summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2014-10-14 22:00:41 (GMT)
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-14 22:00:42 (GMT)
commit755dd70238162d0b631a8a17c42047c61318be30 (patch)
tree9a3536ee0dc7001238f11b460e31b54b74119a82
parent8cce9dd83aecd90920db751ab3f8fb6969f087c5 (diff)
parenteb1ac42fd479cfd9b8e58220173c8bea5c69b649 (diff)
downloadandroid_packages_apps_Trebuchet-755dd70238162d0b631a8a17c42047c61318be30.zip
android_packages_apps_Trebuchet-755dd70238162d0b631a8a17c42047c61318be30.tar.gz
android_packages_apps_Trebuchet-755dd70238162d0b631a8a17c42047c61318be30.tar.bz2
Merge "Fix missing screen when adding widget directly to provider" into ub-now-porkchop
-rw-r--r--src/com/android/launcher3/LauncherProvider.java51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index c0e6487..670780a 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -1290,14 +1290,15 @@ public class LauncherProvider extends ContentProvider {
try {
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
- if (appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {
- return true;
+ if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {
}
} catch (RuntimeException e) {
Log.e(TAG, "Failed to initialize external widget", e);
+ return false;
}
+ } else {
+ return false;
}
- return false;
}
// Add screen id if not present
@@ -1553,24 +1554,11 @@ public class LauncherProvider extends ContentProvider {
}
/**
- * Parse folder starting at current {@link XmlPullParser} location.
+ * Parse folder items starting at {@link XmlPullParser} location. Allow recursive
+ * includes of items.
*/
- private boolean loadFolder(SQLiteDatabase db, ContentValues values, Resources res,
- XmlResourceParser parser) throws IOException, XmlPullParserException {
- final String title;
- final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0);
- if (titleResId != 0) {
- title = res.getString(titleResId);
- } else {
- title = mContext.getResources().getString(R.string.folder_name);
- }
-
- values.put(LauncherSettings.Favorites.TITLE, title);
- long folderId = addFolder(db, values);
- boolean added = folderId >= 0;
-
- ArrayList<Long> folderItems = new ArrayList<Long>();
-
+ private void addToFolder(SQLiteDatabase db, Resources res, XmlResourceParser parser,
+ ArrayList<Long> folderItems, long folderId) throws IOException, XmlPullParserException {
int type;
int folderDepth = parser.getDepth();
while ((type = parser.next()) != XmlPullParser.END_TAG ||
@@ -1600,10 +1588,33 @@ public class LauncherProvider extends ContentProvider {
if (id >= 0) {
folderItems.add(id);
}
+ } else if (TAG_INCLUDE.equals(tag) && folderId >= 0) {
+ addToFolder(db, res, parser, folderItems, folderId);
} else {
throw new RuntimeException("Folders can contain only shortcuts");
}
}
+ }
+
+ /**
+ * Parse folder starting at current {@link XmlPullParser} location.
+ */
+ private boolean loadFolder(SQLiteDatabase db, ContentValues values, Resources res,
+ XmlResourceParser parser) throws IOException, XmlPullParserException {
+ final String title;
+ final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0);
+ if (titleResId != 0) {
+ title = res.getString(titleResId);
+ } else {
+ title = mContext.getResources().getString(R.string.folder_name);
+ }
+
+ values.put(LauncherSettings.Favorites.TITLE, title);
+ long folderId = addFolder(db, values);
+ boolean added = folderId >= 0;
+
+ ArrayList<Long> folderItems = new ArrayList<Long>();
+ addToFolder(db, res, parser, folderItems, folderId);
// 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