Skip to content

Commit

Permalink
Fixed:#23 broken browser tool bar layout when starting app in landscape.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Slion committed Apr 10, 2020
1 parent c235859 commit a18fd2d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 25 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Expand Up @@ -16,6 +16,10 @@ android {
vectorDrawables.useSupportLibrary = true
}

dexOptions {
javaMaxHeapSize "8g"
}

buildTypes {
debug {
multiDexEnabled true
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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 {
Expand All @@ -606,7 +607,8 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr
*/
private fun setupToolBar(configuration: Configuration) {

initFullScreen()
initFullScreen(configuration)
initializeToolbarHeight(configuration)

if (isFullScreen) {
showActionBar()
Expand All @@ -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

Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -1219,6 +1216,8 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr
tabsManager.resumeAll()
initializePreferences()

setupToolBar(resources.configuration)

}

/**
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
27 changes: 21 additions & 6 deletions 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

0 comments on commit a18fd2d

Please sign in to comment.