am b3461336: (-s ours) am 853b55b9: Merge remote-tracking branch \'goog/ub-now-lunchbox\' into lunchbox-release
* commit 'b346133679f409e3f4e7389c5dced451b9980a57':
Small refactor to separate adding workspace / all apps items
Fix deprecated EMPTY_ARRAY usage (nanoprotos).
diff --git a/res/values-lo-rLA/strings.xml b/res/values-lo-rLA/strings.xml
index 79a0a4a..a23b77b 100644
--- a/res/values-lo-rLA/strings.xml
+++ b/res/values-lo-rLA/strings.xml
@@ -95,6 +95,8 @@
<string name="migration_cling_use_default" msgid="2626475813981258626">"ເລີ່ມຕົ້ນໃໝ່"</string>
<string name="workspace_cling_title" msgid="5626202359865825661">"ຈັດການພື້ນທີ່ຂອງທ່ານ"</string>
<string name="workspace_cling_move_item" msgid="528201129978005352">"ແຕະຄ້າງໄວ້ທີ່ພາບພື້ນຫຼັງເພື່ອຈັດການພາບພື້ນຫຼັງ, ວິດເຈັດແລະການຕັ້ງຄ່າ."</string>
+ <string name="all_apps_cling_title" msgid="34929250753095858">"ເລືອກແອັບຯ"</string>
+ <string name="all_apps_cling_add_item" msgid="400866858451850784">"ເພື່ອເພີ່ມແອັບຯໃສ່ໜ້າຈໍຫຼັກຂອງທ່ານ, ໃຫ້ແຕະຄ້າງໄວ້."</string>
<string name="folder_cling_title" msgid="3894908818693254164">"ນີ້ແມ່ນໂຟນເດີ"</string>
<string name="folder_cling_create_folder" msgid="6158215559475836131">"ເພື່ອສ້າງອັນໃໝ່ແບບນີ້ ໃຫ້ແຕະຄ້າງໄວ້ທີ່ແອັບຯທີ່ຕ້ອງການຍ້າຍແລ້ວລາກມັນໄປຫາໂຕອື່ນ."</string>
<string name="cling_dismiss" msgid="8962359497601507581">"ຕົກລົງ"</string>
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 28cef13..7ab4e04 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -304,7 +304,7 @@
// Add the new apps to the model and bind them
if (!addShortcuts.isEmpty()) {
LauncherAppState app = LauncherAppState.getInstance();
- app.getModel().addAndBindAddedWorkspaceApps(context, addShortcuts);
+ app.getModel().addAndBindAddedApps(context, addShortcuts, new ArrayList<AppInfo>());
}
}
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index c57d32e..13507c6 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3852,17 +3852,15 @@
}
// Add the new screens
- if (newScreens != null) {
- bindAddScreens(newScreens);
- }
+ bindAddScreens(newScreens);
// We add the items without animation on non-visible pages, and with
// animations on the new page (which we will try and snap to).
- if (addNotAnimated != null && !addNotAnimated.isEmpty()) {
+ if (!addNotAnimated.isEmpty()) {
bindItems(addNotAnimated, 0,
addNotAnimated.size(), false);
}
- if (addAnimated != null && !addAnimated.isEmpty()) {
+ if (!addAnimated.isEmpty()) {
bindItems(addAnimated, 0,
addAnimated.size(), true);
}
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index a45f293..335028d 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -193,7 +193,7 @@
Log.e(TAG, "launcher backup has failed", e);
}
- out.key = keys.toArray(new BackupProtos.Key[keys.size()]);
+ out.key = keys.toArray(BackupProtos.Key.emptyArray());
writeJournal(newState, out);
Log.v(TAG, "onBackup: wrote " + out.bytes + "b in " + out.rows + " rows.");
}
@@ -266,7 +266,7 @@
// will catch any changes the restore process might have made
Journal out = new Journal();
out.t = 0;
- out.key = mKeys.toArray(new BackupProtos.Key[mKeys.size()]);
+ out.key = mKeys.toArray(BackupProtos.Key.emptyArray());
writeJournal(newState, out);
Log.v(TAG, "onRestore: read " + mKeys.size() + " rows");
mKeys.clear();
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 094d4b7..6839bb3 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -292,40 +292,17 @@
return null;
}
- public void addAppsToAllApps(final Context ctx, final ArrayList<AppInfo> allAppsApps) {
- final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
-
- if (allAppsApps == null) {
- throw new RuntimeException("allAppsApps must not be null");
- }
- if (allAppsApps.isEmpty()) {
- return;
- }
-
- // Process the newly added applications and add them to the database first
- Runnable r = new Runnable() {
- public void run() {
- runOnMainThread(new Runnable() {
- public void run() {
- Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
- if (callbacks == cb && cb != null) {
- callbacks.bindAppsAdded(null, null, null, allAppsApps);
- }
- }
- });
- }
- };
- runOnWorkerThread(r);
+ public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> workspaceApps,
+ final ArrayList<AppInfo> allAppsApps) {
+ Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
+ addAndBindAddedApps(context, workspaceApps, cb, allAppsApps);
}
-
- public void addAndBindAddedWorkspaceApps(final Context context,
- final ArrayList<ItemInfo> workspaceApps) {
- final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
-
- if (workspaceApps == null) {
+ public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> workspaceApps,
+ final Callbacks callbacks, final ArrayList<AppInfo> allAppsApps) {
+ if (workspaceApps == null || allAppsApps == null) {
throw new RuntimeException("workspaceApps and allAppsApps must not be null");
}
- if (workspaceApps.isEmpty()) {
+ if (workspaceApps.isEmpty() && allAppsApps.isEmpty()) {
return;
}
// Process the newly added applications and add them to the database first
@@ -408,7 +385,7 @@
// Update the workspace screens
updateWorkspaceScreenOrder(context, workspaceScreens);
- if (!addedShortcutsFinal.isEmpty()) {
+ if (!addedShortcutsFinal.isEmpty() || !allAppsApps.isEmpty()) {
runOnMainThread(new Runnable() {
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
@@ -427,7 +404,7 @@
}
}
callbacks.bindAppsAdded(addedWorkspaceScreensFinal,
- addNotAnimated, addAnimated, null);
+ addNotAnimated, addAnimated, allAppsApps);
}
}
});
@@ -1584,7 +1561,8 @@
}
}
if (!added.isEmpty()) {
- addAndBindAddedWorkspaceApps(context, added);
+ Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
+ addAndBindAddedApps(context, added, cb, new ArrayList<AppInfo>());
}
}
@@ -2664,14 +2642,14 @@
if (added != null) {
// Ensure that we add all the workspace applications to the db
- if (LauncherAppState.isDisableAllApps()) {
- final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
- addAndBindAddedWorkspaceApps(context, addedInfos);
+ Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
+ if (!LauncherAppState.isDisableAllApps()) {
+ addAndBindAddedApps(context, new ArrayList<ItemInfo>(), cb, added);
} else {
- addAppsToAllApps(context, added);
+ final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
+ addAndBindAddedApps(context, addedInfos, cb, added);
}
}
-
if (modified != null) {
final ArrayList<AppInfo> modifiedFinal = modified;