Search in sources :

Example 96 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class DefaultAppSearchAlgorithm method getTitleMatchResult.

/**
 * Filters {@link AppInfo}s matching specified query
 */
@AnyThread
public static ArrayList<AdapterItem> getTitleMatchResult(List<AppInfo> apps, 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<AdapterItem> result = new ArrayList<>();
    StringMatcherUtility.StringMatcher matcher = StringMatcherUtility.StringMatcher.getInstance();
    int resultCount = 0;
    int total = apps.size();
    for (int i = 0; i < total && resultCount < MAX_RESULTS_COUNT; i++) {
        AppInfo info = apps.get(i);
        if (StringMatcherUtility.matches(queryTextLower, info.title.toString(), matcher)) {
            AdapterItem appItem = AdapterItem.asApp(resultCount, "", info, resultCount);
            result.add(appItem);
            resultCount++;
        }
    }
    return result;
}
Also used : StringMatcherUtility(com.android.launcher3.search.StringMatcherUtility) ArrayList(java.util.ArrayList) AdapterItem(com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem) AppInfo(com.android.launcher3.model.data.AppInfo) AnyThread(androidx.annotation.AnyThread)

Example 97 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class CacheDataUpdatedTaskTest method testCacheUpdate_update_apps.

@Test
public void testCacheUpdate_update_apps() throws Exception {
    // Clear all icons from apps list so that its easy to check what was updated
    for (AppInfo info : mModelHelper.getAllAppsList().data) {
        info.bitmap = BitmapInfo.LOW_RES_INFO;
    }
    mModelHelper.executeTaskForTest(newTask(CacheDataUpdatedTask.OP_CACHE_UPDATE, "app1"));
    // Verify that only the app icons of app1 (id 1 & 2) are updated. Custom shortcut (id 7)
    // is not updated
    verifyUpdate(1, 2);
    // Verify that only app1 var updated in allAppsList
    assertFalse(mModelHelper.getAllAppsList().data.isEmpty());
    for (AppInfo info : mModelHelper.getAllAppsList().data) {
        if (info.componentName.getPackageName().equals("app1")) {
            assertFalse(info.bitmap.isNullOrLowRes());
        } else {
            assertTrue(info.bitmap.isNullOrLowRes());
        }
    }
}
Also used : AppInfo(com.android.launcher3.model.data.AppInfo) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 98 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class FolderNameProviderTest method setUp.

@Before
public void setUp() {
    mContext = getApplicationContext();
    mItem1 = new WorkspaceItemInfo(new AppInfo(new ComponentName("a.b.c", "a.b.c/a.b.c.d"), "title1", UserHandle.of(10), new Intent().setComponent(new ComponentName("a.b.c", "a.b.c/a.b.c.d"))));
    mItem2 = new WorkspaceItemInfo(new AppInfo(new ComponentName("a.b.c", "a.b.c/a.b.c.d"), "title2", UserHandle.of(10), new Intent().setComponent(new ComponentName("a.b.c", "a.b.c/a.b.c.d"))));
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo) Before(org.junit.Before)

Example 99 with AppInfo

use of com.android.launcher3.model.data.AppInfo 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;
}
Also used : TimeInterpolator(android.animation.TimeInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ItemInfo(com.android.launcher3.model.data.ItemInfo) DEACCEL(com.android.launcher3.anim.Interpolators.DEACCEL) TextUtils(android.text.TextUtils) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) ACCEL_2(com.android.launcher3.anim.Interpolators.ACCEL_2) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Collectors(java.util.stream.Collectors) FAST_OUT_SLOW_IN(com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN) BitmapInfo(com.android.launcher3.icons.BitmapInfo) List(java.util.List) PropertyValuesHolder(android.animation.PropertyValuesHolder) R(com.android.launcher3.R) Keyframe(android.animation.Keyframe) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) SCALE_PROPERTY(com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY) Collections(java.util.Collections) ACCEL_DEACCEL(com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL) Resources(android.content.res.Resources) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) Keyframe(android.animation.Keyframe) ItemInfo(com.android.launcher3.model.data.ItemInfo) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) BitmapInfo(com.android.launcher3.icons.BitmapInfo)

Example 100 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class FolderIcon method onDrop.

public void onDrop(DragObject d, boolean itemReturnedOnFailedDrop) {
    WorkspaceItemInfo item;
    if (d.dragInfo instanceof AppInfo) {
        // Came from all apps -- make a copy
        item = ((AppInfo) d.dragInfo).makeWorkspaceItem();
    } else if (d.dragSource instanceof BaseItemDragListener) {
        // Came from a different window -- make a copy
        item = new WorkspaceItemInfo((WorkspaceItemInfo) d.dragInfo);
    } else {
        item = (WorkspaceItemInfo) d.dragInfo;
    }
    mFolder.notifyDrop();
    onDrop(item, d, null, 1.0f, itemReturnedOnFailedDrop ? item.rank : mInfo.contents.size(), itemReturnedOnFailedDrop);
}
Also used : BaseItemDragListener(com.android.launcher3.dragndrop.BaseItemDragListener) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

Aggregations

AppInfo (com.android.launcher3.model.data.AppInfo)181 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)86 ItemInfo (com.android.launcher3.model.data.ItemInfo)46 ArrayList (java.util.ArrayList)46 ComponentName (android.content.ComponentName)36 AppInfo (com.android.launcher3.AppInfo)33 View (android.view.View)32 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)31 Intent (android.content.Intent)30 FolderInfo (com.android.launcher3.model.data.FolderInfo)30 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)30 UserHandle (android.os.UserHandle)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)21 Point (android.graphics.Point)19 BubbleTextView (com.android.launcher3.BubbleTextView)19 LauncherApps (android.content.pm.LauncherApps)17 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)17 PendingAddItemInfo (com.android.launcher3.PendingAddItemInfo)15 AppWidgetHostView (android.appwidget.AppWidgetHostView)14