use of com.android.launcher3.icons.BitmapInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class TaskbarEduController method createWaveAnim.
/**
* Creates a staggered "wave" animation where each icon translates and scales up in succession.
*/
private Animator createWaveAnim() {
AnimatorSet waveAnim = new AnimatorSet();
View[] icons = mControllers.taskbarViewController.getIconViews();
for (int i = 0; i < icons.length; i++) {
View icon = icons[i];
AnimatorSet iconAnim = new AnimatorSet();
Keyframe[] scaleKeyframes = new Keyframe[] { Keyframe.ofFloat(0, 1f), Keyframe.ofFloat(WAVE_ANIM_FRACTION_TOP, WAVE_ANIM_ICON_SCALE), Keyframe.ofFloat(WAVE_ANIM_FRACTION_BOTTOM, 1f), Keyframe.ofFloat(1f, 1f) };
scaleKeyframes[1].setInterpolator(WAVE_ANIM_TO_TOP_INTERPOLATOR);
scaleKeyframes[2].setInterpolator(WAVE_ANIM_TO_BOTTOM_INTERPOLATOR);
Keyframe[] translationYKeyframes = new Keyframe[] { Keyframe.ofFloat(0, 0f), Keyframe.ofFloat(WAVE_ANIM_FRACTION_TOP, -mWaveAnimTranslationY), Keyframe.ofFloat(WAVE_ANIM_FRACTION_BOTTOM, 0f), // Half of the remaining fraction overshoots, then the other half returns to 0.
Keyframe.ofFloat(WAVE_ANIM_FRACTION_BOTTOM + (1 - WAVE_ANIM_FRACTION_BOTTOM) / 2f, mWaveAnimTranslationYReturnOvershoot), Keyframe.ofFloat(1f, 0f) };
translationYKeyframes[1].setInterpolator(WAVE_ANIM_TO_TOP_INTERPOLATOR);
translationYKeyframes[2].setInterpolator(WAVE_ANIM_TO_BOTTOM_INTERPOLATOR);
translationYKeyframes[3].setInterpolator(WAVE_ANIM_OVERSHOOT_INTERPOLATOR);
translationYKeyframes[4].setInterpolator(WAVE_ANIM_OVERSHOOT_RETURN_INTERPOLATOR);
iconAnim.play(ObjectAnimator.ofPropertyValuesHolder(icon, PropertyValuesHolder.ofKeyframe(SCALE_PROPERTY, scaleKeyframes)).setDuration(WAVE_ANIM_EACH_ICON_DURATION));
iconAnim.play(ObjectAnimator.ofPropertyValuesHolder(icon, PropertyValuesHolder.ofKeyframe(View.TRANSLATION_Y, translationYKeyframes)).setDuration(WAVE_ANIM_EACH_ICON_DURATION));
if (icon instanceof PredictedAppIcon) {
// Play slot machine animation through random icons from AllAppsList.
PredictedAppIcon predictedAppIcon = (PredictedAppIcon) icon;
ItemInfo itemInfo = (ItemInfo) icon.getTag();
List<BitmapInfo> iconsToAnimate = mControllers.uiController.getAppIconsForEdu().filter(appInfo -> !TextUtils.equals(appInfo.title, itemInfo.title)).map(appInfo -> appInfo.bitmap).filter(bitmap -> !bitmap.isNullOrLowRes()).collect(Collectors.toList());
// Pick n icons at random.
Collections.shuffle(iconsToAnimate);
if (iconsToAnimate.size() > WAVE_ANIM_SLOT_MACHINE_NUM_ICONS) {
iconsToAnimate = iconsToAnimate.subList(0, WAVE_ANIM_SLOT_MACHINE_NUM_ICONS);
}
Animator slotMachineAnim = predictedAppIcon.createSlotMachineAnim(iconsToAnimate);
if (slotMachineAnim != null) {
iconAnim.play(slotMachineAnim.setDuration(WAVE_ANIM_SLOT_MACHINE_DURATION));
}
}
iconAnim.setStartDelay(WAVE_ANIM_STAGGER * i);
waveAnim.play(iconAnim);
}
waveAnim.setStartDelay(WAVE_ANIM_DELAY);
return waveAnim;
}
use of com.android.launcher3.icons.BitmapInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class ModelUtils method fromLegacyShortcutIntent.
/**
* Creates a workspace item info for the legacy shortcut intent
*/
@SuppressWarnings("deprecation")
public static WorkspaceItemInfo fromLegacyShortcutIntent(Context context, Intent data) {
if (!isValidExtraType(data, Intent.EXTRA_SHORTCUT_INTENT, Intent.class) || !(isValidExtraType(data, Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.class)) || !(isValidExtraType(data, Intent.EXTRA_SHORTCUT_ICON, Bitmap.class))) {
Log.e(TAG, "Invalid install shortcut intent");
return null;
}
Intent launchIntent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
String label = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
if (launchIntent == null || label == null) {
Log.e(TAG, "Invalid install shortcut intent");
return null;
}
final WorkspaceItemInfo info = new WorkspaceItemInfo();
info.user = Process.myUserHandle();
BitmapInfo iconInfo = null;
try (LauncherIcons li = LauncherIcons.obtain(context)) {
Bitmap bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
if (bitmap != null) {
iconInfo = li.createIconBitmap(bitmap);
} else {
info.iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
if (info.iconResource != null) {
iconInfo = li.createIconBitmap(info.iconResource);
}
}
}
if (iconInfo == null) {
Log.e(TAG, "Invalid icon by the app");
return null;
}
info.bitmap = iconInfo;
info.contentDescription = info.title = Utilities.trim(label);
info.intent = launchIntent;
return info;
}
use of com.android.launcher3.icons.BitmapInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class IconCache method getShortcutInfoBadge.
/**
* Returns the badging info for the shortcut
*/
public BitmapInfo getShortcutInfoBadge(ShortcutInfo shortcutInfo) {
ComponentName cn = shortcutInfo.getActivity();
if (cn != null) {
// Get the app info for the source activity.
AppInfo appInfo = new AppInfo();
appInfo.user = shortcutInfo.getUserHandle();
appInfo.componentName = cn;
appInfo.intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(cn);
getTitleAndIcon(appInfo, false);
return appInfo.bitmap;
} else {
PackageItemInfo pkgInfo = new PackageItemInfo(shortcutInfo.getPackage(), shortcutInfo.getUserHandle());
getTitleAndIconForApp(pkgInfo, false);
return pkgInfo.bitmap;
}
}
use of com.android.launcher3.icons.BitmapInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class TaskIconCache method getCacheEntry.
@WorkerThread
private TaskCacheEntry getCacheEntry(Task task) {
TaskCacheEntry entry = mIconCache.getAndInvalidateIfModified(task.key);
if (entry != null) {
return entry;
}
TaskDescription desc = task.taskDescription;
TaskKey key = task.key;
ActivityInfo activityInfo = null;
// Create new cache entry
entry = new TaskCacheEntry();
// Load icon
// TODO: Load icon resource (b/143363444)
Bitmap icon = TaskDescriptionCompat.getIcon(desc, key.userId);
if (icon != null) {
/* isInstantApp */
entry.icon = getBitmapInfo(new BitmapDrawable(mContext.getResources(), icon), key.userId, desc.getPrimaryColor(), false).newIcon(mContext);
} else {
activityInfo = PackageManagerWrapper.getInstance().getActivityInfo(key.getComponent(), key.userId);
if (activityInfo != null) {
BitmapInfo bitmapInfo = getBitmapInfo(mIconProvider.getIcon(activityInfo), key.userId, desc.getPrimaryColor(), activityInfo.applicationInfo.isInstantApp());
entry.icon = bitmapInfo.newIcon(mContext);
} else {
entry.icon = getDefaultIcon(key.userId);
}
}
// Loading content descriptions if accessibility or low RAM recents is enabled.
if (GO_LOW_RAM_RECENTS_ENABLED || mAccessibilityManager.isEnabled()) {
// Skip loading the content description if the activity no longer exists
if (activityInfo == null) {
activityInfo = PackageManagerWrapper.getInstance().getActivityInfo(key.getComponent(), key.userId);
}
if (activityInfo != null) {
entry.contentDescription = getBadgedContentDescription(activityInfo, task.key.userId, task.taskDescription);
}
}
mIconCache.put(task.key, entry);
return entry;
}
use of com.android.launcher3.icons.BitmapInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class TaskIconCache method getBitmapInfo.
@WorkerThread
private BitmapInfo getBitmapInfo(Drawable drawable, int userId, int primaryColor, boolean isInstantApp) {
try (BaseIconFactory bif = getIconFactory()) {
bif.disableColorExtraction();
bif.setWrapperBackgroundColor(primaryColor);
// User version code O, so that the icon is always wrapped in an adaptive icon container
return bif.createBadgedIconBitmap(drawable, UserHandle.of(userId), Build.VERSION_CODES.O, isInstantApp);
}
}
Aggregations