Merge "Do not allow our resend/dontresend messages to be sent twice."
diff --git a/src/com/android/browser/Bookmarks.java b/src/com/android/browser/Bookmarks.java
index 8d98f89..2cbd851 100644
--- a/src/com/android/browser/Bookmarks.java
+++ b/src/com/android/browser/Bookmarks.java
@@ -35,12 +35,6 @@
* This class is purely to have a common place for adding/deleting bookmarks.
*/
/* package */ class Bookmarks {
- private static final String WHERE_CLAUSE
- = "url = ? OR url = ? OR url = ? OR url = ?";
- private static final String WHERE_CLAUSE_SECURE = "url = ? OR url = ?";
-
- private static String[] SELECTION_ARGS;
-
// We only want the user to be able to bookmark content that
// the browser can handle directly.
private static final String acceptableBookmarkSchemes[] = {
@@ -71,38 +65,8 @@
Bitmap thumbnail, boolean retainIcon) {
// Want to append to the beginning of the list
long creationTime = new Date().getTime();
- // First we check to see if the user has already visited this
- // site. They may have bookmarked it in a different way from
- // how it's stored in the database, so allow different combos
- // to map to the same url.
- boolean secure = false;
- String compareString = url;
- if (compareString.startsWith("http://")) {
- compareString = compareString.substring(7);
- } else if (compareString.startsWith("https://")) {
- compareString = compareString.substring(8);
- secure = true;
- }
- if (compareString.startsWith("www.")) {
- compareString = compareString.substring(4);
- }
- if (secure) {
- SELECTION_ARGS = new String[2];
- SELECTION_ARGS[0] = "https://" + compareString;
- SELECTION_ARGS[1] = "https://www." + compareString;
- } else {
- SELECTION_ARGS = new String[4];
- SELECTION_ARGS[0] = compareString;
- SELECTION_ARGS[1] = "www." + compareString;
- SELECTION_ARGS[2] = "http://" + compareString;
- SELECTION_ARGS[3] = "http://" + SELECTION_ARGS[1];
- }
- Cursor cursor = cr.query(Browser.BOOKMARKS_URI,
- Browser.HISTORY_PROJECTION,
- secure ? WHERE_CLAUSE_SECURE : WHERE_CLAUSE,
- SELECTION_ARGS,
- null);
ContentValues map = new ContentValues();
+ Cursor cursor = Browser.getVisitedLike(cr, url);
if (cursor.moveToFirst() && cursor.getInt(
Browser.HISTORY_PROJECTION_BOOKMARK_INDEX) == 0) {
// This means we have been to this site but not bookmarked
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index f860b1f..df80e99 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -722,11 +722,11 @@
url = intent.getStringExtra(SearchManager.QUERY);
if (url != null) {
mLastEnteredUrl = url;
- Browser.updateVisitedHistory(mResolver, url, false);
// In general, we shouldn't modify URL from Intent.
// But currently, we get the user-typed URL from search box as well.
url = fixUrl(url);
url = smartUrlFilter(url);
+ Browser.updateVisitedHistory(mResolver, url, false);
String searchSource = "&source=android-" + GOOGLE_SEARCH_SOURCE_SUGGEST + "&";
if (url.contains(searchSource)) {
String source = null;
@@ -1543,6 +1543,7 @@
}
mFindDialog.setWebView(getTopWindow());
mFindDialog.show();
+ getTopWindow().setFindIsUp(true);
mMenuState = EMPTY_MENU;
break;
@@ -3409,14 +3410,14 @@
}
// issued on:
- String issuedOn = reformatCertificateDate(
- certificate.getValidNotBefore());
+ String issuedOn = formatCertificateDate(
+ certificate.getValidNotBeforeDate());
((TextView) certificateView.findViewById(R.id.issued_on))
.setText(issuedOn);
// expires on:
- String expiresOn = reformatCertificateDate(
- certificate.getValidNotAfter());
+ String expiresOn = formatCertificateDate(
+ certificate.getValidNotAfterDate());
((TextView) certificateView.findViewById(R.id.expires_on))
.setText(expiresOn);
@@ -3424,31 +3425,19 @@
}
/**
- * Re-formats the certificate date (Date.toString()) string to
- * a properly localized date string.
+ * Formats the certificate date to a properly localized date string.
* @return Properly localized version of the certificate date string and
- * the original certificate date string if fails to localize.
- * If the original string is null, returns an empty string "".
+ * the "" if it fails to localize.
*/
- private String reformatCertificateDate(String certificateDate) {
- String reformattedDate = null;
-
- if (certificateDate != null) {
- Date date = null;
- try {
- date = java.text.DateFormat.getInstance().parse(certificateDate);
- } catch (ParseException e) {
- date = null;
- }
-
- if (date != null) {
- reformattedDate =
- DateFormat.getDateFormat(this).format(date);
- }
+ private String formatCertificateDate(Date certificateDate) {
+ if (certificateDate == null) {
+ return "";
}
-
- return reformattedDate != null ? reformattedDate :
- (certificateDate != null ? certificateDate : "");
+ String formattedDate = DateFormat.getDateFormat(this).format(certificateDate);
+ if (formattedDate == null) {
+ return "";
+ }
+ return formattedDate;
}
/**
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java
index 47c9bf9c..7ba135e 100644
--- a/src/com/android/browser/BrowserProvider.java
+++ b/src/com/android/browser/BrowserProvider.java
@@ -86,10 +86,10 @@
private static final int SUGGEST_COLUMN_INTENT_DATA_ID = 2;
private static final int SUGGEST_COLUMN_TEXT_1_ID = 3;
private static final int SUGGEST_COLUMN_TEXT_2_ID = 4;
- private static final int SUGGEST_COLUMN_ICON_1_ID = 5;
- private static final int SUGGEST_COLUMN_ICON_2_ID = 6;
- private static final int SUGGEST_COLUMN_QUERY_ID = 7;
- private static final int SUGGEST_COLUMN_FORMAT = 8;
+ private static final int SUGGEST_COLUMN_TEXT_2_URL_ID = 5;
+ private static final int SUGGEST_COLUMN_ICON_1_ID = 6;
+ private static final int SUGGEST_COLUMN_ICON_2_ID = 7;
+ private static final int SUGGEST_COLUMN_QUERY_ID = 8;
private static final int SUGGEST_COLUMN_INTENT_EXTRA_DATA = 9;
// shared suggestion columns
@@ -99,10 +99,10 @@
SearchManager.SUGGEST_COLUMN_INTENT_DATA,
SearchManager.SUGGEST_COLUMN_TEXT_1,
SearchManager.SUGGEST_COLUMN_TEXT_2,
+ SearchManager.SUGGEST_COLUMN_TEXT_2_URL,
SearchManager.SUGGEST_COLUMN_ICON_1,
SearchManager.SUGGEST_COLUMN_ICON_2,
SearchManager.SUGGEST_COLUMN_QUERY,
- SearchManager.SUGGEST_COLUMN_FORMAT,
SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA};
private static final int MAX_SUGGESTION_SHORT_ENTRIES = 3;
@@ -171,11 +171,6 @@
private SearchManager mSearchManager;
- // The ID of the ColorStateList to be applied to urls of website suggestions, as derived from
- // the current theme. This is not set until/unless beautifyUrl is called, at which point
- // this variable caches the color value.
- private static String mSearchUrlColorId;
-
public BrowserProvider() {
}
@@ -468,6 +463,7 @@
private String mString;
private int mSuggestText1Id;
private int mSuggestText2Id;
+ private int mSuggestText2UrlId;
private int mSuggestQueryId;
private int mSuggestIntentExtraDataId;
@@ -488,6 +484,7 @@
if (mSuggestCursor == null) {
mSuggestText1Id = -1;
mSuggestText2Id = -1;
+ mSuggestText2UrlId = -1;
mSuggestQueryId = -1;
mSuggestIntentExtraDataId = -1;
} else {
@@ -495,6 +492,8 @@
SearchManager.SUGGEST_COLUMN_TEXT_1);
mSuggestText2Id = mSuggestCursor.getColumnIndex(
SearchManager.SUGGEST_COLUMN_TEXT_2);
+ mSuggestText2UrlId = mSuggestCursor.getColumnIndex(
+ SearchManager.SUGGEST_COLUMN_TEXT_2_URL);
mSuggestQueryId = mSuggestCursor.getColumnIndex(
SearchManager.SUGGEST_COLUMN_QUERY);
mSuggestIntentExtraDataId = mSuggestCursor.getColumnIndex(
@@ -590,12 +589,22 @@
if (type == 0) {
return getContext().getString(R.string.search_the_web);
} else if (type == 1) {
- return getHistorySubtitle();
+ return null; // Use TEXT_2_URL instead
} else {
if (mSuggestText2Id == -1) return null;
return mSuggestCursor.getString(mSuggestText2Id);
}
+ case SUGGEST_COLUMN_TEXT_2_URL_ID:
+ if (type == 0) {
+ return null;
+ } else if (type == 1) {
+ return getHistoryUrl();
+ } else {
+ if (mSuggestText2UrlId == -1) return null;
+ return mSuggestCursor.getString(mSuggestText2UrlId);
+ }
+
case SUGGEST_COLUMN_ICON_1_ID:
if (type == 1) {
if (mHistoryCursor.getInt(3) == 1) {
@@ -630,9 +639,6 @@
return mSuggestCursor.getString(mSuggestQueryId);
}
- case SUGGEST_COLUMN_FORMAT:
- return "html";
-
case SUGGEST_COLUMN_INTENT_EXTRA_DATA:
if (type == 0) {
return null;
@@ -718,7 +724,7 @@
private String getHistoryTitle() {
String title = mHistoryCursor.getString(2 /* webpage title */);
if (TextUtils.isEmpty(title) || TextUtils.getTrimmedLength(title) == 0) {
- title = beautifyUrl(mHistoryCursor.getString(1 /* url */));
+ title = stripUrl(mHistoryCursor.getString(1 /* url */));
}
return title;
}
@@ -730,30 +736,15 @@
*
* @return the subtitle string to use, or null if none
*/
- private String getHistorySubtitle() {
+ private String getHistoryUrl() {
String title = mHistoryCursor.getString(2 /* webpage title */);
if (TextUtils.isEmpty(title) || TextUtils.getTrimmedLength(title) == 0) {
return null;
} else {
- return beautifyUrl(mHistoryCursor.getString(1 /* url */));
+ return stripUrl(mHistoryCursor.getString(1 /* url */));
}
}
- /**
- * Strips "http://" from the beginning of a url and "/" from the end,
- * and adds html formatting to make it green.
- */
- private String beautifyUrl(String url) {
- if (mSearchUrlColorId == null) {
- // Get the color used for this purpose from the current theme.
- TypedValue colorValue = new TypedValue();
- getContext().getTheme().resolveAttribute(
- com.android.internal.R.attr.textColorSearchUrl, colorValue, true);
- mSearchUrlColorId = Integer.toString(colorValue.resourceId);
- }
-
- return "<font color=\"@" + mSearchUrlColorId + "\">" + stripUrl(url) + "</font>";
- }
}
private static class ResultsCursor extends AbstractCursor {
diff --git a/src/com/android/browser/FindDialog.java b/src/com/android/browser/FindDialog.java
index e8d2417..45c8016 100644
--- a/src/com/android/browser/FindDialog.java
+++ b/src/com/android/browser/FindDialog.java
@@ -129,7 +129,7 @@
public void dismiss() {
super.dismiss();
mBrowserActivity.closeFind();
- mWebView.clearMatches();
+ mWebView.notifyFindDialogDismissed();
}
@Override