use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.
the class DefaultAppSearchAlgorithm method getApps.
public static List<AppInfo> getApps(Context context, List<AppInfo> defaultApps, AppFilter filter) {
if (!Utilities.getPrefs(context).getBoolean(SEARCH_HIDDEN_APPS, false)) {
return defaultApps;
}
final List<AppInfo> apps = new ArrayList<>();
final IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
for (UserHandle user : UserManagerCompat.getInstance(context).getUserProfiles()) {
final List<ComponentName> duplicatePreventionCache = new ArrayList<>();
for (LauncherActivityInfo info : LauncherAppsCompat.getInstance(context).getActivityList(null, user)) {
if (!filter.shouldShowApp(info.getComponentName(), user)) {
continue;
}
if (!duplicatePreventionCache.contains(info.getComponentName())) {
duplicatePreventionCache.add(info.getComponentName());
final AppInfo appInfo = new AppInfo(context, info, user);
iconCache.getTitleAndIcon(appInfo, false);
apps.add(appInfo);
}
}
}
return apps;
}
use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.
the class LoaderCursor method getAppShortcutInfo.
/**
* Make an WorkspaceItemInfo object for a shortcut that is an application.
*/
public WorkspaceItemInfo getAppShortcutInfo(Intent intent, boolean allowMissingTarget, boolean useLowResIcon) {
if (user == null) {
Log.d(TAG, "Null user found in getShortcutInfo");
return null;
}
ComponentName componentName = intent.getComponent();
if (componentName == null) {
Log.d(TAG, "Missing component found in getShortcutInfo");
return null;
}
Intent newIntent = new Intent(Intent.ACTION_MAIN, null);
newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
newIntent.setComponent(componentName);
LauncherActivityInfo lai = LauncherAppsCompat.getInstance(mContext).resolveActivity(newIntent, user);
if ((lai == null) && !allowMissingTarget) {
Log.d(TAG, "Missing activity found in getShortcutInfo: " + componentName);
return null;
}
final WorkspaceItemInfo info = new WorkspaceItemInfo();
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
info.user = user;
info.intent = newIntent;
mIconCache.getTitleAndIcon(info, lai, useLowResIcon);
if (mIconCache.isDefaultIcon(info.iconBitmap, user)) {
loadIcon(info);
}
if (lai != null) {
AppInfo.updateRuntimeFlagsForActivityTarget(info, lai);
}
// from the db
if (TextUtils.isEmpty(info.title)) {
info.title = getTitle();
}
// fall back to the class name of the activity
if (info.title == null) {
info.title = componentName.getClassName();
}
info.contentDescription = mPM.getUserBadgedLabel(info.title, info.user);
return info;
}
use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.
the class LoaderTask method run.
public void run() {
synchronized (this) {
// Skip fast if we are already stopped.
if (mStopped) {
return;
}
}
TraceHelper.beginSection(TAG);
try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
TraceHelper.partitionSection(TAG, "step 1.1: loading workspace");
loadWorkspace();
verifyNotStopped();
TraceHelper.partitionSection(TAG, "step 1.2: bind workspace workspace");
mResults.bindWorkspace();
// Notify the installer packages of packages with active installs on the first screen.
TraceHelper.partitionSection(TAG, "step 1.3: send first screen broadcast");
sendFirstScreenActiveInstallsBroadcast();
// Take a break
TraceHelper.partitionSection(TAG, "step 1 completed, wait for idle");
waitForIdle();
verifyNotStopped();
// second step
TraceHelper.partitionSection(TAG, "step 2.1: loading all apps");
List<LauncherActivityInfo> allActivityList = loadAllApps();
TraceHelper.partitionSection(TAG, "step 2.2: Binding all apps");
verifyNotStopped();
mResults.bindAllApps();
verifyNotStopped();
TraceHelper.partitionSection(TAG, "step 2.3: Update icon cache");
IconCacheUpdateHandler updateHandler = mIconCache.getUpdateHandler();
setIgnorePackages(updateHandler);
updateHandler.updateIcons(allActivityList, LauncherActivityCachingLogic.newInstance(mApp.getContext()), mApp.getModel()::onPackageIconsUpdated);
// Take a break
TraceHelper.partitionSection(TAG, "step 2 completed, wait for idle");
waitForIdle();
verifyNotStopped();
// third step
TraceHelper.partitionSection(TAG, "step 3.1: loading deep shortcuts");
loadDeepShortcuts();
verifyNotStopped();
TraceHelper.partitionSection(TAG, "step 3.2: bind deep shortcuts");
mResults.bindDeepShortcuts();
// Take a break
TraceHelper.partitionSection(TAG, "step 3 completed, wait for idle");
waitForIdle();
verifyNotStopped();
// fourth step
TraceHelper.partitionSection(TAG, "step 4.1: loading widgets");
List<ComponentWithLabel> allWidgetsList = mBgDataModel.widgetsModel.update(mApp, null);
verifyNotStopped();
TraceHelper.partitionSection(TAG, "step 4.2: Binding widgets");
mResults.bindWidgets();
verifyNotStopped();
TraceHelper.partitionSection(TAG, "step 4.3: save widgets in icon cache");
updateHandler.updateIcons(allWidgetsList, new ComponentCachingLogic(mApp.getContext(), true), mApp.getModel()::onWidgetLabelsUpdated);
verifyNotStopped();
TraceHelper.partitionSection(TAG, "step 5: Finish icon cache update");
updateHandler.finish();
transaction.commit();
} catch (CancellationException e) {
// Loader stopped, ignore
TraceHelper.partitionSection(TAG, "Cancelled");
}
TraceHelper.endSection(TAG);
}
use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.
the class AllAppsList method reloadPackages.
/**
* Add and remove icons for this package, depending on visibility.
*/
public void reloadPackages(Context context, UserHandle user) {
for (final LauncherActivityInfo info : LauncherAppsCompat.getInstance(context).getActivityList(null, user)) {
AppInfo applicationInfo = findAppInfo(info.getComponentName(), user);
if (applicationInfo == null) {
add(new AppInfo(context, info, user), info);
}
}
for (int i = data.size() - 1; i >= 0; i--) {
final AppInfo applicationInfo = data.get(i);
if (user.equals(applicationInfo.user) && !mAppFilter.shouldShowApp(applicationInfo.componentName, applicationInfo.user)) {
removed.add(applicationInfo);
data.remove(i);
}
}
}
use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.
the class AllAppsList method updatePackage.
/**
* Add and remove icons for this package which has been updated.
*/
public void updatePackage(Context context, String packageName, UserHandle user) {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
final List<LauncherActivityInfo> matches = launcherApps.getActivityList(packageName, user);
if (matches.size() > 0) {
// to the removed list.
for (int i = data.size() - 1; i >= 0; i--) {
final AppInfo applicationInfo = data.get(i);
if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
if (!findActivity(matches, applicationInfo.componentName)) {
Log.w(TAG, "Changing shortcut target due to app component name change.");
removeApp(i);
}
}
}
// Also updates existing activities with new labels/icons
for (final LauncherActivityInfo info : matches) {
AppInfo applicationInfo = findAppInfo(info.getComponentName(), user);
if (applicationInfo == null) {
add(new AppInfo(context, info, user), info);
} else {
mIconCache.getTitleAndIcon(applicationInfo, info, true);
applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
mDataChanged = true;
}
}
} else {
// Remove all data for this package.
for (int i = data.size() - 1; i >= 0; i--) {
final AppInfo applicationInfo = data.get(i);
if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
mIconCache.remove(applicationInfo.componentName, user);
removeApp(i);
}
}
}
}
Aggregations