From 522ca697b6b04f09a614c4fc469adb2dc57e36cb Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Wed, 28 Aug 2024 01:00:26 +0200 Subject: [PATCH] fix #9: disable workaround for adjustResize when it is not needed --- .../android/launcher/list/ListActivity.kt | 34 +++++++++++-------- app/src/main/res/layout/list.xml | 1 + 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt b/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt index d1afd08..0aef9c1 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt @@ -4,6 +4,7 @@ import android.app.Activity import android.content.Context import android.content.Intent import android.graphics.Rect +import android.os.Build import android.os.Bundle import android.view.View 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.REQUEST_UNINSTALL import de.jrpie.android.launcher.UIObject +import de.jrpie.android.launcher.databinding.ListBinding import de.jrpie.android.launcher.getPreferences import de.jrpie.android.launcher.list.apps.ListFragmentApps import de.jrpie.android.launcher.list.other.LauncherAction import de.jrpie.android.launcher.list.other.ListFragmentOther import de.jrpie.android.launcher.vibrantColor -import de.jrpie.android.launcher.databinding.ListBinding var intendedChoosePause = false // know when to close @@ -57,24 +58,29 @@ class ListActivity : AppCompatActivity(), UIObject { LauncherAction.SETTINGS.launch(this@ListActivity) } + // android:windowSoftInputMode="adjustResize" doesn't work in full screen. // workaround from https://stackoverflow.com/a/57623505 - this.window.decorView.viewTreeObserver.addOnGlobalLayoutListener { - val r = Rect() - window.decorView.getWindowVisibleDisplayFrame(r) - val height: Int = - binding.listContainer.context.resources.displayMetrics.heightPixels - val diff = height - r.bottom - if (diff != 0 && getPreferences(this).getBoolean(PREF_SCREEN_FULLSCREEN, false)) { - if (binding.listContainer.paddingBottom !== diff) { - binding.listContainer.setPadding(0, 0, 0, diff) - } - } else { - if (binding.listContainer.paddingBottom !== 0) { - binding.listContainer.setPadding(0, 0, 0, 0) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { + this.window.decorView.viewTreeObserver.addOnGlobalLayoutListener { + val r = Rect() + window.decorView.getWindowVisibleDisplayFrame(r) + val height: Int = + binding.listContainer.context.resources.displayMetrics.heightPixels + val diff = height - r.bottom + if (diff != 0 && + getPreferences(this).getBoolean(PREF_SCREEN_FULLSCREEN, true)) { + if (binding.listContainer.paddingBottom !== diff) { + binding.listContainer.setPadding(0, 0, 0, diff) + } + } else { + if (binding.listContainer.paddingBottom !== 0) { + binding.listContainer.setPadding(0, 0, 0, 0) + } } } } + } override fun onStart(){ diff --git a/app/src/main/res/layout/list.xml b/app/src/main/res/layout/list.xml index be14f3f..109aa35 100644 --- a/app/src/main/res/layout/list.xml +++ b/app/src/main/res/layout/list.xml @@ -7,6 +7,7 @@ android:id="@+id/list_container" android:layout_width="match_parent" android:layout_height="match_parent" + android:fitsSystemWindows="true" tools:context=".list.ListActivity">