Browse Source

Fixed some bugs with restoring/initializing tabs when new intents were received and browser was killed by background

master
Anthony Restaino 9 years ago
parent
commit
1685a13df3
  1. 8
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 12
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  3. 5
      app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

8
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -382,9 +382,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -382,9 +382,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
}
if (isPanicTrigger(getIntent())) {
setIntent(null);
panicClean();
} else {
mPresenter.setupTabs(getIntent(), isIncognito());
setIntent(null);
mProxyUtils.checkForProxy(BrowserActivity.this);
}
}
@ -1161,6 +1163,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1161,6 +1163,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mProxyUtils.onStart(this);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mTabsManager.shutdown();
}
@Override
protected void onResume() {
super.onResume();

12
app/src/main/java/acr/browser/lightning/activity/TabsManager.java

@ -112,11 +112,11 @@ public class TabsManager { @@ -112,11 +112,11 @@ public class TabsManager {
return;
}
String dataString = null;
String url = null;
if (intent != null) {
dataString = intent.getDataString();
url = intent.getDataString();
}
final String url = dataString;
Log.d(TAG, "URL from intent: " + url);
mCurrentTab = null;
if (mPreferenceManager.getRestoreLostTabsEnabled()) {
restoreLostTabs(url, activity, subscriber);
@ -130,8 +130,8 @@ public class TabsManager { @@ -130,8 +130,8 @@ public class TabsManager {
}
private void restoreLostTabs(final String url, final Activity activity,
final Subscriber subscriber) {
private void restoreLostTabs(@Nullable final String url, @NonNull final Activity activity,
@NonNull final Subscriber subscriber) {
restoreState().subscribeOn(Schedulers.worker())
.observeOn(Schedulers.main()).subscribe(new OnSubscribe<Bundle>() {
@Override
@ -212,6 +212,7 @@ public class TabsManager { @@ -212,6 +212,7 @@ public class TabsManager {
tab.onDestroy();
}
mTabList.clear();
mIsInitialized = false;
mCurrentTab = null;
}
@ -393,6 +394,7 @@ public class TabsManager { @@ -393,6 +394,7 @@ public class TabsManager {
}
}
}
FileUtils.deleteBundleInStorage(mApp, BUNDLE_STORAGE);
subscriber.onComplete();
}
});

5
app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

@ -52,12 +52,9 @@ public class BrowserPresenter { @@ -52,12 +52,9 @@ public class BrowserPresenter {
});
}
public void setupTabs(Intent intent, boolean isIncognito) {
public void setupTabs(@Nullable Intent intent, boolean isIncognito) {
mTabsModel.initializeTabs((Activity) mView, intent, isIncognito)
.subscribe(new OnSubscribe<Void>() {
@Override
public void onNext(Void item) {}
@Override
public void onComplete() {
// At this point we always have at least a tab in the tab manager

Loading…
Cancel
Save