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