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