Rework exit logic
- If drawer is open, always close it first (existing) - If drawer is closed, quick exit is enabled, close the app (only on apps, games or updates fragment) - If drawer is closed, quick exit is disabled, ask to press back twice (existing) Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -213,12 +213,11 @@ class MainActivity : BaseActivity() {
|
||||
return navController.navigateUp()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onBackPressed() {
|
||||
if (B.drawerLayout.isDrawerOpen(GravityCompat.START)) {
|
||||
B.drawerLayout.close()
|
||||
} else if (!navController.navigateUp()) {
|
||||
if (!B.drawerLayout.isDrawerOpen(GravityCompat.START)) {
|
||||
if (Preferences.getBoolean(this, Preferences.PREFERENCE_QUICK_EXIT)) {
|
||||
super.onBackPressed()
|
||||
this.finish()
|
||||
} else {
|
||||
if (lastBackPressed + 1000 > System.currentTimeMillis()) {
|
||||
super.onBackPressed()
|
||||
@@ -227,6 +226,8 @@ class MainActivity : BaseActivity() {
|
||||
Toast.makeText(this, getString(R.string.toast_double_press_to_exit), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
B.drawerLayout.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user