Enable Promise App Icon in All Apps.

- feature flag defaults to true
- avoid adding additional workspace shortcut if promise shortcut already
  exists
- handle promise app removal in package added callback for success case

Change-Id: I694701e35cc94481a9c337df3a17b1e5aa2c3b4c
This commit is contained in:
Mario Bertschler
2017-03-21 15:49:06 -07:00
parent e28fb8354e
commit bf2d46efad
5 changed files with 30 additions and 18 deletions

View File

@@ -33,6 +33,7 @@ import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.Provider;
@@ -140,7 +141,7 @@ public class AddWorkspaceItemsTask extends ExtendedModelTask {
* the workspace has been loaded. We identify a shortcut by its intent.
*/
protected boolean shortcutExists(BgDataModel dataModel, Intent intent, UserHandle user) {
final String intentWithPkg, intentWithoutPkg;
final String compPkgName, intentWithPkg, intentWithoutPkg;
if (intent == null) {
// Skip items with null intents
return true;
@@ -148,19 +149,21 @@ public class AddWorkspaceItemsTask extends ExtendedModelTask {
if (intent.getComponent() != null) {
// If component is not null, an intent with null package will produce
// the same result and should also be a match.
String packageName = intent.getComponent().getPackageName();
compPkgName = intent.getComponent().getPackageName();
if (intent.getPackage() != null) {
intentWithPkg = intent.toUri(0);
intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
} else {
intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
intentWithPkg = new Intent(intent).setPackage(compPkgName).toUri(0);
intentWithoutPkg = intent.toUri(0);
}
} else {
compPkgName = null;
intentWithPkg = intent.toUri(0);
intentWithoutPkg = intent.toUri(0);
}
boolean isLauncherAppTarget = Utilities.isLauncherAppTarget(intent);
synchronized (dataModel) {
for (ItemInfo item : dataModel.itemsIdMap) {
if (item instanceof ShortcutInfo) {
@@ -172,6 +175,16 @@ public class AddWorkspaceItemsTask extends ExtendedModelTask {
if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
return true;
}
// checking for existing promise icon with same package name
if (isLauncherAppTarget
&& info.isPromise()
&& info.hasStatusFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)
&& info.getTargetComponent() != null
&& compPkgName != null
&& compPkgName.equals(info.getTargetComponent().getPackageName())) {
return true;
}
}
}
}