Android: Add "Ignore for this session" to Warning AlertMessages
This commit is contained in:
parent
991eb6ae83
commit
c3f34ac3fa
|
@ -446,7 +446,7 @@ public final class NativeLibrary
|
|||
public static native void SetObscuredPixelsTop(int height);
|
||||
|
||||
public static boolean displayAlertMsg(final String caption, final String text,
|
||||
final boolean yesNo)
|
||||
final boolean yesNo, final boolean isWarning)
|
||||
{
|
||||
Log.error("[NativeLibrary] Alert: " + text);
|
||||
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
||||
|
@ -455,6 +455,10 @@ public final class NativeLibrary
|
|||
{
|
||||
Log.warning("[NativeLibrary] EmulationActivity is null, can't do panic alert.");
|
||||
}
|
||||
else if (emulationActivity.isIgnoringWarnings() && isWarning)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// AlertMessages while the core is booting will deadlock when WaitUntilDoneBooting is called.
|
||||
|
@ -470,8 +474,9 @@ public final class NativeLibrary
|
|||
{
|
||||
sIsShowingAlertMessage = true;
|
||||
|
||||
emulationActivity.runOnUiThread(() -> AlertMessage.newInstance(caption, text, yesNo)
|
||||
.show(emulationActivity.getSupportFragmentManager(), "AlertMessage"));
|
||||
emulationActivity.runOnUiThread(
|
||||
() -> AlertMessage.newInstance(caption, text, yesNo, isWarning)
|
||||
.show(emulationActivity.getSupportFragmentManager(), "AlertMessage"));
|
||||
|
||||
// Wait for the lock to notify that it is complete.
|
||||
synchronized (sAlertMessageLock)
|
||||
|
|
|
@ -85,12 +85,14 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
private String mSelectedGameId;
|
||||
private int mPlatform;
|
||||
private String[] mPaths;
|
||||
private boolean mIgnoreWarnings;
|
||||
private static boolean sUserPausedEmulation;
|
||||
|
||||
public static final String EXTRA_SELECTED_GAMES = "SelectedGames";
|
||||
public static final String EXTRA_SELECTED_TITLE = "SelectedTitle";
|
||||
public static final String EXTRA_SELECTED_GAMEID = "SelectedGameId";
|
||||
public static final String EXTRA_PLATFORM = "Platform";
|
||||
public static final String EXTRA_IGNORE_WARNINGS = "IgnoreWarnings";
|
||||
public static final String EXTRA_USER_PAUSED_EMULATION = "sUserPausedEmulation";
|
||||
|
||||
@Retention(SOURCE)
|
||||
|
@ -272,6 +274,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
mSelectedTitle = gameToEmulate.getStringExtra(EXTRA_SELECTED_TITLE);
|
||||
mSelectedGameId = gameToEmulate.getStringExtra(EXTRA_SELECTED_GAMEID);
|
||||
mPlatform = gameToEmulate.getIntExtra(EXTRA_PLATFORM, 0);
|
||||
mIgnoreWarnings = gameToEmulate.getBooleanExtra(EXTRA_IGNORE_WARNINGS, false);
|
||||
sUserPausedEmulation = gameToEmulate.getBooleanExtra(EXTRA_USER_PAUSED_EMULATION, false);
|
||||
activityRecreated = false;
|
||||
Toast.makeText(this, R.string.emulation_menu_help, Toast.LENGTH_LONG).show();
|
||||
|
@ -327,6 +330,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
outState.putString(EXTRA_SELECTED_TITLE, mSelectedTitle);
|
||||
outState.putString(EXTRA_SELECTED_GAMEID, mSelectedGameId);
|
||||
outState.putInt(EXTRA_PLATFORM, mPlatform);
|
||||
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, mIgnoreWarnings);
|
||||
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, sUserPausedEmulation);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
@ -337,6 +341,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
mSelectedTitle = savedInstanceState.getString(EXTRA_SELECTED_TITLE);
|
||||
mSelectedGameId = savedInstanceState.getString(EXTRA_SELECTED_GAMEID);
|
||||
mPlatform = savedInstanceState.getInt(EXTRA_PLATFORM);
|
||||
mIgnoreWarnings = savedInstanceState.getBoolean(EXTRA_IGNORE_WARNINGS);
|
||||
sUserPausedEmulation = savedInstanceState.getBoolean(EXTRA_USER_PAUSED_EMULATION);
|
||||
}
|
||||
|
||||
|
@ -671,6 +676,16 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isIgnoringWarnings()
|
||||
{
|
||||
return mIgnoreWarnings;
|
||||
}
|
||||
|
||||
public void setIgnoreWarnings(boolean value)
|
||||
{
|
||||
mIgnoreWarnings = value;
|
||||
}
|
||||
|
||||
public static boolean getHasUserPausedEmulation()
|
||||
{
|
||||
return sUserPausedEmulation;
|
||||
|
|
|
@ -17,8 +17,10 @@ public final class AlertMessage extends DialogFragment
|
|||
private static final String ARG_TITLE = "title";
|
||||
private static final String ARG_MESSAGE = "message";
|
||||
private static final String ARG_YES_NO = "yesNo";
|
||||
private static final String ARG_IS_WARNING = "isWarning";
|
||||
|
||||
public static AlertMessage newInstance(String title, String message, boolean yesNo)
|
||||
public static AlertMessage newInstance(String title, String message, boolean yesNo,
|
||||
boolean isWarning)
|
||||
{
|
||||
AlertMessage fragment = new AlertMessage();
|
||||
|
||||
|
@ -26,6 +28,7 @@ public final class AlertMessage extends DialogFragment
|
|||
args.putString(ARG_TITLE, title);
|
||||
args.putString(ARG_MESSAGE, message);
|
||||
args.putBoolean(ARG_YES_NO, yesNo);
|
||||
args.putBoolean(ARG_IS_WARNING, isWarning);
|
||||
fragment.setArguments(args);
|
||||
|
||||
return fragment;
|
||||
|
@ -39,6 +42,7 @@ public final class AlertMessage extends DialogFragment
|
|||
String title = requireArguments().getString(ARG_TITLE);
|
||||
String message = requireArguments().getString(ARG_MESSAGE);
|
||||
boolean yesNo = requireArguments().getBoolean(ARG_YES_NO);
|
||||
boolean isWarning = requireArguments().getBoolean(ARG_IS_WARNING);
|
||||
setCancelable(false);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(emulationActivity,
|
||||
|
@ -71,6 +75,17 @@ public final class AlertMessage extends DialogFragment
|
|||
NativeLibrary.NotifyAlertMessageLock();
|
||||
});
|
||||
}
|
||||
|
||||
if (isWarning)
|
||||
{
|
||||
builder.setNeutralButton(R.string.ignore_warning_alert_messages, (dialog, which) ->
|
||||
{
|
||||
emulationActivity.setIgnoreWarnings(true);
|
||||
dialog.dismiss();
|
||||
NativeLibrary.NotifyAlertMessageLock();
|
||||
});
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
|
|
@ -438,5 +438,6 @@ It can efficiently compress both junk data and encrypted Wii data.
|
|||
<string name="slider_setting_value">%1$d%2$s</string>
|
||||
<string name="disc_number">Disc %1$d</string>
|
||||
<string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string>
|
||||
<string name="ignore_warning_alert_messages">Ignore for this session</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -210,7 +210,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
|||
const jclass native_library_class = env->FindClass("org/dolphinemu/dolphinemu/NativeLibrary");
|
||||
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
||||
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Z)Z");
|
||||
"(Ljava/lang/String;Ljava/lang/String;ZZ)Z");
|
||||
s_do_rumble = env->GetStaticMethodID(s_native_library_class, "rumble", "(ID)V");
|
||||
s_get_update_touch_pointer =
|
||||
env->GetStaticMethodID(s_native_library_class, "updateTouchPointer", "()V");
|
||||
|
|
|
@ -151,14 +151,14 @@ void Host_TitleChanged()
|
|||
{
|
||||
}
|
||||
|
||||
static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common::MsgType /*style*/)
|
||||
static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common::MsgType style)
|
||||
{
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
|
||||
// Execute the Java method.
|
||||
jboolean result = env->CallStaticBooleanMethod(
|
||||
IDCache::GetNativeLibraryClass(), IDCache::GetDisplayAlertMsg(), ToJString(env, caption),
|
||||
ToJString(env, text), yes_no ? JNI_TRUE : JNI_FALSE);
|
||||
ToJString(env, text), yes_no ? JNI_TRUE : JNI_FALSE, style == Common::MsgType::Warning);
|
||||
|
||||
return result != JNI_FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue