From d1dd1f0142206803dbf0603719bc88a75cc2ba37 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 28 Jul 2017 23:28:45 +0200 Subject: [PATCH] offer uploading local events to Google at activating sync --- .../calendar/activities/SettingsActivity.kt | 22 +++++++++++++++++-- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values-hi-rIN/strings.xml | 2 +- app/src/main/res/values-hu/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-iw/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 2 +- app/src/main/res/values-pt-rBR/strings.xml | 2 +- app/src/main/res/values-pt/strings.xml | 2 +- app/src/main/res/values-ru/strings.xml | 2 +- app/src/main/res/values-sk/strings.xml | 2 +- app/src/main/res/values-sv/strings.xml | 2 +- app/src/main/res/values-tr/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 16 files changed, 35 insertions(+), 17 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt index 3bab04aef..4428d3588 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt @@ -26,6 +26,7 @@ import com.simplemobiletools.calendar.dialogs.SnoozePickerDialog import com.simplemobiletools.calendar.extensions.* import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.calendar.interfaces.GoogleSyncListener +import com.simplemobiletools.calendar.models.Event import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.toast @@ -357,10 +358,14 @@ class SettingsActivity : SimpleActivity() { getGoogleSyncService().colors().get().execute() // just checking if we have the permission for fetching user data storeCalendarData() config.googleSync = true + FetchGoogleEventsTask(applicationContext, googleSyncListener).execute() runOnUiThread { settings_google_sync.isChecked = true + val eventsToExport = dbHelper.getEventsToExport(true) + if (eventsToExport.isNotEmpty()) { + offerEventsUpload(eventsToExport) + } } - FetchGoogleEventsTask(applicationContext, googleSyncListener).execute() } catch (e: Exception) { if (e is UserRecoverableAuthIOException) { startActivityForResult(e.intent, REQUEST_AUTHORIZATION) @@ -396,12 +401,25 @@ class SettingsActivity : SimpleActivity() { config.googleDefaultReminders = reminderMinutes.joinToString(",") } - val googleSyncListener = object : GoogleSyncListener { + private val googleSyncListener = object : GoogleSyncListener { override fun syncCompleted() { toast(R.string.events_imported_successfully) } } + private fun offerEventsUpload(eventsToExport: ArrayList) { + ConfirmationDialog(this, messageId = R.string.google_sync_existing) { + Thread({ + eventsToExport.forEach { + try { + GoogleSyncHandler().tryInsertToGoogle(this, it) + } catch (e: Exception) { + } + } + }).start() + } + } + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index cc2833814..7ad59e703 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 6a508e3a1..d3aa2f16e 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index a0d2c63cc..aceab0c1a 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml index 456e837df..95f6a2eb6 100644 --- a/app/src/main/res/values-hi-rIN/strings.xml +++ b/app/src/main/res/values-hi-rIN/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index f080a820a..e5603e91e 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index fc73f5d3c..dd2da380b 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index 57b230c48..1451af920 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index fdd817ee5..2a4642146 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 51ec98b5c..4ef52300d 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 52c18a102..1c71c698f 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -194,7 +194,7 @@ A sincronização Google ainda não está terminada. Reporte os erros encontrados para hello@simplemobiletools.com. Obrigado! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index d1e4288eb..663565939 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -208,7 +208,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index e983ac9c5..b0e2feff3 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -201,7 +201,7 @@ Google synchronizácia je v testovacej prevádzke, buďte opatrní pri spoliehaní sa na ňu. Nahlásenie akýchkoľvek ohlasov na hello@simplemobiletools.com je vítané. Vďaka! - Odoslať lokálne vytvorené udalosti do oblakov? + Nahrať momentálne existujúce udalosti Googlu? Vypnutie Google synchonizácie odstráni všetky synchronizované udalosti zo zariadenia, no v oblakoch ostanú nedotknuté. Chyba pri nahrávaní udalosti na Google: %1$s Chyba pri úprave udalosti na Googli: %1$s diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index b84f01789..cef6bfd85 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index a77512436..9cbfe839f 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 891bd1885..829267764 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -194,7 +194,7 @@ Google sync is in a testing mode, please be cautions when relying on it. Reporting any feedback at hello@simplemobiletools.com would be appreciated. Thanks! - Send locally created events to the cloud? + Upload currently existing events to Google? Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud. Error uploading event to Google: %1$s Error updating event at Google: %1$s