From 2af8efdd72e4a4a6969ed29337f794ff6505018b Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Wed, 15 Mar 2023 03:29:44 -0400 Subject: [PATCH] Android: Convert SwitchSetting to Kotlin --- .../settings/model/view/SwitchSetting.java | 50 ------------------- .../settings/model/view/SwitchSetting.kt | 41 +++++++++++++++ 2 files changed, 41 insertions(+), 50 deletions(-) delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.java create mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.kt diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.java deleted file mode 100644 index dc7fa44714..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.java +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.settings.model.view; - -import android.content.Context; - -import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; -import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; -import org.dolphinemu.dolphinemu.features.settings.model.Settings; - -public class SwitchSetting extends SettingsItem -{ - protected AbstractBooleanSetting mSetting; - - public SwitchSetting(Context context, AbstractBooleanSetting setting, int titleId, - int descriptionId) - { - super(context, titleId, descriptionId); - mSetting = setting; - } - - public SwitchSetting(AbstractBooleanSetting setting, CharSequence title, - CharSequence description) - { - super(title, description); - mSetting = setting; - } - - public boolean isChecked() - { - return mSetting.getBoolean(); - } - - public void setChecked(Settings settings, boolean checked) - { - mSetting.setBoolean(settings, checked); - } - - @Override - public int getType() - { - return TYPE_SWITCH; - } - - @Override - public AbstractSetting getSetting() - { - return mSetting; - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.kt new file mode 100644 index 0000000000..5f9d0cb218 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.kt @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.settings.model.view + +import android.content.Context +import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting +import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting +import org.dolphinemu.dolphinemu.features.settings.model.Settings + +open class SwitchSetting : SettingsItem { + override val type: Int = TYPE_SWITCH + + protected var booleanSetting: AbstractBooleanSetting + + override val setting: AbstractSetting + get() = booleanSetting + + constructor( + context: Context, + setting: AbstractBooleanSetting, + titleId: Int, + descriptionId: Int + ) : super(context, titleId, descriptionId) { + booleanSetting = setting + } + + constructor( + setting: AbstractBooleanSetting, + title: CharSequence?, + description: CharSequence? + ) : super(title!!, description) { + booleanSetting = setting + } + + open val isChecked: Boolean + get() = booleanSetting.boolean + + open fun setChecked(settings: Settings?, checked: Boolean) { + booleanSetting.setBoolean(settings!!, checked) + } +}