Search in sources :

Example 51 with Hotseat

use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.

the class FocusHelper method handleHotseatButtonKeyEvent.

/**
 * Handles key events in the workspace hotseat (bottom of the screen).
 * <p>Currently we don't special case for the phone UI in different orientations, even though
 * the hotseat is on the side in landscape mode. This is to ensure that accessibility
 * consistency is maintained across rotations.
 */
static boolean handleHotseatButtonKeyEvent(View v, int keyCode, KeyEvent e) {
    boolean consume = FocusLogic.shouldConsume(keyCode);
    if (e.getAction() == KeyEvent.ACTION_UP || !consume) {
        return consume;
    }
    final Launcher launcher = Launcher.getLauncher(v.getContext());
    final DeviceProfile profile = launcher.getDeviceProfile();
    if (DEBUG) {
        Log.v(TAG, String.format("Handle HOTSEAT BUTTONS keyevent=[%s] on hotseat buttons, isVertical=%s", KeyEvent.keyCodeToString(keyCode), profile.isVerticalBarLayout()));
    }
    // Initialize the variables.
    final Workspace workspace = (Workspace) v.getRootView().findViewById(R.id.workspace);
    final ShortcutAndWidgetContainer hotseatParent = (ShortcutAndWidgetContainer) v.getParent();
    final CellLayout hotseatLayout = (CellLayout) hotseatParent.getParent();
    final ItemInfo itemInfo = (ItemInfo) v.getTag();
    int pageIndex = workspace.getNextPage();
    int pageCount = workspace.getChildCount();
    int iconIndex = hotseatParent.indexOfChild(v);
    int iconRank = ((CellLayout.LayoutParams) hotseatLayout.getShortcutsAndWidgets().getChildAt(iconIndex).getLayoutParams()).cellX;
    final CellLayout iconLayout = (CellLayout) workspace.getChildAt(pageIndex);
    if (iconLayout == null) {
        // animation.)
        return consume;
    }
    final ViewGroup iconParent = iconLayout.getShortcutsAndWidgets();
    ViewGroup parent = null;
    int[][] matrix = null;
    if (keyCode == KeyEvent.KEYCODE_DPAD_UP && !profile.isVerticalBarLayout()) {
        matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
        iconIndex += iconParent.getChildCount();
        parent = iconParent;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && profile.isVerticalBarLayout()) {
        matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
        iconIndex += iconParent.getChildCount();
        parent = iconParent;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && profile.isVerticalBarLayout()) {
        keyCode = KeyEvent.KEYCODE_PAGE_DOWN;
    } else {
        // For other KEYCODE_DPAD_LEFT and KEYCODE_DPAD_RIGHT navigation, do not use the
        // matrix extended with hotseat.
        matrix = FocusLogic.createSparseMatrix(hotseatLayout);
        parent = hotseatParent;
    }
    // Process the focus.
    int newIconIndex = FocusLogic.handleKeyEvent(keyCode, matrix, iconIndex, pageIndex, pageCount, Utilities.isRtl(v.getResources()));
    View newIcon = null;
    switch(newIconIndex) {
        case FocusLogic.NEXT_PAGE_FIRST_ITEM:
            parent = getCellLayoutChildrenForIndex(workspace, pageIndex + 1);
            newIcon = parent.getChildAt(0);
            // TODO(hyunyoungs): handle cases where the child is not an icon but
            // a folder or a widget.
            workspace.snapToPage(pageIndex + 1);
            break;
        case FocusLogic.PREVIOUS_PAGE_FIRST_ITEM:
            parent = getCellLayoutChildrenForIndex(workspace, pageIndex - 1);
            newIcon = parent.getChildAt(0);
            // TODO(hyunyoungs): handle cases where the child is not an icon but
            // a folder or a widget.
            workspace.snapToPage(pageIndex - 1);
            break;
        case FocusLogic.PREVIOUS_PAGE_LAST_ITEM:
            parent = getCellLayoutChildrenForIndex(workspace, pageIndex - 1);
            newIcon = parent.getChildAt(parent.getChildCount() - 1);
            // TODO(hyunyoungs): handle cases where the child is not an icon but
            // a folder or a widget.
            workspace.snapToPage(pageIndex - 1);
            break;
        case FocusLogic.PREVIOUS_PAGE_LEFT_COLUMN:
        case FocusLogic.PREVIOUS_PAGE_RIGHT_COLUMN:
            // Go to the previous page but keep the focus on the same hotseat icon.
            workspace.snapToPage(pageIndex - 1);
            break;
        case FocusLogic.NEXT_PAGE_LEFT_COLUMN:
        case FocusLogic.NEXT_PAGE_RIGHT_COLUMN:
            // Go to the next page but keep the focus on the same hotseat icon.
            workspace.snapToPage(pageIndex + 1);
            break;
    }
    if (parent == iconParent && newIconIndex >= iconParent.getChildCount()) {
        newIconIndex -= iconParent.getChildCount();
    }
    if (parent != null) {
        if (newIcon == null && newIconIndex >= 0) {
            newIcon = parent.getChildAt(newIconIndex);
        }
        if (newIcon != null) {
            newIcon.requestFocus();
            playSoundEffect(keyCode, v);
        }
    }
    return consume;
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View) FolderPagedView(com.android.launcher3.folder.FolderPagedView)

Example 52 with Hotseat

use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.

the class FocusHelper method handlePreviousPageLastItem.

private static View handlePreviousPageLastItem(Workspace workspace, CellLayout hotseatLayout, int pageIndex, boolean isRtl) {
    if (pageIndex - 1 < 0) {
        return null;
    }
    CellLayout workspaceLayout = (CellLayout) workspace.getChildAt(pageIndex - 1);
    View newIcon = getFirstFocusableIconInReverseReadingOrder(workspaceLayout, isRtl);
    if (newIcon == null) {
        // Check the hotseat if no focusable item was found on the workspace.
        newIcon = getFirstFocusableIconInReverseReadingOrder(hotseatLayout, isRtl);
        workspace.snapToPage(pageIndex - 1);
    }
    return newIcon;
}
Also used : View(android.view.View) FolderPagedView(com.android.launcher3.folder.FolderPagedView)

Example 53 with Hotseat

use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.

the class Workspace method getFirstMatchForAppClose.

/**
 * Similar to {@link #getFirstMatch} but optimized to finding a suitable view for the app close
 * animation.
 *
 * @param packageName The package name of the app to match.
 * @param user The user of the app to match.
 */
public View getFirstMatchForAppClose(String packageName, UserHandle user) {
    final int curPage = getCurrentPage();
    final CellLayout currentPage = (CellLayout) getPageAt(curPage);
    final Workspace.ItemOperator packageAndUser = (ItemInfo info, View view) -> info != null && info.getTargetComponent() != null && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName) && info.user.equals(user);
    final Workspace.ItemOperator packageAndUserAndApp = (ItemInfo info, View view) -> packageAndUser.evaluate(info, view) && info.itemType == ITEM_TYPE_APPLICATION;
    final Workspace.ItemOperator packageAndUserAndAppInFolder = (info, view) -> {
        if (info instanceof FolderInfo) {
            FolderInfo folderInfo = (FolderInfo) info;
            for (WorkspaceItemInfo shortcutInfo : folderInfo.contents) {
                if (packageAndUserAndApp.evaluate(shortcutInfo, view)) {
                    return true;
                }
            }
        }
        return false;
    };
    // Order: App icons, app in folder. Items in hotseat get returned first.
    if (ADAPTIVE_ICON_WINDOW_ANIM.get()) {
        return getFirstMatch(new CellLayout[] { getHotseat(), currentPage }, packageAndUserAndApp, packageAndUserAndAppInFolder);
    } else {
        // FolderAdaptiveIcon as the background.
        return getFirstMatch(new CellLayout[] { getHotseat(), currentPage }, packageAndUserAndApp);
    }
}
Also used : WorkspaceAccessibilityHelper(com.android.launcher3.accessibility.WorkspaceAccessibilityHelper) Rect(android.graphics.Rect) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) TestProtocol(com.android.launcher3.testing.TestProtocol) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) Animator(android.animation.Animator) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Drawable(android.graphics.drawable.Drawable) ProviderChangedListener(com.android.launcher3.LauncherAppWidgetHost.ProviderChangedListener) WallpaperManager(android.app.WallpaperManager) IBinder(android.os.IBinder) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) SPRING_LOADED(com.android.launcher3.LauncherState.SPRING_LOADED) LayoutTransition(android.animation.LayoutTransition) AttributeSet(android.util.AttributeSet) Interpolators(com.android.launcher3.anim.Interpolators) Handler(android.os.Handler) View(android.view.View) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) Canvas(android.graphics.Canvas) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) OmegaLauncher(com.saggitt.omega.OmegaLauncher) RotationMode(com.android.launcher3.graphics.RotationMode) Log(android.util.Log) ShortcutDragPreviewProvider(com.android.launcher3.shortcuts.ShortcutDragPreviewProvider) Predicate(java.util.function.Predicate) ObjectAnimator(android.animation.ObjectAnimator) WallpaperOffsetInterpolator(com.android.launcher3.util.WallpaperOffsetInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) SPRING_LOADED_TRANSITION_MS(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS) SparseArray(android.util.SparseArray) AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) Message(android.os.Message) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) OVERVIEW_TRANSITION_MS(com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS) NORMAL(com.android.launcher3.LauncherState.NORMAL) ALPHA_INDEX_OVERLAY(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY) AccessibleDragListenerAdapter(com.android.launcher3.accessibility.AccessibleDragListenerAdapter) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) FolderIcon(com.android.launcher3.folder.FolderIcon) UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) SpringLoadedDragController(com.android.launcher3.dragndrop.SpringLoadedDragController) ArrayList(java.util.ArrayList) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) HashSet(java.util.HashSet) SuppressLint(android.annotation.SuppressLint) PreviewBackground(com.android.launcher3.folder.PreviewBackground) AppWidgetHostView(android.appwidget.AppWidgetHostView) MotionEvent(android.view.MotionEvent) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) DragLayer(com.android.launcher3.dragndrop.DragLayer) Executors(com.android.launcher3.util.Executors) IntArray(com.android.launcher3.util.IntArray) ADAPTIVE_ICON_WINDOW_ANIM(com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM) Parcelable(android.os.Parcelable) Action(com.android.launcher3.userevent.nano.LauncherLogProto.Action) ContainerType(com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType) LayoutInflater(android.view.LayoutInflater) AnimationConfig(com.android.launcher3.LauncherStateManager.AnimationConfig) DragController(com.android.launcher3.dragndrop.DragController) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) AppWidgetManagerCompat(com.android.launcher3.compat.AppWidgetManagerCompat) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) Bitmap(android.graphics.Bitmap) LauncherOverlay(com.android.launcher3.Launcher.LauncherOverlay) WorkspacePageIndicator(com.android.launcher3.pageindicators.WorkspacePageIndicator) ViewTreeObserver(android.view.ViewTreeObserver) WorkspaceTouchListener(com.android.launcher3.touch.WorkspaceTouchListener) IntSparseArrayMap(com.android.launcher3.util.IntSparseArrayMap) Thunk(com.android.launcher3.util.Thunk) DragPreviewProvider(com.android.launcher3.graphics.DragPreviewProvider) DragView(com.android.launcher3.dragndrop.DragView) OmegaBackgroundView(com.saggitt.omega.views.OmegaBackgroundView) ValueAnimator(android.animation.ValueAnimator) Resources(android.content.res.Resources) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) OmegaBackgroundView(com.saggitt.omega.views.OmegaBackgroundView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 54 with Hotseat

use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.

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 : View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) OmegaBackgroundView(com.saggitt.omega.views.OmegaBackgroundView)

Example 55 with Hotseat

use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.

the class WorkspaceStateTransitionAnimation method setWorkspaceProperty.

/**
 * Starts a transition animation for the workspace.
 */
private void setWorkspaceProperty(LauncherState state, PropertySetter propertySetter, AnimatorSetBuilder builder, AnimationConfig 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, builder, config);
    }
    int elements = state.getVisibleElements(mLauncher);
    Interpolator fadeInterpolator = builder.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator);
    boolean playAtomicComponent = config.playAtomicOverviewScaleComponent();
    Hotseat hotseat = mWorkspace.getHotseat();
    if (playAtomicComponent) {
        Interpolator scaleInterpolator = builder.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
        propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
        if (!hotseat.getRotationMode().isTransposed) {
            // Set the hotseat's pivot point to match the workspace's, so that it scales
            // together. Since both hotseat and workspace can move, transform the point
            // manually instead of using dragLayer.getDescendantCoordRelativeToSelf and
            // related methods.
            /*hotseat.setPivotY(mWorkspace.getPivotY() + mWorkspace.getTop() - hotseat.getTop());
                hotseat.setPivotX(mWorkspace.getPivotX()
                        + mWorkspace.getLeft() - hotseat.getLeft());*/
            DragLayer dragLayer = mLauncher.getDragLayer();
            float[] workspacePivot = new float[] { mWorkspace.getPivotX(), mWorkspace.getPivotY() };
            dragLayer.getDescendantCoordRelativeToSelf(mWorkspace, workspacePivot);
            dragLayer.mapCoordInSelfToDescendant(hotseat, workspacePivot);
            hotseat.setPivotX(workspacePivot[0]);
            hotseat.setPivotY(workspacePivot[1]);
        }
        float hotseatScale = hotseatScaleAndTranslation.scale;
        Interpolator hotseatScaleInterpolator = builder.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);
        propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(), hotseatIconsAlpha, fadeInterpolator);
    }
    // Set options view
    OptionsPanel optionsPanel = OmegaLauncher.getLauncher(mLauncher).getOptionsView();
    propertySetter.setViewAlpha(optionsPanel, (elements & OPTIONS_VIEW) != 0 ? 1 : 0, fadeInterpolator);
    if (!config.playNonAtomicComponent()) {
        // Only the alpha and scale, handled above, are included in the atomic animation.
        return;
    }
    Interpolator translationInterpolator = !playAtomicComponent ? LINEAR : builder.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
    propertySetter.setFloat(mWorkspace, View.TRANSLATION_X, scaleAndTranslation.translationX, translationInterpolator);
    propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y, scaleAndTranslation.translationY, translationInterpolator);
    Interpolator hotseatTranslationInterpolator = builder.getInterpolator(ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
    propertySetter.setFloat(hotseat, View.TRANSLATION_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    propertySetter.setFloat(mWorkspace.getPageIndicator(), View.TRANSLATION_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    setScrim(propertySetter, state);
}
Also used : ScaleAndTranslation(com.android.launcher3.LauncherState.ScaleAndTranslation) DragLayer(com.android.launcher3.dragndrop.DragLayer) PageAlphaProvider(com.android.launcher3.LauncherState.PageAlphaProvider) Interpolator(android.view.animation.Interpolator) OptionsPanel(com.saggitt.omega.views.OptionsPanel)

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