am 4e63dc8a: am 6d09268c: Updating default workspace and fixing issue where new hotseat browser icon is not shown. (Bug 5478946, Bug 5623287)
* commit '4e63dc8a758515af3690b0fbe6cf5574b88a5c89': Updating default workspace and fixing issue where new hotseat browser icon is not shown. (Bug 5478946, Bug 5623287)
This commit is contained in:
@@ -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>
|
||||
@@ -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");
|
||||
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 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");
|
||||
}
|
||||
|
||||
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();
|
||||
values.put(LauncherSettings.Favorites.CONTAINER, container);
|
||||
values.put(LauncherSettings.Favorites.SCREEN, screen);
|
||||
values.put(LauncherSettings.Favorites.CELLX, x);
|
||||
values.put(LauncherSettings.Favorites.CELLY, y);
|
||||
ArrayList<Long> folderItems = new ArrayList<Long>();
|
||||
|
||||
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);
|
||||
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();
|
||||
|
||||
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 {
|
||||
title = mContext.getResources().getString(R.string.folder_name);
|
||||
throw new RuntimeException("Folders can " +
|
||||
"contain only shortcuts");
|
||||
}
|
||||
values.put(LauncherSettings.Favorites.TITLE, title);
|
||||
long folderId = addFolder(db, values);
|
||||
added = folderId >= 0;
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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++;
|
||||
|
||||
Reference in New Issue
Block a user