Use coroutines in notification preferences

pull/1051/head
Alex Baker 4 years ago
parent 9b4ccd5137
commit 5879774905

@ -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()

@ -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 {
lifecycleScope.launch {
val intent = Intent(context, FilterSelectionActivity::class.java)
intent.putExtra(
FilterSelectionActivity.EXTRA_FILTER, defaultFilterProvider.badgeFilter
FilterSelectionActivity.EXTRA_FILTER, defaultFilterProvider.getBadgeFilter()
)
intent.putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true)
startActivityForResult(intent, REQUEST_BADGE_LIST)
}
true
}

Loading…
Cancel
Save