Widget 'System default' theme changes

* Theme was supposed to be free
* Move dark theme check to getCount. Wasn't always working in
  hasStableIds and I don't expect this to work either
pull/1184/head
Alex Baker 4 years ago
parent 5adeaf2a9a
commit 1c13d7ecbb

@ -53,10 +53,11 @@ class ThemePickerDialog : DialogFragment() {
var adapter: ArrayAdapter<String>? = null
var dialog: AlertDialog? = null
var selected = -1
var widget = false
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: requireArguments().getInt(EXTRA_SELECTED)
val widget = arguments?.getBoolean(EXTRA_WIDGET) ?: false
widget = arguments?.getBoolean(EXTRA_WIDGET) ?: false
val themes = resources.getStringArray(
if (widget) R.array.widget_themes else R.array.base_theme_names
)
@ -131,5 +132,5 @@ class ThemePickerDialog : DialogFragment() {
private fun available() = isAvailable(selected)
private fun isAvailable(index: Int) =
inventory.purchasedThemes() || ThemeBase(index).isFree
inventory.purchasedThemes() || ThemeBase(index).isFree || widget
}

@ -101,6 +101,10 @@ internal class ScrollableViewsFactory(
override fun onDestroy() {}
override fun getCount(): Int {
if (isDark != checkIfDark) {
isDark = !isDark
localBroadcastManager.reconfigureWidget(widgetId)
}
return tasks.size
}
@ -119,10 +123,6 @@ internal class ScrollableViewsFactory(
override fun getItemId(position: Int) = getTask(position)?.id ?: 0
override fun hasStableIds(): Boolean {
if (isDark != checkIfDark) {
isDark = !isDark
localBroadcastManager.reconfigureWidget(widgetId)
}
return true
}

Loading…
Cancel
Save