diff options
| author | Nader Jawad <njawad@google.com> | 2019-02-06 14:52:39 -0800 |
|---|---|---|
| committer | Nader Jawad <njawad@google.com> | 2019-02-15 19:06:51 +0000 |
| commit | a1eef726735dabd048ea599bc79c60ab80707f94 (patch) | |
| tree | 44ecaaa3d1ffff2332449e5c54e6fdb18c214341 /core/java/android/view/ContextThemeWrapper.java | |
| parent | a454dd772c9d175475fe70ab315a0dc4879dddc4 (diff) | |
Annotated mTheme field on ContextThemeWrapper with maxTargetSdk P
Added ContextThemeWrapper#setTheme(Theme) method to programmatically
assign the theme without using a resource id
Change-Id: I043253e65a535abdf8d89d9421d2cff2b41bdb05
Fixes: 123768723
Test: Added CTS test to verify setTheme
Diffstat (limited to 'core/java/android/view/ContextThemeWrapper.java')
| -rw-r--r-- | core/java/android/view/ContextThemeWrapper.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/java/android/view/ContextThemeWrapper.java b/core/java/android/view/ContextThemeWrapper.java index c77500a9fd70..696e048ffed8 100644 --- a/core/java/android/view/ContextThemeWrapper.java +++ b/core/java/android/view/ContextThemeWrapper.java @@ -16,6 +16,7 @@ package android.view; +import android.annotation.Nullable; import android.annotation.StyleRes; import android.annotation.UnsupportedAppUsage; import android.content.Context; @@ -23,6 +24,7 @@ import android.content.ContextWrapper; import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; +import android.os.Build; /** * A context wrapper that allows you to modify or replace the theme of the @@ -31,7 +33,7 @@ import android.content.res.Resources; public class ContextThemeWrapper extends ContextWrapper { @UnsupportedAppUsage private int mThemeResource; - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768723) private Resources.Theme mTheme; @UnsupportedAppUsage private LayoutInflater mInflater; @@ -146,6 +148,15 @@ public class ContextThemeWrapper extends ContextWrapper { } } + /** + * Set the configure the current theme. If null is provided then the default Theme is returned + * on the next call to {@link #getTheme()} + * @param theme Theme to consume in the wrapper, a value of null resets the theme to the default + */ + public void setTheme(@Nullable Resources.Theme theme) { + mTheme = theme; + } + /** @hide */ @Override @UnsupportedAppUsage |
