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;
});
}
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;
}
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;
}
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();
}
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;
}
Aggregations