1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 17:02:13 +01:00

Only sync time on time/timezone changes if appropriate option is set.

This commit is contained in:
Andreas Shimokawa 2015-05-10 11:21:16 +02:00
parent f9efa36322
commit e78c912be3
3 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,8 @@ package nodomain.freeyourgadget.gadgetbridge.externalevents;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import nodomain.freeyourgadget.gadgetbridge.BluetoothCommunicationService; import nodomain.freeyourgadget.gadgetbridge.BluetoothCommunicationService;
@ -14,9 +16,10 @@ public class TimeChangeReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
final String action = intent.getAction(); final String action = intent.getAction();
if (action.equals(Intent.ACTION_TIME_CHANGED) || action.equals(Intent.ACTION_TIMEZONE_CHANGED)) { if (sharedPrefs.getBoolean("datetime_synconconnect", true) && (action.equals(Intent.ACTION_TIME_CHANGED) || action.equals(Intent.ACTION_TIMEZONE_CHANGED))) {
Log.i(TAG, "Time or Timezone changed, syncing with device"); Log.i(TAG, "Time or Timezone changed, syncing with device");
Intent startIntent = new Intent(context, BluetoothCommunicationService.class); Intent startIntent = new Intent(context, BluetoothCommunicationService.class);
startIntent.setAction(BluetoothCommunicationService.ACTION_SETTIME); startIntent.setAction(BluetoothCommunicationService.ACTION_SETTIME);

View File

@ -17,7 +17,8 @@
<string name="pref_header_general">Allgemeine Einstellungen</string> <string name="pref_header_general">Allgemeine Einstellungen</string>
<string name="pref_title_general_autoconnectonbluetooth">Verbinde, wenn Bluetooth eingeschaltet wird</string> <string name="pref_title_general_autoconnectonbluetooth">Verbinde, wenn Bluetooth eingeschaltet wird</string>
<string name="pref_header_datetime">Datum und Zeit</string> <string name="pref_header_datetime">Datum und Zeit</string>
<string name="pref_title_datetime_syctimeonconnect">Synchronisiere die Uhrzeit nach dem Verbindungsaufbau</string> <string name="pref_title_datetime_syctimeonconnect">Uhrzeit synchronisieren</string>
<string name="pref_summary_datetime_syctimeonconnect">Synchronisiere die Urzeit mit dem Gerät (bei Verbindingsaufbau und wenn die Zeit oder Zeitzone auf dem Android Gerät eingestellt wird)</string>
<string name="pref_header_notifications">Benachrichtigungen</string> <string name="pref_header_notifications">Benachrichtigungen</string>
<string name="pref_title_notifications_sms">SMS</string> <string name="pref_title_notifications_sms">SMS</string>
<string name="pref_title_notifications_k9mail">K9-Mail</string> <string name="pref_title_notifications_k9mail">K9-Mail</string>

View File

@ -24,7 +24,8 @@
<string name="pref_title_general_autoconnectonbluetooth">Connect to device when Bluetooth turned on</string> <string name="pref_title_general_autoconnectonbluetooth">Connect to device when Bluetooth turned on</string>
<string name="pref_header_datetime">Date and Time</string> <string name="pref_header_datetime">Date and Time</string>
<string name="pref_title_datetime_syctimeonconnect">Sync time when connecting</string> <string name="pref_title_datetime_syctimeonconnect">Sync time</string>
<string name="pref_summary_datetime_syctimeonconnect">Sync time to device when connecting and when time or timezone changes on Android</string>
<string name="pref_header_notifications">Notifications</string> <string name="pref_header_notifications">Notifications</string>
<string name="pref_title_notifications_sms">SMS</string> <string name="pref_title_notifications_sms">SMS</string>