blob: 9ee6a219940db0868392e816e225b5fee49f45b6 [file] [log] [blame]
The Android Open Source Project31dd5032009-03-03 19:32:27 -08001/*
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
Daniel Sandler325dc232013-06-05 22:57:57 -040017package com.android.launcher3;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080018
Sunny Goyald2497482015-09-22 18:24:19 -070019import android.content.ContentResolver;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080020import android.net.Uri;
Sunny Goyald2497482015-09-22 18:24:19 -070021import android.os.Bundle;
Adam Cohendf2cc412011-04-27 16:56:57 -070022import android.provider.BaseColumns;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080023
Sunny Goyal18b640c2015-04-17 09:24:01 -070024import com.android.launcher3.config.ProviderConfig;
25
The Android Open Source Project31dd5032009-03-03 19:32:27 -080026/**
27 * Settings related utilities.
28 */
Hyunyoung Song3f471442015-04-08 19:01:34 -070029public class LauncherSettings {
Chris Wren1ada10d2013-09-13 18:01:38 -040030 /** Columns required on table staht will be subject to backup and restore. */
31 static interface ChangeLogColumns extends BaseColumns {
32 /**
33 * The time of the last update to this row.
34 * <P>Type: INTEGER</P>
35 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070036 public static final String MODIFIED = "modified";
Chris Wren1ada10d2013-09-13 18:01:38 -040037 }
38
39 static interface BaseLauncherColumns extends ChangeLogColumns {
Romain Guy73b979d2009-06-09 12:57:21 -070040 /**
41 * Descriptive name of the gesture that can be displayed to the user.
42 * <P>Type: TEXT</P>
43 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070044 public static final String TITLE = "title";
Romain Guy73b979d2009-06-09 12:57:21 -070045
46 /**
47 * The Intent URL of the gesture, describing what it points to. This
Romain Guy1ce1a242009-06-23 17:34:54 -070048 * value is given to {@link android.content.Intent#parseUri(String, int)} to create
Romain Guy73b979d2009-06-09 12:57:21 -070049 * an Intent that can be launched.
50 * <P>Type: TEXT</P>
51 */
Sunny Goyal18b640c2015-04-17 09:24:01 -070052 public static final String INTENT = "intent";
Romain Guy73b979d2009-06-09 12:57:21 -070053
54 /**
55 * The type of the gesture
56 *
57 * <P>Type: INTEGER</P>
58 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070059 public static final String ITEM_TYPE = "itemType";
Romain Guy73b979d2009-06-09 12:57:21 -070060
61 /**
62 * The gesture is an application
63 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070064 public static final int ITEM_TYPE_APPLICATION = 0;
Romain Guy73b979d2009-06-09 12:57:21 -070065
66 /**
67 * The gesture is an application created shortcut
68 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070069 public static final int ITEM_TYPE_SHORTCUT = 1;
Romain Guy73b979d2009-06-09 12:57:21 -070070
71 /**
72 * The icon type.
73 * <P>Type: INTEGER</P>
74 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070075 public static final String ICON_TYPE = "iconType";
Romain Guy73b979d2009-06-09 12:57:21 -070076
77 /**
78 * The icon is a resource identified by a package name and an integer id.
79 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070080 public static final int ICON_TYPE_RESOURCE = 0;
Romain Guy73b979d2009-06-09 12:57:21 -070081
82 /**
83 * The icon is a bitmap.
84 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070085 public static final int ICON_TYPE_BITMAP = 1;
Romain Guy73b979d2009-06-09 12:57:21 -070086
87 /**
88 * The icon package name, if icon type is ICON_TYPE_RESOURCE.
89 * <P>Type: TEXT</P>
90 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070091 public static final String ICON_PACKAGE = "iconPackage";
Romain Guy73b979d2009-06-09 12:57:21 -070092
93 /**
94 * The icon resource id, if icon type is ICON_TYPE_RESOURCE.
95 * <P>Type: TEXT</P>
96 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070097 public static final String ICON_RESOURCE = "iconResource";
Romain Guy73b979d2009-06-09 12:57:21 -070098
99 /**
100 * The custom icon bitmap, if icon type is ICON_TYPE_BITMAP.
101 * <P>Type: BLOB</P>
102 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700103 public static final String ICON = "icon";
Romain Guy73b979d2009-06-09 12:57:21 -0700104 }
105
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800106 /**
Adam Cohendcd297f2013-06-18 13:13:40 -0700107 * Workspace Screens.
108 *
109 * Tracks the order of workspace screens.
110 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700111 public static final class WorkspaceScreens implements ChangeLogColumns {
112
113 public static final String TABLE_NAME = "workspaceScreens";
114
Adam Cohendcd297f2013-06-18 13:13:40 -0700115 /**
116 * The content:// style URL for this table
117 */
118 static final Uri CONTENT_URI = Uri.parse("content://" +
Sunny Goyal18b640c2015-04-17 09:24:01 -0700119 ProviderConfig.AUTHORITY + "/" + TABLE_NAME);
Adam Cohendcd297f2013-06-18 13:13:40 -0700120
121 /**
122 * The rank of this screen -- ie. how it is ordered relative to the other screens.
123 * <P>Type: INTEGER</P>
124 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700125 public static final String SCREEN_RANK = "screenRank";
Adam Cohendcd297f2013-06-18 13:13:40 -0700126 }
127
128 /**
Bjorn Bringert93c45762009-12-16 13:19:47 +0000129 * Favorites.
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800130 */
Hyunyoung Song3f471442015-04-08 19:01:34 -0700131 public static final class Favorites implements BaseLauncherColumns {
Sunny Goyal18b640c2015-04-17 09:24:01 -0700132
133 public static final String TABLE_NAME = "favorites";
134
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800135 /**
136 * The content:// style URL for this table
137 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700138 public static final Uri CONTENT_URI = Uri.parse("content://" +
139 ProviderConfig.AUTHORITY + "/" + TABLE_NAME);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800140
141 /**
142 * The content:// style URL for a given row, identified by its id.
143 *
144 * @param id The row id.
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800145 *
146 * @return The unique content URL for the specified row.
147 */
Sunny Goyale5bb7052015-07-27 14:36:07 -0700148 public static Uri getContentUri(long id) {
Sunny Goyal18b640c2015-04-17 09:24:01 -0700149 return Uri.parse("content://" + ProviderConfig.AUTHORITY +
150 "/" + TABLE_NAME + "/" + id);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800151 }
152
153 /**
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800154 * The container holding the favorite
155 * <P>Type: INTEGER</P>
156 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700157 public static final String CONTAINER = "container";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800158
159 /**
160 * The icon is a resource identified by a package name and an integer id.
161 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700162 public static final int CONTAINER_DESKTOP = -100;
163 public static final int CONTAINER_HOTSEAT = -101;
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800164
Dan Sandlerab5fa3a2014-03-06 23:48:04 -0500165 static final String containerToString(int container) {
166 switch (container) {
167 case CONTAINER_DESKTOP: return "desktop";
168 case CONTAINER_HOTSEAT: return "hotseat";
169 default: return String.valueOf(container);
170 }
171 }
172
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800173 /**
174 * The screen holding the favorite (if container is CONTAINER_DESKTOP)
175 * <P>Type: INTEGER</P>
176 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700177 public static final String SCREEN = "screen";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800178
179 /**
180 * The X coordinate of the cell holding the favorite
Adam Cohenc51934b2011-07-26 21:07:43 -0700181 * (if container is CONTAINER_HOTSEAT or CONTAINER_HOTSEAT)
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800182 * <P>Type: INTEGER</P>
183 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700184 public static final String CELLX = "cellX";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800185
186 /**
187 * The Y coordinate of the cell holding the favorite
188 * (if container is CONTAINER_DESKTOP)
189 * <P>Type: INTEGER</P>
190 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700191 public static final String CELLY = "cellY";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800192
193 /**
194 * The X span of the cell holding the favorite
195 * <P>Type: INTEGER</P>
196 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700197 public static final String SPANX = "spanX";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800198
199 /**
200 * The Y span of the cell holding the favorite
201 * <P>Type: INTEGER</P>
202 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700203 public static final String SPANY = "spanY";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800204
205 /**
Kenny Guyed131872014-04-30 03:02:21 +0100206 * The profile id of the item in the cell.
207 * <P>
208 * Type: INTEGER
209 * </P>
210 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700211 public static final String PROFILE_ID = "profileId";
Kenny Guyed131872014-04-30 03:02:21 +0100212
213 /**
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800214 * The favorite is a user created folder
215 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700216 public static final int ITEM_TYPE_FOLDER = 2;
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800217
218 /**
Adam Cohendf2cc412011-04-27 16:56:57 -0700219 * The favorite is a live folder
220 *
221 * Note: live folders can no longer be added to Launcher, and any live folders which
222 * exist within the launcher database will be ignored when loading. That said, these
223 * entries in the database may still exist, and are not automatically stripped.
224 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700225 @Deprecated
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800226 static final int ITEM_TYPE_LIVE_FOLDER = 3;
227
228 /**
The Android Open Source Project7376fae2009-03-11 12:11:58 -0700229 * The favorite is a widget
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800230 */
Hyunyoung Song3f471442015-04-08 19:01:34 -0700231 public static final int ITEM_TYPE_APPWIDGET = 4;
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800232
233 /**
Adam Cohen59400422014-03-05 18:07:04 -0800234 * The favorite is a custom widget provided by the launcher
235 */
Hyunyoung Song3f471442015-04-08 19:01:34 -0700236 public static final int ITEM_TYPE_CUSTOM_APPWIDGET = 5;
Adam Cohen59400422014-03-05 18:07:04 -0800237
238 /**
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800239 * The favorite is a clock
240 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700241 @Deprecated
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800242 static final int ITEM_TYPE_WIDGET_CLOCK = 1000;
243
244 /**
245 * The favorite is a search widget
246 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700247 @Deprecated
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800248 static final int ITEM_TYPE_WIDGET_SEARCH = 1001;
249
250 /**
251 * The favorite is a photo frame
252 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700253 @Deprecated
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800254 static final int ITEM_TYPE_WIDGET_PHOTO_FRAME = 1002;
255
256 /**
The Android Open Source Project7376fae2009-03-11 12:11:58 -0700257 * The appWidgetId of the widget
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800258 *
259 * <P>Type: INTEGER</P>
260 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700261 public static final String APPWIDGET_ID = "appWidgetId";
Chris Wrend5e66bf2013-09-16 14:02:29 -0400262
263 /**
264 * The ComponentName of the widget provider
265 *
266 * <P>Type: STRING</P>
267 */
268 public static final String APPWIDGET_PROVIDER = "appWidgetProvider";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800269
270 /**
271 * Indicates whether this favorite is an application-created shortcut or not.
272 * If the value is 0, the favorite is not an application-created shortcut, if the
273 * value is 1, it is an application-created shortcut.
274 * <P>Type: INTEGER</P>
275 */
Romain Guy73b979d2009-06-09 12:57:21 -0700276 @Deprecated
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800277 static final String IS_SHORTCUT = "isShortcut";
278
279 /**
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800280 * The URI associated with the favorite. It is used, for instance, by
281 * live folders to find the content provider.
282 * <P>Type: TEXT</P>
283 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700284 @Deprecated
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800285 static final String URI = "uri";
286
287 /**
288 * The display mode if the item is a live folder.
289 * <P>Type: INTEGER</P>
290 *
291 * @see android.provider.LiveFolders#DISPLAY_MODE_GRID
292 * @see android.provider.LiveFolders#DISPLAY_MODE_LIST
293 */
Sunny Goyal08f72612015-01-05 13:41:43 -0800294 @Deprecated
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800295 static final String DISPLAY_MODE = "displayMode";
Chris Wrenf4d08112014-01-16 18:13:56 -0500296
297 /**
298 * Boolean indicating that his item was restored and not yet successfully bound.
299 * <P>Type: INTEGER</P>
300 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700301 public static final String RESTORED = "restored";
Sunny Goyal08f72612015-01-05 13:41:43 -0800302
303 /**
304 * Indicates the position of the item inside an auto-arranged view like folder or hotseat.
305 * <p>Type: INTEGER</p>
306 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700307 public static final String RANK = "rank";
Sunny Goyal5d85c442015-03-10 13:14:47 -0700308
309 /**
310 * Stores general flag based options for {@link ItemInfo}s.
311 * <p>Type: INTEGER</p>
312 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700313 public static final String OPTIONS = "options";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800314 }
Sunny Goyal7779d622015-06-11 16:18:39 -0700315
316 /**
317 * Launcher settings
318 */
319 public static final class Settings {
320
321 public static final Uri CONTENT_URI = Uri.parse("content://" +
322 ProviderConfig.AUTHORITY + "/settings");
323
324 public static final String METHOD_GET_BOOLEAN = "get_boolean_setting";
325 public static final String METHOD_SET_BOOLEAN = "set_boolean_setting";
Sunny Goyald2497482015-09-22 18:24:19 -0700326 public static final String METHOD_CLEAR_EMPTY_DB_FLAG = "clear_empty_db_flag";
327
328 public static final String METHOD_DELETE_EMPTY_FOLDERS = "delete_empty_folders";
329 public static final String METHOD_UPDATE_FOLDER_ITEMS_RANK = "update_folder_items_rank";
330 public static final String METHOD_CONVERT_SHORTCUTS_TO_ACTIVITIES =
331 "convert_shortcuts_to_launcher_activities";
332
333 public static final String METHOD_NEW_ITEM_ID = "generate_new_item_id";
334 public static final String METHOD_NEW_SCREEN_ID = "generate_new_screen_id";
335
336 public static final String METHOD_CREATE_EMPTY_DB = "create_empty_db";
337 public static final String METHOD_DELETE_DB = "delete_db";
338
339 public static final String METHOD_LOAD_DEFAULT_FAVORITES = "load_default_favorites";
340 public static final String METHOD_MIGRATE_LAUNCHER2_SHORTCUTS = "migrate_l2_shortcuts";
Sunny Goyal7779d622015-06-11 16:18:39 -0700341
342 public static final String EXTRA_VALUE = "value";
343 public static final String EXTRA_DEFAULT_VALUE = "default_value";
Sunny Goyald2497482015-09-22 18:24:19 -0700344
345 public static Bundle call(ContentResolver cr, String method) {
346 return cr.call(CONTENT_URI, method, null, null);
347 }
Sunny Goyal7779d622015-06-11 16:18:39 -0700348 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800349}