@@ -0,0 +1,59 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.cheats.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.dolphinemu.dolphinemu.databinding.FragmentCheatWarningBinding
import org.dolphinemu.dolphinemu.features.cheats.ui.CheatsActivity.Companion.setOnFocusChangeListenerRecursively
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity

abstract class SettingDisabledWarningFragment(
private val setting: AbstractBooleanSetting,
private val settingShortcut: MenuTag,
private val text: Int
) : Fragment(), View.OnClickListener {
private var _binding: FragmentCheatWarningBinding? = null
private val binding get() = _binding!!

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentCheatWarningBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
binding.textWarning.setText(text)
binding.buttonSettings.setOnClickListener(this)
val activity = requireActivity() as CheatsActivity
setOnFocusChangeListenerRecursively(view) { _: View?, hasFocus: Boolean ->
activity.onListViewFocusChange(hasFocus)
}
}

override fun onResume() {
super.onResume()
val activity = requireActivity() as CheatsActivity
activity.loadGameSpecificSettings().use { settings ->
val cheatsEnabled = setting.getBoolean(settings)
requireView().visibility = if (cheatsEnabled) View.GONE else View.VISIBLE
}
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

override fun onClick(view: View) {
SettingsActivity.launch(requireContext(), settingShortcut)
}
}

This file was deleted.

@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.ui

import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.activity.OnBackPressedCallback
import androidx.slidingpanelayout.widget.SlidingPaneLayout
import androidx.slidingpanelayout.widget.SlidingPaneLayout.PanelSlideListener

class TwoPaneOnBackPressedCallback(private val slidingPaneLayout: SlidingPaneLayout) :
OnBackPressedCallback(slidingPaneLayout.isSlideable && slidingPaneLayout.isOpen),
PanelSlideListener {
init {
slidingPaneLayout.addPanelSlideListener(this)
}

override fun handleOnBackPressed() {
slidingPaneLayout.close()
}

override fun onPanelSlide(panel: View, slideOffset: Float) {}
override fun onPanelOpened(panel: View) {
isEnabled = true
}

override fun onPanelClosed(panel: View) {
closeKeyboard()
isEnabled = false
}

private fun closeKeyboard() {
val manager = slidingPaneLayout.context
.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
manager.hideSoftInputFromWindow(slidingPaneLayout.rootView.windowToken, 0)
}
}
8 changes: 4 additions & 4 deletions Source/Android/jni/AndroidCommon/IDCache.cpp
Expand Up @@ -500,7 +500,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
const jclass ar_cheat_class =
env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/ARCheat");
s_ar_cheat_class = reinterpret_cast<jclass>(env->NewGlobalRef(ar_cheat_class));
s_ar_cheat_pointer = env->GetFieldID(ar_cheat_class, "mPointer", "J");
s_ar_cheat_pointer = env->GetFieldID(ar_cheat_class, "pointer", "J");
s_ar_cheat_constructor = env->GetMethodID(ar_cheat_class, "<init>", "(J)V");
env->DeleteLocalRef(ar_cheat_class);

Expand All @@ -514,22 +514,22 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
const jclass patch_cheat_class =
env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/PatchCheat");
s_patch_cheat_class = reinterpret_cast<jclass>(env->NewGlobalRef(patch_cheat_class));
s_patch_cheat_pointer = env->GetFieldID(patch_cheat_class, "mPointer", "J");
s_patch_cheat_pointer = env->GetFieldID(patch_cheat_class, "pointer", "J");
s_patch_cheat_constructor = env->GetMethodID(patch_cheat_class, "<init>", "(J)V");
env->DeleteLocalRef(patch_cheat_class);

const jclass graphics_mod_group_class =
env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/GraphicsModGroup");
s_graphics_mod_group_class =
reinterpret_cast<jclass>(env->NewGlobalRef(graphics_mod_group_class));
s_graphics_mod_group_pointer = env->GetFieldID(graphics_mod_group_class, "mPointer", "J");
s_graphics_mod_group_pointer = env->GetFieldID(graphics_mod_group_class, "pointer", "J");
s_graphics_mod_group_constructor = env->GetMethodID(graphics_mod_group_class, "<init>", "(J)V");
env->DeleteLocalRef(graphics_mod_group_class);

const jclass graphics_mod_class =
env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/GraphicsMod");
s_graphics_mod_class = reinterpret_cast<jclass>(env->NewGlobalRef(graphics_mod_class));
s_graphics_mod_pointer = env->GetFieldID(graphics_mod_class, "mPointer", "J");
s_graphics_mod_pointer = env->GetFieldID(graphics_mod_class, "pointer", "J");
s_graphics_mod_constructor =
env->GetMethodID(graphics_mod_class, "<init>",
"(JLorg/dolphinemu/dolphinemu/features/cheats/model/GraphicsModGroup;)V");
Expand Down
2 changes: 1 addition & 1 deletion Source/Android/jni/Cheats/ARCheat.cpp
Expand Up @@ -81,7 +81,7 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_ARCheat_getEnabled(JNIEnv*
return static_cast<jboolean>(GetPointer(env, obj)->enabled);
}

JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_ARCheat_trySetImpl(
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_ARCheat_setCheatImpl(
JNIEnv* env, jobject obj, jstring name, jstring creator, jstring notes, jstring code_string)
{
ActionReplay::ARCode* code = GetPointer(env, obj);
Expand Down
2 changes: 1 addition & 1 deletion Source/Android/jni/Cheats/GeckoCheat.cpp
Expand Up @@ -99,7 +99,7 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_equalsImpl(JNIEn
return *GetPointer(env, obj) == *GetPointer(env, other);
}

JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_trySetImpl(
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_setCheatImpl(
JNIEnv* env, jobject obj, jstring name, jstring creator, jstring notes, jstring code_string)
{
Gecko::GeckoCode* code = GetPointer(env, obj);
Expand Down
2 changes: 1 addition & 1 deletion Source/Android/jni/Cheats/PatchCheat.cpp
Expand Up @@ -79,7 +79,7 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_getEnabled(JNIEn
return static_cast<jboolean>(GetPointer(env, obj)->enabled);
}

JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_trySetImpl(
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_setCheatImpl(
JNIEnv* env, jobject obj, jstring name, jstring creator, jstring notes, jstring code_string)
{
PatchEngine::Patch* patch = GetPointer(env, obj);
Expand Down