Search in sources :

Example 86 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_icon_on_hotseat.

@Test
public void testCustomProfileLoaded_with_icon_on_hotseat() throws Exception {
    writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putApp(TEST_PACKAGE, TEST_ACTIVITY));
    // Verify one item in hotseat
    assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
    ItemInfo info = mModelHelper.getBgDataModel().workspaceItems.get(0);
    assertEquals(LauncherSettings.Favorites.CONTAINER_HOTSEAT, info.container);
    assertEquals(LauncherSettings.Favorites.ITEM_TYPE_APPLICATION, info.itemType);
}
Also used : LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) ItemInfo(com.android.launcher3.model.data.ItemInfo) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 87 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

the class Workspace method isPointInSelfOverHotseat.

boolean isPointInSelfOverHotseat(int x, int y) {
    mTempFXY[0] = x;
    mTempFXY[1] = y;
    mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempFXY, true);
    View hotseat = mLauncher.getHotseat();
    return mTempFXY[0] >= hotseat.getLeft() && mTempFXY[0] <= hotseat.getRight() && mTempFXY[1] >= hotseat.getTop() && mTempFXY[1] <= hotseat.getBottom();
}
Also used : DraggableView(com.android.launcher3.dragndrop.DraggableView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView)

Example 88 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

the class Workspace method addExtraEmptyScreenOnDrag.

private void addExtraEmptyScreenOnDrag(DragObject dragObject) {
    boolean lastChildOnScreen = false;
    boolean childOnFinalScreen = false;
    if (mDragSourceInternal != null) {
        int dragSourceChildCount = mDragSourceInternal.getChildCount();
        // If the icon was dragged from Hotseat, there is no page pair
        if (isTwoPanelEnabled() && !(mDragSourceInternal.getParent() instanceof Hotseat)) {
            int pagePairScreenId = getScreenPair(dragObject.dragInfo.screenId);
            CellLayout pagePair = mWorkspaceScreens.get(pagePairScreenId);
            dragSourceChildCount += pagePair.getShortcutsAndWidgets().getChildCount();
        }
        // original parent, ShortcutAndWidgetContainer, and reattached to the DragView.
        if (dragObject.dragView.getContentView() instanceof LauncherAppWidgetHostView) {
            dragSourceChildCount++;
        }
        if (dragSourceChildCount == 1) {
            lastChildOnScreen = true;
        }
        CellLayout cl = (CellLayout) mDragSourceInternal.getParent();
        if (getLeftmostVisiblePageForIndex(indexOfChild(cl)) == getLeftmostVisiblePageForIndex(getPageCount() - 1)) {
            childOnFinalScreen = true;
        }
    }
    // If this is the last item on the final screen
    if (lastChildOnScreen && childOnFinalScreen) {
        return;
    }
    forEachExtraEmptyPageId(extraEmptyPageId -> {
        if (!mWorkspaceScreens.containsKey(extraEmptyPageId)) {
            insertNewWorkspaceScreen(extraEmptyPageId);
        }
    });
}
Also used : LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 89 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

the class WorkspaceLayoutManager method addInScreen.

/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 */
default void addInScreen(View child, int container, int screenId, int x, int y, int spanX, int spanY) {
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (EXTRA_EMPTY_SCREEN_IDS.contains(screenId)) {
        // This should never happen
        throw new RuntimeException("Screen id should not be extra empty screen: " + screenId);
    }
    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT || container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
        layout = getHotseat();
        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(false);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(true);
        }
        layout = getScreenWithId(screenId);
    }
    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }
    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }
    // Get the canonical child id to uniquely represent this view in this screen
    ItemInfo info = (ItemInfo) child.getTag();
    int childId = info.getViewId();
    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, -1, childId, lp, markCellsAsOccupied)) {
        // TODO: This branch occurs when the workspace is adding views
        // outside of the defined grid
        // maybe we should be deleting these items from the LauncherModel?
        Log.e(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout");
    }
    child.setHapticFeedbackEnabled(false);
    child.setOnLongClickListener(getWorkspaceChildOnLongClickListener());
    if (child instanceof DropTarget) {
        onAddDropTarget((DropTarget) child);
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) ViewGroup(android.view.ViewGroup) Folder(com.android.launcher3.folder.Folder)

Example 90 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

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)

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