Add support for setting action mode titles/subtitles by resource ID

Change-Id: Ia0d5234cc16f325eeb29127fb87e2616d67379ec
diff --git a/api/current.xml b/api/current.xml
index 7df4667..e59ea2d 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -177071,6 +177071,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="setTitle"
  return="void"
  abstract="true"
@@ -177084,6 +177097,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>
 </class>
 <interface name="ActionMode.Callback"
  abstract="true"
diff --git a/core/java/android/view/ActionMode.java b/core/java/android/view/ActionMode.java
index d4f4b93..4a7d7ad 100644
--- a/core/java/android/view/ActionMode.java
+++ b/core/java/android/view/ActionMode.java
@@ -29,21 +29,45 @@
      *
      * @param title Title string to set
      *
+     * @see #setTitle(int)
      * @see #setCustomView(View)
      */
     public abstract void setTitle(CharSequence title);
 
     /**
+     * Set the title of the action mode. This method will have no visible effect if
+     * a custom view has been set.
+     *
+     * @param resId Resource ID of a string to set as the title
+     *
+     * @see #setTitle(CharSequence)
+     * @see #setCustomView(View)
+     */
+    public abstract void setTitle(int resId);
+
+    /**
      * Set the subtitle of the action mode. This method will have no visible effect if
      * a custom view has been set.
      *
      * @param subtitle Subtitle string to set
      *
+     * @see #setSubtitle(int)
      * @see #setCustomView(View)
      */
     public abstract void setSubtitle(CharSequence subtitle);
 
     /**
+     * Set the subtitle of the action mode. This method will have no visible effect if
+     * a custom view has been set.
+     *
+     * @param resId Resource ID of a string to set as the subtitle
+     *
+     * @see #setSubtitle(CharSequence)
+     * @see #setCustomView(View)
+     */
+    public abstract void setSubtitle(int resId);
+
+    /**
      * 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.
      *
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index e457701..99dbe4c 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -422,6 +422,16 @@
         }
 
         @Override
+        public void setTitle(int resId) {
+            setTitle(mActivity.getString(resId));
+        }
+
+        @Override
+        public void setSubtitle(int resId) {
+            setSubtitle(mActivity.getString(resId));
+        }
+
+        @Override
         public CharSequence getTitle() {
             return mUpperContextView.getTitle();
         }
diff --git a/core/java/com/android/internal/view/StandaloneActionMode.java b/core/java/com/android/internal/view/StandaloneActionMode.java
index 13eda10..d8fd364 100644
--- a/core/java/com/android/internal/view/StandaloneActionMode.java
+++ b/core/java/com/android/internal/view/StandaloneActionMode.java
@@ -58,6 +58,16 @@
     }
 
     @Override
+    public void setTitle(int resId) {
+        setTitle(mContext.getString(resId));
+    }
+
+    @Override
+    public void setSubtitle(int resId) {
+        setSubtitle(mContext.getString(resId));
+    }
+
+    @Override
     public void setCustomView(View view) {
         mContextView.setCustomView(view);
         mCustomView = view != null ? new WeakReference<View>(view) : null;