diff options
| author | 2023-04-11 21:08:37 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:05:52 -0700 | |
| commit | 921e6dddcc309665cfafdc002f0723cfa533c33d (patch) | |
| tree | 487e373110b1e16639cae7db7a742f7b089b05c8 /src/android | |
| parent | android: Adjustments to card_game (diff) | |
| download | yuzu-921e6dddcc309665cfafdc002f0723cfa533c33d.tar.gz yuzu-921e6dddcc309665cfafdc002f0723cfa533c33d.tar.xz yuzu-921e6dddcc309665cfafdc002f0723cfa533c33d.zip | |
android: Switch from a colored status bar to a custom view
Allows for smoother transitions with the search bar
Diffstat (limited to 'src/android')
4 files changed, 35 insertions, 23 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/OptionsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/OptionsFragment.kt index dac9e67d5..954e52dc6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/OptionsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/OptionsFragment.kt | |||
| @@ -87,13 +87,6 @@ class OptionsFragment : Fragment() { | |||
| 87 | adapter = HomeOptionAdapter(requireActivity() as AppCompatActivity, optionsList) | 87 | adapter = HomeOptionAdapter(requireActivity() as AppCompatActivity, optionsList) |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | requireActivity().window.statusBarColor = ThemeHelper.getColorWithOpacity( | ||
| 91 | MaterialColors.getColor( | ||
| 92 | binding.root, | ||
| 93 | R.attr.colorSurface | ||
| 94 | ), ThemeHelper.SYSTEM_BAR_ALPHA | ||
| 95 | ) | ||
| 96 | |||
| 97 | setInsets() | 90 | setInsets() |
| 98 | } | 91 | } |
| 99 | 92 | ||
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 0c609798b..f542fe2de 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 | |||
| @@ -9,7 +9,6 @@ import android.view.View | |||
| 9 | import android.view.ViewGroup | 9 | import android.view.ViewGroup |
| 10 | import androidx.activity.OnBackPressedCallback | 10 | import androidx.activity.OnBackPressedCallback |
| 11 | import androidx.appcompat.app.AppCompatActivity | 11 | import androidx.appcompat.app.AppCompatActivity |
| 12 | import androidx.core.content.ContextCompat | ||
| 13 | import androidx.core.view.ViewCompat | 12 | import androidx.core.view.ViewCompat |
| 14 | import androidx.core.view.WindowInsetsCompat | 13 | import androidx.core.view.WindowInsetsCompat |
| 15 | import androidx.core.view.updatePadding | 14 | import androidx.core.view.updatePadding |
| @@ -27,7 +26,6 @@ import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager | |||
| 27 | import org.yuzu.yuzu_emu.model.Game | 26 | import org.yuzu.yuzu_emu.model.Game |
| 28 | import org.yuzu.yuzu_emu.model.GamesViewModel | 27 | import org.yuzu.yuzu_emu.model.GamesViewModel |
| 29 | import org.yuzu.yuzu_emu.model.HomeViewModel | 28 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 30 | import org.yuzu.yuzu_emu.utils.ThemeHelper | ||
| 31 | import java.util.Locale | 29 | import java.util.Locale |
| 32 | 30 | ||
| 33 | class GamesFragment : Fragment() { | 31 | class GamesFragment : Fragment() { |
| @@ -145,21 +143,9 @@ class GamesFragment : Fragment() { | |||
| 145 | _binding = null | 143 | _binding = null |
| 146 | } | 144 | } |
| 147 | 145 | ||
| 148 | private fun searchShown() { | 146 | private fun searchShown() = homeViewModel.setNavigationVisible(false) |
| 149 | homeViewModel.setNavigationVisible(false) | ||
| 150 | requireActivity().window.statusBarColor = | ||
| 151 | ContextCompat.getColor(requireContext(), android.R.color.transparent) | ||
| 152 | } | ||
| 153 | 147 | ||
| 154 | private fun searchHidden() { | 148 | private fun searchHidden() = homeViewModel.setNavigationVisible(true) |
| 155 | homeViewModel.setNavigationVisible(true) | ||
| 156 | requireActivity().window.statusBarColor = ThemeHelper.getColorWithOpacity( | ||
| 157 | MaterialColors.getColor( | ||
| 158 | binding.root, | ||
| 159 | R.attr.colorSurface | ||
| 160 | ), ThemeHelper.SYSTEM_BAR_ALPHA | ||
| 161 | ) | ||
| 162 | } | ||
| 163 | 149 | ||
| 164 | private inner class ScoredGame(val score: Double, val item: Game) | 150 | private inner class ScoredGame(val score: Double, val item: Game) |
| 165 | 151 | ||
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 a16ca8529..c7d399846 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 | |||
| @@ -9,6 +9,7 @@ import android.view.ViewGroup.MarginLayoutParams | |||
| 9 | import android.view.animation.PathInterpolator | 9 | import android.view.animation.PathInterpolator |
| 10 | import androidx.activity.viewModels | 10 | import androidx.activity.viewModels |
| 11 | import androidx.appcompat.app.AppCompatActivity | 11 | import androidx.appcompat.app.AppCompatActivity |
| 12 | import androidx.core.content.ContextCompat | ||
| 12 | import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen | 13 | import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen |
| 13 | import androidx.core.view.ViewCompat | 14 | import androidx.core.view.ViewCompat |
| 14 | import androidx.core.view.WindowCompat | 15 | import androidx.core.view.WindowCompat |
| @@ -41,6 +42,8 @@ class MainActivity : AppCompatActivity() { | |||
| 41 | 42 | ||
| 42 | WindowCompat.setDecorFitsSystemWindows(window, false) | 43 | WindowCompat.setDecorFitsSystemWindows(window, false) |
| 43 | 44 | ||
| 45 | window.statusBarColor = | ||
| 46 | ContextCompat.getColor(applicationContext, android.R.color.transparent) | ||
| 44 | ThemeHelper.setNavigationBarColor( | 47 | ThemeHelper.setNavigationBarColor( |
| 45 | this, | 48 | this, |
| 46 | ElevationOverlayProvider(binding.navigationBar.context).compositeOverlay( | 49 | ElevationOverlayProvider(binding.navigationBar.context).compositeOverlay( |
| @@ -80,6 +83,25 @@ class MainActivity : AppCompatActivity() { | |||
| 80 | } | 83 | } |
| 81 | 84 | ||
| 82 | private fun showNavigation(visible: Boolean) { | 85 | private fun showNavigation(visible: Boolean) { |
| 86 | // TODO: This should be decoupled from navigation in the future | ||
| 87 | binding.statusBarShade.animate().apply { | ||
| 88 | if (visible) { | ||
| 89 | binding.statusBarShade.visibility = View.VISIBLE | ||
| 90 | binding.statusBarShade.translationY = binding.statusBarShade.height.toFloat() * -2 | ||
| 91 | duration = 300 | ||
| 92 | translationY(0f) | ||
| 93 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) | ||
| 94 | } else { | ||
| 95 | duration = 300 | ||
| 96 | translationY(binding.navigationBar.height.toFloat() * -2) | ||
| 97 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) | ||
| 98 | } | ||
| 99 | }.withEndAction { | ||
| 100 | if (!visible) { | ||
| 101 | binding.statusBarShade.visibility = View.INVISIBLE | ||
| 102 | } | ||
| 103 | }.start() | ||
| 104 | |||
| 83 | binding.navigationBar.animate().apply { | 105 | binding.navigationBar.animate().apply { |
| 84 | if (visible) { | 106 | if (visible) { |
| 85 | binding.navigationBar.visibility = View.VISIBLE | 107 | binding.navigationBar.visibility = View.VISIBLE |
diff --git a/src/android/app/src/main/res/layout/activity_main.xml b/src/android/app/src/main/res/layout/activity_main.xml index 9002b0642..68a3eae46 100644 --- a/src/android/app/src/main/res/layout/activity_main.xml +++ b/src/android/app/src/main/res/layout/activity_main.xml | |||
| @@ -29,4 +29,15 @@ | |||
| 29 | app:layout_constraintRight_toRightOf="parent" | 29 | app:layout_constraintRight_toRightOf="parent" |
| 30 | app:menu="@menu/menu_navigation" /> | 30 | app:menu="@menu/menu_navigation" /> |
| 31 | 31 | ||
| 32 | <View | ||
| 33 | android:id="@+id/status_bar_shade" | ||
| 34 | android:layout_width="0dp" | ||
| 35 | android:layout_height="1px" | ||
| 36 | android:background="@android:color/transparent" | ||
| 37 | android:clickable="false" | ||
| 38 | android:focusable="false" | ||
| 39 | app:layout_constraintTop_toTopOf="parent" | ||
| 40 | app:layout_constraintEnd_toEndOf="parent" | ||
| 41 | app:layout_constraintStart_toStartOf="parent" /> | ||
| 42 | |||
| 32 | </androidx.constraintlayout.widget.ConstraintLayout> | 43 | </androidx.constraintlayout.widget.ConstraintLayout> |