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

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

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

parents aceaa225 1969b879
Loading
Loading
Loading
Loading
+52 −0
Original line number Original line Diff line number Diff line
@@ -22045,6 +22045,32 @@
<parameter name="useLogo" type="boolean">
<parameter name="useLogo" type="boolean">
</parameter>
</parameter>
</method>
</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"
<method name="setListNavigationCallbacks"
 return="void"
 return="void"
 abstract="true"
 abstract="true"
@@ -22060,6 +22086,32 @@
<parameter name="callback" type="android.app.ActionBar.OnNavigationListener">
<parameter name="callback" type="android.app.ActionBar.OnNavigationListener">
</parameter>
</parameter>
</method>
</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"
<method name="setNavigationMode"
 return="void"
 return="void"
 abstract="true"
 abstract="true"
+60 −0
Original line number Original line Diff line number Diff line
@@ -159,6 +159,66 @@ public abstract class ActionBar {
     */
     */
    public abstract void setCustomView(int resId);
    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.
     * Set the adapter and navigation callback for list navigation mode.
     *
     *
+17 −16
Original line number Original line Diff line number Diff line
@@ -889,23 +889,24 @@ public class ActionBarImpl extends ActionBar {
        return mTabs.get(index);
        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) {
    @Override
            mSelectedTabIndex = oldSelectedTab;
    public void setIcon(int resId) {
        mActionView.setIcon(mContext.getResources().getDrawable(resId));
    }
    }


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

    @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 Original line 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) {
    public void setNavigationMode(int mode) {
        final int oldMode = mNavigationMode;
        final int oldMode = mNavigationMode;
        if (mode != oldMode) {
        if (mode != oldMode) {