Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f0d54eb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix taskbar icon dragging issues" into sc-v2-dev

parents 0af55bbc a8dae26d
Loading
Loading
Loading
Loading
+16 −5
Original line number Original line Diff line number Diff line
@@ -90,11 +90,12 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ


    private static final String WINDOW_TITLE = "Taskbar";
    private static final String WINDOW_TITLE = "Taskbar";


    private final DeviceProfile mDeviceProfile;
    private final LayoutInflater mLayoutInflater;
    private final LayoutInflater mLayoutInflater;
    private final TaskbarDragLayer mDragLayer;
    private final TaskbarDragLayer mDragLayer;
    private final TaskbarControllers mControllers;
    private final TaskbarControllers mControllers;


    private DeviceProfile mDeviceProfile;

    private final WindowManager mWindowManager;
    private final WindowManager mWindowManager;
    private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
    private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
    private final int mTaskbarHeightForIme;
    private final int mTaskbarHeightForIme;
@@ -125,10 +126,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
                Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);


        final Resources resources = getResources();
        final Resources resources = getResources();
        float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size);
        updateIconSize(resources);
        mDeviceProfile.updateIconSize(1, resources);
        float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
        mDeviceProfile.updateIconSize(iconScale, resources);


        mTaskbarHeightForIme = resources.getDimensionPixelSize(R.dimen.taskbar_ime_size);
        mTaskbarHeightForIme = resources.getDimensionPixelSize(R.dimen.taskbar_ime_size);


@@ -211,6 +209,19 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        mWindowManager.addView(mDragLayer, mWindowLayoutParams);
        mWindowManager.addView(mDragLayer, mWindowLayoutParams);
    }
    }


    /** Updates the Device profile instance to the latest representation of the screen. */
    public void updateDeviceProfile(DeviceProfile dp) {
        mDeviceProfile = dp;
        updateIconSize(getResources());
    }

    private void updateIconSize(Resources resources) {
        float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size);
        mDeviceProfile.updateIconSize(1, resources);
        float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
        mDeviceProfile.updateIconSize(iconScale, resources);
    }

    public void onConfigurationChanged(@Config int configChanges) {
    public void onConfigurationChanged(@Config int configChanges) {
        mControllers.onConfigurationChanged(configChanges);
        mControllers.onConfigurationChanged(configChanges);
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -145,7 +145,7 @@ public class TaskbarDragController extends DragController<TaskbarActivityContext
            PopupContainerWithArrow<TaskbarActivityContext> popupContainer =
            PopupContainerWithArrow<TaskbarActivityContext> popupContainer =
                    mControllers.taskbarPopupController.showForIcon(btv);
                    mControllers.taskbarPopupController.showForIcon(btv);
            if (popupContainer != null) {
            if (popupContainer != null) {
                dragOptions.preDragCondition = popupContainer.createPreDragCondition();
                dragOptions.preDragCondition = popupContainer.createPreDragCondition(false);
            }
            }
        }
        }


+7 −0
Original line number Original line Diff line number Diff line
@@ -110,6 +110,13 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen
                } else {
                } else {
                    // Config change might be handled without re-creating the taskbar
                    // Config change might be handled without re-creating the taskbar
                    if (mTaskbarActivityContext != null) {
                    if (mTaskbarActivityContext != null) {
                        DeviceProfile dp = mUserUnlocked
                                ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext)
                                : null;

                        if (dp != null && dp.isTaskbarPresent) {
                            mTaskbarActivityContext.updateDeviceProfile(dp.copy(mContext));
                        }
                        mTaskbarActivityContext.onConfigurationChanged(configDiff);
                        mTaskbarActivityContext.onConfigurationChanged(configDiff);
                    }
                    }
                }
                }
+1 −1
Original line number Original line Diff line number Diff line
@@ -1686,7 +1686,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
            PopupContainerWithArrow<Launcher> popupContainer = PopupContainerWithArrow
            PopupContainerWithArrow<Launcher> popupContainer = PopupContainerWithArrow
                    .showForIcon((BubbleTextView) child);
                    .showForIcon((BubbleTextView) child);
            if (popupContainer != null) {
            if (popupContainer != null) {
                dragOptions.preDragCondition = popupContainer.createPreDragCondition();
                dragOptions.preDragCondition = popupContainer.createPreDragCondition(true);
            }
            }
        }
        }


+7 −1
Original line number Original line Diff line number Diff line
@@ -396,7 +396,7 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
     * Current behavior:
     * Current behavior:
     * - Start the drag if the touch passes a certain distance from the original touch down.
     * - Start the drag if the touch passes a certain distance from the original touch down.
     */
     */
    public DragOptions.PreDragCondition createPreDragCondition() {
    public DragOptions.PreDragCondition createPreDragCondition(boolean updateIconUi) {
        return new DragOptions.PreDragCondition() {
        return new DragOptions.PreDragCondition() {


            @Override
            @Override
@@ -406,6 +406,9 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>


            @Override
            @Override
            public void onPreDragStart(DropTarget.DragObject dragObject) {
            public void onPreDragStart(DropTarget.DragObject dragObject) {
                if (!updateIconUi) {
                    return;
                }
                if (mIsAboveIcon) {
                if (mIsAboveIcon) {
                    // Hide only the icon, keep the text visible.
                    // Hide only the icon, keep the text visible.
                    mOriginalIcon.setIconVisible(false);
                    mOriginalIcon.setIconVisible(false);
@@ -418,6 +421,9 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>


            @Override
            @Override
            public void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted) {
            public void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted) {
                if (!updateIconUi) {
                    return;
                }
                mOriginalIcon.setIconVisible(true);
                mOriginalIcon.setIconVisible(true);
                if (dragStarted) {
                if (dragStarted) {
                    // Make sure we keep the original icon hidden while it is being dragged.
                    // Make sure we keep the original icon hidden while it is being dragged.