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);
|
Tabs.getInstance().attachToActivity(this);
|
||||||
Favicons.getInstance().attachToContext(this);
|
Favicons.getInstance().attachToContext(this);
|
||||||
|
|
||||||
// Check to see if the activity is restarted after configuration change.
|
// When we detect a locale change, we need to restart Gecko, which
|
||||||
if (getLastCustomNonConfigurationInstance() != null) {
|
// actually means restarting the entire application. This logic should
|
||||||
// Restart the application as a safe way to handle the configuration change.
|
// 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();
|
doRestart();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
return;
|
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() {
|
public String getContentProcessName() {
|
||||||
return AppConstants.MOZ_CHILD_PROCESS_NAME;
|
return AppConstants.MOZ_CHILD_PROCESS_NAME;
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,17 @@ import org.mozilla.gecko.util.HardwareUtils;
|
|||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.app.Application;
|
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 {
|
public class GeckoApplication extends Application {
|
||||||
|
|
||||||
private boolean mInited;
|
private boolean mInited;
|
||||||
private boolean mInBackground;
|
private boolean mInBackground;
|
||||||
private boolean mPausedGecko;
|
private boolean mPausedGecko;
|
||||||
|
private boolean mNeedsRestart;
|
||||||
|
|
||||||
private LightweightTheme mLightweightTheme;
|
private LightweightTheme mLightweightTheme;
|
||||||
|
|
||||||
@ -38,6 +43,14 @@ public class GeckoApplication extends Application {
|
|||||||
GeckoNetworkManager.getInstance().init(getApplicationContext());
|
GeckoNetworkManager.getInstance().init(getApplicationContext());
|
||||||
MemoryMonitor.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;
|
mInited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +90,10 @@ public class GeckoApplication extends Application {
|
|||||||
mInBackground = false;
|
mInBackground = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean needsRestart() {
|
||||||
|
return mNeedsRestart;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
HardwareUtils.init(getApplicationContext());
|
HardwareUtils.init(getApplicationContext());
|
||||||
|
Loading…
Reference in New Issue
Block a user