• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 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 com.android.providers.partnerbookmarks;
18 
19 import android.content.ContentUris;
20 import android.net.Uri;
21 
22 /**
23  * <p>
24  * The contract between the partner bookmarks provider and applications.
25  * Contains the definition for the supported URIs and columns.
26  * </p>
27  * <p>
28  * Authority URI: content://com.android.partnerbookmarks
29  * </p>
30  * <p>
31  * Partner bookmarks URI: content://com.android.partnerbookmarks/bookmarks
32  * </p>
33  * <p>
34  * If the provider is found, and the set of bookmarks is non-empty, exactly one
35  * top-level folder with “parent” set to {@link #BOOKMARK_PARENT_ROOT_ID}
36  * shall be provided; more than one bookmark with “parent” set to
37  * {@link #BOOKMARK_PARENT_ROOT_ID} will cause the import to fail.
38  * </p>
39  */
40 public class PartnerBookmarksContract {
41     /** The authority for the partner bookmarks provider */
42     public static final String AUTHORITY = "com.android.partnerbookmarks";
43 
44     /** A content:// style uri to the authority for the partner bookmarks provider */
45     public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
46 
47     /**
48      * A parameter for use when querying any table that allows specifying
49      * a limit on the number of rows returned.
50      */
51     public static final String PARAM_LIMIT = "limit";
52 
53     /**
54      * A parameter for use when querying any table that allows specifying
55      * grouping of the rows returned.
56      */
57     public static final String PARAM_GROUP_BY = "groupBy";
58 
59     /**
60      * The bookmarks table, which holds the partner bookmarks.
61      */
62     public static final class Bookmarks {
63         /**
64          * This utility class cannot be instantiated.
65          */
Bookmarks()66         private Bookmarks() {}
67 
68         /**
69          * The content:// style URI for this table
70          */
71         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "bookmarks");
72 
73         /**
74          * The content:// style URI for the root partner bookmarks folder
75          */
76         public static final Uri CONTENT_URI_PARTNER_BOOKMARKS_FOLDER =
77                 Uri.withAppendedPath(CONTENT_URI, "folder");
78 
79         /**
80          * Builds a URI that points to a specific folder.
81          * @param folderId the ID of the folder to point to
82          */
buildFolderUri(long folderId)83         public static final Uri buildFolderUri(long folderId) {
84             return ContentUris.withAppendedId(CONTENT_URI_PARTNER_BOOKMARKS_FOLDER, folderId);
85         }
86 
87         /**
88          * The MIME type of {@link #CONTENT_URI} providing a directory of bookmarks.
89          */
90         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/partnerbookmark";
91 
92         /**
93          * The MIME type of a {@link #CONTENT_URI} of a single bookmark.
94          */
95         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/partnerbookmark";
96 
97         /**
98          * Used in {@link #TYPE} column and indicates the row is a bookmark.
99          */
100         public static final int BOOKMARK_TYPE_BOOKMARK = 1;
101 
102         /**
103          * Used in {@link #TYPE} column and indicates the row is a folder.
104          */
105         public static final int BOOKMARK_TYPE_FOLDER = 2;
106 
107         /**
108          * Used in {@link #PARENT} column and indicates the row doesn't have a parent.
109          */
110         public static final int BOOKMARK_PARENT_ROOT_ID = 0;
111 
112         /**
113          * The type of the item.
114          * <p>Type: INTEGER</p>
115          * <p>Allowed values are:</p>
116          * <p>
117          * <ul>
118          * <li>{@link #BOOKMARK_TYPE_BOOKMARK}</li>
119          * <li>{@link #BOOKMARK_TYPE_FOLDER}</li>
120          * </ul>
121          * </p>
122          */
123         public static final String TYPE = "type";
124 
125         /**
126          * The unique ID for a row.  Cannot be BOOKMARK_PARENT_ROOT_ID.
127          * <p>Type: INTEGER (long)</p>
128          */
129         public static final String ID = "_id";
130 
131         /**
132          * This column is valid when the row is not a folder.
133          * <p>Type: TEXT (URL)</p>
134          */
135         public static final String URL = "url";
136 
137         /**
138          * The user visible title.
139          * <p>Type: TEXT</p>
140          */
141         public static final String TITLE = "title";
142 
143         /**
144          * The favicon of the bookmark, may be NULL.
145          * Must decode via {@link BitmapFactory#decodeByteArray}.
146          * <p>Type: BLOB (image)</p>
147          */
148         public static final String FAVICON = "favicon";
149 
150         /**
151          * The touch icon for the web page, may be NULL.
152          * Must decode via {@link BitmapFactory#decodeByteArray}.
153          * <p>Type: BLOB (image)</p>
154          */
155         public static final String TOUCHICON = "touchicon";
156 
157         /**
158          * The ID of the parent folder. BOOKMARK_PARENT_ROOT_ID is the root folder.
159          * <p>Type: INTEGER (long) (reference to item in the same table)</p>
160          */
161         public static final String PARENT = "parent";
162     }
163 }
164