Search in sources :

Example 1 with Launcher

use of com.android.launcher3.Launcher in project ADWLauncher2 by boombuler.

the class DefaultAction method GetActions.

public static void GetActions(List<LauncherActions.Action> list) {
    Launcher launcher = LauncherActions.getInstance().getLauncher();
    if (launcher == null)
        return;
    list.add(getAction(launcher, ACTION_OPENCLOSE_DRAWER));
    list.add(getAction(launcher, ACTION_SHOW_ADW_SETTINGS));
    list.add(getAction(launcher, ACTION_SHOW_NOTIFICATIONS));
    list.add(getAction(launcher, ACTION_MANAGE_APPS));
    list.add(getAction(launcher, ACTION_SYSTEM_SETTINGS));
}
Also used : Launcher(org.adw.launcher2.Launcher)

Example 2 with Launcher

use of com.android.launcher3.Launcher in project Launcher3 by chislon.

the class LauncherBackupHelper method backupWidgets.

/**
 * Write all the static widget resources we need to render placeholders
 * for a package that is not installed.
 *
 * @param in notes from last backup
 * @param data output stream for key/value pairs
 * @param out notes about this backup
 * @param keys keys to mark as clean in the notes for next backup
 * @throws IOException
 */
private void backupWidgets(Journal in, BackupDataOutput data, Journal out, ArrayList<Key> keys) throws IOException {
    // persist static widget info that hasn't been persisted yet
    final LauncherAppState appState = LauncherAppState.getInstanceNoCreate();
    if (appState == null) {
        // try again later
        dataChanged();
        if (DEBUG)
            Log.d(TAG, "Launcher is not initialized, delaying widget backup");
        return;
    }
    final ContentResolver cr = mContext.getContentResolver();
    final WidgetPreviewLoader previewLoader = new WidgetPreviewLoader(mContext);
    final PagedViewCellLayout widgetSpacingLayout = new PagedViewCellLayout(mContext);
    final IconCache iconCache = appState.getIconCache();
    final int dpi = mContext.getResources().getDisplayMetrics().densityDpi;
    final DeviceProfile profile = appState.getDynamicGrid().getDeviceProfile();
    if (DEBUG)
        Log.d(TAG, "cellWidthPx: " + profile.cellWidthPx);
    // read the old ID set
    Set<String> savedIds = getSavedIdsByType(Key.WIDGET, in);
    if (DEBUG)
        Log.d(TAG, "widgets savedIds.size()=" + savedIds.size());
    int startRows = out.rows;
    if (DEBUG)
        Log.d(TAG, "starting here: " + startRows);
    String where = Favorites.ITEM_TYPE + "=" + Favorites.ITEM_TYPE_APPWIDGET;
    Cursor cursor = cr.query(Favorites.CONTENT_URI, FAVORITE_PROJECTION, where, null, null);
    Set<String> currentIds = new HashSet<String>(cursor.getCount());
    try {
        cursor.moveToPosition(-1);
        while (cursor.moveToNext()) {
            final long id = cursor.getLong(ID_INDEX);
            final String providerName = cursor.getString(APPWIDGET_PROVIDER_INDEX);
            final int spanX = cursor.getInt(SPANX_INDEX);
            final int spanY = cursor.getInt(SPANY_INDEX);
            final ComponentName provider = ComponentName.unflattenFromString(providerName);
            Key key = null;
            String backupKey = null;
            if (provider != null) {
                key = getKey(Key.WIDGET, providerName);
                backupKey = keyToBackupKey(key);
                currentIds.add(backupKey);
            } else {
                Log.w(TAG, "empty intent on appwidget: " + id);
            }
            if (savedIds.contains(backupKey)) {
                if (DEBUG)
                    Log.d(TAG, "already saved widget " + backupKey);
                // remember that we already backed this up previously
                keys.add(key);
            } else if (backupKey != null) {
                if (DEBUG)
                    Log.d(TAG, "I can count this high: " + out.rows);
                if ((out.rows - startRows) < MAX_WIDGETS_PER_PASS) {
                    if (DEBUG)
                        Log.d(TAG, "saving widget " + backupKey);
                    previewLoader.setPreviewSize(spanX * profile.cellWidthPx, spanY * profile.cellHeightPx, widgetSpacingLayout);
                    byte[] blob = packWidget(dpi, previewLoader, iconCache, provider);
                    keys.add(key);
                    writeRowToBackup(key, blob, out, data);
                } else {
                    if (DEBUG)
                        Log.d(TAG, "scheduling another run for widget " + backupKey);
                    // too many widgets for this pass, request another.
                    dataChanged();
                }
            }
        }
    } finally {
        cursor.close();
    }
    if (DEBUG)
        Log.d(TAG, "widget currentIds.size()=" + currentIds.size());
    // these IDs must have been deleted
    savedIds.removeAll(currentIds);
    out.rows += removeDeletedKeysFromBackup(savedIds, data);
}
Also used : Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver) ComponentName(android.content.ComponentName) Key(com.android.launcher3.backup.BackupProtos.Key) HashSet(java.util.HashSet)

Example 3 with Launcher

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

the class QuickstepTransitionManager method getBackgroundAnimator.

private ObjectAnimator getBackgroundAnimator(RemoteAnimationTargetCompat[] appTargets) {
    // When launching an app from overview that doesn't map to a task, we still want to just
    // blur the wallpaper instead of the launcher surface as well
    boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW;
    DepthController depthController = mLauncher.getDepthController();
    ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(mLauncher)).setDuration(APP_LAUNCH_DURATION);
    if (allowBlurringLauncher) {
        final SurfaceControl dimLayer;
        if (BlurUtils.supportsBlursOnWindows()) {
            // Create a temporary effect layer, that lives on top of launcher, so we can apply
            // the blur to it. The EffectLayer will be fullscreen, which will help with caching
            // optimizations on the SurfaceFlinger side:
            // - Results would be able to be cached as a texture
            // - There won't be texture allocation overhead, because EffectLayers don't have
            // buffers
            ViewRootImpl viewRootImpl = mLauncher.getDragLayer().getViewRootImpl();
            SurfaceControl parent = viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null;
            dimLayer = new SurfaceControl.Builder().setName("Blur layer").setParent(parent).setOpaque(false).setHidden(false).setEffectLayer().build();
        } else {
            dimLayer = null;
        }
        depthController.setSurface(dimLayer);
        backgroundRadiusAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                depthController.setIsInLaunchTransition(true);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                depthController.setIsInLaunchTransition(false);
                depthController.setSurface(null);
                if (dimLayer != null) {
                    new SurfaceControl.Transaction().remove(dimLayer).apply();
                }
            }
        });
    }
    return backgroundRadiusAnim;
}
Also used : ViewRootImpl(android.view.ViewRootImpl) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) SurfaceControl(android.view.SurfaceControl) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) DepthController(com.android.launcher3.statehandlers.DepthController)

Example 4 with Launcher

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

the class WidgetsPredicationUpdateTaskTest method widgetsRecommendationRan_localFilterDisabled_shouldReturnWidgetsInPredicationOrder.

@Test
public void widgetsRecommendationRan_localFilterDisabled_shouldReturnWidgetsInPredicationOrder() throws Exception {
    ShadowDeviceFlag shadowDeviceFlag = Shadow.extract(FeatureFlags.ENABLE_LOCAL_RECOMMENDED_WIDGETS_FILTER);
    shadowDeviceFlag.setValue(false);
    // 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 : CONTAINER_WIDGETS_PREDICTION(com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION) ViewOnDrawExecutor(com.android.launcher3.util.ViewOnDrawExecutor) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) IconCache(com.android.launcher3.icons.IconCache) AppTarget(android.app.prediction.AppTarget) Process(android.os.Process) MockitoAnnotations(org.mockito.MockitoAnnotations) ReflectionHelpers(org.robolectric.util.ReflectionHelpers) Mockito.doAnswer(org.mockito.Mockito.doAnswer) MAIN_EXECUTOR(com.android.launcher3.util.Executors.MAIN_EXECUTOR) ShadowDeviceFlag(com.android.launcher3.shadows.ShadowDeviceFlag) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Shadow(org.robolectric.shadow.api.Shadow) RuntimeEnvironment(org.robolectric.RuntimeEnvironment) Collectors(java.util.stream.Collectors) RobolectricTestRunner(org.robolectric.RobolectricTestRunner) List(java.util.List) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Context(android.content.Context) MODEL_EXECUTOR(com.android.launcher3.util.Executors.MODEL_EXECUTOR) AppTargetId(android.app.prediction.AppTargetId) AppInfo(com.android.launcher3.model.data.AppInfo) Mock(org.mockito.Mock) ItemInfo(com.android.launcher3.model.data.ItemInfo) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) Shadows.shadowOf(org.robolectric.Shadows.shadowOf) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ShadowAppWidgetManager(org.robolectric.shadows.ShadowAppWidgetManager) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) Before(org.junit.Before) IntArray(com.android.launcher3.util.IntArray) ComponentName(android.content.ComponentName) LauncherAppState(com.android.launcher3.LauncherAppState) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) FeatureFlags(com.android.launcher3.config.FeatureFlags) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) AppWidgetManager(android.appwidget.AppWidgetManager) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ComponentKey(com.android.launcher3.util.ComponentKey) PredictorState(com.android.launcher3.model.QuickstepModelDelegate.PredictorState) AppTarget(android.app.prediction.AppTarget) ShadowDeviceFlag(com.android.launcher3.shadows.ShadowDeviceFlag) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) AppTargetId(android.app.prediction.AppTargetId) Test(org.junit.Test)

Example 5 with Launcher

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

the class ItemInstallQueue method flushQueueInBackground.

@WorkerThread
private void flushQueueInBackground() {
    Launcher launcher = Launcher.ACTIVITY_TRACKER.getCreatedActivity();
    if (launcher == null) {
        // Launcher not loaded
        return;
    }
    ensureQueueLoaded();
    if (mItems.isEmpty()) {
        return;
    }
    List<Pair<ItemInfo, Object>> installQueue = mItems.stream().map(info -> info.getItemInfo(mContext)).collect(Collectors.toList());
    // Add the items and clear queue
    if (!installQueue.isEmpty()) {
        // add log
        launcher.getModel().addAndBindAddedWorkspaceItems(installQueue);
    }
    mItems.clear();
    mStorage.getFile(mContext).delete();
}
Also used : Context(android.content.Context) MODEL_EXECUTOR(com.android.launcher3.util.Executors.MODEL_EXECUTOR) FileLog(com.android.launcher3.logging.FileLog) ItemInfo(com.android.launcher3.model.data.ItemInfo) Pair(android.util.Pair) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) WorkerThread(androidx.annotation.WorkerThread) Preconditions(com.android.launcher3.util.Preconditions) Intent(android.content.Intent) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) ShortcutKey(com.android.launcher3.shortcuts.ShortcutKey) HashSet(java.util.HashSet) PersistedItemArray(com.android.launcher3.util.PersistedItemArray) EXTRA_APPWIDGET_ID(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ITEM_TYPE_APPWIDGET(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET) UserHandle(android.os.UserHandle) Log(android.util.Log) MainThreadInitializedObject(com.android.launcher3.util.MainThreadInitializedObject) Launcher(com.android.launcher3.Launcher) Favorites(com.android.launcher3.LauncherSettings.Favorites) AppInfo.makeLaunchIntent(com.android.launcher3.model.data.AppInfo.makeLaunchIntent) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) ITEM_TYPE_DEEP_SHORTCUT(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) LauncherAppState(com.android.launcher3.LauncherAppState) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) Collectors(java.util.stream.Collectors) AppWidgetManager(android.appwidget.AppWidgetManager) LauncherApps(android.content.pm.LauncherApps) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) List(java.util.List) Nullable(androidx.annotation.Nullable) Stream(java.util.stream.Stream) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ShortcutRequest(com.android.launcher3.shortcuts.ShortcutRequest) Launcher(com.android.launcher3.Launcher) Pair(android.util.Pair) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

Launcher (com.android.launcher3.Launcher)30 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)18 Test (org.junit.Test)17 ItemInfo (com.android.launcher3.model.data.ItemInfo)13 Point (android.graphics.Point)12 DeviceProfile (com.android.launcher3.DeviceProfile)12 ArrayList (java.util.ArrayList)12 ComponentName (android.content.ComponentName)11 Intent (android.content.Intent)11 View (android.view.View)11 LargeTest (androidx.test.filters.LargeTest)11 Context (android.content.Context)10 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)10 Rect (android.graphics.Rect)9 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)9 RecentsView (com.android.quickstep.views.RecentsView)9 LauncherApps (android.content.pm.LauncherApps)6 Paint (android.graphics.Paint)6 UserHandle (android.os.UserHandle)5 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)5