mirror of
https://github.com/jrpie/Launcher.git
synced 2025-04-18 18:00:50 +02:00
This commit is contained in:
parent
4f795289d5
commit
22633bdac3
1 changed files with 24 additions and 21 deletions
|
@ -37,7 +37,7 @@ import java.util.Locale
|
||||||
class HomeActivity : UIObject, AppCompatActivity() {
|
class HomeActivity : UIObject, AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: HomeBinding
|
private lateinit var binding: HomeBinding
|
||||||
private lateinit var touchGestureDetector: TouchGestureDetector
|
private var touchGestureDetector: TouchGestureDetector? = null
|
||||||
|
|
||||||
private var sharedPreferencesListener =
|
private var sharedPreferencesListener =
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey ->
|
SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey ->
|
||||||
|
@ -56,29 +56,12 @@ class HomeActivity : UIObject, AppCompatActivity() {
|
||||||
super<AppCompatActivity>.onCreate(savedInstanceState)
|
super<AppCompatActivity>.onCreate(savedInstanceState)
|
||||||
super<UIObject>.onCreate()
|
super<UIObject>.onCreate()
|
||||||
|
|
||||||
touchGestureDetector = TouchGestureDetector(
|
|
||||||
this, 0, 0,
|
|
||||||
LauncherPreferences.enabled_gestures().edgeSwipeEdgeWidth() / 100f
|
|
||||||
)
|
|
||||||
touchGestureDetector.updateScreenSize(windowManager)
|
|
||||||
|
|
||||||
// Initialise layout
|
// Initialise layout
|
||||||
binding = HomeBinding.inflate(layoutInflater)
|
binding = HomeBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
binding.root.setOnApplyWindowInsetsListener { _, windowInsets ->
|
|
||||||
@Suppress("deprecation") // required to support API 29
|
|
||||||
val insets = windowInsets.systemGestureInsets
|
|
||||||
touchGestureDetector.setSystemGestureInsets(insets)
|
|
||||||
|
|
||||||
windowInsets
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handle back key / gesture on Android 13+, cf. onKeyDown()
|
// Handle back key / gesture on Android 13+, cf. onKeyDown()
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
@ -94,7 +77,7 @@ class HomeActivity : UIObject, AppCompatActivity() {
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
touchGestureDetector.updateScreenSize(windowManager)
|
touchGestureDetector?.updateScreenSize(windowManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -188,8 +171,28 @@ class HomeActivity : UIObject, AppCompatActivity() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
touchGestureDetector.edgeWidth =
|
/* This should be initialized in onCreate()
|
||||||
|
However on some devices there seems to be a bug where the touchGestureDetector
|
||||||
|
is not working properly after resuming the app.
|
||||||
|
Reinitializing the touchGestureDetector every time the app is resumed might help to fix that.
|
||||||
|
(see issue #138)
|
||||||
|
*/
|
||||||
|
touchGestureDetector = TouchGestureDetector(
|
||||||
|
this, 0, 0,
|
||||||
LauncherPreferences.enabled_gestures().edgeSwipeEdgeWidth() / 100f
|
LauncherPreferences.enabled_gestures().edgeSwipeEdgeWidth() / 100f
|
||||||
|
).also {
|
||||||
|
it.updateScreenSize(windowManager)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
binding.root.setOnApplyWindowInsetsListener { _, windowInsets ->
|
||||||
|
@Suppress("deprecation") // required to support API 29
|
||||||
|
val insets = windowInsets.systemGestureInsets
|
||||||
|
touchGestureDetector?.setSystemGestureInsets(insets)
|
||||||
|
|
||||||
|
windowInsets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
initClock()
|
initClock()
|
||||||
updateSettingsFallbackButtonVisibility()
|
updateSettingsFallbackButtonVisibility()
|
||||||
|
@ -230,7 +233,7 @@ class HomeActivity : UIObject, AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
touchGestureDetector.onTouchEvent(event)
|
touchGestureDetector?.onTouchEvent(event)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue