Fixed bug where the homepage file url was showing
This commit is contained in:
parent
441b189fad
commit
80ac1928c1
@ -2032,7 +2032,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
public void bookmarkChanged(final BookmarkEvents.BookmarkChanged event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE)
|
||||
&& currentTab.getUrl().endsWith(Constants.BOOKMARKS_FILENAME)) {
|
||||
&& currentTab.getUrl().endsWith(BookmarkPage.FILENAME)) {
|
||||
currentTab.loadBookmarkpage();
|
||||
}
|
||||
if (currentTab != null) {
|
||||
@ -2049,7 +2049,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
public void bookmarkDeleted(final BookmarkEvents.Deleted event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE)
|
||||
&& currentTab.getUrl().endsWith(Constants.BOOKMARKS_FILENAME)) {
|
||||
&& currentTab.getUrl().endsWith(BookmarkPage.FILENAME)) {
|
||||
currentTab.loadBookmarkpage();
|
||||
}
|
||||
if (currentTab != null) {
|
||||
|
@ -20,6 +20,11 @@ import acr.browser.lightning.utils.Utils;
|
||||
|
||||
public final class BookmarkPage {
|
||||
|
||||
/**
|
||||
* The bookmark page standard suffix
|
||||
*/
|
||||
public static final String FILENAME = "bookmarks.html";
|
||||
|
||||
private static final String HEADING = "<!DOCTYPE html><html xmlns=http://www.w3.org/1999/xhtml>\n" +
|
||||
"<head>\n" +
|
||||
"<meta content=en-us http-equiv=Content-Language />\n" +
|
||||
@ -66,9 +71,9 @@ public final class BookmarkPage {
|
||||
final List<HistoryItem> list = manager.getBookmarksFromFolder(folder, true);
|
||||
final File bookmarkWebPage;
|
||||
if (folder == null || folder.isEmpty()) {
|
||||
bookmarkWebPage = new File(FILES_DIR, Constants.BOOKMARKS_FILENAME);
|
||||
bookmarkWebPage = new File(FILES_DIR, FILENAME);
|
||||
} else {
|
||||
bookmarkWebPage = new File(FILES_DIR, folder + '-' + Constants.BOOKMARKS_FILENAME);
|
||||
bookmarkWebPage = new File(FILES_DIR, folder + '-' + FILENAME);
|
||||
}
|
||||
final StringBuilder bookmarkBuilder = new StringBuilder(BookmarkPage.HEADING);
|
||||
|
||||
@ -77,7 +82,7 @@ public final class BookmarkPage {
|
||||
final HistoryItem item = list.get(n);
|
||||
bookmarkBuilder.append(BookmarkPage.PART1);
|
||||
if (item.isFolder()) {
|
||||
final File folderPage = new File(FILES_DIR, item.getTitle() + '-' + Constants.BOOKMARKS_FILENAME);
|
||||
final File folderPage = new File(FILES_DIR, item.getTitle() + '-' + FILENAME);
|
||||
bookmarkBuilder.append(Constants.FILE).append(folderPage);
|
||||
bookmarkBuilder.append(BookmarkPage.PART2);
|
||||
bookmarkBuilder.append(folderIconPath);
|
||||
|
@ -43,11 +43,6 @@ public final class Constants {
|
||||
public static final int PROXY_I2P = 2;
|
||||
public static final int PROXY_MANUAL = 3;
|
||||
|
||||
/**
|
||||
* The bookmark page standard suffix
|
||||
*/
|
||||
public static final String BOOKMARKS_FILENAME = "bookmarks.html";
|
||||
|
||||
public static final String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
public static final String[] TEXT_ENCODINGS = {"ISO-8859-1", "UTF-8", "GBK", "Big5", "ISO-2022-JP", "SHIFT_JS", "EUC-JP", "EUC-KR"};
|
||||
|
@ -16,7 +16,7 @@ import acr.browser.lightning.utils.Utils;
|
||||
|
||||
public class StartPage {
|
||||
|
||||
private static final String FILENAME = "homepage.html";
|
||||
public static final String FILENAME = "homepage.html";
|
||||
|
||||
private static final String HEAD = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">"
|
||||
+ "<head>"
|
||||
|
@ -24,6 +24,7 @@ import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.app.BrowserApp;
|
||||
import acr.browser.lightning.bus.BookmarkEvents;
|
||||
import acr.browser.lightning.bus.BrowserEvents;
|
||||
import acr.browser.lightning.constant.BookmarkPage;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.constant.HistoryPage;
|
||||
import acr.browser.lightning.database.BookmarkManager;
|
||||
@ -60,11 +61,11 @@ public class LightningDialogBuilder {
|
||||
*/
|
||||
public void showLongPressedDialogForBookmarkUrl(final Context context, final String url) {
|
||||
final HistoryItem item;
|
||||
if (url.startsWith(Constants.FILE) && url.endsWith(Constants.BOOKMARKS_FILENAME)) {
|
||||
if (url.startsWith(Constants.FILE) && url.endsWith(BookmarkPage.FILENAME)) {
|
||||
// TODO hacky, make a better bookmark mechanism in the future
|
||||
final Uri uri = Uri.parse(url);
|
||||
final String filename = uri.getLastPathSegment();
|
||||
final String folderTitle = filename.substring(0, filename.length() - Constants.BOOKMARKS_FILENAME.length() - 1);
|
||||
final String folderTitle = filename.substring(0, filename.length() - BookmarkPage.FILENAME.length() - 1);
|
||||
item = new HistoryItem();
|
||||
item.setIsFolder(true);
|
||||
item.setTitle(folderTitle);
|
||||
|
@ -21,8 +21,10 @@ import android.webkit.URLUtil;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import acr.browser.lightning.constant.BookmarkPage;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.constant.HistoryPage;
|
||||
import acr.browser.lightning.constant.StartPage;
|
||||
|
||||
/**
|
||||
* Utility methods for Url manipulation
|
||||
@ -153,7 +155,9 @@ public class UrlUtils {
|
||||
* Returns whether the given url is the bookmarks/history page or a normal website
|
||||
*/
|
||||
public static boolean isSpecialUrl(String url) {
|
||||
return url != null && url.startsWith(Constants.FILE)
|
||||
&& (url.endsWith(Constants.BOOKMARKS_FILENAME) || url.endsWith(HistoryPage.FILENAME));
|
||||
return url != null && url.startsWith(Constants.FILE) &&
|
||||
(url.endsWith(BookmarkPage.FILENAME) ||
|
||||
url.endsWith(HistoryPage.FILENAME) ||
|
||||
url.endsWith(StartPage.FILENAME));
|
||||
}
|
||||
}
|
@ -43,6 +43,7 @@ import javax.inject.Inject;
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.app.BrowserApp;
|
||||
import acr.browser.lightning.bus.BrowserEvents;
|
||||
import acr.browser.lightning.constant.BookmarkPage;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.constant.HistoryPage;
|
||||
import acr.browser.lightning.constant.StartPage;
|
||||
@ -167,7 +168,7 @@ public class LightningView {
|
||||
} finally {
|
||||
Utils.close(outputStream);
|
||||
}
|
||||
File bookmarkWebPage = new File(mActivity.getFilesDir(), Constants.BOOKMARKS_FILENAME);
|
||||
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
|
||||
|
||||
BrowserApp.getAppComponent().getBookmarkPage().buildBookmarkPage(null);
|
||||
mWebView.loadUrl(Constants.FILE + bookmarkWebPage);
|
||||
@ -624,7 +625,7 @@ public class LightningView {
|
||||
final String newUrl = result.getExtra();
|
||||
mBookmarksDialogBuilder.showLongPressedHistoryLinkDialog(mActivity, newUrl);
|
||||
}
|
||||
} else if (currentUrl.endsWith(Constants.BOOKMARKS_FILENAME)) {
|
||||
} else if (currentUrl.endsWith(BookmarkPage.FILENAME)) {
|
||||
if (url != null) {
|
||||
mBookmarksDialogBuilder.showLongPressedDialogForBookmarkUrl(mActivity, url);
|
||||
} else if (result != null && result.getExtra() != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user