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

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

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

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

@ -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) mTabsModel.initializeTabs((Activity) mView, intent, isIncognito)
.subscribe(new OnSubscribe<Void>() { .subscribe(new OnSubscribe<Void>() {
@Override
public void onNext(Void item) {}
@Override @Override
public void onComplete() { public void onComplete() {
// At this point we always have at least a tab in the tab manager // At this point we always have at least a tab in the tab manager

Loading…
Cancel
Save