From 37cb7ae0ec8eda1382965e8dc0301954ea026af2 Mon Sep 17 00:00:00 2001 From: Daniel LaCosse <3759828+daniellacosse@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:23:29 -0500 Subject: [PATCH] pushing this, but let's close for now --- .../java/org/getoutline/pwa/MainActivity.kt | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/x/examples/outline-pwa/android/app/src/main/java/org/getoutline/pwa/MainActivity.kt b/x/examples/outline-pwa/android/app/src/main/java/org/getoutline/pwa/MainActivity.kt index 8fb3bafd..25e84150 100644 --- a/x/examples/outline-pwa/android/app/src/main/java/org/getoutline/pwa/MainActivity.kt +++ b/x/examples/outline-pwa/android/app/src/main/java/org/getoutline/pwa/MainActivity.kt @@ -1,9 +1,13 @@ package org.getoutline.pwa +import android.content.res.Resources +import android.graphics.Color import android.os.Bundle +import android.util.Log +import android.view.View +import androidx.coordinatorlayout.widget.CoordinatorLayout import android.view.WindowInsets import com.getcapacitor.BridgeActivity -import kotlin.math.min import kotlin.math.max import mobileproxy.* @@ -18,6 +22,9 @@ class MainActivity : BridgeActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + Log.d("DIMENSIONS", this.bridge.webView.layoutParams.width.toString()) + Log.d("DIMENSIONS", this.bridge.webView.layoutParams.height.toString()) + if (WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE)) { this.proxy = Mobileproxy.runProxy( "127.0.0.1:0", @@ -49,19 +56,28 @@ class MainActivity : BridgeActivity() { override fun onAttachedToWindow() { super.onAttachedToWindow() - val rootWindowInsets = this.window.decorView.rootView.rootWindowInsets + val rootView = this.window.decorView.rootView + rootView.setBackgroundColor(Color.parseColor("#000000")) + + this.bridge.webView.overScrollMode = View.OVER_SCROLL_NEVER + val rootWindowInsets = rootView.rootWindowInsets if (rootWindowInsets != null) { - val statusBarInsets = rootWindowInsets.getInsets(WindowInsets.Type.statusBars()) + val systemBarInsets = rootWindowInsets.getInsets(WindowInsets.Type.systemBars()) val cutoutInsets = rootWindowInsets.getInsets(WindowInsets.Type.displayCutout()) - val top = max(statusBarInsets.top, cutoutInsets.top).toFloat() - val left = max(statusBarInsets.left, cutoutInsets.left).toFloat() -// val bottom = min(statusBarInsets.bottom, cutoutInsets.bottom).toFloat() -// val right = min(statusBarInsets.right, cutoutInsets.right).toFloat() + val top = max(systemBarInsets.top, cutoutInsets.top) + val left = max(systemBarInsets.left, cutoutInsets.left) + val bottom = max(systemBarInsets.bottom, cutoutInsets.bottom) + val right = max(systemBarInsets.right, cutoutInsets.right) - this.bridge.webView.x = left - this.bridge.webView.y = top + this.bridge.webView.x = left.toFloat() + this.bridge.webView.y = top.toFloat() + + this.bridge.webView.layoutParams = CoordinatorLayout.LayoutParams( + Resources.getSystem().displayMetrics.widthPixels - right - left, + Resources.getSystem().displayMetrics.heightPixels - bottom - top + ) } }