Merge remote-tracking branch 'origin/sync-part-final' into feat/add-sync-triggers-experimental

This commit is contained in:
KaiserBh 2024-01-12 02:29:30 +11:00
commit 9593e726c6
3 changed files with 25 additions and 2 deletions

View File

@ -63,6 +63,7 @@ import tachiyomi.core.util.lang.launchNonCancellable
import tachiyomi.core.util.lang.withUIContext import tachiyomi.core.util.lang.withUIContext
import tachiyomi.core.util.system.logcat import tachiyomi.core.util.system.logcat
import tachiyomi.domain.manga.interactor.ResetViewerFlags import tachiyomi.domain.manga.interactor.ResetViewerFlags
import tachiyomi.domain.sync.SyncPreferences
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.util.collectAsState import tachiyomi.presentation.core.util.collectAsState
@ -142,6 +143,7 @@ object SettingsAdvancedScreen : SearchableSettings {
getNetworkGroup(networkPreferences = networkPreferences), getNetworkGroup(networkPreferences = networkPreferences),
getLibraryGroup(), getLibraryGroup(),
getExtensionsGroup(basePreferences = basePreferences), getExtensionsGroup(basePreferences = basePreferences),
getSyncGroup(),
), ),
) )
} }
@ -404,4 +406,23 @@ object SettingsAdvancedScreen : SearchableSettings {
), ),
) )
} }
@Composable
private fun getSyncGroup(): Preference.PreferenceGroup {
val context = LocalContext.current
val syncPreferences = remember { Injekt.get<SyncPreferences>() }
return Preference.PreferenceGroup(
title = stringResource(MR.strings.label_sync),
preferenceItems = persistentListOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_reset_sync_timestamp),
subtitle = stringResource(MR.strings.pref_reset_sync_timestamp_subtitle),
onClick = {
syncPreferences.lastSyncTimestamp().set(0)
context.toast(MR.strings.success_reset_sync_timestamp)
},
),
),
)
}
} }

View File

@ -151,14 +151,13 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync
} }
override suspend fun pushSyncData(syncData: SyncData) { override suspend fun pushSyncData(syncData: SyncData) {
val jsonData = json.encodeToString(syncData)
val drive = googleDriveService.driveService val drive = googleDriveService.driveService
?: throw Exception(context.stringResource(MR.strings.google_drive_not_signed_in)) ?: throw Exception(context.stringResource(MR.strings.google_drive_not_signed_in))
val fileList = getAppDataFileList(drive) val fileList = getAppDataFileList(drive)
val byteArrayOutputStream = ByteArrayOutputStream() val byteArrayOutputStream = ByteArrayOutputStream()
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
val jsonData = json.encodeToString(syncData)
val gzipOutputStream = GZIPOutputStream(byteArrayOutputStream) val gzipOutputStream = GZIPOutputStream(byteArrayOutputStream)
gzipOutputStream.write(jsonData.toByteArray(Charsets.UTF_8)) gzipOutputStream.write(jsonData.toByteArray(Charsets.UTF_8))
gzipOutputStream.close() gzipOutputStream.close()

View File

@ -561,6 +561,9 @@
<string name="pref_sync_service_category">Sync</string> <string name="pref_sync_service_category">Sync</string>
<string name="pref_sync_automatic_category">Automatic Synchronization</string> <string name="pref_sync_automatic_category">Automatic Synchronization</string>
<string name="pref_sync_interval">Synchronization frequency</string> <string name="pref_sync_interval">Synchronization frequency</string>
<string name="pref_reset_sync_timestamp">Reset last sync timestamp</string>
<string name="pref_reset_sync_timestamp_subtitle">Reset the last sync timestamp to force a full sync</string>
<string name="success_reset_sync_timestamp">Last sync timestamp reset</string>
<string name="syncyomi">SyncYomi</string> <string name="syncyomi">SyncYomi</string>
<string name="sync_completed_message">Done in %1$s</string> <string name="sync_completed_message">Done in %1$s</string>
<string name="last_synchronization">Last Synchronization: %1$s</string> <string name="last_synchronization">Last Synchronization: %1$s</string>