Apply theme to grid selector time picker
This commit is contained in:
parent
42137d8ae2
commit
020ffc921d
@ -280,7 +280,7 @@ public class Utils {
|
|||||||
* @return true if dark mode, false if light.
|
* @return true if dark mode, false if light.
|
||||||
*/
|
*/
|
||||||
public static boolean isDarkTheme(Context context, boolean current) {
|
public static boolean isDarkTheme(Context context, boolean current) {
|
||||||
return resolveBoolean(context, R.attr.theme_dark, current);
|
return resolveBoolean(context, R.attr.themeDark, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -70,6 +70,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
|
|||||||
private static final String KEY_IN_KB_MODE = "in_kb_mode";
|
private static final String KEY_IN_KB_MODE = "in_kb_mode";
|
||||||
private static final String KEY_TYPED_TIMES = "typed_times";
|
private static final String KEY_TYPED_TIMES = "typed_times";
|
||||||
private static final String KEY_DARK_THEME = "dark_theme";
|
private static final String KEY_DARK_THEME = "dark_theme";
|
||||||
|
private static final String KEY_THEME_SET_AT_RUNTIME = "theme_set_at_runtime";
|
||||||
|
|
||||||
public static final int HOUR_INDEX = 0;
|
public static final int HOUR_INDEX = 0;
|
||||||
public static final int MINUTE_INDEX = 1;
|
public static final int MINUTE_INDEX = 1;
|
||||||
@ -112,6 +113,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
|
|||||||
private int mInitialMinute;
|
private int mInitialMinute;
|
||||||
private boolean mIs24HourMode;
|
private boolean mIs24HourMode;
|
||||||
private boolean mThemeDark;
|
private boolean mThemeDark;
|
||||||
|
private boolean mThemeSetAtRuntime;
|
||||||
|
|
||||||
// For hardware IME input.
|
// For hardware IME input.
|
||||||
private char mPlaceholderText;
|
private char mPlaceholderText;
|
||||||
@ -243,6 +245,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
|
|||||||
mIs24HourMode = is24HourMode;
|
mIs24HourMode = is24HourMode;
|
||||||
mInKbMode = false;
|
mInKbMode = false;
|
||||||
mThemeDark = false;
|
mThemeDark = false;
|
||||||
|
mThemeSetAtRuntime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,6 +253,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
|
|||||||
*/
|
*/
|
||||||
public void setThemeDark(boolean dark) {
|
public void setThemeDark(boolean dark) {
|
||||||
mThemeDark = dark;
|
mThemeDark = dark;
|
||||||
|
mThemeSetAtRuntime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isThemeDark() {
|
public boolean isThemeDark() {
|
||||||
@ -278,6 +282,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
|
|||||||
mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
|
mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
|
||||||
mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
|
mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
|
||||||
mThemeDark = savedInstanceState.getBoolean(KEY_DARK_THEME);
|
mThemeDark = savedInstanceState.getBoolean(KEY_DARK_THEME);
|
||||||
|
mThemeSetAtRuntime = savedInstanceState.getBoolean(KEY_THEME_SET_AT_RUNTIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +297,10 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
|
|||||||
|
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
if (!mThemeSetAtRuntime) {
|
||||||
|
mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
|
||||||
|
}
|
||||||
|
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
mHourPickerDescription = res.getString(R.string.hour_picker_description);
|
mHourPickerDescription = res.getString(R.string.hour_picker_description);
|
||||||
mSelectHours = res.getString(R.string.select_hours);
|
mSelectHours = res.getString(R.string.select_hours);
|
||||||
@ -575,6 +584,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
|
|||||||
outState.putIntegerArrayList(KEY_TYPED_TIMES, mTypedTimes);
|
outState.putIntegerArrayList(KEY_TYPED_TIMES, mTypedTimes);
|
||||||
}
|
}
|
||||||
outState.putBoolean(KEY_DARK_THEME, mThemeDark);
|
outState.putBoolean(KEY_DARK_THEME, mThemeDark);
|
||||||
|
outState.putBoolean(KEY_THEME_SET_AT_RUNTIME, mThemeSetAtRuntime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<attr name="theme_dark" format="boolean">false</attr>
|
<attr name="themeDark" format="boolean">false</attr>
|
||||||
|
|
||||||
<style name="time_label">
|
<style name="time_label">
|
||||||
<item name="android:textSize">@dimen/time_label_size</item>
|
<item name="android:textSize">@dimen/time_label_size</item>
|
||||||
|
|||||||
@ -19,6 +19,8 @@
|
|||||||
<item name="themedIconTint">@color/icon_color_active_light</item>
|
<item name="themedIconTint">@color/icon_color_active_light</item>
|
||||||
<item name="android:textColorHint">@color/text_color_disabled_light</item>
|
<item name="android:textColorHint">@color/text_color_disabled_light</item>
|
||||||
<item name="themedPopupOverlay">@style/ThemeOverlay.AppCompat.Light</item>
|
<item name="themedPopupOverlay">@style/ThemeOverlay.AppCompat.Light</item>
|
||||||
|
<!-- For BottomSheetTimePickers -->
|
||||||
|
<item name="themeDark">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.Dark" parent="Theme.AppCompat.NoActionBar">
|
<style name="AppTheme.Dark" parent="Theme.AppCompat.NoActionBar">
|
||||||
@ -40,6 +42,8 @@
|
|||||||
<item name="themedIconTint">@color/icon_color_active_dark</item>
|
<item name="themedIconTint">@color/icon_color_active_dark</item>
|
||||||
<item name="android:textColorHint">@color/text_color_disabled_dark</item>
|
<item name="android:textColorHint">@color/text_color_disabled_dark</item>
|
||||||
<item name="themedPopupOverlay">@style/ThemeOverlay.AppCompat.Dark</item>
|
<item name="themedPopupOverlay">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||||
|
<!-- For BottomSheetTimePickers -->
|
||||||
|
<item name="themeDark">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user