am 6d09268c: Updating default workspace and fixing issue where new hotseat browser icon is not shown. (Bug 5478946, Bug 5623287)

* commit '6d09268cdef87be5686e541ba25148c7d72e0d59':
  Updating default workspace and fixing issue where new hotseat browser icon is not shown. (Bug 5478946, Bug 5623287)
This commit is contained in:
Winson Chung
2011-11-17 10:05:52 -08:00
committed by Android Git Automerger
2 changed files with 131 additions and 83 deletions
+49
View File
@@ -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>
+82 -83
View File
@@ -268,7 +268,7 @@ public class LauncherProvider extends ContentProvider {
if (!convertDatabase(db)) { if (!convertDatabase(db)) {
// Populate favorites table with initial favorites // 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 // Add default hotseat icons
loadFavorites(db, LauncherSettings.Favorites.CONTAINER_HOTSEAT); loadFavorites(db, R.xml.update_workspace);
version = 9; version = 9;
} }
@@ -700,7 +700,7 @@ public class LauncherProvider extends ContentProvider {
* @param db The database to write the values into * @param db The database to write the values into
* @param filterContainerId The specific container id of items to load * @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 intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.addCategory(Intent.CATEGORY_LAUNCHER);
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
@@ -708,7 +708,7 @@ public class LauncherProvider extends ContentProvider {
PackageManager packageManager = mContext.getPackageManager(); PackageManager packageManager = mContext.getPackageManager();
int i = 0; int i = 0;
try { try {
XmlResourceParser parser = mContext.getResources().getXml(R.xml.default_workspace); XmlResourceParser parser = mContext.getResources().getXml(workspaceResourceId);
AttributeSet attrs = Xml.asAttributeSet(parser); AttributeSet attrs = Xml.asAttributeSet(parser);
XmlUtils.beginDocument(parser, TAG_FAVORITES); XmlUtils.beginDocument(parser, TAG_FAVORITES);
@@ -731,92 +731,91 @@ public class LauncherProvider extends ContentProvider {
if (a.hasValue(R.styleable.Favorite_container)) { if (a.hasValue(R.styleable.Favorite_container)) {
container = Long.valueOf(a.getString(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 String screen = a.getString(R.styleable.Favorite_screen);
// hotset. This screen can't be at position 0 because AllApps is in the String x = a.getString(R.styleable.Favorite_x);
// zeroth position. String y = a.getString(R.styleable.Favorite_y);
if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
Hotseat.isAllAppsButtonRank(Integer.valueOf(screen))) { // If we are adding to the hotseat, the screen is used as the position in the
throw new RuntimeException("Invalid screen position for hotseat item"); // 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");
}
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;
values.clear(); ArrayList<Long> folderItems = new ArrayList<Long>();
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)) { int folderDepth = parser.getDepth();
long id = addAppShortcut(db, values, a, packageManager, intent); while ((type = parser.next()) != XmlPullParser.END_TAG ||
added = id >= 0; parser.getDepth() > folderDepth) {
} else if (TAG_SEARCH.equals(name)) { if (type != XmlPullParser.START_TAG) {
added = addSearchWidget(db, values); continue;
} else if (TAG_CLOCK.equals(name)) { }
added = addClockWidget(db, values); final String folder_item_name = parser.getName();
} else if (TAG_APPWIDGET.equals(name)) {
added = addAppWidget(db, values, a, packageManager); TypedArray ar = mContext.obtainStyledAttributes(attrs,
} else if (TAG_SHORTCUT.equals(name)) { R.styleable.Favorite);
long id = addUriShortcut(db, values, a); values.clear();
added = id >= 0; values.put(LauncherSettings.Favorites.CONTAINER, folderId);
} else if (TAG_FOLDER.equals(name)) {
String title; if (TAG_FAVORITE.equals(folder_item_name) && folderId >= 0) {
int titleResId = a.getResourceId(R.styleable.Favorite_title, -1); long id =
if (titleResId != -1) { addAppShortcut(db, values, ar, packageManager, intent);
title = mContext.getResources().getString(titleResId); 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 { } else {
title = mContext.getResources().getString(R.string.folder_name); throw new RuntimeException("Folders can " +
"contain only shortcuts");
} }
values.put(LauncherSettings.Favorites.TITLE, title); ar.recycle();
long folderId = addFolder(db, values); }
added = folderId >= 0; // 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
ArrayList<Long> folderItems = new ArrayList<Long>(); // failed to add, and less than 2 were actually added
if (folderItems.size() < 2 && folderId >= 0) {
int folderDepth = parser.getDepth(); // We just delete the folder and any items that made it
while ((type = parser.next()) != XmlPullParser.END_TAG || deleteId(db, folderId);
parser.getDepth() > folderDepth) { if (folderItems.size() > 0) {
if (type != XmlPullParser.START_TAG) { deleteId(db, folderItems.get(0));
continue;
}
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);
}
} 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;
} }
added = false;
} }
} }
if (added) i++; if (added) i++;