do not allow enabling google sync while offline

This commit is contained in:
tibbi 2017-07-23 19:02:16 +02:00
parent d7dde0517c
commit eea1ab8261
17 changed files with 27 additions and 2 deletions

View File

@ -121,9 +121,13 @@ class SettingsActivity : SimpleActivity() {
toggleGoogleSync()
}
} else {
if (isOnline()) {
ConfirmationDialog(this, getString(R.string.google_sync_testing), positive = R.string.ok, negative = 0) {
toggleGoogleSync()
}
} else {
toast(R.string.cannot_while_offline)
}
}
}
}

View File

@ -10,6 +10,7 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.ConnectivityManager
import android.net.Uri
import android.os.Build
import android.support.v7.app.NotificationCompat
@ -239,6 +240,11 @@ fun Context.getGoogleSyncService(): com.google.api.services.calendar.Calendar {
.build()
}
fun Context.isOnline(): Boolean {
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
return connectivityManager.activeNetworkInfo != null
}
fun Context.getNewEventTimestampFromCode(dayCode: String) = Formatter.getLocalDateTimeFromCode(dayCode).withTime(13, 0, 0, 0).seconds()
fun Context.getCurrentOffset() = SimpleDateFormat("Z", Locale.getDefault()).format(Date())

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Mostrar eventos passados</string>
<string name="snooze_delay">Adiar lembrete com a opção Snooze</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">A sincronização Google ainda não está terminada. Reporte os erros encontrados para hello@simplemobiletools.com. Obrigado!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -203,6 +203,7 @@
<string name="display_past_events">Показывать прошедшие события</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -196,6 +196,7 @@
<string name="display_past_events">Zobraziť minulé udalosti spred</string>
<string name="snooze_delay">Posunúť pripomienku s Odložiť o</string>
<string name="widgets">Widgety</string>
<string name="cannot_while_offline">Nemôžete to urobiť bez internetu.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Odoslať lokálne vytvorené udalosti do oblakov?</string>
<string name="google_sync_disabling">Vypnutie Google synchonizácie odstráni všetky synchronizované udalosti zo zariadenia, no v oblakoch ostanú nedotknuté.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Visa tidigare händelser</string>
<string name="snooze_delay">Skjut upp påminnelse med Snooza</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>

View File

@ -189,6 +189,7 @@
<string name="display_past_events">Display events from the past</string>
<string name="snooze_delay">Postpone reminder with Snooze by</string>
<string name="widgets">Widgets</string>
<string name="cannot_while_offline">You cannot do that while offline.</string>
<string name="google_sync_testing">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!</string>
<string name="google_sync_existing">Send locally created events to the cloud?</string>
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>