Apply theme to grid selector time picker

This commit is contained in:
Phillip Hsu
2016-09-20 23:29:33 -07:00
parent 42137d8ae2
commit 020ffc921d
4 changed files with 16 additions and 2 deletions
@@ -280,7 +280,7 @@ public class Utils {
* @return true if dark mode, false if light.
*/
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_TYPED_TIMES = "typed_times";
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 MINUTE_INDEX = 1;
@@ -112,6 +113,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
private int mInitialMinute;
private boolean mIs24HourMode;
private boolean mThemeDark;
private boolean mThemeSetAtRuntime;
// For hardware IME input.
private char mPlaceholderText;
@@ -243,6 +245,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
mIs24HourMode = is24HourMode;
mInKbMode = false;
mThemeDark = false;
mThemeSetAtRuntime = false;
}
/**
@@ -250,6 +253,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
*/
public void setThemeDark(boolean dark) {
mThemeDark = dark;
mThemeSetAtRuntime = true;
}
public boolean isThemeDark() {
@@ -278,6 +282,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
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);
if (!mThemeSetAtRuntime) {
mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
}
Resources res = getResources();
mHourPickerDescription = res.getString(R.string.hour_picker_description);
mSelectHours = res.getString(R.string.select_hours);
@@ -575,6 +584,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog implements
outState.putIntegerArrayList(KEY_TYPED_TIMES, mTypedTimes);
}
outState.putBoolean(KEY_DARK_THEME, mThemeDark);
outState.putBoolean(KEY_THEME_SET_AT_RUNTIME, mThemeSetAtRuntime);
}
}