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

Commit 1969b879 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 4142917 - Add support for specifying a custom home icon in action bar

Add ActionBar methods for setting icon and logo.

Change-Id: I6151689138c734b7212c3469b8ba8f28f0fd5ec4
parent 37f421c5
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -22045,6 +22045,32 @@
<parameter name="useLogo" type="boolean">
</parameter>
</method>
<method name="setIcon"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="resId" type="int">
</parameter>
</method>
<method name="setIcon"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="icon" type="android.graphics.drawable.Drawable">
</parameter>
</method>
<method name="setListNavigationCallbacks"
 return="void"
 abstract="true"
@@ -22060,6 +22086,32 @@
<parameter name="callback" type="android.app.ActionBar.OnNavigationListener">
</parameter>
</method>
<method name="setLogo"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="resId" type="int">
</parameter>
</method>
<method name="setLogo"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="logo" type="android.graphics.drawable.Drawable">
</parameter>
</method>
<method name="setNavigationMode"
 return="void"
 abstract="true"
+60 −0
Original line number Diff line number Diff line
@@ -159,6 +159,66 @@ public abstract class ActionBar {
     */
    public abstract void setCustomView(int resId);

    /**
     * Set the icon to display in the 'home' section of the action bar.
     * The action bar will use an icon specified by its style or the
     * activity icon by default.
     *
     * Whether the home section shows an icon or logo is controlled
     * by the display option {@link #DISPLAY_USE_LOGO}.
     *
     * @param resId Resource ID of a drawable to show as an icon.
     *
     * @see #setDisplayUseLogoEnabled(boolean)
     * @see #setDisplayShowHomeEnabled(boolean)
     */
    public abstract void setIcon(int resId);

    /**
     * Set the icon to display in the 'home' section of the action bar.
     * The action bar will use an icon specified by its style or the
     * activity icon by default.
     *
     * Whether the home section shows an icon or logo is controlled
     * by the display option {@link #DISPLAY_USE_LOGO}.
     *
     * @param icon Drawable to show as an icon.
     *
     * @see #setDisplayUseLogoEnabled(boolean)
     * @see #setDisplayShowHomeEnabled(boolean)
     */
    public abstract void setIcon(Drawable icon);

    /**
     * Set the logo to display in the 'home' section of the action bar.
     * The action bar will use a logo specified by its style or the
     * activity logo by default.
     *
     * Whether the home section shows an icon or logo is controlled
     * by the display option {@link #DISPLAY_USE_LOGO}.
     *
     * @param resId Resource ID of a drawable to show as a logo.
     *
     * @see #setDisplayUseLogoEnabled(boolean)
     * @see #setDisplayShowHomeEnabled(boolean)
     */
    public abstract void setLogo(int resId);

    /**
     * Set the logo to display in the 'home' section of the action bar.
     * The action bar will use a logo specified by its style or the
     * activity logo by default.
     *
     * Whether the home section shows an icon or logo is controlled
     * by the display option {@link #DISPLAY_USE_LOGO}.
     *
     * @param logo Drawable to show as a logo.
     *
     * @see #setDisplayUseLogoEnabled(boolean)
     * @see #setDisplayShowHomeEnabled(boolean)
     */
    public abstract void setLogo(Drawable logo);

    /**
     * Set the adapter and navigation callback for list navigation mode.
     *
+17 −16
Original line number Diff line number Diff line
@@ -889,23 +889,24 @@ public class ActionBarImpl extends ActionBar {
        return mTabs.get(index);
    }

    /**
     * This fragment is added when we're keeping a back stack in a tab switch
     * transaction. We use it to change the selected tab in the action bar view
     * when we back out.
     */
    private class SwitchSelectedTabViewFragment extends Fragment {
        private int mSelectedTabIndex;

        public SwitchSelectedTabViewFragment(int oldSelectedTab) {
            mSelectedTabIndex = oldSelectedTab;
    @Override
    public void setIcon(int resId) {
        mActionView.setIcon(mContext.getResources().getDrawable(resId));
    }

    @Override
        public void onDetach() {
            if (mSelectedTabIndex >= 0 && mSelectedTabIndex < getTabCount()) {
                mActionView.setTabSelected(mSelectedTabIndex);
    public void setIcon(Drawable icon) {
        mActionView.setIcon(icon);
    }

    @Override
    public void setLogo(int resId) {
        mActionView.setLogo(mContext.getResources().getDrawable(resId));
    }

    @Override
    public void setLogo(Drawable logo) {
        mActionView.setLogo(logo);
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -416,6 +416,21 @@ public class ActionBarView extends ViewGroup {
        }
    }

    public void setIcon(Drawable icon) {
        mIcon = icon;
        if (icon != null &&
                ((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) {
            mIconView.setImageDrawable(icon);
        }
    }

    public void setLogo(Drawable logo) {
        mLogo = logo;
        if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) {
            mIconView.setImageDrawable(logo);
        }
    }

    public void setNavigationMode(int mode) {
        final int oldMode = mNavigationMode;
        if (mode != oldMode) {