diff options
| author | Alan Viverette <alanv@google.com> | 2015-04-10 11:05:50 -0700 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2015-04-10 12:42:57 -0700 |
| commit | 682a433d0b8ff3e4e0ffc8d2cfedc8907ab1e83b (patch) | |
| tree | 4fd0ff75901cdee04112e0b11f5a360def18819e | |
| parent | caa41648f4e3cecc1996447396aabc4e394b8fd0 (diff) | |
| download | frameworks_base-682a433d0b8ff3e4e0ffc8d2cfedc8907ab1e83b.zip frameworks_base-682a433d0b8ff3e4e0ffc8d2cfedc8907ab1e83b.tar.gz frameworks_base-682a433d0b8ff3e4e0ffc8d2cfedc8907ab1e83b.tar.bz2 | |
Fix application of default dialog theme
Cleans up lint annotations.
Bug: 20149703
Change-Id: I2ed4eb002b6679a55ea4d5fcc1ea958a4dcb08df
| -rw-r--r-- | core/java/android/app/AlertDialog.java | 9 | ||||
| -rw-r--r-- | core/java/android/app/Dialog.java | 26 |
2 files changed, 18 insertions, 17 deletions
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java index 2dbbc38..abe12dc 100644 --- a/core/java/android/app/AlertDialog.java +++ b/core/java/android/app/AlertDialog.java @@ -22,6 +22,7 @@ import android.annotation.ArrayRes; import android.annotation.AttrRes; import android.annotation.DrawableRes; import android.annotation.StringRes; +import android.annotation.StyleRes; import android.content.Context; import android.content.DialogInterface; import android.database.Cursor; @@ -191,11 +192,11 @@ public class AlertDialog extends Dialog implements DialogInterface { * {@code context}'s default alert dialog theme * @see android.R.styleable#Theme_alertDialogTheme */ - protected AlertDialog(Context context, @AttrRes int themeResId) { + protected AlertDialog(Context context, @StyleRes int themeResId) { this(context, themeResId, true); } - AlertDialog(Context context, @AttrRes int themeResId, boolean createContextThemeWrapper) { + AlertDialog(Context context, @StyleRes int themeResId, boolean createContextThemeWrapper) { super(context, createContextThemeWrapper ? resolveDialogTheme(context, themeResId) : 0, createContextThemeWrapper); @@ -204,9 +205,7 @@ public class AlertDialog extends Dialog implements DialogInterface { } static int resolveDialogTheme(Context context, int themeResId) { - if (themeResId == 0) { - return 0; - } else if (themeResId == THEME_TRADITIONAL) { + if (themeResId == THEME_TRADITIONAL) { return R.style.Theme_Dialog_Alert; } else if (themeResId == THEME_HOLO_DARK) { return R.style.Theme_Holo_Dialog_Alert; diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index 6a2d207..786a52f 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -20,9 +20,11 @@ import android.annotation.CallSuper; import android.annotation.DrawableRes; import android.annotation.IdRes; import android.annotation.LayoutRes; +import android.annotation.NonNull; import android.annotation.StringRes; import android.annotation.Nullable; +import android.annotation.StyleRes; import android.content.ComponentName; import android.content.Context; import android.content.ContextWrapper; @@ -140,7 +142,7 @@ public class Dialog implements DialogInterface, Window.Callback, * @param context the context in which the dialog should run * @see android.R.styleable#Theme_dialogTheme */ - public Dialog(Context context) { + public Dialog(@NonNull Context context) { this(context, 0, true); } @@ -156,26 +158,26 @@ public class Dialog implements DialogInterface, Window.Callback, * using styles. * * @param context the context in which the dialog should run - * @param theme a style resource describing the theme to use for the + * @param themeResId a style resource describing the theme to use for the * window, or {@code 0} to use the default dialog theme */ - public Dialog(Context context, int theme) { - this(context, theme, true); + public Dialog(@NonNull Context context, @StyleRes int themeResId) { + this(context, themeResId, true); } - Dialog(Context context, int theme, boolean createContextThemeWrapper) { + Dialog(@NonNull Context context, @StyleRes int themeResId, boolean createContextThemeWrapper) { if (createContextThemeWrapper) { - if (theme == 0) { + if (themeResId == 0) { final TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.dialogTheme, outValue, true); - theme = outValue.resourceId; + themeResId = outValue.resourceId; } - mContext = new ContextThemeWrapper(context, theme); + mContext = new ContextThemeWrapper(context, themeResId); } else { mContext = context; } - mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); + mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); final Window w = new PhoneWindow(mContext); mWindow = w; @@ -192,14 +194,13 @@ public class Dialog implements DialogInterface, Window.Callback, * @hide */ @Deprecated - protected Dialog(Context context, boolean cancelable, - Message cancelCallback) { + protected Dialog(@NonNull Context context, boolean cancelable, Message cancelCallback) { this(context); mCancelable = cancelable; mCancelMessage = cancelCallback; } - protected Dialog(Context context, boolean cancelable, + protected Dialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) { this(context); mCancelable = cancelable; @@ -211,6 +212,7 @@ public class Dialog implements DialogInterface, Window.Callback, * * @return Context The Context used by the Dialog. */ + @NonNull public final Context getContext() { return mContext; } |
