Simplify and improve long press handling for links on the bookmark page and history page
This commit is contained in:
parent
19103e9b2c
commit
645b98cd50
@ -95,7 +95,9 @@ import android.widget.TextView;
|
|||||||
import android.widget.TextView.OnEditorActionListener;
|
import android.widget.TextView.OnEditorActionListener;
|
||||||
import android.widget.VideoView;
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -117,6 +119,7 @@ import acr.browser.lightning.R;
|
|||||||
import acr.browser.lightning.constant.BookmarkPage;
|
import acr.browser.lightning.constant.BookmarkPage;
|
||||||
import acr.browser.lightning.constant.Constants;
|
import acr.browser.lightning.constant.Constants;
|
||||||
import acr.browser.lightning.constant.HistoryPage;
|
import acr.browser.lightning.constant.HistoryPage;
|
||||||
|
import acr.browser.lightning.constant.StartPage;
|
||||||
import acr.browser.lightning.controller.BrowserController;
|
import acr.browser.lightning.controller.BrowserController;
|
||||||
import acr.browser.lightning.database.BookmarkManager;
|
import acr.browser.lightning.database.BookmarkManager;
|
||||||
import acr.browser.lightning.database.HistoryDatabase;
|
import acr.browser.lightning.database.HistoryDatabase;
|
||||||
@ -1093,7 +1096,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
|
|||||||
|
|
||||||
Collections.sort(mBookmarkList, new SortIgnoreCase());
|
Collections.sort(mBookmarkList, new SortIgnoreCase());
|
||||||
if (mCurrentView != null && mCurrentView.getUrl().startsWith(Constants.FILE)
|
if (mCurrentView != null && mCurrentView.getUrl().startsWith(Constants.FILE)
|
||||||
&& mCurrentView.getUrl().endsWith("bookmarks.html")) {
|
&& mCurrentView.getUrl().endsWith(BookmarkPage.FILENAME)) {
|
||||||
openBookmarkPage(mWebView);
|
openBookmarkPage(mWebView);
|
||||||
}
|
}
|
||||||
if (mCurrentView != null) {
|
if (mCurrentView != null) {
|
||||||
@ -2044,19 +2047,39 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void openBookmarkPage(WebView view) {
|
public void openBookmarkPage(WebView view) {
|
||||||
|
if (view == null)
|
||||||
|
return;
|
||||||
|
Bitmap folderIcon = ThemeUtils.getThemedBitmap(this, R.drawable.ic_folder, false);
|
||||||
|
FileOutputStream outputStream = null;
|
||||||
|
File image = new File(mActivity.getCacheDir(), "folder.png");
|
||||||
|
try {
|
||||||
|
outputStream = new FileOutputStream(image);
|
||||||
|
folderIcon.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
|
||||||
|
folderIcon.recycle();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
Utils.close(outputStream);
|
||||||
|
}
|
||||||
StringBuilder bookmarkBuilder = new StringBuilder();
|
StringBuilder bookmarkBuilder = new StringBuilder();
|
||||||
bookmarkBuilder.append(BookmarkPage.HEADING);
|
bookmarkBuilder.append(BookmarkPage.HEADING);
|
||||||
Iterator<HistoryItem> iter = mBookmarkList.iterator();
|
Iterator<HistoryItem> iter = mBookmarkList.iterator();
|
||||||
HistoryItem helper;
|
HistoryItem helper;
|
||||||
|
String folderPath = Constants.FILE + mActivity.getCacheDir() + "/folder.png";
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
helper = iter.next();
|
helper = iter.next();
|
||||||
bookmarkBuilder.append(BookmarkPage.PART1);
|
bookmarkBuilder.append(BookmarkPage.PART1);
|
||||||
bookmarkBuilder.append(helper.getUrl());
|
bookmarkBuilder.append(helper.getUrl());
|
||||||
bookmarkBuilder.append(BookmarkPage.PART2);
|
bookmarkBuilder.append(BookmarkPage.PART2);
|
||||||
bookmarkBuilder.append(helper.getUrl());
|
if (helper.getIsFolder()) {
|
||||||
bookmarkBuilder.append(BookmarkPage.PART3);
|
bookmarkBuilder.append(folderPath);
|
||||||
bookmarkBuilder.append(helper.getTitle());
|
} else {
|
||||||
|
bookmarkBuilder.append(BookmarkPage.PART3);
|
||||||
|
bookmarkBuilder.append(helper.getUrl());
|
||||||
|
}
|
||||||
bookmarkBuilder.append(BookmarkPage.PART4);
|
bookmarkBuilder.append(BookmarkPage.PART4);
|
||||||
|
bookmarkBuilder.append(helper.getTitle());
|
||||||
|
bookmarkBuilder.append(BookmarkPage.PART5);
|
||||||
}
|
}
|
||||||
bookmarkBuilder.append(BookmarkPage.END);
|
bookmarkBuilder.append(BookmarkPage.END);
|
||||||
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
|
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
|
||||||
@ -2462,185 +2485,189 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
|
|||||||
*/
|
*/
|
||||||
public void longClickPage(final String url) {
|
public void longClickPage(final String url) {
|
||||||
HitTestResult result = null;
|
HitTestResult result = null;
|
||||||
|
String currentUrl = null;
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
result = mWebView.getHitTestResult();
|
result = mWebView.getHitTestResult();
|
||||||
|
currentUrl = mWebView.getUrl();
|
||||||
}
|
}
|
||||||
if (url != null) {
|
if (currentUrl != null && currentUrl.startsWith(Constants.FILE)) {
|
||||||
if (result != null) {
|
if (currentUrl.endsWith(HistoryPage.FILENAME)) {
|
||||||
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|
if (url != null) {
|
||||||
|| result.getType() == HitTestResult.IMAGE_TYPE) {
|
longPressHistoryLink(url);
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
} else if (result != null && result.getExtra() != null) {
|
||||||
@Override
|
final String newUrl = result.getExtra();
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
longPressHistoryLink(newUrl);
|
||||||
switch (which) {
|
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
|
||||||
newTab(url, false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
|
||||||
mCurrentView.loadUrl(url);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL:
|
|
||||||
if (API > 8) {
|
|
||||||
Utils.downloadFile(mActivity, url,
|
|
||||||
mCurrentView.getUserAgent(), "attachment");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
|
||||||
builder.setTitle(url.replace(Constants.HTTP, ""))
|
|
||||||
.setMessage(getResources().getString(R.string.dialog_image))
|
|
||||||
.setPositiveButton(getResources().getString(R.string.action_new_tab),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNegativeButton(getResources().getString(R.string.action_open),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNeutralButton(getResources().getString(R.string.action_download),
|
|
||||||
dialogClickListener).show();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
switch (which) {
|
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
|
||||||
newTab(url, false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
|
||||||
mCurrentView.loadUrl(url);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL:
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText("label", url);
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
|
||||||
builder.setTitle(url)
|
|
||||||
.setMessage(getResources().getString(R.string.dialog_link))
|
|
||||||
.setPositiveButton(getResources().getString(R.string.action_new_tab),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNegativeButton(getResources().getString(R.string.action_open),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNeutralButton(getResources().getString(R.string.action_copy),
|
|
||||||
dialogClickListener).show();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else if (currentUrl.endsWith(BookmarkPage.FILENAME)) {
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
if (url != null) {
|
||||||
@Override
|
longPressBookmarkLink(url);
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
} else if (result != null && result.getExtra() != null) {
|
||||||
switch (which) {
|
final String newUrl = result.getExtra();
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
longPressBookmarkLink(newUrl);
|
||||||
newTab(url, false);
|
}
|
||||||
break;
|
}
|
||||||
|
} else {
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
if (url != null) {
|
||||||
mCurrentView.loadUrl(url);
|
if (result != null) {
|
||||||
break;
|
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE || result.getType() == HitTestResult.IMAGE_TYPE) {
|
||||||
|
longPressImage(url);
|
||||||
case DialogInterface.BUTTON_NEUTRAL:
|
} else {
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
longPressLink(url);
|
||||||
ClipData clip = ClipData.newPlainText("label", url);
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
|
||||||
builder.setTitle(url)
|
|
||||||
.setMessage(getResources().getString(R.string.dialog_link))
|
|
||||||
.setPositiveButton(getResources().getString(R.string.action_new_tab),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNegativeButton(getResources().getString(R.string.action_open),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNeutralButton(getResources().getString(R.string.action_copy),
|
|
||||||
dialogClickListener).show();
|
|
||||||
}
|
|
||||||
} else if (result != null) {
|
|
||||||
if (result.getExtra() != null) {
|
|
||||||
final String newUrl = result.getExtra();
|
|
||||||
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|
|
||||||
|| result.getType() == HitTestResult.IMAGE_TYPE) {
|
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
switch (which) {
|
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
|
||||||
newTab(newUrl, false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
|
||||||
mCurrentView.loadUrl(newUrl);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL:
|
|
||||||
if (API > 8) {
|
|
||||||
Utils.downloadFile(mActivity, newUrl,
|
|
||||||
mCurrentView.getUserAgent(), "attachment");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
|
||||||
builder.setTitle(newUrl.replace(Constants.HTTP, ""))
|
|
||||||
.setMessage(getResources().getString(R.string.dialog_image))
|
|
||||||
.setPositiveButton(getResources().getString(R.string.action_new_tab),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNegativeButton(getResources().getString(R.string.action_open),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNeutralButton(getResources().getString(R.string.action_download),
|
|
||||||
dialogClickListener).show();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
longPressLink(url);
|
||||||
@Override
|
}
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
} else if (result != null && result.getExtra() != null) {
|
||||||
switch (which) {
|
final String newUrl = result.getExtra();
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE || result.getType() == HitTestResult.IMAGE_TYPE) {
|
||||||
newTab(newUrl, false);
|
longPressImage(newUrl);
|
||||||
break;
|
} else {
|
||||||
|
longPressLink(newUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
private void longPressBookmarkLink(final String url) {
|
||||||
mCurrentView.loadUrl(newUrl);
|
final int position = BookmarkManager.getIndexOfBookmark(mBookmarkList, url);
|
||||||
break;
|
if (position == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
newTab(mBookmarkList.get(position).getUrl(), false);
|
||||||
|
mDrawerLayout.closeDrawers();
|
||||||
|
break;
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL:
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
if (mBookmarkManager.deleteBookmark(mBookmarkList.get(position))) {
|
||||||
ClipData clip = ClipData.newPlainText("label", newUrl);
|
mBookmarkList.remove(position);
|
||||||
clipboard.setPrimaryClip(clip);
|
notifyBookmarkDataSetChanged();
|
||||||
|
mSearchAdapter.refreshBookmarks();
|
||||||
break;
|
openBookmarks();
|
||||||
|
if (mCurrentView != null) {
|
||||||
|
updateBookmarkIndicator(mCurrentView.getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
break;
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
builder.setTitle(newUrl)
|
editBookmark(position);
|
||||||
.setMessage(getResources().getString(R.string.dialog_link))
|
break;
|
||||||
.setPositiveButton(getResources().getString(R.string.action_new_tab),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNegativeButton(getResources().getString(R.string.action_open),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNeutralButton(getResources().getString(R.string.action_copy),
|
|
||||||
dialogClickListener).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
|
builder.setTitle(R.string.action_bookmarks);
|
||||||
|
builder.setMessage(R.string.dialog_bookmark)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setPositiveButton(R.string.action_new_tab, dialogClickListener)
|
||||||
|
.setNegativeButton(R.string.action_delete, dialogClickListener)
|
||||||
|
.setNeutralButton(R.string.action_edit, dialogClickListener)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void longPressHistoryLink(final String url) {
|
||||||
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
newTab(url, false);
|
||||||
|
mDrawerLayout.closeDrawers();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
|
mHistoryDatabase.deleteHistoryItem(url);
|
||||||
|
openHistory();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
|
if (mCurrentView != null) {
|
||||||
|
mCurrentView.loadUrl(url);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
|
builder.setTitle(R.string.action_history);
|
||||||
|
builder.setMessage(R.string.dialog_history_long_press)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setPositiveButton(R.string.action_new_tab, dialogClickListener)
|
||||||
|
.setNegativeButton(R.string.action_delete, dialogClickListener)
|
||||||
|
.setNeutralButton(R.string.action_open, dialogClickListener)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void longPressImage(final String url) {
|
||||||
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
newTab(url, false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
|
mCurrentView.loadUrl(url);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
|
if (API > 8) {
|
||||||
|
Utils.downloadFile(mActivity, url,
|
||||||
|
mCurrentView.getUserAgent(), "attachment");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
|
builder.setTitle(url.replace(Constants.HTTP, ""))
|
||||||
|
.setCancelable(true)
|
||||||
|
.setMessage(R.string.dialog_image)
|
||||||
|
.setPositiveButton(R.string.action_new_tab, dialogClickListener)
|
||||||
|
.setNegativeButton(R.string.action_open, dialogClickListener)
|
||||||
|
.setNeutralButton(R.string.action_download, dialogClickListener)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void longPressLink(final String url) {
|
||||||
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
newTab(url, false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
|
mCurrentView.loadUrl(url);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
|
ClipData clip = ClipData.newPlainText("label", url);
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
||||||
|
builder.setTitle(url)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setMessage(R.string.dialog_link)
|
||||||
|
.setPositiveButton(R.string.action_new_tab, dialogClickListener)
|
||||||
|
.setNegativeButton(R.string.action_open, dialogClickListener)
|
||||||
|
.setNeutralButton(R.string.action_copy, dialogClickListener)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,11 +16,13 @@ public class BookmarkPage {
|
|||||||
|
|
||||||
public static final String PART1 = "<div class=\"box\"><a href=\"";
|
public static final String PART1 = "<div class=\"box\"><a href=\"";
|
||||||
|
|
||||||
public static final String PART2 = "\" ></a><div class=\"stuff\" ><img height=\"20\" width=\"20\" src='http://www.google.com/s2/favicons?domain=";
|
public static final String PART2 = "\" ></a><div class=\"stuff\" ><img height=\"20\" width=\"20\" src='";
|
||||||
|
|
||||||
public static final String PART3 = "' /><p class=\"ellipses\">";
|
public static final String PART3 = "http://www.google.com/s2/favicons?domain=";
|
||||||
|
|
||||||
public static final String PART4 = "</p></div></div>";
|
public static final String PART4 = "' /><p class=\"ellipses\">";
|
||||||
|
|
||||||
|
public static final String PART5 = "</p></div></div>";
|
||||||
|
|
||||||
public static final String END = "</div></body></html>";
|
public static final String END = "</div></body></html>";
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import acr.browser.lightning.utils.Utils;
|
|||||||
|
|
||||||
public class HistoryPage {
|
public class HistoryPage {
|
||||||
|
|
||||||
private static final String FILENAME = "history.html";
|
public static final String FILENAME = "history.html";
|
||||||
|
|
||||||
private static final String HEADING = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"><title>"
|
private static final String HEADING = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"><title>"
|
||||||
+ BrowserApp.getAppContext().getString(R.string.action_history)
|
+ BrowserApp.getAppContext().getString(R.string.action_history)
|
||||||
|
@ -8,6 +8,8 @@ import acr.browser.lightning.R;
|
|||||||
|
|
||||||
public class StartPage {
|
public class StartPage {
|
||||||
|
|
||||||
|
public static final String FILENAME = "homepage.html";
|
||||||
|
|
||||||
public static final String HEAD = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">"
|
public static final String HEAD = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">"
|
||||||
+ "<head>"
|
+ "<head>"
|
||||||
+ "<meta content=\"en-us\" http-equiv=\"Content-Language\" />"
|
+ "<meta content=\"en-us\" http-equiv=\"Content-Language\" />"
|
||||||
|
@ -506,6 +506,22 @@ public class BookmarkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find the index of a bookmark in a list using only its URL
|
||||||
|
*
|
||||||
|
* @param list the list to search
|
||||||
|
* @param url the url to compare
|
||||||
|
* @return returns the index of the bookmark or -1 if none was found
|
||||||
|
*/
|
||||||
|
public static int getIndexOfBookmark(final List<HistoryItem> list, final String url) {
|
||||||
|
for (int n = 0; n < list.size(); n++) {
|
||||||
|
if (list.get(n).getUrl().equals(url)) {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
private class SortIgnoreCase implements Comparator<HistoryItem> {
|
private class SortIgnoreCase implements Comparator<HistoryItem> {
|
||||||
|
|
||||||
public int compare(HistoryItem o1, HistoryItem o2) {
|
public int compare(HistoryItem o1, HistoryItem o2) {
|
||||||
|
@ -238,7 +238,7 @@ public class LightningView {
|
|||||||
homepageBuilder.append(searchUrl);
|
homepageBuilder.append(searchUrl);
|
||||||
homepageBuilder.append(StartPage.END);
|
homepageBuilder.append(StartPage.END);
|
||||||
|
|
||||||
File homepage = new File(mActivity.getFilesDir(), "homepage.html");
|
File homepage = new File(mActivity.getFilesDir(), StartPage.FILENAME);
|
||||||
FileWriter hWriter = null;
|
FileWriter hWriter = null;
|
||||||
try {
|
try {
|
||||||
hWriter = new FileWriter(homepage, false);
|
hWriter = new FileWriter(homepage, false);
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
<string name="action_open">Open</string>
|
<string name="action_open">Open</string>
|
||||||
<string name="dialog_link">What would you like to do with this link?</string>
|
<string name="dialog_link">What would you like to do with this link?</string>
|
||||||
<string name="dialog_title_share">Share this page</string>
|
<string name="dialog_title_share">Share this page</string>
|
||||||
|
<string name="dialog_history_long_press">What would you like to do with this history item?</string>
|
||||||
<string name="dialog_bookmark">What would you like to do with this bookmark?</string>
|
<string name="dialog_bookmark">What would you like to do with this bookmark?</string>
|
||||||
<string name="action_delete">Delete</string>
|
<string name="action_delete">Delete</string>
|
||||||
<string name="action_blank">Blank Page</string>
|
<string name="action_blank">Blank Page</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user