Skip to content

Commit

Permalink
Merge pull request dolphin-emu#11662 from t895/kotlin-settings
Browse files Browse the repository at this point in the history
Android: Convert Settings to Kotlin
  • Loading branch information
JosJuice authored Mar 19, 2023
2 parents a4d3342 + 9020b6a commit 002a96a
Show file tree
Hide file tree
Showing 110 changed files with 6,893 additions and 6,613 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class CheatsActivity : AppCompatActivity(), PanelSlideListener {

fun loadGameSpecificSettings(): Settings {
val settings = Settings()
settings.loadSettings(gameId, revision, isWii)
settings.loadSettings(gameId!!, revision, isWii)
return settings
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class SettingDisabledWarningFragment(
super.onResume()
val activity = requireActivity() as CheatsActivity
activity.loadGameSpecificSettings().use {
val cheatsEnabled = setting.getBoolean()
val cheatsEnabled = setting.boolean
requireView().visibility = if (cheatsEnabled) View.GONE else View.VISIBLE
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void refreshChoicesAndValues()
{
String[] devices = ControllerInterface.getAllDeviceStrings();

mChoices = devices;
mValues = devices;
setChoices(devices);
setValues(devices);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package org.dolphinemu.dolphinemu.features.input.ui

import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -14,6 +13,7 @@ import com.google.android.material.divider.MaterialDividerItemDecoration
import org.dolphinemu.dolphinemu.R
import org.dolphinemu.dolphinemu.databinding.DialogInputProfilesBinding
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag
import org.dolphinemu.dolphinemu.utils.SerializableHelper.serializable

class ProfileDialog : BottomSheetDialogFragment() {
private var presenter: ProfileDialogPresenter? = null
Expand All @@ -22,11 +22,7 @@ class ProfileDialog : BottomSheetDialogFragment() {
private val binding get() = _binding!!

override fun onCreate(savedInstanceState: Bundle?) {
val menuTag: MenuTag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
requireArguments().getSerializable(KEY_MENU_TAG, MenuTag::class.java) as MenuTag
} else {
requireArguments().getSerializable(KEY_MENU_TAG) as MenuTag
}
val menuTag = requireArguments().serializable<MenuTag>(KEY_MENU_TAG)

presenter = ProfileDialogPresenter(this, menuTag)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.settings.model

interface AbstractBooleanSetting : AbstractSetting {
val boolean: Boolean

fun setBoolean(settings: Settings, newValue: Boolean)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.settings.model

interface AbstractFloatSetting : AbstractSetting {
val float: Float

fun setFloat(settings: Settings, newValue: Float)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.settings.model

interface AbstractIntSetting : AbstractSetting {
val int: Int

fun setInt(settings: Settings, newValue: Int)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.settings.model

interface AbstractSetting {
val isOverridden: Boolean
val isRuntimeEditable: Boolean

fun delete(settings: Settings): Boolean
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.settings.model

interface AbstractStringSetting : AbstractSetting {
val string: String

fun setString(settings: Settings, newValue: String)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.settings.model

class AdHocStringSetting(
private val file: String,
private val section: String,
private val key: String,
private val defaultValue: String
) : AbstractStringSetting {
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 string: String
get() = NativeConfig.getString(NativeConfig.LAYER_ACTIVE, file, section, key, defaultValue)

override fun setString(settings: Settings, newValue: String) {
NativeConfig.setString(settings.writeLayer, file, section, key, newValue)
}
}
Loading

0 comments on commit 002a96a

Please sign in to comment.