mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-26 20:04:17 +01:00
Rename Settings
Kotlin class to PreferenceSettings
SharedPreferences will be partially swapped out in the future to support per-game settings. In the meantime, make it clear from which class settings are coming from.
This commit is contained in:
parent
3b27540250
commit
5b4ca79dc8
@ -28,8 +28,8 @@ import emu.skyline.applet.swkbd.SoftwareKeyboardDialog
|
|||||||
import emu.skyline.databinding.EmuActivityBinding
|
import emu.skyline.databinding.EmuActivityBinding
|
||||||
import emu.skyline.input.*
|
import emu.skyline.input.*
|
||||||
import emu.skyline.loader.getRomFormat
|
import emu.skyline.loader.getRomFormat
|
||||||
|
import emu.skyline.utils.PreferenceSettings
|
||||||
import emu.skyline.utils.ByteBufferSerializable
|
import emu.skyline.utils.ByteBufferSerializable
|
||||||
import emu.skyline.utils.Settings
|
|
||||||
import emu.skyline.utils.SettingsValues
|
import emu.skyline.utils.SettingsValues
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.nio.ByteOrder
|
import java.nio.ByteOrder
|
||||||
@ -74,7 +74,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
var desiredRefreshRate = 60f
|
var desiredRefreshRate = 60f
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var settings : Settings
|
lateinit var preferenceSettings : PreferenceSettings
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var inputManager : InputManager
|
lateinit var inputManager : InputManager
|
||||||
@ -172,7 +172,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
if (controller.type != ControllerType.None) {
|
if (controller.type != ControllerType.None) {
|
||||||
val type = when (controller.type) {
|
val type = when (controller.type) {
|
||||||
ControllerType.None -> throw IllegalArgumentException()
|
ControllerType.None -> throw IllegalArgumentException()
|
||||||
ControllerType.HandheldProController -> if (settings.isDocked) ControllerType.ProController.id else ControllerType.HandheldProController.id
|
ControllerType.HandheldProController -> if (preferenceSettings.isDocked) ControllerType.ProController.id else ControllerType.HandheldProController.id
|
||||||
ControllerType.ProController, ControllerType.JoyConLeft, ControllerType.JoyConRight -> controller.type.id
|
ControllerType.ProController, ControllerType.JoyConLeft, ControllerType.JoyConRight -> controller.type.id
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
val romFd = contentResolver.openFileDescriptor(rom, "r")!!
|
val romFd = contentResolver.openFileDescriptor(rom, "r")!!
|
||||||
|
|
||||||
emulationThread = Thread {
|
emulationThread = Thread {
|
||||||
executeApplication(rom.toString(), romType, romFd.detachFd(), SettingsValues(settings), applicationContext.getPublicFilesDir().canonicalPath + "/", applicationContext.filesDir.canonicalPath + "/", applicationInfo.nativeLibraryDir + "/", assets)
|
executeApplication(rom.toString(), romType, romFd.detachFd(), SettingsValues(preferenceSettings), applicationContext.getPublicFilesDir().canonicalPath + "/", applicationContext.filesDir.canonicalPath + "/", applicationInfo.nativeLibraryDir + "/", assets)
|
||||||
returnFromEmulation()
|
returnFromEmulation()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
||||||
override fun onCreate(savedInstanceState : Bundle?) {
|
override fun onCreate(savedInstanceState : Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
requestedOrientation = settings.orientation
|
requestedOrientation = preferenceSettings.orientation
|
||||||
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.respectDisplayCutout) {
|
if (preferenceSettings.respectDisplayCutout) {
|
||||||
binding.perfStats.setOnApplyWindowInsetsListener(insetsOrMarginHandler)
|
binding.perfStats.setOnApplyWindowInsetsListener(insetsOrMarginHandler)
|
||||||
binding.onScreenControllerToggle.setOnApplyWindowInsetsListener(insetsOrMarginHandler)
|
binding.onScreenControllerToggle.setOnApplyWindowInsetsListener(insetsOrMarginHandler)
|
||||||
}
|
}
|
||||||
@ -286,14 +286,14 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
binding.gameView.holder.addCallback(this)
|
binding.gameView.holder.addCallback(this)
|
||||||
|
|
||||||
binding.gameView.setAspectRatio(
|
binding.gameView.setAspectRatio(
|
||||||
when (settings.aspectRatio) {
|
when (preferenceSettings.aspectRatio) {
|
||||||
0 -> Rational(16, 9)
|
0 -> Rational(16, 9)
|
||||||
1 -> Rational(21, 9)
|
1 -> Rational(21, 9)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (settings.perfStats) {
|
if (preferenceSettings.perfStats) {
|
||||||
binding.perfStats.apply {
|
binding.perfStats.apply {
|
||||||
postDelayed(object : Runnable {
|
postDelayed(object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
@ -305,7 +305,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
force60HzRefreshRate(!settings.maxRefreshRate)
|
force60HzRefreshRate(!preferenceSettings.maxRefreshRate)
|
||||||
getSystemService<DisplayManager>()?.registerDisplayListener(this, null)
|
getSystemService<DisplayManager>()?.registerDisplayListener(this, null)
|
||||||
|
|
||||||
binding.gameView.setOnTouchListener(this)
|
binding.gameView.setOnTouchListener(this)
|
||||||
@ -314,11 +314,11 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
binding.onScreenControllerView.apply {
|
binding.onScreenControllerView.apply {
|
||||||
inputManager.controllers[0]!!.type.let {
|
inputManager.controllers[0]!!.type.let {
|
||||||
controllerType = it
|
controllerType = it
|
||||||
isGone = it == ControllerType.None || !settings.onScreenControl
|
isGone = it == ControllerType.None || !preferenceSettings.onScreenControl
|
||||||
}
|
}
|
||||||
setOnButtonStateChangedListener(::onButtonStateChanged)
|
setOnButtonStateChangedListener(::onButtonStateChanged)
|
||||||
setOnStickStateChangedListener(::onStickStateChanged)
|
setOnStickStateChangedListener(::onStickStateChanged)
|
||||||
recenterSticks = settings.onScreenControlRecenterSticks
|
recenterSticks = preferenceSettings.onScreenControlRecenterSticks
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.onScreenControllerToggle.apply {
|
binding.onScreenControllerToggle.apply {
|
||||||
@ -380,7 +380,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||||
// Note: We need FRAME_RATE_COMPATIBILITY_FIXED_SOURCE as there will be a degradation of user experience with FRAME_RATE_COMPATIBILITY_DEFAULT due to game speed alterations when the frame rate doesn't match the display refresh rate
|
// Note: We need FRAME_RATE_COMPATIBILITY_FIXED_SOURCE as there will be a degradation of user experience with FRAME_RATE_COMPATIBILITY_DEFAULT due to game speed alterations when the frame rate doesn't match the display refresh rate
|
||||||
holder.surface.setFrameRate(desiredRefreshRate, if (settings.maxRefreshRate) Surface.FRAME_RATE_COMPATIBILITY_DEFAULT else Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE)
|
holder.surface.setFrameRate(desiredRefreshRate, if (preferenceSettings.maxRefreshRate) Surface.FRAME_RATE_COMPATIBILITY_DEFAULT else Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE)
|
||||||
|
|
||||||
while (emulationThread!!.isAlive)
|
while (emulationThread!!.isAlive)
|
||||||
if (setSurface(holder.surface))
|
if (setSurface(holder.surface))
|
||||||
@ -394,7 +394,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
Log.d(Tag, "surfaceChanged Holder: $holder, Format: $format, Width: $width, Height: $height")
|
Log.d(Tag, "surfaceChanged Holder: $holder, Format: $format, Width: $width, Height: $height")
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||||
holder.surface.setFrameRate(desiredRefreshRate, if (settings.maxRefreshRate) Surface.FRAME_RATE_COMPATIBILITY_DEFAULT else Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE)
|
holder.surface.setFrameRate(desiredRefreshRate, if (preferenceSettings.maxRefreshRate) Surface.FRAME_RATE_COMPATIBILITY_DEFAULT else Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun surfaceDestroyed(holder : SurfaceHolder) {
|
override fun surfaceDestroyed(holder : SurfaceHolder) {
|
||||||
@ -651,7 +651,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
override fun onDisplayChanged(displayId : Int) {
|
override fun onDisplayChanged(displayId : Int) {
|
||||||
val display = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) display!! else windowManager.defaultDisplay
|
val display = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) display!! else windowManager.defaultDisplay
|
||||||
if (display.displayId == displayId)
|
if (display.displayId == displayId)
|
||||||
force60HzRefreshRate(!settings.maxRefreshRate)
|
force60HzRefreshRate(!preferenceSettings.maxRefreshRate)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisplayAdded(displayId : Int) {}
|
override fun onDisplayAdded(displayId : Int) {}
|
||||||
|
@ -35,8 +35,8 @@ import emu.skyline.databinding.MainActivityBinding
|
|||||||
import emu.skyline.loader.AppEntry
|
import emu.skyline.loader.AppEntry
|
||||||
import emu.skyline.loader.LoaderResult
|
import emu.skyline.loader.LoaderResult
|
||||||
import emu.skyline.loader.RomFormat
|
import emu.skyline.loader.RomFormat
|
||||||
|
import emu.skyline.utils.PreferenceSettings
|
||||||
import emu.skyline.provider.DocumentsProvider
|
import emu.skyline.provider.DocumentsProvider
|
||||||
import emu.skyline.utils.Settings
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
@ -50,11 +50,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private val binding by lazy { MainActivityBinding.inflate(layoutInflater) }
|
private val binding by lazy { MainActivityBinding.inflate(layoutInflater) }
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var settings : Settings
|
lateinit var preferenceSettings : PreferenceSettings
|
||||||
|
|
||||||
private val adapter = GenericAdapter()
|
private val adapter = GenericAdapter()
|
||||||
|
|
||||||
private val layoutType get() = LayoutType.values()[settings.layoutType]
|
private val layoutType get() = LayoutType.values()[preferenceSettings.layoutType]
|
||||||
|
|
||||||
private val missingIcon by lazy { ContextCompat.getDrawable(this, R.drawable.default_icon)!!.toBitmap(256, 256) }
|
private val missingIcon by lazy { ContextCompat.getDrawable(this, R.drawable.default_icon)!!.toBitmap(256, 256) }
|
||||||
|
|
||||||
@ -77,14 +77,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private val documentPicker = registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) {
|
private val documentPicker = registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) {
|
||||||
it?.let { uri ->
|
it?.let { uri ->
|
||||||
contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
settings.searchLocation = uri.toString()
|
preferenceSettings.searchLocation = uri.toString()
|
||||||
|
|
||||||
loadRoms(false)
|
loadRoms(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val settingsCallback = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
private val settingsCallback = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
if (settings.refreshRequired) loadRoms(false)
|
if (preferenceSettings.refreshRequired) loadRoms(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun AppItem.toViewItem() = AppViewItem(layoutType, this, missingIcon, ::selectStartGame, ::selectShowGameDialog)
|
private fun AppItem.toViewItem() = AppViewItem(layoutType, this, missingIcon, ::selectStartGame, ::selectShowGameDialog)
|
||||||
@ -92,7 +92,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onCreate(savedInstanceState : Bundle?) {
|
override fun onCreate(savedInstanceState : Bundle?) {
|
||||||
// Need to create new instance of settings, dependency injection happens
|
// Need to create new instance of settings, dependency injection happens
|
||||||
AppCompatDelegate.setDefaultNightMode(
|
AppCompatDelegate.setDefaultNightMode(
|
||||||
when ((Settings(this).appTheme)) {
|
when ((PreferenceSettings(this).appTheme)) {
|
||||||
0 -> AppCompatDelegate.MODE_NIGHT_NO
|
0 -> AppCompatDelegate.MODE_NIGHT_NO
|
||||||
1 -> AppCompatDelegate.MODE_NIGHT_YES
|
1 -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
2 -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
2 -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
@ -106,8 +106,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false)
|
PreferenceManager.setDefaultValues(this, R.xml.preferences, false)
|
||||||
|
|
||||||
adapter.apply {
|
adapter.apply {
|
||||||
setHeaderItems(listOf(HeaderRomFilterItem(formatOrder, if (settings.romFormatFilter == 0) null else formatOrder[settings.romFormatFilter - 1]) { romFormat ->
|
setHeaderItems(listOf(HeaderRomFilterItem(formatOrder, if (preferenceSettings.romFormatFilter == 0) null else formatOrder[preferenceSettings.romFormatFilter - 1]) { romFormat ->
|
||||||
settings.romFormatFilter = romFormat?.let { formatOrder.indexOf(romFormat) + 1 } ?: 0
|
preferenceSettings.romFormatFilter = romFormat?.let { formatOrder.indexOf(romFormat) + 1 } ?: 0
|
||||||
formatFilter = romFormat
|
formatFilter = romFormat
|
||||||
populateAdapter()
|
populateAdapter()
|
||||||
}))
|
}))
|
||||||
@ -127,7 +127,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewModel.stateData.observe(this, ::handleState)
|
viewModel.stateData.observe(this, ::handleState)
|
||||||
loadRoms(!settings.refreshRequired)
|
loadRoms(!preferenceSettings.refreshRequired)
|
||||||
|
|
||||||
binding.searchBar.apply {
|
binding.searchBar.apply {
|
||||||
binding.logIcon.setOnClickListener {
|
binding.logIcon.setOnClickListener {
|
||||||
@ -236,7 +236,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
binding.appList.layoutManager = CustomLayoutManager(gridSpan)
|
binding.appList.layoutManager = CustomLayoutManager(gridSpan)
|
||||||
setAppListDecoration()
|
setAppListDecoration()
|
||||||
|
|
||||||
if (settings.searchLocation.isEmpty()) documentPicker.launch(null)
|
if (preferenceSettings.searchLocation.isEmpty()) documentPicker.launch(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDataItems() = mutableListOf<DataItem>().apply {
|
private fun getDataItems() = mutableListOf<DataItem>().apply {
|
||||||
@ -270,7 +270,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private fun selectStartGame(appItem : AppItem) {
|
private fun selectStartGame(appItem : AppItem) {
|
||||||
if (binding.swipeRefreshLayout.isRefreshing) return
|
if (binding.swipeRefreshLayout.isRefreshing) return
|
||||||
|
|
||||||
if (settings.selectAction) {
|
if (preferenceSettings.selectAction) {
|
||||||
AppDialog.newInstance(appItem).show(supportFragmentManager, "game")
|
AppDialog.newInstance(appItem).show(supportFragmentManager, "game")
|
||||||
} else if (appItem.loaderResult == LoaderResult.Success) {
|
} else if (appItem.loaderResult == LoaderResult.Success) {
|
||||||
startActivity(Intent(this, EmulationActivity::class.java).apply { data = appItem.uri; putExtra(EmulationActivity.ReturnToMainTag, true) })
|
startActivity(Intent(this, EmulationActivity::class.java).apply { data = appItem.uri; putExtra(EmulationActivity.ReturnToMainTag, true) })
|
||||||
@ -284,8 +284,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadRoms(loadFromFile : Boolean) {
|
private fun loadRoms(loadFromFile : Boolean) {
|
||||||
viewModel.loadRoms(this, loadFromFile, Uri.parse(settings.searchLocation), settings.systemLanguage)
|
viewModel.loadRoms(this, loadFromFile, Uri.parse(preferenceSettings.searchLocation), preferenceSettings.systemLanguage)
|
||||||
settings.refreshRequired = false
|
preferenceSettings.refreshRequired = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun populateAdapter() {
|
private fun populateAdapter() {
|
||||||
|
@ -11,7 +11,7 @@ import dagger.hilt.InstallIn
|
|||||||
import dagger.hilt.android.EntryPointAccessors
|
import dagger.hilt.android.EntryPointAccessors
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import emu.skyline.input.InputManager
|
import emu.skyline.input.InputManager
|
||||||
import emu.skyline.utils.Settings
|
import emu.skyline.utils.PreferenceSettings
|
||||||
|
|
||||||
@EntryPoint
|
@EntryPoint
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
@ -24,7 +24,7 @@ fun Context.getInputManager() = EntryPointAccessors.fromApplication(this, InputM
|
|||||||
@EntryPoint
|
@EntryPoint
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
interface SettingsProviderEntryPoint {
|
interface SettingsProviderEntryPoint {
|
||||||
fun settings() : Settings
|
fun preferenceSettings() : PreferenceSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getSettings() = EntryPointAccessors.fromApplication(this, SettingsProviderEntryPoint::class.java).settings()
|
fun Context.getSettings() = EntryPointAccessors.fromApplication(this, SettingsProviderEntryPoint::class.java).preferenceSettings()
|
||||||
|
@ -29,7 +29,7 @@ import emu.skyline.input.dialog.ButtonDialog
|
|||||||
import emu.skyline.input.dialog.RumbleDialog
|
import emu.skyline.input.dialog.RumbleDialog
|
||||||
import emu.skyline.input.dialog.StickDialog
|
import emu.skyline.input.dialog.StickDialog
|
||||||
import emu.skyline.input.onscreen.OnScreenEditActivity
|
import emu.skyline.input.onscreen.OnScreenEditActivity
|
||||||
import emu.skyline.utils.Settings
|
import emu.skyline.utils.PreferenceSettings
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,7 @@ class ControllerActivity : AppCompatActivity() {
|
|||||||
val buttonItems = mutableListOf<ControllerButtonViewItem>()
|
val buttonItems = mutableListOf<ControllerButtonViewItem>()
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var settings : Settings
|
lateinit var preferenceSettings : PreferenceSettings
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var inputManager : InputManager
|
lateinit var inputManager : InputManager
|
||||||
@ -84,14 +84,14 @@ class ControllerActivity : AppCompatActivity() {
|
|||||||
items.add(ControllerHeaderItem(getString(R.string.osc)))
|
items.add(ControllerHeaderItem(getString(R.string.osc)))
|
||||||
|
|
||||||
val oscSummary = { checked : Boolean -> getString(if (checked) R.string.osc_shown else R.string.osc_not_shown) }
|
val oscSummary = { checked : Boolean -> getString(if (checked) R.string.osc_shown else R.string.osc_not_shown) }
|
||||||
items.add(ControllerCheckBoxViewItem(getString(R.string.osc_enable), oscSummary.invoke(settings.onScreenControl), settings.onScreenControl) { item, position ->
|
items.add(ControllerCheckBoxViewItem(getString(R.string.osc_enable), oscSummary.invoke(preferenceSettings.onScreenControl), preferenceSettings.onScreenControl) { item, position ->
|
||||||
item.summary = oscSummary.invoke(item.checked)
|
item.summary = oscSummary.invoke(item.checked)
|
||||||
settings.onScreenControl = item.checked
|
preferenceSettings.onScreenControl = item.checked
|
||||||
adapter.notifyItemChanged(position)
|
adapter.notifyItemChanged(position)
|
||||||
})
|
})
|
||||||
|
|
||||||
items.add(ControllerCheckBoxViewItem(getString(R.string.osc_recenter_sticks), "", settings.onScreenControlRecenterSticks) { item, position ->
|
items.add(ControllerCheckBoxViewItem(getString(R.string.osc_recenter_sticks), "", preferenceSettings.onScreenControlRecenterSticks) { item, position ->
|
||||||
settings.onScreenControlRecenterSticks = item.checked
|
preferenceSettings.onScreenControlRecenterSticks = item.checked
|
||||||
adapter.notifyItemChanged(position)
|
adapter.notifyItemChanged(position)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import emu.skyline.R
|
import emu.skyline.R
|
||||||
import emu.skyline.databinding.OnScreenEditActivityBinding
|
import emu.skyline.databinding.OnScreenEditActivityBinding
|
||||||
import emu.skyline.utils.Settings
|
import emu.skyline.utils.PreferenceSettings
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -26,7 +26,7 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
private var editMode = false
|
private var editMode = false
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var settings : Settings
|
lateinit var preferenceSettings : PreferenceSettings
|
||||||
|
|
||||||
private val closeAction : () -> Unit = {
|
private val closeAction : () -> Unit = {
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
@ -101,7 +101,7 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.onScreenControllerView.recenterSticks = settings.onScreenControlRecenterSticks
|
binding.onScreenControllerView.recenterSticks = preferenceSettings.onScreenControlRecenterSticks
|
||||||
|
|
||||||
actions.forEach { pair ->
|
actions.forEach { pair ->
|
||||||
binding.fabParent.addView(LayoutInflater.from(this).inflate(R.layout.on_screen_edit_mini_fab, binding.fabParent, false).apply {
|
binding.fabParent.addView(LayoutInflater.from(this).inflate(R.layout.on_screen_edit_mini_fab, binding.fabParent, false).apply {
|
||||||
|
@ -13,7 +13,7 @@ import javax.inject.Singleton
|
|||||||
import emu.skyline.R
|
import emu.skyline.R
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class Settings @Inject constructor(@ApplicationContext private val context : Context) {
|
class PreferenceSettings @Inject constructor(@ApplicationContext private val context : Context) {
|
||||||
// Emulator
|
// Emulator
|
||||||
var searchLocation by sharedPreferences(context, "")
|
var searchLocation by sharedPreferences(context, "")
|
||||||
var appTheme by sharedPreferences(context, 2)
|
var appTheme by sharedPreferences(context, 2)
|
@ -7,7 +7,7 @@ package emu.skyline.utils
|
|||||||
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
class SettingsValues(pref: Settings) : Serializable {
|
class SettingsValues(pref: PreferenceSettings) : Serializable {
|
||||||
var isDocked : Boolean = pref.isDocked
|
var isDocked : Boolean = pref.isDocked
|
||||||
var usernameValue : String = pref.usernameValue
|
var usernameValue : String = pref.usernameValue
|
||||||
var systemLanguage : Int = pref.systemLanguage
|
var systemLanguage : Int = pref.systemLanguage
|
||||||
|
Loading…
Reference in New Issue
Block a user