diff options
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt | 28 | ||||
| -rw-r--r-- | src/android/app/src/main/res/layout-w600dp/fragment_setup.xml | 2 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt index 35c84699b..7c8a37855 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt | |||
| @@ -13,6 +13,8 @@ import androidx.appcompat.app.AppCompatActivity | |||
| 13 | import androidx.core.content.ContextCompat | 13 | import androidx.core.content.ContextCompat |
| 14 | import androidx.core.view.ViewCompat | 14 | import androidx.core.view.ViewCompat |
| 15 | import androidx.core.view.WindowInsetsCompat | 15 | import androidx.core.view.WindowInsetsCompat |
| 16 | import androidx.core.view.isVisible | ||
| 17 | import androidx.core.view.updatePadding | ||
| 16 | import androidx.fragment.app.Fragment | 18 | import androidx.fragment.app.Fragment |
| 17 | import androidx.fragment.app.activityViewModels | 19 | import androidx.fragment.app.activityViewModels |
| 18 | import androidx.navigation.findNavController | 20 | import androidx.navigation.findNavController |
| @@ -36,6 +38,11 @@ class SetupFragment : Fragment() { | |||
| 36 | 38 | ||
| 37 | private lateinit var mainActivity: MainActivity | 39 | private lateinit var mainActivity: MainActivity |
| 38 | 40 | ||
| 41 | companion object { | ||
| 42 | const val KEY_NEXT_VISIBILITY = "NextButtonVisibility" | ||
| 43 | const val KEY_BACK_VISIBILITY = "BackButtonVisibility" | ||
| 44 | } | ||
| 45 | |||
| 39 | override fun onCreate(savedInstanceState: Bundle?) { | 46 | override fun onCreate(savedInstanceState: Bundle?) { |
| 40 | super.onCreate(savedInstanceState) | 47 | super.onCreate(savedInstanceState) |
| 41 | exitTransition = MaterialFadeThrough() | 48 | exitTransition = MaterialFadeThrough() |
| @@ -134,14 +141,27 @@ class SetupFragment : Fragment() { | |||
| 134 | binding.buttonNext.setOnClickListener { pageForward() } | 141 | binding.buttonNext.setOnClickListener { pageForward() } |
| 135 | binding.buttonBack.setOnClickListener { pageBackward() } | 142 | binding.buttonBack.setOnClickListener { pageBackward() } |
| 136 | 143 | ||
| 137 | if (binding.viewPager2.currentItem == 0) { | 144 | if (savedInstanceState != null) { |
| 138 | binding.buttonNext.visibility = View.INVISIBLE | 145 | val nextIsVisible = savedInstanceState.getBoolean(KEY_NEXT_VISIBILITY) |
| 139 | binding.buttonBack.visibility = View.INVISIBLE | 146 | val backIsVisible = savedInstanceState.getBoolean(KEY_BACK_VISIBILITY) |
| 147 | |||
| 148 | if (nextIsVisible) { | ||
| 149 | binding.buttonNext.visibility = View.VISIBLE | ||
| 150 | } | ||
| 151 | if (backIsVisible) { | ||
| 152 | binding.buttonBack.visibility = View.VISIBLE | ||
| 153 | } | ||
| 140 | } | 154 | } |
| 141 | 155 | ||
| 142 | setInsets() | 156 | setInsets() |
| 143 | } | 157 | } |
| 144 | 158 | ||
| 159 | override fun onSaveInstanceState(outState: Bundle) { | ||
| 160 | super.onSaveInstanceState(outState) | ||
| 161 | outState.putBoolean(KEY_NEXT_VISIBILITY, binding.buttonNext.isVisible) | ||
| 162 | outState.putBoolean(KEY_BACK_VISIBILITY, binding.buttonBack.isVisible) | ||
| 163 | } | ||
| 164 | |||
| 145 | override fun onDestroyView() { | 165 | override fun onDestroyView() { |
| 146 | super.onDestroyView() | 166 | super.onDestroyView() |
| 147 | _binding = null | 167 | _binding = null |
| @@ -190,7 +210,7 @@ class SetupFragment : Fragment() { | |||
| 190 | } | 210 | } |
| 191 | 211 | ||
| 192 | private fun setInsets() = | 212 | private fun setInsets() = |
| 193 | ViewCompat.setOnApplyWindowInsetsListener(binding.setupRoot) { view: View, windowInsets: WindowInsetsCompat -> | 213 | ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view: View, windowInsets: WindowInsetsCompat -> |
| 194 | val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) | 214 | val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) |
| 195 | view.setPadding( | 215 | view.setPadding( |
| 196 | insets.left, | 216 | insets.left, |
diff --git a/src/android/app/src/main/res/layout-w600dp/fragment_setup.xml b/src/android/app/src/main/res/layout-w600dp/fragment_setup.xml index e05af9bdd..cbe631d88 100644 --- a/src/android/app/src/main/res/layout-w600dp/fragment_setup.xml +++ b/src/android/app/src/main/res/layout-w600dp/fragment_setup.xml | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | android:layout_height="wrap_content" | 22 | android:layout_height="wrap_content" |
| 23 | android:layout_margin="16dp" | 23 | android:layout_margin="16dp" |
| 24 | android:text="@string/next" | 24 | android:text="@string/next" |
| 25 | android:visibility="invisible" | ||
| 25 | app:layout_constraintBottom_toBottomOf="parent" | 26 | app:layout_constraintBottom_toBottomOf="parent" |
| 26 | app:layout_constraintEnd_toEndOf="parent" /> | 27 | app:layout_constraintEnd_toEndOf="parent" /> |
| 27 | 28 | ||
| @@ -32,6 +33,7 @@ | |||
| 32 | android:layout_height="wrap_content" | 33 | android:layout_height="wrap_content" |
| 33 | android:layout_margin="16dp" | 34 | android:layout_margin="16dp" |
| 34 | android:text="@string/back" | 35 | android:text="@string/back" |
| 36 | android:visibility="invisible" | ||
| 35 | app:layout_constraintBottom_toBottomOf="parent" | 37 | app:layout_constraintBottom_toBottomOf="parent" |
| 36 | app:layout_constraintStart_toStartOf="parent" /> | 38 | app:layout_constraintStart_toStartOf="parent" /> |
| 37 | 39 | ||