diff options
| author | 2023-12-12 17:06:47 -0500 | |
|---|---|---|
| committer | 2023-12-12 17:25:37 -0500 | |
| commit | 86d26914a2e7b250d346a8aad84783aef1a6850b (patch) | |
| tree | 4d2de4a2863d10343b9e4b96b21499863b5a7f9a /src | |
| parent | android: Prevent editing non-savable settings in per-game settings (diff) | |
| download | yuzu-86d26914a2e7b250d346a8aad84783aef1a6850b.tar.gz yuzu-86d26914a2e7b250d346a8aad84783aef1a6850b.tar.xz yuzu-86d26914a2e7b250d346a8aad84783aef1a6850b.zip | |
android: Rework InstallableProperty view with icon
Diffstat (limited to '')
6 files changed, 191 insertions, 11 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GamePropertiesAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GamePropertiesAdapter.kt index ff6270fa8..95841d786 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GamePropertiesAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GamePropertiesAdapter.kt | |||
| @@ -14,7 +14,7 @@ import androidx.lifecycle.lifecycleScope | |||
| 14 | import androidx.lifecycle.repeatOnLifecycle | 14 | import androidx.lifecycle.repeatOnLifecycle |
| 15 | import androidx.recyclerview.widget.RecyclerView | 15 | import androidx.recyclerview.widget.RecyclerView |
| 16 | import kotlinx.coroutines.launch | 16 | import kotlinx.coroutines.launch |
| 17 | import org.yuzu.yuzu_emu.databinding.CardInstallableBinding | 17 | import org.yuzu.yuzu_emu.databinding.CardInstallableIconBinding |
| 18 | import org.yuzu.yuzu_emu.databinding.CardSimpleOutlinedBinding | 18 | import org.yuzu.yuzu_emu.databinding.CardSimpleOutlinedBinding |
| 19 | import org.yuzu.yuzu_emu.model.GameProperty | 19 | import org.yuzu.yuzu_emu.model.GameProperty |
| 20 | import org.yuzu.yuzu_emu.model.InstallableProperty | 20 | import org.yuzu.yuzu_emu.model.InstallableProperty |
| @@ -42,7 +42,7 @@ class GamePropertiesAdapter( | |||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | else -> InstallablePropertyViewHolder( | 44 | else -> InstallablePropertyViewHolder( |
| 45 | CardInstallableBinding.inflate( | 45 | CardInstallableIconBinding.inflate( |
| 46 | inflater, | 46 | inflater, |
| 47 | parent, | 47 | parent, |
| 48 | false | 48 | false |
| @@ -107,13 +107,20 @@ class GamePropertiesAdapter( | |||
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | inner class InstallablePropertyViewHolder(val binding: CardInstallableBinding) : | 110 | inner class InstallablePropertyViewHolder(val binding: CardInstallableIconBinding) : |
| 111 | GamePropertyViewHolder(binding.root) { | 111 | GamePropertyViewHolder(binding.root) { |
| 112 | override fun bind(property: GameProperty) { | 112 | override fun bind(property: GameProperty) { |
| 113 | val installableProperty = property as InstallableProperty | 113 | val installableProperty = property as InstallableProperty |
| 114 | 114 | ||
| 115 | binding.title.setText(installableProperty.titleId) | 115 | binding.title.setText(installableProperty.titleId) |
| 116 | binding.description.setText(installableProperty.descriptionId) | 116 | binding.description.setText(installableProperty.descriptionId) |
| 117 | binding.icon.setImageDrawable( | ||
| 118 | ResourcesCompat.getDrawable( | ||
| 119 | binding.icon.context.resources, | ||
| 120 | installableProperty.iconId, | ||
| 121 | binding.icon.context.theme | ||
| 122 | ) | ||
| 123 | ) | ||
| 117 | 124 | ||
| 118 | if (installableProperty.install != null) { | 125 | if (installableProperty.install != null) { |
| 119 | binding.buttonInstall.visibility = View.VISIBLE | 126 | binding.buttonInstall.visibility = View.VISIBLE |
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 6ede3f85c..b1d3c0040 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 | |||
| @@ -194,6 +194,7 @@ class GamePropertiesFragment : Fragment() { | |||
| 194 | InstallableProperty( | 194 | InstallableProperty( |
| 195 | R.string.save_data, | 195 | R.string.save_data, |
| 196 | R.string.save_data_description, | 196 | R.string.save_data_description, |
| 197 | R.drawable.ic_save, | ||
| 197 | { | 198 | { |
| 198 | MessageDialogFragment.newInstance( | 199 | MessageDialogFragment.newInstance( |
| 199 | requireActivity(), | 200 | requireActivity(), |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GameProperties.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GameProperties.kt index bb3df5bd0..0135a95be 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GameProperties.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GameProperties.kt | |||
| @@ -10,17 +10,18 @@ import kotlinx.coroutines.flow.StateFlow | |||
| 10 | interface GameProperty { | 10 | interface GameProperty { |
| 11 | @get:StringRes | 11 | @get:StringRes |
| 12 | val titleId: Int | 12 | val titleId: Int |
| 13 | get() = -1 | ||
| 14 | 13 | ||
| 15 | @get:StringRes | 14 | @get:StringRes |
| 16 | val descriptionId: Int | 15 | val descriptionId: Int |
| 17 | get() = -1 | 16 | |
| 17 | @get:DrawableRes | ||
| 18 | val iconId: Int | ||
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | data class SubmenuProperty( | 21 | data class SubmenuProperty( |
| 21 | override val titleId: Int, | 22 | override val titleId: Int, |
| 22 | override val descriptionId: Int, | 23 | override val descriptionId: Int, |
| 23 | @DrawableRes val iconId: Int, | 24 | override val iconId: Int, |
| 24 | val details: (() -> String)? = null, | 25 | val details: (() -> String)? = null, |
| 25 | val detailsFlow: StateFlow<String>? = null, | 26 | val detailsFlow: StateFlow<String>? = null, |
| 26 | val action: () -> Unit | 27 | val action: () -> Unit |
| @@ -29,6 +30,7 @@ data class SubmenuProperty( | |||
| 29 | data class InstallableProperty( | 30 | data class InstallableProperty( |
| 30 | override val titleId: Int, | 31 | override val titleId: Int, |
| 31 | override val descriptionId: Int, | 32 | override val descriptionId: Int, |
| 33 | override val iconId: Int, | ||
| 32 | val install: (() -> Unit)? = null, | 34 | val install: (() -> Unit)? = null, |
| 33 | val export: (() -> Unit)? = null | 35 | val export: (() -> Unit)? = null |
| 34 | ) : GameProperty | 36 | ) : GameProperty |
diff --git a/src/android/app/src/main/res/drawable/ic_save.xml b/src/android/app/src/main/res/drawable/ic_save.xml index a9af3d9cf..5acc2bbab 100644 --- a/src/android/app/src/main/res/drawable/ic_save.xml +++ b/src/android/app/src/main/res/drawable/ic_save.xml | |||
| @@ -1,10 +1,9 @@ | |||
| 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" |
| 2 | android:width="24dp" | 2 | android:width="24dp" |
| 3 | android:height="24dp" | 3 | android:height="24dp" |
| 4 | android:viewportWidth="960" | 4 | android:viewportWidth="24" |
| 5 | android:viewportHeight="960" | 5 | android:viewportHeight="24"> |
| 6 | android:tint="?attr/colorControlNormal"> | ||
| 7 | <path | 6 | <path |
| 8 | android:fillColor="@android:color/white" | 7 | android:fillColor="?attr/colorControlNormal" |
| 9 | android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L647,120Q663,120 677.5,126Q692,132 703,143L817,257Q828,268 834,282.5Q840,297 840,313L840,760Q840,793 816.5,816.5Q793,840 760,840L200,840ZM760,314L646,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760L760,760Q760,760 760,760Q760,760 760,760L760,314ZM480,720Q530,720 565,685Q600,650 600,600Q600,550 565,515Q530,480 480,480Q430,480 395,515Q360,550 360,600Q360,650 395,685Q430,720 480,720ZM280,400L560,400Q577,400 588.5,388.5Q600,377 600,360L600,280Q600,263 588.5,251.5Q577,240 560,240L280,240Q263,240 251.5,251.5Q240,263 240,280L240,360Q240,377 251.5,388.5Q263,400 280,400ZM200,314L200,760Q200,760 200,760Q200,760 200,760L200,760Q200,760 200,760Q200,760 200,760L200,200Q200,200 200,200Q200,200 200,200L200,200L200,314Z"/> | 8 | android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z" /> |
| 10 | </vector> | 9 | </vector> |
diff --git a/src/android/app/src/main/res/layout-w1000dp/card_installable_icon.xml b/src/android/app/src/main/res/layout-w1000dp/card_installable_icon.xml new file mode 100644 index 000000000..59ee1aad3 --- /dev/null +++ b/src/android/app/src/main/res/layout-w1000dp/card_installable_icon.xml | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | style="?attr/materialCardViewOutlinedStyle" | ||
| 6 | android:layout_width="match_parent" | ||
| 7 | android:layout_height="wrap_content" | ||
| 8 | android:layout_marginHorizontal="16dp" | ||
| 9 | android:layout_marginVertical="12dp"> | ||
| 10 | |||
| 11 | <LinearLayout | ||
| 12 | android:layout_width="match_parent" | ||
| 13 | android:layout_height="wrap_content" | ||
| 14 | android:layout_gravity="center" | ||
| 15 | android:orientation="horizontal" | ||
| 16 | android:gravity="center_vertical" | ||
| 17 | android:paddingHorizontal="24dp" | ||
| 18 | android:paddingVertical="16dp"> | ||
| 19 | |||
| 20 | <ImageView | ||
| 21 | android:id="@+id/icon" | ||
| 22 | android:layout_width="24dp" | ||
| 23 | android:layout_height="24dp" | ||
| 24 | android:layout_marginEnd="20dp" | ||
| 25 | android:layout_gravity="center_vertical" | ||
| 26 | app:tint="?attr/colorOnSurface" | ||
| 27 | tools:src="@drawable/ic_settings" /> | ||
| 28 | |||
| 29 | <LinearLayout | ||
| 30 | android:layout_width="0dp" | ||
| 31 | android:layout_height="wrap_content" | ||
| 32 | android:layout_marginEnd="16dp" | ||
| 33 | android:layout_weight="1" | ||
| 34 | android:orientation="vertical"> | ||
| 35 | |||
| 36 | <com.google.android.material.textview.MaterialTextView | ||
| 37 | android:id="@+id/title" | ||
| 38 | style="@style/TextAppearance.Material3.TitleMedium" | ||
| 39 | android:layout_width="match_parent" | ||
| 40 | android:layout_height="wrap_content" | ||
| 41 | android:text="@string/user_data" | ||
| 42 | android:textAlignment="viewStart" /> | ||
| 43 | |||
| 44 | <com.google.android.material.textview.MaterialTextView | ||
| 45 | android:id="@+id/description" | ||
| 46 | style="@style/TextAppearance.Material3.BodyMedium" | ||
| 47 | android:layout_width="match_parent" | ||
| 48 | android:layout_height="wrap_content" | ||
| 49 | android:layout_marginTop="6dp" | ||
| 50 | android:text="@string/user_data_description" | ||
| 51 | android:textAlignment="viewStart" /> | ||
| 52 | |||
| 53 | </LinearLayout> | ||
| 54 | |||
| 55 | <Button | ||
| 56 | android:id="@+id/button_export" | ||
| 57 | style="@style/Widget.Material3.Button.IconButton.Filled.Tonal" | ||
| 58 | android:layout_width="wrap_content" | ||
| 59 | android:layout_height="wrap_content" | ||
| 60 | android:layout_gravity="center_vertical" | ||
| 61 | android:contentDescription="@string/export" | ||
| 62 | android:tooltipText="@string/export" | ||
| 63 | android:visibility="gone" | ||
| 64 | app:icon="@drawable/ic_export" | ||
| 65 | tools:visibility="visible" /> | ||
| 66 | |||
| 67 | <Button | ||
| 68 | android:id="@+id/button_install" | ||
| 69 | style="@style/Widget.Material3.Button.IconButton.Filled.Tonal" | ||
| 70 | android:layout_width="wrap_content" | ||
| 71 | android:layout_height="wrap_content" | ||
| 72 | android:layout_gravity="center_vertical" | ||
| 73 | android:layout_marginStart="12dp" | ||
| 74 | android:contentDescription="@string/string_import" | ||
| 75 | android:tooltipText="@string/string_import" | ||
| 76 | android:visibility="gone" | ||
| 77 | app:icon="@drawable/ic_import" | ||
| 78 | tools:visibility="visible" /> | ||
| 79 | |||
| 80 | </LinearLayout> | ||
| 81 | |||
| 82 | </com.google.android.material.card.MaterialCardView> | ||
diff --git a/src/android/app/src/main/res/layout/card_installable_icon.xml b/src/android/app/src/main/res/layout/card_installable_icon.xml new file mode 100644 index 000000000..4ae5423b1 --- /dev/null +++ b/src/android/app/src/main/res/layout/card_installable_icon.xml | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | style="?attr/materialCardViewOutlinedStyle" | ||
| 6 | android:layout_width="match_parent" | ||
| 7 | android:layout_height="wrap_content" | ||
| 8 | android:layout_marginHorizontal="16dp" | ||
| 9 | android:layout_marginVertical="12dp"> | ||
| 10 | |||
| 11 | <LinearLayout | ||
| 12 | android:layout_width="match_parent" | ||
| 13 | android:layout_height="wrap_content" | ||
| 14 | android:layout_gravity="center" | ||
| 15 | android:orientation="horizontal" | ||
| 16 | android:gravity="center_vertical" | ||
| 17 | android:paddingHorizontal="24dp" | ||
| 18 | android:paddingVertical="16dp"> | ||
| 19 | |||
| 20 | <ImageView | ||
| 21 | android:id="@+id/icon" | ||
| 22 | android:layout_width="24dp" | ||
| 23 | android:layout_height="24dp" | ||
| 24 | android:layout_marginEnd="20dp" | ||
| 25 | android:layout_gravity="center_vertical" | ||
| 26 | app:tint="?attr/colorOnSurface" | ||
| 27 | tools:src="@drawable/ic_settings" /> | ||
| 28 | |||
| 29 | <LinearLayout | ||
| 30 | android:layout_width="0dp" | ||
| 31 | android:layout_height="wrap_content" | ||
| 32 | android:layout_marginEnd="16dp" | ||
| 33 | android:layout_weight="1" | ||
| 34 | android:orientation="vertical"> | ||
| 35 | |||
| 36 | <com.google.android.material.textview.MaterialTextView | ||
| 37 | android:id="@+id/title" | ||
| 38 | style="@style/TextAppearance.Material3.TitleMedium" | ||
| 39 | android:layout_width="match_parent" | ||
| 40 | android:layout_height="wrap_content" | ||
| 41 | android:text="@string/user_data" | ||
| 42 | android:textAlignment="viewStart" /> | ||
| 43 | |||
| 44 | <com.google.android.material.textview.MaterialTextView | ||
| 45 | android:id="@+id/description" | ||
| 46 | style="@style/TextAppearance.Material3.BodyMedium" | ||
| 47 | android:layout_width="match_parent" | ||
| 48 | android:layout_height="wrap_content" | ||
| 49 | android:layout_marginTop="6dp" | ||
| 50 | android:text="@string/user_data_description" | ||
| 51 | android:textAlignment="viewStart" /> | ||
| 52 | |||
| 53 | </LinearLayout> | ||
| 54 | |||
| 55 | <LinearLayout | ||
| 56 | android:layout_width="wrap_content" | ||
| 57 | android:layout_height="wrap_content" | ||
| 58 | android:orientation="vertical"> | ||
| 59 | |||
| 60 | <Button | ||
| 61 | android:id="@+id/button_install" | ||
| 62 | style="@style/Widget.Material3.Button.IconButton.Filled.Tonal" | ||
| 63 | android:layout_width="wrap_content" | ||
| 64 | android:layout_height="wrap_content" | ||
| 65 | android:layout_gravity="center_vertical" | ||
| 66 | android:contentDescription="@string/string_import" | ||
| 67 | android:tooltipText="@string/string_import" | ||
| 68 | android:visibility="gone" | ||
| 69 | app:icon="@drawable/ic_import" | ||
| 70 | tools:visibility="visible" /> | ||
| 71 | |||
| 72 | <Button | ||
| 73 | android:id="@+id/button_export" | ||
| 74 | style="@style/Widget.Material3.Button.IconButton.Filled.Tonal" | ||
| 75 | android:layout_width="wrap_content" | ||
| 76 | android:layout_height="wrap_content" | ||
| 77 | android:layout_gravity="center_vertical" | ||
| 78 | android:layout_marginTop="8dp" | ||
| 79 | android:contentDescription="@string/export" | ||
| 80 | android:tooltipText="@string/export" | ||
| 81 | android:visibility="gone" | ||
| 82 | app:icon="@drawable/ic_export" | ||
| 83 | tools:visibility="visible" /> | ||
| 84 | |||
| 85 | </LinearLayout> | ||
| 86 | |||
| 87 | </LinearLayout> | ||
| 88 | |||
| 89 | </com.google.android.material.card.MaterialCardView> | ||