use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class AllAppsList method updatePackage.
/**
* Add and remove icons for this package which has been updated.
*/
public List<LauncherActivityInfo> updatePackage(Context context, String packageName, UserHandle user) {
final List<LauncherActivityInfo> matches = context.getSystemService(LauncherApps.class).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 {
Intent launchIntent = AppInfo.makeLaunchIntent(info);
mIconCache.getTitleAndIcon(applicationInfo, info, false);
applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
applicationInfo.setProgressLevel(PackageManagerHelper.getLoadingProgress(info), PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
applicationInfo.intent = launchIntent;
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);
}
}
}
return matches;
}
use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class AllAppsList method removeApp.
private void removeApp(int index) {
AppInfo removed = data.remove(index);
if (removed != null) {
mDataChanged = true;
mRemoveListener.accept(removed);
}
}
use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class AllAppsList method updateIconsAndLabels.
public void updateIconsAndLabels(HashSet<String> packages, UserHandle user) {
for (AppInfo info : data) {
if (info.user.equals(user) && packages.contains(info.componentName.getPackageName())) {
mIconCache.updateTitleAndIcon(info);
info.sectionName = mIndex.computeSectionName(info.title);
mDataChanged = true;
}
}
}
use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetsListSearchHeaderViewHolderBinderTest method generateSampleSearchHeader.
private WidgetsListSearchHeaderEntry generateSampleSearchHeader(String appName, String packageName, int numOfWidgets) {
PackageItemInfo appInfo = new PackageItemInfo(packageName, UserHandle.CURRENT);
appInfo.title = appName;
appInfo.bitmap = BitmapInfo.of(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8), 0);
return new WidgetsListSearchHeaderEntry(appInfo, /* titleSectionName= */
"", generateWidgetItems(packageName, numOfWidgets));
}
use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class LauncherModelHelper method initializeData.
/**
* Initializes mock data for the test.
*/
public void initializeData(String resourceName) throws Exception {
BgDataModel bgDataModel = getBgDataModel();
AllAppsList allAppsList = getAllAppsList();
MODEL_EXECUTOR.submit(() -> {
// Copy apk from resources to a local file and install from there.
Resources resources = testContext().getResources();
int resId = resources.getIdentifier(resourceName, "raw", testContext().getPackageName());
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resources.openRawResource(resId)))) {
String line;
HashMap<String, Class> classMap = new HashMap<>();
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.startsWith("#") || line.isEmpty()) {
continue;
}
String[] commands = line.split(" ");
switch(commands[0]) {
case "classMap":
classMap.put(commands[1], Class.forName(commands[2]));
break;
case "bgItem":
bgDataModel.addItem(sandboxContext, (ItemInfo) initItem(classMap.get(commands[1]), commands, 2), false);
break;
case "allApps":
allAppsList.add((AppInfo) initItem(AppInfo.class, commands, 1), null);
break;
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}).get();
}
Aggregations