Add resource ID variants of ActionBar tab setters

Bugs 3204153 and 2901235

Change-Id: Ib430f96da77f8e7647b22d190243a2fcd766d842
diff --git a/api/current.xml b/api/current.xml
index a66acbc..839d387 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -20395,6 +20395,19 @@
 <parameter name="view" type="android.view.View">
 </parameter>
 </method>
+<method name="setCustomView"
+ return="android.app.ActionBar.Tab"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="layoutResId" type="int">
+</parameter>
+</method>
 <method name="setIcon"
  return="android.app.ActionBar.Tab"
  abstract="true"
@@ -20408,6 +20421,19 @@
 <parameter name="icon" type="android.graphics.drawable.Drawable">
 </parameter>
 </method>
+<method name="setIcon"
+ return="android.app.ActionBar.Tab"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="resId" type="int">
+</parameter>
+</method>
 <method name="setTabListener"
  return="android.app.ActionBar.Tab"
  abstract="true"
@@ -20447,6 +20473,19 @@
 <parameter name="text" type="java.lang.CharSequence">
 </parameter>
 </method>
+<method name="setText"
+ return="android.app.ActionBar.Tab"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="resId" type="int">
+</parameter>
+</method>
 <field name="INVALID_POSITION"
  type="int"
  transient="false"
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java
index 246d661..7a6ad0f 100644
--- a/core/java/android/app/ActionBar.java
+++ b/core/java/android/app/ActionBar.java
@@ -590,6 +590,14 @@
         public abstract Tab setIcon(Drawable icon);
 
         /**
+         * Set the icon displayed on this tab.
+         *
+         * @param resId Resource ID referring to the drawable to use as an icon
+         * @return The current instance for call chaining
+         */
+        public abstract Tab setIcon(int resId);
+
+        /**
          * Set the text displayed on this tab. Text may be truncated if there is not
          * room to display the entire string.
          *
@@ -599,6 +607,15 @@
         public abstract Tab setText(CharSequence text);
 
         /**
+         * Set the text displayed on this tab. Text may be truncated if there is not
+         * room to display the entire string.
+         *
+         * @param resId A resource ID referring to the text that should be displayed
+         * @return The current instance for call chaining
+         */
+        public abstract Tab setText(int resId);
+
+        /**
          * Set a custom view to be used for this tab. This overrides values set by
          * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
          *
@@ -608,6 +625,15 @@
         public abstract Tab setCustomView(View view);
 
         /**
+         * Set a custom view to be used for this tab. This overrides values set by
+         * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
+         *
+         * @param layoutResId A layout resource to inflate and use as a custom tab view
+         * @return The current instance for call chaining
+         */
+        public abstract Tab setCustomView(int layoutResId);
+
+        /**
          * Retrieve a previously set custom view for this tab.
          *
          * @return The custom view set by {@link #setCustomView(View)}.
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 86523ac..20402a3 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -31,6 +31,7 @@
 import android.graphics.drawable.Drawable;
 import android.os.Handler;
 import android.view.ActionMode;
+import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
@@ -563,6 +564,11 @@
         }
 
         @Override
+        public Tab setCustomView(int layoutResId) {
+            return setCustomView(LayoutInflater.from(mContext).inflate(layoutResId, null));
+        }
+
+        @Override
         public Drawable getIcon() {
             return mIcon;
         }
@@ -588,12 +594,22 @@
         }
 
         @Override
+        public Tab setIcon(int resId) {
+            return setIcon(mContext.getResources().getDrawable(resId));
+        }
+
+        @Override
         public Tab setText(CharSequence text) {
             mText = text;
             return this;
         }
 
         @Override
+        public Tab setText(int resId) {
+            return setText(mContext.getResources().getText(resId));
+        }
+
+        @Override
         public void select() {
             selectTab(this);
         }