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

Commit b87148b2 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Add support for optional titles in action modes"

parents f9c83f37 b98a81f8
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -21935,12 +21935,14 @@ package android.view {
    method public java.lang.Object getTag();
    method public java.lang.Object getTag();
    method public abstract java.lang.CharSequence getTitle();
    method public abstract java.lang.CharSequence getTitle();
    method public abstract void invalidate();
    method public abstract void invalidate();
    method public boolean isTitleOptional();
    method public abstract void setCustomView(android.view.View);
    method public abstract void setCustomView(android.view.View);
    method public abstract void setSubtitle(java.lang.CharSequence);
    method public abstract void setSubtitle(java.lang.CharSequence);
    method public abstract void setSubtitle(int);
    method public abstract void setSubtitle(int);
    method public void setTag(java.lang.Object);
    method public void setTag(java.lang.Object);
    method public abstract void setTitle(java.lang.CharSequence);
    method public abstract void setTitle(java.lang.CharSequence);
    method public abstract void setTitle(int);
    method public abstract void setTitle(int);
    method public void setTitleOptionalHint(boolean);
  }
  }
  public static abstract interface ActionMode.Callback {
  public static abstract interface ActionMode.Callback {
+6 −0
Original line number Original line Diff line number Diff line
@@ -123,6 +123,12 @@ public class ExtractEditLayout extends LinearLayout {
            // Subtitle will not be shown.
            // Subtitle will not be shown.
        }
        }


        @Override
        public boolean isTitleOptional() {
            // Not only is it optional, it will *never* be shown.
            return true;
        }

        @Override
        @Override
        public void setCustomView(View view) {
        public void setCustomView(View view) {
            // Custom view is not supported here.
            // Custom view is not supported here.
+26 −0
Original line number Original line Diff line number Diff line
@@ -103,6 +103,32 @@ public abstract class ActionMode {
     */
     */
    public abstract void setSubtitle(int resId);
    public abstract void setSubtitle(int resId);


    /**
     * Set whether or not the title/subtitle display for this action mode
     * is optional.
     *
     * <p>In many cases the supplied title for an action mode is merely
     * meant to add context and is not strictly required for the action
     * mode to be useful. If the title is optional, the system may choose
     * to hide the title entirely rather than truncate it due to a lack
     * of available space.</p>
     *
     * <p>Note that this is merely a hint; the underlying implementation
     * may choose to ignore this setting under some circumstances.</p>
     *
     * @param titleOptional true if the title only presents optional information.
     */
    public void setTitleOptionalHint(boolean titleOptional) {
    }

    /**
     * @return true if this action mode considers the title and subtitle fields
     *         as optional. Optional titles may not be displayed to the user.
     */
    public boolean isTitleOptional() {
        return false;
    }

    /**
    /**
     * Set a custom view for this action mode. The custom view will take the place of
     * Set a custom view for this action mode. The custom view will take the place of
     * the title and subtitle. Useful for things like search boxes.
     * the title and subtitle. Useful for things like search boxes.
+2 −4
Original line number Original line Diff line number Diff line
@@ -53,10 +53,8 @@ class SelectActionModeCallback implements ActionMode.Callback {
        mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_copy, menu);
        mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_copy, menu);


        final Context context = mWebView.getContext();
        final Context context = mWebView.getContext();
        boolean allowText = context.getResources().getBoolean(
        mode.setTitle(context.getString(com.android.internal.R.string.textSelectionCABTitle));
                com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon);
        mode.setTitleOptionalHint(true);
        mode.setTitle(allowText ?
                context.getString(com.android.internal.R.string.textSelectionCABTitle) : null);


        // If the action mode UI we're running in isn't capable of taking window focus
        // If the action mode UI we're running in isn't capable of taking window focus
        // the user won't be able to type into the find on page UI. Disable this functionality.
        // the user won't be able to type into the find on page UI. Disable this functionality.
+2 −2
Original line number Original line Diff line number Diff line
@@ -10363,9 +10363,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            boolean allowText = getContext().getResources().getBoolean(
            boolean allowText = getContext().getResources().getBoolean(
                    com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon);
                    com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon);


            mode.setTitle(allowText ?
            mode.setTitle(mContext.getString(com.android.internal.R.string.textSelectionCABTitle));
                    mContext.getString(com.android.internal.R.string.textSelectionCABTitle) : null);
            mode.setSubtitle(null);
            mode.setSubtitle(null);
            mode.setTitleOptionalHint(true);


            int selectAllIconId = 0; // No icon by default
            int selectAllIconId = 0; // No icon by default
            if (!allowText) {
            if (!allowText) {
Loading