Replace hasTasksSubscription with hasTasksAccount

pull/1419/head
Alex Baker 4 years ago
parent 7f3c1f1756
commit 83bee2a59e

@ -76,7 +76,7 @@ class Tasks : Application(), Configuration.Provider {
}
private fun backgroundWork() = CoroutineScope(Dispatchers.Default).launch {
inventory.updateTasksSubscription()
inventory.updateTasksAccount()
NotificationSchedulerIntentService.enqueueWork(context, false)
CalendarNotificationIntentService.enqueueWork(context)
refreshScheduler.get().scheduleAll()

@ -28,7 +28,7 @@ class Inventory @Inject constructor(
private val purchases: MutableMap<String, Purchase> = HashMap()
val subscription = MutableLiveData<Purchase?>()
var hasTasksSubscription = false
var hasTasksAccount = false
private set
fun clear() {
@ -62,16 +62,15 @@ class Inventory @Inject constructor(
get() {
return BuildConfig.FLAVOR == "generic"
|| (BuildConfig.DEBUG && preferences.getBoolean(R.string.p_debug_pro, false))
|| hasTasksSubscription
|| hasTasksAccount
|| field
}
private set
suspend fun updateTasksSubscription() {
hasTasksSubscription =
subscription.value?.isTasksSubscription == true || caldavDao.getAccounts(TYPE_TASKS).any {
it.isTasksSubscription(context)
}
suspend fun updateTasksAccount() {
hasTasksAccount = caldavDao.getAccounts(TYPE_TASKS).any {
it.isTasksSubscription(context)
}
}
fun purchased(sku: String) = purchases.containsKey(sku)

@ -63,12 +63,15 @@ class PurchaseDialog : DialogFragment(), OnPurchasesUpdated {
private var priceChanged = false
private var nameYourPrice = false
private val hasTasksSubscription
get() = inventory.subscription.value?.isTasksSubscription == true
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
binding = ActivityPurchaseBinding.inflate(layoutInflater)
ButterKnife.bind(this, binding.root)
if (savedInstanceState == null) {
nameYourPrice = !isTasksPayment && !inventory.hasTasksSubscription
nameYourPrice = !isTasksPayment && !hasTasksSubscription
} else {
binding.slider.value = savedInstanceState.getFloat(EXTRA_PRICE)
priceChanged = savedInstanceState.getBoolean(EXTRA_PRICE_CHANGED)
@ -124,7 +127,7 @@ class PurchaseDialog : DialogFragment(), OnPurchasesUpdated {
var benefits = "### ${getString(when {
nameYourPrice -> R.string.name_your_price
!inventory.hasPro -> R.string.upgrade_to_pro
!inventory.hasTasksSubscription -> R.string.button_upgrade
!hasTasksSubscription -> R.string.button_upgrade
else -> R.string.manage_subscription
})}"
benefits += if (nameYourPrice) {

@ -178,7 +178,7 @@ class FilterProvider @Inject constructor(
private val navDrawerFooter: List<FilterListItem>
get() = listOf(NavigationDrawerSeparator())
.plusIf(BuildConfig.FLAVOR == "generic" && !inventory.hasTasksSubscription) {
.plusIf(BuildConfig.FLAVOR == "generic" && !inventory.hasTasksAccount) {
NavigationDrawerAction(
context.getString(R.string.TLA_menu_donate),
R.drawable.ic_outline_attach_money_24px,

@ -20,5 +20,5 @@ class ViewModelModule {
inventory: Inventory,
google: Lazy<PlaceSearchGoogle>,
mapbox: Lazy<PlaceSearchMapbox>
): PlaceSearch = if (inventory.hasTasksSubscription) google.get() else mapbox.get()
): PlaceSearch = if (inventory.hasTasksAccount) google.get() else mapbox.get()
}

@ -34,7 +34,7 @@ class SyncCaldavWork @AssistedInject constructor(
override suspend fun doSync() {
caldavJobs().awaitAll()
inventory.updateTasksSubscription()
inventory.updateTasksAccount()
}
private suspend fun caldavJobs(): List<Deferred<Unit>> = coroutineScope {

@ -96,7 +96,7 @@ class TasksAccount : BaseAccountPreference() {
override suspend fun removeAccount() {
// try to delete session from caldav.tasks.org
taskDeleter.delete(caldavAccount)
inventory.updateTasksSubscription()
inventory.updateTasksAccount()
}
override fun onResume() {

Loading…
Cancel
Save