Android: Convert ControlGroupEnabledSetting to Kotlin

This commit is contained in:
Charles Lombardo 2023-06-10 05:04:32 -04:00
parent 260bad74ea
commit 0454578f45
2 changed files with 25 additions and 52 deletions

View File

@ -1,52 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.input.model;
import androidx.annotation.NonNull;
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.ControlGroup;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public class ControlGroupEnabledSetting implements AbstractBooleanSetting
{
private final ControlGroup mControlGroup;
public ControlGroupEnabledSetting(ControlGroup controlGroup)
{
mControlGroup = controlGroup;
}
@Override
public boolean getBoolean()
{
return mControlGroup.getEnabled();
}
@Override
public void setBoolean(@NonNull Settings settings, boolean newValue)
{
mControlGroup.setEnabled(newValue);
}
@Override
public boolean isOverridden()
{
return false;
}
@Override
public boolean isRuntimeEditable()
{
return true;
}
@Override
public boolean delete(@NonNull Settings settings)
{
boolean newValue = mControlGroup.getDefaultEnabledValue() != ControlGroup.DEFAULT_ENABLED_NO;
mControlGroup.setEnabled(newValue);
return true;
}
}

View File

@ -0,0 +1,25 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.input.model
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.ControlGroup
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting
import org.dolphinemu.dolphinemu.features.settings.model.Settings
class ControlGroupEnabledSetting(private val controlGroup: ControlGroup) : AbstractBooleanSetting {
override val boolean: Boolean
get() = controlGroup.getEnabled()
override fun setBoolean(settings: Settings, newValue: Boolean) =
controlGroup.setEnabled(newValue)
override val isOverridden: Boolean = false
override val isRuntimeEditable: Boolean = true
override fun delete(settings: Settings): Boolean {
val newValue = controlGroup.getDefaultEnabledValue() != ControlGroup.DEFAULT_ENABLED_NO
controlGroup.setEnabled(newValue)
return true
}
}