Remove custom order synchronization fix preference

Automatically perform full sync if manual sort was active during any
sync in the past seven days
pull/1296/head
Alex Baker 3 years ago
parent 14919d9f81
commit 22b72f0f1b

@ -17,7 +17,7 @@ class SyncGoogleTasksWork @WorkerInject constructor(
@Assisted workerParams: WorkerParameters,
firebase: Firebase,
localBroadcastManager: LocalBroadcastManager,
preferences: Preferences,
private val preferences: Preferences,
private val googleTaskListDao: GoogleTaskListDao,
private val googleTaskSynchronizer: GoogleTaskSynchronizer
) : SyncWork(context, workerParams, firebase, localBroadcastManager, preferences) {
@ -27,6 +27,9 @@ class SyncGoogleTasksWork @WorkerInject constructor(
override val syncStatus = R.string.p_sync_ongoing_google_tasks
override suspend fun doSync() {
if (preferences.isManualSort) {
preferences.isPositionHackEnabled = true
}
googleTaskJobs().awaitAll()
}

@ -12,6 +12,8 @@ import android.os.Binder
import androidx.core.app.NotificationCompat
import androidx.documentfile.provider.DocumentFile
import androidx.preference.PreferenceManager
import com.todoroo.andlib.utility.DateUtilities
import com.todoroo.andlib.utility.DateUtilities.now
import com.todoroo.astrid.activity.BeastModePreferences
import com.todoroo.astrid.api.AstridApiConstants
import com.todoroo.astrid.core.SortHelper
@ -432,8 +434,9 @@ class Preferences @JvmOverloads constructor(
val isFlipperEnabled: Boolean
get() = BuildConfig.DEBUG && getBoolean(R.string.p_flipper, false)
val isPositionHackEnabled: Boolean
get() = getLong(R.string.p_google_tasks_position_hack, 0) > 0
var isPositionHackEnabled: Boolean
get() = getLong(R.string.p_google_tasks_position_hack, 0) > now() - DateUtilities.ONE_WEEK
set(value) { setLong(R.string.p_google_tasks_position_hack, if (value) now() else 0) }
override var isManualSort: Boolean
get() = getBoolean(R.string.p_manual_sort, false)

@ -5,8 +5,6 @@ import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.SwitchPreferenceCompat
import com.todoroo.andlib.utility.DateUtilities
import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity
import com.todoroo.astrid.service.TaskDeleter
import dagger.hilt.android.AndroidEntryPoint
@ -63,22 +61,6 @@ class Synchronization : InjectingPreferenceFragment() {
true
}
val positionHack =
findPreference(R.string.google_tasks_position_hack) as SwitchPreferenceCompat
positionHack.isChecked = preferences.isPositionHackEnabled
positionHack.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any? ->
if (newValue == null) {
false
} else {
preferences.setLong(
R.string.p_google_tasks_position_hack,
if (newValue as Boolean) DateUtilities.now() else 0
)
true
}
}
findPreference(R.string.add_account)
.setOnPreferenceClickListener {
newAccountDialog(this@Synchronization, REQUEST_ADD_ACCOUNT)
@ -204,7 +186,6 @@ class Synchronization : InjectingPreferenceFragment() {
synchronizationPreferences.removeAll()
val hasGoogleAccounts: Boolean = addGoogleTasksAccounts(synchronizationPreferences)
val hasCaldavAccounts = addCaldavAccounts(synchronizationPreferences)
findPreference(R.string.gtasks_GPr_header).isVisible = hasGoogleAccounts
val syncEnabled = hasGoogleAccounts || hasCaldavAccounts
findPreference(R.string.accounts).isVisible = syncEnabled
findPreference(R.string.sync_SPr_interval_title).isVisible = syncEnabled

@ -405,8 +405,6 @@
<string name="preference_screen">preference_screen</string>
<string name="p_add_to_top">google_tasks_add_to_top</string>
<string name="p_google_tasks_position_hack">google_tasks_position_hack</string>
<string name="google_tasks_position_hack">Custom order synchronization fix</string>
<string name="google_tasks_position_hack_summary">Always perform a full synchronization to workaround https://issuetracker.google.com/issues/132432317</string>
<string name="subscription_help_url">https://tasks.org/subscribe</string>
<string name="p_use_paged_queries">disable_subtasks</string>
<string name="p_disable_sort_groups">disable_sort_groups</string>

@ -13,18 +13,6 @@
android:title="@string/add_account"
app:icon="@drawable/ic_outline_add_24px" />
<PreferenceCategory
android:key="@string/gtasks_GPr_header"
android:title="@string/gtasks_GPr_header"
app:isPreferenceVisible="false">
<SwitchPreferenceCompat
android:key="@string/google_tasks_position_hack"
android:summary="@string/google_tasks_position_hack_summary"
android:title="@string/google_tasks_position_hack" />
</PreferenceCategory>
<PreferenceCategory
android:key="@string/sync_SPr_interval_title"
android:title="@string/sync_SPr_interval_title"

Loading…
Cancel
Save