fix #9: disable workaround for adjustResize when it is not needed

This commit is contained in:
Josia Pietsch 2024-08-28 01:00:26 +02:00
parent 31727d63c4
commit 522ca697b6
Signed by: jrpie
GPG key ID: E70B571D66986A2D
2 changed files with 21 additions and 14 deletions

View file

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Rect import android.graphics.Rect
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.widget.Toast import android.widget.Toast
@ -17,12 +18,12 @@ import de.jrpie.android.launcher.PREF_SCREEN_FULLSCREEN
import de.jrpie.android.launcher.R import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.REQUEST_UNINSTALL import de.jrpie.android.launcher.REQUEST_UNINSTALL
import de.jrpie.android.launcher.UIObject import de.jrpie.android.launcher.UIObject
import de.jrpie.android.launcher.databinding.ListBinding
import de.jrpie.android.launcher.getPreferences import de.jrpie.android.launcher.getPreferences
import de.jrpie.android.launcher.list.apps.ListFragmentApps import de.jrpie.android.launcher.list.apps.ListFragmentApps
import de.jrpie.android.launcher.list.other.LauncherAction import de.jrpie.android.launcher.list.other.LauncherAction
import de.jrpie.android.launcher.list.other.ListFragmentOther import de.jrpie.android.launcher.list.other.ListFragmentOther
import de.jrpie.android.launcher.vibrantColor import de.jrpie.android.launcher.vibrantColor
import de.jrpie.android.launcher.databinding.ListBinding
var intendedChoosePause = false // know when to close var intendedChoosePause = false // know when to close
@ -57,15 +58,18 @@ class ListActivity : AppCompatActivity(), UIObject {
LauncherAction.SETTINGS.launch(this@ListActivity) LauncherAction.SETTINGS.launch(this@ListActivity)
} }
// android:windowSoftInputMode="adjustResize" doesn't work in full screen. // android:windowSoftInputMode="adjustResize" doesn't work in full screen.
// workaround from https://stackoverflow.com/a/57623505 // workaround from https://stackoverflow.com/a/57623505
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
this.window.decorView.viewTreeObserver.addOnGlobalLayoutListener { this.window.decorView.viewTreeObserver.addOnGlobalLayoutListener {
val r = Rect() val r = Rect()
window.decorView.getWindowVisibleDisplayFrame(r) window.decorView.getWindowVisibleDisplayFrame(r)
val height: Int = val height: Int =
binding.listContainer.context.resources.displayMetrics.heightPixels binding.listContainer.context.resources.displayMetrics.heightPixels
val diff = height - r.bottom val diff = height - r.bottom
if (diff != 0 && getPreferences(this).getBoolean(PREF_SCREEN_FULLSCREEN, false)) { if (diff != 0 &&
getPreferences(this).getBoolean(PREF_SCREEN_FULLSCREEN, true)) {
if (binding.listContainer.paddingBottom !== diff) { if (binding.listContainer.paddingBottom !== diff) {
binding.listContainer.setPadding(0, 0, 0, diff) binding.listContainer.setPadding(0, 0, 0, diff)
} }
@ -77,6 +81,8 @@ class ListActivity : AppCompatActivity(), UIObject {
} }
} }
}
override fun onStart(){ override fun onStart(){
super<AppCompatActivity>.onStart() super<AppCompatActivity>.onStart()
super<UIObject>.onStart() super<UIObject>.onStart()

View file

@ -7,6 +7,7 @@
android:id="@+id/list_container" android:id="@+id/list_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".list.ListActivity"> tools:context=".list.ListActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout