diff options
| author | 2024-02-08 20:36:23 -0500 | |
|---|---|---|
| committer | 2024-02-09 07:07:06 -0500 | |
| commit | f44183db9ebf7dcab0426096a06b2095ce864cbf (patch) | |
| tree | 6e989cc712882fcb380bb59ac201990dc0a36fcb | |
| parent | android: Add thermal throttling overlay (diff) | |
| download | yuzu-f44183db9ebf7dcab0426096a06b2095ce864cbf.tar.gz yuzu-f44183db9ebf7dcab0426096a06b2095ce864cbf.tar.xz yuzu-f44183db9ebf7dcab0426096a06b2095ce864cbf.zip | |
android: Use utility function for applying view margins
15 files changed, 104 insertions, 163 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragment.kt index d7ab0b5d9..6f6e7be10 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragment.kt | |||
| @@ -8,7 +8,6 @@ import android.os.Bundle | |||
| 8 | import android.view.LayoutInflater | 8 | import android.view.LayoutInflater |
| 9 | import android.view.View | 9 | import android.view.View |
| 10 | import android.view.ViewGroup | 10 | import android.view.ViewGroup |
| 11 | import android.view.ViewGroup.MarginLayoutParams | ||
| 12 | import androidx.core.view.ViewCompat | 11 | import androidx.core.view.ViewCompat |
| 13 | import androidx.core.view.WindowInsetsCompat | 12 | import androidx.core.view.WindowInsetsCompat |
| 14 | import androidx.core.view.updatePadding | 13 | import androidx.core.view.updatePadding |
| @@ -27,6 +26,7 @@ import org.yuzu.yuzu_emu.R | |||
| 27 | import org.yuzu.yuzu_emu.databinding.FragmentSettingsBinding | 26 | import org.yuzu.yuzu_emu.databinding.FragmentSettingsBinding |
| 28 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 27 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 29 | import org.yuzu.yuzu_emu.model.SettingsViewModel | 28 | import org.yuzu.yuzu_emu.model.SettingsViewModel |
| 29 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 30 | 30 | ||
| 31 | class SettingsFragment : Fragment() { | 31 | class SettingsFragment : Fragment() { |
| 32 | private lateinit var presenter: SettingsFragmentPresenter | 32 | private lateinit var presenter: SettingsFragmentPresenter |
| @@ -125,18 +125,10 @@ class SettingsFragment : Fragment() { | |||
| 125 | val leftInsets = barInsets.left + cutoutInsets.left | 125 | val leftInsets = barInsets.left + cutoutInsets.left |
| 126 | val rightInsets = barInsets.right + cutoutInsets.right | 126 | val rightInsets = barInsets.right + cutoutInsets.right |
| 127 | 127 | ||
| 128 | val mlpSettingsList = binding.listSettings.layoutParams as MarginLayoutParams | 128 | binding.listSettings.updateMargins(left = leftInsets, right = rightInsets) |
| 129 | mlpSettingsList.leftMargin = leftInsets | 129 | binding.listSettings.updatePadding(bottom = barInsets.bottom) |
| 130 | mlpSettingsList.rightMargin = rightInsets | 130 | |
| 131 | binding.listSettings.layoutParams = mlpSettingsList | 131 | binding.appbarSettings.updateMargins(left = leftInsets, right = rightInsets) |
| 132 | binding.listSettings.updatePadding( | ||
| 133 | bottom = barInsets.bottom | ||
| 134 | ) | ||
| 135 | |||
| 136 | val mlpAppBar = binding.appbarSettings.layoutParams as MarginLayoutParams | ||
| 137 | mlpAppBar.leftMargin = leftInsets | ||
| 138 | mlpAppBar.rightMargin = rightInsets | ||
| 139 | binding.appbarSettings.layoutParams = mlpAppBar | ||
| 140 | windowInsets | 132 | windowInsets |
| 141 | } | 133 | } |
| 142 | } | 134 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt index 5ab38ffda..ff4f0e5df 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt | |||
| @@ -13,7 +13,6 @@ import android.os.Bundle | |||
| 13 | import android.view.LayoutInflater | 13 | import android.view.LayoutInflater |
| 14 | import android.view.View | 14 | import android.view.View |
| 15 | import android.view.ViewGroup | 15 | import android.view.ViewGroup |
| 16 | import android.view.ViewGroup.MarginLayoutParams | ||
| 17 | import android.widget.Toast | 16 | import android.widget.Toast |
| 18 | import androidx.core.view.ViewCompat | 17 | import androidx.core.view.ViewCompat |
| 19 | import androidx.core.view.WindowInsetsCompat | 18 | import androidx.core.view.WindowInsetsCompat |
| @@ -26,6 +25,7 @@ import org.yuzu.yuzu_emu.BuildConfig | |||
| 26 | import org.yuzu.yuzu_emu.R | 25 | import org.yuzu.yuzu_emu.R |
| 27 | import org.yuzu.yuzu_emu.databinding.FragmentAboutBinding | 26 | import org.yuzu.yuzu_emu.databinding.FragmentAboutBinding |
| 28 | import org.yuzu.yuzu_emu.model.HomeViewModel | 27 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 28 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 29 | 29 | ||
| 30 | class AboutFragment : Fragment() { | 30 | class AboutFragment : Fragment() { |
| 31 | private var _binding: FragmentAboutBinding? = null | 31 | private var _binding: FragmentAboutBinding? = null |
| @@ -114,15 +114,8 @@ class AboutFragment : Fragment() { | |||
| 114 | val leftInsets = barInsets.left + cutoutInsets.left | 114 | val leftInsets = barInsets.left + cutoutInsets.left |
| 115 | val rightInsets = barInsets.right + cutoutInsets.right | 115 | val rightInsets = barInsets.right + cutoutInsets.right |
| 116 | 116 | ||
| 117 | val mlpToolbar = binding.toolbarAbout.layoutParams as MarginLayoutParams | 117 | binding.toolbarAbout.updateMargins(left = leftInsets, right = rightInsets) |
| 118 | mlpToolbar.leftMargin = leftInsets | 118 | binding.scrollAbout.updateMargins(left = leftInsets, right = rightInsets) |
| 119 | mlpToolbar.rightMargin = rightInsets | ||
| 120 | binding.toolbarAbout.layoutParams = mlpToolbar | ||
| 121 | |||
| 122 | val mlpScrollAbout = binding.scrollAbout.layoutParams as MarginLayoutParams | ||
| 123 | mlpScrollAbout.leftMargin = leftInsets | ||
| 124 | mlpScrollAbout.rightMargin = rightInsets | ||
| 125 | binding.scrollAbout.layoutParams = mlpScrollAbout | ||
| 126 | 119 | ||
| 127 | binding.contentAbout.updatePadding(bottom = barInsets.bottom) | 120 | binding.contentAbout.updatePadding(bottom = barInsets.bottom) |
| 128 | 121 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt index adb65812c..f5647fa95 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt | |||
| @@ -31,6 +31,7 @@ import org.yuzu.yuzu_emu.model.AddonViewModel | |||
| 31 | import org.yuzu.yuzu_emu.model.HomeViewModel | 31 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 32 | import org.yuzu.yuzu_emu.utils.AddonUtil | 32 | import org.yuzu.yuzu_emu.utils.AddonUtil |
| 33 | import org.yuzu.yuzu_emu.utils.FileUtil.copyFilesTo | 33 | import org.yuzu.yuzu_emu.utils.FileUtil.copyFilesTo |
| 34 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 34 | import java.io.File | 35 | import java.io.File |
| 35 | 36 | ||
| 36 | class AddonsFragment : Fragment() { | 37 | class AddonsFragment : Fragment() { |
| @@ -202,27 +203,19 @@ class AddonsFragment : Fragment() { | |||
| 202 | val leftInsets = barInsets.left + cutoutInsets.left | 203 | val leftInsets = barInsets.left + cutoutInsets.left |
| 203 | val rightInsets = barInsets.right + cutoutInsets.right | 204 | val rightInsets = barInsets.right + cutoutInsets.right |
| 204 | 205 | ||
| 205 | val mlpToolbar = binding.toolbarAddons.layoutParams as ViewGroup.MarginLayoutParams | 206 | binding.toolbarAddons.updateMargins(left = leftInsets, right = rightInsets) |
| 206 | mlpToolbar.leftMargin = leftInsets | 207 | binding.listAddons.updateMargins(left = leftInsets, right = rightInsets) |
| 207 | mlpToolbar.rightMargin = rightInsets | ||
| 208 | binding.toolbarAddons.layoutParams = mlpToolbar | ||
| 209 | |||
| 210 | val mlpAddonsList = binding.listAddons.layoutParams as ViewGroup.MarginLayoutParams | ||
| 211 | mlpAddonsList.leftMargin = leftInsets | ||
| 212 | mlpAddonsList.rightMargin = rightInsets | ||
| 213 | binding.listAddons.layoutParams = mlpAddonsList | ||
| 214 | binding.listAddons.updatePadding( | 208 | binding.listAddons.updatePadding( |
| 215 | bottom = barInsets.bottom + | 209 | bottom = barInsets.bottom + |
| 216 | resources.getDimensionPixelSize(R.dimen.spacing_bottom_list_fab) | 210 | resources.getDimensionPixelSize(R.dimen.spacing_bottom_list_fab) |
| 217 | ) | 211 | ) |
| 218 | 212 | ||
| 219 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) | 213 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) |
| 220 | val mlpFab = | 214 | binding.buttonInstall.updateMargins( |
| 221 | binding.buttonInstall.layoutParams as ViewGroup.MarginLayoutParams | 215 | left = leftInsets + fabSpacing, |
| 222 | mlpFab.leftMargin = leftInsets + fabSpacing | 216 | right = rightInsets + fabSpacing, |
| 223 | mlpFab.rightMargin = rightInsets + fabSpacing | 217 | bottom = barInsets.bottom + fabSpacing |
| 224 | mlpFab.bottomMargin = barInsets.bottom + fabSpacing | 218 | ) |
| 225 | binding.buttonInstall.layoutParams = mlpFab | ||
| 226 | 219 | ||
| 227 | windowInsets | 220 | windowInsets |
| 228 | } | 221 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt index 1f66b440d..73ca40484 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt | |||
| @@ -21,6 +21,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentAppletLauncherBinding | |||
| 21 | import org.yuzu.yuzu_emu.model.Applet | 21 | import org.yuzu.yuzu_emu.model.Applet |
| 22 | import org.yuzu.yuzu_emu.model.AppletInfo | 22 | import org.yuzu.yuzu_emu.model.AppletInfo |
| 23 | import org.yuzu.yuzu_emu.model.HomeViewModel | 23 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 24 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 24 | 25 | ||
| 25 | class AppletLauncherFragment : Fragment() { | 26 | class AppletLauncherFragment : Fragment() { |
| 26 | private var _binding: FragmentAppletLauncherBinding? = null | 27 | private var _binding: FragmentAppletLauncherBinding? = null |
| @@ -95,16 +96,8 @@ class AppletLauncherFragment : Fragment() { | |||
| 95 | val leftInsets = barInsets.left + cutoutInsets.left | 96 | val leftInsets = barInsets.left + cutoutInsets.left |
| 96 | val rightInsets = barInsets.right + cutoutInsets.right | 97 | val rightInsets = barInsets.right + cutoutInsets.right |
| 97 | 98 | ||
| 98 | val mlpAppBar = binding.toolbarApplets.layoutParams as ViewGroup.MarginLayoutParams | 99 | binding.toolbarApplets.updateMargins(left = leftInsets, right = rightInsets) |
| 99 | mlpAppBar.leftMargin = leftInsets | 100 | binding.listApplets.updateMargins(left = leftInsets, right = rightInsets) |
| 100 | mlpAppBar.rightMargin = rightInsets | ||
| 101 | binding.toolbarApplets.layoutParams = mlpAppBar | ||
| 102 | |||
| 103 | val mlpListApplets = | ||
| 104 | binding.listApplets.layoutParams as ViewGroup.MarginLayoutParams | ||
| 105 | mlpListApplets.leftMargin = leftInsets | ||
| 106 | mlpListApplets.rightMargin = rightInsets | ||
| 107 | binding.listApplets.layoutParams = mlpListApplets | ||
| 108 | 101 | ||
| 109 | binding.listApplets.updatePadding(bottom = barInsets.bottom) | 102 | binding.listApplets.updatePadding(bottom = barInsets.bottom) |
| 110 | 103 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt index bf017cd7c..41cff46c1 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt | |||
| @@ -34,6 +34,7 @@ import org.yuzu.yuzu_emu.model.HomeViewModel | |||
| 34 | import org.yuzu.yuzu_emu.utils.FileUtil | 34 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 35 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper | 35 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper |
| 36 | import org.yuzu.yuzu_emu.utils.NativeConfig | 36 | import org.yuzu.yuzu_emu.utils.NativeConfig |
| 37 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 37 | import java.io.File | 38 | import java.io.File |
| 38 | import java.io.IOException | 39 | import java.io.IOException |
| 39 | 40 | ||
| @@ -141,23 +142,15 @@ class DriverManagerFragment : Fragment() { | |||
| 141 | val leftInsets = barInsets.left + cutoutInsets.left | 142 | val leftInsets = barInsets.left + cutoutInsets.left |
| 142 | val rightInsets = barInsets.right + cutoutInsets.right | 143 | val rightInsets = barInsets.right + cutoutInsets.right |
| 143 | 144 | ||
| 144 | val mlpAppBar = binding.toolbarDrivers.layoutParams as ViewGroup.MarginLayoutParams | 145 | binding.toolbarDrivers.updateMargins(left = leftInsets, right = rightInsets) |
| 145 | mlpAppBar.leftMargin = leftInsets | 146 | binding.listDrivers.updateMargins(left = leftInsets, right = rightInsets) |
| 146 | mlpAppBar.rightMargin = rightInsets | ||
| 147 | binding.toolbarDrivers.layoutParams = mlpAppBar | ||
| 148 | |||
| 149 | val mlplistDrivers = binding.listDrivers.layoutParams as ViewGroup.MarginLayoutParams | ||
| 150 | mlplistDrivers.leftMargin = leftInsets | ||
| 151 | mlplistDrivers.rightMargin = rightInsets | ||
| 152 | binding.listDrivers.layoutParams = mlplistDrivers | ||
| 153 | 147 | ||
| 154 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) | 148 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) |
| 155 | val mlpFab = | 149 | binding.buttonInstall.updateMargins( |
| 156 | binding.buttonInstall.layoutParams as ViewGroup.MarginLayoutParams | 150 | left = leftInsets + fabSpacing, |
| 157 | mlpFab.leftMargin = leftInsets + fabSpacing | 151 | right = rightInsets + fabSpacing, |
| 158 | mlpFab.rightMargin = rightInsets + fabSpacing | 152 | bottom = barInsets.bottom + fabSpacing |
| 159 | mlpFab.bottomMargin = barInsets.bottom + fabSpacing | 153 | ) |
| 160 | binding.buttonInstall.layoutParams = mlpFab | ||
| 161 | 154 | ||
| 162 | binding.listDrivers.updatePadding( | 155 | binding.listDrivers.updatePadding( |
| 163 | bottom = barInsets.bottom + | 156 | bottom = barInsets.bottom + |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EarlyAccessFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EarlyAccessFragment.kt index dbc16da4a..0534b68ce 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EarlyAccessFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EarlyAccessFragment.kt | |||
| @@ -19,6 +19,7 @@ import com.google.android.material.transition.MaterialSharedAxis | |||
| 19 | import org.yuzu.yuzu_emu.R | 19 | import org.yuzu.yuzu_emu.R |
| 20 | import org.yuzu.yuzu_emu.databinding.FragmentEarlyAccessBinding | 20 | import org.yuzu.yuzu_emu.databinding.FragmentEarlyAccessBinding |
| 21 | import org.yuzu.yuzu_emu.model.HomeViewModel | 21 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 22 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 22 | 23 | ||
| 23 | class EarlyAccessFragment : Fragment() { | 24 | class EarlyAccessFragment : Fragment() { |
| 24 | private var _binding: FragmentEarlyAccessBinding? = null | 25 | private var _binding: FragmentEarlyAccessBinding? = null |
| @@ -73,10 +74,7 @@ class EarlyAccessFragment : Fragment() { | |||
| 73 | val leftInsets = barInsets.left + cutoutInsets.left | 74 | val leftInsets = barInsets.left + cutoutInsets.left |
| 74 | val rightInsets = barInsets.right + cutoutInsets.right | 75 | val rightInsets = barInsets.right + cutoutInsets.right |
| 75 | 76 | ||
| 76 | val mlpAppBar = binding.appbarEa.layoutParams as ViewGroup.MarginLayoutParams | 77 | binding.appbarEa.updateMargins(left = leftInsets, right = rightInsets) |
| 77 | mlpAppBar.leftMargin = leftInsets | ||
| 78 | mlpAppBar.rightMargin = rightInsets | ||
| 79 | binding.appbarEa.layoutParams = mlpAppBar | ||
| 80 | 78 | ||
| 81 | binding.scrollEa.updatePadding( | 79 | binding.scrollEa.updatePadding( |
| 82 | left = leftInsets, | 80 | left = leftInsets, |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt index 341a37fdb..5c558b1a5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt | |||
| @@ -26,6 +26,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentFoldersBinding | |||
| 26 | import org.yuzu.yuzu_emu.model.GamesViewModel | 26 | import org.yuzu.yuzu_emu.model.GamesViewModel |
| 27 | import org.yuzu.yuzu_emu.model.HomeViewModel | 27 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 28 | import org.yuzu.yuzu_emu.ui.main.MainActivity | 28 | import org.yuzu.yuzu_emu.ui.main.MainActivity |
| 29 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 29 | 30 | ||
| 30 | class GameFoldersFragment : Fragment() { | 31 | class GameFoldersFragment : Fragment() { |
| 31 | private var _binding: FragmentFoldersBinding? = null | 32 | private var _binding: FragmentFoldersBinding? = null |
| @@ -100,23 +101,16 @@ class GameFoldersFragment : Fragment() { | |||
| 100 | val leftInsets = barInsets.left + cutoutInsets.left | 101 | val leftInsets = barInsets.left + cutoutInsets.left |
| 101 | val rightInsets = barInsets.right + cutoutInsets.right | 102 | val rightInsets = barInsets.right + cutoutInsets.right |
| 102 | 103 | ||
| 103 | val mlpToolbar = binding.toolbarFolders.layoutParams as ViewGroup.MarginLayoutParams | 104 | binding.toolbarFolders.updateMargins(left = leftInsets, right = rightInsets) |
| 104 | mlpToolbar.leftMargin = leftInsets | ||
| 105 | mlpToolbar.rightMargin = rightInsets | ||
| 106 | binding.toolbarFolders.layoutParams = mlpToolbar | ||
| 107 | 105 | ||
| 108 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) | 106 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) |
| 109 | val mlpFab = | 107 | binding.buttonAdd.updateMargins( |
| 110 | binding.buttonAdd.layoutParams as ViewGroup.MarginLayoutParams | 108 | left = leftInsets + fabSpacing, |
| 111 | mlpFab.leftMargin = leftInsets + fabSpacing | 109 | right = rightInsets + fabSpacing, |
| 112 | mlpFab.rightMargin = rightInsets + fabSpacing | 110 | bottom = barInsets.bottom + fabSpacing |
| 113 | mlpFab.bottomMargin = barInsets.bottom + fabSpacing | 111 | ) |
| 114 | binding.buttonAdd.layoutParams = mlpFab | 112 | |
| 115 | 113 | binding.listFolders.updateMargins(left = leftInsets, right = rightInsets) | |
| 116 | val mlpListFolders = binding.listFolders.layoutParams as ViewGroup.MarginLayoutParams | ||
| 117 | mlpListFolders.leftMargin = leftInsets | ||
| 118 | mlpListFolders.rightMargin = rightInsets | ||
| 119 | binding.listFolders.layoutParams = mlpListFolders | ||
| 120 | 114 | ||
| 121 | binding.listFolders.updatePadding( | 115 | binding.listFolders.updatePadding( |
| 122 | bottom = barInsets.bottom + | 116 | bottom = barInsets.bottom + |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt index 5aa3f453f..dbd56e84f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt | |||
| @@ -27,6 +27,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentGameInfoBinding | |||
| 27 | import org.yuzu.yuzu_emu.model.GameVerificationResult | 27 | import org.yuzu.yuzu_emu.model.GameVerificationResult |
| 28 | import org.yuzu.yuzu_emu.model.HomeViewModel | 28 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 29 | import org.yuzu.yuzu_emu.utils.GameMetadata | 29 | import org.yuzu.yuzu_emu.utils.GameMetadata |
| 30 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 30 | 31 | ||
| 31 | class GameInfoFragment : Fragment() { | 32 | class GameInfoFragment : Fragment() { |
| 32 | private var _binding: FragmentGameInfoBinding? = null | 33 | private var _binding: FragmentGameInfoBinding? = null |
| @@ -122,11 +123,13 @@ class GameInfoFragment : Fragment() { | |||
| 122 | titleId = R.string.verify_success, | 123 | titleId = R.string.verify_success, |
| 123 | descriptionId = R.string.operation_completed_successfully | 124 | descriptionId = R.string.operation_completed_successfully |
| 124 | ) | 125 | ) |
| 126 | |||
| 125 | GameVerificationResult.Failed -> | 127 | GameVerificationResult.Failed -> |
| 126 | MessageDialogFragment.newInstance( | 128 | MessageDialogFragment.newInstance( |
| 127 | titleId = R.string.verify_failure, | 129 | titleId = R.string.verify_failure, |
| 128 | descriptionId = R.string.verify_failure_description | 130 | descriptionId = R.string.verify_failure_description |
| 129 | ) | 131 | ) |
| 132 | |||
| 130 | GameVerificationResult.NotImplemented -> | 133 | GameVerificationResult.NotImplemented -> |
| 131 | MessageDialogFragment.newInstance( | 134 | MessageDialogFragment.newInstance( |
| 132 | titleId = R.string.verify_no_result, | 135 | titleId = R.string.verify_no_result, |
| @@ -165,15 +168,8 @@ class GameInfoFragment : Fragment() { | |||
| 165 | val leftInsets = barInsets.left + cutoutInsets.left | 168 | val leftInsets = barInsets.left + cutoutInsets.left |
| 166 | val rightInsets = barInsets.right + cutoutInsets.right | 169 | val rightInsets = barInsets.right + cutoutInsets.right |
| 167 | 170 | ||
| 168 | val mlpToolbar = binding.toolbarInfo.layoutParams as ViewGroup.MarginLayoutParams | 171 | binding.toolbarInfo.updateMargins(left = leftInsets, right = rightInsets) |
| 169 | mlpToolbar.leftMargin = leftInsets | 172 | binding.scrollInfo.updateMargins(left = leftInsets, right = rightInsets) |
| 170 | mlpToolbar.rightMargin = rightInsets | ||
| 171 | binding.toolbarInfo.layoutParams = mlpToolbar | ||
| 172 | |||
| 173 | val mlpScrollAbout = binding.scrollInfo.layoutParams as ViewGroup.MarginLayoutParams | ||
| 174 | mlpScrollAbout.leftMargin = leftInsets | ||
| 175 | mlpScrollAbout.rightMargin = rightInsets | ||
| 176 | binding.scrollInfo.layoutParams = mlpScrollAbout | ||
| 177 | 173 | ||
| 178 | binding.contentInfo.updatePadding(bottom = barInsets.bottom) | 174 | binding.contentInfo.updatePadding(bottom = barInsets.bottom) |
| 179 | 175 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt index 582df0133..d14b2c634 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt | |||
| @@ -46,6 +46,7 @@ import org.yuzu.yuzu_emu.utils.FileUtil | |||
| 46 | import org.yuzu.yuzu_emu.utils.GameIconUtils | 46 | import org.yuzu.yuzu_emu.utils.GameIconUtils |
| 47 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper | 47 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper |
| 48 | import org.yuzu.yuzu_emu.utils.MemoryUtil | 48 | import org.yuzu.yuzu_emu.utils.MemoryUtil |
| 49 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 49 | import java.io.BufferedOutputStream | 50 | import java.io.BufferedOutputStream |
| 50 | import java.io.File | 51 | import java.io.File |
| 51 | 52 | ||
| @@ -320,46 +321,25 @@ class GamePropertiesFragment : Fragment() { | |||
| 320 | 321 | ||
| 321 | val smallLayout = resources.getBoolean(R.bool.small_layout) | 322 | val smallLayout = resources.getBoolean(R.bool.small_layout) |
| 322 | if (smallLayout) { | 323 | if (smallLayout) { |
| 323 | val mlpListAll = | 324 | binding.listAll.updateMargins(left = leftInsets, right = rightInsets) |
| 324 | binding.listAll.layoutParams as ViewGroup.MarginLayoutParams | ||
| 325 | mlpListAll.leftMargin = leftInsets | ||
| 326 | mlpListAll.rightMargin = rightInsets | ||
| 327 | binding.listAll.layoutParams = mlpListAll | ||
| 328 | } else { | 325 | } else { |
| 329 | if (ViewCompat.getLayoutDirection(binding.root) == | 326 | if (ViewCompat.getLayoutDirection(binding.root) == |
| 330 | ViewCompat.LAYOUT_DIRECTION_LTR | 327 | ViewCompat.LAYOUT_DIRECTION_LTR |
| 331 | ) { | 328 | ) { |
| 332 | val mlpListAll = | 329 | binding.listAll.updateMargins(right = rightInsets) |
| 333 | binding.listAll.layoutParams as ViewGroup.MarginLayoutParams | 330 | binding.iconLayout!!.updateMargins(top = barInsets.top, left = leftInsets) |
| 334 | mlpListAll.rightMargin = rightInsets | ||
| 335 | binding.listAll.layoutParams = mlpListAll | ||
| 336 | |||
| 337 | val mlpIconLayout = | ||
| 338 | binding.iconLayout!!.layoutParams as ViewGroup.MarginLayoutParams | ||
| 339 | mlpIconLayout.topMargin = barInsets.top | ||
| 340 | mlpIconLayout.leftMargin = leftInsets | ||
| 341 | binding.iconLayout!!.layoutParams = mlpIconLayout | ||
| 342 | } else { | 331 | } else { |
| 343 | val mlpListAll = | 332 | binding.listAll.updateMargins(left = leftInsets) |
| 344 | binding.listAll.layoutParams as ViewGroup.MarginLayoutParams | 333 | binding.iconLayout!!.updateMargins(top = barInsets.top, right = rightInsets) |
| 345 | mlpListAll.leftMargin = leftInsets | ||
| 346 | binding.listAll.layoutParams = mlpListAll | ||
| 347 | |||
| 348 | val mlpIconLayout = | ||
| 349 | binding.iconLayout!!.layoutParams as ViewGroup.MarginLayoutParams | ||
| 350 | mlpIconLayout.topMargin = barInsets.top | ||
| 351 | mlpIconLayout.rightMargin = rightInsets | ||
| 352 | binding.iconLayout!!.layoutParams = mlpIconLayout | ||
| 353 | } | 334 | } |
| 354 | } | 335 | } |
| 355 | 336 | ||
| 356 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) | 337 | val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab) |
| 357 | val mlpFab = | 338 | binding.buttonStart.updateMargins( |
| 358 | binding.buttonStart.layoutParams as ViewGroup.MarginLayoutParams | 339 | left = leftInsets + fabSpacing, |
| 359 | mlpFab.leftMargin = leftInsets + fabSpacing | 340 | right = rightInsets + fabSpacing, |
| 360 | mlpFab.rightMargin = rightInsets + fabSpacing | 341 | bottom = barInsets.bottom + fabSpacing |
| 361 | mlpFab.bottomMargin = barInsets.bottom + fabSpacing | 342 | ) |
| 362 | binding.buttonStart.layoutParams = mlpFab | ||
| 363 | 343 | ||
| 364 | binding.layoutAll.updatePadding( | 344 | binding.layoutAll.updatePadding( |
| 365 | top = barInsets.top, | 345 | top = barInsets.top, |
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 1f3578b22..87e130d3e 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 | |||
| @@ -12,7 +12,6 @@ import android.provider.DocumentsContract | |||
| 12 | import android.view.LayoutInflater | 12 | import android.view.LayoutInflater |
| 13 | import android.view.View | 13 | import android.view.View |
| 14 | import android.view.ViewGroup | 14 | import android.view.ViewGroup |
| 15 | import android.view.ViewGroup.MarginLayoutParams | ||
| 16 | import android.widget.Toast | 15 | import android.widget.Toast |
| 17 | import androidx.appcompat.app.AppCompatActivity | 16 | import androidx.appcompat.app.AppCompatActivity |
| 18 | import androidx.core.app.ActivityCompat | 17 | import androidx.core.app.ActivityCompat |
| @@ -44,6 +43,7 @@ import org.yuzu.yuzu_emu.ui.main.MainActivity | |||
| 44 | import org.yuzu.yuzu_emu.utils.FileUtil | 43 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 45 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper | 44 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper |
| 46 | import org.yuzu.yuzu_emu.utils.Log | 45 | import org.yuzu.yuzu_emu.utils.Log |
| 46 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 47 | 47 | ||
| 48 | class HomeSettingsFragment : Fragment() { | 48 | class HomeSettingsFragment : Fragment() { |
| 49 | private var _binding: FragmentHomeSettingsBinding? = null | 49 | private var _binding: FragmentHomeSettingsBinding? = null |
| @@ -408,10 +408,7 @@ class HomeSettingsFragment : Fragment() { | |||
| 408 | bottom = barInsets.bottom | 408 | bottom = barInsets.bottom |
| 409 | ) | 409 | ) |
| 410 | 410 | ||
| 411 | val mlpScrollSettings = binding.scrollViewSettings.layoutParams as MarginLayoutParams | 411 | binding.scrollViewSettings.updateMargins(left = leftInsets, right = rightInsets) |
| 412 | mlpScrollSettings.leftMargin = leftInsets | ||
| 413 | mlpScrollSettings.rightMargin = rightInsets | ||
| 414 | binding.scrollViewSettings.layoutParams = mlpScrollSettings | ||
| 415 | 412 | ||
| 416 | binding.linearLayoutSettings.updatePadding(bottom = spacingNavigation) | 413 | binding.linearLayoutSettings.updatePadding(bottom = spacingNavigation) |
| 417 | 414 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt index 7df8e6bf4..63112dc6f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt | |||
| @@ -34,6 +34,7 @@ import org.yuzu.yuzu_emu.model.TaskState | |||
| 34 | import org.yuzu.yuzu_emu.ui.main.MainActivity | 34 | import org.yuzu.yuzu_emu.ui.main.MainActivity |
| 35 | import org.yuzu.yuzu_emu.utils.DirectoryInitialization | 35 | import org.yuzu.yuzu_emu.utils.DirectoryInitialization |
| 36 | import org.yuzu.yuzu_emu.utils.FileUtil | 36 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 37 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 37 | import java.io.BufferedOutputStream | 38 | import java.io.BufferedOutputStream |
| 38 | import java.io.File | 39 | import java.io.File |
| 39 | import java.math.BigInteger | 40 | import java.math.BigInteger |
| @@ -172,16 +173,8 @@ class InstallableFragment : Fragment() { | |||
| 172 | val leftInsets = barInsets.left + cutoutInsets.left | 173 | val leftInsets = barInsets.left + cutoutInsets.left |
| 173 | val rightInsets = barInsets.right + cutoutInsets.right | 174 | val rightInsets = barInsets.right + cutoutInsets.right |
| 174 | 175 | ||
| 175 | val mlpAppBar = binding.toolbarInstallables.layoutParams as ViewGroup.MarginLayoutParams | 176 | binding.toolbarInstallables.updateMargins(left = leftInsets, right = rightInsets) |
| 176 | mlpAppBar.leftMargin = leftInsets | 177 | binding.listInstallables.updateMargins(left = leftInsets, right = rightInsets) |
| 177 | mlpAppBar.rightMargin = rightInsets | ||
| 178 | binding.toolbarInstallables.layoutParams = mlpAppBar | ||
| 179 | |||
| 180 | val mlpScrollAbout = | ||
| 181 | binding.listInstallables.layoutParams as ViewGroup.MarginLayoutParams | ||
| 182 | mlpScrollAbout.leftMargin = leftInsets | ||
| 183 | mlpScrollAbout.rightMargin = rightInsets | ||
| 184 | binding.listInstallables.layoutParams = mlpScrollAbout | ||
| 185 | 178 | ||
| 186 | binding.listInstallables.updatePadding(bottom = barInsets.bottom) | 179 | binding.listInstallables.updatePadding(bottom = barInsets.bottom) |
| 187 | 180 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt index b6e9129f7..f17f621f8 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt | |||
| @@ -7,7 +7,6 @@ import android.os.Bundle | |||
| 7 | import android.view.LayoutInflater | 7 | 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 | ||
| 11 | import androidx.appcompat.app.AppCompatActivity | 10 | import androidx.appcompat.app.AppCompatActivity |
| 12 | import androidx.core.view.ViewCompat | 11 | import androidx.core.view.ViewCompat |
| 13 | import androidx.core.view.WindowInsetsCompat | 12 | import androidx.core.view.WindowInsetsCompat |
| @@ -22,6 +21,7 @@ import org.yuzu.yuzu_emu.adapters.LicenseAdapter | |||
| 22 | import org.yuzu.yuzu_emu.databinding.FragmentLicensesBinding | 21 | import org.yuzu.yuzu_emu.databinding.FragmentLicensesBinding |
| 23 | import org.yuzu.yuzu_emu.model.HomeViewModel | 22 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 24 | import org.yuzu.yuzu_emu.model.License | 23 | import org.yuzu.yuzu_emu.model.License |
| 24 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 25 | 25 | ||
| 26 | class LicensesFragment : Fragment() { | 26 | class LicensesFragment : Fragment() { |
| 27 | private var _binding: FragmentLicensesBinding? = null | 27 | private var _binding: FragmentLicensesBinding? = null |
| @@ -122,15 +122,8 @@ class LicensesFragment : Fragment() { | |||
| 122 | val leftInsets = barInsets.left + cutoutInsets.left | 122 | val leftInsets = barInsets.left + cutoutInsets.left |
| 123 | val rightInsets = barInsets.right + cutoutInsets.right | 123 | val rightInsets = barInsets.right + cutoutInsets.right |
| 124 | 124 | ||
| 125 | val mlpAppBar = binding.appbarLicenses.layoutParams as MarginLayoutParams | 125 | binding.appbarLicenses.updateMargins(left = leftInsets, right = rightInsets) |
| 126 | mlpAppBar.leftMargin = leftInsets | 126 | binding.listLicenses.updateMargins(left = leftInsets, right = rightInsets) |
| 127 | mlpAppBar.rightMargin = rightInsets | ||
| 128 | binding.appbarLicenses.layoutParams = mlpAppBar | ||
| 129 | |||
| 130 | val mlpScrollAbout = binding.listLicenses.layoutParams as MarginLayoutParams | ||
| 131 | mlpScrollAbout.leftMargin = leftInsets | ||
| 132 | mlpScrollAbout.rightMargin = rightInsets | ||
| 133 | binding.listLicenses.layoutParams = mlpScrollAbout | ||
| 134 | 127 | ||
| 135 | binding.listLicenses.updatePadding(bottom = barInsets.bottom) | 128 | binding.listLicenses.updatePadding(bottom = barInsets.bottom) |
| 136 | 129 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SettingsSearchFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SettingsSearchFragment.kt index f95d545bf..a135b80b4 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SettingsSearchFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SettingsSearchFragment.kt | |||
| @@ -29,6 +29,7 @@ import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem | |||
| 29 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter | 29 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter |
| 30 | import org.yuzu.yuzu_emu.model.SettingsViewModel | 30 | import org.yuzu.yuzu_emu.model.SettingsViewModel |
| 31 | import org.yuzu.yuzu_emu.utils.NativeConfig | 31 | import org.yuzu.yuzu_emu.utils.NativeConfig |
| 32 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 32 | 33 | ||
| 33 | class SettingsSearchFragment : Fragment() { | 34 | class SettingsSearchFragment : Fragment() { |
| 34 | private var _binding: FragmentSettingsSearchBinding? = null | 35 | private var _binding: FragmentSettingsSearchBinding? = null |
| @@ -174,15 +175,14 @@ class SettingsSearchFragment : Fragment() { | |||
| 174 | bottom = barInsets.bottom | 175 | bottom = barInsets.bottom |
| 175 | ) | 176 | ) |
| 176 | 177 | ||
| 177 | val mlpSettingsList = binding.settingsList.layoutParams as ViewGroup.MarginLayoutParams | 178 | binding.settingsList.updateMargins( |
| 178 | mlpSettingsList.leftMargin = leftInsets + sideMargin | 179 | left = leftInsets + sideMargin, |
| 179 | mlpSettingsList.rightMargin = rightInsets + sideMargin | 180 | right = rightInsets + sideMargin |
| 180 | binding.settingsList.layoutParams = mlpSettingsList | 181 | ) |
| 181 | 182 | binding.divider.updateMargins( | |
| 182 | val mlpDivider = binding.divider.layoutParams as ViewGroup.MarginLayoutParams | 183 | left = leftInsets + sideMargin, |
| 183 | mlpDivider.leftMargin = leftInsets + sideMargin | 184 | right = rightInsets + sideMargin |
| 184 | mlpDivider.rightMargin = rightInsets + sideMargin | 185 | ) |
| 185 | binding.divider.layoutParams = mlpDivider | ||
| 186 | 186 | ||
| 187 | windowInsets | 187 | windowInsets |
| 188 | } | 188 | } |
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 54380323e..23ca49b53 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,7 +8,6 @@ import android.os.Bundle | |||
| 8 | import android.view.LayoutInflater | 8 | import android.view.LayoutInflater |
| 9 | import android.view.View | 9 | import android.view.View |
| 10 | import android.view.ViewGroup | 10 | import android.view.ViewGroup |
| 11 | import android.view.ViewGroup.MarginLayoutParams | ||
| 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 |
| @@ -27,6 +26,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentGamesBinding | |||
| 27 | import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager | 26 | import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager |
| 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 |
| 29 | import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins | ||
| 30 | 30 | ||
| 31 | class GamesFragment : Fragment() { | 31 | class GamesFragment : Fragment() { |
| 32 | private var _binding: FragmentGamesBinding? = null | 32 | private var _binding: FragmentGamesBinding? = null |
| @@ -169,15 +169,16 @@ class GamesFragment : Fragment() { | |||
| 169 | 169 | ||
| 170 | val leftInsets = barInsets.left + cutoutInsets.left | 170 | val leftInsets = barInsets.left + cutoutInsets.left |
| 171 | val rightInsets = barInsets.right + cutoutInsets.right | 171 | val rightInsets = barInsets.right + cutoutInsets.right |
| 172 | val mlpSwipe = binding.swipeRefresh.layoutParams as MarginLayoutParams | 172 | val left: Int |
| 173 | val right: Int | ||
| 173 | if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_LTR) { | 174 | if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_LTR) { |
| 174 | mlpSwipe.leftMargin = leftInsets + spacingNavigationRail | 175 | left = leftInsets + spacingNavigationRail |
| 175 | mlpSwipe.rightMargin = rightInsets | 176 | right = rightInsets |
| 176 | } else { | 177 | } else { |
| 177 | mlpSwipe.leftMargin = leftInsets | 178 | left = leftInsets |
| 178 | mlpSwipe.rightMargin = rightInsets + spacingNavigationRail | 179 | right = rightInsets + spacingNavigationRail |
| 179 | } | 180 | } |
| 180 | binding.swipeRefresh.layoutParams = mlpSwipe | 181 | binding.swipeRefresh.updateMargins(left = left, right = right) |
| 181 | 182 | ||
| 182 | binding.noticeText.updatePadding(bottom = spacingNavigation) | 183 | binding.noticeText.updatePadding(bottom = spacingNavigation) |
| 183 | 184 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ViewUtils.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ViewUtils.kt index f9a3e4126..ffbfa9337 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ViewUtils.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ViewUtils.kt | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | package org.yuzu.yuzu_emu.utils | 4 | package org.yuzu.yuzu_emu.utils |
| 5 | 5 | ||
| 6 | import android.view.View | 6 | import android.view.View |
| 7 | import android.view.ViewGroup | ||
| 7 | 8 | ||
| 8 | object ViewUtils { | 9 | object ViewUtils { |
| 9 | fun showView(view: View, length: Long = 300) { | 10 | fun showView(view: View, length: Long = 300) { |
| @@ -32,4 +33,28 @@ object ViewUtils { | |||
| 32 | view.visibility = View.INVISIBLE | 33 | view.visibility = View.INVISIBLE |
| 33 | }.start() | 34 | }.start() |
| 34 | } | 35 | } |
| 36 | |||
| 37 | fun View.updateMargins( | ||
| 38 | left: Int = -1, | ||
| 39 | top: Int = -1, | ||
| 40 | right: Int = -1, | ||
| 41 | bottom: Int = -1 | ||
| 42 | ) { | ||
| 43 | val layoutParams = this.layoutParams as ViewGroup.MarginLayoutParams | ||
| 44 | layoutParams.apply { | ||
| 45 | if (left != -1) { | ||
| 46 | leftMargin = left | ||
| 47 | } | ||
| 48 | if (top != -1) { | ||
| 49 | topMargin = top | ||
| 50 | } | ||
| 51 | if (right != -1) { | ||
| 52 | rightMargin = right | ||
| 53 | } | ||
| 54 | if (bottom != -1) { | ||
| 55 | bottomMargin = bottom | ||
| 56 | } | ||
| 57 | } | ||
| 58 | this.layoutParams = layoutParams | ||
| 59 | } | ||
| 35 | } | 60 | } |