зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1305439 - Store the last selected tab in GeckoApp in onPause and switch back to it in onResume. r=sebastian
This commit is contained in:
Родитель
430e61c30f
Коммит
6415e8f510
|
@ -160,6 +160,7 @@ public abstract class GeckoApp
|
|||
|
||||
public static final String SAVED_STATE_IN_BACKGROUND = "inBackground";
|
||||
public static final String SAVED_STATE_PRIVATE_SESSION = "privateSession";
|
||||
public static final String SAVED_STATE_LAST_TAB = "lastTab";
|
||||
|
||||
// Delay before running one-time "cleanup" tasks that may be needed
|
||||
// after a version upgrade.
|
||||
|
@ -202,6 +203,8 @@ public abstract class GeckoApp
|
|||
|
||||
private EventDispatcher eventDispatcher;
|
||||
|
||||
private Tab lastSelectedTab = null;
|
||||
|
||||
private static final class LastSessionParser extends SessionParser {
|
||||
private JSONArray tabs;
|
||||
private JSONObject windowObject;
|
||||
|
@ -583,6 +586,15 @@ public abstract class GeckoApp
|
|||
|
||||
outState.putBoolean(SAVED_STATE_IN_BACKGROUND, isApplicationInBackground());
|
||||
outState.putString(SAVED_STATE_PRIVATE_SESSION, mPrivateBrowsingSession);
|
||||
outState.putInt(SAVED_STATE_LAST_TAB, lastSelectedTab.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(final Bundle state) {
|
||||
super.onRestoreInstanceState(state);
|
||||
|
||||
final int tabId = state.getInt(SAVED_STATE_LAST_TAB);
|
||||
Tabs.getInstance().selectTab(tabId);
|
||||
}
|
||||
|
||||
public void addTab() { }
|
||||
|
@ -2080,6 +2092,10 @@ public abstract class GeckoApp
|
|||
|
||||
GeckoAppShell.setGeckoInterface(this);
|
||||
|
||||
if (lastSelectedTab != null) {
|
||||
Tabs.getInstance().selectTab(lastSelectedTab.getId());
|
||||
}
|
||||
|
||||
int newOrientation = getResources().getConfiguration().orientation;
|
||||
if (GeckoScreenOrientation.getInstance().update(newOrientation)) {
|
||||
refreshChrome();
|
||||
|
@ -2154,6 +2170,8 @@ public abstract class GeckoApp
|
|||
return;
|
||||
}
|
||||
|
||||
lastSelectedTab = Tabs.getInstance().getSelectedTab();
|
||||
|
||||
final HealthRecorder rec = mHealthRecorder;
|
||||
final Context context = this;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче