|
|
|
@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
|
|
|
|
|
package acr.browser.lightning.browser; |
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.app.Application; |
|
|
|
|
import android.content.DialogInterface; |
|
|
|
|
import android.content.Intent; |
|
|
|
|
import android.support.annotation.NonNull; |
|
|
|
@ -17,7 +18,9 @@ import acr.browser.lightning.BuildConfig;
@@ -17,7 +18,9 @@ import acr.browser.lightning.BuildConfig;
|
|
|
|
|
import acr.browser.lightning.R; |
|
|
|
|
import acr.browser.lightning.activity.TabsManager; |
|
|
|
|
import acr.browser.lightning.app.BrowserApp; |
|
|
|
|
import acr.browser.lightning.constant.BookmarkPage; |
|
|
|
|
import acr.browser.lightning.constant.Constants; |
|
|
|
|
import acr.browser.lightning.constant.StartPage; |
|
|
|
|
import acr.browser.lightning.controller.UIController; |
|
|
|
|
import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
|
|
|
|
|
@ -34,6 +37,7 @@ public class BrowserPresenter {
@@ -34,6 +37,7 @@ public class BrowserPresenter {
|
|
|
|
|
private static final String TAG = "BrowserPresenter"; |
|
|
|
|
|
|
|
|
|
@NonNull private final TabsManager mTabsModel; |
|
|
|
|
@Inject Application mApplication; |
|
|
|
|
@Inject PreferenceManager mPreferences; |
|
|
|
|
|
|
|
|
|
@NonNull private final BrowserView mView; |
|
|
|
@ -144,6 +148,19 @@ public class BrowserPresenter {
@@ -144,6 +148,19 @@ public class BrowserPresenter {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
|
private String mapHomepageToCurrentUrl() { |
|
|
|
|
String homepage = mPreferences.getHomepage(); |
|
|
|
|
switch (homepage) { |
|
|
|
|
case Constants.SCHEME_HOMEPAGE: |
|
|
|
|
return Constants.FILE + StartPage.getStartPageFile(mApplication); |
|
|
|
|
case Constants.SCHEME_BOOKMARKS: |
|
|
|
|
return Constants.FILE + BookmarkPage.getBookmarkPage(mApplication, null); |
|
|
|
|
default: |
|
|
|
|
return homepage; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Deletes the tab at the specified position. |
|
|
|
|
* |
|
|
|
@ -166,8 +183,8 @@ public class BrowserPresenter {
@@ -166,8 +183,8 @@ public class BrowserPresenter {
|
|
|
|
|
boolean shouldClose = mShouldClose && isShown && tabToDelete.isNewTab(); |
|
|
|
|
final LightningView currentTab = mTabsModel.getCurrentTab(); |
|
|
|
|
if (mTabsModel.size() == 1 && currentTab != null && |
|
|
|
|
(UrlUtils.isStartPageUrl(currentTab.getUrl()) || |
|
|
|
|
currentTab.getUrl().equals(mPreferences.getHomepage()))) { |
|
|
|
|
URLUtil.isFileUrl(currentTab.getUrl()) && |
|
|
|
|
currentTab.getUrl().equals(mapHomepageToCurrentUrl())) { |
|
|
|
|
mView.closeActivity(); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|