mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-11 06:29:10 +01:00
Address CR + Code formatting
This commit is contained in:
parent
ca97517d81
commit
4d20d7a4d0
@ -54,7 +54,8 @@ static std::string GetTimeZoneName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication(
|
extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication(
|
||||||
JNIEnv *env, jobject instance,
|
JNIEnv *env,
|
||||||
|
jobject instance,
|
||||||
jstring romUriJstring,
|
jstring romUriJstring,
|
||||||
jint romType,
|
jint romType,
|
||||||
jint romFd,
|
jint romFd,
|
||||||
@ -84,8 +85,7 @@ extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication(
|
|||||||
perfetto::TrackEvent::Register();
|
perfetto::TrackEvent::Register();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto os{
|
auto os{std::make_shared<skyline::kernel::OS>(
|
||||||
std::make_shared<skyline::kernel::OS>(
|
|
||||||
jvmManager,
|
jvmManager,
|
||||||
logger,
|
logger,
|
||||||
settings,
|
settings,
|
||||||
|
@ -54,7 +54,7 @@ extern "C" JNIEXPORT jint JNICALL Java_emu_skyline_loader_RomFile_populate(JNIEn
|
|||||||
|
|
||||||
if (loader->nacp) {
|
if (loader->nacp) {
|
||||||
auto language{skyline::languages::GetApplicationLanguage(static_cast<skyline::languages::SystemLanguage>(systemLanguage))};
|
auto language{skyline::languages::GetApplicationLanguage(static_cast<skyline::languages::SystemLanguage>(systemLanguage))};
|
||||||
if ((1 << static_cast<skyline::u32>(language) & loader->nacp->supportedTitleLanguages) == 0)
|
if (((1 << static_cast<skyline::u32>(language)) & loader->nacp->supportedTitleLanguages) == 0)
|
||||||
language = loader->nacp->GetFirstSupportedTitleLanguage();
|
language = loader->nacp->GetFirstSupportedTitleLanguage();
|
||||||
|
|
||||||
env->SetObjectField(thiz, applicationNameField, env->NewStringUTF(loader->nacp->GetApplicationName(language).c_str()));
|
env->SetObjectField(thiz, applicationNameField, env->NewStringUTF(loader->nacp->GetApplicationName(language).c_str()));
|
||||||
|
@ -21,13 +21,12 @@ namespace skyline::kernel {
|
|||||||
std::string deviceTimeZone,
|
std::string deviceTimeZone,
|
||||||
languages::SystemLanguage systemLanguage,
|
languages::SystemLanguage systemLanguage,
|
||||||
std::shared_ptr<vfs::FileSystem> assetFileSystem
|
std::shared_ptr<vfs::FileSystem> assetFileSystem
|
||||||
)
|
) : state(this, jvmManager, settings, logger),
|
||||||
: state(this, jvmManager, settings, logger),
|
appFilesPath(std::move(appFilesPath)),
|
||||||
appFilesPath(std::move(appFilesPath)),
|
deviceTimeZone(std::move(deviceTimeZone)),
|
||||||
deviceTimeZone(std::move(deviceTimeZone)),
|
assetFileSystem(std::move(assetFileSystem)),
|
||||||
assetFileSystem(std::move(assetFileSystem)),
|
serviceManager(state),
|
||||||
serviceManager(state),
|
systemLanguage(systemLanguage) {}
|
||||||
systemLanguage(systemLanguage) {}
|
|
||||||
|
|
||||||
void OS::Execute(int romFd, loader::RomFormat romType) {
|
void OS::Execute(int romFd, loader::RomFormat romType) {
|
||||||
auto romFile{std::make_shared<vfs::OsBacking>(romFd)};
|
auto romFile{std::make_shared<vfs::OsBacking>(romFd)};
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
#include "IApplicationFunctions.h"
|
#include "IApplicationFunctions.h"
|
||||||
|
|
||||||
namespace skyline::service::am {
|
namespace skyline::service::am {
|
||||||
IApplicationFunctions::IApplicationFunctions(const DeviceState &state, ServiceManager &manager)
|
IApplicationFunctions::IApplicationFunctions(const DeviceState &state, ServiceManager &manager) : gpuErrorEvent(std::make_shared<type::KEvent>(state, false)), BaseService(state, manager) {}
|
||||||
: gpuErrorEvent(std::make_shared<type::KEvent>(state, false)), BaseService(state, manager) {}
|
|
||||||
|
|
||||||
Result IApplicationFunctions::PopLaunchParameter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationFunctions::PopLaunchParameter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
constexpr u32 LaunchParameterMagic{0xC79497CA}; //!< The magic of the application launch parameters
|
constexpr u32 LaunchParameterMagic{0xC79497CA}; //!< The magic of the application launch parameters
|
||||||
@ -36,7 +35,8 @@ namespace skyline::service::am {
|
|||||||
Result IApplicationFunctions::GetDesiredLanguage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationFunctions::GetDesiredLanguage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto desiredLanguage{languages::GetApplicationLanguage(state.os->systemLanguage)};
|
auto desiredLanguage{languages::GetApplicationLanguage(state.os->systemLanguage)};
|
||||||
|
|
||||||
if ((1 << static_cast<u32>(desiredLanguage) & state.loader->nacp->nacpContents.supportedLanguageFlag) == 0)
|
// In the future we might want to trigger an UI dialog if the user selected languages is not available, for now it will use the first available
|
||||||
|
if (((1 << static_cast<u32>(desiredLanguage)) & state.loader->nacp->nacpContents.supportedLanguageFlag) == 0)
|
||||||
desiredLanguage = state.loader->nacp->GetFirstSupportedLanguage();
|
desiredLanguage = state.loader->nacp->GetFirstSupportedLanguage();
|
||||||
|
|
||||||
response.Push(languages::GetLanguageCode(languages::GetSystemLanguage(desiredLanguage)));
|
response.Push(languages::GetLanguageCode(languages::GetSystemLanguage(desiredLanguage)));
|
||||||
|
@ -60,10 +60,9 @@ class SettingsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onDisplayPreferenceDialog(preference : Preference?) {
|
override fun onDisplayPreferenceDialog(preference : Preference?) {
|
||||||
if (preference is IntegerListPreference) {
|
if (preference is IntegerListPreference) {
|
||||||
// check if dialog is already showing
|
// Check if dialog is already showing
|
||||||
if (parentFragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
|
if (parentFragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG) != null)
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
val f = IntegerListPreference.IntegerListPreferenceDialogFragmentCompat.newInstance(preference.getKey())
|
val f = IntegerListPreference.IntegerListPreferenceDialogFragmentCompat.newInstance(preference.getKey())
|
||||||
f.setTargetFragment(this, 0)
|
f.setTargetFragment(this, 0)
|
||||||
|
@ -25,11 +25,10 @@ import emu.skyline.R as sR
|
|||||||
import emu.skyline.di.getSettings
|
import emu.skyline.di.getSettings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Preference that displays a list of entries as a dialog.
|
* A Preference that displays a list of strings in a dialog and saves an integer that corresponds to the selected entry (as specified by entryValues or the index of the selected entry)
|
||||||
* This preference saves an integer value instead of a string one.
|
|
||||||
* @see androidx.preference.ListPreference
|
* @see androidx.preference.ListPreference
|
||||||
*/
|
*/
|
||||||
@SuppressLint("RestrictedApi", "ResourceType")
|
@SuppressLint("RestrictedApi")
|
||||||
class IntegerListPreference @JvmOverloads constructor(
|
class IntegerListPreference @JvmOverloads constructor(
|
||||||
context : Context,
|
context : Context,
|
||||||
attrs : AttributeSet? = null,
|
attrs : AttributeSet? = null,
|
||||||
@ -40,28 +39,27 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
defStyleRes : Int = 0
|
defStyleRes : Int = 0
|
||||||
) : DialogPreference(context, attrs, defStyleAttr, defStyleRes) {
|
) : DialogPreference(context, attrs, defStyleAttr, defStyleRes) {
|
||||||
/**
|
/**
|
||||||
* The list of entries to be shown in the list in subsequent dialogs.
|
* The list of entries to be shown in the list in subsequent dialogs
|
||||||
*/
|
*/
|
||||||
var entries : Array<CharSequence>?
|
var entries : Array<CharSequence>?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The array to find the value to save for a preference when an entry from entries is
|
* The array to find the value to save for a preference when an entry from entries is
|
||||||
* selected. If a user clicks on the second item in entries, the second item in this array
|
* selected. If a user clicks on the second item in entries, the second item in this array
|
||||||
* will be saved to the preference.
|
* will be saved to the preference
|
||||||
*/
|
*/
|
||||||
var entryValues : IntArray?
|
var entryValues : IntArray?
|
||||||
|
|
||||||
private var value : Int? = null
|
private var value : Int? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
// Always persist/notify the first time.
|
// Always persist/notify the first time
|
||||||
val changed = field != value
|
val changed = field != value
|
||||||
if (changed || !isValueSet) {
|
if (changed || !isValueSet) {
|
||||||
field = value
|
field = value
|
||||||
isValueSet = true
|
isValueSet = true
|
||||||
value?.let { persistInt(it) }
|
value?.let { persistInt(it) }
|
||||||
if (changed) {
|
if (changed)
|
||||||
notifyChanged()
|
notifyChanged()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,36 +68,19 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val res : Resources = context.resources
|
val res : Resources = context.resources
|
||||||
|
val styledAttrs = context.obtainStyledAttributes(attrs, sR.styleable.IntegerListPreference, defStyleAttr, defStyleRes)
|
||||||
|
|
||||||
val a = context.obtainStyledAttributes(
|
entries = TypedArrayUtils.getTextArray(styledAttrs, sR.styleable.IntegerListPreference_entries, sR.styleable.IntegerListPreference_android_entries)
|
||||||
attrs, sR.styleable.IntegerListPreference, defStyleAttr, defStyleRes
|
|
||||||
)
|
|
||||||
|
|
||||||
entries = TypedArrayUtils.getTextArray(
|
val entryValuesId = TypedArrayUtils.getResourceId(styledAttrs, sR.styleable.IntegerListPreference_android_entryValues, sR.styleable.IntegerListPreference_android_entryValues, 0)
|
||||||
a, sR.styleable.IntegerListPreference_entries,
|
|
||||||
sR.styleable.IntegerListPreference_android_entries
|
|
||||||
)
|
|
||||||
|
|
||||||
val entryValuesId = TypedArrayUtils.getResourceId(
|
|
||||||
a, sR.styleable.IntegerListPreference_android_entryValues,
|
|
||||||
sR.styleable.IntegerListPreference_android_entryValues, 0
|
|
||||||
)
|
|
||||||
entryValues = if (entryValuesId != 0) res.getIntArray(entryValuesId) else null
|
entryValues = if (entryValuesId != 0) res.getIntArray(entryValuesId) else null
|
||||||
|
|
||||||
if (TypedArrayUtils.getBoolean(
|
if (TypedArrayUtils.getBoolean(styledAttrs, sR.styleable.IntegerListPreference_useSimpleSummaryProvider, sR.styleable.IntegerListPreference_useSimpleSummaryProvider, false))
|
||||||
a, sR.styleable.IntegerListPreference_useSimpleSummaryProvider,
|
|
||||||
sR.styleable.IntegerListPreference_useSimpleSummaryProvider, false
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
summaryProvider = SimpleSummaryProvider.instance
|
summaryProvider = SimpleSummaryProvider.instance
|
||||||
}
|
|
||||||
|
|
||||||
refreshRequired = TypedArrayUtils.getBoolean(
|
refreshRequired = TypedArrayUtils.getBoolean(styledAttrs, sR.styleable.IntegerListPreference_refreshRequired, sR.styleable.IntegerListPreference_refreshRequired, false)
|
||||||
a, sR.styleable.IntegerListPreference_refreshRequired,
|
|
||||||
sR.styleable.IntegerListPreference_refreshRequired, false
|
|
||||||
)
|
|
||||||
|
|
||||||
a.recycle()
|
styledAttrs.recycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,16 +105,14 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param value The value whose index should be returned
|
|
||||||
* @return The index of the value, or -1 if not found
|
* @return The index of the value, or -1 if not found
|
||||||
*/
|
*/
|
||||||
private fun findIndexOfValue(value : Int?) : Int {
|
private fun findIndexOfValue(value : Int?) : Int {
|
||||||
entryValues?.let {
|
entryValues?.let {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
for (i in it.indices.reversed()) {
|
for (i in it.indices.reversed()) {
|
||||||
if (it[i] == value) {
|
if (it[i] == value)
|
||||||
return i
|
return i
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,8 +120,7 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value to the given index from the entry values.
|
* Sets the value to the given index from the entry values
|
||||||
* @param index The index of the value to set
|
|
||||||
*/
|
*/
|
||||||
fun setValueIndex(index : Int) {
|
fun setValueIndex(index : Int) {
|
||||||
value = entryValues?.get(index) ?: index
|
value = entryValues?.get(index) ?: index
|
||||||
@ -157,22 +135,19 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSetInitialValue(defaultValue : Any?) {
|
override fun onSetInitialValue(defaultValue : Any?) {
|
||||||
// `Preference` superclass passes a null defaultValue if it is sure there
|
// `Preference` superclass passes a null defaultValue if it is sure there is already a persisted value
|
||||||
// is already a persisted value, se we have to account for that here by
|
// We have to account for that here by passing a random number as default value
|
||||||
// passing a random number as default value.
|
value = if (defaultValue != null)
|
||||||
value = if (defaultValue != null) {
|
|
||||||
getPersistedInt(defaultValue as Int)
|
getPersistedInt(defaultValue as Int)
|
||||||
} else {
|
else
|
||||||
getPersistedInt(0)
|
getPersistedInt(0)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState() : Parcelable {
|
override fun onSaveInstanceState() : Parcelable {
|
||||||
val superState = super.onSaveInstanceState()
|
val superState = super.onSaveInstanceState()
|
||||||
if (isPersistent) {
|
if (isPersistent)
|
||||||
// No need to save instance state since it's persistent
|
// No need to save instance state since it's persistent
|
||||||
return superState
|
return superState
|
||||||
}
|
|
||||||
val myState = SavedState(superState)
|
val myState = SavedState(superState)
|
||||||
myState.value = value
|
myState.value = value
|
||||||
return myState
|
return myState
|
||||||
@ -218,9 +193,8 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple [androidx.preference.Preference.SummaryProvider] implementation for a
|
* A simple [androidx.preference.Preference.SummaryProvider] implementation
|
||||||
* [IntegerListPreference]. If no value has been set, the summary displayed will be 'Not set',
|
* If no value has been set, the summary displayed will be 'Not set', otherwise the summary displayed will be the entry set for this preference
|
||||||
* otherwise the summary displayed will be the entry set for this preference.
|
|
||||||
*/
|
*/
|
||||||
class SimpleSummaryProvider private constructor() : SummaryProvider<IntegerListPreference> {
|
class SimpleSummaryProvider private constructor() : SummaryProvider<IntegerListPreference> {
|
||||||
override fun provideSummary(preference : IntegerListPreference) : CharSequence {
|
override fun provideSummary(preference : IntegerListPreference) : CharSequence {
|
||||||
@ -230,18 +204,10 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
companion object {
|
companion object {
|
||||||
private var simpleSummaryProvider : SimpleSummaryProvider? = null
|
private var simpleSummaryProvider : SimpleSummaryProvider? = null
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a singleton instance of this simple
|
|
||||||
* [androidx.preference.Preference.SummaryProvider] implementation.
|
|
||||||
*
|
|
||||||
* @return a singleton instance of this simple
|
|
||||||
* [androidx.preference.Preference.SummaryProvider] implementation
|
|
||||||
*/
|
|
||||||
val instance : SimpleSummaryProvider?
|
val instance : SimpleSummaryProvider?
|
||||||
get() {
|
get() {
|
||||||
if (simpleSummaryProvider == null) {
|
if (simpleSummaryProvider == null)
|
||||||
simpleSummaryProvider = SimpleSummaryProvider()
|
simpleSummaryProvider = SimpleSummaryProvider()
|
||||||
}
|
|
||||||
return simpleSummaryProvider
|
return simpleSummaryProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,17 +254,12 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
context?.getSettings()?.refreshRequired = true
|
context?.getSettings()?.refreshRequired = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clicking on an item simulates the positive button click, and dismisses
|
// Clicking on an item simulates the positive button click, and dismisses the dialog
|
||||||
// the dialog.
|
onClick(dialog, DialogInterface.BUTTON_POSITIVE)
|
||||||
onClick(
|
|
||||||
dialog,
|
|
||||||
DialogInterface.BUTTON_POSITIVE
|
|
||||||
)
|
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
// The typical interaction for list-based dialogs is to have click-on-an-item dismiss the
|
// The typical interaction for list-based dialogs is to have click-on-an-item dismiss the dialog instead of the user having to press 'Ok'
|
||||||
// dialog instead of the user having to press 'Ok'.
|
|
||||||
builder.setPositiveButton(null, null)
|
builder.setPositiveButton(null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,9 +267,8 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
if (positiveResult && clickedDialogEntryIndex >= 0) {
|
if (positiveResult && clickedDialogEntryIndex >= 0) {
|
||||||
val value = entryValues?.get(clickedDialogEntryIndex) ?: clickedDialogEntryIndex
|
val value = entryValues?.get(clickedDialogEntryIndex) ?: clickedDialogEntryIndex
|
||||||
val preference = listPreference
|
val preference = listPreference
|
||||||
if (preference.callChangeListener(value)) {
|
if (preference.callChangeListener(value))
|
||||||
preference.value = value
|
preference.value = value
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,9 +279,9 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
|
|
||||||
fun newInstance(key : String?) : IntegerListPreferenceDialogFragmentCompat {
|
fun newInstance(key : String?) : IntegerListPreferenceDialogFragmentCompat {
|
||||||
val fragment = IntegerListPreferenceDialogFragmentCompat()
|
val fragment = IntegerListPreferenceDialogFragmentCompat()
|
||||||
val b = Bundle(1)
|
val bundle = Bundle(1)
|
||||||
b.putString(ARG_KEY, key)
|
bundle.putString(ARG_KEY, key)
|
||||||
fragment.arguments = b
|
fragment.arguments = bundle
|
||||||
return fragment
|
return fragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user