summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-11-16 18:43:26 -0800
committerWinson Chung <winsonc@google.com>2011-11-16 18:43:26 -0800
commit6d09268cdef87be5686e541ba25148c7d72e0d59 (patch)
treeeb3bd5522a352ed24593644efb02accc02a78fdd
parentc97ddb679c7b2eaec78f136d840ad7975d03002f (diff)
downloadandroid_packages_apps_Trebuchet-6d09268cdef87be5686e541ba25148c7d72e0d59.tar.gz
android_packages_apps_Trebuchet-6d09268cdef87be5686e541ba25148c7d72e0d59.tar.bz2
android_packages_apps_Trebuchet-6d09268cdef87be5686e541ba25148c7d72e0d59.zip
Updating default workspace and fixing issue where new hotseat browser icon is not shown. (Bug 5478946, Bug 5623287)
Change-Id: I7ebac3a4bde868de2b5beacc95fc94302dc0d6ee
-rw-r--r--res/xml/update_workspace.xml49
-rw-r--r--src/com/android/launcher2/LauncherProvider.java165
2 files changed, 131 insertions, 83 deletions
diff --git a/res/xml/update_workspace.xml b/res/xml/update_workspace.xml
new file mode 100644
index 000000000..44a3f9efa
--- /dev/null
+++ b/res/xml/update_workspace.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<favorites xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher">
+ <!-- Update the db with new hotseat items. Note that we reference the browser's original
+ package name. -->
+ <!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
+ <favorite
+ launcher:packageName="com.android.contacts"
+ launcher:className="com.android.contacts.activities.DialtactsActivity"
+ launcher:container="-101"
+ launcher:screen="0"
+ launcher:x="0"
+ launcher:y="0" />
+ <favorite
+ launcher:packageName="com.android.contacts"
+ launcher:className="com.android.contacts.activities.PeopleActivity"
+ launcher:container="-101"
+ launcher:screen="1"
+ launcher:x="1"
+ launcher:y="0" />
+ <favorite
+ launcher:packageName="com.android.mms"
+ launcher:className="com.android.mms.ui.ConversationList"
+ launcher:container="-101"
+ launcher:screen="3"
+ launcher:x="3"
+ launcher:y="0" />
+ <favorite
+ launcher:packageName="com.android.browser"
+ launcher:className="com.android.browser.BrowserActivity"
+ launcher:container="-101"
+ launcher:screen="4"
+ launcher:x="4"
+ launcher:y="0" />
+</favorites>
diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java
index 6cec101ab..a01cc479b 100644
--- a/src/com/android/launcher2/LauncherProvider.java
+++ b/src/com/android/launcher2/LauncherProvider.java
@@ -268,7 +268,7 @@ public class LauncherProvider extends ContentProvider {
if (!convertDatabase(db)) {
// Populate favorites table with initial favorites
- loadFavorites(db, ItemInfo.NO_ID);
+ loadFavorites(db, R.xml.default_workspace);
}
}
@@ -446,7 +446,7 @@ public class LauncherProvider extends ContentProvider {
}
// Add default hotseat icons
- loadFavorites(db, LauncherSettings.Favorites.CONTAINER_HOTSEAT);
+ loadFavorites(db, R.xml.update_workspace);
version = 9;
}
@@ -700,7 +700,7 @@ public class LauncherProvider extends ContentProvider {
* @param db The database to write the values into
* @param filterContainerId The specific container id of items to load
*/
- private int loadFavorites(SQLiteDatabase db, long filterContainerId) {
+ private int loadFavorites(SQLiteDatabase db, int workspaceResourceId) {
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ContentValues values = new ContentValues();
@@ -708,7 +708,7 @@ public class LauncherProvider extends ContentProvider {
PackageManager packageManager = mContext.getPackageManager();
int i = 0;
try {
- XmlResourceParser parser = mContext.getResources().getXml(R.xml.default_workspace);
+ XmlResourceParser parser = mContext.getResources().getXml(workspaceResourceId);
AttributeSet attrs = Xml.asAttributeSet(parser);
XmlUtils.beginDocument(parser, TAG_FAVORITES);
@@ -731,92 +731,91 @@ public class LauncherProvider extends ContentProvider {
if (a.hasValue(R.styleable.Favorite_container)) {
container = Long.valueOf(a.getString(R.styleable.Favorite_container));
}
- if (filterContainerId == ItemInfo.NO_ID || filterContainerId == container) {
- String screen = a.getString(R.styleable.Favorite_screen);
- String x = a.getString(R.styleable.Favorite_x);
- String y = a.getString(R.styleable.Favorite_y);
-
- // If we are adding to the hotset, the screen is used as the position in the
- // hotset. This screen can't be at position 0 because AllApps is in the
- // zeroth position.
- if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
- Hotseat.isAllAppsButtonRank(Integer.valueOf(screen))) {
- throw new RuntimeException("Invalid screen position for hotseat item");
- }
- values.clear();
- values.put(LauncherSettings.Favorites.CONTAINER, container);
- values.put(LauncherSettings.Favorites.SCREEN, screen);
- values.put(LauncherSettings.Favorites.CELLX, x);
- values.put(LauncherSettings.Favorites.CELLY, y);
-
- if (TAG_FAVORITE.equals(name)) {
- long id = addAppShortcut(db, values, a, packageManager, intent);
- added = id >= 0;
- } else if (TAG_SEARCH.equals(name)) {
- added = addSearchWidget(db, values);
- } else if (TAG_CLOCK.equals(name)) {
- added = addClockWidget(db, values);
- } else if (TAG_APPWIDGET.equals(name)) {
- added = addAppWidget(db, values, a, packageManager);
- } else if (TAG_SHORTCUT.equals(name)) {
- long id = addUriShortcut(db, values, a);
- added = id >= 0;
- } else if (TAG_FOLDER.equals(name)) {
- String title;
- int titleResId = a.getResourceId(R.styleable.Favorite_title, -1);
- if (titleResId != -1) {
- title = mContext.getResources().getString(titleResId);
- } else {
- title = mContext.getResources().getString(R.string.folder_name);
- }
- values.put(LauncherSettings.Favorites.TITLE, title);
- long folderId = addFolder(db, values);
- added = folderId >= 0;
+ String screen = a.getString(R.styleable.Favorite_screen);
+ String x = a.getString(R.styleable.Favorite_x);
+ String y = a.getString(R.styleable.Favorite_y);
- ArrayList<Long> folderItems = new ArrayList<Long>();
+ // If we are adding to the hotseat, the screen is used as the position in the
+ // hotseat. This screen can't be at position 0 because AllApps is in the
+ // zeroth position.
+ if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
+ Hotseat.isAllAppsButtonRank(Integer.valueOf(screen))) {
+ throw new RuntimeException("Invalid screen position for hotseat item");
+ }
- int folderDepth = parser.getDepth();
- while ((type = parser.next()) != XmlPullParser.END_TAG ||
- parser.getDepth() > folderDepth) {
- if (type != XmlPullParser.START_TAG) {
- continue;
- }
- final String folder_item_name = parser.getName();
+ values.clear();
+ values.put(LauncherSettings.Favorites.CONTAINER, container);
+ values.put(LauncherSettings.Favorites.SCREEN, screen);
+ values.put(LauncherSettings.Favorites.CELLX, x);
+ values.put(LauncherSettings.Favorites.CELLY, y);
+
+ if (TAG_FAVORITE.equals(name)) {
+ long id = addAppShortcut(db, values, a, packageManager, intent);
+ added = id >= 0;
+ } else if (TAG_SEARCH.equals(name)) {
+ added = addSearchWidget(db, values);
+ } else if (TAG_CLOCK.equals(name)) {
+ added = addClockWidget(db, values);
+ } else if (TAG_APPWIDGET.equals(name)) {
+ added = addAppWidget(db, values, a, packageManager);
+ } else if (TAG_SHORTCUT.equals(name)) {
+ long id = addUriShortcut(db, values, a);
+ added = id >= 0;
+ } else if (TAG_FOLDER.equals(name)) {
+ String title;
+ int titleResId = a.getResourceId(R.styleable.Favorite_title, -1);
+ if (titleResId != -1) {
+ title = mContext.getResources().getString(titleResId);
+ } else {
+ title = mContext.getResources().getString(R.string.folder_name);
+ }
+ values.put(LauncherSettings.Favorites.TITLE, title);
+ long folderId = addFolder(db, values);
+ added = folderId >= 0;
- TypedArray ar = mContext.obtainStyledAttributes(attrs,
- R.styleable.Favorite);
- values.clear();
- values.put(LauncherSettings.Favorites.CONTAINER, folderId);
-
- if (TAG_FAVORITE.equals(folder_item_name) && folderId >= 0) {
- long id =
- addAppShortcut(db, values, ar, packageManager, intent);
- if (id >= 0) {
- folderItems.add(id);
- }
- } else if (TAG_SHORTCUT.equals(folder_item_name) && folderId >= 0) {
- long id = addUriShortcut(db, values, ar);
- if (id >= 0) {
- folderItems.add(id);
- }
- } else {
- throw new RuntimeException("Folders can " +
- "contain only shortcuts");
- }
- ar.recycle();
+ ArrayList<Long> folderItems = new ArrayList<Long>();
+
+ int folderDepth = parser.getDepth();
+ while ((type = parser.next()) != XmlPullParser.END_TAG ||
+ parser.getDepth() > folderDepth) {
+ if (type != XmlPullParser.START_TAG) {
+ continue;
}
- // We can only have folders with >= 2 items, so we need to remove the
- // folder and clean up if less than 2 items were included, or some
- // failed to add, and less than 2 were actually added
- if (folderItems.size() < 2 && folderId >= 0) {
- // We just delete the folder and any items that made it
- deleteId(db, folderId);
- if (folderItems.size() > 0) {
- deleteId(db, folderItems.get(0));
+ final String folder_item_name = parser.getName();
+
+ TypedArray ar = mContext.obtainStyledAttributes(attrs,
+ R.styleable.Favorite);
+ values.clear();
+ values.put(LauncherSettings.Favorites.CONTAINER, folderId);
+
+ if (TAG_FAVORITE.equals(folder_item_name) && folderId >= 0) {
+ long id =
+ addAppShortcut(db, values, ar, packageManager, intent);
+ if (id >= 0) {
+ folderItems.add(id);
+ }
+ } else if (TAG_SHORTCUT.equals(folder_item_name) && folderId >= 0) {
+ long id = addUriShortcut(db, values, ar);
+ if (id >= 0) {
+ folderItems.add(id);
}
- added = false;
+ } else {
+ throw new RuntimeException("Folders can " +
+ "contain only shortcuts");
+ }
+ ar.recycle();
+ }
+ // We can only have folders with >= 2 items, so we need to remove the
+ // folder and clean up if less than 2 items were included, or some
+ // failed to add, and less than 2 were actually added
+ if (folderItems.size() < 2 && folderId >= 0) {
+ // We just delete the folder and any items that made it
+ deleteId(db, folderId);
+ if (folderItems.size() > 0) {
+ deleteId(db, folderItems.get(0));
}
+ added = false;
}
}
if (added) i++;