Make dark mode free

pull/935/head
Alex Baker 5 years ago
parent cb29478e71
commit 69685be912

@ -59,7 +59,7 @@ class ThemePickerDialog : InjectingDialogFragment() {
adapter = object : ArrayAdapter<String>(activity!!, R.layout.simple_list_item_single_choice, themes) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val view = super.getView(position, convertView, parent)
val textColor = if (inventory.purchasedThemes() || position < 2) {
val textColor = if (isAvailable(position)) {
R.color.text_primary
} else {
R.color.text_tertiary
@ -123,5 +123,8 @@ class ThemePickerDialog : InjectingDialogFragment() {
dialog?.getButton(AlertDialog.BUTTON_POSITIVE)?.text = getString(stringRes)
}
private fun available() = inventory.purchasedThemes() || selected < 2
private fun available() = isAvailable(selected)
private fun isAvailable(index: Int) =
inventory.purchasedThemes() || themeCache.getThemeBase(index).isFree
}

@ -533,4 +533,8 @@ public class Preferences {
public boolean showSubtasks() {
return atLeastLollipop() && getBoolean(R.string.p_show_subtasks, false);
}
public int getThemeBase() {
return getInt(R.string.p_theme, 5);
}
}

@ -265,14 +265,14 @@ class LookAndFeel : InjectingPreferenceFragment(), Preference.OnPreferenceChange
data?.getIntExtra(ThemePickerDialog.EXTRA_SELECTED, themeBase.index)
?: themeBase.index
} else {
preferences.getInt(R.string.p_theme, 0)
preferences.themeBase
}
setBaseTheme(index)
} else if (requestCode == REQUEST_THEME_PICKER) {
val index = data?.getIntExtra(ThemePickerDialog.EXTRA_SELECTED, themeBase.index)
?: preferences.getInt(R.string.p_theme, 0)
?: preferences.themeBase
if (resultCode == RESULT_OK) {
if (inventory.purchasedThemes() || index < 2) {
if (inventory.purchasedThemes() || themeCache.getThemeBase(index).isFree) {
setBaseTheme(index)
} else {
startActivityForResult(

@ -61,7 +61,7 @@ public class ThemeBase implements Pickable {
@Override
public boolean isFree() {
return index < 2;
return index < 3 || index == 5;
}
@Override
@ -70,7 +70,7 @@ public class ThemeBase implements Pickable {
}
public boolean isDarkTheme(Activity activity) {
return index == 4
return index == 4 || index == 5
? Configuration.UI_MODE_NIGHT_YES
== (activity.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK)

@ -96,13 +96,11 @@ public class ThemeCache {
}
public ThemeBase getThemeBase(@Nullable Intent intent) {
int index = preferences.getInt(R.string.p_theme, 0);
if (intent != null && intent.hasExtra(EXTRA_THEME_OVERRIDE)) {
index = intent.getIntExtra(EXTRA_THEME_OVERRIDE, 0);
} else if (index > 1 && !inventory.purchasedThemes()) {
index = 0;
return getThemeBase(intent.getIntExtra(EXTRA_THEME_OVERRIDE, 5));
}
return getThemeBase(index);
ThemeBase themeBase = getThemeBase(preferences.getThemeBase());
return themeBase.isFree() || inventory.purchasedThemes() ? themeBase : getThemeBase(5);
}
public ThemeBase getThemeBase(int index) {

Loading…
Cancel
Save