diff options
| author | 2023-05-01 02:26:47 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:05:57 -0700 | |
| commit | 9f6f21946c8e755093827ec3dfc7cb281a59381d (patch) | |
| tree | bbc050b670bd82a2b0b6c56eff2942df37441955 /src | |
| parent | android: Search Fragment (diff) | |
| download | yuzu-9f6f21946c8e755093827ec3dfc7cb281a59381d.tar.gz yuzu-9f6f21946c8e755093827ec3dfc7cb281a59381d.tar.xz yuzu-9f6f21946c8e755093827ec3dfc7cb281a59381d.zip | |
android: Add navigation rail
Diffstat (limited to 'src')
14 files changed, 208 insertions, 93 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 a92fc1075..ea3d47d82 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.appcompat.app.AppCompatActivity | |||
| 15 | import androidx.core.view.ViewCompat | 15 | import androidx.core.view.ViewCompat |
| 16 | import androidx.core.view.WindowCompat | 16 | import androidx.core.view.WindowCompat |
| 17 | import androidx.core.view.WindowInsetsCompat | 17 | import androidx.core.view.WindowInsetsCompat |
| 18 | import android.view.ViewGroup.MarginLayoutParams | ||
| 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 |
| @@ -52,12 +53,14 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView { | |||
| 52 | setSupportActionBar(binding.toolbarSettings) | 53 | setSupportActionBar(binding.toolbarSettings) |
| 53 | supportActionBar!!.setDisplayHomeAsUpEnabled(true) | 54 | supportActionBar!!.setDisplayHomeAsUpEnabled(true) |
| 54 | 55 | ||
| 55 | binding.navigationBarShade.setBackgroundColor( | 56 | if (InsetsHelper.getSystemGestureType(applicationContext) != InsetsHelper.GESTURE_NAVIGATION) { |
| 56 | ThemeHelper.getColorWithOpacity( | 57 | binding.navigationBarShade.setBackgroundColor( |
| 57 | MaterialColors.getColor(binding.navigationBarShade, R.attr.colorSurface), | 58 | ThemeHelper.getColorWithOpacity( |
| 58 | ThemeHelper.SYSTEM_BAR_ALPHA | 59 | MaterialColors.getColor(binding.navigationBarShade, R.attr.colorSurface), |
| 60 | ThemeHelper.SYSTEM_BAR_ALPHA | ||
| 61 | ) | ||
| 59 | ) | 62 | ) |
| 60 | ) | 63 | } |
| 61 | 64 | ||
| 62 | setInsets() | 65 | setInsets() |
| 63 | } | 66 | } |
| @@ -164,12 +167,20 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView { | |||
| 164 | 167 | ||
| 165 | private fun setInsets() { | 168 | private fun setInsets() { |
| 166 | ViewCompat.setOnApplyWindowInsetsListener(binding.frameContent) { view: View, windowInsets: WindowInsetsCompat -> | 169 | ViewCompat.setOnApplyWindowInsetsListener(binding.frameContent) { view: View, windowInsets: WindowInsetsCompat -> |
| 167 | val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) | 170 | val barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) |
| 168 | view.updatePadding(left = insets.left, right = insets.right) | 171 | val cutoutInsets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout()) |
| 169 | InsetsHelper.insetAppBar(insets, binding.appbarSettings) | 172 | view.updatePadding( |
| 173 | left = barInsets.left + cutoutInsets.left, | ||
| 174 | right = barInsets.right + cutoutInsets.right | ||
| 175 | ) | ||
| 176 | |||
| 177 | val mlpAppBar = binding.appbarSettings.layoutParams as MarginLayoutParams | ||
| 178 | mlpAppBar.leftMargin = barInsets.left + cutoutInsets.left | ||
| 179 | mlpAppBar.rightMargin = barInsets.right + cutoutInsets.right | ||
| 180 | binding.appbarSettings.layoutParams = mlpAppBar | ||
| 170 | 181 | ||
| 171 | val mlpShade = binding.navigationBarShade.layoutParams as ViewGroup.MarginLayoutParams | 182 | val mlpShade = binding.navigationBarShade.layoutParams as MarginLayoutParams |
| 172 | mlpShade.height = insets.bottom | 183 | mlpShade.height = barInsets.bottom |
| 173 | binding.navigationBarShade.layoutParams = mlpShade | 184 | binding.navigationBarShade.layoutParams = mlpShade |
| 174 | 185 | ||
| 175 | windowInsets | 186 | windowInsets |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt index eb29d6c96..d651732bf 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt | |||
| @@ -20,6 +20,7 @@ import androidx.core.app.NotificationCompat | |||
| 20 | import androidx.core.app.NotificationManagerCompat | 20 | import androidx.core.app.NotificationManagerCompat |
| 21 | import androidx.core.view.ViewCompat | 21 | import androidx.core.view.ViewCompat |
| 22 | import androidx.core.view.WindowInsetsCompat | 22 | import androidx.core.view.WindowInsetsCompat |
| 23 | import androidx.core.view.updatePadding | ||
| 23 | import androidx.fragment.app.Fragment | 24 | import androidx.fragment.app.Fragment |
| 24 | import androidx.fragment.app.activityViewModels | 25 | import androidx.fragment.app.activityViewModels |
| 25 | import androidx.recyclerview.widget.LinearLayoutManager | 26 | import androidx.recyclerview.widget.LinearLayoutManager |
| @@ -107,26 +108,30 @@ class HomeSettingsFragment : Fragment() { | |||
| 107 | try { | 108 | try { |
| 108 | startActivity(getFileManagerIntentOnDocumentProvider(Intent.ACTION_VIEW)) | 109 | startActivity(getFileManagerIntentOnDocumentProvider(Intent.ACTION_VIEW)) |
| 109 | return | 110 | return |
| 110 | } catch (_: ActivityNotFoundException) {} | 111 | } catch (_: ActivityNotFoundException) { |
| 112 | } | ||
| 111 | 113 | ||
| 112 | try { | 114 | try { |
| 113 | startActivity(getFileManagerIntentOnDocumentProvider("android.provider.action.BROWSE")) | 115 | startActivity(getFileManagerIntentOnDocumentProvider("android.provider.action.BROWSE")) |
| 114 | return | 116 | return |
| 115 | } catch (_: ActivityNotFoundException) {} | 117 | } catch (_: ActivityNotFoundException) { |
| 118 | } | ||
| 116 | 119 | ||
| 117 | // Just try to open the file manager, try the package name used on "normal" phones | 120 | // Just try to open the file manager, try the package name used on "normal" phones |
| 118 | try { | 121 | try { |
| 119 | startActivity(getFileManagerIntent("com.google.android.documentsui")) | 122 | startActivity(getFileManagerIntent("com.google.android.documentsui")) |
| 120 | showNoLinkNotification() | 123 | showNoLinkNotification() |
| 121 | return | 124 | return |
| 122 | } catch (_: ActivityNotFoundException) {} | 125 | } catch (_: ActivityNotFoundException) { |
| 126 | } | ||
| 123 | 127 | ||
| 124 | try { | 128 | try { |
| 125 | // Next, try the AOSP package name | 129 | // Next, try the AOSP package name |
| 126 | startActivity(getFileManagerIntent("com.android.documentsui")) | 130 | startActivity(getFileManagerIntent("com.android.documentsui")) |
| 127 | showNoLinkNotification() | 131 | showNoLinkNotification() |
| 128 | return | 132 | return |
| 129 | } catch (_: ActivityNotFoundException) {} | 133 | } catch (_: ActivityNotFoundException) { |
| 134 | } | ||
| 130 | 135 | ||
| 131 | Toast.makeText( | 136 | Toast.makeText( |
| 132 | requireContext(), | 137 | requireContext(), |
| @@ -153,7 +158,10 @@ class HomeSettingsFragment : Fragment() { | |||
| 153 | } | 158 | } |
| 154 | 159 | ||
| 155 | private fun showNoLinkNotification() { | 160 | private fun showNoLinkNotification() { |
| 156 | val builder = NotificationCompat.Builder(requireContext(), getString(R.string.notice_notification_channel_id)) | 161 | val builder = NotificationCompat.Builder( |
| 162 | requireContext(), | ||
| 163 | getString(R.string.notice_notification_channel_id) | ||
| 164 | ) | ||
| 157 | .setSmallIcon(R.drawable.ic_stat_notification_logo) | 165 | .setSmallIcon(R.drawable.ic_stat_notification_logo) |
| 158 | .setContentTitle(getString(R.string.notification_no_directory_link)) | 166 | .setContentTitle(getString(R.string.notification_no_directory_link)) |
| 159 | .setContentText(getString(R.string.notification_no_directory_link_description)) | 167 | .setContentText(getString(R.string.notification_no_directory_link_description)) |
| @@ -204,14 +212,28 @@ class HomeSettingsFragment : Fragment() { | |||
| 204 | } | 212 | } |
| 205 | 213 | ||
| 206 | private fun setInsets() = | 214 | private fun setInsets() = |
| 207 | ViewCompat.setOnApplyWindowInsetsListener(binding.scrollViewSettings) { view: View, windowInsets: WindowInsetsCompat -> | 215 | ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view: View, windowInsets: WindowInsetsCompat -> |
| 208 | val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) | 216 | val barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) |
| 209 | view.setPadding( | 217 | val cutoutInsets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout()) |
| 210 | insets.left, | 218 | val spacingNavigation = resources.getDimensionPixelSize(R.dimen.spacing_navigation) |
| 211 | insets.top, | 219 | val spacingNavigationRail = |
| 212 | insets.right, | 220 | resources.getDimensionPixelSize(R.dimen.spacing_navigation_rail) |
| 213 | insets.bottom + resources.getDimensionPixelSize(R.dimen.spacing_navigation) | 221 | |
| 222 | binding.scrollViewSettings.setPadding( | ||
| 223 | barInsets.left + cutoutInsets.left, | ||
| 224 | barInsets.top, | ||
| 225 | barInsets.right + cutoutInsets.right, | ||
| 226 | barInsets.bottom | ||
| 214 | ) | 227 | ) |
| 228 | |||
| 229 | binding.linearLayoutSettings.updatePadding(bottom = spacingNavigation) | ||
| 230 | |||
| 231 | if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_LTR) { | ||
| 232 | binding.linearLayoutSettings.updatePadding(left = spacingNavigationRail) | ||
| 233 | } else { | ||
| 234 | binding.linearLayoutSettings.updatePadding(right = spacingNavigationRail) | ||
| 235 | } | ||
| 236 | |||
| 215 | windowInsets | 237 | windowInsets |
| 216 | } | 238 | } |
| 217 | } | 239 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt index 5babd9bbf..f6aa370f0 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt | |||
| @@ -141,7 +141,8 @@ class SearchFragment : Fragment() { | |||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | if (binding.searchText.text.toString().isEmpty() | 143 | if (binding.searchText.text.toString().isEmpty() |
| 144 | && binding.chipGroup.checkedChipId != View.NO_ID) { | 144 | && binding.chipGroup.checkedChipId != View.NO_ID |
| 145 | ) { | ||
| 145 | gamesViewModel.setSearchedGames(filteredList) | 146 | gamesViewModel.setSearchedGames(filteredList) |
| 146 | return | 147 | return |
| 147 | } | 148 | } |
| @@ -182,41 +183,51 @@ class SearchFragment : Fragment() { | |||
| 182 | } | 183 | } |
| 183 | 184 | ||
| 184 | private fun setInsets() = | 185 | private fun setInsets() = |
| 185 | ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _: View, windowInsets: WindowInsetsCompat -> | 186 | ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view: View, windowInsets: WindowInsetsCompat -> |
| 186 | val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) | 187 | val barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) |
| 188 | val cutoutInsets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout()) | ||
| 187 | val extraListSpacing = resources.getDimensionPixelSize(R.dimen.spacing_med) | 189 | val extraListSpacing = resources.getDimensionPixelSize(R.dimen.spacing_med) |
| 188 | val navigationSpacing = resources.getDimensionPixelSize(R.dimen.spacing_navigation) | 190 | val spacingNavigation = resources.getDimensionPixelSize(R.dimen.spacing_navigation) |
| 191 | val spacingNavigationRail = | ||
| 192 | resources.getDimensionPixelSize(R.dimen.spacing_navigation_rail) | ||
| 189 | val chipSpacing = resources.getDimensionPixelSize(R.dimen.spacing_chip) | 193 | val chipSpacing = resources.getDimensionPixelSize(R.dimen.spacing_chip) |
| 190 | 194 | ||
| 191 | binding.frameSearch.updatePadding( | 195 | binding.constraintSearch.updatePadding( |
| 192 | left = insets.left, | 196 | left = barInsets.left + cutoutInsets.left, |
| 193 | top = insets.top, | 197 | top = barInsets.top, |
| 194 | right = insets.right | 198 | right = barInsets.right + cutoutInsets.right |
| 195 | ) | 199 | ) |
| 196 | 200 | ||
| 197 | binding.gridGamesSearch.setPadding( | 201 | binding.gridGamesSearch.updatePadding( |
| 198 | insets.left, | 202 | top = extraListSpacing, |
| 199 | extraListSpacing, | 203 | bottom = barInsets.bottom + spacingNavigation + extraListSpacing |
| 200 | insets.right, | ||
| 201 | insets.bottom + resources.getDimensionPixelSize(R.dimen.spacing_navigation) + extraListSpacing | ||
| 202 | ) | ||
| 203 | |||
| 204 | binding.noResultsView.updatePadding( | ||
| 205 | left = insets.left, | ||
| 206 | right = insets.right, | ||
| 207 | bottom = insets.bottom + navigationSpacing | ||
| 208 | ) | 204 | ) |
| 205 | binding.noResultsView.updatePadding(bottom = spacingNavigation + barInsets.bottom) | ||
| 209 | 206 | ||
| 210 | val mlpDivider = binding.divider.layoutParams as ViewGroup.MarginLayoutParams | 207 | val mlpDivider = binding.divider.layoutParams as ViewGroup.MarginLayoutParams |
| 211 | mlpDivider.leftMargin = insets.left + chipSpacing | 208 | if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_LTR) { |
| 212 | mlpDivider.rightMargin = insets.right + chipSpacing | 209 | binding.frameSearch.updatePadding(left = spacingNavigationRail) |
| 210 | binding.gridGamesSearch.updatePadding(left = spacingNavigationRail) | ||
| 211 | binding.noResultsView.updatePadding(left = spacingNavigationRail) | ||
| 212 | binding.chipGroup.updatePadding( | ||
| 213 | left = chipSpacing + spacingNavigationRail, | ||
| 214 | right = chipSpacing | ||
| 215 | ) | ||
| 216 | mlpDivider.leftMargin = chipSpacing + spacingNavigationRail | ||
| 217 | mlpDivider.rightMargin = chipSpacing | ||
| 218 | } else { | ||
| 219 | binding.frameSearch.updatePadding(right = spacingNavigationRail) | ||
| 220 | binding.gridGamesSearch.updatePadding(right = spacingNavigationRail) | ||
| 221 | binding.noResultsView.updatePadding(right = spacingNavigationRail) | ||
| 222 | binding.chipGroup.updatePadding( | ||
| 223 | left = chipSpacing, | ||
| 224 | right = chipSpacing + spacingNavigationRail | ||
| 225 | ) | ||
| 226 | mlpDivider.leftMargin = chipSpacing | ||
| 227 | mlpDivider.rightMargin = chipSpacing + spacingNavigationRail | ||
| 228 | } | ||
| 213 | binding.divider.layoutParams = mlpDivider | 229 | binding.divider.layoutParams = mlpDivider |
| 214 | 230 | ||
| 215 | binding.chipGroup.updatePadding( | ||
| 216 | left = insets.left + chipSpacing, | ||
| 217 | right = insets.right + chipSpacing | ||
| 218 | ) | ||
| 219 | |||
| 220 | windowInsets | 231 | windowInsets |
| 221 | } | 232 | } |
| 222 | } | 233 | } |
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 6f9e04f7e..cc17b8626 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 | |||
| @@ -8,27 +8,20 @@ import android.view.LayoutInflater | |||
| 8 | import android.view.View | 8 | import android.view.View |
| 9 | import android.view.ViewGroup | 9 | import android.view.ViewGroup |
| 10 | import android.view.ViewGroup.MarginLayoutParams | 10 | import android.view.ViewGroup.MarginLayoutParams |
| 11 | import androidx.activity.OnBackPressedCallback | ||
| 12 | import androidx.appcompat.app.AppCompatActivity | 11 | import androidx.appcompat.app.AppCompatActivity |
| 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 |
| 16 | import androidx.core.widget.doOnTextChanged | ||
| 17 | import androidx.fragment.app.Fragment | 15 | import androidx.fragment.app.Fragment |
| 18 | import androidx.fragment.app.activityViewModels | 16 | import androidx.fragment.app.activityViewModels |
| 19 | import com.google.android.material.color.MaterialColors | 17 | import com.google.android.material.color.MaterialColors |
| 20 | import com.google.android.material.search.SearchView | ||
| 21 | import com.google.android.material.search.SearchView.TransitionState | ||
| 22 | import com.google.android.material.transition.MaterialFadeThrough | 18 | import com.google.android.material.transition.MaterialFadeThrough |
| 23 | import info.debatty.java.stringsimilarity.Jaccard | ||
| 24 | import org.yuzu.yuzu_emu.R | 19 | import org.yuzu.yuzu_emu.R |
| 25 | import org.yuzu.yuzu_emu.adapters.GameAdapter | 20 | import org.yuzu.yuzu_emu.adapters.GameAdapter |
| 26 | import org.yuzu.yuzu_emu.databinding.FragmentGamesBinding | 21 | import org.yuzu.yuzu_emu.databinding.FragmentGamesBinding |
| 27 | import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager | 22 | import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager |
| 28 | import org.yuzu.yuzu_emu.model.Game | ||
| 29 | import org.yuzu.yuzu_emu.model.GamesViewModel | 23 | import org.yuzu.yuzu_emu.model.GamesViewModel |
| 30 | import org.yuzu.yuzu_emu.model.HomeViewModel | 24 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 31 | import java.util.Locale | ||
| 32 | 25 | ||
| 33 | class GamesFragment : Fragment() { | 26 | class GamesFragment : Fragment() { |
| 34 | private var _binding: FragmentGamesBinding? = null | 27 | private var _binding: FragmentGamesBinding? = null |
| @@ -127,24 +120,37 @@ class GamesFragment : Fragment() { | |||
| 127 | 120 | ||
| 128 | private fun setInsets() = | 121 | private fun setInsets() = |
| 129 | ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view: View, windowInsets: WindowInsetsCompat -> | 122 | ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view: View, windowInsets: WindowInsetsCompat -> |
| 130 | val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) | 123 | val barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) |
| 124 | val cutoutInsets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout()) | ||
| 131 | val extraListSpacing = resources.getDimensionPixelSize(R.dimen.spacing_large) | 125 | val extraListSpacing = resources.getDimensionPixelSize(R.dimen.spacing_large) |
| 126 | val spacingNavigation = resources.getDimensionPixelSize(R.dimen.spacing_navigation) | ||
| 127 | val spacingNavigationRail = | ||
| 128 | resources.getDimensionPixelSize(R.dimen.spacing_navigation_rail) | ||
| 132 | 129 | ||
| 133 | binding.gridGames.updatePadding( | 130 | binding.gridGames.updatePadding( |
| 134 | top = insets.top + extraListSpacing, | 131 | top = barInsets.top + extraListSpacing, |
| 135 | bottom = insets.bottom + resources.getDimensionPixelSize(R.dimen.spacing_navigation) + extraListSpacing | 132 | bottom = barInsets.bottom + spacingNavigation + extraListSpacing |
| 136 | ) | 133 | ) |
| 137 | 134 | ||
| 138 | binding.swipeRefresh.setProgressViewEndTarget( | 135 | binding.swipeRefresh.setProgressViewEndTarget( |
| 139 | false, | 136 | false, |
| 140 | insets.top + resources.getDimensionPixelSize(R.dimen.spacing_refresh_end) | 137 | barInsets.top + resources.getDimensionPixelSize(R.dimen.spacing_refresh_end) |
| 141 | ) | 138 | ) |
| 142 | 139 | ||
| 140 | val leftInsets = barInsets.left + cutoutInsets.left | ||
| 141 | val rightInsets = barInsets.right + cutoutInsets.right | ||
| 143 | val mlpSwipe = binding.swipeRefresh.layoutParams as MarginLayoutParams | 142 | val mlpSwipe = binding.swipeRefresh.layoutParams as MarginLayoutParams |
| 144 | mlpSwipe.rightMargin = insets.right | 143 | if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_LTR) { |
| 145 | mlpSwipe.leftMargin = insets.left | 144 | mlpSwipe.leftMargin = leftInsets + spacingNavigationRail |
| 145 | mlpSwipe.rightMargin = rightInsets | ||
| 146 | } else { | ||
| 147 | mlpSwipe.leftMargin = leftInsets | ||
| 148 | mlpSwipe.rightMargin = rightInsets + spacingNavigationRail | ||
| 149 | } | ||
| 146 | binding.swipeRefresh.layoutParams = mlpSwipe | 150 | binding.swipeRefresh.layoutParams = mlpSwipe |
| 147 | 151 | ||
| 152 | binding.noticeText.updatePadding(bottom = spacingNavigation) | ||
| 153 | |||
| 148 | windowInsets | 154 | windowInsets |
| 149 | } | 155 | } |
| 150 | } | 156 | } |
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 35b66d1f2..c620c3c7c 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 | |||
| @@ -67,16 +67,16 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 67 | ContextCompat.getColor(applicationContext, android.R.color.transparent) | 67 | ContextCompat.getColor(applicationContext, android.R.color.transparent) |
| 68 | ThemeHelper.setNavigationBarColor( | 68 | ThemeHelper.setNavigationBarColor( |
| 69 | this, | 69 | this, |
| 70 | ElevationOverlayProvider(binding.navigationBar.context).compositeOverlay( | 70 | ElevationOverlayProvider(binding.navigationView.context).compositeOverlay( |
| 71 | MaterialColors.getColor(binding.navigationBar, R.attr.colorSurface), | 71 | MaterialColors.getColor(binding.navigationView, R.attr.colorSurface), |
| 72 | binding.navigationBar.elevation | 72 | binding.navigationView.elevation |
| 73 | ) | 73 | ) |
| 74 | ) | 74 | ) |
| 75 | 75 | ||
| 76 | val navHostFragment = | 76 | val navHostFragment = |
| 77 | supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment | 77 | supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment |
| 78 | setUpNavigation(navHostFragment.navController) | 78 | setUpNavigation(navHostFragment.navController) |
| 79 | (binding.navigationBar as NavigationBarView).setOnItemReselectedListener { | 79 | (binding.navigationView as NavigationBarView).setOnItemReselectedListener { |
| 80 | when (it.itemId) { | 80 | when (it.itemId) { |
| 81 | R.id.gamesFragment -> gamesViewModel.setShouldScrollToTop(true) | 81 | R.id.gamesFragment -> gamesViewModel.setShouldScrollToTop(true) |
| 82 | R.id.searchFragment -> gamesViewModel.setSearchFocused(true) | 82 | R.id.searchFragment -> gamesViewModel.setSearchFocused(true) |
| @@ -95,7 +95,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 95 | 95 | ||
| 96 | // Prevents navigation from being drawn for a short time on recreation if set to hidden | 96 | // Prevents navigation from being drawn for a short time on recreation if set to hidden |
| 97 | if (!homeViewModel.navigationVisible.value?.first!!) { | 97 | if (!homeViewModel.navigationVisible.value?.first!!) { |
| 98 | binding.navigationBar.visibility = View.INVISIBLE | 98 | binding.navigationView.visibility = View.INVISIBLE |
| 99 | binding.statusBarShade.visibility = View.INVISIBLE | 99 | binding.statusBarShade.visibility = View.INVISIBLE |
| 100 | } | 100 | } |
| 101 | 101 | ||
| @@ -114,14 +114,14 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 114 | 114 | ||
| 115 | fun finishSetup(navController: NavController) { | 115 | fun finishSetup(navController: NavController) { |
| 116 | navController.navigate(R.id.action_firstTimeSetupFragment_to_gamesFragment) | 116 | navController.navigate(R.id.action_firstTimeSetupFragment_to_gamesFragment) |
| 117 | binding.navigationBar.setupWithNavController(navController) | 117 | (binding.navigationView as NavigationBarView).setupWithNavController(navController) |
| 118 | showNavigation(visible = true, animated = true) | 118 | showNavigation(visible = true, animated = true) |
| 119 | 119 | ||
| 120 | ThemeHelper.setNavigationBarColor( | 120 | ThemeHelper.setNavigationBarColor( |
| 121 | this, | 121 | this, |
| 122 | ElevationOverlayProvider(binding.navigationBar.context).compositeOverlay( | 122 | ElevationOverlayProvider(binding.navigationView.context).compositeOverlay( |
| 123 | MaterialColors.getColor(binding.navigationBar, R.attr.colorSurface), | 123 | MaterialColors.getColor(binding.navigationView, R.attr.colorSurface), |
| 124 | binding.navigationBar.elevation | 124 | binding.navigationView.elevation |
| 125 | ) | 125 | ) |
| 126 | ) | 126 | ) |
| 127 | } | 127 | } |
| @@ -134,35 +134,35 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 134 | navController.navigate(R.id.firstTimeSetupFragment) | 134 | navController.navigate(R.id.firstTimeSetupFragment) |
| 135 | homeViewModel.navigatedToSetup = true | 135 | homeViewModel.navigatedToSetup = true |
| 136 | } else { | 136 | } else { |
| 137 | binding.navigationBar.setupWithNavController(navController) | 137 | (binding.navigationView as NavigationBarView).setupWithNavController(navController) |
| 138 | } | 138 | } |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | private fun showNavigation(visible: Boolean, animated: Boolean) { | 141 | private fun showNavigation(visible: Boolean, animated: Boolean) { |
| 142 | if (!animated) { | 142 | if (!animated) { |
| 143 | if (visible) { | 143 | if (visible) { |
| 144 | binding.navigationBar.visibility = View.VISIBLE | 144 | binding.navigationView.visibility = View.VISIBLE |
| 145 | } else { | 145 | } else { |
| 146 | binding.navigationBar.visibility = View.INVISIBLE | 146 | binding.navigationView.visibility = View.INVISIBLE |
| 147 | } | 147 | } |
| 148 | return | 148 | return |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | binding.navigationBar.animate().apply { | 151 | binding.navigationView.animate().apply { |
| 152 | if (visible) { | 152 | if (visible) { |
| 153 | binding.navigationBar.visibility = View.VISIBLE | 153 | binding.navigationView.visibility = View.VISIBLE |
| 154 | binding.navigationBar.translationY = binding.navigationBar.height.toFloat() * 2 | 154 | binding.navigationView.translationY = binding.navigationView.height.toFloat() * 2 |
| 155 | duration = 300 | 155 | duration = 300 |
| 156 | translationY(0f) | 156 | translationY(0f) |
| 157 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) | 157 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) |
| 158 | } else { | 158 | } else { |
| 159 | duration = 300 | 159 | duration = 300 |
| 160 | translationY(binding.navigationBar.height.toFloat() * 2) | 160 | translationY(binding.navigationView.height.toFloat() * 2) |
| 161 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) | 161 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) |
| 162 | } | 162 | } |
| 163 | }.withEndAction { | 163 | }.withEndAction { |
| 164 | if (!visible) { | 164 | if (!visible) { |
| 165 | binding.navigationBar.visibility = View.INVISIBLE | 165 | binding.navigationView.visibility = View.INVISIBLE |
| 166 | } | 166 | } |
| 167 | }.start() | 167 | }.start() |
| 168 | } | 168 | } |
| @@ -177,7 +177,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 177 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) | 177 | interpolator = PathInterpolator(0.05f, 0.7f, 0.1f, 1f) |
| 178 | } else { | 178 | } else { |
| 179 | duration = 300 | 179 | duration = 300 |
| 180 | translationY(binding.navigationBar.height.toFloat() * -2) | 180 | translationY(binding.navigationView.height.toFloat() * -2) |
| 181 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) | 181 | interpolator = PathInterpolator(0.3f, 0f, 0.8f, 0.15f) |
| 182 | } | 182 | } |
| 183 | }.withEndAction { | 183 | }.withEndAction { |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InsetsHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InsetsHelper.kt index e7a04d917..e587fea06 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InsetsHelper.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InsetsHelper.kt | |||
| @@ -4,22 +4,12 @@ import android.annotation.SuppressLint | |||
| 4 | import android.app.Activity | 4 | import android.app.Activity |
| 5 | import android.content.Context | 5 | import android.content.Context |
| 6 | import android.graphics.Rect | 6 | import android.graphics.Rect |
| 7 | import android.view.ViewGroup.MarginLayoutParams | ||
| 8 | import androidx.core.graphics.Insets | ||
| 9 | import com.google.android.material.appbar.AppBarLayout | ||
| 10 | 7 | ||
| 11 | object InsetsHelper { | 8 | object InsetsHelper { |
| 12 | const val THREE_BUTTON_NAVIGATION = 0 | 9 | const val THREE_BUTTON_NAVIGATION = 0 |
| 13 | const val TWO_BUTTON_NAVIGATION = 1 | 10 | const val TWO_BUTTON_NAVIGATION = 1 |
| 14 | const val GESTURE_NAVIGATION = 2 | 11 | const val GESTURE_NAVIGATION = 2 |
| 15 | 12 | ||
| 16 | fun insetAppBar(insets: Insets, appBarLayout: AppBarLayout) { | ||
| 17 | val mlpAppBar = appBarLayout.layoutParams as MarginLayoutParams | ||
| 18 | mlpAppBar.leftMargin = insets.left | ||
| 19 | mlpAppBar.rightMargin = insets.right | ||
| 20 | appBarLayout.layoutParams = mlpAppBar | ||
| 21 | } | ||
| 22 | |||
| 23 | @SuppressLint("DiscouragedApi") | 13 | @SuppressLint("DiscouragedApi") |
| 24 | fun getSystemGestureType(context: Context): Int { | 14 | fun getSystemGestureType(context: Context): Int { |
| 25 | val resources = context.resources | 15 | val resources = context.resources |
diff --git a/src/android/app/src/main/res/layout-w600dp/activity_main.xml b/src/android/app/src/main/res/layout-w600dp/activity_main.xml new file mode 100644 index 000000000..39b61a13e --- /dev/null +++ b/src/android/app/src/main/res/layout-w600dp/activity_main.xml | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <androidx.constraintlayout.widget.ConstraintLayout | ||
| 3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 5 | xmlns:tools="http://schemas.android.com/tools" | ||
| 6 | android:id="@+id/coordinator_main" | ||
| 7 | android:layout_width="match_parent" | ||
| 8 | android:layout_height="match_parent"> | ||
| 9 | |||
| 10 | <androidx.fragment.app.FragmentContainerView | ||
| 11 | android:id="@+id/fragment_container" | ||
| 12 | android:name="androidx.navigation.fragment.NavHostFragment" | ||
| 13 | android:layout_width="0dp" | ||
| 14 | android:layout_height="0dp" | ||
| 15 | app:defaultNavHost="true" | ||
| 16 | app:layout_constraintBottom_toBottomOf="parent" | ||
| 17 | app:layout_constraintEnd_toEndOf="parent" | ||
| 18 | app:layout_constraintStart_toStartOf="parent" | ||
| 19 | app:layout_constraintTop_toTopOf="parent" | ||
| 20 | app:navGraph="@navigation/home_navigation" | ||
| 21 | tools:layout="@layout/fragment_games" /> | ||
| 22 | |||
| 23 | <com.google.android.material.navigationrail.NavigationRailView | ||
| 24 | android:id="@+id/navigation_view" | ||
| 25 | android:layout_width="wrap_content" | ||
| 26 | android:layout_height="match_parent" | ||
| 27 | android:visibility="invisible" | ||
| 28 | app:layout_constraintBottom_toBottomOf="parent" | ||
| 29 | app:layout_constraintStart_toStartOf="parent" | ||
| 30 | app:layout_constraintTop_toTopOf="parent" | ||
| 31 | app:labelVisibilityMode="selected" | ||
| 32 | app:menu="@menu/menu_navigation" | ||
| 33 | tools:visibility="visible" /> | ||
| 34 | |||
| 35 | <View | ||
| 36 | android:id="@+id/status_bar_shade" | ||
| 37 | android:layout_width="0dp" | ||
| 38 | android:layout_height="1px" | ||
| 39 | android:background="@android:color/transparent" | ||
| 40 | android:clickable="false" | ||
| 41 | android:focusable="false" | ||
| 42 | app:layout_constraintTop_toTopOf="parent" | ||
| 43 | app:layout_constraintEnd_toEndOf="parent" | ||
| 44 | app:layout_constraintStart_toStartOf="parent" /> | ||
| 45 | |||
| 46 | </androidx.constraintlayout.widget.ConstraintLayout> | ||
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 6ca426b54..214acb041 100644 --- a/src/android/app/src/main/res/layout/activity_main.xml +++ b/src/android/app/src/main/res/layout/activity_main.xml | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | tools:layout="@layout/fragment_games" /> | 21 | tools:layout="@layout/fragment_games" /> |
| 22 | 22 | ||
| 23 | <com.google.android.material.bottomnavigation.BottomNavigationView | 23 | <com.google.android.material.bottomnavigation.BottomNavigationView |
| 24 | android:id="@+id/navigation_bar" | 24 | android:id="@+id/navigation_view" |
| 25 | android:layout_width="match_parent" | 25 | android:layout_width="match_parent" |
| 26 | android:layout_height="wrap_content" | 26 | android:layout_height="wrap_content" |
| 27 | android:visibility="invisible" | 27 | android:visibility="invisible" |
diff --git a/src/android/app/src/main/res/layout/fragment_home_settings.xml b/src/android/app/src/main/res/layout/fragment_home_settings.xml index e0c609309..82b037010 100644 --- a/src/android/app/src/main/res/layout/fragment_home_settings.xml +++ b/src/android/app/src/main/res/layout/fragment_home_settings.xml | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | android:clipToPadding="false"> | 8 | android:clipToPadding="false"> |
| 9 | 9 | ||
| 10 | <androidx.appcompat.widget.LinearLayoutCompat | 10 | <androidx.appcompat.widget.LinearLayoutCompat |
| 11 | android:id="@+id/linear_layout_settings" | ||
| 11 | android:layout_width="match_parent" | 12 | android:layout_width="match_parent" |
| 12 | android:layout_height="match_parent" | 13 | android:layout_height="match_parent" |
| 13 | android:orientation="vertical" | 14 | android:orientation="vertical" |
diff --git a/src/android/app/src/main/res/layout/fragment_search.xml b/src/android/app/src/main/res/layout/fragment_search.xml index 3b1aefdfb..b8d54d947 100644 --- a/src/android/app/src/main/res/layout/fragment_search.xml +++ b/src/android/app/src/main/res/layout/fragment_search.xml | |||
| @@ -3,9 +3,11 @@ | |||
| 3 | xmlns:android="http://schemas.android.com/apk/res/android" | 3 | xmlns:android="http://schemas.android.com/apk/res/android" |
| 4 | xmlns:app="http://schemas.android.com/apk/res-auto" | 4 | xmlns:app="http://schemas.android.com/apk/res-auto" |
| 5 | xmlns:tools="http://schemas.android.com/tools" | 5 | xmlns:tools="http://schemas.android.com/tools" |
| 6 | android:id="@+id/constraint_search" | ||
| 6 | android:layout_width="match_parent" | 7 | android:layout_width="match_parent" |
| 7 | android:layout_height="match_parent" | 8 | android:layout_height="match_parent" |
| 8 | android:background="?attr/colorSurface"> | 9 | android:background="?attr/colorSurface" |
| 10 | android:clipToPadding="false"> | ||
| 9 | 11 | ||
| 10 | <RelativeLayout | 12 | <RelativeLayout |
| 11 | android:layout_width="0dp" | 13 | android:layout_width="0dp" |
| @@ -52,7 +54,8 @@ | |||
| 52 | android:id="@+id/frame_search" | 54 | android:id="@+id/frame_search" |
| 53 | android:layout_width="match_parent" | 55 | android:layout_width="match_parent" |
| 54 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
| 55 | android:layout_margin="20dp" | 57 | android:layout_marginTop="12dp" |
| 58 | android:layout_marginHorizontal="20dp" | ||
| 56 | app:layout_constraintEnd_toEndOf="parent" | 59 | app:layout_constraintEnd_toEndOf="parent" |
| 57 | app:layout_constraintStart_toStartOf="parent" | 60 | app:layout_constraintStart_toStartOf="parent" |
| 58 | app:layout_constraintTop_toTopOf="parent"> | 61 | app:layout_constraintTop_toTopOf="parent"> |
diff --git a/src/android/app/src/main/res/menu-w600dp/menu_navigation.xml b/src/android/app/src/main/res/menu-w600dp/menu_navigation.xml new file mode 100644 index 000000000..073d00cab --- /dev/null +++ b/src/android/app/src/main/res/menu-w600dp/menu_navigation.xml | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | |||
| 4 | <item | ||
| 5 | android:id="@+id/homeSettingsFragment" | ||
| 6 | android:icon="@drawable/ic_settings" | ||
| 7 | android:title="@string/home_settings" /> | ||
| 8 | |||
| 9 | <item | ||
| 10 | android:id="@+id/searchFragment" | ||
| 11 | android:icon="@drawable/ic_search" | ||
| 12 | android:title="@string/home_search" /> | ||
| 13 | |||
| 14 | <item | ||
| 15 | android:id="@+id/gamesFragment" | ||
| 16 | android:icon="@drawable/ic_controller" | ||
| 17 | android:title="@string/home_games" /> | ||
| 18 | |||
| 19 | </menu> | ||
diff --git a/src/android/app/src/main/res/values-w600dp/dimens.xml b/src/android/app/src/main/res/values-w600dp/dimens.xml new file mode 100644 index 000000000..128319e27 --- /dev/null +++ b/src/android/app/src/main/res/values-w600dp/dimens.xml | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <resources> | ||
| 3 | <dimen name="spacing_navigation">0dp</dimen> | ||
| 4 | <dimen name="spacing_navigation_rail">80dp</dimen> | ||
| 5 | </resources> | ||
diff --git a/src/android/app/src/main/res/values/dimens.xml b/src/android/app/src/main/res/values/dimens.xml index 28a6d25cf..00757e5e8 100644 --- a/src/android/app/src/main/res/values/dimens.xml +++ b/src/android/app/src/main/res/values/dimens.xml | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | <dimen name="spacing_list">64dp</dimen> | 7 | <dimen name="spacing_list">64dp</dimen> |
| 8 | <dimen name="spacing_chip">20dp</dimen> | 8 | <dimen name="spacing_chip">20dp</dimen> |
| 9 | <dimen name="spacing_navigation">80dp</dimen> | 9 | <dimen name="spacing_navigation">80dp</dimen> |
| 10 | <dimen name="spacing_navigation_rail">0dp</dimen> | ||
| 10 | <dimen name="spacing_search">128dp</dimen> | 11 | <dimen name="spacing_search">128dp</dimen> |
| 11 | <dimen name="spacing_refresh_end">72dp</dimen> | 12 | <dimen name="spacing_refresh_end">72dp</dimen> |
| 12 | <dimen name="menu_width">256dp</dimen> | 13 | <dimen name="menu_width">256dp</dimen> |
diff --git a/src/android/app/src/main/res/values/themes.xml b/src/android/app/src/main/res/values/themes.xml index f32e2f5d0..60388b71e 100644 --- a/src/android/app/src/main/res/values/themes.xml +++ b/src/android/app/src/main/res/values/themes.xml | |||
| @@ -42,7 +42,7 @@ | |||
| 42 | <item name="sliderStyle">@style/YuzuSlider</item> | 42 | <item name="sliderStyle">@style/YuzuSlider</item> |
| 43 | <item name="materialAlertDialogTheme">@style/YuzuMaterialDialog</item> | 43 | <item name="materialAlertDialogTheme">@style/YuzuMaterialDialog</item> |
| 44 | 44 | ||
| 45 | <item name="android:windowLayoutInDisplayCutoutMode">default</item> | 45 | <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item> |
| 46 | 46 | ||
| 47 | <item name="android:enforceStatusBarContrast">false</item> | 47 | <item name="android:enforceStatusBarContrast">false</item> |
| 48 | <item name="android:enforceNavigationBarContrast">false</item> | 48 | <item name="android:enforceNavigationBarContrast">false</item> |