Merge "Remove LAUNCHER3_ALL_APPS_PULL_UP Bug: 63712253 Verified: all apps transition fully functional Verified: NO_ALL_APPS_ICON = false case also works." into ub-launcher3-dorval-polish2
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 106a11b..6b2be3b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -119,6 +119,7 @@
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.util.ActivityResultInfo;
+import com.android.launcher3.util.RunnableWithId;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiHashMap;
@@ -146,6 +147,9 @@
import java.util.Set;
import java.util.concurrent.Executor;
+import static com.android.launcher3.util.RunnableWithId.RUNNABLE_ID_BIND_APPS;
+import static com.android.launcher3.util.RunnableWithId.RUNNABLE_ID_BIND_WIDGETS;
+
/**
* Default launcher application.
*/
@@ -246,7 +250,6 @@
// Main container view and the model for the widget tray screen.
@Thunk WidgetsContainerView mWidgetsView;
- @Thunk MultiHashMap<PackageItemInfo, WidgetItem> mAllWidgets;
// We set the state in both onCreate and then onNewIntent in some cases, which causes both
// scroll issues (because the workspace may not have been measured yet) and extra work.
@@ -3111,12 +3114,12 @@
*
* @return {@code true} if we are currently paused. The caller might be able to skip some work
*/
- @Thunk boolean waitUntilResume(Runnable run, boolean deletePreviousRunnables) {
+ @Thunk boolean waitUntilResume(Runnable run) {
if (mPaused) {
if (LOGD) Log.d(TAG, "Deferring update until onResume");
- if (deletePreviousRunnables) {
- while (mBindOnResumeCallbacks.remove(run)) {
- }
+ if (run instanceof RunnableWithId) {
+ // Remove any runnables which have the same id
+ while (mBindOnResumeCallbacks.remove(run)) { }
}
mBindOnResumeCallbacks.add(run);
return true;
@@ -3125,10 +3128,6 @@
}
}
- private boolean waitUntilResume(Runnable run) {
- return waitUntilResume(run, false);
- }
-
public void addOnResumeCallback(Runnable run) {
mOnResumeCallbacks.add(run);
}
@@ -3247,13 +3246,13 @@
}
}
+ @Override
public void bindAppsAdded(final ArrayList<Long> newScreens,
final ArrayList<ItemInfo> addNotAnimated,
- final ArrayList<ItemInfo> addAnimated,
- final ArrayList<AppInfo> addedApps) {
+ final ArrayList<ItemInfo> addAnimated) {
Runnable r = new Runnable() {
public void run() {
- bindAppsAdded(newScreens, addNotAnimated, addAnimated, addedApps);
+ bindAppsAdded(newScreens, addNotAnimated, addAnimated);
}
};
if (waitUntilResume(r)) {
@@ -3268,20 +3267,14 @@
// 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()) {
- bindItems(addNotAnimated, 0,
- addNotAnimated.size(), false);
+ bindItems(addNotAnimated, false);
}
if (addAnimated != null && !addAnimated.isEmpty()) {
- bindItems(addAnimated, 0,
- addAnimated.size(), true);
+ bindItems(addAnimated, true);
}
// Remove the extra empty screen
mWorkspace.removeExtraEmptyScreen(false, false);
-
- if (addedApps != null && mAppsView != null) {
- mAppsView.addApps(addedApps);
- }
}
/**
@@ -3290,11 +3283,10 @@
* Implementation of the method from LauncherModel.Callbacks.
*/
@Override
- public void bindItems(final ArrayList<ItemInfo> items, final int start, final int end,
- final boolean forceAnimateIcons) {
+ public void bindItems(final List<ItemInfo> items, final boolean forceAnimateIcons) {
Runnable r = new Runnable() {
public void run() {
- bindItems(items, start, end, forceAnimateIcons);
+ bindItems(items, forceAnimateIcons);
}
};
if (waitUntilResume(r)) {
@@ -3307,7 +3299,8 @@
final boolean animateIcons = forceAnimateIcons && canRunNewAppsAnimation();
Workspace workspace = mWorkspace;
long newItemsScreenId = -1;
- for (int i = start; i < end; i++) {
+ int end = items.size();
+ for (int i = 0; i < end; i++) {
final ItemInfo item = items.get(i);
// Short circuit if we are loading dock items for a configuration which has no dock
@@ -3332,19 +3325,10 @@
break;
}
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: {
- LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) item;
- if (mIsSafeModeEnabled) {
- view = new PendingAppWidgetHostView(this, info, mIconCache, true);
- } else {
- LauncherAppWidgetProviderInfo providerInfo =
- mAppWidgetManager.getLauncherAppWidgetInfo(info.appWidgetId);
- if (providerInfo == null) {
- deleteWidgetInfo(info);
- continue;
- }
- view = mAppWidgetHost.createView(this, info.appWidgetId, providerInfo);
+ view = inflateAppWidget((LauncherAppWidgetInfo) item);
+ if (view == null) {
+ continue;
}
- prepareAppWidget((AppWidgetHostView) view, info);
break;
}
default:
@@ -3414,26 +3398,21 @@
/**
* Add the views for a widget to the workspace.
- *
- * Implementation of the method from LauncherModel.Callbacks.
*/
- public void bindAppWidget(final LauncherAppWidgetInfo item) {
- Runnable r = new Runnable() {
- public void run() {
- bindAppWidget(item);
- }
- };
- if (waitUntilResume(r)) {
- return;
+ public void bindAppWidget(LauncherAppWidgetInfo item) {
+ View view = inflateAppWidget(item);
+ if (view != null) {
+ mWorkspace.addInScreen(view, item);
+ mWorkspace.requestLayout();
}
+ }
+ private View inflateAppWidget(LauncherAppWidgetInfo item) {
if (mIsSafeModeEnabled) {
PendingAppWidgetHostView view =
new PendingAppWidgetHostView(this, item, mIconCache, true);
prepareAppWidget(view, item);
- mWorkspace.addInScreen(view, item);
- mWorkspace.requestLayout();
- return;
+ return view;
}
final long start = DEBUG_WIDGETS ? SystemClock.uptimeMillis() : 0;
@@ -3463,7 +3442,7 @@
+ ", as the provider is null");
}
getModelWriter().deleteItemFromDatabase(item);
- return;
+ return null;
}
// If we do not have a valid id, try to bind an id.
@@ -3531,7 +3510,7 @@
if (appWidgetInfo == null) {
FileLog.e(TAG, "Removing invalid widget: id=" + item.appWidgetId);
deleteWidgetInfo(item);
- return;
+ return null;
}
item.minSpanX = appWidgetInfo.minSpanX;
@@ -3541,13 +3520,12 @@
view = new PendingAppWidgetHostView(this, item, mIconCache, false);
}
prepareAppWidget(view, item);
- mWorkspace.addInScreen(view, item);
- mWorkspace.requestLayout();
if (DEBUG_WIDGETS) {
Log.d(TAG, "bound widget id="+item.appWidgetId+" in "
+ (SystemClock.uptimeMillis()-start) + "ms");
}
+ return view;
}
/**
@@ -3683,25 +3661,17 @@
}
/**
- * A runnable that we can dequeue and re-enqueue when all applications are bound (to prevent
- * multiple calls to bind the same list.)
- */
- @Thunk ArrayList<AppInfo> mTmpAppsList;
- private final Runnable mBindAllApplicationsRunnable = new Runnable() {
- public void run() {
- bindAllApplications(mTmpAppsList);
- mTmpAppsList = null;
- }
- };
-
- /**
* Add the icons for all apps.
*
* Implementation of the method from LauncherModel.Callbacks.
*/
public void bindAllApplications(final ArrayList<AppInfo> apps) {
- if (waitUntilResume(mBindAllApplicationsRunnable, true)) {
- mTmpAppsList = apps;
+ Runnable r = new RunnableWithId(RUNNABLE_ID_BIND_APPS) {
+ public void run() {
+ bindAllApplications(apps);
+ }
+ };
+ if (waitUntilResume(r)) {
return;
}
@@ -3709,10 +3679,10 @@
Executor pendingExecutor = getPendingExecutor();
if (pendingExecutor != null && mState != State.APPS) {
// Wait until the fade in animation has finished before setting all apps list.
- mTmpAppsList = apps;
- pendingExecutor.execute(mBindAllApplicationsRunnable);
+ pendingExecutor.execute(r);
return;
}
+
mAppsView.setApps(apps);
}
if (mLauncherCallbacks != null) {
@@ -3742,10 +3712,10 @@
*
* Implementation of the method from LauncherModel.Callbacks.
*/
- public void bindAppsUpdated(final ArrayList<AppInfo> apps) {
+ public void bindAppsAddedOrUpdated(final ArrayList<AppInfo> apps) {
Runnable r = new Runnable() {
public void run() {
- bindAppsUpdated(apps);
+ bindAppsAddedOrUpdated(apps);
}
};
if (waitUntilResume(r)) {
@@ -3753,7 +3723,7 @@
}
if (mAppsView != null) {
- mAppsView.updateApps(apps);
+ mAppsView.addOrUpdateApps(apps);
}
}
@@ -3906,28 +3876,25 @@
}
}
- private final Runnable mBindAllWidgetsRunnable = new Runnable() {
+ @Override
+ public void bindAllWidgets(final MultiHashMap<PackageItemInfo, WidgetItem> allWidgets) {
+ Runnable r = new RunnableWithId(RUNNABLE_ID_BIND_WIDGETS) {
+ @Override
public void run() {
- bindAllWidgets(mAllWidgets);
+ bindAllWidgets(allWidgets);
}
};
-
- @Override
- public void bindAllWidgets(MultiHashMap<PackageItemInfo, WidgetItem> allWidgets) {
- if (waitUntilResume(mBindAllWidgetsRunnable, true)) {
- mAllWidgets = allWidgets;
+ if (waitUntilResume(r)) {
return;
}
if (mWidgetsView != null && allWidgets != null) {
Executor pendingExecutor = getPendingExecutor();
if (pendingExecutor != null && mState != State.WIDGETS) {
- mAllWidgets = allWidgets;
- pendingExecutor.execute(mBindAllWidgetsRunnable);
+ pendingExecutor.execute(r);
return;
}
mWidgetsView.setWidgets(allWidgets);
- mAllWidgets = null;
}
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 1007748..22d62ec 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -138,18 +138,15 @@
public int getCurrentWorkspaceScreen();
public void clearPendingBinds();
public void startBinding();
- public void bindItems(ArrayList<ItemInfo> shortcuts, int start, int end,
- boolean forceAnimateIcons);
+ public void bindItems(List<ItemInfo> shortcuts, boolean forceAnimateIcons);
public void bindScreens(ArrayList<Long> orderedScreenIds);
public void finishFirstPageBind(ViewOnDrawExecutor executor);
public void finishBindingItems();
- public void bindAppWidget(LauncherAppWidgetInfo info);
public void bindAllApplications(ArrayList<AppInfo> apps);
+ public void bindAppsAddedOrUpdated(ArrayList<AppInfo> apps);
public void bindAppsAdded(ArrayList<Long> newScreens,
ArrayList<ItemInfo> addNotAnimated,
- ArrayList<ItemInfo> addAnimated,
- ArrayList<AppInfo> addedApps);
- public void bindAppsUpdated(ArrayList<AppInfo> apps);
+ ArrayList<ItemInfo> addAnimated);
public void bindPromiseAppProgressUpdated(PromiseAppInfo app);
public void bindShortcutsChanged(ArrayList<ShortcutInfo> updated,
ArrayList<ShortcutInfo> removed, UserHandle user);
@@ -537,7 +534,7 @@
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
- callbacks.bindAppsAdded(null, null, null, arrayList);
+ callbacks.bindAppsAddedOrUpdated(arrayList);
}
});
}
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index 643d48a..a814323 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -11,6 +11,9 @@
import android.view.View;
import android.view.ViewDebug;
+import static com.android.launcher3.util.SystemUiController.FLAG_DARK_NAV;
+import static com.android.launcher3.util.SystemUiController.UI_STATE_ROOT_VIEW;
+
public class LauncherRootView extends InsettableFrameLayout {
private final Paint mOpaquePaint;
@@ -44,20 +47,28 @@
@TargetApi(23)
@Override
protected boolean fitSystemWindows(Rect insets) {
- boolean rawInsetsChanged = !mInsets.equals(insets);
mDrawSideInsetBar = (insets.right > 0 || insets.left > 0) &&
(!Utilities.ATLEAST_MARSHMALLOW ||
- getContext().getSystemService(ActivityManager.class).isLowRamDevice());
- mRightInsetBarWidth = insets.right;
- mLeftInsetBarWidth = insets.left;
- setInsets(mDrawSideInsetBar ? new Rect(0, insets.top, 0, insets.bottom) : insets);
+ getContext().getSystemService(ActivityManager.class).isLowRamDevice());
+ if (mDrawSideInsetBar) {
+ mLeftInsetBarWidth = insets.left;
+ mRightInsetBarWidth = insets.right;
+ insets = new Rect(0, insets.top, 0, insets.bottom);
+ } else {
+ mLeftInsetBarWidth = mRightInsetBarWidth = 0;
+ }
+ Launcher.getLauncher(getContext()).getSystemUiController().updateUiState(
+ UI_STATE_ROOT_VIEW, mDrawSideInsetBar ? FLAG_DARK_NAV : 0);
- if (mAlignedView != null && mDrawSideInsetBar) {
+ boolean rawInsetsChanged = !mInsets.equals(insets);
+ setInsets(insets);
+
+ if (mAlignedView != null) {
// Apply margins on aligned view to handle left/right insets.
MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams();
- if (lp.leftMargin != insets.left || lp.rightMargin != insets.right) {
- lp.leftMargin = insets.left;
- lp.rightMargin = insets.right;
+ if (lp.leftMargin != mLeftInsetBarWidth || lp.rightMargin != mRightInsetBarWidth) {
+ lp.leftMargin = mLeftInsetBarWidth;
+ lp.rightMargin = mRightInsetBarWidth;
mAlignedView.setLayoutParams(lp);
}
}
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 3433533..a0ad07a 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -173,7 +173,7 @@
ArrayList<ItemInfo> itemList = new ArrayList<>();
itemList.add(info);
- mLauncher.bindItems(itemList, 0, itemList.size(), true);
+ mLauncher.bindItems(itemList, true);
} else if (item instanceof PendingAddItemInfo) {
PendingAddItemInfo info = (PendingAddItemInfo) item;
Workspace workspace = mLauncher.getWorkspace();
@@ -205,7 +205,7 @@
public void run() {
ArrayList<ItemInfo> itemList = new ArrayList<>();
itemList.add(item);
- mLauncher.bindItems(itemList, 0, itemList.size(), true);
+ mLauncher.bindItems(itemList, true);
announceConfirmation(R.string.item_moved);
}
});
diff --git a/src/com/android/launcher3/accessibility/ShortcutMenuAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/ShortcutMenuAccessibilityDelegate.java
index b7c500f..5b7353a 100644
--- a/src/com/android/launcher3/accessibility/ShortcutMenuAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/ShortcutMenuAccessibilityDelegate.java
@@ -73,7 +73,7 @@
screenId, coordinates[0], coordinates[1]);
ArrayList<ItemInfo> itemList = new ArrayList<>();
itemList.add(info);
- mLauncher.bindItems(itemList, 0, itemList.size(), true);
+ mLauncher.bindItems(itemList, true);
AbstractFloatingView.closeAllOpenViews(mLauncher);
announceConfirmation(R.string.item_added_to_workspace);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 93f04e9..97a87c1 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -128,18 +128,10 @@
}
/**
- * Adds new apps to the list.
+ * Adds or updates existing apps in the list
*/
- public void addApps(List<AppInfo> apps) {
- mApps.addApps(apps);
- mSearchUiManager.refreshSearchResult();
- }
-
- /**
- * Updates existing apps in the list
- */
- public void updateApps(List<AppInfo> apps) {
- mApps.updateApps(apps);
+ public void addOrUpdateApps(List<AppInfo> apps) {
+ mApps.addOrUpdateApps(apps);
mSearchUiManager.refreshSearchResult();
}
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 43b56a4..5e7a5ca 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -374,20 +374,13 @@
*/
public void setApps(List<AppInfo> apps) {
mComponentToAppMap.clear();
- addApps(apps);
+ addOrUpdateApps(apps);
}
/**
- * Adds new apps to the list.
+ * Adds or updates existing apps in the list
*/
- public void addApps(List<AppInfo> apps) {
- updateApps(apps);
- }
-
- /**
- * Updates existing apps in the list
- */
- public void updateApps(List<AppInfo> apps) {
+ public void addOrUpdateApps(List<AppInfo> apps) {
for (AppInfo app : apps) {
mComponentToAppMap.put(app.toComponentKey(), app);
}
diff --git a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
index 68012c4..42926fa 100644
--- a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
+++ b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
@@ -158,7 +158,7 @@
}
}
callbacks.bindAppsAdded(addedWorkspaceScreensFinal,
- addNotAnimated, addAnimated, null);
+ addNotAnimated, addAnimated);
}
});
}
diff --git a/src/com/android/launcher3/model/CacheDataUpdatedTask.java b/src/com/android/launcher3/model/CacheDataUpdatedTask.java
index 8597e10..7a27741 100644
--- a/src/com/android/launcher3/model/CacheDataUpdatedTask.java
+++ b/src/com/android/launcher3/model/CacheDataUpdatedTask.java
@@ -77,7 +77,7 @@
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
- callbacks.bindAppsUpdated(updatedApps);
+ callbacks.bindAppsAddedOrUpdated(updatedApps);
}
});
}
diff --git a/src/com/android/launcher3/model/LoaderResults.java b/src/com/android/launcher3/model/LoaderResults.java
index 0df8b6f..b7a6b68 100644
--- a/src/com/android/launcher3/model/LoaderResults.java
+++ b/src/com/android/launcher3/model/LoaderResults.java
@@ -122,7 +122,7 @@
filterCurrentWorkspaceItems(currentScreenId, workspaceItems, currentWorkspaceItems,
otherWorkspaceItems);
- filterCurrentAppWidgets(currentScreenId, appWidgets, currentAppWidgets,
+ filterCurrentWorkspaceItems(currentScreenId, appWidgets, currentAppWidgets,
otherAppWidgets);
sortWorkspaceItemsSpatially(currentWorkspaceItems);
sortWorkspaceItemsSpatially(otherWorkspaceItems);
@@ -208,12 +208,12 @@
/** Filters the set of items who are directly or indirectly (via another container) on the
* specified screen. */
- private void filterCurrentWorkspaceItems(long currentScreenId,
- ArrayList<ItemInfo> allWorkspaceItems,
- ArrayList<ItemInfo> currentScreenItems,
- ArrayList<ItemInfo> otherScreenItems) {
+ private <T extends ItemInfo> void filterCurrentWorkspaceItems(long currentScreenId,
+ ArrayList<T> allWorkspaceItems,
+ ArrayList<T> currentScreenItems,
+ ArrayList<T> otherScreenItems) {
// Purge any null ItemInfos
- Iterator<ItemInfo> iter = allWorkspaceItems.iterator();
+ Iterator<T> iter = allWorkspaceItems.iterator();
while (iter.hasNext()) {
ItemInfo i = iter.next();
if (i == null) {
@@ -224,14 +224,14 @@
// Order the set of items by their containers first, this allows use to walk through the
// list sequentially, build up a list of containers that are in the specified screen,
// as well as all items in those containers.
- Set<Long> itemsOnScreen = new HashSet<Long>();
+ Set<Long> itemsOnScreen = new HashSet<>();
Collections.sort(allWorkspaceItems, new Comparator<ItemInfo>() {
@Override
public int compare(ItemInfo lhs, ItemInfo rhs) {
return Utilities.longCompare(lhs.container, rhs.container);
}
});
- for (ItemInfo info : allWorkspaceItems) {
+ for (T info : allWorkspaceItems) {
if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
if (info.screenId == currentScreenId) {
currentScreenItems.add(info);
@@ -253,23 +253,6 @@
}
}
- /** Filters the set of widgets which are on the specified screen. */
- private void filterCurrentAppWidgets(long currentScreenId,
- ArrayList<LauncherAppWidgetInfo> appWidgets,
- ArrayList<LauncherAppWidgetInfo> currentScreenWidgets,
- ArrayList<LauncherAppWidgetInfo> otherScreenWidgets) {
-
- for (LauncherAppWidgetInfo widget : appWidgets) {
- if (widget == null) continue;
- if (widget.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
- widget.screenId == currentScreenId) {
- currentScreenWidgets.add(widget);
- } else {
- otherScreenWidgets.add(widget);
- }
- }
- }
-
/** Sorts the set of items by hotseat, workspace (spatially from top to bottom, left to
* right) */
private void sortWorkspaceItemsSpatially(ArrayList<ItemInfo> workspaceItems) {
@@ -322,7 +305,7 @@
public void run() {
Callbacks callbacks = mCallbacks.get();
if (callbacks != null) {
- callbacks.bindItems(workspaceItems, start, start+chunkSize, false);
+ callbacks.bindItems(workspaceItems.subList(start, start+chunkSize), false);
}
}
};
@@ -332,12 +315,12 @@
// Bind the widgets, one at a time
N = appWidgets.size();
for (int i = 0; i < N; i++) {
- final LauncherAppWidgetInfo widget = appWidgets.get(i);
+ final ItemInfo widget = appWidgets.get(i);
final Runnable r = new Runnable() {
public void run() {
Callbacks callbacks = mCallbacks.get();
if (callbacks != null) {
- callbacks.bindAppWidget(widget);
+ callbacks.bindItems(Collections.singletonList(widget), false);
}
}
};
diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java
index 1b2f8d6..c6e878c 100644
--- a/src/com/android/launcher3/model/PackageUpdatedTask.java
+++ b/src/com/android/launcher3/model/PackageUpdatedTask.java
@@ -147,51 +147,28 @@
break;
}
- ArrayList<AppInfo> added = null;
- ArrayList<AppInfo> modified = null;
- final ArrayList<AppInfo> removedApps = new ArrayList<>();
+ final ArrayList<AppInfo> addedOrModified = new ArrayList<>();
+ addedOrModified.addAll(appsList.added);
+ appsList.added.clear();
+ addedOrModified.addAll(appsList.modified);
+ appsList.modified.clear();
- if (appsList.added.size() > 0) {
- added = new ArrayList<>(appsList.added);
- appsList.added.clear();
- }
- if (appsList.modified.size() > 0) {
- modified = new ArrayList<>(appsList.modified);
- appsList.modified.clear();
- }
- if (appsList.removed.size() > 0) {
- removedApps.addAll(appsList.removed);
- appsList.removed.clear();
- }
+ final ArrayList<AppInfo> removedApps = new ArrayList<>(appsList.removed);
+ appsList.removed.clear();
final ArrayMap<ComponentName, AppInfo> addedOrUpdatedApps = new ArrayMap<>();
-
- if (added != null) {
- final ArrayList<AppInfo> addedApps = added;
+ if (!addedOrModified.isEmpty()) {
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
- callbacks.bindAppsAdded(null, null, null, addedApps);
+ callbacks.bindAppsAddedOrUpdated(addedOrModified);
}
});
- for (AppInfo ai : added) {
+ for (AppInfo ai : addedOrModified) {
addedOrUpdatedApps.put(ai.componentName, ai);
}
}
- if (modified != null) {
- final ArrayList<AppInfo> modifiedFinal = modified;
- for (AppInfo ai : modified) {
- addedOrUpdatedApps.put(ai.componentName, ai);
- }
- scheduleCallbackTask(new CallbackTask() {
- @Override
- public void execute(Callbacks callbacks) {
- callbacks.bindAppsUpdated(modifiedFinal);
- }
- });
- }
-
// Update shortcut infos
if (mOp == OP_ADD || flagOp != FlagOp.NO_OP) {
final ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
diff --git a/src/com/android/launcher3/util/RunnableWithId.java b/src/com/android/launcher3/util/RunnableWithId.java
new file mode 100644
index 0000000..030eb09
--- /dev/null
+++ b/src/com/android/launcher3/util/RunnableWithId.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package com.android.launcher3.util;
+
+/**
+ * A runnable with an id associated which is used for equality check.
+ */
+public abstract class RunnableWithId implements Runnable {
+
+ public static final int RUNNABLE_ID_BIND_APPS = 1;
+ public static final int RUNNABLE_ID_BIND_WIDGETS = 2;
+
+ public final int id;
+
+ public RunnableWithId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof RunnableWithId && ((RunnableWithId) obj).id == id;
+ }
+}
diff --git a/src/com/android/launcher3/util/SystemUiController.java b/src/com/android/launcher3/util/SystemUiController.java
index 6b5b095..d7a2625 100644
--- a/src/com/android/launcher3/util/SystemUiController.java
+++ b/src/com/android/launcher3/util/SystemUiController.java
@@ -30,6 +30,7 @@
public static final int UI_STATE_BASE_WINDOW = 0;
public static final int UI_STATE_ALL_APPS = 1;
public static final int UI_STATE_WIDGET_BOTTOM_SHEET = 2;
+ public static final int UI_STATE_ROOT_VIEW = 3;
public static final int FLAG_LIGHT_NAV = 1 << 0;
public static final int FLAG_DARK_NAV = 1 << 1;
@@ -37,7 +38,7 @@
public static final int FLAG_DARK_STATUS = 1 << 3;
private final Window mWindow;
- private final int[] mStates = new int[3];
+ private final int[] mStates = new int[4];
public SystemUiController(Window window) {
mWindow = window;
diff --git a/tests/src/com/android/launcher3/model/AddWorkspaceItemsTaskTest.java b/tests/src/com/android/launcher3/model/AddWorkspaceItemsTaskTest.java
index ae15f08..82f34e4 100644
--- a/tests/src/com/android/launcher3/model/AddWorkspaceItemsTaskTest.java
+++ b/tests/src/com/android/launcher3/model/AddWorkspaceItemsTaskTest.java
@@ -131,7 +131,7 @@
// only info2 should be added because info was already added to the workspace
// in setupWorkspaceWithHoles()
verify(callbacks).bindAppsAdded(any(ArrayList.class), notAnimated.capture(),
- animated.capture(), isNull(ArrayList.class));
+ animated.capture());
assertTrue(notAnimated.getValue().isEmpty());
assertEquals(1, animated.getValue().size());