Move Kotlin settings to a dedicate package

This commit is contained in:
lynxnb 2023-02-14 14:17:17 +01:00 committed by Niccolò Betto
parent 180d1efd4d
commit a1ca84f95e
17 changed files with 27 additions and 23 deletions

View File

@ -50,7 +50,7 @@
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" /> <option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
</Profilers> </Profilers>
<option name="DEEP_LINK" value="" /> <option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="emu.skyline.SettingsActivity" /> <option name="ACTIVITY_CLASS" value="emu.skyline.settings.SettingsActivity" />
<option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" /> <option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
<option name="SKIP_ACTIVITY_VALIDATION" value="false" /> <option name="SKIP_ACTIVITY_VALIDATION" value="false" />
<method v="2"> <method v="2">

View File

@ -37,7 +37,7 @@
</activity> </activity>
<activity <activity
android:name=".SettingsActivity" android:name=".settings.SettingsActivity"
android:exported="true" android:exported="true"
android:label="@string/settings" android:label="@string/settings"
android:launchMode="singleTop" android:launchMode="singleTop"
@ -47,13 +47,13 @@
<activity <activity
android:name=".input.ControllerActivity" android:name=".input.ControllerActivity"
android:exported="true" android:exported="true"
android:parentActivityName=".SettingsActivity"> android:parentActivityName=".settings.SettingsActivity">
</activity> </activity>
<activity <activity
android:name=".preference.GpuDriverActivity" android:name=".preference.GpuDriverActivity"
android:exported="true" android:exported="true"
android:parentActivityName=".SettingsActivity"> android:parentActivityName=".settings.SettingsActivity">
</activity> </activity>
<activity <activity

View File

@ -243,13 +243,13 @@ extern "C" JNIEXPORT void JNICALL Java_emu_skyline_input_InputHandler_00024Compa
env->ReleaseIntArrayElements(pointsJni, reinterpret_cast<jint *>(points.data()), JNI_ABORT); env->ReleaseIntArrayElements(pointsJni, reinterpret_cast<jint *>(points.data()), JNI_ABORT);
} }
extern "C" JNIEXPORT void JNICALL Java_emu_skyline_utils_NativeSettings_updateNative(JNIEnv *env, jobject) { extern "C" JNIEXPORT void JNICALL Java_emu_skyline_settings_NativeSettings_updateNative(JNIEnv *env, jobject) {
auto settings{SettingsWeak.lock()}; auto settings{SettingsWeak.lock()};
if (!settings) if (!settings)
return; // We don't mind if we miss settings updates while settings haven't been initialized return; // We don't mind if we miss settings updates while settings haven't been initialized
settings->Update(); settings->Update();
} }
extern "C" JNIEXPORT void JNICALL Java_emu_skyline_utils_NativeSettings_00024Companion_setLogLevel(JNIEnv *, jobject, jint logLevel) { extern "C" JNIEXPORT void JNICALL Java_emu_skyline_settings_NativeSettings_00024Companion_setLogLevel(JNIEnv *, jobject, jint logLevel) {
skyline::Logger::configLevel = static_cast<skyline::Logger::LogLevel>(logLevel); skyline::Logger::configLevel = static_cast<skyline::Logger::LogLevel>(logLevel);
} }

View File

@ -31,8 +31,8 @@ import emu.skyline.input.*
import emu.skyline.loader.getRomFormat import emu.skyline.loader.getRomFormat
import emu.skyline.utils.ByteBufferSerializable import emu.skyline.utils.ByteBufferSerializable
import emu.skyline.utils.GpuDriverHelper import emu.skyline.utils.GpuDriverHelper
import emu.skyline.utils.NativeSettings import emu.skyline.settings.NativeSettings
import emu.skyline.utils.PreferenceSettings import emu.skyline.settings.PreferenceSettings
import java.nio.ByteBuffer import java.nio.ByteBuffer
import java.nio.ByteOrder import java.nio.ByteOrder
import java.util.concurrent.FutureTask import java.util.concurrent.FutureTask

View File

@ -38,7 +38,8 @@ import emu.skyline.loader.LoaderResult
import emu.skyline.loader.RomFormat import emu.skyline.loader.RomFormat
import emu.skyline.provider.DocumentsProvider import emu.skyline.provider.DocumentsProvider
import emu.skyline.utils.GpuDriverHelper import emu.skyline.utils.GpuDriverHelper
import emu.skyline.utils.PreferenceSettings import emu.skyline.settings.PreferenceSettings
import emu.skyline.settings.SettingsActivity
import emu.skyline.utils.WindowInsetsHelper import emu.skyline.utils.WindowInsetsHelper
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.ceil import kotlin.math.ceil

View File

@ -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.PreferenceSettings import emu.skyline.settings.PreferenceSettings
@EntryPoint @EntryPoint
@InstallIn(SingletonComponent::class) @InstallIn(SingletonComponent::class)

View File

@ -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.PreferenceSettings import emu.skyline.settings.PreferenceSettings
import emu.skyline.utils.WindowInsetsHelper import emu.skyline.utils.WindowInsetsHelper
import javax.inject.Inject import javax.inject.Inject

View File

@ -17,7 +17,7 @@ import android.view.OrientationEventListener
import android.view.View import android.view.View
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import emu.skyline.utils.ByteBufferSerializable import emu.skyline.utils.ByteBufferSerializable
import emu.skyline.utils.PreferenceSettings import emu.skyline.settings.PreferenceSettings
import emu.skyline.utils.u64 import emu.skyline.utils.u64
import java.nio.ByteBuffer import java.nio.ByteBuffer
import java.nio.ByteOrder import java.nio.ByteOrder

View File

@ -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.PreferenceSettings import emu.skyline.settings.PreferenceSettings
import javax.inject.Inject import javax.inject.Inject
@AndroidEntryPoint @AndroidEntryPoint

View File

@ -14,7 +14,7 @@ import androidx.preference.Preference
import androidx.preference.R import androidx.preference.R
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import emu.skyline.R as SkylineR import emu.skyline.R as SkylineR
import emu.skyline.SettingsActivity import emu.skyline.settings.SettingsActivity
import emu.skyline.provider.DocumentsProvider import emu.skyline.provider.DocumentsProvider
class DocumentsProviderPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.preferenceStyle) : Preference(context, attrs, defStyleAttr) { class DocumentsProviderPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.preferenceStyle) : Preference(context, attrs, defStyleAttr) {

View File

@ -25,7 +25,7 @@ import emu.skyline.adapter.SpacingItemDecoration
import emu.skyline.databinding.GpuDriverActivityBinding import emu.skyline.databinding.GpuDriverActivityBinding
import emu.skyline.utils.GpuDriverHelper import emu.skyline.utils.GpuDriverHelper
import emu.skyline.utils.GpuDriverInstallResult import emu.skyline.utils.GpuDriverInstallResult
import emu.skyline.utils.PreferenceSettings import emu.skyline.settings.PreferenceSettings
import emu.skyline.utils.WindowInsetsHelper import emu.skyline.utils.WindowInsetsHelper
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers

View File

@ -14,7 +14,7 @@ import androidx.preference.Preference
import androidx.preference.Preference.SummaryProvider import androidx.preference.Preference.SummaryProvider
import androidx.preference.R import androidx.preference.R
import emu.skyline.utils.GpuDriverHelper import emu.skyline.utils.GpuDriverHelper
import emu.skyline.utils.PreferenceSettings import emu.skyline.settings.PreferenceSettings
import emu.skyline.R as SkylineR import emu.skyline.R as SkylineR
/** /**

View File

@ -14,7 +14,7 @@ import androidx.preference.Preference
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import emu.skyline.KeyReader import emu.skyline.KeyReader
import emu.skyline.R import emu.skyline.R
import emu.skyline.SettingsActivity import emu.skyline.settings.SettingsActivity
import emu.skyline.di.getSettings import emu.skyline.di.getSettings
class KeyPickerPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = androidx.preference.R.attr.preferenceStyle) : Preference(context, attrs, defStyleAttr) { class KeyPickerPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = androidx.preference.R.attr.preferenceStyle) : Preference(context, attrs, defStyleAttr) {

View File

@ -8,7 +8,7 @@ package emu.skyline.preference
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import androidx.preference.R import androidx.preference.R
import emu.skyline.utils.NativeSettings import emu.skyline.settings.NativeSettings
class LogLevelPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.dialogPreferenceStyle) : IntegerListPreference(context, attrs, defStyleAttr) { class LogLevelPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.dialogPreferenceStyle) : IntegerListPreference(context, attrs, defStyleAttr) {
init { init {

View File

@ -3,10 +3,11 @@
* Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
*/ */
package emu.skyline.utils package emu.skyline.settings
import android.content.Context import android.content.Context
import emu.skyline.BuildConfig import emu.skyline.BuildConfig
import emu.skyline.utils.GpuDriverHelper
/** /**
* The settings that will be passed to libskyline when running and executable * The settings that will be passed to libskyline when running and executable

View File

@ -3,14 +3,15 @@
* Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) * Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
*/ */
package emu.skyline.utils package emu.skyline.settings
import android.content.Context import android.content.Context
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import emu.skyline.R
import emu.skyline.utils.sharedPreferences
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import emu.skyline.R
@Singleton @Singleton
class PreferenceSettings @Inject constructor(@ApplicationContext private val context : Context) { class PreferenceSettings @Inject constructor(@ApplicationContext private val context : Context) {

View File

@ -3,7 +3,7 @@
* Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) * Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
*/ */
package emu.skyline package emu.skyline.settings
import android.os.Bundle import android.os.Bundle
import android.view.* import android.view.*
@ -14,11 +14,12 @@ import androidx.preference.CheckBoxPreference
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceCategory import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import emu.skyline.BuildConfig
import emu.skyline.R
import emu.skyline.databinding.SettingsActivityBinding import emu.skyline.databinding.SettingsActivityBinding
import emu.skyline.preference.IntegerListPreference import emu.skyline.preference.IntegerListPreference
import emu.skyline.utils.GpuDriverHelper import emu.skyline.utils.GpuDriverHelper
import emu.skyline.utils.WindowInsetsHelper import emu.skyline.utils.WindowInsetsHelper
import emu.skyline.utils.sharedPreferences
class SettingsActivity : AppCompatActivity() { class SettingsActivity : AppCompatActivity() {
val binding by lazy { SettingsActivityBinding.inflate(layoutInflater) } val binding by lazy { SettingsActivityBinding.inflate(layoutInflater) }