diff options
| author | 2023-04-19 02:52:38 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:05:52 -0700 | |
| commit | 9c9d9131b5834d2551ee761eff8d4673946a4a8a (patch) | |
| tree | 718745e2cf3d80ee585988171934ce9fede7053b /src | |
| parent | android: Enable code minification (diff) | |
| download | yuzu-9c9d9131b5834d2551ee761eff8d4673946a4a8a.tar.gz yuzu-9c9d9131b5834d2551ee761eff8d4673946a4a8a.tar.xz yuzu-9c9d9131b5834d2551ee761eff8d4673946a4a8a.zip | |
android: Decouple status bar shade from navigation bar visibility
Diffstat (limited to 'src')
3 files changed, 34 insertions, 14 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt index 74f12429c..b3f4188cd 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt | |||
| @@ -8,10 +8,20 @@ class HomeViewModel : ViewModel() { | |||
| 8 | private val _navigationVisible = MutableLiveData(true) | 8 | private val _navigationVisible = MutableLiveData(true) |
| 9 | val navigationVisible: LiveData<Boolean> get() = _navigationVisible | 9 | val navigationVisible: LiveData<Boolean> get() = _navigationVisible |
| 10 | 10 | ||
| 11 | fun setNavigationVisible(visible: Boolean) { | 11 | private val _statusBarShadeVisible = MutableLiveData(true) |
| 12 | val statusBarShadeVisible: LiveData<Boolean> get() = _statusBarShadeVisible | ||
| 13 | |||
| 14 | fun setNavigationVisibility(visible: Boolean) { | ||
| 12 | if (_navigationVisible.value == visible) { | 15 | if (_navigationVisible.value == visible) { |
| 13 | return | 16 | return |
| 14 | } | 17 | } |
| 15 | _navigationVisible.value = visible | 18 | _navigationVisible.value = visible |
| 16 | } | 19 | } |
| 20 | |||
| 21 | fun setStatusBarShadeVisibility(visible: Boolean) { | ||
| 22 | if (_statusBarShadeVisible.value == visible) { | ||
| 23 | return | ||
| 24 | } | ||
| 25 | _statusBarShadeVisible.value = visible | ||
| 26 | } | ||
| 17 | } | 27 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt index f542fe2de..c6bbc3c65 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt | |||
| @@ -143,9 +143,15 @@ class GamesFragment : Fragment() { | |||
| 143 | _binding = null | 143 | _binding = null |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | private fun searchShown() = homeViewModel.setNavigationVisible(false) | 146 | private fun searchShown() { |
| 147 | homeViewModel.setNavigationVisibility(false) | ||
| 148 | homeViewModel.setStatusBarShadeVisibility(false) | ||
| 149 | } | ||
| 147 | 150 | ||
| 148 | private fun searchHidden() = homeViewModel.setNavigationVisible(true) | 151 | private fun searchHidden() { |
| 152 | homeViewModel.setNavigationVisibility(true) | ||
| 153 | homeViewModel.setStatusBarShadeVisibility(true) | ||
| 154 | } | ||
| 149 | 155 | ||
| 150 | private inner class ScoredGame(val score: Double, val item: Game) | 156 | private inner class ScoredGame(val score: Double, val item: Game) |
| 151 | 157 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index c7d399846..e47866030 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt | |||
| @@ -75,6 +75,9 @@ class MainActivity : AppCompatActivity() { | |||
| 75 | homeViewModel.navigationVisible.observe(this) { visible -> | 75 | homeViewModel.navigationVisible.observe(this) { visible -> |
| 76 | showNavigation(visible) | 76 | showNavigation(visible) |
| 77 | } | 77 | } |
| 78 | homeViewModel.statusBarShadeVisible.observe(this) { visible -> | ||
| 79 | showStatusBarShade(visible) | ||
| 80 | } | ||
| 78 | 81 | ||
| 79 | // Dismiss previous notifications (should not happen unless a crash occurred) | 82 | // Dismiss previous notifications (should not happen unless a crash occurred) |
| 80 | EmulationActivity.tryDismissRunningNotification(this) | 83 | EmulationActivity.tryDismissRunningNotification(this) |
| @@ -83,40 +86,41 @@ class MainActivity : AppCompatActivity() { | |||
| 83 | } | 86 | } |
| 84 | 87 | ||
| 85 | private fun showNavigation(visible: Boolean) { | 88 | private fun showNavigation(visible: Boolean) { |
| 86 | // TODO: This should be decoupled from navigation in the future | 89 | binding.navigationBar.animate().apply { |
| 87 | binding.statusBarShade.animate().apply { | ||
| 88 | if (visible) { | 90 | if (visible) { |
| 89 | binding.statusBarShade.visibility = View.VISIBLE | 91 | binding.navigationBar.visibility = View.VISIBLE |
| 90 | binding.statusBarShade.translationY = binding.statusBarShade.height.toFloat() * -2 | 92 | binding.navigationBar.translationY = binding.navigationBar.height.toFloat() * 2 |
| 91 | duration = 300 | 93 | duration = 300 |
| 92 | translationY(0f) | 94 | translationY(0f) |
| 93 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) | 95 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) |
| 94 | } else { | 96 | } else { |
| 95 | duration = 300 | 97 | duration = 300 |
| 96 | translationY(binding.navigationBar.height.toFloat() * -2) | 98 | translationY(binding.navigationBar.height.toFloat() * 2) |
| 97 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) | 99 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) |
| 98 | } | 100 | } |
| 99 | }.withEndAction { | 101 | }.withEndAction { |
| 100 | if (!visible) { | 102 | if (!visible) { |
| 101 | binding.statusBarShade.visibility = View.INVISIBLE | 103 | binding.navigationBar.visibility = View.INVISIBLE |
| 102 | } | 104 | } |
| 103 | }.start() | 105 | }.start() |
| 106 | } | ||
| 104 | 107 | ||
| 105 | binding.navigationBar.animate().apply { | 108 | private fun showStatusBarShade(visible: Boolean) { |
| 109 | binding.statusBarShade.animate().apply { | ||
| 106 | if (visible) { | 110 | if (visible) { |
| 107 | binding.navigationBar.visibility = View.VISIBLE | 111 | binding.statusBarShade.visibility = View.VISIBLE |
| 108 | binding.navigationBar.translationY = binding.navigationBar.height.toFloat() * 2 | 112 | binding.statusBarShade.translationY = binding.statusBarShade.height.toFloat() * -2 |
| 109 | duration = 300 | 113 | duration = 300 |
| 110 | translationY(0f) | 114 | translationY(0f) |
| 111 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) | 115 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) |
| 112 | } else { | 116 | } else { |
| 113 | duration = 300 | 117 | duration = 300 |
| 114 | translationY(binding.navigationBar.height.toFloat() * 2) | 118 | translationY(binding.navigationBar.height.toFloat() * -2) |
| 115 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) | 119 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) |
| 116 | } | 120 | } |
| 117 | }.withEndAction { | 121 | }.withEndAction { |
| 118 | if (!visible) { | 122 | if (!visible) { |
| 119 | binding.navigationBar.visibility = View.INVISIBLE | 123 | binding.statusBarShade.visibility = View.INVISIBLE |
| 120 | } | 124 | } |
| 121 | }.start() | 125 | }.start() |
| 122 | } | 126 | } |