Search in sources :

Example 36 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatPredictionController method mapToWorkspaceItemInfo.

private List<WorkspaceItemInfo> mapToWorkspaceItemInfo(List<ComponentKeyMapper> components) {
    AllAppsStore allAppsStore = mLauncher.getAppsView().getAppsStore();
    if (allAppsStore.getApps().length == 0) {
        return Collections.emptyList();
    }
    List<WorkspaceItemInfo> predictedApps = new ArrayList<>();
    for (ComponentKeyMapper mapper : components) {
        ItemInfoWithIcon info = mapper.getApp(allAppsStore);
        if (info instanceof AppInfo) {
            WorkspaceItemInfo predictedApp = new WorkspaceItemInfo((AppInfo) info);
            predictedApp.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
            predictedApps.add(predictedApp);
        } else if (info instanceof WorkspaceItemInfo) {
            WorkspaceItemInfo predictedApp = new WorkspaceItemInfo((WorkspaceItemInfo) info);
            predictedApp.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
            predictedApps.add(predictedApp);
        } else {
            if (DEBUG) {
                Log.e(TAG, "Predicted app not found: " + mapper);
            }
        }
        // Stop at the number of hotseat items
        if (predictedApps.size() == mHotSeatItemsCount) {
            break;
        }
    }
    return predictedApps;
}
Also used : ArrayList(java.util.ArrayList) AllAppsStore(com.android.launcher3.allapps.AllAppsStore) ComponentKeyMapper(com.android.launcher3.appprediction.ComponentKeyMapper) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 37 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.

the class OverviewState method getHotseatScaleAndTranslation.

@Override
public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) {
    if ((getVisibleElements(launcher) & HOTSEAT_ICONS) != 0) {
        DeviceProfile dp = launcher.getDeviceProfile();
        if (dp.allAppsIconSizePx >= dp.iconSizePx) {
            return new ScaleAndTranslation(1, 0, 0);
        } else {
            float scale = ((float) dp.allAppsIconSizePx) / dp.iconSizePx;
            // Distance between the screen center (which is the pivotY for hotseat) and the
            // bottom of the hotseat (which we want to preserve)
            float distanceFromBottom = dp.heightPx / 2 - dp.hotseatBarBottomPaddingPx;
            // On scaling, the bottom edge is moved closer to the pivotY. We move the
            // hotseat back down so that the bottom edge's position is preserved.
            float translationY = distanceFromBottom * (1 - scale);
            return new ScaleAndTranslation(scale, 0, translationY);
        }
    }
    return getWorkspaceScaleAndTranslation(launcher);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile)

Example 38 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatEduController method migrateHotseatWhole.

/**
 * This migration option attempts to move the entire hotseat up to the first workspace that
 * has space to host items. If no such page is found, it moves items to a new page.
 *
 * @return pageId where items are migrated
 */
private int migrateHotseatWhole() {
    Workspace workspace = mLauncher.getWorkspace();
    int pageId = -1;
    int toRow = 0;
    for (int i = 0; i < workspace.getPageCount(); i++) {
        CellLayout target = workspace.getScreenWithId(workspace.getScreenIdForPageIndex(i));
        if (target.makeSpaceForHotseatMigration(true)) {
            toRow = mLauncher.getDeviceProfile().inv.numRows - 1;
            pageId = i;
            break;
        }
    }
    if (pageId == -1) {
        pageId = LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_SCREEN_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
        mNewScreens = IntArray.wrap(pageId);
    }
    for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) {
        View child = mHotseat.getChildAt(i, 0);
        if (child == null || child.getTag() == null)
            continue;
        ItemInfo tag = (ItemInfo) child.getTag();
        if (tag.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION)
            continue;
        mLauncher.getModelWriter().moveItemInDatabase(tag, LauncherSettings.Favorites.CONTAINER_DESKTOP, pageId, i, toRow);
        mNewItems.add(tag);
    }
    return pageId;
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ArrowTipView(com.android.launcher3.views.ArrowTipView) View(android.view.View) Workspace(com.android.launcher3.Workspace)

Example 39 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.

the class DiscoveryBounce method showForHomeIfNeeded.

private static void showForHomeIfNeeded(Launcher launcher, boolean withDelay) {
    OnboardingPrefs onboardingPrefs = launcher.getOnboardingPrefs();
    if (!launcher.isInState(NORMAL) || onboardingPrefs.getBoolean(OnboardingPrefs.HOME_BOUNCE_SEEN) || AbstractFloatingView.getTopOpenView(launcher) != null || launcher.getSystemService(UserManager.class).isDemoUser() || Utilities.IS_RUNNING_IN_TEST_HARNESS) {
        return;
    }
    if (withDelay) {
        new Handler().postDelayed(() -> showForHomeIfNeeded(launcher, false), DELAY_MS);
        return;
    }
    onboardingPrefs.incrementEventCount(OnboardingPrefs.HOME_BOUNCE_COUNT);
    new DiscoveryBounce(launcher, 0).show(HOTSEAT);
}
Also used : OnboardingPrefs(com.android.launcher3.util.OnboardingPrefs) UserManager(android.os.UserManager) Handler(android.os.Handler) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 40 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.

the class Folder method replaceFolderWithFinalItem.

@Thunk
void replaceFolderWithFinalItem() {
    // Add the last remaining child to the workspace in place of the folder
    Runnable onCompleteRunnable = new Runnable() {

        @Override
        public void run() {
            int itemCount = getItemCount();
            if (itemCount <= 1) {
                View newIcon = null;
                WorkspaceItemInfo finalItem = null;
                if (itemCount == 1) {
                    // Move the item from the folder to the workspace, in the position of the
                    // folder
                    CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screenId);
                    finalItem = mInfo.contents.remove(0);
                    newIcon = mLauncher.createShortcut(cellLayout, finalItem);
                    mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem, mInfo.container, mInfo.screenId, mInfo.cellX, mInfo.cellY);
                }
                // Remove the folder
                mLauncher.removeItem(mFolderIcon, mInfo, true);
                if (mFolderIcon instanceof DropTarget) {
                    mDragController.removeDropTarget((DropTarget) mFolderIcon);
                }
                if (newIcon != null) {
                    // We add the child after removing the folder to prevent both from existing
                    // at the same time in the CellLayout.  We need to add the new item with
                    // addInScreenFromBind() to ensure that hotseat items are placed correctly.
                    mLauncher.getWorkspace().addInScreenFromBind(newIcon, mInfo);
                    // Focus the newly created child
                    newIcon.requestFocus();
                }
                if (finalItem != null) {
                    mLauncher.folderConvertedToItem(mFolderIcon.getFolder(), finalItem);
                }
            }
        }
    };
    View finalChild = mContent.getLastItem();
    if (finalChild != null) {
        mFolderIcon.performDestroyAnimation(onCompleteRunnable);
    } else {
        onCompleteRunnable.run();
    }
    mDestroyed = true;
}
Also used : CellLayout(com.android.launcher3.CellLayout) DropTarget(com.android.launcher3.DropTarget) ClipPathView(com.android.launcher3.views.ClipPathView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) PagedView(com.android.launcher3.PagedView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) SuppressLint(android.annotation.SuppressLint) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Thunk(com.android.launcher3.util.Thunk)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)67 View (android.view.View)66 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)46 Point (android.graphics.Point)27 ArrayList (java.util.ArrayList)27 CellLayout (com.android.launcher3.CellLayout)26 ViewGroup (android.view.ViewGroup)23 BubbleTextView (com.android.launcher3.BubbleTextView)23 FolderInfo (com.android.launcher3.model.data.FolderInfo)23 ArrowTipView (com.android.launcher3.views.ArrowTipView)22 FolderIcon (com.android.launcher3.folder.FolderIcon)20 SuppressLint (android.annotation.SuppressLint)19 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)19 Hotseat (com.android.launcher3.Hotseat)16 Intent (android.content.Intent)15 IntArray (com.android.launcher3.util.IntArray)13 Workspace (com.android.launcher3.Workspace)12 DraggableView (com.android.launcher3.dragndrop.DraggableView)12 HashSet (java.util.HashSet)12 AppWidgetHostView (android.appwidget.AppWidgetHostView)11