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