More logging for time/timezone changes
(trying to find an explanation for #91)
This commit is contained in:
parent
05ee6e46c6
commit
69b64ed4b6
|
@ -9,7 +9,11 @@ import android.preference.PreferenceManager;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
|
||||
|
||||
public class TimeChangeReceiver extends BroadcastReceiver {
|
||||
|
@ -22,7 +26,8 @@ public class TimeChangeReceiver extends BroadcastReceiver {
|
|||
final String action = intent.getAction();
|
||||
|
||||
if (sharedPrefs.getBoolean("datetime_synconconnect", true) && (action.equals(Intent.ACTION_TIME_CHANGED) || action.equals(Intent.ACTION_TIMEZONE_CHANGED))) {
|
||||
LOG.info("Time or Timezone changed, syncing with device");
|
||||
Date newTime = GregorianCalendar.getInstance().getTime();
|
||||
LOG.info("Time or Timezone changed, syncing with device: " + DateTimeUtils.formatDate(newTime) + " (" + newTime.toGMTString() + "), " + intent.getAction());
|
||||
GBApplication.deviceService().onSetTime();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@ package nodomain.freeyourgadget.gadgetbridge.service.btle;
|
|||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
|
||||
/**
|
||||
* The Bluedroid implementation only allows performing one GATT request at a time.
|
||||
* As they are asynchronous anyway, we encapsulate every GATT request (read and write)
|
||||
|
@ -50,7 +51,7 @@ public abstract class BtLEAction {
|
|||
}
|
||||
|
||||
protected String getCreationTime() {
|
||||
return DateFormat.getTimeInstance().format(new Date(creationTimestamp));
|
||||
return DateTimeUtils.formatDateTime(new Date(creationTimestamp));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
@ -12,6 +12,10 @@ import java.util.concurrent.TimeUnit;
|
|||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
|
||||
public class DateTimeUtils {
|
||||
public static String formatDateTime(Date date) {
|
||||
return DateUtils.formatDateTime(GBApplication.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
|
||||
}
|
||||
|
||||
public static String formatDate(Date date) {
|
||||
return DateUtils.formatDateTime(GBApplication.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_DATE);
|
||||
// long dateMillis = date.getTime();
|
||||
|
|
Loading…
Reference in New Issue