summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2022-09-24 13:03:45 +0200
committerJosJuice <josjuice@gmail.com>2022-09-24 13:03:45 +0200
commit04072f0ce63c64924695743cd83a028c06fe6be2 (patch)
tree358e1d8a5703ba1db7da09dbcbb1ee54929de98e /Source/Android
parent16c71b9a35dbe522d6d78406bf298dcd6a56f93f (diff)
Integrate "Ignore for this session" better with config system
Because of the previous commit, this is needed to stop DolphinQt from forgetting that the user pressed ignore whenever any part of the config is changed. This commit also changes the behavior a bit on DolphinQt: "Ignore for this session" now applies to the current emulation session instead of the current Dolphin launch. This matches how it already worked on Android, and is in my opinion better because it means the user won't lose out on important panic alerts in a game becase they played another game first that had repeated panic alerts that they wanted to ignore. For Android, this commit isn't necessary, but it makes the code cleaner.
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java75
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java15
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/AlertMessage.java4
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java12
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java1
-rw-r--r--Source/Android/jni/Config/NativeConfig.cpp5
6 files changed, 56 insertions, 56 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
index dd2c4e8407..fa347e0f25 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
@@ -511,59 +511,54 @@ public final class NativeLibrary
Log.error("[NativeLibrary] Alert: " + text);
final EmulationActivity emulationActivity = sEmulationActivity.get();
boolean result = false;
- if (isWarning && emulationActivity != null && emulationActivity.isIgnoringWarnings())
+
+ // We can't use AlertMessages unless we have a non-null activity reference
+ // and are allowed to block. As a fallback, we can use toasts.
+ if (emulationActivity == null || nonBlocking)
{
- return true;
+ new Handler(Looper.getMainLooper()).post(
+ () -> Toast.makeText(DolphinApplication.getAppContext(), text, Toast.LENGTH_LONG)
+ .show());
}
else
{
- // We can't use AlertMessages unless we have a non-null activity reference
- // and are allowed to block. As a fallback, we can use toasts.
- if (emulationActivity == null || nonBlocking)
- {
- new Handler(Looper.getMainLooper()).post(
- () -> Toast.makeText(DolphinApplication.getAppContext(), text, Toast.LENGTH_LONG)
- .show());
- }
- else
- {
- sIsShowingAlertMessage = true;
+ sIsShowingAlertMessage = true;
- emulationActivity.runOnUiThread(() ->
+ emulationActivity.runOnUiThread(() ->
+ {
+ FragmentManager fragmentManager = emulationActivity.getSupportFragmentManager();
+ if (fragmentManager.isStateSaved())
{
- FragmentManager fragmentManager = emulationActivity.getSupportFragmentManager();
- if (fragmentManager.isStateSaved())
- {
- // The activity is being destroyed, so we can't use it to display an AlertMessage.
- // Fall back to a toast.
- Toast.makeText(emulationActivity, text, Toast.LENGTH_LONG).show();
- NotifyAlertMessageLock();
- }
- else
- {
- AlertMessage.newInstance(caption, text, yesNo, isWarning)
- .show(fragmentManager, "AlertMessage");
- }
- });
-
- // Wait for the lock to notify that it is complete.
- synchronized (sAlertMessageLock)
+ // The activity is being destroyed, so we can't use it to display an AlertMessage.
+ // Fall back to a toast.
+ Toast.makeText(emulationActivity, text, Toast.LENGTH_LONG).show();
+ NotifyAlertMessageLock();
+ }
+ else
{
- try
- {
- sAlertMessageLock.wait();
- }
- catch (Exception ignored)
- {
- }
+ AlertMessage.newInstance(caption, text, yesNo, isWarning)
+ .show(fragmentManager, "AlertMessage");
}
+ });
- if (yesNo)
+ // Wait for the lock to notify that it is complete.
+ synchronized (sAlertMessageLock)
+ {
+ try
{
- result = AlertMessage.getAlertResult();
+ sAlertMessageLock.wait();
}
+ catch (Exception ignored)
+ {
+ }
+ }
+
+ if (yesNo)
+ {
+ result = AlertMessage.getAlertResult();
}
}
+
sIsShowingAlertMessage = false;
return result;
}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
index 969d1ca3f1..9106d8d81c 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
@@ -88,14 +88,12 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
private String[] mPaths;
private boolean mRiivolution;
private boolean mLaunchSystemMenu;
- private boolean mIgnoreWarnings;
private static boolean sUserPausedEmulation;
private boolean mMenuToastShown;
public static final String EXTRA_SELECTED_GAMES = "SelectedGames";
public static final String EXTRA_RIIVOLUTION = "Riivolution";
public static final String EXTRA_SYSTEM_MENU = "SystemMenu";
- public static final String EXTRA_IGNORE_WARNINGS = "IgnoreWarnings";
public static final String EXTRA_USER_PAUSED_EMULATION = "sUserPausedEmulation";
public static final String EXTRA_MENU_TOAST_SHOWN = "MenuToastShown";
@@ -316,7 +314,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
mPaths = gameToEmulate.getStringArrayExtra(EXTRA_SELECTED_GAMES);
mRiivolution = gameToEmulate.getBooleanExtra(EXTRA_RIIVOLUTION, false);
mLaunchSystemMenu = gameToEmulate.getBooleanExtra(EXTRA_SYSTEM_MENU, false);
- mIgnoreWarnings = gameToEmulate.getBooleanExtra(EXTRA_IGNORE_WARNINGS, false);
sUserPausedEmulation = gameToEmulate.getBooleanExtra(EXTRA_USER_PAUSED_EMULATION, false);
mMenuToastShown = false;
activityRecreated = false;
@@ -366,7 +363,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
mEmulationFragment.saveTemporaryState();
}
outState.putStringArray(EXTRA_SELECTED_GAMES, mPaths);
- outState.putBoolean(EXTRA_IGNORE_WARNINGS, mIgnoreWarnings);
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, sUserPausedEmulation);
outState.putBoolean(EXTRA_MENU_TOAST_SHOWN, mMenuToastShown);
super.onSaveInstanceState(outState);
@@ -375,7 +371,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
protected void restoreState(Bundle savedInstanceState)
{
mPaths = savedInstanceState.getStringArray(EXTRA_SELECTED_GAMES);
- mIgnoreWarnings = savedInstanceState.getBoolean(EXTRA_IGNORE_WARNINGS);
sUserPausedEmulation = savedInstanceState.getBoolean(EXTRA_USER_PAUSED_EMULATION);
mMenuToastShown = savedInstanceState.getBoolean(EXTRA_MENU_TOAST_SHOWN);
}
@@ -754,16 +749,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
}
}
- public boolean isIgnoringWarnings()
- {
- return mIgnoreWarnings;
- }
-
- public void setIgnoreWarnings(boolean value)
- {
- mIgnoreWarnings = value;
- }
-
public static boolean getHasUserPausedEmulation()
{
return sUserPausedEmulation;
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/AlertMessage.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/AlertMessage.java
index 69cf5ef280..aef3016134 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/AlertMessage.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/AlertMessage.java
@@ -13,6 +13,8 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
+import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
+import org.dolphinemu.dolphinemu.features.settings.model.NativeConfig;
public final class AlertMessage extends DialogFragment
{
@@ -82,7 +84,7 @@ public final class AlertMessage extends DialogFragment
{
builder.setNeutralButton(R.string.ignore_warning_alert_messages, (dialog, which) ->
{
- emulationActivity.setIgnoreWarnings(true);
+ BooleanSetting.MAIN_USE_PANIC_HANDLERS.setBoolean(NativeConfig.LAYER_CURRENT, false);
dialog.dismiss();
NativeLibrary.NotifyAlertMessageLock();
});
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java
index 0c02f1b9a0..2a82bdd5b4 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java
@@ -329,6 +329,18 @@ public enum BooleanSetting implements AbstractBooleanSetting
}
}
+ public void setBoolean(int layerType, boolean newValue)
+ {
+ if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
+ {
+ NativeConfig.setBoolean(layerType, mFile, mSection, mKey, newValue);
+ }
+ else
+ {
+ throw new UnsupportedOperationException("The old config system doesn't support layers");
+ }
+ }
+
public boolean getBooleanGlobal()
{
return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java
index 21ad4b661f..07646a2eb8 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java
@@ -8,6 +8,7 @@ public class NativeConfig
public static final int LAYER_BASE = 1;
public static final int LAYER_LOCAL_GAME = 2;
public static final int LAYER_ACTIVE = 3;
+ public static final int LAYER_CURRENT = 4;
public static native boolean isSettingSaveable(String file, String section, String key);
diff --git a/Source/Android/jni/Config/NativeConfig.cpp b/Source/Android/jni/Config/NativeConfig.cpp
index 4ec0d0bd86..f707e91f5b 100644
--- a/Source/Android/jni/Config/NativeConfig.cpp
+++ b/Source/Android/jni/Config/NativeConfig.cpp
@@ -16,6 +16,7 @@ constexpr jint LAYER_BASE_OR_CURRENT = 0;
constexpr jint LAYER_BASE = 1;
constexpr jint LAYER_LOCAL_GAME = 2;
constexpr jint LAYER_ACTIVE = 3;
+constexpr jint LAYER_CURRENT = 4;
static Config::Location GetLocation(JNIEnv* env, jstring file, jstring section, jstring key)
{
@@ -76,6 +77,10 @@ static std::shared_ptr<Config::Layer> GetLayer(jint layer, const Config::Locatio
layer_type = Config::GetActiveLayerForConfig(location);
break;
+ case LAYER_CURRENT:
+ layer_type = Config::LayerType::CurrentRun;
+ break;
+
default:
ASSERT(false);
return nullptr;