Search in sources :

Example 1 with Launcher

use of org.adw.launcher2.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 org.adw.launcher2.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)

Example 3 with Launcher

use of org.adw.launcher2.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class FolderIcon method onDrop.

private void onDrop(final WorkspaceItemInfo item, DragObject d, Rect finalRect, float scaleRelativeToDragLayer, int index, boolean itemReturnedOnFailedDrop) {
    item.cellX = -1;
    item.cellY = -1;
    DragView animateView = d.dragView;
    // will not have a view to animate
    if (animateView != null && mActivity instanceof Launcher) {
        final Launcher launcher = (Launcher) mActivity;
        DragLayer dragLayer = launcher.getDragLayer();
        Rect from = new Rect();
        dragLayer.getViewRectRelativeToSelf(animateView, from);
        Rect to = finalRect;
        if (to == null) {
            to = new Rect();
            Workspace workspace = launcher.getWorkspace();
            // Set cellLayout and this to it's final state to compute final animation locations
            workspace.setFinalTransitionTransform();
            float scaleX = getScaleX();
            float scaleY = getScaleY();
            setScaleX(1.0f);
            setScaleY(1.0f);
            scaleRelativeToDragLayer = dragLayer.getDescendantRectRelativeToSelf(this, to);
            // Finished computing final animation locations, restore current state
            setScaleX(scaleX);
            setScaleY(scaleY);
            workspace.resetTransitionTransform();
        }
        int numItemsInPreview = Math.min(MAX_NUM_ITEMS_IN_PREVIEW, index + 1);
        boolean itemAdded = false;
        if (itemReturnedOnFailedDrop || index >= MAX_NUM_ITEMS_IN_PREVIEW) {
            List<WorkspaceItemInfo> oldPreviewItems = new ArrayList<>(mCurrentPreviewItems);
            mInfo.add(item, index, false);
            mCurrentPreviewItems.clear();
            mCurrentPreviewItems.addAll(getPreviewItemsOnPage(0));
            if (!oldPreviewItems.equals(mCurrentPreviewItems)) {
                int newIndex = mCurrentPreviewItems.indexOf(item);
                if (newIndex >= 0) {
                    // If the item dropped is going to be in the preview, we update the
                    // index here to reflect its position in the preview.
                    index = newIndex;
                }
                mPreviewItemManager.hidePreviewItem(index, true);
                mPreviewItemManager.onDrop(oldPreviewItems, mCurrentPreviewItems, item);
                itemAdded = true;
            } else {
                removeItem(item, false);
            }
        }
        if (!itemAdded) {
            mInfo.add(item, index, true);
        }
        int[] center = new int[2];
        float scale = getLocalCenterForIndex(index, numItemsInPreview, center);
        center[0] = Math.round(scaleRelativeToDragLayer * center[0]);
        center[1] = Math.round(scaleRelativeToDragLayer * center[1]);
        to.offset(center[0] - animateView.getMeasuredWidth() / 2, center[1] - animateView.getMeasuredHeight() / 2);
        float finalAlpha = index < MAX_NUM_ITEMS_IN_PREVIEW ? 1f : 0f;
        float finalScale = scale * scaleRelativeToDragLayer;
        // Account for potentially different icon sizes with non-default grid settings
        if (d.dragSource instanceof AllAppsContainerView) {
            DeviceProfile grid = mActivity.getDeviceProfile();
            float containerScale = (1f * grid.iconSizePx / grid.allAppsIconSizePx);
            finalScale *= containerScale;
        }
        final int finalIndex = index;
        dragLayer.animateView(animateView, from, to, finalAlpha, 1, 1, finalScale, finalScale, DROP_IN_ANIMATION_DURATION, Interpolators.DEACCEL_2, Interpolators.ACCEL_2, () -> {
            mPreviewItemManager.hidePreviewItem(finalIndex, false);
            mFolder.showItem(item);
        }, DragLayer.ANIMATION_END_DISAPPEAR, null);
        mFolder.hideItem(item);
        if (!itemAdded)
            mPreviewItemManager.hidePreviewItem(index, true);
        FolderNameInfos nameInfos = new FolderNameInfos();
        if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
            Executors.MODEL_EXECUTOR.post(() -> {
                d.folderNameProvider.getSuggestedFolderName(getContext(), mInfo.contents, nameInfos);
                showFinalView(finalIndex, item, nameInfos, d.logInstanceId);
            });
        } else {
            showFinalView(finalIndex, item, nameInfos, d.logInstanceId);
        }
    } else {
        addItem(item);
    }
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) DragView(com.android.launcher3.dragndrop.DragView) DeviceProfile(com.android.launcher3.DeviceProfile) DragLayer(com.android.launcher3.dragndrop.DragLayer) Launcher(com.android.launcher3.Launcher) Workspace(com.android.launcher3.Workspace) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 4 with Launcher

use of org.adw.launcher2.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class DragViewStateAnnouncer method completeAction.

public void completeAction(int announceResId) {
    cancel();
    Launcher launcher = Launcher.getLauncher(mTargetView.getContext());
    launcher.getDragLayer().announceForAccessibility(launcher.getText(announceResId));
}
Also used : Launcher(com.android.launcher3.Launcher)

Example 5 with Launcher

use of org.adw.launcher2.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherActivityInterface method onOneHandedModeStateChanged.

@Override
public void onOneHandedModeStateChanged(boolean activated) {
    Launcher launcher = getCreatedActivity();
    if (launcher == null) {
        return;
    }
    launcher.onOneHandedStateChanged(activated);
}
Also used : Launcher(com.android.launcher3.Launcher) BaseQuickstepLauncher(com.android.launcher3.BaseQuickstepLauncher)

Aggregations

Launcher (com.android.launcher3.Launcher)30 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)8 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)7 Context (android.content.Context)5 ItemInfo (com.android.launcher3.model.data.ItemInfo)5 ComponentName (android.content.ComponentName)4 Intent (android.content.Intent)4 LauncherUIHelper.buildAndBindLauncher (com.android.launcher3.util.LauncherUIHelper.buildAndBindLauncher)4 Test (org.junit.Test)4 LauncherApps (android.content.pm.LauncherApps)3 Point (android.graphics.Point)3 Rect (android.graphics.Rect)3 RepetitiveTest (android.test.RepetitiveTest)3 DeviceProfile (com.android.launcher3.DeviceProfile)3 AppInfo (com.android.launcher3.model.data.AppInfo)3 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)3 PendingIntent (android.app.PendingIntent)2 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)2 ShortcutInfo (android.content.pm.ShortcutInfo)2 UserHandle (android.os.UserHandle)2