Improve widget opacity settings

pull/996/head
Alex Baker 5 years ago
parent 290584de16
commit 9ce5a727b8

@ -4,10 +4,8 @@ import android.app.Activity
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.os.Bundle
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.SeekBarPreference
import androidx.preference.SwitchPreferenceCompat
import androidx.preference.*
import com.google.common.primitives.Ints.max
import com.todoroo.astrid.api.Filter
import org.tasks.LocalBroadcastManager
import org.tasks.R
@ -59,9 +57,22 @@ class ScrollableWidget : InjectingPreferenceFragment() {
appWidgetId = arguments!!.getInt(EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
widgetPreferences = WidgetPreferences(context, preferences, appWidgetId)
setupSlider(R.string.p_widget_header_opacity, 100)
setupSlider(R.string.p_widget_opacity, 100)
setupSlider(R.string.p_widget_empty_space_opacity, 100)
val row = setupSlider(R.string.p_widget_opacity, 100)
val header = setupSlider(R.string.p_widget_header_opacity, row.value)
val footer = setupSlider(R.string.p_widget_empty_space_opacity, row.value)
val opacity = findPreference(R.string.opacity) as SeekBarPreference
opacity.value = max(header.value, row.value, footer.value)
if (header.value != row.value || header.value != footer.value) {
(findPreference(R.string.preferences_advanced) as PreferenceCategory).initialExpandedChildrenCount = 4
}
opacity.setOnPreferenceChangeListener { _, newValue ->
header.value = newValue as Int
row.value = newValue
footer.value = newValue
true
}
setupSlider(R.string.p_widget_font_size, 16)
val showDueDate = setupCheckbox(R.string.p_widget_show_due_date)
setupCheckbox(R.string.p_widget_due_date_underneath, false).dependency = showDueDate.key
@ -76,6 +87,7 @@ class ScrollableWidget : InjectingPreferenceFragment() {
showSettings.dependency = showHeader.key
val showMenu = setupCheckbox(R.string.p_widget_show_menu)
showMenu.dependency = showHeader.key
header.dependency = showHeader.key
findPreference(R.string.p_widget_filter)
.setOnPreferenceClickListener {

@ -390,6 +390,9 @@ File %1$s contained %2$s.\n\n
<string name="default_sync">Default sync</string>
<string name="filter">Filter</string>
<string name="opacity">Opacity</string>
<string name="opacity_header">Header opacity</string>
<string name="opacity_row">Row opacity</string>
<string name="opacity_footer">Footer opacity</string>
<string name="theme">Theme</string>
<string name="color">Color</string>
<string name="icon">Icon</string>
@ -412,7 +415,7 @@ File %1$s contained %2$s.\n\n
<string name="widget_settings">Widget settings</string>
<string name="widget_header_settings">Header settings</string>
<string name="widget_row_settings">Row settings</string>
<string name="widget_empty_space">Empty space</string>
<string name="widget_footer_settings">Footer settings</string>
<string name="widget_empty_space_on_click">On click</string>
<string name="widget_empty_space_do_nothing">Do nothing</string>
<string name="widget_empty_space_open_list">Open list</string>

@ -10,25 +10,58 @@
android:key="@string/p_widget_theme"
android:title="@string/theme" />
<PreferenceCategory android:title="@string/widget_header_settings">
<SwitchPreferenceCompat
android:key="@string/p_widget_show_header"
android:title="@string/widget_show_header" />
<PreferenceCategory
app:key="@string/preferences_advanced"
app:title="@string/opacity"
app:initialExpandedChildrenCount="1">
<Preference
android:key="@string/p_widget_color_v2"
android:title="@string/color" />
<SeekBarPreference
android:defaultValue="100"
android:key="@string/opacity"
android:max="100"
app:min="0"
app:seekBarIncrement="5"
app:showSeekBarValue="true" />
<SeekBarPreference
android:defaultValue="100"
android:key="@string/p_widget_header_opacity"
android:max="100"
android:title="@string/opacity"
android:title="@string/opacity_header"
app:min="0"
app:seekBarIncrement="5"
app:showSeekBarValue="true" />
<SeekBarPreference
android:defaultValue="100"
android:key="@string/p_widget_opacity"
android:max="100"
android:title="@string/opacity_row"
app:min="0"
app:seekBarIncrement="5"
app:showSeekBarValue="true" />
<SeekBarPreference
android:defaultValue="100"
android:key="@string/p_widget_empty_space_opacity"
android:max="100"
android:title="@string/opacity_footer"
app:min="0"
app:seekBarIncrement="5"
app:showSeekBarValue="true" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/widget_header_settings">
<SwitchPreferenceCompat
android:key="@string/p_widget_show_header"
android:title="@string/widget_show_header" />
<Preference
android:key="@string/p_widget_color_v2"
android:title="@string/color" />
<SwitchPreferenceCompat
android:key="@string/p_widget_show_menu"
android:title="@string/widget_show_menu" />
@ -41,15 +74,6 @@
<PreferenceCategory android:title="@string/widget_row_settings">
<SeekBarPreference
android:defaultValue="100"
android:key="@string/p_widget_opacity"
android:max="100"
android:title="@string/opacity"
app:min="0"
app:seekBarIncrement="5"
app:showSeekBarValue="true" />
<SeekBarPreference
android:defaultValue="16"
android:key="@string/p_widget_font_size"
@ -96,16 +120,7 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/widget_empty_space">
<SeekBarPreference
android:defaultValue="100"
android:key="@string/p_widget_empty_space_opacity"
android:max="100"
android:title="@string/opacity"
app:min="0"
app:seekBarIncrement="5"
app:showSeekBarValue="true" />
<PreferenceCategory android:title="@string/widget_footer_settings">
<ListPreference
android:defaultValue="0"

Loading…
Cancel
Save