Browse Source

Move "activate display on lift wrist" and "rotate wrist to switch info" to per-device settings

"activate display on lift wrist" for Mi Band 2/3, Cor, Bip
"rotate wrist" only for Mi Band 2
tags/0.34.0
Andreas Shimokawa 4 months ago
parent
commit
d779310962

+ 23
- 11
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java View File

@@ -193,9 +193,9 @@ public class GBApplication extends Application {
if (isRunningMarshmallowOrLater()) {
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
//the following will ensure the notification manager is kept alive
if(isRunningOreoOrLater()) {
if (isRunningOreoOrLater()) {
NotificationChannel channel = notificationManager.getNotificationChannel(NOTIFICATION_CHANNEL_ID);
if(channel == null) {
if (channel == null) {
channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
getString(R.string.notification_channel_name),
NotificationManager.IMPORTANCE_LOW);
@@ -238,7 +238,7 @@ public class GBApplication extends Application {
logging.setupLogging(enabled);
}

public static String getLogPath(){
public static String getLogPath() {
return logging.getLogPath();
}

@@ -326,11 +326,12 @@ public class GBApplication extends Application {
public static boolean isRunningMarshmallowOrLater() {
return VERSION.SDK_INT >= Build.VERSION_CODES.M;
}

public static boolean isRunningNougatOrLater() {
return VERSION.SDK_INT >= Build.VERSION_CODES.N;
}

public static boolean isRunningOreoOrLater(){
public static boolean isRunningOreoOrLater() {
return VERSION.SDK_INT >= Build.VERSION_CODES.O;
}

@@ -491,14 +492,14 @@ public class GBApplication extends Application {
saveAppsPebbleBlackList();
}

public static String packageNameToPebbleMsgSender(String packageName) {
if ("eu.siacs.conversations".equals(packageName)){
return("Conversations");
} else if ("net.osmand.plus".equals(packageName)) {
return("OsmAnd");
public static String packageNameToPebbleMsgSender(String packageName) {
if ("eu.siacs.conversations".equals(packageName)) {
return ("Conversations");
} else if ("net.osmand.plus".equals(packageName)) {
return ("OsmAnd");
}
return packageName;
}
return packageName;
}

private static HashSet<String> calendars_blacklist = null;

@@ -668,6 +669,11 @@ public static String packageNameToPebbleMsgSender(String packageName) {
deviceSharedPrefsEdit.putString("do_not_disturb_start", prefs.getString("mi2_do_not_disturb_start", "1:00"));
deviceSharedPrefsEdit.putString("do_not_disturb_end", prefs.getString("mi2_do_not_disturb_end", "6:00"));
}
if (dbDevice.getManufacturer().equals("Huami")) {
deviceSharedPrefsEdit.putString("activate_display_on_lift_wrist", prefs.getString("activate_display_on_lift_wrist", "off"));
deviceSharedPrefsEdit.putString("display_on_lift_start", prefs.getString("display_on_lift_start", "0:00"));
deviceSharedPrefsEdit.putString("display_on_lift_end", prefs.getString("display_on_lift_end", "0:00"));
}
switch (deviceType) {
case MIBAND:
deviceSharedPrefsEdit.putBoolean("low_latency_fw_update", prefs.getBoolean("mi_low_latency_fw_update", true));
@@ -683,6 +689,7 @@ public static String packageNameToPebbleMsgSender(String packageName) {
displayItems = prefs.getStringSet("mi2_display_items", null);
deviceSharedPrefsEdit.putBoolean("mi2_enable_text_notifications", prefs.getBoolean("mi2_enable_text_notifications", true));
deviceSharedPrefsEdit.putString("mi2_dateformat", prefs.getString("mi2_dateformat", "dateformat_time"));
deviceSharedPrefsEdit.putBoolean("rotate_wrist_to_cycle_info", prefs.getBoolean("mi2_rotate_wrist_to_switch_info", false));
break;
case MIBAND3:
newLanguage = prefs.getString("miband3_language", "auto");
@@ -709,6 +716,10 @@ public static String packageNameToPebbleMsgSender(String packageName) {
editor.remove("disconnect_notification");
editor.remove("disconnect_notification_start");
editor.remove("disconnect_notification_end");
editor.remove("activate_display_on_lift_wrist");
editor.remove("display_on_lift_start");
editor.remove("display_on_lift_end");

editor.remove("mi_low_latency_fw_update");
editor.remove("mi_device_time_offset_hours");
editor.remove("mi2_do_not_disturb");
@@ -716,6 +727,7 @@ public static String packageNameToPebbleMsgSender(String packageName) {
editor.remove("mi2_do_not_disturb_end");
editor.remove("mi2_dateformat");
editor.remove("mi2_display_items");
editor.remove("mi2_rotate_wrist_to_switch_info");
editor.remove("mi2_enable_text_notifications");
editor.remove("mi3_band_screen_unlock");
editor.remove("mi3_night_mode");

+ 97
- 8
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java View File

@@ -10,6 +10,11 @@ import androidx.preference.EditTextPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Objects;

import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
@@ -17,15 +22,19 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreference;
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreferenceFragment;

import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_END;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_START;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISPLAY_ON_LIFT_END;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISPLAY_ON_LIFT_START;
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_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;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DATEFORMAT;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE_END;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE_OFF;
@@ -35,6 +44,8 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PR

public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {

private static final Logger LOG = LoggerFactory.getLogger(DeviceSpecificSettingsFragment.class);

static final String FRAGMENT_TAG = "DEVICE_SPECIFIC_SETTINGS_FRAGMENT";

private void setSettingsFileSuffix(String settingsFileSuffix, @NonNull int[] supportedSettings) {
@@ -137,8 +148,8 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
public boolean onPreferenceChange(Preference preference, Object newVal) {
final boolean scheduled = PREF_DO_NOT_DISTURB_SCHEDULED.equals(newVal.toString());

disconnectNotificationStart.setEnabled(scheduled);
disconnectNotificationEnd.setEnabled(scheduled);
Objects.requireNonNull(disconnectNotificationStart).setEnabled(scheduled);
Objects.requireNonNull(disconnectNotificationEnd).setEnabled(scheduled);
invokeLater(new Runnable() {
@Override
public void run() {
@@ -196,8 +207,8 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
public boolean onPreferenceChange(Preference preference, Object newVal) {
final boolean scheduled = PREF_NIGHT_MODE_SCHEDULED.equals(newVal.toString());

nightModeStart.setEnabled(scheduled);
nightModeEnd.setEnabled(scheduled);
Objects.requireNonNull(nightModeStart).setEnabled(scheduled);
Objects.requireNonNull(nightModeEnd).setEnabled(scheduled);

invokeLater(new Runnable() {
@Override
@@ -255,8 +266,8 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
public boolean onPreferenceChange(Preference preference, Object newVal) {
final boolean scheduled = PREF_DO_NOT_DISTURB_SCHEDULED.equals(newVal.toString());

doNotDisturbStart.setEnabled(scheduled);
doNotDisturbEnd.setEnabled(scheduled);
Objects.requireNonNull(doNotDisturbStart).setEnabled(scheduled);
Objects.requireNonNull(doNotDisturbEnd).setEnabled(scheduled);

invokeLater(new Runnable() {
@Override
@@ -273,6 +284,82 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
addPreferenceHandlerFor(PREF_MI2_DATEFORMAT);
addPreferenceHandlerFor(HuamiConst.PREF_DISPLAY_ITEMS);

String displayOnLiftState = prefs.getString(PREF_ACTIVATE_DISPLAY_ON_LIFT, PREF_DO_NOT_DISTURB_OFF);
boolean displayOnLiftScheduled = displayOnLiftState.equals(PREF_DO_NOT_DISTURB_SCHEDULED);

final Preference rotateWristCycleInfo = findPreference(PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO);
if (rotateWristCycleInfo != null) {
rotateWristCycleInfo.setEnabled(!PREF_DO_NOT_DISTURB_OFF.equals(displayOnLiftState));
rotateWristCycleInfo.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO);
}
});
return true;
}
});
}

final Preference displayOnLiftStart = findPreference(PREF_DISPLAY_ON_LIFT_START);
if (displayOnLiftStart != null) {
displayOnLiftStart.setEnabled(displayOnLiftScheduled);
displayOnLiftStart.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_DISPLAY_ON_LIFT_START);
}
});
return true;
}
});
}

final Preference displayOnLiftEnd = findPreference(PREF_DISPLAY_ON_LIFT_END);
if (displayOnLiftEnd != null) {
displayOnLiftEnd.setEnabled(displayOnLiftScheduled);
displayOnLiftEnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_DISPLAY_ON_LIFT_END);
}
});
return true;
}
});
}

final Preference displayOnLift = findPreference(PREF_ACTIVATE_DISPLAY_ON_LIFT);
if (displayOnLift != null) {
displayOnLift.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
final boolean scheduled = PREF_DO_NOT_DISTURB_SCHEDULED.equals(newVal.toString());
Objects.requireNonNull(displayOnLiftStart).setEnabled(scheduled);
Objects.requireNonNull(displayOnLiftEnd).setEnabled(scheduled);
if (rotateWristCycleInfo != null) {
rotateWristCycleInfo.setEnabled(!PREF_DO_NOT_DISTURB_OFF.equals(newVal.toString()));
}
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_ACTIVATE_DISPLAY_ON_LIFT);
}
});
return true;
}
});
}

EditTextPreference pref = findPreference(MiBandConst.PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS);
if (pref != null) {
pref.setOnBindEditTextListener(new EditTextPreference.OnBindEditTextListener() {
@@ -293,14 +380,16 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {

@Override
public void onDisplayPreferenceDialog(Preference preference) {
DialogFragment dialogFragment = null;
DialogFragment dialogFragment;
if (preference instanceof XTimePreference) {
dialogFragment = new XTimePreferenceFragment();
Bundle bundle = new Bundle(1);
bundle.putString("key", preference.getKey());
dialogFragment.setArguments(bundle);
dialogFragment.setTargetFragment(this, 0);
dialogFragment.show(getFragmentManager(), "androidx.preference.PreferenceFragment.DIALOG");
if (getFragmentManager() != null) {
dialogFragment.show(getFragmentManager(), "androidx.preference.PreferenceFragment.DIALOG");
}
} else {
super.onDisplayPreferenceDialog(preference);
}

+ 8
- 8
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiCoordinator.java View File

@@ -140,8 +140,8 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
return DateTimeDisplay.DATE_TIME;
}

public static ActivateDisplayOnLift getActivateDisplayOnLiftWrist(Context context) {
Prefs prefs = GBApplication.getPrefs();
public static ActivateDisplayOnLift getActivateDisplayOnLiftWrist(Context context, String deviceAddress) {
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);

String liftOff = context.getString(R.string.p_off);
String liftOn = context.getString(R.string.p_on);
@@ -158,12 +158,12 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
return ActivateDisplayOnLift.OFF;
}

public static Date getDisplayOnLiftStart() {
return getTimePreference(HuamiConst.PREF_DISPLAY_ON_LIFT_START, "00:00");
public static Date getDisplayOnLiftStart(String deviceAddress) {
return getTimePreference(HuamiConst.PREF_DISPLAY_ON_LIFT_START, "00:00", deviceAddress);
}

public static Date getDisplayOnLiftEnd() {
return getTimePreference(HuamiConst.PREF_DISPLAY_ON_LIFT_END, "00:00");
public static Date getDisplayOnLiftEnd(String deviceAddress) {
return getTimePreference(HuamiConst.PREF_DISPLAY_ON_LIFT_END, "00:00", deviceAddress);
}

public static DisconnectNotificationSetting getDisconnectNotificationSetting(Context context, String deviceAddress) {
@@ -202,8 +202,8 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
return prefs.getBoolean(MiBandConst.PREF_MI2_GOAL_NOTIFICATION, false);
}

public static boolean getRotateWristToSwitchInfo() {
Prefs prefs = GBApplication.getPrefs();
public static boolean getRotateWristToSwitchInfo(String deviceAddress) {
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
return prefs.getBoolean(MiBandConst.PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO, false);
}


+ 1
- 0
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java View File

@@ -81,6 +81,7 @@ public class AmazfitBipCoordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_amazfitbip,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_pairingkey
};

+ 1
- 0
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorCoordinator.java View File

@@ -84,6 +84,7 @@ public class AmazfitCorCoordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_amazfitcor,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_pairingkey};
}

+ 2
- 0
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java View File

@@ -85,6 +85,8 @@ public class MiBand2Coordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_miband2,
R.xml.devicesettings_donotdisturb_withauto,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_rotatewrist_cycleinfo,
R.xml.devicesettings_pairingkey
};
}

+ 1
- 0
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Coordinator.java View File

@@ -105,6 +105,7 @@ public class MiBand3Coordinator extends HuamiCoordinator {
R.xml.devicesettings_miband3,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_donotdisturb_withauto,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_pairingkey
};

+ 1
- 1
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java View File

@@ -48,7 +48,7 @@ public final class MiBandConst {
public static final String PREF_MI2_DISPLAY_ITEM_CALORIES = "calories";
public static final String PREF_MI2_DISPLAY_ITEM_HEART_RATE = "heart_rate";
public static final String PREF_MI2_DISPLAY_ITEM_BATTERY = "battery";
public static final String PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO = "mi2_rotate_wrist_to_switch_info";
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_OFF = "off";

+ 0
- 86
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPreferencesActivity.java View File

@@ -41,11 +41,8 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISPLAY_ON_LIFT_START;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.ORIGIN_ALARM_CLOCK;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.ORIGIN_INCOMING_CALL;
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_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;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_GOAL_NOTIFICATION;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_INACTIVITY_WARNINGS;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_INACTIVITY_WARNINGS_DND;
@@ -56,7 +53,6 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PR
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_INACTIVITY_WARNINGS_THRESHOLD;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_ADDRESS;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_RESERVE_ALARM_FOR_CALENDAR;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_USE_HR_FOR_SLEEP_DETECTION;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_USER_ALIAS;
@@ -106,37 +102,6 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity {
}
});

final Preference activateDisplayOnLift = findPreference(PREF_ACTIVATE_DISPLAY_ON_LIFT);
activateDisplayOnLift.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_ACTIVATE_DISPLAY_ON_LIFT);
}
});
return true;
}
});

String displayOnLiftState = prefs.getString(PREF_ACTIVATE_DISPLAY_ON_LIFT, PREF_DO_NOT_DISTURB_OFF);
boolean displayOnLiftScheduled = displayOnLiftState.equals(PREF_DO_NOT_DISTURB_SCHEDULED);

final Preference rotateWristCycleInfo = findPreference(PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO);
rotateWristCycleInfo.setEnabled(!PREF_DO_NOT_DISTURB_OFF.equals(displayOnLiftState));
rotateWristCycleInfo.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO);
}
});
return true;
}
});

final Preference inactivityWarnings = findPreference(PREF_MI2_INACTIVITY_WARNINGS);
inactivityWarnings.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@@ -236,56 +201,6 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity {
}
});

final Preference displayOnLiftStart = findPreference(PREF_DISPLAY_ON_LIFT_START);
displayOnLiftStart.setEnabled(displayOnLiftScheduled);
displayOnLiftStart.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_DISPLAY_ON_LIFT_START);
}
});
return true;
}
});


final Preference displayOnLiftEnd = findPreference(PREF_DISPLAY_ON_LIFT_END);
displayOnLiftEnd.setEnabled(displayOnLiftScheduled);
displayOnLiftEnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_DISPLAY_ON_LIFT_END);
}
});
return true;
}
});


final Preference displayOnLift = findPreference(PREF_ACTIVATE_DISPLAY_ON_LIFT);
displayOnLift.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
final boolean scheduled = PREF_DO_NOT_DISTURB_SCHEDULED.equals(newVal.toString());

displayOnLiftStart.setEnabled(scheduled);
displayOnLiftEnd.setEnabled(scheduled);
rotateWristCycleInfo.setEnabled(!PREF_DO_NOT_DISTURB_OFF.equals(newVal.toString()));
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_ACTIVATE_DISPLAY_ON_LIFT);
}
});
return true;
}
});

final Preference fitnessGoal = findPreference(ActivityUser.PREF_USER_STEPS_GOAL);
fitnessGoal.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@@ -356,7 +271,6 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity {
prefKeys.add(PREF_MIBAND_ADDRESS);
prefKeys.add(ActivityUser.PREF_USER_STEPS_GOAL);
prefKeys.add(PREF_MIBAND_RESERVE_ALARM_FOR_CALENDAR);
prefKeys.add(PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS);
prefKeys.add(PREF_MI2_INACTIVITY_WARNINGS_THRESHOLD);
prefKeys.add(getNotificationPrefKey(VIBRATION_COUNT, ORIGIN_ALARM_CLOCK));
prefKeys.add(getNotificationPrefKey(VIBRATION_COUNT, ORIGIN_INCOMING_CALL));

+ 4
- 4
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java View File

@@ -1616,7 +1616,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
}

private HuamiSupport setActivateDisplayOnLiftWrist(TransactionBuilder builder) {
ActivateDisplayOnLift displayOnLift = HuamiCoordinator.getActivateDisplayOnLiftWrist(getContext());
ActivateDisplayOnLift displayOnLift = HuamiCoordinator.getActivateDisplayOnLiftWrist(getContext(), gbDevice.getAddress());
LOG.info("Setting activate display on lift wrist to " + displayOnLift);

switch (displayOnLift) {
@@ -1631,12 +1631,12 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {

Calendar calendar = GregorianCalendar.getInstance();

Date start = HuamiCoordinator.getDisplayOnLiftStart();
Date start = HuamiCoordinator.getDisplayOnLiftStart(gbDevice.getAddress());
calendar.setTime(start);
cmd[4] = (byte) calendar.get(Calendar.HOUR_OF_DAY);
cmd[5] = (byte) calendar.get(Calendar.MINUTE);

Date end = HuamiCoordinator.getDisplayOnLiftEnd();
Date end = HuamiCoordinator.getDisplayOnLiftEnd(gbDevice.getAddress());
calendar.setTime(end);
cmd[6] = (byte) calendar.get(Calendar.HOUR_OF_DAY);
cmd[7] = (byte) calendar.get(Calendar.MINUTE);
@@ -1675,7 +1675,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
}

private HuamiSupport setRotateWristToSwitchInfo(TransactionBuilder builder) {
boolean enable = HuamiCoordinator.getRotateWristToSwitchInfo();
boolean enable = HuamiCoordinator.getRotateWristToSwitchInfo(gbDevice.getAddress());
LOG.info("Setting rotate wrist to cycle info to " + enable);
if (enable) {
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), HuamiService.COMMAND_ENABLE_ROTATE_WRIST_TO_SWITCH_INFO);

+ 30
- 0
app/src/main/res/xml/devicesettings_liftwrist_display.xml View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen
android:key="screen_liftwrist_display"
android:persistent="false"
android:title="@string/mi2_prefs_activate_display_on_lift">

<!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/mi2_prefs_activate_display_on_lift" />

<ListPreference
android:defaultValue="@string/p_off"
android:entries="@array/activate_display_on_lift"
android:entryValues="@array/activate_display_on_lift_values"
android:key="activate_display_on_lift_wrist"
android:summary="%s"
android:title="@string/mi2_prefs_activate_display_on_lift" />

<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="00:00"
android:key="display_on_lift_start"
android:title="@string/mi2_prefs_do_not_disturb_start" />

<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="00:00"
android:key="display_on_lift_end"
android:title="@string/mi2_prefs_do_not_disturb_end" />

</PreferenceScreen>
</androidx.preference.PreferenceScreen>

+ 7
- 0
app/src/main/res/xml/devicesettings_rotatewrist_cycleinfo.xml View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="false"
android:key="rotate_wrist_to_cycle_info"
android:title="@string/mi2_prefs_rotate_wrist_to_switch_info" />
</androidx.preference.PreferenceScreen>

+ 0
- 31
app/src/main/res/xml/miband_preferences.xml View File

@@ -106,37 +106,6 @@
android:summary="%s"
android:title="@string/prefs_title_heartrate_measurement_interval" />

<PreferenceScreen
android:persistent="false"
android:title="@string/mi2_prefs_activate_display_on_lift">

<!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/mi2_prefs_activate_display_on_lift" />

<ListPreference
android:defaultValue="@string/p_off"
android:entries="@array/activate_display_on_lift"
android:entryValues="@array/activate_display_on_lift_values"
android:key="activate_display_on_lift_wrist"
android:summary="%s"
android:title="@string/mi2_prefs_activate_display_on_lift" />

<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
android:defaultValue="00:00"
android:key="display_on_lift_start"
android:title="@string/mi2_prefs_do_not_disturb_start" />

<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
android:defaultValue="00:00"
android:key="display_on_lift_end"
android:title="@string/mi2_prefs_do_not_disturb_end" />

</PreferenceScreen>
<CheckBoxPreference
android:defaultValue="false"
android:key="mi2_rotate_wrist_to_switch_info"
android:title="@string/mi2_prefs_rotate_wrist_to_switch_info" />

<PreferenceScreen
android:key="mi2_inactivity_warning_key"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"

Loading…
Cancel
Save