Skip to content

Commit

Permalink
Android: Cleanup some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamer64ytb committed Aug 19, 2024
1 parent 296ffb1 commit 8d88676
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ object MiiSelector {
lateinit var data: MiiSelectorData
val finishLock = Object()

private fun ExecuteImpl(config: MiiSelectorConfig) {
private fun executeImpl(config: MiiSelectorConfig) {
val emulationActivity = NativeLibrary.sEmulationActivity.get()
data = MiiSelectorData(0, 0)
val fragment = MiiSelectorDialogFragment.newInstance(config)
fragment.show(emulationActivity!!.supportFragmentManager, "mii_selector")
}

@JvmStatic
fun Execute(config: MiiSelectorConfig): MiiSelectorData {
NativeLibrary.sEmulationActivity.get()!!.runOnUiThread { ExecuteImpl(config) }
fun execute(config: MiiSelectorConfig): MiiSelectorData {
NativeLibrary.sEmulationActivity.get()!!.runOnUiThread { executeImpl(config) }
synchronized(finishLock) {
try {
finishLock.wait()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ object SoftwareKeyboard {
lateinit var data: KeyboardData
val finishLock = Object()

private fun ExecuteImpl(config: KeyboardConfig) {
private fun executeImpl(config: KeyboardConfig) {
val emulationActivity = NativeLibrary.sEmulationActivity.get()
data = KeyboardData(0, "")
KeyboardDialogFragment.newInstance(config)
.show(emulationActivity!!.supportFragmentManager, KeyboardDialogFragment.TAG)
}

fun HandleValidationError(config: KeyboardConfig, error: ValidationError) {
fun handleValidationError(config: KeyboardConfig, error: ValidationError) {
val emulationActivity = NativeLibrary.sEmulationActivity.get()!!
val message: String = when (error) {
ValidationError.FixedLengthRequired -> emulationActivity.getString(
Expand All @@ -54,12 +54,12 @@ object SoftwareKeyboard {
}

@JvmStatic
fun Execute(config: KeyboardConfig): KeyboardData {
if (config.buttonConfig == ButtonConfig.None) {
fun execute(config: KeyboardConfig): KeyboardData {
if (config.buttonConfig == ButtonConfig.NONE) {
Log.error("Unexpected button config None")
return KeyboardData(0, "")
}
NativeLibrary.sEmulationActivity.get()!!.runOnUiThread { ExecuteImpl(config) }
NativeLibrary.sEmulationActivity.get()!!.runOnUiThread { executeImpl(config) }
synchronized(finishLock) {
try {
finishLock.wait()
Expand All @@ -70,24 +70,24 @@ object SoftwareKeyboard {
}

@JvmStatic
fun ShowError(error: String) {
fun showError(error: String) {
NativeLibrary.displayAlertMsg(
appContext.resources.getString(R.string.software_keyboard),
error,
false
)
}

private external fun ValidateFilters(text: String): ValidationError
external fun ValidateInput(text: String): ValidationError
private external fun validateFilters(text: String): ValidationError
external fun validateInput(text: String): ValidationError

/// Corresponds to Frontend::ButtonConfig
interface ButtonConfig {
companion object {
const val Single = 0 /// Ok button
const val Dual = 1 /// Cancel | Ok buttons
const val Triple = 2 /// Cancel | I Forgot | Ok buttons
const val None = 3 /// No button (returned by swkbdInputText in special cases)
const val SINGLE = 0 /// Ok button
const val DUAL = 1 /// Cancel | Ok buttons
const val TRIPLE = 2 /// Cancel | I Forgot | Ok buttons
const val NONE = 3 /// No button (returned by swkbdInputText in special cases)
}
}

Expand Down Expand Up @@ -142,7 +142,7 @@ object SoftwareKeyboard {
val text = StringBuilder(dest)
.replace(dstart, dend, source.subSequence(start, end).toString())
.toString()
return if (ValidateFilters(text) == ValidationError.None) {
return if (validateFilters(text) == ValidationError.None) {
null // Accept replacement
} else {
dest.subSequence(dstart, dend) // Request the subsequence to be unchanged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ class ScreenAdjustmentUtil(private val windowManager: WindowManager,

fun cycleLayouts() {
// TODO: figure out how to pull these from R.array
val landscape_values = intArrayOf(6,1,3,4,0,5)
val portrait_values = intArrayOf(0,1)
val landscapeValues = intArrayOf(6, 1, 3, 4, 0, 5)
val portraitValues = intArrayOf(0, 1)
if (NativeLibrary.isPortraitMode) {
val current_layout = IntSetting.PORTRAIT_SCREEN_LAYOUT.int
val pos = portrait_values.indexOf(current_layout)
val layout_option = portrait_values[(pos + 1) % portrait_values.size]
changePortraitOrientation(layout_option)
val currentLayout = IntSetting.PORTRAIT_SCREEN_LAYOUT.int
val pos = portraitValues.indexOf(currentLayout)
val layoutOption = portraitValues[(pos + 1) % portraitValues.size]
changePortraitOrientation(layoutOption)
} else {
val current_layout = IntSetting.SCREEN_LAYOUT.int
val pos = landscape_values.indexOf(current_layout)
val layout_option = landscape_values[(pos + 1) % landscape_values.size]
changeScreenOrientation(layout_option)
val currentLayout = IntSetting.SCREEN_LAYOUT.int
val pos = landscapeValues.indexOf(currentLayout)
val layoutOption = landscapeValues[(pos + 1) % landscapeValues.size]
changeScreenOrientation(layoutOption)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class KeyboardDialogFragment : DialogFragment() {
isCancelable = false

when (config.buttonConfig) {
SoftwareKeyboard.ButtonConfig.Triple -> {
SoftwareKeyboard.ButtonConfig.TRIPLE -> {
val negativeText =
config.buttonText[0].ifEmpty { getString(android.R.string.cancel) }
val neutralText = config.buttonText[1].ifEmpty { getString(R.string.i_forgot) }
Expand All @@ -50,15 +50,15 @@ class KeyboardDialogFragment : DialogFragment() {
.setPositiveButton(positiveText, null)
}

SoftwareKeyboard.ButtonConfig.Dual -> {
SoftwareKeyboard.ButtonConfig.DUAL -> {
val negativeText =
config.buttonText[0].ifEmpty { getString(android.R.string.cancel) }
val positiveText = config.buttonText[2].ifEmpty { getString(android.R.string.ok) }
builder.setNegativeButton(negativeText, null)
.setPositiveButton(positiveText, null)
}

SoftwareKeyboard.ButtonConfig.Single -> {
SoftwareKeyboard.ButtonConfig.SINGLE -> {
val positiveText = config.buttonText[2].ifEmpty { getString(android.R.string.ok) }
builder.setPositiveButton(positiveText, null)
}
Expand All @@ -72,9 +72,9 @@ class KeyboardDialogFragment : DialogFragment() {
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
SoftwareKeyboard.data.button = config.buttonConfig
SoftwareKeyboard.data.text = binding.editTextInput.text.toString()
val error = SoftwareKeyboard.ValidateInput(SoftwareKeyboard.data.text)
val error = SoftwareKeyboard.validateInput(SoftwareKeyboard.data.text)
if (error != SoftwareKeyboard.ValidationError.None) {
SoftwareKeyboard.HandleValidationError(config, error)
SoftwareKeyboard.handleValidationError(config, error)
return@setOnClickListener
}
dismiss()
Expand Down
2 changes: 1 addition & 1 deletion src/android/app/src/main/jni/applets/mii_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void InitJNI(JNIEnv* env) {
env->FindClass("io/github/mandarine3ds/mandarine/applets/MiiSelector$MiiSelectorData")));

s_mii_selector_execute = env->GetStaticMethodID(
s_mii_selector_class, "Execute",
s_mii_selector_class, "execute",
"(Lio/github/mandarine3ds/mandarine/applets/MiiSelector$MiiSelectorConfig;)Lio/"
"github/mandarine3ds/mandarine/applets/MiiSelector$MiiSelectorData;");
}
Expand Down
8 changes: 4 additions & 4 deletions src/android/app/src/main/jni/applets/swkbd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ void InitJNI(JNIEnv* env) {
"io/github/mandarine3ds/mandarine/applets/SoftwareKeyboard$ValidationError")));

s_swkbd_execute =
env->GetStaticMethodID(s_software_keyboard_class, "Execute",
env->GetStaticMethodID(s_software_keyboard_class, "execute",
"(Lio/github/mandarine3ds/mandarine/applets/"
"SoftwareKeyboard$KeyboardConfig;)Lio/github/mandarine3ds/mandarine/"
"applets/SoftwareKeyboard$KeyboardData;");
s_swkbd_show_error =
env->GetStaticMethodID(s_software_keyboard_class, "ShowError", "(Ljava/lang/String;)V");
env->GetStaticMethodID(s_software_keyboard_class, "showError", "(Ljava/lang/String;)V");
}

void CleanupJNI(JNIEnv* env) {
Expand Down Expand Up @@ -126,15 +126,15 @@ jobject ToJavaValidationError(Frontend::ValidationError error) {
"Lio/github/mandarine3ds/mandarine/applets/SoftwareKeyboard$ValidationError;"));
}

jobject Java_io_github_mandarine3ds_mandarine_applets_SoftwareKeyboard_ValidateFilters(
jobject Java_io_github_mandarine3ds_mandarine_applets_SoftwareKeyboard_validateFilters(
JNIEnv* env, jclass clazz, jstring text) {

const auto ret =
Core::System::GetInstance().GetSoftwareKeyboard()->ValidateFilters(GetJString(env, text));
return ToJavaValidationError(ret);
}

jobject Java_io_github_mandarine3ds_mandarine_applets_SoftwareKeyboard_ValidateInput(JNIEnv* env,
jobject Java_io_github_mandarine3ds_mandarine_applets_SoftwareKeyboard_validateInput(JNIEnv* env,
jclass clazz,
jstring text) {

Expand Down

0 comments on commit 8d88676

Please sign in to comment.