Skip to content

Commit

Permalink
updated binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
KojiNakamaru committed Nov 10, 2023
1 parent 1177ce1 commit 2f8db15
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 60 deletions.
34 changes: 4 additions & 30 deletions dist/package-nofragment/Assets/Plugins/WebViewObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,39 +85,14 @@ public class WebViewObject : MonoBehaviour
#elif UNITY_ANDROID
AndroidJavaObject webView;

static int sWindowVisibleDisplayFrameWidth;
static int sWindowVisibleDisplayFrameHeight;
bool mVisibility;
int mKeyboardVisibleHeight;
int mWindowVisibleDisplayFrameHeight;
float mResumedTimestamp;
#if UNITYWEBVIEW_ANDROID_ENABLE_NAVIGATOR_ONLINE
float androidNetworkReachabilityCheckT0 = -1.0f;
NetworkReachability? androidNetworkReachability0 = null;
#endif

[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
using(AndroidJavaClass UnityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
AndroidJavaObject View = UnityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer").Call<AndroidJavaObject>("getView");
using(AndroidJavaObject Rct = new AndroidJavaObject("android.graphics.Rect"))
{
View.Call("getWindowVisibleDisplayFrame", Rct);
sWindowVisibleDisplayFrameWidth = Rct.Call<int>("width");
sWindowVisibleDisplayFrameHeight = Rct.Call<int>("height");
if (sWindowVisibleDisplayFrameWidth > sWindowVisibleDisplayFrameHeight)
{
// store values in portrait mode.
var tmp = sWindowVisibleDisplayFrameWidth;
sWindowVisibleDisplayFrameWidth = sWindowVisibleDisplayFrameHeight;
sWindowVisibleDisplayFrameHeight = tmp;
}
}
}
}

void OnApplicationPause(bool paused)
{
this.paused = paused;
Expand Down Expand Up @@ -157,10 +132,6 @@ void Update()
return;
if (webView == null)
return;
mWindowVisibleDisplayFrameHeight
= (Screen.width < Screen.height)
? sWindowVisibleDisplayFrameHeight
: sWindowVisibleDisplayFrameWidth;
#if UNITYWEBVIEW_ANDROID_ENABLE_NAVIGATOR_ONLINE
var t = Time.time;
if (t - 1.0f >= androidNetworkReachabilityCheckT0)
Expand Down Expand Up @@ -397,8 +368,11 @@ public int AdjustBottomMargin(int bottom)
AndroidJavaObject View = UnityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer").Call<AndroidJavaObject>("getView");
using(AndroidJavaObject Rct = new AndroidJavaObject("android.graphics.Rect"))
{
View.Call("getDrawingRect", Rct);
int h0 = Rct.Call<int>("height");
View.Call("getWindowVisibleDisplayFrame", Rct);
keyboardHeight = mWindowVisibleDisplayFrameHeight - Rct.Call<int>("height");
int h1 = Rct.Call<int>("height");
keyboardHeight = h0 - h1;
}
}
return (bottom > keyboardHeight) ? bottom : keyboardHeight;
Expand Down
34 changes: 4 additions & 30 deletions dist/package/Assets/Plugins/WebViewObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,39 +85,14 @@ public class WebViewObject : MonoBehaviour
#elif UNITY_ANDROID
AndroidJavaObject webView;

static int sWindowVisibleDisplayFrameWidth;
static int sWindowVisibleDisplayFrameHeight;
bool mVisibility;
int mKeyboardVisibleHeight;
int mWindowVisibleDisplayFrameHeight;
float mResumedTimestamp;
#if UNITYWEBVIEW_ANDROID_ENABLE_NAVIGATOR_ONLINE
float androidNetworkReachabilityCheckT0 = -1.0f;
NetworkReachability? androidNetworkReachability0 = null;
#endif

[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
using(AndroidJavaClass UnityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
AndroidJavaObject View = UnityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer").Call<AndroidJavaObject>("getView");
using(AndroidJavaObject Rct = new AndroidJavaObject("android.graphics.Rect"))
{
View.Call("getWindowVisibleDisplayFrame", Rct);
sWindowVisibleDisplayFrameWidth = Rct.Call<int>("width");
sWindowVisibleDisplayFrameHeight = Rct.Call<int>("height");
if (sWindowVisibleDisplayFrameWidth > sWindowVisibleDisplayFrameHeight)
{
// store values in portrait mode.
var tmp = sWindowVisibleDisplayFrameWidth;
sWindowVisibleDisplayFrameWidth = sWindowVisibleDisplayFrameHeight;
sWindowVisibleDisplayFrameHeight = tmp;
}
}
}
}

void OnApplicationPause(bool paused)
{
this.paused = paused;
Expand Down Expand Up @@ -157,10 +132,6 @@ void Update()
return;
if (webView == null)
return;
mWindowVisibleDisplayFrameHeight
= (Screen.width < Screen.height)
? sWindowVisibleDisplayFrameHeight
: sWindowVisibleDisplayFrameWidth;
#if UNITYWEBVIEW_ANDROID_ENABLE_NAVIGATOR_ONLINE
var t = Time.time;
if (t - 1.0f >= androidNetworkReachabilityCheckT0)
Expand Down Expand Up @@ -397,8 +368,11 @@ public int AdjustBottomMargin(int bottom)
AndroidJavaObject View = UnityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer").Call<AndroidJavaObject>("getView");
using(AndroidJavaObject Rct = new AndroidJavaObject("android.graphics.Rect"))
{
View.Call("getDrawingRect", Rct);
int h0 = Rct.Call<int>("height");
View.Call("getWindowVisibleDisplayFrame", Rct);
keyboardHeight = mWindowVisibleDisplayFrameHeight - Rct.Call<int>("height");
int h1 = Rct.Call<int>("height");
keyboardHeight = h0 - h1;
}
}
return (bottom > keyboardHeight) ? bottom : keyboardHeight;
Expand Down
Binary file modified dist/unity-webview-nofragment.unitypackage
Binary file not shown.
Binary file modified dist/unity-webview-nofragment.zip
Binary file not shown.
Binary file modified dist/unity-webview.unitypackage
Binary file not shown.
Binary file modified dist/unity-webview.zip
Binary file not shown.

0 comments on commit 2f8db15

Please sign in to comment.