summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-04-26 16:40:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-04-26 16:40:40 +0000
commit9ea13ca0b67e77c5efda1c94c141dc49987c0745 (patch)
tree27f0abc0fa0bbda3cb6aa6ec1fca773467b1fc92 /core/java/android/widget/RemoteViews.java
parent39cfdf1325efc3699c9371e06e895e6ad5c56391 (diff)
parent36b86c28f88e4c7853a4255a0fd9b754cbb547c4 (diff)
Merge "Autofill: new UX for TV and support themes" into pi-dev
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 5ecbf90a4eca..4865dab6056a 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -21,6 +21,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import android.annotation.ColorInt;
import android.annotation.DimenRes;
import android.annotation.NonNull;
+import android.annotation.StyleRes;
import android.app.ActivityOptions;
import android.app.ActivityThread;
import android.app.Application;
@@ -56,6 +57,7 @@ import android.os.UserHandle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
+import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.LayoutInflater.Filter;
import android.view.RemotableViewMethod;
@@ -182,6 +184,12 @@ public class RemoteViews implements Parcelable, Filter {
private boolean mIsRoot = true;
/**
+ * Optional theme resource id applied in inflateView(). When 0, Theme.DeviceDefault will be
+ * used.
+ */
+ private int mApplyThemeResId;
+
+ /**
* Whether reapply is disallowed on this remoteview. This maybe be true if some actions modify
* the layout in a way that isn't recoverable, since views are being removed.
*/
@@ -3267,6 +3275,14 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * Set the theme used in apply() and applyASync().
+ * @hide
+ */
+ public void setApplyTheme(@StyleRes int themeResId) {
+ mApplyThemeResId = themeResId;
+ }
+
+ /**
* Inflates the view hierarchy represented by this object and applies
* all of the actions.
*
@@ -3301,6 +3317,10 @@ public class RemoteViews implements Parcelable, Filter {
final Context contextForResources = getContextForResources(context);
Context inflationContext = new RemoteViewsContextWrapper(context, contextForResources);
+ // If mApplyThemeResId is not given, Theme.DeviceDefault will be used.
+ if (mApplyThemeResId != 0) {
+ inflationContext = new ContextThemeWrapper(inflationContext, mApplyThemeResId);
+ }
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);