Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d67ac24 authored by Jeff Hamilton's avatar Jeff Hamilton
Browse files

Add new items to the BrowserContract.

- Add a limit parameter for querying any table
- Add parameters for specifying an account when
  querying Bookmarks
- Add columns to read the source ID for a row's
  parent and insert_after references
- Add the Images, Combined, and Accounts tables

Change-Id: Ie382bc425565688b0006fa6d50765fdac226dd02
parent 06fb6e07
Loading
Loading
Loading
Loading
+128 −31
Original line number Diff line number Diff line
@@ -46,6 +46,12 @@ public class BrowserContract {
     */
    public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";

    /**
     * A parameter for use when querying any table that allows specifying a limit on the number
     * of rows returned.
     */
    public static final String PARAM_LIMIT = "limit";

    /**
     * Generic columns for use by sync adapters. The specific functions of
     * these columns are private to the sync adapter. Other clients of the API
@@ -121,22 +127,14 @@ public class BrowserContract {
         */
        public static final String DIRTY = "dirty";

        /**
         * The time that this row was created on its originating client (msecs
         * since the epoch).
         * <P>Type: INTEGER</P>
         */
        public static final String DATE_CREATED = "created";

        /**
         * The time that this row was last modified by a client (msecs since the epoch).
         * <P>Type: INTEGER</P>
         */
        public static final String DATE_MODIFIED = "modified";

    }

    interface BookmarkColumns {
    interface CommonColumns {
        /**
         * The unique ID for a row.
         * <P>Type: INTEGER (long)</P>
@@ -155,6 +153,15 @@ public class BrowserContract {
         */
        public static final String TITLE = "title";

        /**
         * The time that this row was created on its originating client (msecs
         * since the epoch).
         * <P>Type: INTEGER</P>
         */
        public static final String DATE_CREATED = "created";
    }

    interface ImageColumns {
        /**
         * The favicon of the bookmark, may be NULL.
         * Must decode via {@link BitmapFactory#decodeByteArray}.
@@ -178,10 +185,26 @@ public class BrowserContract {
        public static final String TOUCH_ICON = "touch_icon";
    }

    interface HistoryColumns {
        /**
         * The date the item was last visited, in milliseconds since the epoch.
         * <p>Type: INTEGER (date in milliseconds since January 1, 1970)</p>
         */
        public static final String DATE_LAST_VISITED = "date";

        /**
         * The number of times the item has been visited.
         * <p>Type: INTEGER</p>
         */
        public static final String VISITS = "visits";

        public static final String USER_ENTERED = "user_entered";
    }

    /**
     * The bookmarks table, which holds the user's browser bookmarks.
     */
    public static final class Bookmarks implements BookmarkColumns, SyncColumns {
    public static final class Bookmarks implements CommonColumns, ImageColumns, SyncColumns {
        /**
         * This utility class cannot be instantiated.
         */
@@ -198,6 +221,16 @@ public class BrowserContract {
        public static final Uri CONTENT_URI_DEFAULT_FOLDER =
                Uri.withAppendedPath(CONTENT_URI, "folder");

        /**
         * Query parameter used to specify an account name
         */
        public static final String PARAM_ACCOUNT_NAME = "acct_name";

        /**
         * Query parameter used to specify an account type
         */
        public static final String PARAM_ACCOUNT_TYPE = "acct_type";

        /**
         * Builds a URI that points to a specific folder.
         * @param folderId the ID of the folder to point to
@@ -236,6 +269,12 @@ public class BrowserContract {
         */
        public static final String PARENT = "parent";

        /**
         * The source ID for an item's parent. Read-only.
         * @see #PARENT
         */
        public static final String PARENT_SOURCE_ID = "parent_source";

        /**
         * The position of the bookmark in relation to it's siblings that share the same
         * {@link #PARENT}. May be negative.
@@ -250,6 +289,14 @@ public class BrowserContract {
         */
        public static final String INSERT_AFTER = "insert_after";

        /**
         * The source ID for the item that the bookmark should be inserted after. Read-only.
         * May be negative.
         * <P>Type: INTEGER</P>
         * @see #INSERT_AFTER
         */
        public static final String INSERT_AFTER_SOURCE_ID = "insert_after_source";

        /**
         * A flag to indicate if an item has been deleted. Queries will not return deleted
         * entries unless you add the {@link #QUERY_PARAMETER_SHOW_DELETED} query paramter
@@ -261,48 +308,53 @@ public class BrowserContract {
    }

    /**
     * The history table, which holds the browsing history.
     * Read-only table that lists all the accounts that are used to provide bookmarks.
     */
    public static final class History implements BookmarkColumns {
    public static final class Accounts {
        /**
         * This utility class cannot be instantiated.
         * Directory under {@link Bookmarks#CONTENT_URI}
         */
        private History() {}
        public static final Uri CONTENT_URI =
                AUTHORITY_URI.buildUpon().appendPath("accounts").build();

        /**
         * The content:// style URI for this table
         * The name of the account instance to which this row belongs, which when paired with
         * {@link #ACCOUNT_TYPE} identifies a specific account.
         * <P>Type: TEXT</P>
         */
        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "history");
        public static final String ACCOUNT_NAME = "account_name";

        /**
         * The MIME type of {@link #CONTENT_URI} providing a directory of browser history items.
         * The type of account to which this row belongs, which when paired with
         * {@link #ACCOUNT_NAME} identifies a specific account.
         * <P>Type: TEXT</P>
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/browser-history";
        public static final String ACCOUNT_TYPE = "account_type";
    }

    /**
         * The MIME type of a {@link #CONTENT_URI} of a single browser history item.
     * The history table, which holds the browsing history.
     */
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/browser-history";

    public static final class History implements CommonColumns, HistoryColumns, ImageColumns {
        /**
         * The date the item was last visited, in milliseconds since the epoch.
         * <p>Type: INTEGER (date in milliseconds since January 1, 1970)</p>
         * This utility class cannot be instantiated.
         */
        public static final String DATE_LAST_VISITED = "date";
        private History() {}

        /**
         * The date the item created, in milliseconds since the epoch.
         * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p>
         * The content:// style URI for this table
         */
        public static final String DATE_CREATED = "created";
        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "history");

        /**
         * The number of times the item has been visited.
         * <p>Type: INTEGER</p>
         * The MIME type of {@link #CONTENT_URI} providing a directory of browser history items.
         */
        public static final String VISITS = "visits";
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/browser-history";

        public static final String USER_ENTERED = "user_entered";
        /**
         * The MIME type of a {@link #CONTENT_URI} of a single browser history item.
         */
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/browser-history";
    }

    /**
@@ -396,4 +448,49 @@ public class BrowserContract {
            return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
        }
    }

    /**
     * Stores images for URLs. Only support query() and update().
     * @hide
     */
    public static final class Images implements ImageColumns {
        /**
         * This utility class cannot be instantiated
         */
        private Images() {}

        /**
         * The content:// style URI for this table
         */
        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "images");

        /**
         * The URL the images came from.
         * <P>Type: TEXT (URL)</P>
         */
        public static final String URL = "url_key";
    }

    /**
     * A combined view of bookmarks and history. All bookmarks in all folders are included and
     * no folders are included.
     */
    public static final class Combined implements CommonColumns, HistoryColumns, ImageColumns {
        /**
         * This utility class cannot be instantiated
         */
        private Combined() {}

        /**
         * The content:// style URI for this table
         */
        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "combined");

        /**
         * Flag indicating that an item is a bookmark. A value of 1 indicates a bookmark, a value
         * of 0 indicates a history item.
         * <p>Type: INTEGER (boolean)</p>
         */
        public static final String IS_BOOKMARK = "bookmark";
    }
}