• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.database.sqlite.SQLiteDatabase;
20 import android.provider.BaseColumns;
21 
22 import com.android.launcher3.model.data.ItemInfo;
23 
24 /**
25  * Settings related utilities.
26  */
27 public class LauncherSettings {
28 
29     /**
30      * 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;
41         /**
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;
45     }
46 
47     /**
48      * Favorites.
49      */
50     public static final class Favorites implements BaseColumns {
51         /**
52          * The time of the last update to this row.
53          * <P>Type: INTEGER</P>
54          */
55         public static final String MODIFIED = "modified";
56 
57         /**
58          * Descriptive name of the gesture that can be displayed to the user.
59          * <P>Type: TEXT</P>
60          */
61         public static final String TITLE = "title";
62 
63         /**
64          * The Intent URL of the gesture, describing what it points to. This
65          * value is given to {@link android.content.Intent#parseUri(String, int)} to create
66          * an Intent that can be launched.
67          * <P>Type: TEXT</P>
68          */
69         public static final String INTENT = "intent";
70 
71         /**
72          * The type of the gesture
73          *
74          * <P>Type: INTEGER</P>
75          */
76         public static final String ITEM_TYPE = "itemType";
77 
78         /**
79          * The gesture is a package
80          */
81         public static final int ITEM_TYPE_NON_ACTIONABLE = -1;
82         /**
83          * The gesture is an application
84          */
85         public static final int ITEM_TYPE_APPLICATION = 0;
86 
87         /**
88          * The gesture is an application created shortcut
89          * @deprecated This is no longer supported. Use {@link #ITEM_TYPE_DEEP_SHORTCUT} instead
90          */
91         @Deprecated
92         public static final int ITEM_TYPE_SHORTCUT = 1;
93 
94         /**
95          * 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 
114         /**
115          * The favorite is an app pair for launching split screen
116          */
117         public static final int ITEM_TYPE_APP_PAIR = 10;
118 
119         // *** Below enum values are used for metrics purpose but not used in Favorites DB ***
120 
121         /**
122          * Type of the item is recents task.
123          */
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         /**
132          * The favorite is a search action
133          */
134         public static final int ITEM_TYPE_SEARCH_ACTION = 9;
135 
136         /**
137          * The custom icon bitmap.
138          * <P>Type: BLOB</P>
139          */
140         public static final String ICON = "icon";
141 
142         public static final String TABLE_NAME = "favorites";
143 
144         /**
145          * 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         /**
150          * Temporary table used specifically for multi-db grid migrations
151          */
152         public static final String TMP_TABLE = "favorites_tmp";
153 
154         /**
155          * The container holding the favorite
156          * <P>Type: INTEGER</P>
157          */
158         public static final String CONTAINER = "container";
159 
160         /**
161          * The icon is a resource identified by a package name and an integer id.
162          */
163         public static final int CONTAINER_DESKTOP = -100;
164         public static final int CONTAINER_HOTSEAT = -101;
165         public static final int CONTAINER_PREDICTION = -102;
166         public static final int CONTAINER_WIDGETS_PREDICTION = -111;
167         public static final int CONTAINER_HOTSEAT_PREDICTION = -103;
168         public static final int CONTAINER_ALL_APPS = -104;
169         public static final int CONTAINER_WIDGETS_TRAY = -105;
170         public static final int CONTAINER_BOTTOM_WIDGETS_TRAY = -112;
171         public static final int CONTAINER_PIN_WIDGETS = -113;
172         public static final int CONTAINER_WALLPAPERS = -114;
173         public static final int CONTAINER_SHORTCUTS = -107;
174         public static final int CONTAINER_SETTINGS = -108;
175         public static final int CONTAINER_TASKSWITCHER = -109;
176 
177         // Represents any of the extended containers implemented in non-AOSP variants.
178         public static final int EXTENDED_CONTAINERS = -200;
179 
180         public static final int CONTAINER_UNKNOWN = -1;
181 
containerToString(int container)182         public static final String containerToString(int container) {
183             switch (container) {
184                 case CONTAINER_DESKTOP: return "desktop";
185                 case CONTAINER_HOTSEAT: return "hotseat";
186                 case CONTAINER_PREDICTION: return "prediction";
187                 case CONTAINER_ALL_APPS: return "all_apps";
188                 case CONTAINER_WIDGETS_TRAY: return "widgets_tray";
189                 case CONTAINER_SHORTCUTS: return "shortcuts";
190                 default: return String.valueOf(container);
191             }
192         }
193 
itemTypeToString(int type)194         public static final String itemTypeToString(int type) {
195             switch(type) {
196                 case ITEM_TYPE_APPLICATION: return "APP";
197                 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";
201                 case ITEM_TYPE_TASK: return "TASK";
202                 case ITEM_TYPE_QSB: return "QSB";
203                 case ITEM_TYPE_APP_PAIR: return "APP_PAIR";
204                 default: return String.valueOf(type);
205             }
206         }
207 
208         /**
209          * The screen holding the favorite (if container is CONTAINER_DESKTOP)
210          * <P>Type: INTEGER</P>
211          */
212         public static final String SCREEN = "screen";
213 
214         /**
215          * The X coordinate of the cell holding the favorite
216          * (if container is CONTAINER_HOTSEAT or CONTAINER_HOTSEAT)
217          * <P>Type: INTEGER</P>
218          */
219         public static final String CELLX = "cellX";
220 
221         /**
222          * The Y coordinate of the cell holding the favorite
223          * (if container is CONTAINER_DESKTOP)
224          * <P>Type: INTEGER</P>
225          */
226         public static final String CELLY = "cellY";
227 
228         /**
229          * The X span of the cell holding the favorite
230          * <P>Type: INTEGER</P>
231          */
232         public static final String SPANX = "spanX";
233 
234         /**
235          * The Y span of the cell holding the favorite
236          * <P>Type: INTEGER</P>
237          */
238         public static final String SPANY = "spanY";
239 
240         /**
241          * The profile id of the item in the cell.
242          * <P>
243          * Type: INTEGER
244          * </P>
245          */
246         public static final String PROFILE_ID = "profileId";
247 
248         /**
249          * The appWidgetId of the widget
250          *
251          * <P>Type: INTEGER</P>
252          */
253         public static final String APPWIDGET_ID = "appWidgetId";
254 
255         /**
256          * The ComponentName of the widget provider
257          *
258          * <P>Type: STRING</P>
259          */
260         public static final String APPWIDGET_PROVIDER = "appWidgetProvider";
261 
262         /**
263          * Boolean indicating that his item was restored and not yet successfully bound.
264          * <P>Type: INTEGER</P>
265          */
266         public static final String RESTORED = "restored";
267 
268         /**
269          * Indicates the position of the item inside an auto-arranged view like folder or hotseat.
270          * <p>Type: INTEGER</p>
271          */
272         public static final String RANK = "rank";
273 
274         /**
275          * Stores general flag based options for {@link ItemInfo}s.
276          * <p>Type: INTEGER</p>
277          */
278         public static final String OPTIONS = "options";
279 
280         /**
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 
addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional)286         public static void addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional) {
287             addTableToDb(db, myProfileId, optional, TABLE_NAME);
288         }
289 
addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional, String tableName)290         public static void addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional,
291                 String tableName) {
292             String ifNotExists = optional ? " IF NOT EXISTS " : "";
293             db.execSQL("CREATE TABLE " + ifNotExists + tableName + " (" +
294                     "_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," +
305                     "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," +
311                     "options INTEGER NOT NULL DEFAULT 0," +
312                     APPWIDGET_SOURCE + " INTEGER NOT NULL DEFAULT " + CONTAINER_UNKNOWN +
313                     ");");
314         }
315     }
316 
317     /**
318      * Launcher settings
319      */
320     public static final class Settings {
321         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";
324     }
325 }
326