mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 06:39:14 +01:00
Android: Convert AdHocBooleanSetting to Kotlin
This commit is contained in:
parent
f1028b4652
commit
a8f3d4291a
@ -1,62 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
package org.dolphinemu.dolphinemu.features.settings.model;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
public class AdHocBooleanSetting implements AbstractBooleanSetting
|
|
||||||
{
|
|
||||||
private final String mFile;
|
|
||||||
private final String mSection;
|
|
||||||
private final String mKey;
|
|
||||||
private final boolean mDefaultValue;
|
|
||||||
|
|
||||||
public AdHocBooleanSetting(String file, String section, String key, boolean defaultValue)
|
|
||||||
{
|
|
||||||
mFile = file;
|
|
||||||
mSection = section;
|
|
||||||
mKey = key;
|
|
||||||
mDefaultValue = defaultValue;
|
|
||||||
|
|
||||||
if (!NativeConfig.isSettingSaveable(file, section, key))
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("File/section/key is unknown or legacy");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOverridden()
|
|
||||||
{
|
|
||||||
return NativeConfig.isOverridden(mFile, mSection, mKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRuntimeEditable()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean delete(@NonNull Settings settings)
|
|
||||||
{
|
|
||||||
return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getBoolean()
|
|
||||||
{
|
|
||||||
return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBoolean(@NonNull Settings settings, boolean newValue)
|
|
||||||
{
|
|
||||||
NativeConfig.setBoolean(settings.getWriteLayer(), mFile, mSection, mKey, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getBooleanGlobal(String file, String section, String key,
|
|
||||||
boolean defaultValue)
|
|
||||||
{
|
|
||||||
return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, file, section, key, defaultValue);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,36 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.dolphinemu.dolphinemu.features.settings.model
|
||||||
|
|
||||||
|
class AdHocBooleanSetting(
|
||||||
|
private val file: String,
|
||||||
|
private val section: String,
|
||||||
|
private val key: String,
|
||||||
|
private val defaultValue: Boolean
|
||||||
|
) : AbstractBooleanSetting {
|
||||||
|
init {
|
||||||
|
require(
|
||||||
|
NativeConfig.isSettingSaveable(
|
||||||
|
file,
|
||||||
|
section,
|
||||||
|
key
|
||||||
|
)
|
||||||
|
) { "File/section/key is unknown or legacy" }
|
||||||
|
}
|
||||||
|
|
||||||
|
override val isOverridden: Boolean
|
||||||
|
get() = NativeConfig.isOverridden(file, section, key)
|
||||||
|
|
||||||
|
override val isRuntimeEditable: Boolean = true
|
||||||
|
|
||||||
|
override fun delete(settings: Settings): Boolean {
|
||||||
|
return NativeConfig.deleteKey(settings.writeLayer, file, section, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val boolean: Boolean
|
||||||
|
get() = NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, file, section, key, defaultValue)
|
||||||
|
|
||||||
|
override fun setBoolean(settings: Settings, newValue: Boolean) {
|
||||||
|
NativeConfig.setBoolean(settings.writeLayer, file, section, key, newValue)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user