Search in sources :

Example 86 with FolderInfo

use of com.android.launcher3.model.data.FolderInfo in project Launcher3 by chislon.

the class LauncherTransitionable method onClick.

/**
 * Launches the intent referred by the clicked shortcut.
 *
 * @param v The view representing the clicked shortcut.
 */
public void onClick(View v) {
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null) {
        return;
    }
    if (!mWorkspace.isFinishedSwitchingState()) {
        return;
    }
    if (v instanceof Workspace) {
        if (mWorkspace.isInOverviewMode()) {
            mWorkspace.exitOverviewMode(true);
        }
        return;
    }
    if (v instanceof CellLayout) {
        if (mWorkspace.isInOverviewMode()) {
            mWorkspace.exitOverviewMode(mWorkspace.indexOfChild(v), true);
        }
    }
    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        // Open shortcut
        final ShortcutInfo shortcut = (ShortcutInfo) tag;
        final Intent intent = shortcut.intent;
        // Check for special shortcuts
        if (intent.getComponent() != null) {
            final String shortcutClass = intent.getComponent().getClassName();
            if (shortcutClass.equals(WidgetAdder.class.getName())) {
                showAllApps(true, AppsCustomizePagedView.ContentType.Widgets, true);
                return;
            } else if (shortcutClass.equals(MemoryDumpActivity.class.getName())) {
                MemoryDumpActivity.startDump(this);
                return;
            } else if (shortcutClass.equals(ToggleWeightWatcher.class.getName())) {
                toggleShowWeightWatcher();
                return;
            }
        }
        // Start activities
        int[] pos = new int[2];
        v.getLocationOnScreen(pos);
        intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()));
        boolean success = startActivitySafely(v, intent, tag);
        mStats.recordLaunch(intent, shortcut);
        if (success && v instanceof BubbleTextView) {
            mWaitingForResume = (BubbleTextView) v;
            mWaitingForResume.setStayPressed(true);
        }
    } else if (tag instanceof FolderInfo) {
        if (v instanceof FolderIcon) {
            FolderIcon fi = (FolderIcon) v;
            handleFolderClick(fi);
        }
    } else if (v == mAllAppsButton) {
        if (isAllAppsVisible()) {
            showWorkspace(true);
        } else {
            onClickAllAppsButton(v);
        }
    }
}
Also used : Rect(android.graphics.Rect) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) DragObject(com.android.launcher3.DropTarget.DragObject)

Example 87 with FolderInfo

use of com.android.launcher3.model.data.FolderInfo in project android_packages_apps_404Launcher by P-404.

the class HotseatEduController method placeFoldersInWorkspace.

private int placeFoldersInWorkspace(ArrayDeque<FolderInfo> folders) {
    if (folders.isEmpty())
        return 0;
    Workspace workspace = mLauncher.getWorkspace();
    InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
    GridOccupancy[] occupancyList = new GridOccupancy[workspace.getChildCount()];
    for (int i = 0; i < occupancyList.length; i++) {
        occupancyList[i] = ((CellLayout) workspace.getChildAt(i)).cloneGridOccupancy();
    }
    // scan every screen to find available spots to place folders
    int occupancyIndex = 0;
    int[] itemXY = new int[2];
    while (occupancyIndex < occupancyList.length && !folders.isEmpty()) {
        GridOccupancy occupancy = occupancyList[occupancyIndex];
        if (occupancy.findVacantCell(itemXY, 1, 1)) {
            FolderInfo info = folders.poll();
            mLauncher.getModelWriter().moveItemInDatabase(info, LauncherSettings.Favorites.CONTAINER_DESKTOP, workspace.getScreenIdForPageIndex(occupancyIndex), itemXY[0], itemXY[1]);
            occupancy.markCells(info, true);
        } else {
            occupancyIndex++;
        }
    }
    if (folders.isEmpty())
        return workspace.getScreenIdForPageIndex(occupancyIndex);
    int screenId = LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_SCREEN_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
    // if all screens are full and we still have folders left, put those on a new page
    FolderInfo folderInfo;
    int col = 0;
    while ((folderInfo = folders.poll()) != null) {
        mLauncher.getModelWriter().moveItemInDatabase(folderInfo, LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId, col++, idp.numRows - 1);
    }
    mNewScreens = IntArray.wrap(screenId);
    return workspace.getPageCount();
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) GridOccupancy(com.android.launcher3.util.GridOccupancy) FolderInfo(com.android.launcher3.model.data.FolderInfo) Workspace(com.android.launcher3.Workspace)

Example 88 with FolderInfo

use of com.android.launcher3.model.data.FolderInfo in project android_packages_apps_404Launcher by P-404.

the class TaskbarActivityContext method onTaskbarIconClicked.

protected void onTaskbarIconClicked(View view) {
    Object tag = view.getTag();
    if (tag instanceof Task) {
        Task task = (Task) tag;
        ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key, ActivityOptions.makeBasic());
    } else if (tag instanceof FolderInfo) {
        FolderIcon folderIcon = (FolderIcon) view;
        Folder folder = folderIcon.getFolder();
        setTaskbarWindowFullscreen(true);
        getDragLayer().post(() -> {
            folder.animateOpen();
            getStatsLogManager().logger().withItemInfo(folder.mInfo).log(LAUNCHER_FOLDER_OPEN);
            folder.iterateOverItems((itemInfo, itemView) -> {
                mControllers.taskbarViewController.setClickAndLongClickListenersForIcon(itemView);
                // To play haptic when dragging, like other Taskbar items do.
                itemView.setHapticFeedbackEnabled(true);
                return false;
            });
        });
    } else if (tag instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo info = (WorkspaceItemInfo) tag;
        if (info.isDisabled()) {
            ItemClickHandler.handleDisabledItemClicked(info, this);
        } else {
            Intent intent = new Intent(info.getIntent()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) {
                    Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
                } else if (info.isPromise()) {
                    intent = new PackageManagerHelper(this).getMarketIntent(info.getTargetPackage()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                } else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
                    String id = info.getDeepShortcutId();
                    String packageName = intent.getPackage();
                    getSystemService(LauncherApps.class).startShortcut(packageName, id, null, null, info.user);
                } else if (info.user.equals(Process.myUserHandle())) {
                    startActivity(intent);
                } else {
                    getSystemService(LauncherApps.class).startMainActivity(intent.getComponent(), info.user, intent.getSourceBounds(), null);
                }
                mControllers.uiController.onTaskbarIconLaunched(info);
            } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
                Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
                Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
            }
        }
    } else {
        Log.e(TAG, "Unknown type clicked: " + tag);
    }
    AbstractFloatingView.closeAllOpenViews(this);
}
Also used : Rect(android.graphics.Rect) Task(com.android.systemui.shared.recents.model.Task) Config(android.content.pm.ActivityInfo.Config) NonNull(androidx.annotation.NonNull) WindowManager(android.view.WindowManager) FrameLayout(android.widget.FrameLayout) Process(android.os.Process) ITYPE_BOTTOM_TAPPABLE_ELEMENT(com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT) ActivityOptions(android.app.ActivityOptions) ActivityManagerWrapper(com.android.systemui.shared.system.ActivityManagerWrapper) WindowManagerWrapper(com.android.systemui.shared.system.WindowManagerWrapper) LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS(android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS) LauncherAtom(com.android.launcher3.logger.LauncherAtom) ContextThemeWrapper(android.view.ContextThemeWrapper) FolderInfo(com.android.launcher3.model.data.FolderInfo) Display(android.view.Display) View(android.view.View) RotationButtonController(com.android.systemui.shared.rotation.RotationButtonController) Log(android.util.Log) SysUINavigationMode(com.android.quickstep.SysUINavigationMode) Favorites(com.android.launcher3.LauncherSettings.Favorites) Mode(com.android.quickstep.SysUINavigationMode.Mode) TYPE_NAVIGATION_BAR_PANEL(android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL) LauncherApps(android.content.pm.LauncherApps) DeviceProfile(com.android.launcher3.DeviceProfile) Nullable(androidx.annotation.Nullable) ActivityNotFoundException(android.content.ActivityNotFoundException) ITYPE_EXTRA_NAVIGATION_BAR(com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR) LAUNCHER_FOLDER_OPEN(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN) Themes(com.android.launcher3.util.Themes) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) SettingsCache(com.android.launcher3.util.SettingsCache) Insets(android.graphics.Insets) FolderIcon(com.android.launcher3.folder.FolderIcon) ScopedUnfoldTransitionProgressProvider(com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider) Intent(android.content.Intent) PixelFormat(android.graphics.PixelFormat) SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) ViewCache(com.android.launcher3.util.ViewCache) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Toast(android.widget.Toast) AnimatorSet(android.animation.AnimatorSet) Settings(android.provider.Settings) SYSUI_STATE_QUICK_SETTINGS_EXPANDED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED) ActivityContext(com.android.launcher3.views.ActivityContext) LayoutInflater(android.view.LayoutInflater) MATCH_PARENT(android.view.ViewGroup.LayoutParams.MATCH_PARENT) ItemClickHandler(com.android.launcher3.touch.ItemClickHandler) SystemProperties(android.os.SystemProperties) Gravity(android.view.Gravity) R(com.android.launcher3.R) RoundedCorner(android.view.RoundedCorner) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) TraceHelper(com.android.launcher3.util.TraceHelper) Resources(android.content.res.Resources) Task(com.android.systemui.shared.recents.model.Task) Intent(android.content.Intent) LauncherApps(android.content.pm.LauncherApps) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) ActivityNotFoundException(android.content.ActivityNotFoundException) FolderIcon(com.android.launcher3.folder.FolderIcon) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 89 with FolderInfo

use of com.android.launcher3.model.data.FolderInfo in project android_packages_apps_404Launcher by P-404.

the class QuickstepModelDelegate method modelLoadComplete.

@Override
@WorkerThread
public void modelLoadComplete() {
    super.modelLoadComplete();
    // Log snapshot of the model
    SharedPreferences prefs = getDevicePrefs(mApp.getContext());
    long lastSnapshotTimeMillis = prefs.getLong(LAST_SNAPSHOT_TIME_MILLIS, 0);
    // Log snapshot only if previous snapshot was older than a day
    long now = System.currentTimeMillis();
    if (now - lastSnapshotTimeMillis < DAY_IN_MILLIS) {
        if (IS_DEBUG) {
            String elapsedTime = formatElapsedTime((now - lastSnapshotTimeMillis) / 1000);
            Log.d(TAG, String.format("Skipped snapshot logging since previous snapshot was %s old.", elapsedTime));
        }
    } else {
        IntSparseArrayMap<ItemInfo> itemsIdMap;
        synchronized (mDataModel) {
            itemsIdMap = mDataModel.itemsIdMap.clone();
        }
        InstanceId instanceId = new InstanceIdSequence().newInstanceId();
        for (ItemInfo info : itemsIdMap) {
            FolderInfo parent = getContainer(info, itemsIdMap);
            StatsLogCompatManager.writeSnapshot(info.buildProto(parent), instanceId);
        }
        additionalSnapshotEvents(instanceId);
        prefs.edit().putLong(LAST_SNAPSHOT_TIME_MILLIS, now).apply();
    }
    // instance, as there will be additional instances that may be destroyed at any time.
    if (mIsPrimaryInstance) {
        registerSnapshotLoggingCallback();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) PredictionHelper.getAppTargetFromItemInfo(com.android.launcher3.model.PredictionHelper.getAppTargetFromItemInfo) InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkerThread(androidx.annotation.WorkerThread)

Example 90 with FolderInfo

use of com.android.launcher3.model.data.FolderInfo in project android_packages_apps_404Launcher by P-404.

the class Launcher method addFolder.

/**
 * Creates and adds new folder to CellLayout
 */
public FolderIcon addFolder(CellLayout layout, int container, final int screenId, int cellX, int cellY) {
    final FolderInfo folderInfo = new FolderInfo();
    // Update the model
    getModelWriter().addItemToDatabase(folderInfo, container, screenId, cellX, cellY);
    // Create the view
    FolderIcon newFolder = FolderIcon.inflateFolderAndIcon(R.layout.folder_icon, this, layout, folderInfo);
    mWorkspace.addInScreen(newFolder, folderInfo);
    // Force measure the new folder icon
    CellLayout parent = mWorkspace.getParentCellLayoutForView(newFolder);
    parent.getShortcutsAndWidgets().measureChild(newFolder);
    return newFolder;
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) FolderInfo(com.android.launcher3.model.data.FolderInfo)

Aggregations

FolderInfo (com.android.launcher3.model.data.FolderInfo)152 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)121 ItemInfo (com.android.launcher3.model.data.ItemInfo)100 View (android.view.View)98 FolderIcon (com.android.launcher3.folder.FolderIcon)73 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)65 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)61 ArrayList (java.util.ArrayList)59 AppWidgetHostView (android.appwidget.AppWidgetHostView)55 DragView (com.android.launcher3.dragndrop.DragView)51 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)50 Point (android.graphics.Point)47 AppInfo (com.android.launcher3.model.data.AppInfo)41 SuppressLint (android.annotation.SuppressLint)39 Rect (android.graphics.Rect)28 Folder (com.android.launcher3.folder.Folder)28 IntArray (com.android.launcher3.util.IntArray)28 HashSet (java.util.HashSet)28 UserHandle (android.os.UserHandle)27 Intent (android.content.Intent)26