use of com.android.launcher3.icons.BitmapInfo in project android_packages_apps_Launcher3 by AOSPA.
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 ArrowOS.
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 ArrowOS.
the class CacheDataUpdatedTaskTest method setup.
@Before
public void setup() throws Exception {
mModelHelper = new LauncherModelHelper();
mModelHelper.initializeData("cache_data_updated_task_data");
// Add placeholder entries in the cache to simulate update
Context context = mModelHelper.sandboxContext;
IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
CachingLogic<ItemInfo> placeholderLogic = new CachingLogic<ItemInfo>() {
@Override
public ComponentName getComponent(ItemInfo info) {
return info.getTargetComponent();
}
@Override
public UserHandle getUser(ItemInfo info) {
return info.user;
}
@Override
public CharSequence getLabel(ItemInfo info) {
return NEW_LABEL_PREFIX + info.id;
}
@NonNull
@Override
public BitmapInfo loadIcon(Context context, ItemInfo info) {
return BitmapInfo.of(Bitmap.createBitmap(1, 1, Config.ARGB_8888), Color.RED);
}
};
UserManager um = context.getSystemService(UserManager.class);
for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
iconCache.addIconToDBAndMemCache(info, placeholderLogic, new PackageInfo(), um.getSerialNumberForUser(info.user), true);
}
}
use of com.android.launcher3.icons.BitmapInfo in project android_packages_apps_Launcher3 by ArrowOS.
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 ArrowOS.
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;
}
Aggregations