summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/BrowserProvider.java
diff options
context:
space:
mode:
authorBjorn Bringert <bringert@android.com>2010-03-02 11:20:29 +0000
committerBjorn Bringert <bringert@android.com>2010-03-03 09:23:24 +0000
commitc7c0fced4bfa9a15d4db28b4376f3fec28ef7fa5 (patch)
treec3e676d7015196176d6ff4b536c6eb4e68eb2b4e /src/com/android/browser/BrowserProvider.java
parentda3e030722f8703a27595e31a87428ca5df1f213 (diff)
downloadpackages_apps_Browser-c7c0fced4bfa9a15d4db28b4376f3fec28ef7fa5.zip
packages_apps_Browser-c7c0fced4bfa9a15d4db28b4376f3fec28ef7fa5.tar.gz
packages_apps_Browser-c7c0fced4bfa9a15d4db28b4376f3fec28ef7fa5.tar.bz2
Use SUGGEST_COLUMN_TEXT_2_URL in browser suggestions
Before, the Browser used an HTML <font> tag to style URLs in history / bookmark suggestions. The color used was a hidden framework resource, it assumed that the caller knew to interpret HTML mark-up, and it only worked on a light colored background. Now a separate column is used for displayed URLs, letting the caller decide how to style URLs. Part of the fix for http://b/issue?id=2380681 Change-Id: I1c3981de22bccf9cba2f2b903225ef1b50226758
Diffstat (limited to 'src/com/android/browser/BrowserProvider.java')
-rw-r--r--src/com/android/browser/BrowserProvider.java55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java
index 47c9bf9..7ba135e 100644
--- a/src/com/android/browser/BrowserProvider.java
+++ b/src/com/android/browser/BrowserProvider.java
@@ -86,10 +86,10 @@ public class BrowserProvider extends ContentProvider {
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 @@ public class BrowserProvider extends ContentProvider {
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 @@ public class BrowserProvider extends ContentProvider {
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 @@ public class BrowserProvider extends ContentProvider {
private String mString;
private int mSuggestText1Id;
private int mSuggestText2Id;
+ private int mSuggestText2UrlId;
private int mSuggestQueryId;
private int mSuggestIntentExtraDataId;
@@ -488,6 +484,7 @@ public class BrowserProvider extends ContentProvider {
if (mSuggestCursor == null) {
mSuggestText1Id = -1;
mSuggestText2Id = -1;
+ mSuggestText2UrlId = -1;
mSuggestQueryId = -1;
mSuggestIntentExtraDataId = -1;
} else {
@@ -495,6 +492,8 @@ public class BrowserProvider extends ContentProvider {
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 @@ public class BrowserProvider extends ContentProvider {
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 @@ public class BrowserProvider extends ContentProvider {
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 @@ public class BrowserProvider extends ContentProvider {
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 @@ public class BrowserProvider extends ContentProvider {
*
* @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 {