diff options
| author | 2023-05-22 20:03:18 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:06:03 -0700 | |
| commit | 7812de4adeb9530fa5591d3d6e42cd610e5231cc (patch) | |
| tree | 5895d5cbd5cd119b1c2c6206aa78dda2ea39785a /src/android | |
| parent | android: Add option for touch overlay haptics (diff) | |
| download | yuzu-7812de4adeb9530fa5591d3d6e42cd610e5231cc.tar.gz yuzu-7812de4adeb9530fa5591d3d6e42cd610e5231cc.tar.xz yuzu-7812de4adeb9530fa5591d3d6e42cd610e5231cc.zip | |
android: Remove deprecated use of onBackPressed()
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt index 5c6f7eec5..783122860 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt | |||
| @@ -15,6 +15,7 @@ import androidx.core.view.ViewCompat | |||
| 15 | import androidx.core.view.WindowCompat | 15 | import androidx.core.view.WindowCompat |
| 16 | import androidx.core.view.WindowInsetsCompat | 16 | import androidx.core.view.WindowInsetsCompat |
| 17 | import android.view.ViewGroup.MarginLayoutParams | 17 | import android.view.ViewGroup.MarginLayoutParams |
| 18 | import androidx.activity.OnBackPressedCallback | ||
| 18 | import androidx.core.view.updatePadding | 19 | import androidx.core.view.updatePadding |
| 19 | import com.google.android.material.color.MaterialColors | 20 | import com.google.android.material.color.MaterialColors |
| 20 | import org.yuzu.yuzu_emu.NativeLibrary | 21 | import org.yuzu.yuzu_emu.NativeLibrary |
| @@ -70,14 +71,28 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView { | |||
| 70 | ) | 71 | ) |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 74 | onBackPressedDispatcher.addCallback( | ||
| 75 | this, | ||
| 76 | object : OnBackPressedCallback(true) { | ||
| 77 | override fun handleOnBackPressed() = navigateBack() | ||
| 78 | }) | ||
| 79 | |||
| 73 | setInsets() | 80 | setInsets() |
| 74 | } | 81 | } |
| 75 | 82 | ||
| 76 | override fun onSupportNavigateUp(): Boolean { | 83 | override fun onSupportNavigateUp(): Boolean { |
| 77 | onBackPressed() | 84 | navigateBack() |
| 78 | return true | 85 | return true |
| 79 | } | 86 | } |
| 80 | 87 | ||
| 88 | private fun navigateBack() { | ||
| 89 | if (supportFragmentManager.backStackEntryCount > 0) { | ||
| 90 | supportFragmentManager.popBackStack() | ||
| 91 | } else { | ||
| 92 | finish() | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 81 | override fun onCreateOptionsMenu(menu: Menu): Boolean { | 96 | override fun onCreateOptionsMenu(menu: Menu): Boolean { |
| 82 | val inflater = menuInflater | 97 | val inflater = menuInflater |
| 83 | inflater.inflate(R.menu.menu_settings, menu) | 98 | inflater.inflate(R.menu.menu_settings, menu) |