Mi2: Add config option to configure date/time display
(added a new EventHandler method to set a specific configuration option)
This commit is contained in:
parent
ddaf51768d
commit
d89899557c
|
@ -67,5 +67,12 @@ public interface EventHandler {
|
||||||
|
|
||||||
void onDeleteCalendarEvent(byte type, long id);
|
void onDeleteCalendarEvent(byte type, long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the given option in the device, typically with values from the preferences.
|
||||||
|
* The config name is device specific.
|
||||||
|
* @param config the device specific option to set on the device
|
||||||
|
*/
|
||||||
|
void onSendConfiguration(String config);
|
||||||
|
|
||||||
void onTestNewFunction();
|
void onTestNewFunction();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.devices.miband;
|
||||||
|
|
||||||
|
public enum DateTimeDisplay {
|
||||||
|
TIME,
|
||||||
|
DATE_TIME
|
||||||
|
}
|
|
@ -7,10 +7,13 @@ import android.net.Uri;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
|
|
||||||
public class MiBand2Coordinator extends MiBandCoordinator {
|
public class MiBand2Coordinator extends MiBandCoordinator {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(MiBand2Coordinator.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MiBand2Coordinator.class);
|
||||||
|
@ -55,4 +58,13 @@ public class MiBand2Coordinator extends MiBandCoordinator {
|
||||||
public InstallHandler findInstallHandler(Uri uri, Context context) {
|
public InstallHandler findInstallHandler(Uri uri, Context context) {
|
||||||
return null; // not supported at the moment
|
return null; // not supported at the moment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DateTimeDisplay getDateDisplay(Context context) throws IllegalArgumentException {
|
||||||
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
|
String dateFormatTime = context.getString(R.string.p_dateformat_time);
|
||||||
|
if (dateFormatTime.equals(prefs.getString(MiBandConst.PREF_MI2_DATEFORMAT, dateFormatTime))) {
|
||||||
|
return DateTimeDisplay.TIME;
|
||||||
|
}
|
||||||
|
return DateTimeDisplay.DATE_TIME;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ public final class MiBandConst {
|
||||||
public static final String PREF_MIBAND_RESERVE_ALARM_FOR_CALENDAR = "mi_reserve_alarm_calendar";
|
public static final String PREF_MIBAND_RESERVE_ALARM_FOR_CALENDAR = "mi_reserve_alarm_calendar";
|
||||||
public static final String PREF_MIBAND_USE_HR_FOR_SLEEP_DETECTION = "mi_hr_sleep_detection";
|
public static final String PREF_MIBAND_USE_HR_FOR_SLEEP_DETECTION = "mi_hr_sleep_detection";
|
||||||
public static final String PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS = "mi_device_time_offset_hours";
|
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_TRY_SMS = "mi_try_sms";
|
public static final String PREF_TRY_SMS = "mi_try_sms";
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.ORIGIN_INCOMING_CALL;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.ORIGIN_INCOMING_CALL;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DATEFORMAT;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_ADDRESS;
|
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_DEVICE_TIME_OFFSET_HOURS;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_FITNESS_GOAL;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_FITNESS_GOAL;
|
||||||
|
@ -44,8 +45,22 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
final Preference setDateFormat = findPreference(PREF_MI2_DATEFORMAT);
|
||||||
|
setDateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
|
getListView().post(new Runnable() { // delayed execution so that the preferences are applied first
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
GBApplication.deviceService().onSendConfiguration(PREF_MI2_DATEFORMAT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onPostCreate(Bundle savedInstanceState) {
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
super.onPostCreate(savedInstanceState);
|
super.onPostCreate(savedInstanceState);
|
||||||
final Preference developmentMiaddr = findPreference(PREF_MIBAND_ADDRESS);
|
final Preference developmentMiaddr = findPreference(PREF_MIBAND_ADDRESS);
|
||||||
|
|
|
@ -281,6 +281,13 @@ public class GBDeviceService implements DeviceService {
|
||||||
invokeService(intent);
|
invokeService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSendConfiguration(String config) {
|
||||||
|
Intent intent = createIntent().setAction(ACTION_SEND_CONFIGURATION)
|
||||||
|
.putExtra(EXTRA_CONFIG, config);
|
||||||
|
invokeService(intent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
Intent intent = createIntent().setAction(ACTION_TEST_NEW_FUNCTION);
|
Intent intent = createIntent().setAction(ACTION_TEST_NEW_FUNCTION);
|
||||||
|
|
|
@ -48,6 +48,7 @@ public interface DeviceService extends EventHandler {
|
||||||
String ACTION_HEARTRATE_MEASUREMENT = PREFIX + ".action.hr_measurement";
|
String ACTION_HEARTRATE_MEASUREMENT = PREFIX + ".action.hr_measurement";
|
||||||
String ACTION_ADD_CALENDAREVENT = PREFIX + ".action.add_calendarevent";
|
String ACTION_ADD_CALENDAREVENT = PREFIX + ".action.add_calendarevent";
|
||||||
String ACTION_DELETE_CALENDAREVENT = PREFIX + ".action.delete_calendarevent";
|
String ACTION_DELETE_CALENDAREVENT = PREFIX + ".action.delete_calendarevent";
|
||||||
|
String ACTION_SEND_CONFIGURATION = PREFIX + ".action.send_configuration";
|
||||||
String ACTION_TEST_NEW_FUNCTION = PREFIX + ".action.test_new_function";
|
String ACTION_TEST_NEW_FUNCTION = PREFIX + ".action.test_new_function";
|
||||||
String EXTRA_DEVICE_ADDRESS = "device_address";
|
String EXTRA_DEVICE_ADDRESS = "device_address";
|
||||||
String EXTRA_NOTIFICATION_BODY = "notification_body";
|
String EXTRA_NOTIFICATION_BODY = "notification_body";
|
||||||
|
@ -80,6 +81,7 @@ public interface DeviceService extends EventHandler {
|
||||||
String EXTRA_APP_START = "app_start";
|
String EXTRA_APP_START = "app_start";
|
||||||
String EXTRA_APP_CONFIG = "app_config";
|
String EXTRA_APP_CONFIG = "app_config";
|
||||||
String EXTRA_URI = "uri";
|
String EXTRA_URI = "uri";
|
||||||
|
String EXTRA_CONFIG = "config";
|
||||||
String EXTRA_ALARMS = "alarms";
|
String EXTRA_ALARMS = "alarms";
|
||||||
String EXTRA_PERFORM_PAIR = "perform_pair";
|
String EXTRA_PERFORM_PAIR = "perform_pair";
|
||||||
String EXTRA_BOOLEAN_ENABLE = "enable_realtime_steps";
|
String EXTRA_BOOLEAN_ENABLE = "enable_realtime_steps";
|
||||||
|
|
|
@ -72,6 +72,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_RE
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_APPINFO;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_APPINFO;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_DEVICEINFO;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_DEVICEINFO;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_SCREENSHOT;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_SCREENSHOT;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SEND_CONFIGURATION;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETCANNEDMESSAGES;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETCANNEDMESSAGES;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICINFO;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICINFO;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICSTATE;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICSTATE;
|
||||||
|
@ -96,6 +97,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CAL
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_PHONENUMBER;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_PHONENUMBER;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CANNEDMESSAGES;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CANNEDMESSAGES;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CANNEDMESSAGES_TYPE;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CANNEDMESSAGES_TYPE;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CONFIG;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_DEVICE_ADDRESS;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_DEVICE_ADDRESS;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_FIND_START;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_FIND_START;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ALBUM;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ALBUM;
|
||||||
|
@ -485,6 +487,11 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||||
mDeviceSupport.onEnableRealtimeHeartRateMeasurement(enable);
|
mDeviceSupport.onEnableRealtimeHeartRateMeasurement(enable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ACTION_SEND_CONFIGURATION: {
|
||||||
|
String config = intent.getStringExtra(EXTRA_CONFIG);
|
||||||
|
mDeviceSupport.onSendConfiguration(config);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ACTION_TEST_NEW_FUNCTION: {
|
case ACTION_TEST_NEW_FUNCTION: {
|
||||||
mDeviceSupport.onTestNewFunction();
|
mDeviceSupport.onTestNewFunction();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -320,6 +320,14 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
||||||
delegate.onDeleteCalendarEvent(type, id);
|
delegate.onDeleteCalendarEvent(type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSendConfiguration(String config) {
|
||||||
|
if (checkBusy("send configuration: " + config)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delegate.onSendConfiguration(config);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
if (checkBusy("test new function event")) {
|
if (checkBusy("test new function event")) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Coordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandCoordinator;
|
||||||
|
@ -56,7 +57,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateA
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfoProfile;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfoProfile;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.heartrate.HeartRateProfile;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.heartrate.HeartRateProfile;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.DateDisplay;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.DateTimeDisplay;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.Mi2NotificationStrategy;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.Mi2NotificationStrategy;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.InitOperation;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.InitOperation;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||||
|
@ -401,6 +402,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
LOG.info("Attempting to set wear location...");
|
LOG.info("Attempting to set wear location...");
|
||||||
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBand2Service.UUID_UNKNOWN_CHARACTERISTIC8);
|
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBand2Service.UUID_UNKNOWN_CHARACTERISTIC8);
|
||||||
if (characteristic != null) {
|
if (characteristic != null) {
|
||||||
|
builder.notify(characteristic, true);
|
||||||
int location = MiBandCoordinator.getWearLocation(getDevice().getAddress());
|
int location = MiBandCoordinator.getWearLocation(getDevice().getAddress());
|
||||||
switch (location) {
|
switch (location) {
|
||||||
case 0: // left hand
|
case 0: // left hand
|
||||||
|
@ -410,6 +412,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
builder.write(characteristic, MiBand2Service.WEAR_LOCATION_RIGHT_WRIST);
|
builder.write(characteristic, MiBand2Service.WEAR_LOCATION_RIGHT_WRIST);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
builder.notify(characteristic, false); // TODO: this should actually be in some kind of finally-block in the queue
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -444,6 +447,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
BluetoothGattCharacteristic characteristicHRControlPoint = getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT);
|
BluetoothGattCharacteristic characteristicHRControlPoint = getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT);
|
||||||
final boolean enableHrSleepSupport = MiBandCoordinator.getHeartrateSleepSupport(getDevice().getAddress());
|
final boolean enableHrSleepSupport = MiBandCoordinator.getHeartrateSleepSupport(getDevice().getAddress());
|
||||||
if (characteristicHRControlPoint != null) {
|
if (characteristicHRControlPoint != null) {
|
||||||
|
builder.notify(characteristicHRControlPoint, true);
|
||||||
if (enableHrSleepSupport) {
|
if (enableHrSleepSupport) {
|
||||||
LOG.info("Enabling heartrate sleep support...");
|
LOG.info("Enabling heartrate sleep support...");
|
||||||
builder.write(characteristicHRControlPoint, MiBand2Service.COMMAND_ENABLE_HR_SLEEP_MEASUREMENT);
|
builder.write(characteristicHRControlPoint, MiBand2Service.COMMAND_ENABLE_HR_SLEEP_MEASUREMENT);
|
||||||
|
@ -451,6 +455,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
LOG.info("Disabling heartrate sleep support...");
|
LOG.info("Disabling heartrate sleep support...");
|
||||||
builder.write(characteristicHRControlPoint, MiBand2Service.COMMAND_DISABLE_HR_SLEEP_MEASUREMENT);
|
builder.write(characteristicHRControlPoint, MiBand2Service.COMMAND_DISABLE_HR_SLEEP_MEASUREMENT);
|
||||||
}
|
}
|
||||||
|
builder.notify(characteristicHRControlPoint, false); // TODO: this should run in some kind of finally-block in the queue
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -1154,13 +1159,30 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSendConfiguration(String config) {
|
||||||
|
TransactionBuilder builder = null;
|
||||||
|
try {
|
||||||
|
builder = performInitialized("Sending configuration for option: " + config);
|
||||||
|
switch (config) {
|
||||||
|
case MiBandConst.PREF_MI2_DATEFORMAT:
|
||||||
|
setDateDisplay(builder);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
builder.queue(getQueue());
|
||||||
|
} catch (IOException e) {
|
||||||
|
GB.toast("Error setting configuration", Toast.LENGTH_LONG, GB.ERROR, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiBand2Support setDateDisplay(DateDisplay displayConfig, TransactionBuilder builder) {
|
private MiBand2Support setDateDisplay(TransactionBuilder builder) {
|
||||||
LOG.info("Setting date display to " + displayConfig);
|
DateTimeDisplay dateTimeDisplay = MiBand2Coordinator.getDateDisplay(getContext());
|
||||||
switch (displayConfig) {
|
LOG.info("Setting date display to " + dateTimeDisplay);
|
||||||
|
switch (dateTimeDisplay) {
|
||||||
case TIME:
|
case TIME:
|
||||||
builder.write(getCharacteristic(MiBand2Service.UUID_UNKNOWN_CHARACTERISTIC3), MiBand2Service.DATEFORMAT_TIME);
|
builder.write(getCharacteristic(MiBand2Service.UUID_UNKNOWN_CHARACTERISTIC3), MiBand2Service.DATEFORMAT_TIME);
|
||||||
break;
|
break;
|
||||||
|
@ -1174,8 +1196,9 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
public void phase2Initialize(TransactionBuilder builder) {
|
public void phase2Initialize(TransactionBuilder builder) {
|
||||||
LOG.info("phase2Initialize...");
|
LOG.info("phase2Initialize...");
|
||||||
enableFurtherNotifications(builder, true);
|
enableFurtherNotifications(builder, true);
|
||||||
setDateDisplay(DateDisplay.TIME, builder);
|
setDateDisplay(builder);
|
||||||
setWearLocation(builder);
|
setWearLocation(builder);
|
||||||
setHeartrateSleepSupport(builder);
|
setHeartrateSleepSupport(builder);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1190,6 +1190,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSendConfiguration(String config) {
|
||||||
|
// nothing yet
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.miband2;
|
|
||||||
|
|
||||||
public enum DateDisplay {
|
|
||||||
TIME,
|
|
||||||
DATE_TIME
|
|
||||||
}
|
|
|
@ -157,6 +157,13 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSendConfiguration(String config) {
|
||||||
|
if (reconnect()) {
|
||||||
|
super.onSendConfiguration(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
if (reconnect()) {
|
if (reconnect()) {
|
||||||
|
|
|
@ -272,6 +272,11 @@ public class VibratissimoSupport extends AbstractBTLEDeviceSupport {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSendConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
|
|
||||||
|
|
|
@ -215,6 +215,12 @@ public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport
|
||||||
sendToDevice(bytes);
|
sendToDevice(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSendConfiguration(String config) {
|
||||||
|
byte[] bytes = gbDeviceProtocol.encodeSendConfiguration(config);
|
||||||
|
sendToDevice(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
byte[] bytes = gbDeviceProtocol.encodeTestNewFunction();
|
byte[] bytes = gbDeviceProtocol.encodeTestNewFunction();
|
||||||
|
|
|
@ -94,6 +94,10 @@ public abstract class GBDeviceProtocol {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] encodeSendConfiguration(String config) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] encodeTestNewFunction() { return null; }
|
public byte[] encodeTestNewFunction() { return null; }
|
||||||
|
|
||||||
public GBDeviceEvent[] decodeResponse(byte[] responseData) {
|
public GBDeviceEvent[] decodeResponse(byte[] responseData) {
|
||||||
|
@ -103,4 +107,5 @@ public abstract class GBDeviceProtocol {
|
||||||
public GBDevice getDevice() {
|
public GBDevice getDevice() {
|
||||||
return mDevice;
|
return mDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,5 +113,13 @@
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="mi2_dateformats">
|
||||||
|
<item>@string/dateformat_time</item>
|
||||||
|
<item>@string/dateformat_date_time</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="mi2_dateformats_values">
|
||||||
|
<item>@string/p_dateformat_time</item>
|
||||||
|
<item>@string/p_dateformat_datetime</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -345,4 +345,7 @@
|
||||||
|
|
||||||
<!-- Strings related to Vibration Activity -->
|
<!-- Strings related to Vibration Activity -->
|
||||||
<string name="title_activity_vibration">Vibration</string>
|
<string name="title_activity_vibration">Vibration</string>
|
||||||
|
<string name="miband2_prefs_dateformat">Mi2: Date Format</string>
|
||||||
|
<string name="dateformat_time">Time</string>
|
||||||
|
<string name="dateformat_date_time"><![CDATA[Time & Date]]></string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -9,4 +9,7 @@
|
||||||
<item name="p_ring" type="string">ring</item>
|
<item name="p_ring" type="string">ring</item>
|
||||||
<item name="p_alarm_clock" type="string">alarm_clock</item>
|
<item name="p_alarm_clock" type="string">alarm_clock</item>
|
||||||
|
|
||||||
|
<item name="p_dateformat_time" type="string">dateformat_time</item>
|
||||||
|
<item name="p_dateformat_datetime" type="string">dateformat_datetime</item>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -43,6 +43,15 @@
|
||||||
android:maxLength="2"
|
android:maxLength="2"
|
||||||
android:title="@string/miband_prefs_device_time_offset_hours" />
|
android:title="@string/miband_prefs_device_time_offset_hours" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="@string/p_dateformat_time"
|
||||||
|
android:entries="@array/mi2_dateformats"
|
||||||
|
android:entryValues="@array/mi2_dateformats_values"
|
||||||
|
android:key="mi2_dateformat"
|
||||||
|
android:title="@string/miband2_prefs_dateformat"
|
||||||
|
android:summary="%s" />
|
||||||
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|
|
@ -168,6 +168,11 @@ public class TestDeviceSupport extends AbstractDeviceSupport {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSendConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue