The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.provider; |
| 18 | |
| 19 | import android.content.ContentResolver; |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 20 | import android.content.ContentUris; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.content.ContentValues; |
| 22 | import android.content.Context; |
| 23 | import android.content.Intent; |
| 24 | import android.database.Cursor; |
| 25 | import android.database.DatabaseUtils; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 26 | import android.graphics.BitmapFactory; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.net.Uri; |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 28 | import android.provider.BrowserContract.Bookmarks; |
John Reck | ba5c412 | 2010-12-22 15:42:34 -0800 | [diff] [blame] | 29 | import android.provider.BrowserContract.Combined; |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 30 | import android.provider.BrowserContract.History; |
Jeff Hamilton | 88697b5 | 2010-08-23 10:16:43 -0500 | [diff] [blame] | 31 | import android.provider.BrowserContract.Searches; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.util.Log; |
| 33 | import android.webkit.WebIconDatabase; |
| 34 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | public class Browser { |
| 36 | private static final String LOGTAG = "browser"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * A table containing both bookmarks and history items. The columns of the table are defined in |
| 40 | * {@link BookmarkColumns}. Reading this table requires the |
| 41 | * {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} permission and writing to it |
| 42 | * requires the {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} permission. |
| 43 | */ |
| 44 | public static final Uri BOOKMARKS_URI = Uri.parse("content://browser/bookmarks"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * The name of extra data when starting Browser with ACTION_VIEW or |
| 48 | * ACTION_SEARCH intent. |
| 49 | * <p> |
| 50 | * The value should be an integer between 0 and 1000. If not set or set to |
| 51 | * 0, the Browser will use default. If set to 100, the Browser will start |
| 52 | * with 100%. |
| 53 | */ |
| 54 | public static final String INITIAL_ZOOM_LEVEL = "browser.initialZoomLevel"; |
| 55 | |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 56 | /** |
| 57 | * The name of the extra data when starting the Browser from another |
| 58 | * application. |
| 59 | * <p> |
| 60 | * The value is a unique identification string that will be used to |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 61 | * identify the calling application. The Browser will attempt to reuse the |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 62 | * same window each time the application launches the Browser with the same |
| 63 | * identifier. |
| 64 | */ |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 65 | public static final String EXTRA_APPLICATION_ID = "com.android.browser.application_id"; |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 66 | |
Mitsuru Oshima | 8eb241b | 2009-06-10 15:18:08 -0700 | [diff] [blame] | 67 | /** |
Grace Kloba | 6790918 | 2010-01-27 14:11:13 -0800 | [diff] [blame] | 68 | * The name of the extra data in the VIEW intent. The data are key/value |
| 69 | * pairs in the format of Bundle. They will be sent in the HTTP request |
Grace Kloba | d0d9bc2 | 2010-01-26 18:08:28 -0800 | [diff] [blame] | 70 | * headers for the provided url. The keys can't be the standard HTTP headers |
| 71 | * as they are set by the WebView. The url's schema must be http(s). |
| 72 | * <p> |
| 73 | */ |
Grace Kloba | 6790918 | 2010-01-27 14:11:13 -0800 | [diff] [blame] | 74 | public static final String EXTRA_HEADERS = "com.android.browser.headers"; |
Grace Kloba | d0d9bc2 | 2010-01-26 18:08:28 -0800 | [diff] [blame] | 75 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | /* if you change column order you must also change indices |
| 77 | below */ |
| 78 | public static final String[] HISTORY_PROJECTION = new String[] { |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 79 | BookmarkColumns._ID, // 0 |
| 80 | BookmarkColumns.URL, // 1 |
| 81 | BookmarkColumns.VISITS, // 2 |
| 82 | BookmarkColumns.DATE, // 3 |
| 83 | BookmarkColumns.BOOKMARK, // 4 |
| 84 | BookmarkColumns.TITLE, // 5 |
| 85 | BookmarkColumns.FAVICON, // 6 |
| 86 | BookmarkColumns.THUMBNAIL, // 7 |
| 87 | BookmarkColumns.TOUCH_ICON, // 8 |
| 88 | BookmarkColumns.USER_ENTERED, // 9 |
| 89 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | |
| 91 | /* these indices dependent on HISTORY_PROJECTION */ |
| 92 | public static final int HISTORY_PROJECTION_ID_INDEX = 0; |
| 93 | public static final int HISTORY_PROJECTION_URL_INDEX = 1; |
| 94 | public static final int HISTORY_PROJECTION_VISITS_INDEX = 2; |
| 95 | public static final int HISTORY_PROJECTION_DATE_INDEX = 3; |
| 96 | public static final int HISTORY_PROJECTION_BOOKMARK_INDEX = 4; |
| 97 | public static final int HISTORY_PROJECTION_TITLE_INDEX = 5; |
| 98 | public static final int HISTORY_PROJECTION_FAVICON_INDEX = 6; |
Leon Scroggins | 9f53fca | 2009-06-18 18:12:10 -0400 | [diff] [blame] | 99 | /** |
Leon Scroggins | 7e2ff1a | 2009-06-18 17:45:14 -0400 | [diff] [blame] | 100 | * @hide |
| 101 | */ |
Leon Scroggins | 908baed | 2009-06-18 13:39:38 -0400 | [diff] [blame] | 102 | public static final int HISTORY_PROJECTION_THUMBNAIL_INDEX = 7; |
Patrick Scott | 2ba1262 | 2009-08-04 13:20:05 -0400 | [diff] [blame] | 103 | /** |
| 104 | * @hide |
| 105 | */ |
| 106 | public static final int HISTORY_PROJECTION_TOUCH_ICON_INDEX = 8; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | |
| 108 | /* columns needed to determine whether to truncate history */ |
| 109 | public static final String[] TRUNCATE_HISTORY_PROJECTION = new String[] { |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 110 | BookmarkColumns._ID, |
| 111 | BookmarkColumns.DATE, |
| 112 | }; |
| 113 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | public static final int TRUNCATE_HISTORY_PROJECTION_ID_INDEX = 0; |
| 115 | |
| 116 | /* truncate this many history items at a time */ |
| 117 | public static final int TRUNCATE_N_OLDEST = 5; |
| 118 | |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 119 | /** |
| 120 | * A table containing a log of browser searches. The columns of the table are defined in |
| 121 | * {@link SearchColumns}. Reading this table requires the |
| 122 | * {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} permission and writing to it |
| 123 | * requires the {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} permission. |
| 124 | */ |
| 125 | public static final Uri SEARCHES_URI = Uri.parse("content://browser/searches"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 126 | |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 127 | /** |
| 128 | * A projection of {@link #SEARCHES_URI} that contains {@link SearchColumns#_ID}, |
| 129 | * {@link SearchColumns#SEARCH}, and {@link SearchColumns#DATE}. |
| 130 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | public static final String[] SEARCHES_PROJECTION = new String[] { |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 132 | // if you change column order you must also change indices below |
| 133 | SearchColumns._ID, // 0 |
| 134 | SearchColumns.SEARCH, // 1 |
| 135 | SearchColumns.DATE, // 2 |
| 136 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | |
| 138 | /* these indices dependent on SEARCHES_PROJECTION */ |
| 139 | public static final int SEARCHES_PROJECTION_SEARCH_INDEX = 1; |
| 140 | public static final int SEARCHES_PROJECTION_DATE_INDEX = 2; |
| 141 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | /* Set a cap on the count of history items in the history/bookmark |
| 143 | table, to prevent db and layout operations from dragging to a |
| 144 | crawl. Revisit this cap when/if db/layout performance |
| 145 | improvements are made. Note: this does not affect bookmark |
| 146 | entries -- if the user wants more bookmarks than the cap, they |
| 147 | get them. */ |
| 148 | private static final int MAX_HISTORY_COUNT = 250; |
| 149 | |
| 150 | /** |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 151 | * Open an activity to save a bookmark. Launch with a title |
| 152 | * and/or a url, both of which can be edited by the user before saving. |
| 153 | * |
| 154 | * @param c Context used to launch the activity to add a bookmark. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | * @param title Title for the bookmark. Can be null or empty string. |
| 156 | * @param url Url for the bookmark. Can be null or empty string. |
| 157 | */ |
| 158 | public static final void saveBookmark(Context c, |
| 159 | String title, |
| 160 | String url) { |
| 161 | Intent i = new Intent(Intent.ACTION_INSERT, Browser.BOOKMARKS_URI); |
| 162 | i.putExtra("title", title); |
| 163 | i.putExtra("url", url); |
| 164 | c.startActivity(i); |
| 165 | } |
| 166 | |
Leon Scroggins | dcf19a8 | 2009-12-10 12:37:09 -0500 | [diff] [blame] | 167 | /** |
Leon Scroggins | 31cb0be | 2011-02-25 10:53:50 -0500 | [diff] [blame^] | 168 | * Boolean extra passed along with an Intent to a browser, specifying that |
| 169 | * a new tab be created. Overrides EXTRA_APPLICATION_ID; if both are set, |
| 170 | * a new tab will be used, rather than using the same one. |
Leon Scroggins | af5b406 | 2011-02-22 16:35:13 -0500 | [diff] [blame] | 171 | */ |
| 172 | public static final String EXTRA_CREATE_NEW_TAB = "create_new_tab"; |
| 173 | |
| 174 | /** |
Leon Scroggins | dcf19a8 | 2009-12-10 12:37:09 -0500 | [diff] [blame] | 175 | * Stores a Bitmap extra in an {@link Intent} representing the screenshot of |
| 176 | * a page to share. When receiving an {@link Intent#ACTION_SEND} from the |
| 177 | * Browser, use this to access the screenshot. |
| 178 | * @hide |
| 179 | */ |
| 180 | public final static String EXTRA_SHARE_SCREENSHOT = "share_screenshot"; |
| 181 | |
| 182 | /** |
| 183 | * Stores a Bitmap extra in an {@link Intent} representing the favicon of a |
| 184 | * page to share. When receiving an {@link Intent#ACTION_SEND} from the |
| 185 | * Browser, use this to access the favicon. |
| 186 | * @hide |
| 187 | */ |
| 188 | public final static String EXTRA_SHARE_FAVICON = "share_favicon"; |
| 189 | |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 190 | /** |
| 191 | * Sends the given string using an Intent with {@link Intent#ACTION_SEND} and a mime type |
| 192 | * of text/plain. The string is put into {@link Intent#EXTRA_TEXT}. |
| 193 | * |
| 194 | * @param context the context used to start the activity |
| 195 | * @param string the string to send |
| 196 | */ |
| 197 | public static final void sendString(Context context, String string) { |
| 198 | sendString(context, string, context.getString(com.android.internal.R.string.sendText)); |
Andrei Popescu | 354eb66 | 2009-09-24 13:45:08 +0100 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Find an application to handle the given string and, if found, invoke |
| 203 | * it with the given string as a parameter. |
| 204 | * @param c Context used to launch the new activity. |
| 205 | * @param stringToSend The string to be handled. |
| 206 | * @param chooserDialogTitle The title of the dialog that allows the user |
| 207 | * to select between multiple applications that are all capable of handling |
| 208 | * the string. |
| 209 | * @hide pending API council approval |
| 210 | */ |
| 211 | public static final void sendString(Context c, |
| 212 | String stringToSend, |
| 213 | String chooserDialogTitle) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 214 | Intent send = new Intent(Intent.ACTION_SEND); |
| 215 | send.setType("text/plain"); |
Andrei Popescu | 354eb66 | 2009-09-24 13:45:08 +0100 | [diff] [blame] | 216 | send.putExtra(Intent.EXTRA_TEXT, stringToSend); |
| 217 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | try { |
Leon Scroggins | fe026bd | 2010-08-24 14:16:09 -0400 | [diff] [blame] | 219 | Intent i = Intent.createChooser(send, chooserDialogTitle); |
| 220 | // In case this is called from outside an Activity |
| 221 | i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 222 | c.startActivity(i); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | } catch(android.content.ActivityNotFoundException ex) { |
| 224 | // if no app handles it, do nothing |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | /** |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 229 | * Return a cursor pointing to a list of all the bookmarks. The cursor will have a single |
| 230 | * column, {@link BookmarkColumns#URL}. |
| 231 | * <p> |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 232 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 233 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 234 | * @param cr The ContentResolver used to access the database. |
| 235 | */ |
| 236 | public static final Cursor getAllBookmarks(ContentResolver cr) throws |
| 237 | IllegalStateException { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 238 | return cr.query(Bookmarks.CONTENT_URI, |
| 239 | new String[] { Bookmarks.URL }, |
| 240 | Bookmarks.IS_FOLDER + " = 0", null, null); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | /** |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 244 | * Return a cursor pointing to a list of all visited site urls. The cursor will |
| 245 | * have a single column, {@link BookmarkColumns#URL}. |
| 246 | * <p> |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 247 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 248 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 249 | * @param cr The ContentResolver used to access the database. |
| 250 | */ |
| 251 | public static final Cursor getAllVisitedUrls(ContentResolver cr) throws |
| 252 | IllegalStateException { |
John Reck | ba5c412 | 2010-12-22 15:42:34 -0800 | [diff] [blame] | 253 | return cr.query(Combined.CONTENT_URI, |
| 254 | new String[] { Combined.URL }, null, null, |
| 255 | Combined.DATE_CREATED + " ASC"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 256 | } |
| 257 | |
Leon Scroggins | d2334cb | 2010-03-02 15:58:40 -0500 | [diff] [blame] | 258 | private static final void addOrUrlEquals(StringBuilder sb) { |
| 259 | sb.append(" OR " + BookmarkColumns.URL + " = "); |
| 260 | } |
| 261 | |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 262 | private static final Cursor getVisitedLike(ContentResolver cr, String url) { |
Leon Scroggins | d2334cb | 2010-03-02 15:58:40 -0500 | [diff] [blame] | 263 | boolean secure = false; |
| 264 | String compareString = url; |
| 265 | if (compareString.startsWith("http://")) { |
| 266 | compareString = compareString.substring(7); |
| 267 | } else if (compareString.startsWith("https://")) { |
| 268 | compareString = compareString.substring(8); |
| 269 | secure = true; |
| 270 | } |
| 271 | if (compareString.startsWith("www.")) { |
| 272 | compareString = compareString.substring(4); |
| 273 | } |
| 274 | StringBuilder whereClause = null; |
| 275 | if (secure) { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 276 | whereClause = new StringBuilder(Bookmarks.URL + " = "); |
Leon Scroggins | d2334cb | 2010-03-02 15:58:40 -0500 | [diff] [blame] | 277 | DatabaseUtils.appendEscapedSQLString(whereClause, |
| 278 | "https://" + compareString); |
| 279 | addOrUrlEquals(whereClause); |
| 280 | DatabaseUtils.appendEscapedSQLString(whereClause, |
| 281 | "https://www." + compareString); |
| 282 | } else { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 283 | whereClause = new StringBuilder(Bookmarks.URL + " = "); |
Leon Scroggins | d2334cb | 2010-03-02 15:58:40 -0500 | [diff] [blame] | 284 | DatabaseUtils.appendEscapedSQLString(whereClause, |
| 285 | compareString); |
| 286 | addOrUrlEquals(whereClause); |
| 287 | String wwwString = "www." + compareString; |
| 288 | DatabaseUtils.appendEscapedSQLString(whereClause, |
| 289 | wwwString); |
| 290 | addOrUrlEquals(whereClause); |
| 291 | DatabaseUtils.appendEscapedSQLString(whereClause, |
| 292 | "http://" + compareString); |
| 293 | addOrUrlEquals(whereClause); |
| 294 | DatabaseUtils.appendEscapedSQLString(whereClause, |
| 295 | "http://" + wwwString); |
| 296 | } |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 297 | return cr.query(History.CONTENT_URI, new String[] { History._ID, History.VISITS }, |
Leon Scroggins | d2334cb | 2010-03-02 15:58:40 -0500 | [diff] [blame] | 298 | whereClause.toString(), null, null); |
| 299 | } |
| 300 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 301 | /** |
| 302 | * Update the visited history to acknowledge that a site has been |
| 303 | * visited. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 304 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
| 305 | * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 306 | * @param cr The ContentResolver used to access the database. |
| 307 | * @param url The site being visited. |
Leon Scroggins | 331c778 | 2009-11-25 12:43:11 -0500 | [diff] [blame] | 308 | * @param real If true, this is an actual visit, and should add to the |
| 309 | * number of visits. If false, the user entered it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 310 | */ |
| 311 | public static final void updateVisitedHistory(ContentResolver cr, |
| 312 | String url, boolean real) { |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 313 | long now = System.currentTimeMillis(); |
Leon Scroggins | e77852c | 2010-03-24 14:44:04 -0400 | [diff] [blame] | 314 | Cursor c = null; |
| 315 | try { |
| 316 | c = getVisitedLike(cr, url); |
| 317 | /* We should only get one answer that is exactly the same. */ |
| 318 | if (c.moveToFirst()) { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 319 | ContentValues values = new ContentValues(); |
Leon Scroggins | e77852c | 2010-03-24 14:44:04 -0400 | [diff] [blame] | 320 | if (real) { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 321 | values.put(History.VISITS, c.getInt(1) + 1); |
Leon Scroggins | 331c778 | 2009-11-25 12:43:11 -0500 | [diff] [blame] | 322 | } else { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 323 | values.put(History.USER_ENTERED, 1); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | } |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 325 | values.put(History.DATE_LAST_VISITED, now); |
| 326 | cr.update(ContentUris.withAppendedId(History.CONTENT_URI, c.getLong(0)), |
| 327 | values, null, null); |
Leon Scroggins | e77852c | 2010-03-24 14:44:04 -0400 | [diff] [blame] | 328 | } else { |
| 329 | truncateHistory(cr); |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 330 | ContentValues values = new ContentValues(); |
Leon Scroggins | e77852c | 2010-03-24 14:44:04 -0400 | [diff] [blame] | 331 | int visits; |
| 332 | int user_entered; |
| 333 | if (real) { |
| 334 | visits = 1; |
| 335 | user_entered = 0; |
| 336 | } else { |
| 337 | visits = 0; |
| 338 | user_entered = 1; |
| 339 | } |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 340 | values.put(History.URL, url); |
| 341 | values.put(History.VISITS, visits); |
| 342 | values.put(History.DATE_LAST_VISITED, now); |
| 343 | values.put(History.TITLE, url); |
| 344 | values.put(History.DATE_CREATED, 0); |
| 345 | values.put(History.USER_ENTERED, user_entered); |
| 346 | cr.insert(History.CONTENT_URI, values); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 347 | } |
Leon Scroggins | e77852c | 2010-03-24 14:44:04 -0400 | [diff] [blame] | 348 | } catch (IllegalStateException e) { |
| 349 | Log.e(LOGTAG, "updateVisitedHistory", e); |
| 350 | } finally { |
| 351 | if (c != null) c.close(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 352 | } |
| 353 | } |
| 354 | |
| 355 | /** |
Leon Clarke | 9c8d886 | 2009-09-24 15:20:10 +0100 | [diff] [blame] | 356 | * Returns all the URLs in the history. |
| 357 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
| 358 | * @param cr The ContentResolver used to access the database. |
| 359 | * @hide pending API council approval |
| 360 | */ |
| 361 | public static final String[] getVisitedHistory(ContentResolver cr) { |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 362 | Cursor c = null; |
| 363 | String[] str = null; |
Grace Kloba | bf54f02b | 2009-09-24 14:14:11 -0700 | [diff] [blame] | 364 | try { |
| 365 | String[] projection = new String[] { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 366 | History.URL, |
Grace Kloba | bf54f02b | 2009-09-24 14:14:11 -0700 | [diff] [blame] | 367 | }; |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 368 | c = cr.query(History.CONTENT_URI, projection, History.VISITS + " > 0", null, null); |
| 369 | if (c == null) return new String[0]; |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 370 | str = new String[c.getCount()]; |
Grace Kloba | bf54f02b | 2009-09-24 14:14:11 -0700 | [diff] [blame] | 371 | int i = 0; |
| 372 | while (c.moveToNext()) { |
| 373 | str[i] = c.getString(0); |
| 374 | i++; |
| 375 | } |
Grace Kloba | bf54f02b | 2009-09-24 14:14:11 -0700 | [diff] [blame] | 376 | } catch (IllegalStateException e) { |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 377 | Log.e(LOGTAG, "getVisitedHistory", e); |
| 378 | str = new String[0]; |
| 379 | } finally { |
| 380 | if (c != null) c.close(); |
Grace Kloba | bf54f02b | 2009-09-24 14:14:11 -0700 | [diff] [blame] | 381 | } |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 382 | return str; |
Leon Clarke | 9c8d886 | 2009-09-24 15:20:10 +0100 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | * If there are more than MAX_HISTORY_COUNT non-bookmark history |
| 387 | * items in the bookmark/history table, delete TRUNCATE_N_OLDEST |
| 388 | * of them. This is used to keep our history table to a |
| 389 | * reasonable size. Note: it does not prune bookmarks. If the |
| 390 | * user wants 1000 bookmarks, the user gets 1000 bookmarks. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 391 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
| 392 | * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 393 | * |
| 394 | * @param cr The ContentResolver used to access the database. |
| 395 | */ |
| 396 | public static final void truncateHistory(ContentResolver cr) { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 397 | // TODO make a single request to the provider to do this in a single transaction |
| 398 | Cursor cursor = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | try { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 400 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | // Select non-bookmark history, ordered by date |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 402 | cursor = cr.query(History.CONTENT_URI, |
| 403 | new String[] { History._ID, History.URL, History.DATE_LAST_VISITED }, |
| 404 | null, null, History.DATE_LAST_VISITED + " ASC"); |
| 405 | |
| 406 | if (cursor.moveToFirst() && cursor.getCount() >= MAX_HISTORY_COUNT) { |
| 407 | final WebIconDatabase iconDb = WebIconDatabase.getInstance(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 408 | /* eliminate oldest history items */ |
| 409 | for (int i = 0; i < TRUNCATE_N_OLDEST; i++) { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 410 | cr.delete(ContentUris.withAppendedId(History.CONTENT_URI, cursor.getLong(0)), |
| 411 | null, null); |
| 412 | iconDb.releaseIconForPageUrl(cursor.getString(1)); |
| 413 | if (!cursor.moveToNext()) break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 414 | } |
| 415 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 416 | } catch (IllegalStateException e) { |
| 417 | Log.e(LOGTAG, "truncateHistory", e); |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 418 | } finally { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 419 | if (cursor != null) cursor.close(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 420 | } |
| 421 | } |
| 422 | |
| 423 | /** |
| 424 | * Returns whether there is any history to clear. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 425 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 426 | * @param cr The ContentResolver used to access the database. |
| 427 | * @return boolean True if the history can be cleared. |
| 428 | */ |
| 429 | public static final boolean canClearHistory(ContentResolver cr) { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 430 | Cursor cursor = null; |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 431 | boolean ret = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 432 | try { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 433 | cursor = cr.query(History.CONTENT_URI, |
| 434 | new String [] { History._ID, History.VISITS }, |
| 435 | null, null, null); |
| 436 | ret = cursor.getCount() > 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 437 | } catch (IllegalStateException e) { |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 438 | Log.e(LOGTAG, "canClearHistory", e); |
| 439 | } finally { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 440 | if (cursor != null) cursor.close(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | } |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 442 | return ret; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Delete all entries from the bookmarks/history table which are |
| 447 | * not bookmarks. Also set all visited bookmarks to unvisited. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 448 | * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 449 | * @param cr The ContentResolver used to access the database. |
| 450 | */ |
| 451 | public static final void clearHistory(ContentResolver cr) { |
| 452 | deleteHistoryWhere(cr, null); |
| 453 | } |
| 454 | |
| 455 | /** |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 456 | * Helper function to delete all history items and release the icons for them in the |
| 457 | * {@link WebIconDatabase}. |
| 458 | * |
| 459 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
| 460 | * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} |
| 461 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 462 | * @param cr The ContentResolver used to access the database. |
| 463 | * @param whereClause String to limit the items affected. |
| 464 | * null means all items. |
| 465 | */ |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 466 | private static final void deleteHistoryWhere(ContentResolver cr, String whereClause) { |
| 467 | Cursor cursor = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 468 | try { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 469 | cursor = cr.query(History.CONTENT_URI, new String[] { History.URL }, whereClause, |
| 470 | null, null); |
| 471 | if (cursor.moveToFirst()) { |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 472 | final WebIconDatabase iconDb = WebIconDatabase.getInstance(); |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 473 | do { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 474 | // Delete favicons |
| 475 | // TODO don't release if the URL is bookmarked |
| 476 | iconDb.releaseIconForPageUrl(cursor.getString(0)); |
| 477 | } while (cursor.moveToNext()); |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 478 | |
Jeff Hamilton | 5360eab | 2010-09-16 00:46:48 -0500 | [diff] [blame] | 479 | cr.delete(History.CONTENT_URI, whereClause, null); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 480 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 481 | } catch (IllegalStateException e) { |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 482 | Log.e(LOGTAG, "deleteHistoryWhere", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 483 | return; |
Leon Scroggins | fe1143b | 2010-03-12 17:42:21 -0500 | [diff] [blame] | 484 | } finally { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 485 | if (cursor != null) cursor.close(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 486 | } |
| 487 | } |
| 488 | |
| 489 | /** |
| 490 | * Delete all history items from begin to end. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 491 | * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 492 | * @param cr The ContentResolver used to access the database. |
| 493 | * @param begin First date to remove. If -1, all dates before end. |
| 494 | * Inclusive. |
| 495 | * @param end Last date to remove. If -1, all dates after begin. |
| 496 | * Non-inclusive. |
| 497 | */ |
| 498 | public static final void deleteHistoryTimeFrame(ContentResolver cr, |
| 499 | long begin, long end) { |
| 500 | String whereClause; |
| 501 | String date = BookmarkColumns.DATE; |
| 502 | if (-1 == begin) { |
| 503 | if (-1 == end) { |
| 504 | clearHistory(cr); |
| 505 | return; |
| 506 | } |
| 507 | whereClause = date + " < " + Long.toString(end); |
| 508 | } else if (-1 == end) { |
| 509 | whereClause = date + " >= " + Long.toString(begin); |
| 510 | } else { |
| 511 | whereClause = date + " >= " + Long.toString(begin) + " AND " + date |
| 512 | + " < " + Long.toString(end); |
| 513 | } |
| 514 | deleteHistoryWhere(cr, whereClause); |
| 515 | } |
| 516 | |
| 517 | /** |
| 518 | * Remove a specific url from the history database. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 519 | * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 520 | * @param cr The ContentResolver used to access the database. |
| 521 | * @param url url to remove. |
| 522 | */ |
| 523 | public static final void deleteFromHistory(ContentResolver cr, |
| 524 | String url) { |
Jeff Hamilton | 6f42edc | 2010-08-18 11:12:05 -0500 | [diff] [blame] | 525 | cr.delete(History.CONTENT_URI, History.URL + "=?", new String[] { url }); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | /** |
| 529 | * Add a search string to the searches database. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 530 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
| 531 | * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 532 | * @param cr The ContentResolver used to access the database. |
| 533 | * @param search The string to add to the searches database. |
| 534 | */ |
| 535 | public static final void addSearchUrl(ContentResolver cr, String search) { |
Jeff Hamilton | 88697b5 | 2010-08-23 10:16:43 -0500 | [diff] [blame] | 536 | // The content provider will take care of updating existing searches instead of duplicating |
| 537 | ContentValues values = new ContentValues(); |
| 538 | values.put(Searches.SEARCH, search); |
| 539 | values.put(Searches.DATE, System.currentTimeMillis()); |
| 540 | cr.insert(Searches.CONTENT_URI, values); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 541 | } |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 542 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 543 | /** |
| 544 | * Remove all searches from the search database. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 545 | * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 546 | * @param cr The ContentResolver used to access the database. |
| 547 | */ |
| 548 | public static final void clearSearches(ContentResolver cr) { |
| 549 | // FIXME: Should this clear the urls to which these searches lead? |
| 550 | // (i.e. remove google.com/query= blah blah blah) |
| 551 | try { |
Jeff Hamilton | 88697b5 | 2010-08-23 10:16:43 -0500 | [diff] [blame] | 552 | cr.delete(Searches.CONTENT_URI, null, null); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 553 | } catch (IllegalStateException e) { |
| 554 | Log.e(LOGTAG, "clearSearches", e); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | /** |
Patrick Scott | 36acfbc | 2010-04-09 12:42:03 -0400 | [diff] [blame] | 559 | * Request all icons from the database. This call must either be called |
| 560 | * in the main thread or have had Looper.prepare() invoked in the calling |
| 561 | * thread. |
Leon Scroggins | 9ce4c6c | 2009-06-19 14:13:08 -0400 | [diff] [blame] | 562 | * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 563 | * @param cr The ContentResolver used to access the database. |
| 564 | * @param where Clause to be used to limit the query from the database. |
| 565 | * Must be an allowable string to be passed into a database query. |
| 566 | * @param listener IconListener that gets the icons once they are |
| 567 | * retrieved. |
| 568 | */ |
| 569 | public static final void requestAllIcons(ContentResolver cr, String where, |
| 570 | WebIconDatabase.IconListener listener) { |
Jeff Hamilton | 88697b5 | 2010-08-23 10:16:43 -0500 | [diff] [blame] | 571 | WebIconDatabase.getInstance().bulkRequestIconForPageUrl(cr, where, listener); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 572 | } |
| 573 | |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 574 | /** |
| 575 | * Column definitions for the mixed bookmark and history items available |
| 576 | * at {@link #BOOKMARKS_URI}. |
| 577 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 578 | public static class BookmarkColumns implements BaseColumns { |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 579 | /** |
| 580 | * The URL of the bookmark or history item. |
| 581 | * <p>Type: TEXT (URL)</p> |
| 582 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 583 | public static final String URL = "url"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 584 | |
| 585 | /** |
| 586 | * The number of time the item has been visited. |
| 587 | * <p>Type: NUMBER</p> |
| 588 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 589 | public static final String VISITS = "visits"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 590 | |
| 591 | /** |
| 592 | * The date the item was last visited, in milliseconds since the epoch. |
| 593 | * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p> |
| 594 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 595 | public static final String DATE = "date"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 596 | |
| 597 | /** |
| 598 | * Flag indicating that an item is a bookmark. A value of 1 indicates a bookmark, a value |
| 599 | * of 0 indicates a history item. |
| 600 | * <p>Type: INTEGER (boolean)</p> |
| 601 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 602 | public static final String BOOKMARK = "bookmark"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 603 | |
| 604 | /** |
| 605 | * The user visible title of the bookmark or history item. |
| 606 | * <p>Type: TEXT</p> |
| 607 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 608 | public static final String TITLE = "title"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 609 | |
| 610 | /** |
| 611 | * The date the item created, in milliseconds since the epoch. |
| 612 | * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p> |
| 613 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 614 | public static final String CREATED = "created"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 615 | |
| 616 | /** |
| 617 | * The favicon of the bookmark. Must decode via {@link BitmapFactory#decodeByteArray}. |
| 618 | * <p>Type: BLOB (image)</p> |
| 619 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 620 | public static final String FAVICON = "favicon"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 621 | |
Leon Scroggins | 9f53fca | 2009-06-18 18:12:10 -0400 | [diff] [blame] | 622 | /** |
Leon Scroggins | 7e2ff1a | 2009-06-18 17:45:14 -0400 | [diff] [blame] | 623 | * @hide |
| 624 | */ |
Leon Scroggins | 908baed | 2009-06-18 13:39:38 -0400 | [diff] [blame] | 625 | public static final String THUMBNAIL = "thumbnail"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 626 | |
Patrick Scott | 2ba1262 | 2009-08-04 13:20:05 -0400 | [diff] [blame] | 627 | /** |
| 628 | * @hide |
| 629 | */ |
| 630 | public static final String TOUCH_ICON = "touch_icon"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 631 | |
Leon Scroggins | 331c778 | 2009-11-25 12:43:11 -0500 | [diff] [blame] | 632 | /** |
| 633 | * @hide |
| 634 | */ |
| 635 | public static final String USER_ENTERED = "user_entered"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 636 | } |
| 637 | |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 638 | /** |
| 639 | * Column definitions for the search history table, available at {@link #SEARCHES_URI}. |
| 640 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 641 | public static class SearchColumns implements BaseColumns { |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 642 | /** |
Kristian Monsen | b5503c1 | 2010-08-31 14:02:38 +0100 | [diff] [blame] | 643 | * @deprecated Not used. |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 644 | */ |
| 645 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 646 | public static final String URL = "url"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 647 | |
| 648 | /** |
| 649 | * The user entered search term. |
| 650 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 651 | public static final String SEARCH = "search"; |
Jeff Hamilton | 31d95db | 2010-07-29 16:00:55 -0500 | [diff] [blame] | 652 | |
| 653 | /** |
| 654 | * The date the search was performed, in milliseconds since the epoch. |
| 655 | * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p> |
| 656 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 657 | public static final String DATE = "date"; |
| 658 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 659 | } |