mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-26 03:46:49 +01:00
First part: Add inactivity alert.
This commit is contained in:
parent
6be181047a
commit
828df4898f
@ -127,6 +127,18 @@ public class ZeTimeConstants {
|
|||||||
public static final String PREF_DO_NOT_DISTURB_START = "zetime_do_not_disturb_start";
|
public static final String PREF_DO_NOT_DISTURB_START = "zetime_do_not_disturb_start";
|
||||||
public static final String PREF_DO_NOT_DISTURB_END = "zetime_do_not_disturb_end";
|
public static final String PREF_DO_NOT_DISTURB_END = "zetime_do_not_disturb_end";
|
||||||
|
|
||||||
|
public static final String PREF_INACTIVITY_ENABLE = "zetime_inactivity_warnings";
|
||||||
|
public static final String PREF_INACTIVITY_START = "zetime_inactivity_warnings_start";
|
||||||
|
public static final String PREF_INACTIVITY_END = "zetime_inactivity_warnings_end";
|
||||||
|
public static final String PREF_INACTIVITY_THRESHOLD = "zetime_inactivity_warnings_threshold";
|
||||||
|
public static final String PREF_INACTIVITY_MO = "zetime_prefs_inactivity_repetitions_mo";
|
||||||
|
public static final String PREF_INACTIVITY_TU = "zetime_prefs_inactivity_repetitions_tu";
|
||||||
|
public static final String PREF_INACTIVITY_WE = "zetime_prefs_inactivity_repetitions_we";
|
||||||
|
public static final String PREF_INACTIVITY_TH = "zetime_prefs_inactivity_repetitions_th";
|
||||||
|
public static final String PREF_INACTIVITY_FR = "zetime_prefs_inactivity_repetitions_fr";
|
||||||
|
public static final String PREF_INACTIVITY_SA = "zetime_prefs_inactivity_repetitions_sa";
|
||||||
|
public static final String PREF_INACTIVITY_SU = "zetime_prefs_inactivity_repetitions_su";
|
||||||
|
|
||||||
public static final String PREF_ANALOG_MODE = "zetime_analog_mode";
|
public static final String PREF_ANALOG_MODE = "zetime_analog_mode";
|
||||||
public static final String PREF_ACTIVITY_TRACKING = "zetime_activity_tracking";
|
public static final String PREF_ACTIVITY_TRACKING = "zetime_activity_tracking";
|
||||||
public static final String PREF_HANDMOVE_DISPLAY = "zetime_handmove_display";
|
public static final String PREF_HANDMOVE_DISPLAY = "zetime_handmove_display";
|
||||||
|
@ -1614,4 +1614,50 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
sendMsgToWatch(builder, dateformat);
|
sendMsgToWatch(builder, dateformat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setInactivityAlert(TransactionBuilder builder)
|
||||||
|
{
|
||||||
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
|
boolean enabled = prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_ENABLE, false);
|
||||||
|
int threshold = prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD, 60);
|
||||||
|
|
||||||
|
if(threshold > 0xff)
|
||||||
|
{
|
||||||
|
threshold = 0xff;
|
||||||
|
GB.toast(getContext(), "Value for inactivity threshold is greater than 255min! ", Toast.LENGTH_LONG, GB.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] inactivity = {
|
||||||
|
ZeTimeConstants.CMD_PREAMBLE,
|
||||||
|
ZeTimeConstants.CMD_INACTIVITY_ALERT,
|
||||||
|
ZeTimeConstants.CMD_SEND,
|
||||||
|
(byte)0x8,
|
||||||
|
(byte)0x0,
|
||||||
|
(byte)0x0,
|
||||||
|
(byte)threshold,
|
||||||
|
(byte)0x0,
|
||||||
|
(byte)0x0,
|
||||||
|
(byte)0x0,
|
||||||
|
(byte)0x0,
|
||||||
|
(byte)0x64,
|
||||||
|
(byte)0x0,
|
||||||
|
ZeTimeConstants.CMD_END
|
||||||
|
};
|
||||||
|
|
||||||
|
if(enabled)
|
||||||
|
{
|
||||||
|
int reps = (1 << 7); // set inactivity active: set bit 7
|
||||||
|
reps |= prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_MO, 0);
|
||||||
|
reps |= (prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_TU, 0) << 1);
|
||||||
|
reps |= (prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_WE, 0) << 2);
|
||||||
|
reps |= (prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_TH, 0) << 3);
|
||||||
|
reps |= (prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_FR, 0) << 4);
|
||||||
|
reps |= (prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_SA, 0) << 5);
|
||||||
|
reps |= (prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_SU, 0) << 6);
|
||||||
|
|
||||||
|
inactivity[5] = (byte)reps;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMsgToWatch(builder, inactivity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,14 @@
|
|||||||
<string name="zetime_date_format_1">YY/MM/DD</string>
|
<string name="zetime_date_format_1">YY/MM/DD</string>
|
||||||
<string name="zetime_date_format_2">DD/MM/YY</string>
|
<string name="zetime_date_format_2">DD/MM/YY</string>
|
||||||
<string name="zetime_date_format_3">MM/DD/YY</string>
|
<string name="zetime_date_format_3">MM/DD/YY</string>
|
||||||
|
<string name="zetime_prefs_inactivity_repetitions">Repetitions</string>
|
||||||
|
<string name="zetime_prefs_inactivity_mo">Monday</string>
|
||||||
|
<string name="zetime_prefs_inactivity_tu">Tuesday</string>
|
||||||
|
<string name="zetime_prefs_inactivity_we">Wednesday</string>
|
||||||
|
<string name="zetime_prefs_inactivity_th">Thursday</string>
|
||||||
|
<string name="zetime_prefs_inactivity_fr">Friday</string>
|
||||||
|
<string name="zetime_prefs_inactivity_sa">Saturday</string>
|
||||||
|
<string name="zetime_prefs_inactivity_su">Sunday</string>
|
||||||
|
|
||||||
<!-- Auto export preferences -->
|
<!-- Auto export preferences -->
|
||||||
<string name="pref_header_auto_export">Auto export</string>
|
<string name="pref_header_auto_export">Auto export</string>
|
||||||
|
@ -24,6 +24,77 @@
|
|||||||
android:title="@string/zetime_activity_tracking"
|
android:title="@string/zetime_activity_tracking"
|
||||||
android:summary="@string/zetime_activity_tracking_summary" />
|
android:summary="@string/zetime_activity_tracking_summary" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="zetime_inactivity_warning_key"
|
||||||
|
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
|
||||||
|
android:title="@string/mi2_prefs_inactivity_warnings"
|
||||||
|
android:persistent="false">
|
||||||
|
|
||||||
|
<!-- workaround for missing toolbar -->
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/mi2_prefs_inactivity_warnings"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="zetime_inactivity_warnings"
|
||||||
|
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
|
||||||
|
android:title="@string/mi2_prefs_inactivity_warnings" />
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:defaultValue="60"
|
||||||
|
android:dependency="zetime_inactivity_warnings"
|
||||||
|
android:inputType="numberSigned"
|
||||||
|
android:key="zetime_inactivity_warnings_threshold"
|
||||||
|
android:maxLength="3"
|
||||||
|
android:title="@string/mi2_prefs_inactivity_warnings_threshold" />
|
||||||
|
|
||||||
|
<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
|
||||||
|
android:defaultValue="06:00"
|
||||||
|
android:dependency="zetime_inactivity_warnings"
|
||||||
|
android:key="zetime_inactivity_warnings_start"
|
||||||
|
android:title="@string/mi2_prefs_do_not_disturb_start" />
|
||||||
|
|
||||||
|
<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
|
||||||
|
android:defaultValue="22:00"
|
||||||
|
android:dependency="zetime_inactivity_warnings"
|
||||||
|
android:key="zetime_inactivity_warnings_end"
|
||||||
|
android:title="@string/mi2_prefs_do_not_disturb_end" />
|
||||||
|
|
||||||
|
<!-- workaround for missing toolbar -->
|
||||||
|
<PreferenceCategory android:title="@string/zetime_prefs_inactivity_repetitions"
|
||||||
|
android:dependency="zetime_inactivity_warnings">
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="zetime_prefs_inactivity_repetitions_mo"
|
||||||
|
android:title="@string/zetime_prefs_inactivity_mo" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="zetime_prefs_inactivity_repetitions_tu"
|
||||||
|
android:title="@string/zetime_prefs_inactivity_tu" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="zetime_prefs_inactivity_repetitions_we"
|
||||||
|
android:title="@string/zetime_prefs_inactivity_we" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="zetime_prefs_inactivity_repetitions_th"
|
||||||
|
android:title="@string/zetime_prefs_inactivity_th" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="zetime_prefs_inactivity_repetitions_fr"
|
||||||
|
android:title="@string/zetime_prefs_inactivity_fr" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="zetime_prefs_inactivity_repetitions_sa"
|
||||||
|
android:title="@string/zetime_prefs_inactivity_sa" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="zetime_prefs_inactivity_repetitions_su"
|
||||||
|
android:title="@string/zetime_prefs_inactivity_su" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
</PreferenceScreen>
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="0"
|
android:defaultValue="0"
|
||||||
android:entries="@array/zetime_calories_type"
|
android:entries="@array/zetime_calories_type"
|
||||||
|
Loading…
Reference in New Issue
Block a user