Merge pull request #9156 from JosJuice/android-alertmsg-outside-emulation
Android: Show alert messages as toasts outside of emulation
This commit is contained in:
commit
150282f7b2
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
package org.dolphinemu.dolphinemu;
|
package org.dolphinemu.dolphinemu;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -451,23 +453,19 @@ public final class NativeLibrary
|
||||||
Log.error("[NativeLibrary] Alert: " + text);
|
Log.error("[NativeLibrary] Alert: " + text);
|
||||||
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (emulationActivity == null)
|
if (isWarning && emulationActivity != null && emulationActivity.isIgnoringWarnings())
|
||||||
{
|
|
||||||
Log.warning("[NativeLibrary] EmulationActivity is null, can't do panic alert.");
|
|
||||||
}
|
|
||||||
else if (emulationActivity.isIgnoringWarnings() && isWarning)
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// AlertMessages while the core is booting will deadlock when WaitUntilDoneBooting is called.
|
// AlertMessages while the core is booting will deadlock if WaitUntilDoneBooting is called.
|
||||||
// Report the AlertMessage text as a toast instead.
|
// We also can't use AlertMessages unless we have a non-null activity reference.
|
||||||
if (IsBooting())
|
// As a fallback, we use toasts instead.
|
||||||
|
if (emulationActivity == null || IsBooting())
|
||||||
{
|
{
|
||||||
emulationActivity.runOnUiThread(
|
new Handler(Looper.getMainLooper()).post(
|
||||||
() -> Toast.makeText(emulationActivity.getApplicationContext(), text,
|
() -> Toast.makeText(DolphinApplication.getAppContext(), text, Toast.LENGTH_LONG)
|
||||||
Toast.LENGTH_LONG)
|
|
||||||
.show());
|
.show());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue