Only add widgets system shortcut if widgets exist

Before we were adding it in a disabled state, and then enabling it once
widgets were bound (if widgets existed for that app). Now we load all
widgets when launcher starts so that we can use the values for the
purpose of animating the popup container. Then, as the container opens,
we reload widgets/shortcuts for that particular app and add/remove the
widgets shortcut if necessary.

Bug: 34940468
Change-Id: I64bd009442d10d3d1f9a977bdedfdb639a7dd193
This commit is contained in:
Tony Wickham
2017-04-13 16:24:38 -07:00
parent 343a77e609
commit a7e1c1c088
7 changed files with 116 additions and 63 deletions

View File

@@ -44,6 +44,7 @@ import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.ManagedProfileHeuristic;
import com.android.launcher3.util.PackageUserKey;
import java.util.ArrayList;
import java.util.Arrays;
@@ -370,6 +371,14 @@ public class PackageUpdatedTask extends ExtendedModelTask {
callbacks.notifyWidgetProvidersChanged();
}
});
} else if (Utilities.isAtLeastO() && mOp == OP_ADD) {
// Load widgets for the new package.
for (int i = 0; i < N; i++) {
LauncherModel model = app.getModel();
model.refreshAndBindWidgetsAndShortcuts(
model.getCallback(), false /* bindFirst */,
new PackageUserKey(packages[i], mUser) /* packageUser */);
}
}
}
}