diff --git a/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt b/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt index f221f33c0..4dfac57e6 100644 --- a/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt +++ b/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt @@ -24,35 +24,32 @@ class DefaultFilterProvider @Inject constructor( private val locationDao: LocationDao, private val googleTaskDao: GoogleTaskDao) { - @Deprecated("use coroutines") var dashclockFilter: Filter - get() = runBlocking { getFilterFromPreference(R.string.p_dashclock_filter) } + @Deprecated("use coroutines") get() = runBlocking { getFilterFromPreference(R.string.p_dashclock_filter) } set(filter) = setFilterPreference(filter, R.string.p_dashclock_filter) - @Deprecated("use coroutines") var badgeFilter: Filter - get() = runBlocking { getFilterFromPreference(R.string.p_badge_list) } + @Deprecated("use coroutines") get() = runBlocking { getBadgeFilter() } set(filter) = setFilterPreference(filter, R.string.p_badge_list) - @Deprecated("use coroutines") var defaultOpenFilter: Filter - get() = runBlocking { getDefaultOpenFilter() } + @Deprecated("use coroutines") get() = runBlocking { getDefaultOpenFilter() } set(filter) = setFilterPreference(filter, R.string.p_default_open_filter) - @Deprecated("use coroutines") var lastViewedFilter: Filter - get() = runBlocking { getFilterFromPreference(R.string.p_last_viewed_list) } + @Deprecated("use coroutines") get() = runBlocking { getFilterFromPreference(R.string.p_last_viewed_list) } set(filter) = setFilterPreference(filter, R.string.p_last_viewed_list) - @Deprecated("use coroutines") var defaultList: Filter - get() = runBlocking { getDefaultList() } + @Deprecated("use coroutines") get() = runBlocking { getDefaultList() } set(filter) = setFilterPreference(filter, R.string.p_default_list) @Deprecated("use coroutines") val startupFilter: Filter get() = runBlocking { getStartupFilter() } + suspend fun getBadgeFilter() = getFilterFromPreference(R.string.p_badge_list) + suspend fun getDefaultList() = getFilterFromPreference(preferences.getStringValue(R.string.p_default_list), null) ?: getAnyList() diff --git a/app/src/main/java/org/tasks/preferences/fragments/Notifications.kt b/app/src/main/java/org/tasks/preferences/fragments/Notifications.kt index a100884a5..30e9aa34a 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/Notifications.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/Notifications.kt @@ -9,12 +9,14 @@ import android.os.Bundle import android.os.PowerManager import android.provider.Settings import android.speech.tts.TextToSpeech +import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import androidx.preference.SwitchPreferenceCompat import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.astrid.api.Filter import com.todoroo.astrid.voice.VoiceOutputAssistant import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.launch import org.tasks.LocalBroadcastManager import org.tasks.R import org.tasks.activities.FilterSelectionActivity @@ -76,15 +78,17 @@ class Notifications : InjectingPreferenceFragment() { } val badgePreference: Preference = findPreference(R.string.p_badge_list) - val filter = defaultFilterProvider.badgeFilter + val filter = defaultFilterProvider.getBadgeFilter() badgePreference.summary = filter.listingTitle badgePreference.onPreferenceClickListener = Preference.OnPreferenceClickListener { - val intent = Intent(context, FilterSelectionActivity::class.java) - intent.putExtra( - FilterSelectionActivity.EXTRA_FILTER, defaultFilterProvider.badgeFilter - ) - intent.putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true) - startActivityForResult(intent, REQUEST_BADGE_LIST) + lifecycleScope.launch { + val intent = Intent(context, FilterSelectionActivity::class.java) + intent.putExtra( + FilterSelectionActivity.EXTRA_FILTER, defaultFilterProvider.getBadgeFilter() + ) + intent.putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true) + startActivityForResult(intent, REQUEST_BADGE_LIST) + } true }