Merge "Add support for setting action bar title/subtitle by resource ID"
diff --git a/api/current.xml b/api/current.xml
index 280537d..d97bbb5 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -19835,6 +19835,21 @@
deprecated="not deprecated"
visibility="public"
>
+<parameter name="titleResId" type="int">
+</parameter>
+<parameter name="subtitleResId" type="int">
+</parameter>
+</method>
+<method name="setStandardNavigationMode"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
<parameter name="title" type="java.lang.CharSequence">
</parameter>
</method>
@@ -19848,6 +19863,19 @@
deprecated="not deprecated"
visibility="public"
>
+<parameter name="titleResId" type="int">
+</parameter>
+</method>
+<method name="setStandardNavigationMode"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
</method>
<method name="setSubtitle"
return="void"
@@ -19862,6 +19890,19 @@
<parameter name="subtitle" type="java.lang.CharSequence">
</parameter>
</method>
+<method name="setSubtitle"
+ 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="setTabNavigationMode"
return="void"
abstract="true"
@@ -19899,6 +19940,19 @@
<parameter name="title" type="java.lang.CharSequence">
</parameter>
</method>
+<method name="setTitle"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="resId" type="int">
+</parameter>
+</method>
<field name="DISPLAY_HIDE_HOME"
type="int"
transient="false"
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java
index fbc0be3..d33494b 100644
--- a/core/java/android/app/ActionBar.java
+++ b/core/java/android/app/ActionBar.java
@@ -131,6 +131,11 @@
*
* @param title The action bar's title. null is treated as an empty string.
* @param subtitle The action bar's subtitle. null will remove the subtitle entirely.
+ *
+ * @see #setStandardNavigationMode()
+ * @see #setStandardNavigationMode(CharSequence)
+ * @see #setStandardNavigationMode(int)
+ * @see #setStandardNavigationMode(int, int)
*/
public abstract void setStandardNavigationMode(CharSequence title, CharSequence subtitle);
@@ -138,13 +143,51 @@
* Set the action bar into standard navigation mode, supplying a title and subtitle.
*
* Standard navigation mode is default. The title is automatically set to the
+ * name of your Activity. Subtitles are displayed underneath the title, usually
+ * in a smaller font or otherwise less prominently than the title. Subtitles are
+ * good for extended descriptions of activity state.
+ *
+ * @param titleResId Resource ID of a title string
+ * @param subtitleResId Resource ID of a subtitle string
+ *
+ * @see #setStandardNavigationMode()
+ * @see #setStandardNavigationMode(CharSequence)
+ * @see #setStandardNavigationMode(CharSequence, CharSequence)
+ * @see #setStandardNavigationMode(int)
+ */
+ public abstract void setStandardNavigationMode(int titleResId, int subtitleResId);
+
+ /**
+ * Set the action bar into standard navigation mode, supplying a title and subtitle.
+ *
+ * Standard navigation mode is default. The title is automatically set to the
* name of your Activity on startup if an action bar is present.
*
* @param title The action bar's title. null is treated as an empty string.
+ *
+ * @see #setStandardNavigationMode()
+ * @see #setStandardNavigationMode(CharSequence, CharSequence)
+ * @see #setStandardNavigationMode(int)
+ * @see #setStandardNavigationMode(int, int)
*/
public abstract void setStandardNavigationMode(CharSequence title);
/**
+ * Set the action bar into standard navigation mode, supplying a title and subtitle.
+ *
+ * Standard navigation mode is default. The title is automatically set to the
+ * name of your Activity on startup if an action bar is present.
+ *
+ * @param titleResId Resource ID of a title string
+ *
+ * @see #setStandardNavigationMode()
+ * @see #setStandardNavigationMode(CharSequence)
+ * @see #setStandardNavigationMode(CharSequence, CharSequence)
+ * @see #setStandardNavigationMode(int, int)
+ */
+ public abstract void setStandardNavigationMode(int titleResId);
+
+ /**
* Set the action bar into standard navigation mode, using the currently set title
* and/or subtitle.
*
@@ -157,18 +200,40 @@
* Set the action bar's title. This will only be displayed in standard navigation mode.
*
* @param title Title to set
+ *
+ * @see #setTitle(int)
*/
public abstract void setTitle(CharSequence title);
/**
+ * Set the action bar's title. This will only be displayed in standard navigation mode.
+ *
+ * @param resId Resource ID of title string to set
+ *
+ * @see #setTitle(CharSequence)
+ */
+ public abstract void setTitle(int resId);
+
+ /**
* Set the action bar's subtitle. This will only be displayed in standard navigation mode.
* Set to null to disable the subtitle entirely.
*
* @param subtitle Subtitle to set
+ *
+ * @see #setSubtitle(int)
*/
public abstract void setSubtitle(CharSequence subtitle);
/**
+ * Set the action bar's subtitle. This will only be displayed in standard navigation mode.
+ *
+ * @param resId Resource ID of subtitle string to set
+ *
+ * @see #setSubtitle(CharSequence)
+ */
+ public abstract void setSubtitle(int resId);
+
+ /**
* Set display options. This changes all display option bits at once. To change
* a limited subset of display options, see {@link #setDisplayOptions(int, int)}.
*
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 99dbe4c..0860bfe 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -106,6 +106,27 @@
CONTEXT_DISPLAY_NORMAL : CONTEXT_DISPLAY_SPLIT;
}
+ @Override
+ public void setStandardNavigationMode(int titleResId, int subtitleResId) {
+ setStandardNavigationMode(mActivity.getString(titleResId),
+ mActivity.getString(subtitleResId));
+ }
+
+ @Override
+ public void setStandardNavigationMode(int titleResId) {
+ setStandardNavigationMode(mActivity.getString(titleResId));
+ }
+
+ @Override
+ public void setTitle(int resId) {
+ setTitle(mActivity.getString(resId));
+ }
+
+ @Override
+ public void setSubtitle(int resId) {
+ setSubtitle(mActivity.getString(resId));
+ }
+
public void setCustomNavigationMode(View view) {
cleanupTabs();
mActionView.setCustomNavigationView(view);