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 17 package com.android.launcher3; 18 19 import android.net.Uri; 20 import android.provider.BaseColumns; 21 22 import com.android.launcher3.config.ProviderConfig; 23 24 /** 25 * Settings related utilities. 26 */ 27 public class LauncherSettings { 28 /** Columns required on table staht will be subject to backup and restore. */ 29 static interface ChangeLogColumns extends BaseColumns { 30 /** 31 * The time of the last update to this row. 32 * <P>Type: INTEGER</P> 33 */ 34 public static final String MODIFIED = "modified"; 35 } 36 37 static interface BaseLauncherColumns extends ChangeLogColumns { 38 /** 39 * Descriptive name of the gesture that can be displayed to the user. 40 * <P>Type: TEXT</P> 41 */ 42 public static final String TITLE = "title"; 43 44 /** 45 * The Intent URL of the gesture, describing what it points to. This 46 * value is given to {@link android.content.Intent#parseUri(String, int)} to create 47 * an Intent that can be launched. 48 * <P>Type: TEXT</P> 49 */ 50 public static final String INTENT = "intent"; 51 52 /** 53 * The type of the gesture 54 * 55 * <P>Type: INTEGER</P> 56 */ 57 public static final String ITEM_TYPE = "itemType"; 58 59 /** 60 * The gesture is an application 61 */ 62 public static final int ITEM_TYPE_APPLICATION = 0; 63 64 /** 65 * The gesture is an application created shortcut 66 */ 67 public static final int ITEM_TYPE_SHORTCUT = 1; 68 69 /** 70 * The icon type. 71 * <P>Type: INTEGER</P> 72 */ 73 public static final String ICON_TYPE = "iconType"; 74 75 /** 76 * The icon is a resource identified by a package name and an integer id. 77 */ 78 public static final int ICON_TYPE_RESOURCE = 0; 79 80 /** 81 * The icon is a bitmap. 82 */ 83 public static final int ICON_TYPE_BITMAP = 1; 84 85 /** 86 * The icon package name, if icon type is ICON_TYPE_RESOURCE. 87 * <P>Type: TEXT</P> 88 */ 89 public static final String ICON_PACKAGE = "iconPackage"; 90 91 /** 92 * The icon resource id, if icon type is ICON_TYPE_RESOURCE. 93 * <P>Type: TEXT</P> 94 */ 95 public static final String ICON_RESOURCE = "iconResource"; 96 97 /** 98 * The custom icon bitmap, if icon type is ICON_TYPE_BITMAP. 99 * <P>Type: BLOB</P> 100 */ 101 public static final String ICON = "icon"; 102 } 103 104 /** 105 * Workspace Screens. 106 * 107 * Tracks the order of workspace screens. 108 */ 109 public static final class WorkspaceScreens implements ChangeLogColumns { 110 111 public static final String TABLE_NAME = "workspaceScreens"; 112 113 /** 114 * The content:// style URL for this table 115 */ 116 public static final Uri CONTENT_URI = Uri.parse("content://" + 117 ProviderConfig.AUTHORITY + "/" + TABLE_NAME); 118 119 /** 120 * The rank of this screen -- ie. how it is ordered relative to the other screens. 121 * <P>Type: INTEGER</P> 122 */ 123 public static final String SCREEN_RANK = "screenRank"; 124 } 125 126 /** 127 * Favorites. 128 */ 129 public static final class Favorites implements BaseLauncherColumns { 130 131 public static final String TABLE_NAME = "favorites"; 132 133 /** 134 * The content:// style URL for this table 135 */ 136 public static final Uri CONTENT_URI = Uri.parse("content://" + 137 ProviderConfig.AUTHORITY + "/" + TABLE_NAME); 138 139 /** 140 * The content:// style URL for a given row, identified by its id. 141 * 142 * @param id The row id. 143 * 144 * @return The unique content URL for the specified row. 145 */ getContentUri(long id)146 public static Uri getContentUri(long id) { 147 return Uri.parse("content://" + ProviderConfig.AUTHORITY + 148 "/" + TABLE_NAME + "/" + id); 149 } 150 151 /** 152 * The container holding the favorite 153 * <P>Type: INTEGER</P> 154 */ 155 public static final String CONTAINER = "container"; 156 157 /** 158 * The icon is a resource identified by a package name and an integer id. 159 */ 160 public static final int CONTAINER_DESKTOP = -100; 161 public static final int CONTAINER_HOTSEAT = -101; 162 containerToString(int container)163 static final String containerToString(int container) { 164 switch (container) { 165 case CONTAINER_DESKTOP: return "desktop"; 166 case CONTAINER_HOTSEAT: return "hotseat"; 167 default: return String.valueOf(container); 168 } 169 } 170 171 /** 172 * The screen holding the favorite (if container is CONTAINER_DESKTOP) 173 * <P>Type: INTEGER</P> 174 */ 175 public static final String SCREEN = "screen"; 176 177 /** 178 * The X coordinate of the cell holding the favorite 179 * (if container is CONTAINER_HOTSEAT or CONTAINER_HOTSEAT) 180 * <P>Type: INTEGER</P> 181 */ 182 public static final String CELLX = "cellX"; 183 184 /** 185 * The Y coordinate of the cell holding the favorite 186 * (if container is CONTAINER_DESKTOP) 187 * <P>Type: INTEGER</P> 188 */ 189 public static final String CELLY = "cellY"; 190 191 /** 192 * The X span of the cell holding the favorite 193 * <P>Type: INTEGER</P> 194 */ 195 public static final String SPANX = "spanX"; 196 197 /** 198 * The Y span of the cell holding the favorite 199 * <P>Type: INTEGER</P> 200 */ 201 public static final String SPANY = "spanY"; 202 203 /** 204 * The profile id of the item in the cell. 205 * <P> 206 * Type: INTEGER 207 * </P> 208 */ 209 public static final String PROFILE_ID = "profileId"; 210 211 /** 212 * The favorite is a user created folder 213 */ 214 public static final int ITEM_TYPE_FOLDER = 2; 215 216 /** 217 * The favorite is a live folder 218 * 219 * Note: live folders can no longer be added to Launcher, and any live folders which 220 * exist within the launcher database will be ignored when loading. That said, these 221 * entries in the database may still exist, and are not automatically stripped. 222 */ 223 @Deprecated 224 static final int ITEM_TYPE_LIVE_FOLDER = 3; 225 226 /** 227 * The favorite is a widget 228 */ 229 public static final int ITEM_TYPE_APPWIDGET = 4; 230 231 /** 232 * The favorite is a custom widget provided by the launcher 233 */ 234 public static final int ITEM_TYPE_CUSTOM_APPWIDGET = 5; 235 236 /** 237 * The favorite is a clock 238 */ 239 @Deprecated 240 static final int ITEM_TYPE_WIDGET_CLOCK = 1000; 241 242 /** 243 * The favorite is a search widget 244 */ 245 @Deprecated 246 static final int ITEM_TYPE_WIDGET_SEARCH = 1001; 247 248 /** 249 * The favorite is a photo frame 250 */ 251 @Deprecated 252 static final int ITEM_TYPE_WIDGET_PHOTO_FRAME = 1002; 253 254 /** 255 * The appWidgetId of the widget 256 * 257 * <P>Type: INTEGER</P> 258 */ 259 public static final String APPWIDGET_ID = "appWidgetId"; 260 261 /** 262 * The ComponentName of the widget provider 263 * 264 * <P>Type: STRING</P> 265 */ 266 public static final String APPWIDGET_PROVIDER = "appWidgetProvider"; 267 268 /** 269 * Indicates whether this favorite is an application-created shortcut or not. 270 * If the value is 0, the favorite is not an application-created shortcut, if the 271 * value is 1, it is an application-created shortcut. 272 * <P>Type: INTEGER</P> 273 */ 274 @Deprecated 275 static final String IS_SHORTCUT = "isShortcut"; 276 277 /** 278 * The URI associated with the favorite. It is used, for instance, by 279 * live folders to find the content provider. 280 * <P>Type: TEXT</P> 281 */ 282 @Deprecated 283 static final String URI = "uri"; 284 285 /** 286 * The display mode if the item is a live folder. 287 * <P>Type: INTEGER</P> 288 * 289 * @see android.provider.LiveFolders#DISPLAY_MODE_GRID 290 * @see android.provider.LiveFolders#DISPLAY_MODE_LIST 291 */ 292 @Deprecated 293 static final String DISPLAY_MODE = "displayMode"; 294 295 /** 296 * Boolean indicating that his item was restored and not yet successfully bound. 297 * <P>Type: INTEGER</P> 298 */ 299 public static final String RESTORED = "restored"; 300 301 /** 302 * Indicates the position of the item inside an auto-arranged view like folder or hotseat. 303 * <p>Type: INTEGER</p> 304 */ 305 public static final String RANK = "rank"; 306 307 /** 308 * Stores general flag based options for {@link ItemInfo}s. 309 * <p>Type: INTEGER</p> 310 */ 311 public static final String OPTIONS = "options"; 312 } 313 314 /** 315 * Launcher settings 316 */ 317 public static final class Settings { 318 319 public static final Uri CONTENT_URI = Uri.parse("content://" + 320 ProviderConfig.AUTHORITY + "/settings"); 321 322 public static final String METHOD_GET_BOOLEAN = "get_boolean_setting"; 323 public static final String METHOD_SET_BOOLEAN = "set_boolean_setting"; 324 325 public static final String EXTRA_VALUE = "value"; 326 public static final String EXTRA_DEFAULT_VALUE = "default_value"; 327 328 // Extra for set_boolean method to also notify the backup manager of the change. 329 public static final String NOTIFY_BACKUP = "notify_backup"; 330 } 331 } 332