diff options
| author | 2023-03-07 15:43:32 -0500 | |
|---|---|---|
| committer | 2023-06-03 00:05:35 -0700 | |
| commit | 22b44be0b228133951f7a2651467c8bf9392e712 (patch) | |
| tree | 4c91cbed1fc86b11c7880f99413806bf9fd7cf76 /src/android | |
| parent | android: Convert HeaderSetting to Kotlin (diff) | |
| download | yuzu-22b44be0b228133951f7a2651467c8bf9392e712.tar.gz yuzu-22b44be0b228133951f7a2651467c8bf9392e712.tar.xz yuzu-22b44be0b228133951f7a2651467c8bf9392e712.zip | |
android: Convert SettingsItem to Kotlin
Diffstat (limited to 'src/android')
2 files changed, 30 insertions, 100 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.java deleted file mode 100644 index e2ba9014f..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.java +++ /dev/null | |||
| @@ -1,100 +0,0 @@ | |||
| 1 | package org.yuzu.yuzu_emu.features.settings.model.view; | ||
| 2 | |||
| 3 | import org.yuzu.yuzu_emu.features.settings.model.Setting; | ||
| 4 | import org.yuzu.yuzu_emu.features.settings.model.Settings; | ||
| 5 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * ViewModel abstraction for an Item in the RecyclerView powering SettingsFragments. | ||
| 9 | * Each one corresponds to a {@link Setting} object, so this class's subclasses | ||
| 10 | * should vaguely correspond to those subclasses. There are a few with multiple analogues | ||
| 11 | * and a few with none (Headers, for example, do not correspond to anything in the ini | ||
| 12 | * file.) | ||
| 13 | */ | ||
| 14 | public abstract class SettingsItem { | ||
| 15 | public static final int TYPE_HEADER = 0; | ||
| 16 | public static final int TYPE_CHECKBOX = 1; | ||
| 17 | public static final int TYPE_SINGLE_CHOICE = 2; | ||
| 18 | public static final int TYPE_SLIDER = 3; | ||
| 19 | public static final int TYPE_SUBMENU = 4; | ||
| 20 | public static final int TYPE_STRING_SINGLE_CHOICE = 5; | ||
| 21 | public static final int TYPE_DATETIME_SETTING = 6; | ||
| 22 | |||
| 23 | private String mKey; | ||
| 24 | private String mSection; | ||
| 25 | |||
| 26 | private Setting mSetting; | ||
| 27 | |||
| 28 | private int mNameId; | ||
| 29 | private int mDescriptionId; | ||
| 30 | private boolean mIsPremium; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * Base constructor. Takes a key / section name in case the third parameter, the Setting, | ||
| 34 | * is null; in which case, one can be constructed and saved using the key / section. | ||
| 35 | * | ||
| 36 | * @param key Identifier for the Setting represented by this Item. | ||
| 37 | * @param section Section to which the Setting belongs. | ||
| 38 | * @param setting A possibly-null backing Setting, to be modified on UI events. | ||
| 39 | * @param nameId Resource ID for a text string to be displayed as this setting's name. | ||
| 40 | * @param descriptionId Resource ID for a text string to be displayed as this setting's description. | ||
| 41 | */ | ||
| 42 | public SettingsItem(String key, String section, Setting setting, int nameId, | ||
| 43 | int descriptionId) { | ||
| 44 | mKey = key; | ||
| 45 | mSection = section; | ||
| 46 | mSetting = setting; | ||
| 47 | mNameId = nameId; | ||
| 48 | mDescriptionId = descriptionId; | ||
| 49 | } | ||
| 50 | |||
| 51 | /** | ||
| 52 | * @return The identifier for the backing Setting. | ||
| 53 | */ | ||
| 54 | public String getKey() { | ||
| 55 | return mKey; | ||
| 56 | } | ||
| 57 | |||
| 58 | /** | ||
| 59 | * @return The header under which the backing Setting belongs. | ||
| 60 | */ | ||
| 61 | public String getSection() { | ||
| 62 | return mSection; | ||
| 63 | } | ||
| 64 | |||
| 65 | /** | ||
| 66 | * @return The backing Setting, possibly null. | ||
| 67 | */ | ||
| 68 | public Setting getSetting() { | ||
| 69 | return mSetting; | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Replace the backing setting with a new one. Generally used in cases where | ||
| 74 | * the backing setting is null. | ||
| 75 | * | ||
| 76 | * @param setting A non-null Setting. | ||
| 77 | */ | ||
| 78 | public void setSetting(Setting setting) { | ||
| 79 | mSetting = setting; | ||
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 | * @return A resource ID for a text string representing this Setting's name. | ||
| 84 | */ | ||
| 85 | public int getNameId() { | ||
| 86 | return mNameId; | ||
| 87 | } | ||
| 88 | |||
| 89 | public int getDescriptionId() { | ||
| 90 | return mDescriptionId; | ||
| 91 | } | ||
| 92 | |||
| 93 | /** | ||
| 94 | * Used by {@link SettingsAdapter}'s onCreateViewHolder() | ||
| 95 | * method to determine which type of ViewHolder should be created. | ||
| 96 | * | ||
| 97 | * @return An integer (ideally, one of the constants defined in this file) | ||
| 98 | */ | ||
| 99 | public abstract int getType(); | ||
| 100 | } | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt new file mode 100644 index 000000000..a795374f9 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | package org.yuzu.yuzu_emu.features.settings.model.view | ||
| 2 | |||
| 3 | import org.yuzu.yuzu_emu.features.settings.model.Setting | ||
| 4 | |||
| 5 | /** | ||
| 6 | * ViewModel abstraction for an Item in the RecyclerView powering SettingsFragments. | ||
| 7 | * Each one corresponds to a [Setting] object, so this class's subclasses | ||
| 8 | * should vaguely correspond to those subclasses. There are a few with multiple analogues | ||
| 9 | * and a few with none (Headers, for example, do not correspond to anything in the ini | ||
| 10 | * file.) | ||
| 11 | */ | ||
| 12 | abstract class SettingsItem( | ||
| 13 | val key: String?, | ||
| 14 | val section: String?, | ||
| 15 | var setting: Setting?, | ||
| 16 | val nameId: Int, | ||
| 17 | val descriptionId: Int? | ||
| 18 | ) { | ||
| 19 | abstract val type: Int | ||
| 20 | |||
| 21 | companion object { | ||
| 22 | const val TYPE_HEADER = 0 | ||
| 23 | const val TYPE_CHECKBOX = 1 | ||
| 24 | const val TYPE_SINGLE_CHOICE = 2 | ||
| 25 | const val TYPE_SLIDER = 3 | ||
| 26 | const val TYPE_SUBMENU = 4 | ||
| 27 | const val TYPE_STRING_SINGLE_CHOICE = 5 | ||
| 28 | const val TYPE_DATETIME_SETTING = 6 | ||
| 29 | } | ||
| 30 | } | ||