From a18fd2dadcd979071f0116fe354d91507bac4db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lenclud?= Date: Fri, 10 Apr 2020 18:10:12 +0200 Subject: [PATCH] Fixed:#23 broken browser tool bar layout when starting app in landscape. Also fixed are the broken drawers after rotation. Adding some configuration option to have Android Studio use more memory but I guess we could remove that at some point. --- app/build.gradle | 4 ++ .../browser/activity/BrowserActivity.kt | 37 +++++++++---------- gradle.properties | 27 +++++++++++--- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d71b822c5..da7c550a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,6 +16,10 @@ android { vectorDrawables.useSupportLibrary = true } + dexOptions { + javaMaxHeapSize "8g" + } + buildTypes { debug { multiDexEnabled true diff --git a/app/src/main/java/acr/browser/lightning/browser/activity/BrowserActivity.kt b/app/src/main/java/acr/browser/lightning/browser/activity/BrowserActivity.kt index bc6237a94..c0a7bd128 100644 --- a/app/src/main/java/acr/browser/lightning/browser/activity/BrowserActivity.kt +++ b/app/src/main/java/acr/browser/lightning/browser/activity/BrowserActivity.kt @@ -79,6 +79,7 @@ import androidx.core.content.ContextCompat import androidx.core.graphics.drawable.toBitmap import androidx.core.net.toUri import androidx.core.view.GravityCompat +import androidx.core.view.doOnPreDraw import androidx.customview.widget.ViewDragHelper import androidx.drawerlayout.widget.DrawerLayout import androidx.palette.graphics.Palette @@ -241,7 +242,7 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr } private fun initialize(savedInstanceState: Bundle?) { - initializeToolbarHeight(resources.configuration) + //initializeToolbarHeight(resources.configuration) setSupportActionBar(toolbar) val actionBar = requireNotNull(supportActionBar) @@ -514,7 +515,7 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr drawerOpening = false //TODO: make this a settings option? - if (isFlavorSlions) return; // Drawers remain locked for tha flavor + if (isFlavorSlions) return; // Drawers remain locked for that flavor val tabsDrawer = getTabDrawer() val bookmarksDrawer = getBookmarkDrawer() @@ -592,8 +593,8 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr } } - private fun initFullScreen() { - isFullScreen = if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { + private fun initFullScreen(configuration: Configuration) { + isFullScreen = if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { userPreferences.hideToolBarInPortrait } else { @@ -606,7 +607,8 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr */ private fun setupToolBar(configuration: Configuration) { - initFullScreen() + initFullScreen(configuration) + initializeToolbarHeight(configuration) if (isFullScreen) { showActionBar() @@ -620,19 +622,15 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr putToolbarInRoot() } + setToolbarColor() + setFullscreenIfNeeded(resources.configuration) } private fun initializePreferences() { - initFullScreen() - - setToolbarColor() - // TODO layout transition causing memory leak // content_frame.setLayoutTransition(new LayoutTransition()); - setFullscreenIfNeeded() - val currentSearchEngine = searchEngineProvider.provideSearchEngine() searchText = currentSearchEngine.queryUrl @@ -1093,14 +1091,13 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr logger.log(TAG, "onConfigurationChanged") - // TODO: why did we not have to pass the new config in there? - setFullscreenIfNeeded() - + setFullscreenIfNeeded(newConfig) setupToolBar(newConfig) invalidateOptionsMenu() - initializeToolbarHeight(newConfig) - ui_layout.doOnLayout {setNavigationDrawerWidth()} + + // First close drawers then set width again + closeDrawers{drawer_layout.doOnPreDraw {setNavigationDrawerWidth()}} } private fun initializeToolbarHeight(configuration: Configuration) = @@ -1219,6 +1216,8 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr tabsManager.resumeAll() initializePreferences() + setupToolBar(resources.configuration) + } /** @@ -1640,7 +1639,7 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr logger.log(TAG, "WebView is not allowed to keep the screen on") } - setFullscreenIfNeeded() + setFullscreenIfNeeded(resources.configuration) if (fullscreenContainerView != null) { val parent = fullscreenContainerView?.parent as ViewGroup parent.removeView(fullscreenContainerView) @@ -1721,8 +1720,8 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr /** * Hide the status bar according to orientation and user preferences */ - private fun setFullscreenIfNeeded() { - if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { + private fun setFullscreenIfNeeded(configuration: Configuration) { + if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { setFullscreen( userPreferences.hideStatusBarInPortrait, false) } else { diff --git a/gradle.properties b/gradle.properties index 8362cfff3..fc11eb217 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,23 @@ -kotlin.incremental=false -android.useAndroidX=true -android.enableJetifier=true - -# TODO: Remove when I2P 0.9.41 or later is available via maven +## For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +#Fri Apr 10 15:54:50 CEST 2020 +ANDROID_BUILD_SDK_VERSION=28 I2P_VERSION=0.9.41 ANDROID_BUILD_TARGET_SDK_VERSION=28 -ANDROID_BUILD_SDK_VERSION=28 +android.enableJetifier=true +org.gradle.daemon=true +org.gradle.configureondemand=true +org.gradle.jvmargs=-Xmx4096M -Dkotlin.daemon.jvm.options\="-Xmx4096M" -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +android.useAndroidX=true +kotlin.incremental=false +