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

Commit b2536cf4 authored by Adam Powell's avatar Adam Powell
Browse files

Change the CAB to use the up-glyph for closing action modes

In an effort to reduce glyph proliferation, change the "done"
checkmark from the CAB to the up-navigation arrow, placing the CAB
firmly in the current navigation hierarchy. This matches behavior for
expandable action views such as SearchView.

Allow the use of different CAB "done" layouts by theme; the material
layout should not include the "done" text and should use the standard
borderless selectable item background.

Bug 17372188

Change-Id: Icfb3e0bbc6a718e22ab27f9d520da5fe4eb833e7
parent 5ec176dc
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
    private int mSubtitleStyleRes;
    private Drawable mSplitBackground;
    private boolean mTitleOptional;
    private int mCloseItemLayout;

    private Animator mCurrentAnimation;
    private boolean mAnimateInOnLayout;
@@ -99,6 +100,10 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
        mSplitBackground = a.getDrawable(
                com.android.internal.R.styleable.ActionMode_backgroundSplit);

        mCloseItemLayout = a.getResourceId(
                com.android.internal.R.styleable.ActionMode_closeItemLayout,
                R.layout.action_mode_close_item);

        a.recycle();
    }

@@ -120,7 +125,7 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
                        LayoutParams.MATCH_PARENT);
                if (!split) {
                    mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
                    mMenuView.setBackgroundDrawable(null);
                    mMenuView.setBackground(null);
                    final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
                    if (oldParent != null) oldParent.removeView(mMenuView);
                    addView(mMenuView, layoutParams);
@@ -134,7 +139,7 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
                    layoutParams.width = LayoutParams.MATCH_PARENT;
                    layoutParams.height = mContentHeight;
                    mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
                    mMenuView.setBackgroundDrawable(mSplitBackground);
                    mMenuView.setBackground(mSplitBackground);
                    final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
                    if (oldParent != null) oldParent.removeView(mMenuView);
                    mSplitView.addView(mMenuView, layoutParams);
@@ -211,7 +216,7 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
    public void initForMode(final ActionMode mode) {
        if (mClose == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            mClose = inflater.inflate(R.layout.action_mode_close_item, this, false);
            mClose = inflater.inflate(mCloseItemLayout, this, false);
            addView(mClose);
        } else if (mClose.getParent() == null) {
            addView(mClose);
+11 −4
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
<!-- Copyright (C) 2011 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
@@ -14,6 +14,13 @@
     limitations under the License.
-->

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/ic_cab_done_mtrl_alpha"
    android:tint="?attr/colorControlNormal" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/action_mode_close_button"
        android:focusable="true"
        android:clickable="true"
        android:paddingStart="8dip"
        android:src="?android:attr/actionModeCloseDrawable"
        style="?android:attr/actionModeCloseButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginEnd="16dip" />
+2 −0
Original line number Diff line number Diff line
@@ -7115,6 +7115,8 @@
        <attr name="backgroundSplit" />
        <!-- Specifies a fixed height for the action mode bar. -->
        <attr name="height" />
        <!-- Specifies a layout to use for the "close" item at the starting edge. -->
        <attr name="closeItemLayout" format="reference" />
    </declare-styleable>

    <declare-styleable name="SearchView">
+2 −1
Original line number Diff line number Diff line
@@ -838,7 +838,7 @@ please see styles_device_defaults.xml.
    </style>

    <style name="Widget.Material.ActionButton.CloseMode">
        <item name="background">@drawable/btn_cab_done_material</item>
        <item name="background">?attr/selectableItemBackgroundBorderless</item>
    </style>

    <style name="Widget.Material.ActionButton.Overflow">
@@ -901,6 +901,7 @@ please see styles_device_defaults.xml.
    <style name="Widget.Material.ActionMode" parent="Widget.ActionMode">
        <item name="titleTextStyle">@style/TextAppearance.Material.Widget.ActionMode.Title</item>
        <item name="subtitleTextStyle">@style/TextAppearance.Material.Widget.ActionMode.Subtitle</item>
        <item name="closeItemLayout">@layout/action_mode_close_item_material</item>
    </style>

    <style name="Widget.Material.FastScroll" parent="Widget.FastScroll">
+1 −0
Original line number Diff line number Diff line
@@ -2000,4 +2000,5 @@
  <java-symbol type="id" name="parentMatrix" />
  <java-symbol type="bool" name="config_auto_attach_data_on_creation" />
  <java-symbol type="id" name="date_picker_month_day_year_layout" />
  <java-symbol type="attr" name="closeItemLayout" />
</resources>
Loading