1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-24 01:25:50 +01:00

Fix for DST (summer time), option to sync time on connect (enabled by default)

This commit is contained in:
Andreas Shimokawa 2015-03-29 17:12:06 +02:00
parent 4117444c26
commit d9a2d85f6d
8 changed files with 38 additions and 16 deletions

View File

@ -1,5 +1,11 @@
###Changelog
####Version 0.1.5
* Fix for DST (summer time)
* Option to sync time on connect (enabled by default)
* Opening .pbw files with Gadgetbridge prints some package information
(Tbis was not meant to be released yet, but the DST fix made a new release neccessary)
####Version 0.1.4
* New AppManager shows installed Apps/Watchfaces (removal possible via context menu)
* Allow back navigation in ActionBar (Debug and AppMananger Activities)

View File

@ -396,6 +396,7 @@ public class BluetoothCommunicationService extends Service {
gbdevice.setState(GBDevice.State.CONNECTED);
sendDeviceUpdateIntent();
updateNotification("connected to " + btDevice.getName());
return true;
}
@ -441,6 +442,13 @@ public class BluetoothCommunicationService extends Service {
Log.i(TAG, "Pebble asked for Phone/App Version - repLYING!");
write(PebbleProtocol.encodePhoneVersion(PebbleProtocol.PHONEVERSION_REMOTE_OS_ANDROID));
write(PebbleProtocol.encodeFirmwareVersionReq());
// this does not really belong here, but since the pebble only asks for our version once it should do the job
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(BluetoothCommunicationService.this);
if (sharedPrefs.getBoolean("datetime_synconconnect", true)) {
Log.i(TAG, "syncing time");
write(PebbleProtocol.encodeSetTime(-1));
}
} else if (endpoint != PebbleProtocol.ENDPOINT_DATALOG) {
GBDeviceCommand deviceCmd = PebbleProtocol.decodeResponse(buffer);
if (deviceCmd == null) {

View File

@ -22,6 +22,12 @@ public class SettingsActivity extends PreferenceActivity {
// Add 'general' preferences.
addPreferencesFromResource(R.xml.pref_general);
// Add 'date' preferences, and a corresponding header.
PreferenceCategory fakeHeaderDateTime = new PreferenceCategory(this);
fakeHeaderDateTime.setTitle(R.string.pref_header_datetime);
getPreferenceScreen().addPreference(fakeHeaderDateTime);
addPreferencesFromResource(R.xml.pref_datetime);
// Add 'notifications' preferences, and a corresponding header.
PreferenceCategory fakeHeader = new PreferenceCategory(this);
fakeHeader.setTitle(R.string.pref_header_notifications);

View File

@ -5,6 +5,7 @@ import android.util.Log;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import nodomain.freeyourgadget.gadgetbridge.GBCommand;
import nodomain.freeyourgadget.gadgetbridge.GBDeviceApp;
@ -149,7 +150,8 @@ public class PebbleProtocol {
public static byte[] encodeSMS(String from, String body) {
Long ts = System.currentTimeMillis() / 1000;
ts += SimpleTimeZone.getDefault().getOffset(ts) / 1000;
TimeZone tz = SimpleTimeZone.getDefault();
ts += (tz.getOffset(ts) + tz.getDSTSavings()) / 1000;
String tsstring = ts.toString(); // SIC
String[] parts = {from, body, tsstring};
@ -158,7 +160,8 @@ public class PebbleProtocol {
public static byte[] encodeEmail(String from, String subject, String body) {
Long ts = System.currentTimeMillis() / 1000;
ts += SimpleTimeZone.getDefault().getOffset(ts) / 1000;
TimeZone tz = SimpleTimeZone.getDefault();
ts += (tz.getOffset(ts) + tz.getDSTSavings()) / 1000;
String tsstring = ts.toString(); // SIC
String[] parts = {from, body, tsstring, subject};
@ -168,7 +171,8 @@ public class PebbleProtocol {
public static byte[] encodeSetTime(long ts) {
if (ts == -1) {
ts = System.currentTimeMillis() / 1000;
ts += SimpleTimeZone.getDefault().getOffset(ts) / 1000;
TimeZone tz = SimpleTimeZone.getDefault();
ts += (tz.getOffset(ts) + tz.getDSTSavings()) / 1000;
}
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_SETTIME);
buf.order(ByteOrder.BIG_ENDIAN);

View File

@ -19,8 +19,13 @@
<!-- Strings related to Settings -->
<string name="title_activity_settings">Settings</string>
<string name="pref_header_general">General Settings</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_title_datetime_syctimeonconnect">Sync time when connecting</string>
<string name="pref_header_notifications">Notifications</string>
<string name="pref_title_notifications_sms">Notification for SMS</string>
<string name="pref_title_notifications_k9mail">Notification for K9-Mail</string>

View File

@ -0,0 +1,6 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:defaultValue="true"
android:key="datetime_synconconnect"
android:title="@string/pref_title_datetime_syctimeonconnect" />
</PreferenceScreen>

View File

@ -3,5 +3,4 @@
android:defaultValue="false"
android:key="general_autoconnectonbluetooth"
android:title="@string/pref_title_general_autoconnectonbluetooth" />
</PreferenceScreen>

View File

@ -1,12 +0,0 @@
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
<!-- These settings headers are only used on tablets. -->
<header android:fragment="nodomain.freeyourgadget.gadgetbridge.SettingsActivity$GeneralPreferenceFragment"
android:title="@string/pref_header_general" />
<header
android:fragment="nodomain.freeyourgadget.gadgetbridge.SettingsActivity$NotificationPreferenceFragment"
android:title="@string/pref_header_notifications" />
</preference-headers>