mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-05 01:47:24 +00:00
App menu now scrolls to the top when opening the app menu with automatic keyboard opening enabled.
This commit is contained in:
parent
d0b0a2eb83
commit
a3c3f9b249
1 changed files with 7 additions and 9 deletions
|
|
@ -16,7 +16,6 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.os.ResultReceiver
|
|
||||||
import android.os.UserHandle
|
import android.os.UserHandle
|
||||||
import android.provider.AlarmClock
|
import android.provider.AlarmClock
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
|
|
@ -121,6 +120,8 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
|
|
||||||
var returnAllowed = true
|
var returnAllowed = true
|
||||||
|
|
||||||
|
private var isInitialOpen = false
|
||||||
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
@ -279,17 +280,11 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
animations.showApps(binding.homeView, binding.appView)
|
animations.showApps(binding.homeView, binding.appView)
|
||||||
animations.backgroundIn(this@MainActivity)
|
animations.backgroundIn(this@MainActivity)
|
||||||
if (sharedPreferenceManager.isAutoKeyboardEnabled()) {
|
if (sharedPreferenceManager.isAutoKeyboardEnabled()) {
|
||||||
val keyboardReceiver = object : ResultReceiver(null) {
|
isInitialOpen = true
|
||||||
override fun onReceiveResult(resultCode: Int, resultData: Bundle?) {
|
|
||||||
super.onReceiveResult(resultCode, resultData)
|
|
||||||
appRecycler.scrollToPosition(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
val imm =
|
val imm =
|
||||||
getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
searchView.requestFocus()
|
searchView.requestFocus()
|
||||||
imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT, keyboardReceiver)
|
imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -836,6 +831,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
if (bottom - top > oldBottom - oldTop) {
|
if (bottom - top > oldBottom - oldTop) {
|
||||||
// If keyboard is closed, remove cursor from the search bar
|
// If keyboard is closed, remove cursor from the search bar
|
||||||
searchView.clearFocus()
|
searchView.clearFocus()
|
||||||
|
} else if (bottom - top < oldBottom - oldTop && isInitialOpen) {
|
||||||
|
isInitialOpen = false
|
||||||
|
appRecycler.scrollToPosition(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue