blob: 105d5f30c8fb67b8aa9db28947dcda51762883e7 [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 Goyalc190dbf2016-05-05 14:37:05 -070019import android.database.sqlite.SQLiteDatabase;
Adam Cohendf2cc412011-04-27 16:56:57 -070020import android.provider.BaseColumns;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080021
Sunny Goyale396abf2020-04-06 15:11:17 -070022import com.android.launcher3.model.data.ItemInfo;
23
The Android Open Source Project31dd5032009-03-03 19:32:27 -080024/**
25 * Settings related utilities.
26 */
Hyunyoung Song3f471442015-04-08 19:01:34 -070027public class LauncherSettings {
Sunny Goyalc5939392018-12-07 11:43:47 -080028
29 /**
Luca Zuccarini20983812023-01-03 14:19:48 +000030 * Types of animations.
31 */
32 public static final class Animation {
33 /**
34 * The default animation for a given view/item info type.
35 */
36 public static final int DEFAULT = 0;
37 /**
38 * An animation using the view's background.
39 */
40 public static final int VIEW_BACKGROUND = 1;
Hyunyoung Songa38aab92023-03-14 07:56:59 +000041 /**
42 * The default animation for a given view/item info type, but without the splash icon.
43 */
44 public static final int DEFAULT_NO_ICON = 2;
Luca Zuccarini20983812023-01-03 14:19:48 +000045 }
46
47 /**
Sunny Goyalc5939392018-12-07 11:43:47 -080048 * Favorites.
49 */
50 public static final class Favorites implements BaseColumns {
Chris Wren1ada10d2013-09-13 18:01:38 -040051 /**
52 * The time of the last update to this row.
53 * <P>Type: INTEGER</P>
54 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070055 public static final String MODIFIED = "modified";
Chris Wren1ada10d2013-09-13 18:01:38 -040056
Romain Guy73b979d2009-06-09 12:57:21 -070057 /**
58 * Descriptive name of the gesture that can be displayed to the user.
59 * <P>Type: TEXT</P>
60 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070061 public static final String TITLE = "title";
Romain Guy73b979d2009-06-09 12:57:21 -070062
63 /**
64 * The Intent URL of the gesture, describing what it points to. This
Romain Guy1ce1a242009-06-23 17:34:54 -070065 * value is given to {@link android.content.Intent#parseUri(String, int)} to create
Romain Guy73b979d2009-06-09 12:57:21 -070066 * an Intent that can be launched.
67 * <P>Type: TEXT</P>
68 */
Sunny Goyal18b640c2015-04-17 09:24:01 -070069 public static final String INTENT = "intent";
Romain Guy73b979d2009-06-09 12:57:21 -070070
71 /**
72 * The type of the gesture
73 *
74 * <P>Type: INTEGER</P>
75 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070076 public static final String ITEM_TYPE = "itemType";
Romain Guy73b979d2009-06-09 12:57:21 -070077
78 /**
Samuel Fufad3720c22019-09-06 11:25:08 -070079 * The gesture is a package
80 */
81 public static final int ITEM_TYPE_NON_ACTIONABLE = -1;
82 /**
Romain Guy73b979d2009-06-09 12:57:21 -070083 * The gesture is an application
84 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070085 public static final int ITEM_TYPE_APPLICATION = 0;
Romain Guy73b979d2009-06-09 12:57:21 -070086
87 /**
88 * The gesture is an application created shortcut
Sunny Goyale274d972023-05-01 16:55:59 -070089 * @deprecated This is no longer supported. Use {@link #ITEM_TYPE_DEEP_SHORTCUT} instead
Romain Guy73b979d2009-06-09 12:57:21 -070090 */
Sunny Goyale274d972023-05-01 16:55:59 -070091 @Deprecated
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -070092 public static final int ITEM_TYPE_SHORTCUT = 1;
Romain Guy73b979d2009-06-09 12:57:21 -070093
94 /**
Andy Wickham19ab1772021-02-10 21:36:51 -080095 * The favorite is a user created folder
96 */
97 public static final int ITEM_TYPE_FOLDER = 2;
98
99 /**
100 * The favorite is a widget
101 */
102 public static final int ITEM_TYPE_APPWIDGET = 4;
103
104 /**
105 * The favorite is a custom widget provided by the launcher
106 */
107 public static final int ITEM_TYPE_CUSTOM_APPWIDGET = 5;
108
109 /**
110 * The gesture is an application created deep shortcut
111 */
112 public static final int ITEM_TYPE_DEEP_SHORTCUT = 6;
113
Jeremy Sim7cf0dd92023-03-24 22:39:45 -0700114 /**
115 * The favorite is an app pair for launching split screen
116 */
117 public static final int ITEM_TYPE_APP_PAIR = 10;
sfufa@google.comca76de02021-09-24 08:55:48 -0700118
Andy Wickham93456812022-10-05 17:58:45 -0700119 // *** Below enum values are used for metrics purpose but not used in Favorites DB ***
sfufa@google.comca76de02021-09-24 08:55:48 -0700120
121 /**
Andy Wickham19ab1772021-02-10 21:36:51 -0800122 * Type of the item is recents task.
Andy Wickham19ab1772021-02-10 21:36:51 -0800123 */
124 public static final int ITEM_TYPE_TASK = 7;
125
126 /**
127 * The item is QSB
128 */
129 public static final int ITEM_TYPE_QSB = 8;
130
131 /**
Andy Wickham93456812022-10-05 17:58:45 -0700132 * The favorite is a search action
133 */
134 public static final int ITEM_TYPE_SEARCH_ACTION = 9;
135
136 /**
Sunny Goyaleb4b7992016-04-21 14:30:18 -0700137 * The custom icon bitmap.
Romain Guy73b979d2009-06-09 12:57:21 -0700138 * <P>Type: BLOB</P>
139 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700140 public static final String ICON = "icon";
Sunny Goyal18b640c2015-04-17 09:24:01 -0700141
142 public static final String TABLE_NAME = "favorites";
143
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800144 /**
Samuel Fufaf667a132020-05-29 14:47:42 -0700145 * Backup table created when user hotseat is moved to workspace for hybrid hotseat
146 */
147 public static final String HYBRID_HOTSEAT_BACKUP_TABLE = "hotseat_restore_backup";
148
149 /**
Tracy Zhouf6018722020-02-06 16:37:16 -0800150 * Temporary table used specifically for multi-db grid migrations
151 */
152 public static final String TMP_TABLE = "favorites_tmp";
153
154 /**
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800155 * The container holding the favorite
156 * <P>Type: INTEGER</P>
157 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700158 public static final String CONTAINER = "container";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800159
160 /**
161 * The icon is a resource identified by a package name and an integer id.
162 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700163 public static final int CONTAINER_DESKTOP = -100;
164 public static final int CONTAINER_HOTSEAT = -101;
Samuel Fufa866ff002019-08-09 16:16:06 -0700165 public static final int CONTAINER_PREDICTION = -102;
Steven Ng3a835322021-03-02 21:26:00 +0000166 public static final int CONTAINER_WIDGETS_PREDICTION = -111;
Samuel Fufa225ac272019-10-21 02:02:40 -0700167 public static final int CONTAINER_HOTSEAT_PREDICTION = -103;
thiruram261c3a62020-04-29 16:23:15 -0700168 public static final int CONTAINER_ALL_APPS = -104;
thiruram6bf68482020-05-06 22:19:43 -0700169 public static final int CONTAINER_WIDGETS_TRAY = -105;
Yogisha Dixit658c5da2021-05-24 23:23:15 +0100170 public static final int CONTAINER_BOTTOM_WIDGETS_TRAY = -112;
171 public static final int CONTAINER_PIN_WIDGETS = -113;
Brian Isganitisf0ca4ae2021-09-02 16:08:29 -0400172 public static final int CONTAINER_WALLPAPERS = -114;
thiruram63bf8ee2020-06-01 12:03:19 -0700173 public static final int CONTAINER_SHORTCUTS = -107;
Hyunyoung Songf26c7932020-06-06 14:44:27 -0700174 public static final int CONTAINER_SETTINGS = -108;
Hyunyoung Song13c2bc72020-06-10 00:35:35 -0700175 public static final int CONTAINER_TASKSWITCHER = -109;
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800176
thiruram73821a92021-02-05 17:50:37 -0800177 // Represents any of the extended containers implemented in non-AOSP variants.
178 public static final int EXTENDED_CONTAINERS = -200;
179
Yogisha Dixit658c5da2021-05-24 23:23:15 +0100180 public static final int CONTAINER_UNKNOWN = -1;
181
Sunny Goyale396abf2020-04-06 15:11:17 -0700182 public static final String containerToString(int container) {
Dan Sandlerab5fa3a2014-03-06 23:48:04 -0500183 switch (container) {
184 case CONTAINER_DESKTOP: return "desktop";
185 case CONTAINER_HOTSEAT: return "hotseat";
Samuel Fufa866ff002019-08-09 16:16:06 -0700186 case CONTAINER_PREDICTION: return "prediction";
thiruram6bf68482020-05-06 22:19:43 -0700187 case CONTAINER_ALL_APPS: return "all_apps";
188 case CONTAINER_WIDGETS_TRAY: return "widgets_tray";
thiruram63bf8ee2020-06-01 12:03:19 -0700189 case CONTAINER_SHORTCUTS: return "shortcuts";
Dan Sandlerab5fa3a2014-03-06 23:48:04 -0500190 default: return String.valueOf(container);
191 }
192 }
193
Sunny Goyale396abf2020-04-06 15:11:17 -0700194 public static final String itemTypeToString(int type) {
Hyunyoung Song86160f52017-02-06 10:46:24 -0800195 switch(type) {
196 case ITEM_TYPE_APPLICATION: return "APP";
Hyunyoung Song86160f52017-02-06 10:46:24 -0800197 case ITEM_TYPE_FOLDER: return "FOLDER";
198 case ITEM_TYPE_APPWIDGET: return "WIDGET";
199 case ITEM_TYPE_CUSTOM_APPWIDGET: return "CUSTOMWIDGET";
200 case ITEM_TYPE_DEEP_SHORTCUT: return "DEEPSHORTCUT";
Andy Wickham19ab1772021-02-10 21:36:51 -0800201 case ITEM_TYPE_TASK: return "TASK";
202 case ITEM_TYPE_QSB: return "QSB";
Jeremy Sim7cf0dd92023-03-24 22:39:45 -0700203 case ITEM_TYPE_APP_PAIR: return "APP_PAIR";
Hyunyoung Song86160f52017-02-06 10:46:24 -0800204 default: return String.valueOf(type);
205 }
206 }
207
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800208 /**
209 * The screen holding the favorite (if container is CONTAINER_DESKTOP)
210 * <P>Type: INTEGER</P>
211 */
Sunny Goyal18b640c2015-04-17 09:24:01 -0700212 public static final String SCREEN = "screen";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800213
214 /**
215 * The X coordinate of the cell holding the favorite
Adam Cohenc51934b2011-07-26 21:07:43 -0700216 * (if container is CONTAINER_HOTSEAT or CONTAINER_HOTSEAT)
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800217 * <P>Type: INTEGER</P>
218 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700219 public static final String CELLX = "cellX";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800220
221 /**
222 * The Y coordinate of the cell holding the favorite
223 * (if container is CONTAINER_DESKTOP)
224 * <P>Type: INTEGER</P>
225 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700226 public static final String CELLY = "cellY";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800227
228 /**
229 * The X span of the cell holding the favorite
230 * <P>Type: INTEGER</P>
231 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700232 public static final String SPANX = "spanX";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800233
234 /**
235 * The Y span of the cell holding the favorite
236 * <P>Type: INTEGER</P>
237 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700238 public static final String SPANY = "spanY";
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800239
240 /**
Kenny Guyed131872014-04-30 03:02:21 +0100241 * The profile id of the item in the cell.
242 * <P>
243 * Type: INTEGER
244 * </P>
245 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700246 public static final String PROFILE_ID = "profileId";
Kenny Guyed131872014-04-30 03:02:21 +0100247
248 /**
The Android Open Source Project7376fae2009-03-11 12:11:58 -0700249 * The appWidgetId of the widget
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800250 *
251 * <P>Type: INTEGER</P>
252 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700253 public static final String APPWIDGET_ID = "appWidgetId";
Chris Wrend5e66bf2013-09-16 14:02:29 -0400254
255 /**
256 * The ComponentName of the widget provider
257 *
258 * <P>Type: STRING</P>
259 */
260 public static final String APPWIDGET_PROVIDER = "appWidgetProvider";
Chris Wrenf4d08112014-01-16 18:13:56 -0500261
262 /**
263 * Boolean indicating that his item was restored and not yet successfully bound.
264 * <P>Type: INTEGER</P>
265 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700266 public static final String RESTORED = "restored";
Sunny Goyal08f72612015-01-05 13:41:43 -0800267
268 /**
269 * Indicates the position of the item inside an auto-arranged view like folder or hotseat.
270 * <p>Type: INTEGER</p>
271 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700272 public static final String RANK = "rank";
Sunny Goyal5d85c442015-03-10 13:14:47 -0700273
274 /**
275 * Stores general flag based options for {@link ItemInfo}s.
276 * <p>Type: INTEGER</p>
277 */
Sunny Goyal2fb2f0b2015-06-22 13:57:26 -0700278 public static final String OPTIONS = "options";
Sunny Goyalc190dbf2016-05-05 14:37:05 -0700279
Yogisha Dixit658c5da2021-05-24 23:23:15 +0100280 /**
281 * Stores the source container that the widget was added from.
282 * <p>Type: INTEGER</p>
283 */
284 public static final String APPWIDGET_SOURCE = "appWidgetSource";
285
Sunny Goyalc190dbf2016-05-05 14:37:05 -0700286 public static void addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional) {
Sunny Goyal161a2142018-10-29 14:02:20 -0700287 addTableToDb(db, myProfileId, optional, TABLE_NAME);
288 }
289
290 public static void addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional,
291 String tableName) {
Sunny Goyalc190dbf2016-05-05 14:37:05 -0700292 String ifNotExists = optional ? " IF NOT EXISTS " : "";
Sunny Goyal161a2142018-10-29 14:02:20 -0700293 db.execSQL("CREATE TABLE " + ifNotExists + tableName + " (" +
Sunny Goyalc190dbf2016-05-05 14:37:05 -0700294 "_id INTEGER PRIMARY KEY," +
295 "title TEXT," +
296 "intent TEXT," +
297 "container INTEGER," +
298 "screen INTEGER," +
299 "cellX INTEGER," +
300 "cellY INTEGER," +
301 "spanX INTEGER," +
302 "spanY INTEGER," +
303 "itemType INTEGER," +
304 "appWidgetId INTEGER NOT NULL DEFAULT -1," +
Sunny Goyalc190dbf2016-05-05 14:37:05 -0700305 "icon BLOB," +
306 "appWidgetProvider TEXT," +
307 "modified INTEGER NOT NULL DEFAULT 0," +
308 "restored INTEGER NOT NULL DEFAULT 0," +
309 "profileId INTEGER DEFAULT " + myProfileId + "," +
310 "rank INTEGER NOT NULL DEFAULT 0," +
Yogisha Dixit658c5da2021-05-24 23:23:15 +0100311 "options INTEGER NOT NULL DEFAULT 0," +
312 APPWIDGET_SOURCE + " INTEGER NOT NULL DEFAULT " + CONTAINER_UNKNOWN +
Sunny Goyalc190dbf2016-05-05 14:37:05 -0700313 ");");
314 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800315 }
Sunny Goyal7779d622015-06-11 16:18:39 -0700316
317 /**
318 * Launcher settings
319 */
320 public static final class Settings {
Sunny Goyalab2f8082023-04-11 11:35:43 -0700321 public static final String LAYOUT_DIGEST_KEY = "launcher3.layout.provider.blob";
322 public static final String LAYOUT_DIGEST_LABEL = "launcher-layout";
323 public static final String LAYOUT_DIGEST_TAG = "ignore";
Sunny Goyal7779d622015-06-11 16:18:39 -0700324 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800325}