Browse Source

Fixed bug where new intents wouldn't open in the browser if it had been killed by the OS

master
Anthony Restaino 9 years ago
parent
commit
486078a7d1
  1. 1
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 27
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  3. 7
      app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

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

@ -549,7 +549,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -549,7 +549,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private void initializePreferences() {
final LightningView currentView = mTabsManager.getCurrentTab();
final WebView currentWebView = mTabsManager.getCurrentWebView();
mFullScreen = mPreferences.getFullScreenEnabled();
boolean colorMode = mPreferences.getColorModeEnabled();
colorMode &= !mDarkTheme;

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

@ -64,6 +64,24 @@ public class TabsManager { @@ -64,6 +64,24 @@ public class TabsManager {
mTabNumberListener = listener;
}
private boolean mIsInitialized = false;
private List<Runnable> mPostInitializationWorkList = new ArrayList<>();
public void doAfterInitialization(@NonNull Runnable runnable) {
if (mIsInitialized) {
runnable.run();
} else {
mPostInitializationWorkList.add(runnable);
}
}
private void finishInitialization() {
mIsInitialized = true;
for (Runnable runnable : mPostInitializationWorkList) {
runnable.run();
}
}
/**
* Restores old tabs that were open before the browser
* was closed. Handles the intent used to open the browser.
@ -79,10 +97,12 @@ public class TabsManager { @@ -79,10 +97,12 @@ public class TabsManager {
@Override
public void onSubscribe(@NonNull final Subscriber<Void> subscriber) {
// Make sure we start with a clean tab list
shutdown();
// If incognito, only create one tab, do not handle intent
// in order to protect user privacy
if (incognito && mTabList.isEmpty()) {
if (incognito) {
newTab(activity, null, true);
subscriber.onComplete();
return;
@ -93,10 +113,12 @@ public class TabsManager { @@ -93,10 +113,12 @@ public class TabsManager {
dataString = intent.getDataString();
}
final String url = dataString;
mTabList.clear();
mCurrentTab = null;
if (mPreferenceManager.getRestoreLostTabsEnabled()) {
restoreLostTabs(url, activity, subscriber);
} else {
newTab(activity, null, false);
finishInitialization();
}
}
@ -138,6 +160,7 @@ public class TabsManager { @@ -138,6 +160,7 @@ public class TabsManager {
if (mTabList.size() == 0) {
newTab(activity, null, false);
}
finishInitialization();
subscriber.onComplete();
}
});

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

@ -169,7 +169,10 @@ public class BrowserPresenter { @@ -169,7 +169,10 @@ public class BrowserPresenter {
Log.d(Constants.TAG, "deleted tab");
}
public void onNewIntent(Intent intent) {
public void onNewIntent(final Intent intent) {
mTabsModel.doAfterInitialization(new Runnable() {
@Override
public void run() {
final String url;
if (intent != null) {
url = intent.getDataString();
@ -197,6 +200,8 @@ public class BrowserPresenter { @@ -197,6 +200,8 @@ public class BrowserPresenter {
mIsNewIntent = true;
}
}
});
}
public void loadUrlInCurrentView(final String url) {
final LightningView currentTab = mTabsModel.getCurrentTab();

Loading…
Cancel
Save