mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 04:46:51 +01:00
Send current time to device if time/timezone changes. Closes #51.
This commit is contained in:
parent
70889e5326
commit
157deff237
@ -102,6 +102,13 @@
|
|||||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
<receiver android:name=".externalevents.TimeChangeReceiver"
|
||||||
|
android:enabled="false" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
||||||
|
<action android:name="android.intent.action.TIME_SET" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".externalevents.K9Receiver"
|
android:name=".externalevents.K9Receiver"
|
||||||
android:enabled="false" >
|
android:enabled="false" >
|
||||||
|
@ -16,6 +16,7 @@ import nodomain.freeyourgadget.gadgetbridge.externalevents.MusicPlaybackReceiver
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.PebbleReceiver;
|
import nodomain.freeyourgadget.gadgetbridge.externalevents.PebbleReceiver;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.PhoneCallReceiver;
|
import nodomain.freeyourgadget.gadgetbridge.externalevents.PhoneCallReceiver;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.SMSReceiver;
|
import nodomain.freeyourgadget.gadgetbridge.externalevents.SMSReceiver;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.externalevents.TimeChangeReceiver;
|
||||||
|
|
||||||
public class GB {
|
public class GB {
|
||||||
public static final int NOTIFICATION_ID = 1;
|
public static final int NOTIFICATION_ID = 1;
|
||||||
@ -54,6 +55,7 @@ public class GB {
|
|||||||
K9Receiver.class,
|
K9Receiver.class,
|
||||||
PebbleReceiver.class,
|
PebbleReceiver.class,
|
||||||
MusicPlaybackReceiver.class,
|
MusicPlaybackReceiver.class,
|
||||||
|
TimeChangeReceiver.class,
|
||||||
//NotificationListener.class, // disabling this leads to loss of permission to read notifications
|
//NotificationListener.class, // disabling this leads to loss of permission to read notifications
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package nodomain.freeyourgadget.gadgetbridge.externalevents;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.BluetoothCommunicationService;
|
||||||
|
|
||||||
|
|
||||||
|
public class TimeChangeReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
final String action = intent.getAction();
|
||||||
|
|
||||||
|
if (action.equals(Intent.ACTION_TIME_CHANGED) || action.equals(Intent.ACTION_TIMEZONE_CHANGED)) {
|
||||||
|
Log.i(TAG, "Time or Timezone changed, syncing with device");
|
||||||
|
Intent startIntent = new Intent(context, BluetoothCommunicationService.class);
|
||||||
|
startIntent.setAction(BluetoothCommunicationService.ACTION_SETTIME);
|
||||||
|
context.startService(startIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user