Search in sources :

Example 86 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class OptionsPopupView method startSettings.

private static boolean startSettings(View view) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startSettings");
    Launcher launcher = Launcher.getLauncher(view.getContext());
    launcher.startActivity(new Intent(Intent.ACTION_APPLICATION_PREFERENCES).setPackage(launcher.getPackageName()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
    return true;
}
Also used : Launcher(com.android.launcher3.Launcher) Intent(android.content.Intent)

Example 87 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class OptionsPopupView method startWallpaperPicker.

/**
 * Event handler for the wallpaper picker button that appears after a long press
 * on the home screen.
 */
private static boolean startWallpaperPicker(View v) {
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!Utilities.isWallpaperAllowed(launcher)) {
        Toast.makeText(launcher, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
        return false;
    }
    Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK).putExtra(EXTRA_WALLPAPER_OFFSET, launcher.getWorkspace().getWallpaperOffsetForCenterPage()).putExtra(EXTRA_WALLPAPER_LAUNCH_SOURCE, "app_launched_launcher");
    if (!Utilities.existsStyleWallpapers(launcher)) {
        intent.putExtra(EXTRA_WALLPAPER_FLAVOR, "wallpaper_only");
    } else {
        intent.putExtra(EXTRA_WALLPAPER_FLAVOR, "focus_wallpaper");
        intent.setComponent(new ComponentName(launcher.getString(R.string.wallpaper_picker_package), "com.android.customization.picker.CustomizationPickerActivity"));
    }
    String pickerPackage = launcher.getString(R.string.wallpaper_picker_package);
    if (!TextUtils.isEmpty(pickerPackage)) {
        intent.setPackage(pickerPackage);
    }
    return launcher.startActivitySafely(v, intent, placeholderInfo(intent));
}
Also used : Launcher(com.android.launcher3.Launcher) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 88 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class OptionsPopupView method show.

public static OptionsPopupView show(Launcher launcher, RectF targetRect, List<OptionItem> items, boolean shouldAddArrow, int width) {
    OptionsPopupView popup = (OptionsPopupView) launcher.getLayoutInflater().inflate(R.layout.longpress_options_menu, launcher.getDragLayer(), false);
    popup.mTargetRect = targetRect;
    popup.setShouldAddArrow(shouldAddArrow);
    for (OptionItem item : items) {
        DeepShortcutView view = (DeepShortcutView) popup.inflateAndAdd(R.layout.system_shortcut, popup);
        if (width > 0) {
            view.getLayoutParams().width = width;
        }
        view.getIconView().setBackgroundDrawable(item.icon);
        view.getBubbleText().setText(item.label);
        view.setOnClickListener(popup);
        view.setOnLongClickListener(popup);
        popup.mItemMap.put(view, item);
    }
    popup.addPreDrawForColorExtraction(launcher);
    popup.show();
    return popup;
}
Also used : DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView)

Example 89 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class PromiseIconUiTest method testPromiseIcon_addedFromEligibleSession.

@Test
public void testPromiseIcon_addedFromEligibleSession() throws Throwable {
    final String appLabel = "Test Promise App " + UUID.randomUUID().toString();
    final ItemOperator findPromiseApp = (info, view) -> info != null && TextUtils.equals(info.title, appLabel);
    // Create and add test session
    mSessionId = createSession(appLabel, Bitmap.createBitmap(100, 100, Bitmap.Config.ALPHA_8));
    // Verify promise icon is added
    waitForLauncherCondition("Test Promise App not found on workspace", launcher -> launcher.getWorkspace().getFirstMatch(findPromiseApp) != null);
    // Remove session
    mTargetContext.getPackageManager().getPackageInstaller().abandonSession(mSessionId);
    mSessionId = -1;
    // Verify promise icon is removed
    waitForLauncherCondition("Test Promise App not removed from workspace", launcher -> launcher.getWorkspace().getFirstMatch(findPromiseApp) == null);
}
Also used : AndroidJUnit4(androidx.test.runner.AndroidJUnit4) Launcher(com.android.launcher3.Launcher) PackageManager(android.content.pm.PackageManager) ItemOperator(com.android.launcher3.util.LauncherBindableItemsContainer.ItemOperator) RunWith(org.junit.runner.RunWith) TextUtils(android.text.TextUtils) Test(org.junit.Test) UUID(java.util.UUID) SessionParams(android.content.pm.PackageInstaller.SessionParams) LauncherState(com.android.launcher3.LauncherState) Bitmap(android.graphics.Bitmap) After(org.junit.After) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest) ItemOperator(com.android.launcher3.util.LauncherBindableItemsContainer.ItemOperator) Test(org.junit.Test) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest)

Example 90 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsPredicationUpdateTaskTest method widgetsRecommendationRan_localFilterDisabled_shouldReturnWidgetsInPredicationOrder.

@Test
public void widgetsRecommendationRan_localFilterDisabled_shouldReturnWidgetsInPredicationOrder() throws Exception {
    if (FeatureFlags.ENABLE_LOCAL_RECOMMENDED_WIDGETS_FILTER.get()) {
        return;
    }
    // WHEN newPredicationTask is executed with 5 predicated widgets.
    AppTarget widget1 = new AppTarget(new AppTargetId("app1"), "app1", "provider1", mUserHandle);
    AppTarget widget2 = new AppTarget(new AppTargetId("app1"), "app1", "provider2", mUserHandle);
    // Not installed app
    AppTarget widget3 = new AppTarget(new AppTargetId("app2"), "app3", "provider1", mUserHandle);
    // Not installed widget
    AppTarget widget4 = new AppTarget(new AppTargetId("app4"), "app4", "provider3", mUserHandle);
    AppTarget widget5 = new AppTarget(new AppTargetId("app5"), "app5", "provider1", mUserHandle);
    mModelHelper.executeTaskForTest(newWidgetsPredicationTask(List.of(widget5, widget3, widget2, widget4, widget1))).forEach(Runnable::run);
    // THEN only 3 widgets are returned because the launcher only filters out non-exist widgets.
    List<PendingAddWidgetInfo> recommendedWidgets = mCallback.mRecommendedWidgets.items.stream().map(itemInfo -> (PendingAddWidgetInfo) itemInfo).collect(Collectors.toList());
    assertThat(recommendedWidgets).hasSize(3);
    assertWidgetInfo(recommendedWidgets.get(0).info, mApp5Provider1);
    assertWidgetInfo(recommendedWidgets.get(1).info, mApp1Provider2);
    assertWidgetInfo(recommendedWidgets.get(2).info, mApp1Provider1);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) CONTAINER_WIDGETS_PREDICTION(com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION) Arrays(java.util.Arrays) MODEL_EXECUTOR(com.android.launcher3.util.Executors.MODEL_EXECUTOR) AppTargetId(android.app.prediction.AppTargetId) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) RunWith(org.junit.runner.RunWith) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) IconCache(com.android.launcher3.icons.IconCache) AppTarget(android.app.prediction.AppTarget) MockitoAnnotations(org.mockito.MockitoAnnotations) Process.myUserHandle(android.os.Process.myUserHandle) Mockito.doAnswer(org.mockito.Mockito.doAnswer) UserHandle(android.os.UserHandle) After(org.junit.After) MAIN_EXECUTOR(com.android.launcher3.util.Executors.MAIN_EXECUTOR) WidgetUtils.createAppWidgetProviderInfo(com.android.launcher3.util.WidgetUtils.createAppWidgetProviderInfo) Mockito.doReturn(org.mockito.Mockito.doReturn) Log(android.util.Log) Before(org.junit.Before) SmallTest(androidx.test.filters.SmallTest) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) ComponentName(android.content.ComponentName) LauncherAppState(com.android.launcher3.LauncherAppState) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) Collectors(java.util.stream.Collectors) AppWidgetManager(android.appwidget.AppWidgetManager) List(java.util.List) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) PredictorState(com.android.launcher3.model.QuickstepModelDelegate.PredictorState) AppTarget(android.app.prediction.AppTarget) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) AppTargetId(android.app.prediction.AppTargetId) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

Launcher (com.android.launcher3.Launcher)194 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)102 Test (org.junit.Test)102 View (android.view.View)87 LargeTest (androidx.test.filters.LargeTest)83 ItemInfo (com.android.launcher3.model.data.ItemInfo)83 Rect (android.graphics.Rect)80 Point (android.graphics.Point)77 Intent (android.content.Intent)71 ArrayList (java.util.ArrayList)69 DeviceProfile (com.android.launcher3.DeviceProfile)66 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)64 Context (android.content.Context)61 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)49 RecentsView (com.android.quickstep.views.RecentsView)46 DragLayer (com.android.launcher3.dragndrop.DragLayer)45 ComponentName (android.content.ComponentName)43 FolderInfo (com.android.launcher3.model.data.FolderInfo)42 ViewGroup (android.view.ViewGroup)41 AllApps (com.android.launcher3.tapl.AllApps)40