mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-05 09:47:01 +01:00
Mi2: make text/icon notifications confiurable and version dependent
This commit is contained in:
parent
cf35e84feb
commit
d408be5ec8
@ -21,6 +21,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Version;
|
||||
|
||||
public final class MiBandConst {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MiBandConst.class);
|
||||
@ -35,6 +36,7 @@ public final class MiBandConst {
|
||||
public static final String PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS = "mi_device_time_offset_hours";
|
||||
public static final String PREF_MI2_DATEFORMAT = "mi2_dateformat";
|
||||
public static final String PREF_MI2_ACTIVATE_DISPLAY_ON_LIFT = "mi2_activate_display_on_lift_wrist";
|
||||
public static final String PREF_MI2_ENABLE_TEXT_NOTIFICATIONS = "mi2_enable_text_notifications";
|
||||
public static final String PREF_MIBAND_SETUP_BT_PAIRING = "mi_setup_bt_pairing";
|
||||
|
||||
|
||||
@ -48,6 +50,9 @@ public final class MiBandConst {
|
||||
public static final String MI_AMAZFIT = "Amazfit";
|
||||
public static final String MI_PRO = "2";
|
||||
|
||||
public static final Version MI2_FW_VERSION_MIN_TEXT_NOTIFICATIONS = new Version("1.0.1.28");
|
||||
public static final Version MI2_FW_VERSION_INTERMEDIATE_UPGRADE_53 = new Version("1.0.0.53");
|
||||
|
||||
public static int getNotificationPrefIntValue(String pref, String origin, Prefs prefs, int defaultValue) {
|
||||
String key = getNotificationPrefKey(pref, origin);
|
||||
return prefs.getInt(key, defaultValue);
|
||||
|
@ -39,6 +39,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.OR
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.ORIGIN_INCOMING_CALL;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_ACTIVATE_DISPLAY_ON_LIFT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DATEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_ENABLE_TEXT_NOTIFICATIONS;
|
||||
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;
|
||||
@ -163,6 +164,7 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity {
|
||||
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_ENABLE_TEXT_NOTIFICATIONS);
|
||||
prefKeys.add(getNotificationPrefKey(VIBRATION_COUNT, ORIGIN_ALARM_CLOCK));
|
||||
prefKeys.add(getNotificationPrefKey(VIBRATION_COUNT, ORIGIN_INCOMING_CALL));
|
||||
|
||||
|
@ -28,6 +28,7 @@ import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.FirmwareType;
|
||||
@ -63,7 +64,7 @@ public class MiBand2FWInstallHandler extends AbstractMiBandFWInstallHandler {
|
||||
|
||||
Version deviceVersion = getFirmwareVersionOf(device);
|
||||
if (deviceVersion != null) {
|
||||
Version v53 = new Version("1.0.0.53");
|
||||
Version v53 = MiBandConst.MI2_FW_VERSION_INTERMEDIATE_UPGRADE_53;
|
||||
if (deviceVersion.compareTo(v53) < 0) {
|
||||
String vInstall = getHelper().format(getHelper().getFirmwareVersion());
|
||||
if (vInstall == null || new Version(vInstall).compareTo(v53) > 0) {
|
||||
|
@ -58,6 +58,7 @@ public class Mi2FirmwareInfo {
|
||||
// firmware
|
||||
crcToVersion.put(41899, "1.0.0.39");
|
||||
crcToVersion.put(49197, "1.0.0.53");
|
||||
crcToVersion.put(32450, "1.0.1.28");
|
||||
crcToVersion.put(51770, "1.0.1.34");
|
||||
crcToVersion.put(3929, "1.0.1.39");
|
||||
|
||||
|
@ -99,6 +99,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.U
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Version;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_FLASH_COLOUR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_FLASH_COUNT;
|
||||
@ -304,8 +305,17 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
private NotificationStrategy getNotificationStrategy() {
|
||||
// return new Mi2NotificationStrategy(this);
|
||||
return new Mi2TextNotificationStrategy(this);
|
||||
String firmwareVersion = getDevice().getFirmwareVersion();
|
||||
if (firmwareVersion != null) {
|
||||
Version ver = new Version(firmwareVersion);
|
||||
if (MiBandConst.MI2_FW_VERSION_MIN_TEXT_NOTIFICATIONS.compareTo(ver) > 0) {
|
||||
return new Mi2NotificationStrategy(this);
|
||||
}
|
||||
}
|
||||
if (GBApplication.getPrefs().getBoolean(MiBandConst.PREF_MI2_ENABLE_TEXT_NOTIFICATIONS, true)) {
|
||||
return new Mi2TextNotificationStrategy(this);
|
||||
}
|
||||
return new Mi2NotificationStrategy(this);
|
||||
}
|
||||
|
||||
private static final byte[] startHeartMeasurementManual = new byte[]{0x15, MiBandService.COMMAND_SET_HR_MANUAL, 1};
|
||||
@ -990,6 +1000,9 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
versionCmd.hwVersion = info.getHardwareRevision();
|
||||
// versionCmd.fwVersion = info.getFirmwareRevision(); // always null
|
||||
versionCmd.fwVersion = info.getSoftwareRevision();
|
||||
if (versionCmd.fwVersion != null && versionCmd.fwVersion.length() > 0 && versionCmd.fwVersion.charAt(0) == 'V') {
|
||||
versionCmd.fwVersion = versionCmd.fwVersion.substring(1);
|
||||
}
|
||||
handleGBDeviceEvent(versionCmd);
|
||||
}
|
||||
|
||||
|
@ -407,4 +407,7 @@
|
||||
<string name="find_device_you_found_it">You found it!</string>
|
||||
<string name="miband2_prefs_timeformat">Mi2: Time Format</string>
|
||||
<string name="mi2_fw_installhandler_fw53_hint">You need to install version %1$s before installing this firmware!</string>
|
||||
<string name="mi2_enable_text_notifications">Text notifications</string>
|
||||
<string name="mi2_enable_text_notifications_summary"><![CDATA[Needs firmware >= 1.0.1.28 and Mili_pro.ft* installed.]]></string>
|
||||
<string name="off">off</string>
|
||||
</resources>
|
||||
|
@ -48,6 +48,13 @@
|
||||
android:key="mi2_activate_display_on_lift_wrist"
|
||||
android:title="@string/mi2_prefs_activate_display_on_lift" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="mi2_enable_text_notifications"
|
||||
android:summaryOn="@string/mi2_enable_text_notifications_summary"
|
||||
android:summaryOff="@string/off"
|
||||
android:title="@string/mi2_enable_text_notifications" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/p_dateformat_time"
|
||||
android:entries="@array/mi2_dateformats"
|
||||
|
Loading…
Reference in New Issue
Block a user