Search in sources :

Example 86 with ComponentKey

use of com.android.launcher3.util.ComponentKey in project Neo-Launcher by NeoApplications.

the class OmegaLauncher method startEditIcon.

public void startEditIcon(ItemInfo itemInfo, CustomInfoProvider<ItemInfo> infoProvider) {
    ComponentKey component;
    currentEditInfo = itemInfo;
    if (itemInfo instanceof AppInfo) {
        component = ((AppInfo) itemInfo).toComponentKey();
        currentEditIcon = Objects.requireNonNull(Companion.getInstance(this).getEntryForComponent(component)).getDrawable();
    } else if (itemInfo instanceof WorkspaceItemInfo) {
        component = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
        currentEditIcon = new BitmapDrawable(mContext.getResources(), ((WorkspaceItemInfo) itemInfo).iconBitmap);
    } else if (itemInfo instanceof FolderInfo) {
        component = ((FolderInfo) itemInfo).toComponentKey();
        currentEditIcon = ((FolderInfo) itemInfo).getDefaultIcon(this);
    } else {
        component = null;
        currentEditIcon = null;
    }
    boolean folderInfo = itemInfo instanceof FolderInfo;
    int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_CLEAR_TASK;
    Intent intent = EditIconActivity.Companion.newIntent(this, infoProvider.getTitle(itemInfo), folderInfo, component);
    BlankActivity.Companion.startActivityForResult(this, intent, Config.CODE_EDIT_ICON, flags, (resultCode, data) -> {
        handleEditIconResult(resultCode, data);
        return null;
    });
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) Intent(android.content.Intent) BitmapDrawable(android.graphics.drawable.BitmapDrawable) FolderInfo(com.android.launcher3.FolderInfo) AppInfo(com.android.launcher3.AppInfo) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Example 87 with ComponentKey

use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.

the class TaskView method getItemInfo.

/**
 * Builds proto for logging
 */
public WorkspaceItemInfo getItemInfo() {
    ComponentKey componentKey = TaskUtils.getLaunchComponentKeyForTask(getTask().key);
    WorkspaceItemInfo dummyInfo = new WorkspaceItemInfo();
    dummyInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_TASK;
    dummyInfo.container = LauncherSettings.Favorites.CONTAINER_TASKSWITCHER;
    dummyInfo.user = componentKey.user;
    dummyInfo.intent = new Intent().setComponent(componentKey.componentName);
    dummyInfo.title = TaskUtils.getTitle(getContext(), getTask());
    dummyInfo.screenId = getRecentsView().indexOfChild(this);
    return dummyInfo;
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 88 with ComponentKey

use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.

the class DefaultAppSearchAlgorithm method getTitleMatchResult.

private ArrayList<ComponentKey> getTitleMatchResult(String query) {
    // Do an intersection of the words in the query and each title, and filter out all the
    // apps that don't match all of the words in the query.
    final String queryTextLower = query.toLowerCase();
    final ArrayList<ComponentKey> result = new ArrayList<>();
    StringMatcher matcher = StringMatcher.getInstance();
    for (AppInfo info : mApps) {
        if (matches(info, queryTextLower, matcher)) {
            result.add(info.toComponentKey());
        }
    }
    return result;
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) ArrayList(java.util.ArrayList) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 89 with ComponentKey

use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionUiStateManager method getAllAppsRank.

/**
 * Returns ranking info for the app within all apps prediction.
 * Only applicable when {@link ItemInfo#itemType} is one of the followings:
 * {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
 * {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
 * {@link LauncherSettings.Favorites#ITEM_TYPE_DEEP_SHORTCUT}
 */
public OptionalInt getAllAppsRank(@Nullable ItemInfo itemInfo) {
    if (itemInfo == null || itemInfo.getTargetComponent() == null || itemInfo.user == null) {
        return OptionalInt.empty();
    }
    if (itemInfo.itemType == ITEM_TYPE_APPLICATION || itemInfo.itemType == ITEM_TYPE_SHORTCUT || itemInfo.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
        ComponentKey key = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
        final List<ComponentKeyMapper> apps = getCurrentState().apps;
        return IntStream.range(0, apps.size()).filter(index -> key.equals(apps.get(index).getComponentKey())).findFirst();
    }
    return OptionalInt.empty();
}
Also used : BACKGROUND_APP(com.android.launcher3.LauncherState.BACKGROUND_APP) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) IntStream(java.util.stream.IntStream) Context(android.content.Context) NonNull(androidx.annotation.NonNull) ItemInfo(com.android.launcher3.model.data.ItemInfo) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) HotseatPredictionController(com.android.launcher3.hybridhotseat.HotseatPredictionController) OVERVIEW(com.android.launcher3.LauncherState.OVERVIEW) LauncherSettings(com.android.launcher3.LauncherSettings) StateListener(com.android.launcher3.statemanager.StateManager.StateListener) OnUpdateListener(com.android.launcher3.allapps.AllAppsStore.OnUpdateListener) OptionalInt(java.util.OptionalInt) AppTarget(android.app.prediction.AppTarget) ShortcutKey(com.android.launcher3.shortcuts.ShortcutKey) ArrayList(java.util.ArrayList) Utilities(com.android.launcher3.Utilities) MainThreadInitializedObject(com.android.launcher3.util.MainThreadInitializedObject) AppPredictor(android.app.prediction.AppPredictor) Launcher(com.android.launcher3.Launcher) ItemInfoUpdateReceiver(com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver) ComponentName(android.content.ComponentName) ITEM_TYPE_DEEP_SHORTCUT(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) LauncherAppState(com.android.launcher3.LauncherAppState) ITEM_TYPE_SHORTCUT(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) LauncherState(com.android.launcher3.LauncherState) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) List(java.util.List) Nullable(androidx.annotation.Nullable) ComponentKey(com.android.launcher3.util.ComponentKey) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) OnIDPChangeListener(com.android.launcher3.InvariantDeviceProfile.OnIDPChangeListener) Collections(java.util.Collections) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) ComponentKey(com.android.launcher3.util.ComponentKey)

Example 90 with ComponentKey

use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionUiStateManager method parseLastState.

private PredictionState parseLastState() {
    PredictionState state = new PredictionState();
    state.isEnabled = mGettingValidPredictionResults;
    if (!state.isEnabled) {
        state.apps = Collections.EMPTY_LIST;
        return state;
    }
    state.apps = new ArrayList<>();
    List<AppTarget> appTargets = mPredictionServicePredictions[mActiveClient.ordinal()];
    if (!appTargets.isEmpty()) {
        for (AppTarget appTarget : appTargets) {
            ComponentKey key;
            if (appTarget.getShortcutInfo() != null) {
                key = ShortcutKey.fromInfo(appTarget.getShortcutInfo());
            } else {
                key = new ComponentKey(new ComponentName(appTarget.getPackageName(), appTarget.getClassName()), appTarget.getUser());
            }
            state.apps.add(new ComponentKeyMapper(key, mDynamicItemCache));
        }
    }
    updateDependencies(state);
    return state;
}
Also used : AppTarget(android.app.prediction.AppTarget) ComponentKey(com.android.launcher3.util.ComponentKey) ComponentName(android.content.ComponentName)

Aggregations

ComponentKey (com.android.launcher3.util.ComponentKey)98 ComponentName (android.content.ComponentName)40 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)26 ArrayList (java.util.ArrayList)26 ShortcutInfo (android.content.pm.ShortcutInfo)21 UserHandle (android.os.UserHandle)20 HashMap (java.util.HashMap)19 ShortcutKey (com.android.launcher3.shortcuts.ShortcutKey)17 PackageUserKey (com.android.launcher3.util.PackageUserKey)17 Intent (android.content.Intent)16 HashSet (java.util.HashSet)16 Context (android.content.Context)15 ItemInfo (com.android.launcher3.model.data.ItemInfo)14 List (java.util.List)13 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)12 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)11 AppTarget (android.app.prediction.AppTarget)10 FixedContainerItems (com.android.launcher3.model.BgDataModel.FixedContainerItems)10 ShortcutRequest (com.android.launcher3.shortcuts.ShortcutRequest)10 QueryResult (com.android.launcher3.shortcuts.ShortcutRequest.QueryResult)10