Fixed bug where new intents wouldn't open in the browser if it had been killed by the OS
This commit is contained in:
parent
7486ebe3c4
commit
486078a7d1
@ -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;
|
||||
|
@ -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 {
|
||||
@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 {
|
||||
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 {
|
||||
if (mTabList.size() == 0) {
|
||||
newTab(activity, null, false);
|
||||
}
|
||||
finishInitialization();
|
||||
subscriber.onComplete();
|
||||
}
|
||||
});
|
||||
|
@ -169,33 +169,38 @@ public class BrowserPresenter {
|
||||
Log.d(Constants.TAG, "deleted tab");
|
||||
}
|
||||
|
||||
public void onNewIntent(Intent intent) {
|
||||
final String url;
|
||||
if (intent != null) {
|
||||
url = intent.getDataString();
|
||||
} else {
|
||||
url = null;
|
||||
}
|
||||
int num = 0;
|
||||
if (intent != null && intent.getExtras() != null) {
|
||||
num = intent.getExtras().getInt(Constants.INTENT_ORIGIN);
|
||||
}
|
||||
public void onNewIntent(final Intent intent) {
|
||||
mTabsModel.doAfterInitialization(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String url;
|
||||
if (intent != null) {
|
||||
url = intent.getDataString();
|
||||
} else {
|
||||
url = null;
|
||||
}
|
||||
int num = 0;
|
||||
if (intent != null && intent.getExtras() != null) {
|
||||
num = intent.getExtras().getInt(Constants.INTENT_ORIGIN);
|
||||
}
|
||||
|
||||
if (num == 1) {
|
||||
loadUrlInCurrentView(url);
|
||||
} else if (url != null) {
|
||||
if (url.startsWith(Constants.FILE)) {
|
||||
mView.showBlockedLocalFileDialog(new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (num == 1) {
|
||||
loadUrlInCurrentView(url);
|
||||
} else if (url != null) {
|
||||
if (url.startsWith(Constants.FILE)) {
|
||||
mView.showBlockedLocalFileDialog(new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
newTab(url, true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
newTab(url, true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
newTab(url, true);
|
||||
mIsNewIntent = true;
|
||||
}
|
||||
}
|
||||
mIsNewIntent = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadUrlInCurrentView(final String url) {
|
||||
|
Loading…
Reference in New Issue
Block a user