The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 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 | |
Daniel Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 19 | import android.content.ContentResolver; |
Sunny Goyal | c190dbf | 2016-05-05 14:37:05 -0700 | [diff] [blame] | 20 | import android.database.sqlite.SQLiteDatabase; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 21 | import android.net.Uri; |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 22 | import android.os.Bundle; |
Adam Cohen | df2cc41 | 2011-04-27 16:56:57 -0700 | [diff] [blame] | 23 | import android.provider.BaseColumns; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 24 | |
Sunny Goyal | e396abf | 2020-04-06 15:11:17 -0700 | [diff] [blame] | 25 | import com.android.launcher3.model.data.ItemInfo; |
| 26 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 27 | /** |
| 28 | * Settings related utilities. |
| 29 | */ |
Hyunyoung Song | 3f47144 | 2015-04-08 19:01:34 -0700 | [diff] [blame] | 30 | public class LauncherSettings { |
Sunny Goyal | c593939 | 2018-12-07 11:43:47 -0800 | [diff] [blame] | 31 | |
| 32 | /** |
Luca Zuccarini | 2098381 | 2023-01-03 14:19:48 +0000 | [diff] [blame] | 33 | * Types of animations. |
| 34 | */ |
| 35 | public static final class Animation { |
| 36 | /** |
| 37 | * The default animation for a given view/item info type. |
| 38 | */ |
| 39 | public static final int DEFAULT = 0; |
| 40 | /** |
| 41 | * An animation using the view's background. |
| 42 | */ |
| 43 | public static final int VIEW_BACKGROUND = 1; |
Hyunyoung Song | a38aab9 | 2023-03-14 07:56:59 +0000 | [diff] [blame] | 44 | /** |
| 45 | * The default animation for a given view/item info type, but without the splash icon. |
| 46 | */ |
| 47 | public static final int DEFAULT_NO_ICON = 2; |
Luca Zuccarini | 2098381 | 2023-01-03 14:19:48 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /** |
Sunny Goyal | c593939 | 2018-12-07 11:43:47 -0800 | [diff] [blame] | 51 | * Favorites. |
| 52 | */ |
| 53 | public static final class Favorites implements BaseColumns { |
Chris Wren | 1ada10d | 2013-09-13 18:01:38 -0400 | [diff] [blame] | 54 | /** |
| 55 | * The time of the last update to this row. |
| 56 | * <P>Type: INTEGER</P> |
| 57 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 58 | public static final String MODIFIED = "modified"; |
Chris Wren | 1ada10d | 2013-09-13 18:01:38 -0400 | [diff] [blame] | 59 | |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 60 | /** |
| 61 | * Descriptive name of the gesture that can be displayed to the user. |
| 62 | * <P>Type: TEXT</P> |
| 63 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 64 | public static final String TITLE = "title"; |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * The Intent URL of the gesture, describing what it points to. This |
Romain Guy | 1ce1a24 | 2009-06-23 17:34:54 -0700 | [diff] [blame] | 68 | * value is given to {@link android.content.Intent#parseUri(String, int)} to create |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 69 | * an Intent that can be launched. |
| 70 | * <P>Type: TEXT</P> |
| 71 | */ |
Sunny Goyal | 18b640c | 2015-04-17 09:24:01 -0700 | [diff] [blame] | 72 | public static final String INTENT = "intent"; |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * The type of the gesture |
| 76 | * |
| 77 | * <P>Type: INTEGER</P> |
| 78 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 79 | public static final String ITEM_TYPE = "itemType"; |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
Samuel Fufa | d3720c2 | 2019-09-06 11:25:08 -0700 | [diff] [blame] | 82 | * The gesture is a package |
| 83 | */ |
| 84 | public static final int ITEM_TYPE_NON_ACTIONABLE = -1; |
| 85 | /** |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 86 | * The gesture is an application |
| 87 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 88 | public static final int ITEM_TYPE_APPLICATION = 0; |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * The gesture is an application created shortcut |
| 92 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 93 | public static final int ITEM_TYPE_SHORTCUT = 1; |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
Andy Wickham | 19ab177 | 2021-02-10 21:36:51 -0800 | [diff] [blame] | 96 | * The favorite is a user created folder |
| 97 | */ |
| 98 | public static final int ITEM_TYPE_FOLDER = 2; |
| 99 | |
| 100 | /** |
| 101 | * The favorite is a widget |
| 102 | */ |
| 103 | public static final int ITEM_TYPE_APPWIDGET = 4; |
| 104 | |
| 105 | /** |
| 106 | * The favorite is a custom widget provided by the launcher |
| 107 | */ |
| 108 | public static final int ITEM_TYPE_CUSTOM_APPWIDGET = 5; |
| 109 | |
| 110 | /** |
| 111 | * The gesture is an application created deep shortcut |
| 112 | */ |
| 113 | public static final int ITEM_TYPE_DEEP_SHORTCUT = 6; |
| 114 | |
Jeremy Sim | 7cf0dd9 | 2023-03-24 22:39:45 -0700 | [diff] [blame] | 115 | /** |
| 116 | * The favorite is an app pair for launching split screen |
| 117 | */ |
| 118 | public static final int ITEM_TYPE_APP_PAIR = 10; |
sfufa@google.com | ca76de0 | 2021-09-24 08:55:48 -0700 | [diff] [blame] | 119 | |
Andy Wickham | 9345681 | 2022-10-05 17:58:45 -0700 | [diff] [blame] | 120 | // *** Below enum values are used for metrics purpose but not used in Favorites DB *** |
sfufa@google.com | ca76de0 | 2021-09-24 08:55:48 -0700 | [diff] [blame] | 121 | |
| 122 | /** |
Andy Wickham | 19ab177 | 2021-02-10 21:36:51 -0800 | [diff] [blame] | 123 | * Type of the item is recents task. |
Andy Wickham | 19ab177 | 2021-02-10 21:36:51 -0800 | [diff] [blame] | 124 | */ |
| 125 | public static final int ITEM_TYPE_TASK = 7; |
| 126 | |
| 127 | /** |
| 128 | * The item is QSB |
| 129 | */ |
| 130 | public static final int ITEM_TYPE_QSB = 8; |
| 131 | |
| 132 | /** |
Andy Wickham | 9345681 | 2022-10-05 17:58:45 -0700 | [diff] [blame] | 133 | * The favorite is a search action |
| 134 | */ |
| 135 | public static final int ITEM_TYPE_SEARCH_ACTION = 9; |
| 136 | |
| 137 | /** |
Sunny Goyal | eb4b799 | 2016-04-21 14:30:18 -0700 | [diff] [blame] | 138 | * The custom icon bitmap. |
Romain Guy | 73b979d | 2009-06-09 12:57:21 -0700 | [diff] [blame] | 139 | * <P>Type: BLOB</P> |
| 140 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 141 | public static final String ICON = "icon"; |
Sunny Goyal | 18b640c | 2015-04-17 09:24:01 -0700 | [diff] [blame] | 142 | |
| 143 | public static final String TABLE_NAME = "favorites"; |
| 144 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 145 | /** |
Samuel Fufa | f667a13 | 2020-05-29 14:47:42 -0700 | [diff] [blame] | 146 | * Backup table created when user hotseat is moved to workspace for hybrid hotseat |
| 147 | */ |
| 148 | public static final String HYBRID_HOTSEAT_BACKUP_TABLE = "hotseat_restore_backup"; |
| 149 | |
| 150 | /** |
Tracy Zhou | f601872 | 2020-02-06 16:37:16 -0800 | [diff] [blame] | 151 | * Temporary table used specifically for multi-db grid migrations |
| 152 | */ |
| 153 | public static final String TMP_TABLE = "favorites_tmp"; |
| 154 | |
| 155 | /** |
Tracy Zhou | be13d10 | 2020-01-12 01:07:59 -0800 | [diff] [blame] | 156 | * The content:// style URL for "favorites" table |
| 157 | */ |
| 158 | public static final Uri CONTENT_URI = Uri.parse("content://" |
| 159 | + LauncherProvider.AUTHORITY + "/" + TABLE_NAME); |
| 160 | |
| 161 | /** |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 162 | * The content:// style URL for a given row, identified by its id. |
| 163 | * |
| 164 | * @param id The row id. |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 165 | * |
| 166 | * @return The unique content URL for the specified row. |
| 167 | */ |
Sunny Goyal | efb7e84 | 2018-10-04 15:11:00 -0700 | [diff] [blame] | 168 | public static Uri getContentUri(int id) { |
Tracy Zhou | be13d10 | 2020-01-12 01:07:59 -0800 | [diff] [blame] | 169 | return Uri.parse("content://" + LauncherProvider.AUTHORITY |
| 170 | + "/" + TABLE_NAME + "/" + id); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /** |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 174 | * The container holding the favorite |
| 175 | * <P>Type: INTEGER</P> |
| 176 | */ |
Sunny Goyal | 18b640c | 2015-04-17 09:24:01 -0700 | [diff] [blame] | 177 | public static final String CONTAINER = "container"; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 178 | |
| 179 | /** |
| 180 | * The icon is a resource identified by a package name and an integer id. |
| 181 | */ |
Sunny Goyal | 18b640c | 2015-04-17 09:24:01 -0700 | [diff] [blame] | 182 | public static final int CONTAINER_DESKTOP = -100; |
| 183 | public static final int CONTAINER_HOTSEAT = -101; |
Samuel Fufa | 866ff00 | 2019-08-09 16:16:06 -0700 | [diff] [blame] | 184 | public static final int CONTAINER_PREDICTION = -102; |
Steven Ng | 3a83532 | 2021-03-02 21:26:00 +0000 | [diff] [blame] | 185 | public static final int CONTAINER_WIDGETS_PREDICTION = -111; |
Samuel Fufa | 225ac27 | 2019-10-21 02:02:40 -0700 | [diff] [blame] | 186 | public static final int CONTAINER_HOTSEAT_PREDICTION = -103; |
thiruram | 261c3a6 | 2020-04-29 16:23:15 -0700 | [diff] [blame] | 187 | public static final int CONTAINER_ALL_APPS = -104; |
thiruram | 6bf6848 | 2020-05-06 22:19:43 -0700 | [diff] [blame] | 188 | public static final int CONTAINER_WIDGETS_TRAY = -105; |
Yogisha Dixit | 658c5da | 2021-05-24 23:23:15 +0100 | [diff] [blame] | 189 | public static final int CONTAINER_BOTTOM_WIDGETS_TRAY = -112; |
| 190 | public static final int CONTAINER_PIN_WIDGETS = -113; |
Brian Isganitis | f0ca4ae | 2021-09-02 16:08:29 -0400 | [diff] [blame] | 191 | public static final int CONTAINER_WALLPAPERS = -114; |
thiruram | 63bf8ee | 2020-06-01 12:03:19 -0700 | [diff] [blame] | 192 | public static final int CONTAINER_SHORTCUTS = -107; |
Hyunyoung Song | f26c793 | 2020-06-06 14:44:27 -0700 | [diff] [blame] | 193 | public static final int CONTAINER_SETTINGS = -108; |
Hyunyoung Song | 13c2bc7 | 2020-06-10 00:35:35 -0700 | [diff] [blame] | 194 | public static final int CONTAINER_TASKSWITCHER = -109; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 195 | |
thiruram | 73821a9 | 2021-02-05 17:50:37 -0800 | [diff] [blame] | 196 | // Represents any of the extended containers implemented in non-AOSP variants. |
| 197 | public static final int EXTENDED_CONTAINERS = -200; |
| 198 | |
Yogisha Dixit | 658c5da | 2021-05-24 23:23:15 +0100 | [diff] [blame] | 199 | public static final int CONTAINER_UNKNOWN = -1; |
| 200 | |
Sunny Goyal | e396abf | 2020-04-06 15:11:17 -0700 | [diff] [blame] | 201 | public static final String containerToString(int container) { |
Dan Sandler | ab5fa3a | 2014-03-06 23:48:04 -0500 | [diff] [blame] | 202 | switch (container) { |
| 203 | case CONTAINER_DESKTOP: return "desktop"; |
| 204 | case CONTAINER_HOTSEAT: return "hotseat"; |
Samuel Fufa | 866ff00 | 2019-08-09 16:16:06 -0700 | [diff] [blame] | 205 | case CONTAINER_PREDICTION: return "prediction"; |
thiruram | 6bf6848 | 2020-05-06 22:19:43 -0700 | [diff] [blame] | 206 | case CONTAINER_ALL_APPS: return "all_apps"; |
| 207 | case CONTAINER_WIDGETS_TRAY: return "widgets_tray"; |
thiruram | 63bf8ee | 2020-06-01 12:03:19 -0700 | [diff] [blame] | 208 | case CONTAINER_SHORTCUTS: return "shortcuts"; |
Dan Sandler | ab5fa3a | 2014-03-06 23:48:04 -0500 | [diff] [blame] | 209 | default: return String.valueOf(container); |
| 210 | } |
| 211 | } |
| 212 | |
Sunny Goyal | e396abf | 2020-04-06 15:11:17 -0700 | [diff] [blame] | 213 | public static final String itemTypeToString(int type) { |
Hyunyoung Song | 86160f5 | 2017-02-06 10:46:24 -0800 | [diff] [blame] | 214 | switch(type) { |
| 215 | case ITEM_TYPE_APPLICATION: return "APP"; |
| 216 | case ITEM_TYPE_SHORTCUT: return "SHORTCUT"; |
| 217 | case ITEM_TYPE_FOLDER: return "FOLDER"; |
| 218 | case ITEM_TYPE_APPWIDGET: return "WIDGET"; |
| 219 | case ITEM_TYPE_CUSTOM_APPWIDGET: return "CUSTOMWIDGET"; |
| 220 | case ITEM_TYPE_DEEP_SHORTCUT: return "DEEPSHORTCUT"; |
Andy Wickham | 19ab177 | 2021-02-10 21:36:51 -0800 | [diff] [blame] | 221 | case ITEM_TYPE_TASK: return "TASK"; |
| 222 | case ITEM_TYPE_QSB: return "QSB"; |
Jeremy Sim | 7cf0dd9 | 2023-03-24 22:39:45 -0700 | [diff] [blame] | 223 | case ITEM_TYPE_APP_PAIR: return "APP_PAIR"; |
Hyunyoung Song | 86160f5 | 2017-02-06 10:46:24 -0800 | [diff] [blame] | 224 | default: return String.valueOf(type); |
| 225 | } |
| 226 | } |
| 227 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 228 | /** |
| 229 | * The screen holding the favorite (if container is CONTAINER_DESKTOP) |
| 230 | * <P>Type: INTEGER</P> |
| 231 | */ |
Sunny Goyal | 18b640c | 2015-04-17 09:24:01 -0700 | [diff] [blame] | 232 | public static final String SCREEN = "screen"; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 233 | |
| 234 | /** |
| 235 | * The X coordinate of the cell holding the favorite |
Adam Cohen | c51934b | 2011-07-26 21:07:43 -0700 | [diff] [blame] | 236 | * (if container is CONTAINER_HOTSEAT or CONTAINER_HOTSEAT) |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 237 | * <P>Type: INTEGER</P> |
| 238 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 239 | public static final String CELLX = "cellX"; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 240 | |
| 241 | /** |
| 242 | * The Y coordinate of the cell holding the favorite |
| 243 | * (if container is CONTAINER_DESKTOP) |
| 244 | * <P>Type: INTEGER</P> |
| 245 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 246 | public static final String CELLY = "cellY"; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 247 | |
| 248 | /** |
| 249 | * The X span of the cell holding the favorite |
| 250 | * <P>Type: INTEGER</P> |
| 251 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 252 | public static final String SPANX = "spanX"; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 253 | |
| 254 | /** |
| 255 | * The Y span of the cell holding the favorite |
| 256 | * <P>Type: INTEGER</P> |
| 257 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 258 | public static final String SPANY = "spanY"; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 259 | |
| 260 | /** |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 261 | * The profile id of the item in the cell. |
| 262 | * <P> |
| 263 | * Type: INTEGER |
| 264 | * </P> |
| 265 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 266 | public static final String PROFILE_ID = "profileId"; |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 267 | |
| 268 | /** |
The Android Open Source Project | 7376fae | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 269 | * The appWidgetId of the widget |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 270 | * |
| 271 | * <P>Type: INTEGER</P> |
| 272 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 273 | public static final String APPWIDGET_ID = "appWidgetId"; |
Chris Wren | d5e66bf | 2013-09-16 14:02:29 -0400 | [diff] [blame] | 274 | |
| 275 | /** |
| 276 | * The ComponentName of the widget provider |
| 277 | * |
| 278 | * <P>Type: STRING</P> |
| 279 | */ |
| 280 | public static final String APPWIDGET_PROVIDER = "appWidgetProvider"; |
Chris Wren | f4d0811 | 2014-01-16 18:13:56 -0500 | [diff] [blame] | 281 | |
| 282 | /** |
| 283 | * Boolean indicating that his item was restored and not yet successfully bound. |
| 284 | * <P>Type: INTEGER</P> |
| 285 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 286 | public static final String RESTORED = "restored"; |
Sunny Goyal | 08f7261 | 2015-01-05 13:41:43 -0800 | [diff] [blame] | 287 | |
| 288 | /** |
| 289 | * Indicates the position of the item inside an auto-arranged view like folder or hotseat. |
| 290 | * <p>Type: INTEGER</p> |
| 291 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 292 | public static final String RANK = "rank"; |
Sunny Goyal | 5d85c44 | 2015-03-10 13:14:47 -0700 | [diff] [blame] | 293 | |
| 294 | /** |
| 295 | * Stores general flag based options for {@link ItemInfo}s. |
| 296 | * <p>Type: INTEGER</p> |
| 297 | */ |
Sunny Goyal | 2fb2f0b | 2015-06-22 13:57:26 -0700 | [diff] [blame] | 298 | public static final String OPTIONS = "options"; |
Sunny Goyal | c190dbf | 2016-05-05 14:37:05 -0700 | [diff] [blame] | 299 | |
Yogisha Dixit | 658c5da | 2021-05-24 23:23:15 +0100 | [diff] [blame] | 300 | /** |
| 301 | * Stores the source container that the widget was added from. |
| 302 | * <p>Type: INTEGER</p> |
| 303 | */ |
| 304 | public static final String APPWIDGET_SOURCE = "appWidgetSource"; |
| 305 | |
Sunny Goyal | c190dbf | 2016-05-05 14:37:05 -0700 | [diff] [blame] | 306 | public static void addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional) { |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 307 | addTableToDb(db, myProfileId, optional, TABLE_NAME); |
| 308 | } |
| 309 | |
| 310 | public static void addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional, |
| 311 | String tableName) { |
Sunny Goyal | c190dbf | 2016-05-05 14:37:05 -0700 | [diff] [blame] | 312 | String ifNotExists = optional ? " IF NOT EXISTS " : ""; |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 313 | db.execSQL("CREATE TABLE " + ifNotExists + tableName + " (" + |
Sunny Goyal | c190dbf | 2016-05-05 14:37:05 -0700 | [diff] [blame] | 314 | "_id INTEGER PRIMARY KEY," + |
| 315 | "title TEXT," + |
| 316 | "intent TEXT," + |
| 317 | "container INTEGER," + |
| 318 | "screen INTEGER," + |
| 319 | "cellX INTEGER," + |
| 320 | "cellY INTEGER," + |
| 321 | "spanX INTEGER," + |
| 322 | "spanY INTEGER," + |
| 323 | "itemType INTEGER," + |
| 324 | "appWidgetId INTEGER NOT NULL DEFAULT -1," + |
Sunny Goyal | c190dbf | 2016-05-05 14:37:05 -0700 | [diff] [blame] | 325 | "icon BLOB," + |
| 326 | "appWidgetProvider TEXT," + |
| 327 | "modified INTEGER NOT NULL DEFAULT 0," + |
| 328 | "restored INTEGER NOT NULL DEFAULT 0," + |
| 329 | "profileId INTEGER DEFAULT " + myProfileId + "," + |
| 330 | "rank INTEGER NOT NULL DEFAULT 0," + |
Yogisha Dixit | 658c5da | 2021-05-24 23:23:15 +0100 | [diff] [blame] | 331 | "options INTEGER NOT NULL DEFAULT 0," + |
| 332 | APPWIDGET_SOURCE + " INTEGER NOT NULL DEFAULT " + CONTAINER_UNKNOWN + |
Sunny Goyal | c190dbf | 2016-05-05 14:37:05 -0700 | [diff] [blame] | 333 | ");"); |
| 334 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 335 | } |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 336 | |
| 337 | /** |
| 338 | * Launcher settings |
| 339 | */ |
| 340 | public static final class Settings { |
| 341 | |
| 342 | public static final Uri CONTENT_URI = Uri.parse("content://" + |
Sunny Goyal | 3d706ad | 2017-03-06 16:56:39 -0800 | [diff] [blame] | 343 | LauncherProvider.AUTHORITY + "/settings"); |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 344 | |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 345 | public static final String METHOD_CLEAR_EMPTY_DB_FLAG = "clear_empty_db_flag"; |
| 346 | |
| 347 | public static final String METHOD_DELETE_EMPTY_FOLDERS = "delete_empty_folders"; |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 348 | |
| 349 | public static final String METHOD_NEW_ITEM_ID = "generate_new_item_id"; |
| 350 | public static final String METHOD_NEW_SCREEN_ID = "generate_new_screen_id"; |
| 351 | |
| 352 | public static final String METHOD_CREATE_EMPTY_DB = "create_empty_db"; |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 353 | |
| 354 | public static final String METHOD_LOAD_DEFAULT_FAVORITES = "load_default_favorites"; |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 355 | |
Sunny Goyal | 55fddc8 | 2017-04-06 15:02:52 -0700 | [diff] [blame] | 356 | public static final String METHOD_REMOVE_GHOST_WIDGETS = "remove_ghost_widgets"; |
| 357 | |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 358 | public static final String METHOD_NEW_TRANSACTION = "new_db_transaction"; |
| 359 | |
Samuel Fufa | f667a13 | 2020-05-29 14:47:42 -0700 | [diff] [blame] | 360 | public static final String METHOD_REFRESH_HOTSEAT_RESTORE_TABLE = "restore_hotseat_table"; |
| 361 | |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 362 | public static final String EXTRA_VALUE = "value"; |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 363 | |
Pinyao Ting | 702ed27 | 2020-10-14 11:17:04 -0700 | [diff] [blame] | 364 | public static final String EXTRA_DB_NAME = "db_name"; |
| 365 | |
Sunny Goyal | ab2f808 | 2023-04-11 11:35:43 -0700 | [diff] [blame] | 366 | public static final String LAYOUT_DIGEST_KEY = "launcher3.layout.provider.blob"; |
| 367 | public static final String LAYOUT_DIGEST_LABEL = "launcher-layout"; |
| 368 | public static final String LAYOUT_DIGEST_TAG = "ignore"; |
| 369 | |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 370 | public static Bundle call(ContentResolver cr, String method) { |
Pinyao Ting | 96186af | 2020-07-20 11:03:39 -0700 | [diff] [blame] | 371 | return call(cr, method, null /* arg */); |
Tracy Zhou | c000045 | 2020-03-17 18:28:38 -0700 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | public static Bundle call(ContentResolver cr, String method, String arg) { |
Sunny Goyal | 7bc6cde | 2023-05-12 23:07:25 +0000 | [diff] [blame] | 375 | return cr.call(CONTENT_URI, method, arg, null); |
Pinyao Ting | 96186af | 2020-07-20 11:03:39 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 378 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 379 | } |