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

Commit fe1de383 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Hyunyoung Song
Browse files

Enable selection action mode for Android M+.

Since I62963d225e6ea5d2ec9d8ebc8a6d73099f5d6c7f, we have disabled
selection action mode in the folder-name editing mode on Launcher,
mainly because it messed up the view on phones.  However that is no
longer the case in Android M and later, where floating action mode
is available.

With this CL, we start relying on the default floating action mode
in Android M and later.

Bug: 22210697
Bug: 28526978
Change-Id: Ie19e7844194acd86cdb013254a1923f0b1d78e11
(cherry picked from commit 1bd9a430)
parent d419681a
Loading
Loading
Loading
Loading
+20 −19
Original line number Diff line number Diff line
@@ -208,23 +208,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
        });
        mFolderName.setOnFocusChangeListener(this);

        // We disable action mode for now since it messes up the view on phones
        mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
        mFolderName.setOnEditorActionListener(this);
        mFolderName.setSelectAllOnFocus(true);
        mFolderName.setInputType(mFolderName.getInputType() |
                InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

        mFooter = findViewById(R.id.folder_footer);

        // We find out how tall footer wants to be (it is set to wrap_content), so that
        // we can allocate the appropriate amount of space for it.
        int measureSpec = MeasureSpec.UNSPECIFIED;
        mFooter.measure(measureSpec, measureSpec);
        mFooterHeight = mFooter.getMeasuredHeight();
    }

    private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
        if (!Utilities.ATLEAST_MARSHMALLOW) {
            // We disable action mode in older OSes where floating selection menu is not yet
            // available.
            mFolderName.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
                public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                    return false;
                }
@@ -239,7 +226,21 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
                public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                    return false;
                }
    };
            });
        }
        mFolderName.setOnEditorActionListener(this);
        mFolderName.setSelectAllOnFocus(true);
        mFolderName.setInputType(mFolderName.getInputType() |
                InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

        mFooter = findViewById(R.id.folder_footer);

        // We find out how tall footer wants to be (it is set to wrap_content), so that
        // we can allocate the appropriate amount of space for it.
        int measureSpec = MeasureSpec.UNSPECIFIED;
        mFooter.measure(measureSpec, measureSpec);
        mFooterHeight = mFooter.getMeasuredHeight();
    }

    public void onClick(View v) {
        Object tag = v.getTag();