Add IconCache support for deep shortcuts, loads deepshortcut on

background thread.  Added a feature flag to toggle on/off this
feature.

Bug: 140242324
Test:
  1. (Custom Shortcut) Long click on google maps -> widgets -> drag
     driving mode to workspace.

  2. Open chrome -> add to home screen -> add -> add automatically.

  3. InstallShortcutReceiver
     In Launcher.completeAddShortcut, commend out the code that
     calls PinRequestHelper.createWorkspaceItemFromPinItemRequest,
     then open chrome -> add to home screen -> add -> add
     automatically.

  4. ShortcutDragPreviewProvider
     qdb -> long press on suggested app that has deep shortcut
     -> drag to workspace.

Change-Id: If7babe4eddf5434909bf686b4e9bde15e444d9fd
This commit is contained in:
Pinyao Ting
2019-11-05 11:27:28 -08:00
parent 5d3dc9c76d
commit c1a1ced33a
11 changed files with 248 additions and 21 deletions
@@ -15,10 +15,19 @@
*/
package com.android.launcher3.util;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import android.content.Context;
import android.content.pm.ShortcutInfo;
import androidx.annotation.NonNull;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.Utilities;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.shortcuts.ShortcutKey;
@@ -61,6 +70,21 @@ public class ShortcutUtil {
&& info instanceof WorkspaceItemInfo;
}
/**
* Fetch the shortcut icon in background, then update the UI.
*/
public static void fetchAndUpdateShortcutIconAsync(
@NonNull Context context, @NonNull WorkspaceItemInfo info, @NonNull ShortcutInfo si,
boolean badged) {
MODEL_EXECUTOR.execute(() -> {
try (LauncherIcons li = LauncherIcons.obtain(context)) {
info.bitmap = li.createShortcutIcon(si, badged, null);
LauncherAppState.getInstance(context).getModel()
.updateAndBindWorkspaceItem(info, si);
}
});
}
private static boolean isActive(ItemInfo info) {
boolean isLoading = info instanceof WorkspaceItemInfo
&& ((WorkspaceItemInfo) info).hasPromiseIconUi();