1/*
2 * Copyright (C) 2008 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
17package com.android.launcher3;
18
19import android.net.Uri;
20import android.provider.BaseColumns;
21
22/**
23 * Settings related utilities.
24 */
25class LauncherSettings {
26    /** Columns required on table staht will be subject to backup and restore. */
27    static interface ChangeLogColumns extends BaseColumns {
28        /**
29         * The time of the last update to this row.
30         * <P>Type: INTEGER</P>
31         */
32        static final String MODIFIED = "modified";
33    }
34
35    static interface BaseLauncherColumns extends ChangeLogColumns {
36        /**
37         * Descriptive name of the gesture that can be displayed to the user.
38         * <P>Type: TEXT</P>
39         */
40        static final String TITLE = "title";
41
42        /**
43         * The Intent URL of the gesture, describing what it points to. This
44         * value is given to {@link android.content.Intent#parseUri(String, int)} to create
45         * an Intent that can be launched.
46         * <P>Type: TEXT</P>
47         */
48        static final String INTENT = "intent";
49
50        /**
51         * The type of the gesture
52         *
53         * <P>Type: INTEGER</P>
54         */
55        static final String ITEM_TYPE = "itemType";
56
57        /**
58         * The gesture is an application
59         */
60        static final int ITEM_TYPE_APPLICATION = 0;
61
62        /**
63         * The gesture is an application created shortcut
64         */
65        static final int ITEM_TYPE_SHORTCUT = 1;
66
67        /**
68         * The icon type.
69         * <P>Type: INTEGER</P>
70         */
71        static final String ICON_TYPE = "iconType";
72
73        /**
74         * The icon is a resource identified by a package name and an integer id.
75         */
76        static final int ICON_TYPE_RESOURCE = 0;
77
78        /**
79         * The icon is a bitmap.
80         */
81        static final int ICON_TYPE_BITMAP = 1;
82
83        /**
84         * The icon package name, if icon type is ICON_TYPE_RESOURCE.
85         * <P>Type: TEXT</P>
86         */
87        static final String ICON_PACKAGE = "iconPackage";
88
89        /**
90         * The icon resource id, if icon type is ICON_TYPE_RESOURCE.
91         * <P>Type: TEXT</P>
92         */
93        static final String ICON_RESOURCE = "iconResource";
94
95        /**
96         * The custom icon bitmap, if icon type is ICON_TYPE_BITMAP.
97         * <P>Type: BLOB</P>
98         */
99        static final String ICON = "icon";
100    }
101
102    /**
103     * Workspace Screens.
104     *
105     * Tracks the order of workspace screens.
106     */
107    static final class WorkspaceScreens implements ChangeLogColumns {
108        /**
109         * The content:// style URL for this table
110         */
111        static final Uri CONTENT_URI = Uri.parse("content://" +
112                LauncherProvider.AUTHORITY + "/" + LauncherProvider.TABLE_WORKSPACE_SCREENS +
113                "?" + LauncherProvider.PARAMETER_NOTIFY + "=true");
114
115        /**
116         * The rank of this screen -- ie. how it is ordered relative to the other screens.
117         * <P>Type: INTEGER</P>
118         */
119        static final String SCREEN_RANK = "screenRank";
120    }
121
122    /**
123     * Favorites.
124     */
125    static final class Favorites implements BaseLauncherColumns {
126        /**
127         * The content:// style URL for this table
128         */
129        static final Uri CONTENT_URI = Uri.parse("content://" +
130                LauncherProvider.AUTHORITY + "/" + LauncherProvider.TABLE_FAVORITES +
131                "?" + LauncherProvider.PARAMETER_NOTIFY + "=true");
132
133        /**
134         * The content:// style URL for this table
135         */
136        static final Uri OLD_CONTENT_URI = Uri.parse("content://" +
137                LauncherProvider.OLD_AUTHORITY + "/" + LauncherProvider.TABLE_FAVORITES +
138                "?" + LauncherProvider.PARAMETER_NOTIFY + "=true");
139
140        /**
141         * The content:// style URL for this table. When this Uri is used, no notification is
142         * sent if the content changes.
143         */
144        static final Uri CONTENT_URI_NO_NOTIFICATION = Uri.parse("content://" +
145                LauncherProvider.AUTHORITY + "/" + LauncherProvider.TABLE_FAVORITES +
146                "?" + LauncherProvider.PARAMETER_NOTIFY + "=false");
147
148        /**
149         * The content:// style URL for a given row, identified by its id.
150         *
151         * @param id The row id.
152         * @param notify True to send a notification is the content changes.
153         *
154         * @return The unique content URL for the specified row.
155         */
156        static Uri getContentUri(long id, boolean notify) {
157            return Uri.parse("content://" + LauncherProvider.AUTHORITY +
158                    "/" + LauncherProvider.TABLE_FAVORITES + "/" + id + "?" +
159                    LauncherProvider.PARAMETER_NOTIFY + "=" + notify);
160        }
161
162        /**
163         * The container holding the favorite
164         * <P>Type: INTEGER</P>
165         */
166        static final String CONTAINER = "container";
167
168        /**
169         * The icon is a resource identified by a package name and an integer id.
170         */
171        static final int CONTAINER_DESKTOP = -100;
172        static final int CONTAINER_HOTSEAT = -101;
173
174        /**
175         * The screen holding the favorite (if container is CONTAINER_DESKTOP)
176         * <P>Type: INTEGER</P>
177         */
178        static final String SCREEN = "screen";
179
180        /**
181         * The X coordinate of the cell holding the favorite
182         * (if container is CONTAINER_HOTSEAT or CONTAINER_HOTSEAT)
183         * <P>Type: INTEGER</P>
184         */
185        static final String CELLX = "cellX";
186
187        /**
188         * The Y coordinate of the cell holding the favorite
189         * (if container is CONTAINER_DESKTOP)
190         * <P>Type: INTEGER</P>
191         */
192        static final String CELLY = "cellY";
193
194        /**
195         * The X span of the cell holding the favorite
196         * <P>Type: INTEGER</P>
197         */
198        static final String SPANX = "spanX";
199
200        /**
201         * The Y span of the cell holding the favorite
202         * <P>Type: INTEGER</P>
203         */
204        static final String SPANY = "spanY";
205
206        /**
207         * The favorite is a user created folder
208         */
209        static final int ITEM_TYPE_FOLDER = 2;
210
211        /**
212        * The favorite is a live folder
213        *
214        * Note: live folders can no longer be added to Launcher, and any live folders which
215        * exist within the launcher database will be ignored when loading.  That said, these
216        * entries in the database may still exist, and are not automatically stripped.
217        */
218        static final int ITEM_TYPE_LIVE_FOLDER = 3;
219
220        /**
221         * The favorite is a widget
222         */
223        static final int ITEM_TYPE_APPWIDGET = 4;
224
225        /**
226         * The favorite is a clock
227         */
228        static final int ITEM_TYPE_WIDGET_CLOCK = 1000;
229
230        /**
231         * The favorite is a search widget
232         */
233        static final int ITEM_TYPE_WIDGET_SEARCH = 1001;
234
235        /**
236         * The favorite is a photo frame
237         */
238        static final int ITEM_TYPE_WIDGET_PHOTO_FRAME = 1002;
239
240        /**
241         * The appWidgetId of the widget
242         *
243         * <P>Type: INTEGER</P>
244         */
245        static final String APPWIDGET_ID = "appWidgetId";
246
247        /**
248         * The ComponentName of the widget provider
249         *
250         * <P>Type: STRING</P>
251         */
252        public static final String APPWIDGET_PROVIDER = "appWidgetProvider";
253
254        /**
255         * Indicates whether this favorite is an application-created shortcut or not.
256         * If the value is 0, the favorite is not an application-created shortcut, if the
257         * value is 1, it is an application-created shortcut.
258         * <P>Type: INTEGER</P>
259         */
260        @Deprecated
261        static final String IS_SHORTCUT = "isShortcut";
262
263        /**
264         * The URI associated with the favorite. It is used, for instance, by
265         * live folders to find the content provider.
266         * <P>Type: TEXT</P>
267         */
268        static final String URI = "uri";
269
270        /**
271         * The display mode if the item is a live folder.
272         * <P>Type: INTEGER</P>
273         *
274         * @see android.provider.LiveFolders#DISPLAY_MODE_GRID
275         * @see android.provider.LiveFolders#DISPLAY_MODE_LIST
276         */
277        static final String DISPLAY_MODE = "displayMode";
278    }
279}
280