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