mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Mi Band 3: Add preference to enable display on wrist lift during DND
This commit is contained in:
parent
09cfe95e89
commit
300491d483
@ -179,6 +179,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_SHORTCUTS_SORTABLE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_END;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_LIFT_WRIST;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_OFF;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_SCHEDULED;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_START;
|
||||
@ -493,6 +494,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
|
||||
addPreferenceHandlerFor(PREF_DO_NOT_DISTURB_NOAUTO);
|
||||
addPreferenceHandlerFor(PREF_DO_NOT_DISTURB_NOAUTO_START);
|
||||
addPreferenceHandlerFor(PREF_DO_NOT_DISTURB_NOAUTO_END);
|
||||
addPreferenceHandlerFor(PREF_DO_NOT_DISTURB_LIFT_WRIST);
|
||||
addPreferenceHandlerFor(PREF_FIND_PHONE_ENABLED);
|
||||
addPreferenceHandlerFor(PREF_AUTOLIGHT);
|
||||
addPreferenceHandlerFor(PREF_AUTOREMOVE_MESSAGE);
|
||||
|
@ -309,6 +309,12 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
|
||||
return DoNotDisturb.OFF;
|
||||
}
|
||||
|
||||
public static boolean getDoNotDisturbLiftWrist(String deviceAddress) {
|
||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
|
||||
|
||||
return prefs.getBoolean(MiBandConst.PREF_DO_NOT_DISTURB_LIFT_WRIST, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsScreenshots() {
|
||||
return false;
|
||||
|
@ -108,6 +108,7 @@ public class MiBand3Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_nightmode,
|
||||
R.xml.devicesettings_donotdisturb_withauto,
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_donotdisturb_lift_wrist,
|
||||
R.xml.devicesettings_swipeunlock,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_reserve_reminders_calendar,
|
||||
|
@ -37,6 +37,7 @@ public final class MiBandConst {
|
||||
public static final String PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO = "rotate_wrist_to_cycle_info";
|
||||
public static final String PREF_MI2_ENABLE_TEXT_NOTIFICATIONS = "mi2_enable_text_notifications";
|
||||
public static final String PREF_DO_NOT_DISTURB = "do_not_disturb";
|
||||
public static final String PREF_DO_NOT_DISTURB_LIFT_WRIST = "do_not_disturb_lift_wrist";
|
||||
public static final String PREF_DO_NOT_DISTURB_OFF = "off";
|
||||
public static final String PREF_DO_NOT_DISTURB_AUTOMATIC = "automatic";
|
||||
public static final String PREF_DO_NOT_DISTURB_SCHEDULED = "scheduled";
|
||||
|
@ -2119,6 +2119,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB:
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB_LIFT_WRIST:
|
||||
setDoNotDisturb(builder);
|
||||
break;
|
||||
case MiBandConst.PREF_MI2_INACTIVITY_WARNINGS:
|
||||
@ -2715,16 +2716,19 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
private HuamiSupport setDoNotDisturb(TransactionBuilder builder) {
|
||||
DoNotDisturb doNotDisturb = HuamiCoordinator.getDoNotDisturb(gbDevice.getAddress());
|
||||
LOG.info("Setting do not disturb to " + doNotDisturb);
|
||||
boolean doNotDisturbLiftWrist = HuamiCoordinator.getDoNotDisturbLiftWrist(gbDevice.getAddress());
|
||||
LOG.info("Setting do not disturb to {}, wake on lift wrist {}", doNotDisturb, doNotDisturbLiftWrist);
|
||||
byte[] data = null;
|
||||
|
||||
switch (doNotDisturb) {
|
||||
case OFF:
|
||||
writeToConfiguration(builder, HuamiService.COMMAND_DO_NOT_DISTURB_OFF);
|
||||
data = HuamiService.COMMAND_DO_NOT_DISTURB_OFF.clone();
|
||||
break;
|
||||
case AUTOMATIC:
|
||||
writeToConfiguration(builder, HuamiService.COMMAND_DO_NOT_DISTURB_AUTOMATIC);
|
||||
data = HuamiService.COMMAND_DO_NOT_DISTURB_AUTOMATIC.clone();
|
||||
break;
|
||||
case SCHEDULED:
|
||||
byte[] data = HuamiService.COMMAND_DO_NOT_DISTURB_SCHEDULED.clone();
|
||||
data = HuamiService.COMMAND_DO_NOT_DISTURB_SCHEDULED.clone();
|
||||
|
||||
Calendar calendar = GregorianCalendar.getInstance();
|
||||
|
||||
@ -2738,11 +2742,17 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
data[HuamiService.DND_BYTE_END_HOURS] = (byte) calendar.get(Calendar.HOUR_OF_DAY);
|
||||
data[HuamiService.DND_BYTE_END_MINUTES] = (byte) calendar.get(Calendar.MINUTE);
|
||||
|
||||
writeToConfiguration(builder, data);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (data != null) {
|
||||
if (doNotDisturbLiftWrist && doNotDisturb != DoNotDisturb.OFF) {
|
||||
data[1] &= ~0x80;
|
||||
}
|
||||
|
||||
writeToConfiguration(builder, data);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -637,6 +637,7 @@
|
||||
<string name="mi2_prefs_inactivity_warnings_dnd_summary">Disable inactivity warnings for a time interval</string>
|
||||
<string name="mi2_prefs_do_not_disturb_start">Start time</string>
|
||||
<string name="mi2_prefs_do_not_disturb_end">End time</string>
|
||||
<string name="mi2_prefs_do_not_disturb_lift_wrist">Activate display upon lift during Do Not Disturb</string>
|
||||
<string name="mi3_prefs_band_screen_unlock">Band screen unlock"</string>
|
||||
<string name="mi3_prefs_band_screen_unlock_summary">Swipe up to unlock the band\'s screen</string>
|
||||
<string name="mi3_prefs_night_mode">Night mode</string>
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_arrow_upward"
|
||||
android:key="do_not_disturb_lift_wrist"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_lift_wrist" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user