mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 886123 - Handle locale changes with BroadcastReceiver instead of getLastCustomNonConfigurationInstance(). r=sriram
This commit is contained in:
parent
76d5b48885
commit
943c6fc4a0
@ -1203,9 +1203,12 @@ abstract public class GeckoApp
|
||||
Tabs.getInstance().attachToActivity(this);
|
||||
Favicons.getInstance().attachToContext(this);
|
||||
|
||||
// Check to see if the activity is restarted after configuration change.
|
||||
if (getLastCustomNonConfigurationInstance() != null) {
|
||||
// Restart the application as a safe way to handle the configuration change.
|
||||
// When we detect a locale change, we need to restart Gecko, which
|
||||
// actually means restarting the entire application. This logic should
|
||||
// actually be handled elsewhere since GeckoApp may not be alive to
|
||||
// handle this event if "Don't keep activities" is enabled (filed as
|
||||
// bug 889082).
|
||||
if (((GeckoApplication)getApplication()).needsRestart()) {
|
||||
doRestart();
|
||||
System.exit(0);
|
||||
return;
|
||||
@ -2084,13 +2087,6 @@ abstract public class GeckoApp
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object onRetainCustomNonConfigurationInstance() {
|
||||
// Send a non-null value so that we can restart the application,
|
||||
// when activity restarts due to configuration change.
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
public String getContentProcessName() {
|
||||
return AppConstants.MOZ_CHILD_PROCESS_NAME;
|
||||
}
|
||||
|
@ -12,12 +12,17 @@ import org.mozilla.gecko.util.HardwareUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
public class GeckoApplication extends Application {
|
||||
|
||||
private boolean mInited;
|
||||
private boolean mInBackground;
|
||||
private boolean mPausedGecko;
|
||||
private boolean mNeedsRestart;
|
||||
|
||||
private LightweightTheme mLightweightTheme;
|
||||
|
||||
@ -38,6 +43,14 @@ public class GeckoApplication extends Application {
|
||||
GeckoNetworkManager.getInstance().init(getApplicationContext());
|
||||
MemoryMonitor.getInstance().init(getApplicationContext());
|
||||
|
||||
BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mNeedsRestart = true;
|
||||
}
|
||||
};
|
||||
registerReceiver(receiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
|
||||
|
||||
mInited = true;
|
||||
}
|
||||
|
||||
@ -77,6 +90,10 @@ public class GeckoApplication extends Application {
|
||||
mInBackground = false;
|
||||
}
|
||||
|
||||
protected boolean needsRestart() {
|
||||
return mNeedsRestart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
HardwareUtils.init(getApplicationContext());
|
||||
|
Loading…
Reference in New Issue
Block a user