Search in sources :

Example 6 with Hotseat

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

the class LoaderCursor method checkItemPlacement.

/**
 * check & update map of what's occupied; used to discard overlapping/invalid items
 */
protected boolean checkItemPlacement(ItemInfo item) {
    int containerIndex = item.screenId;
    if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        final GridOccupancy hotseatOccupancy = occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT);
        if (item.screenId >= mIDP.numDatabaseHotseatIcons) {
            Log.e(TAG, "Error loading shortcut " + item + " into hotseat position " + item.screenId + ", position out of bounds: (0 to " + (mIDP.numDatabaseHotseatIcons - 1) + ")");
            return false;
        }
        if (hotseatOccupancy != null) {
            if (hotseatOccupancy.cells[(int) item.screenId][0]) {
                Log.e(TAG, "Error loading shortcut into hotseat " + item + " into position (" + item.screenId + ":" + item.cellX + "," + item.cellY + ") already occupied");
                return false;
            } else {
                hotseatOccupancy.cells[item.screenId][0] = true;
                return true;
            }
        } else {
            final GridOccupancy occupancy = new GridOccupancy(mIDP.numDatabaseHotseatIcons, 1);
            occupancy.cells[item.screenId][0] = true;
            occupied.put(LauncherSettings.Favorites.CONTAINER_HOTSEAT, occupancy);
            return true;
        }
    } else if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        // Skip further checking if it is not the hotseat or workspace container
        return true;
    }
    final int countX = mIDP.numColumns;
    final int countY = mIDP.numRows;
    if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP && item.cellX < 0 || item.cellY < 0 || item.cellX + item.spanX > countX || item.cellY + item.spanY > countY) {
        Log.e(TAG, "Error loading shortcut " + item + " into cell (" + containerIndex + "-" + item.screenId + ":" + item.cellX + "," + item.cellY + ") out of screen bounds ( " + countX + "x" + countY + ")");
        return false;
    }
    if (!occupied.containsKey(item.screenId)) {
        GridOccupancy screen = new GridOccupancy(countX + 1, countY + 1);
        if (item.screenId == Workspace.FIRST_SCREEN_ID) {
            // Mark the first row as occupied (if the feature is enabled)
            // in order to account for the QSB.
            int spanY = FeatureFlags.EXPANDED_SMARTSPACE.get() ? 2 : 1;
            screen.markCells(0, 0, countX + 1, spanY, FeatureFlags.QSB_ON_FIRST_SCREEN);
        }
        occupied.put(item.screenId, screen);
    }
    final GridOccupancy occupancy = occupied.get(item.screenId);
    // Check if any workspace icons overlap with each other
    if (occupancy.isRegionVacant(item.cellX, item.cellY, item.spanX, item.spanY)) {
        occupancy.markCells(item, true);
        return true;
    } else {
        Log.e(TAG, "Error loading shortcut " + item + " into cell (" + containerIndex + "-" + item.screenId + ":" + item.cellX + "," + item.cellX + "," + item.spanX + "," + item.spanY + ") already occupied");
        return false;
    }
}
Also used : GridOccupancy(com.android.launcher3.util.GridOccupancy)

Example 7 with Hotseat

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

the class ModelUtils method getMissingHotseatRanks.

/**
 * Iterates though current workspace items and returns available hotseat ranks for prediction.
 */
public static IntArray getMissingHotseatRanks(List<ItemInfo> items, int len) {
    IntSet seen = new IntSet();
    items.stream().filter(info -> info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT).forEach(i -> seen.add(i.screenId));
    IntArray result = new IntArray(len);
    IntStream.range(0, len).filter(i -> !seen.contains(i)).forEach(result::add);
    return result;
}
Also used : Utilities(com.android.launcher3.Utilities) IntStream(java.util.stream.IntStream) Context(android.content.Context) IntArray(com.android.launcher3.util.IntArray) Utilities.isValidExtraType(com.android.launcher3.Utilities.isValidExtraType) ItemInfo(com.android.launcher3.model.data.ItemInfo) Intent(android.content.Intent) FeatureFlags(com.android.launcher3.config.FeatureFlags) LauncherSettings(com.android.launcher3.LauncherSettings) LauncherIcons(com.android.launcher3.icons.LauncherIcons) Process(android.os.Process) ArrayList(java.util.ArrayList) BitmapInfo(com.android.launcher3.icons.BitmapInfo) Objects(java.util.Objects) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) IntSet(com.android.launcher3.util.IntSet) List(java.util.List) Bitmap(android.graphics.Bitmap) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Collections(java.util.Collections) Log(android.util.Log) IntArray(com.android.launcher3.util.IntArray) IntSet(com.android.launcher3.util.IntSet)

Example 8 with Hotseat

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

the class WorkspaceStateTransitionAnimation method setWorkspaceProperty.

/**
 * Starts a transition animation for the workspace.
 */
private void setWorkspaceProperty(LauncherState state, PropertySetter propertySetter, StateAnimationConfig config) {
    ScaleAndTranslation scaleAndTranslation = state.getWorkspaceScaleAndTranslation(mLauncher);
    ScaleAndTranslation hotseatScaleAndTranslation = state.getHotseatScaleAndTranslation(mLauncher);
    mNewScale = scaleAndTranslation.scale;
    PageAlphaProvider pageAlphaProvider = state.getWorkspacePageAlphaProvider(mLauncher);
    final int childCount = mWorkspace.getChildCount();
    for (int i = 0; i < childCount; i++) {
        applyChildState(state, (CellLayout) mWorkspace.getChildAt(i), i, pageAlphaProvider, propertySetter, config);
    }
    int elements = state.getVisibleElements(mLauncher);
    Interpolator fadeInterpolator = config.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator);
    Hotseat hotseat = mWorkspace.getHotseat();
    Interpolator scaleInterpolator = config.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
    LauncherState fromState = mLauncher.getStateManager().getState();
    boolean shouldSpring = propertySetter instanceof PendingAnimation && fromState == HINT_STATE && state == NORMAL;
    if (shouldSpring) {
        ((PendingAnimation) propertySetter).add(getSpringScaleAnimator(mLauncher, mWorkspace, mNewScale));
    } else {
        propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
    }
    mWorkspace.setPivotToScaleWithSelf(hotseat);
    float hotseatScale = hotseatScaleAndTranslation.scale;
    if (shouldSpring) {
        PendingAnimation pa = (PendingAnimation) propertySetter;
        pa.add(getSpringScaleAnimator(mLauncher, hotseat, hotseatScale));
    } else {
        Interpolator hotseatScaleInterpolator = config.getInterpolator(ANIM_HOTSEAT_SCALE, scaleInterpolator);
        propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale, hotseatScaleInterpolator);
    }
    float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
    propertySetter.setViewAlpha(hotseat, hotseatIconsAlpha, fadeInterpolator);
    float workspacePageIndicatorAlpha = (elements & WORKSPACE_PAGE_INDICATOR) != 0 ? 1 : 0;
    propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(), workspacePageIndicatorAlpha, fadeInterpolator);
    Interpolator translationInterpolator = config.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
    propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_X, scaleAndTranslation.translationX, translationInterpolator);
    propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_Y, scaleAndTranslation.translationY, translationInterpolator);
    Interpolator hotseatTranslationInterpolator = config.getInterpolator(ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
    propertySetter.setFloat(hotseat, VIEW_TRANSLATE_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    propertySetter.setFloat(mWorkspace.getPageIndicator(), VIEW_TRANSLATE_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    if (!config.hasAnimationFlag(SKIP_SCRIM)) {
        setScrim(propertySetter, state, config);
    }
}
Also used : ScaleAndTranslation(com.android.launcher3.LauncherState.ScaleAndTranslation) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PageAlphaProvider(com.android.launcher3.LauncherState.PageAlphaProvider) Interpolator(android.view.animation.Interpolator)

Example 9 with Hotseat

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

the class LauncherTaskbarUIController method alignRealHotseatWithTaskbar.

/**
 * Pads the Hotseat to line up exactly with Taskbar's copy of the Hotseat.
 */
@Override
public void alignRealHotseatWithTaskbar() {
    Rect hotseatBounds = new Rect();
    DeviceProfile grid = mLauncher.getDeviceProfile();
    int hotseatHeight = grid.workspacePadding.bottom + grid.taskbarSize;
    int taskbarOffset = mLauncher.getHotseat().getTaskbarOffsetY();
    int hotseatTopDiff = hotseatHeight - grid.taskbarSize - taskbarOffset;
    int hotseatBottomDiff = taskbarOffset;
    RectF hotseatBoundsF = mTaskbarView.getHotseatBounds();
    Utilities.scaleRectFAboutPivot(hotseatBoundsF, getTaskbarScaleOnHome(), mTaskbarView.getPivotX(), mTaskbarView.getPivotY());
    hotseatBoundsF.round(hotseatBounds);
    mLauncher.getHotseat().setPadding(hotseatBounds.left, hotseatBounds.top + hotseatTopDiff, mTaskbarView.getWidth() - hotseatBounds.right, mTaskbarView.getHeight() - hotseatBounds.bottom + hotseatBottomDiff);
}
Also used : RectF(android.graphics.RectF) DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect)

Example 10 with Hotseat

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

the class TaskbarHotseatController method onHotseatUpdated.

/**
 * Called when any Hotseat item changes, and reports the new list of items to TaskbarController.
 */
protected void onHotseatUpdated() {
    ShortcutAndWidgetContainer shortcutsAndWidgets = mHotseat.getShortcutsAndWidgets();
    ItemInfo[] hotseatItemInfos = new ItemInfo[mNumHotseatIcons];
    for (int i = 0; i < shortcutsAndWidgets.getChildCount(); i++) {
        View child = shortcutsAndWidgets.getChildAt(i);
        Object tag = shortcutsAndWidgets.getChildAt(i).getTag();
        if (tag instanceof ItemInfo) {
            ItemInfo itemInfo = (ItemInfo) tag;
            CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
            // Since the hotseat might be laid out vertically or horizontally, use whichever
            // index is higher.
            int index = Math.max(lp.cellX, lp.cellY);
            if (0 <= index && index < hotseatItemInfos.length) {
                hotseatItemInfos[index] = itemInfo;
            }
        }
    }
    mTaskbarCallbacks.accept(hotseatItemInfos);
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) View(android.view.View)

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