From a07c8a2cb3c98643338c9273ba688db62b72952d Mon Sep 17 00:00:00 2001 From: ottoptj Date: Mon, 16 Sep 2024 16:05:56 +0300 Subject: [PATCH] Started work on scrolling to top even with automatic keyboard opening --- app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index 07006fa..ef1c299 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -16,6 +16,7 @@ import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper +import android.os.ResultReceiver import android.os.UserHandle import android.provider.AlarmClock import android.provider.ContactsContract @@ -278,10 +279,17 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh animations.showApps(binding.homeView, binding.appView) animations.backgroundIn(this@MainActivity) if (sharedPreferenceManager.isAutoKeyboardEnabled()) { + val keyboardReceiver = object : ResultReceiver(null) { + override fun onReceiveResult(resultCode: Int, resultData: Bundle?) { + super.onReceiveResult(resultCode, resultData) + appRecycler.scrollToPosition(0) + } + + } val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager searchView.requestFocus() - imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT) + imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT, keyboardReceiver) } }