diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/AlarmDialog.java b/app/src/main/java/com/forrestguice/suntimeswidget/AlarmDialog.java index 799ce6f38..174bdd848 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/AlarmDialog.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/AlarmDialog.java @@ -97,7 +97,7 @@ public void setChoice( SolarEvents choice ) * @param savedInstanceState a Bundle containing dialog state * @return an AlarmDialog ready to be shown */ - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation","RestrictedApi"}) @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/LocationConfigDialog.java b/app/src/main/java/com/forrestguice/suntimeswidget/LocationConfigDialog.java index f2a6b5a96..96ac339ba 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/LocationConfigDialog.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/LocationConfigDialog.java @@ -124,7 +124,7 @@ public void onResume() * @param savedInstanceState a Bundle containing previously saved dialog state * @return an AlertDialog ready for display */ - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation","RestrictedApi"}) @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java b/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java index f178af236..c7ffe8c63 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java @@ -841,6 +841,7 @@ public boolean onCreateOptionsMenu(Menu menu) return true; } + @SuppressWarnings("RestrictedApi") @Override protected boolean onPrepareOptionsPanel(View view, Menu menu) { diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/TimeDateDialog.java b/app/src/main/java/com/forrestguice/suntimeswidget/TimeDateDialog.java index 31deca6b8..aabcdba00 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/TimeDateDialog.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/TimeDateDialog.java @@ -132,18 +132,18 @@ private void initViews(Context context, View dialogContent) * @param savedInstanceState a bundle containing previously saved dialog state * @return a dialog instance ready to be shown */ - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation","RestrictedApi"}) @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); final FragmentActivity myParent = getActivity(); - Resources r = getResources(); LayoutInflater inflater = myParent.getLayoutInflater(); @SuppressLint("InflateParams") View dialogContent = inflater.inflate(R.layout.layout_dialog_date, null); + Resources r = getResources(); int padding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, r.getDisplayMetrics()); AlertDialog.Builder builder = new AlertDialog.Builder(myParent); diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/TimeZoneDialog.java b/app/src/main/java/com/forrestguice/suntimeswidget/TimeZoneDialog.java index 4462ba976..6d6ba404c 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/TimeZoneDialog.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/TimeZoneDialog.java @@ -74,7 +74,7 @@ public class TimeZoneDialog extends DialogFragment private WidgetTimezones.TimeZoneItemAdapter spinner_timezone_adapter; private boolean loading = false; - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation","RestrictedApi"}) @NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { @@ -90,7 +90,6 @@ public Dialog onCreateDialog(final Bundle savedInstanceState) AlertDialog.Builder builder = new AlertDialog.Builder(myParent); builder.setView(dialogContent, 0, padding, 0, 0); - builder.setTitle(myParent.getString(R.string.timezone_dialog_title)); AlertDialog dialog = builder.create(); diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/themes/WidgetThemeConfigActivity.java b/app/src/main/java/com/forrestguice/suntimeswidget/themes/WidgetThemeConfigActivity.java index 82e247f42..9e8a67a95 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/themes/WidgetThemeConfigActivity.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/themes/WidgetThemeConfigActivity.java @@ -489,9 +489,9 @@ public void onRestoreInstanceState(@NonNull Bundle savedState) super.onRestoreInstanceState(savedState); if (mode == UIMode.ADD_THEME) { - chooseName.setThemeName(savedState.getString(SuntimesTheme.THEME_NAME, chooseName.getThemeName())); + chooseName.setThemeName(getString(savedState, SuntimesTheme.THEME_NAME, chooseName.getThemeName())); } - editDisplay.setText(savedState.getString(SuntimesTheme.THEME_DISPLAYSTRING, editDisplay.getText().toString())); + editDisplay.setText(getString(savedState, SuntimesTheme.THEME_DISPLAYSTRING, editDisplay.getText().toString())); ThemeBackground background = (ThemeBackground)spinBackground.getSelectedItem(); setSelectedBackground(savedState.getInt(SuntimesTheme.THEME_BACKGROUND, (background != null ? background.getResID() : DarkTheme.THEMEDEF_BACKGROUND_ID))); @@ -510,6 +510,14 @@ public void onRestoreInstanceState(@NonNull Bundle savedState) choosePadding.setPadding(savedState.getIntArray(SuntimesTheme.THEME_PADDING)); } + private String getString(Bundle bundle, String key, String defaultValue) + { + String value = bundle.getString(key); + if (value != null) + return value; + else return defaultValue; + } + @Override public boolean onCreateOptionsMenu(Menu menu) { diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/themes/WidgetThemeListActivity.java b/app/src/main/java/com/forrestguice/suntimeswidget/themes/WidgetThemeListActivity.java index 922b0269a..3c95570b2 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/themes/WidgetThemeListActivity.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/themes/WidgetThemeListActivity.java @@ -510,7 +510,7 @@ public void onSaveInstanceState( Bundle outState ) public void onRestoreInstanceState(@NonNull Bundle savedState) { super.onRestoreInstanceState(savedState); - String themeName = savedState.getString(SuntimesTheme.THEME_NAME, null); + String themeName = savedState.getString(SuntimesTheme.THEME_NAME); if (themeName != null) { SuntimesTheme.ThemeDescriptor theme = (SuntimesTheme.ThemeDescriptor) adapter.getItem(adapter.ordinal(themeName)); @@ -531,11 +531,11 @@ public void onResume() } } + @SuppressWarnings("RestrictedApi") @Override protected boolean onPrepareOptionsPanel(View view, Menu menu) { SuntimesUtils.forceActionBarIcons(menu); return super.onPrepareOptionsPanel(view, menu); } - }