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

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

Merge "Adding support for auto-cancelling an action mode when interacting with...

Merge "Adding support for auto-cancelling an action mode when interacting with launcher" into ub-launcher3-master
parents 179249d8 7c8a65e7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch

    public static void closeAllOpenViews(Launcher launcher, boolean animate) {
        closeOpenViews(launcher, animate, TYPE_ALL);
        launcher.finishAutoCancelActionMode();
    }

    public static void closeAllOpenViews(Launcher launcher) {
+29 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import android.text.TextUtils;
import android.text.method.TextKeyListener;
import android.util.Log;
import android.util.SparseArray;
import android.view.ActionMode;
import android.view.Display;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
@@ -197,6 +198,10 @@ public class Launcher extends BaseActivity
    // Type: SparseArray<Parcelable>
    private static final String RUNTIME_STATE_WIDGET_PANEL = "launcher.widget_panel";

    // When starting an action mode, setting this tag will cause the action mode to be cancelled
    // automatically when user interacts with the launcher.
    public static final Object AUTO_CANCEL_ACTION_MODE = new Object();

    private LauncherStateManager mStateManager;

    private boolean mIsSafeModeEnabled;
@@ -272,6 +277,7 @@ public class Launcher extends BaseActivity
    private boolean mAppLaunchSuccess;

    private RotationPrefChangeHandler mRotationPrefChangeHandler;
    private ActionMode mCurrentActionMode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -1601,6 +1607,9 @@ public class Launcher extends BaseActivity

    @Override
    public void onBackPressed() {
        if (finishAutoCancelActionMode()) {
            return;
        }
        if (mLauncherCallbacks != null && mLauncherCallbacks.handleBackPressed()) {
            return;
        }
@@ -2819,6 +2828,26 @@ public class Launcher extends BaseActivity
        }
    }

    @Override
    public void onActionModeStarted(ActionMode mode) {
        super.onActionModeStarted(mode);
        mCurrentActionMode = mode;
    }

    @Override
    public void onActionModeFinished(ActionMode mode) {
        super.onActionModeFinished(mode);
        mCurrentActionMode = null;
    }

    public boolean finishAutoCancelActionMode() {
        if (mCurrentActionMode != null && AUTO_CANCEL_ACTION_MODE == mCurrentActionMode.getTag()) {
            mCurrentActionMode.finish();
            return true;
        }
        return false;
    }

    /**
     * Callback for listening for onResume
     */
+1 −0
Original line number Diff line number Diff line
@@ -264,6 +264,7 @@ public class LauncherStateManager {
    private void onStateTransitionEnd(LauncherState state) {
        mLauncher.getWorkspace().setClipChildren(!state.disablePageClipping);
        mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
        mLauncher.finishAutoCancelActionMode();
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -157,6 +157,8 @@ public class DragLayer extends InsettableFrameLayout {
                mTouchCompleteListener.onTouchComplete();
            }
            mTouchCompleteListener = null;
        } else if (action == MotionEvent.ACTION_DOWN) {
            mLauncher.finishAutoCancelActionMode();
        }
        mActiveController = null;