mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 02:25:50 +01:00
Reading the device preferences from the watch and set them in the ZeTime menu.
This commit is contained in:
parent
6b82340093
commit
a7553188f9
@ -96,6 +96,13 @@ public interface EventHandler {
|
|||||||
*/
|
*/
|
||||||
void onSendConfiguration(String config);
|
void onSendConfiguration(String config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the given option from the device, sets the values in the preferences.
|
||||||
|
* The config name is device specific.
|
||||||
|
* @param config the device specific option to get from the device
|
||||||
|
*/
|
||||||
|
void onReadConfiguration(String config);
|
||||||
|
|
||||||
void onTestNewFunction();
|
void onTestNewFunction();
|
||||||
|
|
||||||
void onSendWeather(WeatherSpec weatherSpec);
|
void onSendWeather(WeatherSpec weatherSpec);
|
||||||
|
@ -137,6 +137,7 @@ public class ZeTimeConstants {
|
|||||||
public static final String PREF_ZETIME_HEARTRATE_ALARM = "zetime_heartrate_alarm_enable";
|
public static final String PREF_ZETIME_HEARTRATE_ALARM = "zetime_heartrate_alarm_enable";
|
||||||
public static final String PREF_ZETIME_MAX_HEARTRATE = "alarm_max_heart_rate";
|
public static final String PREF_ZETIME_MAX_HEARTRATE = "alarm_max_heart_rate";
|
||||||
public static final String PREF_ZETIME_MIN_HEARTRATE = "alarm_min_heart_rate";
|
public static final String PREF_ZETIME_MIN_HEARTRATE = "alarm_min_heart_rate";
|
||||||
|
public static final String PREF_ZETIME_HEARTRATE_INTERVAL = "heartrate_measurement_interval";
|
||||||
|
|
||||||
public static final String PREF_DO_NOT_DISTURB = "zetime_do_not_disturb";
|
public static final String PREF_DO_NOT_DISTURB = "zetime_do_not_disturb";
|
||||||
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";
|
||||||
|
@ -1,392 +1,394 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.zetime;
|
package nodomain.freeyourgadget.gadgetbridge.devices.zetime;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
|
|
||||||
public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
|
public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.zetime_preferences);
|
addPreferencesFromResource(R.xml.zetime_preferences);
|
||||||
|
|
||||||
//addTryListeners();
|
//addTryListeners();
|
||||||
|
|
||||||
Prefs prefs = GBApplication.getPrefs();
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
|
|
||||||
final Preference heartrateMeasurementInterval = findPreference("heartrate_measurement_interval");
|
final Preference heartrateMeasurementInterval = findPreference(ZeTimeConstants.PREF_ZETIME_HEARTRATE_INTERVAL);
|
||||||
heartrateMeasurementInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
heartrateMeasurementInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSetHeartRateMeasurementInterval(Integer.parseInt((String) newVal));
|
GBApplication.deviceService().onSetHeartRateMeasurementInterval(Integer.parseInt((String) newVal));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference screenOnDuration = findPreference(ZeTimeConstants.PREF_SCREENTIME);
|
final Preference screenOnDuration = findPreference(ZeTimeConstants.PREF_SCREENTIME);
|
||||||
screenOnDuration.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
screenOnDuration.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SCREENTIME);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SCREENTIME);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference wearSide = findPreference(ZeTimeConstants.PREF_WRIST);
|
final Preference wearSide = findPreference(ZeTimeConstants.PREF_WRIST);
|
||||||
wearSide.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
wearSide.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_WRIST);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_WRIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference analogMode = findPreference(ZeTimeConstants.PREF_ANALOG_MODE);
|
final Preference analogMode = findPreference(ZeTimeConstants.PREF_ANALOG_MODE);
|
||||||
analogMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
analogMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANALOG_MODE);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANALOG_MODE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference activity = findPreference(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
|
final Preference activity = findPreference(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
|
||||||
activity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
activity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference handmove = findPreference(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
|
final Preference handmove = findPreference(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
|
||||||
handmove.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
handmove.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference dnd = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
final Preference dnd = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||||
dnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
dnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference dnd_start = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_START);
|
final Preference dnd_start = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_START);
|
||||||
dnd_start.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
dnd_start.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference dnd_end = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_END);
|
final Preference dnd_end = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_END);
|
||||||
dnd_end.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
dnd_end.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference caloriesType = findPreference(ZeTimeConstants.PREF_CALORIES_TYPE);
|
final Preference caloriesType = findPreference(ZeTimeConstants.PREF_CALORIES_TYPE);
|
||||||
caloriesType.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
caloriesType.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALORIES_TYPE);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALORIES_TYPE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference timeFormat = findPreference(ZeTimeConstants.PREF_TIME_FORMAT);
|
final Preference timeFormat = findPreference(ZeTimeConstants.PREF_TIME_FORMAT);
|
||||||
timeFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
timeFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_TIME_FORMAT);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_TIME_FORMAT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference dateFormat = findPreference(ZeTimeConstants.PREF_DATE_FORMAT);
|
final Preference dateFormat = findPreference(ZeTimeConstants.PREF_DATE_FORMAT);
|
||||||
dateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
dateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DATE_FORMAT);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DATE_FORMAT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlert = findPreference(ZeTimeConstants.PREF_INACTIVITY_ENABLE);
|
final Preference inactivityAlert = findPreference(ZeTimeConstants.PREF_INACTIVITY_ENABLE);
|
||||||
inactivityAlert.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlert.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertStart = findPreference(ZeTimeConstants.PREF_INACTIVITY_START);
|
final Preference inactivityAlertStart = findPreference(ZeTimeConstants.PREF_INACTIVITY_START);
|
||||||
inactivityAlertStart.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertStart.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertEnd = findPreference(ZeTimeConstants.PREF_INACTIVITY_END);
|
final Preference inactivityAlertEnd = findPreference(ZeTimeConstants.PREF_INACTIVITY_END);
|
||||||
inactivityAlertEnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertEnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertThreshold = findPreference(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD);
|
final Preference inactivityAlertThreshold = findPreference(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD);
|
||||||
inactivityAlertThreshold.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertThreshold.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertMo = findPreference(ZeTimeConstants.PREF_INACTIVITY_MO);
|
final Preference inactivityAlertMo = findPreference(ZeTimeConstants.PREF_INACTIVITY_MO);
|
||||||
inactivityAlertMo.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertMo.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertTu = findPreference(ZeTimeConstants.PREF_INACTIVITY_TU);
|
final Preference inactivityAlertTu = findPreference(ZeTimeConstants.PREF_INACTIVITY_TU);
|
||||||
inactivityAlertTu.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertTu.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertWe = findPreference(ZeTimeConstants.PREF_INACTIVITY_WE);
|
final Preference inactivityAlertWe = findPreference(ZeTimeConstants.PREF_INACTIVITY_WE);
|
||||||
inactivityAlertWe.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertWe.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertTh = findPreference(ZeTimeConstants.PREF_INACTIVITY_TH);
|
final Preference inactivityAlertTh = findPreference(ZeTimeConstants.PREF_INACTIVITY_TH);
|
||||||
inactivityAlertTh.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertTh.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertFr = findPreference(ZeTimeConstants.PREF_INACTIVITY_FR);
|
final Preference inactivityAlertFr = findPreference(ZeTimeConstants.PREF_INACTIVITY_FR);
|
||||||
inactivityAlertFr.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertFr.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertSa = findPreference(ZeTimeConstants.PREF_INACTIVITY_SA);
|
final Preference inactivityAlertSa = findPreference(ZeTimeConstants.PREF_INACTIVITY_SA);
|
||||||
inactivityAlertSa.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertSa.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference inactivityAlertSu = findPreference(ZeTimeConstants.PREF_INACTIVITY_SU);
|
final Preference inactivityAlertSu = findPreference(ZeTimeConstants.PREF_INACTIVITY_SU);
|
||||||
inactivityAlertSu.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivityAlertSu.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Preference smsSignaling = findPreference(ZeTimeConstants.PREF_SMS_SIGNALING);
|
final Preference smsSignaling = findPreference(ZeTimeConstants.PREF_SMS_SIGNALING);
|
||||||
smsSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
smsSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SMS_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SMS_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Preference antiSignaling = findPreference(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
|
final Preference antiSignaling = findPreference(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
|
||||||
antiSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
antiSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Preference calendarSignaling = findPreference(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
|
final Preference calendarSignaling = findPreference(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
|
||||||
calendarSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
calendarSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Preference callSignaling = findPreference(ZeTimeConstants.PREF_CALL_SIGNALING);
|
final Preference callSignaling = findPreference(ZeTimeConstants.PREF_CALL_SIGNALING);
|
||||||
callSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
callSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALL_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALL_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Preference missedSignaling = findPreference(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
|
final Preference missedSignaling = findPreference(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
|
||||||
missedSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
missedSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Preference emailSignaling = findPreference(ZeTimeConstants.PREF_EMAIL_SIGNALING);
|
final Preference emailSignaling = findPreference(ZeTimeConstants.PREF_EMAIL_SIGNALING);
|
||||||
emailSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
emailSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_EMAIL_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_EMAIL_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Preference inactivitySignaling = findPreference(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
|
final Preference inactivitySignaling = findPreference(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
|
||||||
inactivitySignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
inactivitySignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Preference powerSignaling = findPreference(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
|
final Preference powerSignaling = findPreference(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
|
||||||
powerSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
powerSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Preference socialSignaling = findPreference(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
|
final Preference socialSignaling = findPreference(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
|
||||||
socialSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
socialSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
|
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
GBApplication.deviceService().onReadConfiguration("do_it");
|
||||||
/**
|
}
|
||||||
* delayed execution so that the preferences are applied first
|
|
||||||
*/
|
/**
|
||||||
private void invokeLater(Runnable runnable) {
|
* delayed execution so that the preferences are applied first
|
||||||
getListView().post(runnable);
|
*/
|
||||||
}
|
private void invokeLater(Runnable runnable) {
|
||||||
|
getListView().post(runnable);
|
||||||
// private void addTryListeners() {
|
}
|
||||||
// for (final NotificationType type : NotificationType.values()) {
|
|
||||||
// String prefKey = "zetime_try_" + type.getGenericType();
|
// private void addTryListeners() {
|
||||||
// final Preference tryPref = findPreference(prefKey);
|
// for (final NotificationType type : NotificationType.values()) {
|
||||||
// if (tryPref != null) {
|
// String prefKey = "zetime_try_" + type.getGenericType();
|
||||||
// tryPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
// final Preference tryPref = findPreference(prefKey);
|
||||||
// @Override
|
// if (tryPref != null) {
|
||||||
// public boolean onPreferenceClick(Preference preference) {
|
// tryPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
// tryVibration(type);
|
// @Override
|
||||||
// return true;
|
// public boolean onPreferenceClick(Preference preference) {
|
||||||
// }
|
// tryVibration(type);
|
||||||
// });
|
// return true;
|
||||||
// } else {
|
// }
|
||||||
// GB.toast(getBaseContext(), "Unable to find preference key: " + prefKey + ", trying the vibration won't work", Toast.LENGTH_LONG, GB.WARN);
|
// });
|
||||||
// }
|
// } else {
|
||||||
// }
|
// GB.toast(getBaseContext(), "Unable to find preference key: " + prefKey + ", trying the vibration won't work", Toast.LENGTH_LONG, GB.WARN);
|
||||||
// }
|
// }
|
||||||
//
|
// }
|
||||||
// private void tryVibration(NotificationType type) {
|
// }
|
||||||
// NotificationSpec spec = new NotificationSpec();
|
//
|
||||||
// spec.type = type;
|
// private void tryVibration(NotificationType type) {
|
||||||
// GBApplication.deviceService().onNotification(spec);
|
// NotificationSpec spec = new NotificationSpec();
|
||||||
// }
|
// spec.type = type;
|
||||||
}
|
// GBApplication.deviceService().onNotification(spec);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
@ -377,6 +377,13 @@ public class GBDeviceService implements DeviceService {
|
|||||||
invokeService(intent);
|
invokeService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
Intent intent = createIntent().setAction(ACTION_READ_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);
|
||||||
|
@ -63,6 +63,7 @@ public interface DeviceService extends EventHandler {
|
|||||||
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_SEND_CONFIGURATION = PREFIX + ".action.send_configuration";
|
||||||
|
String ACTION_READ_CONFIGURATION = PREFIX + ".action.read_configuration";
|
||||||
String ACTION_SEND_WEATHER = PREFIX + ".action.send_weather";
|
String ACTION_SEND_WEATHER = PREFIX + ".action.send_weather";
|
||||||
String ACTION_TEST_NEW_FUNCTION = PREFIX + ".action.test_new_function";
|
String ACTION_TEST_NEW_FUNCTION = PREFIX + ".action.test_new_function";
|
||||||
String ACTION_SET_FM_FREQUENCY = PREFIX + ".action.set_fm_frequency";
|
String ACTION_SET_FM_FREQUENCY = PREFIX + ".action.set_fm_frequency";
|
||||||
|
@ -99,6 +99,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_RE
|
|||||||
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_SEND_CONFIGURATION;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_READ_CONFIGURATION;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SEND_WEATHER;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SEND_WEATHER;
|
||||||
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;
|
||||||
@ -556,6 +557,11 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||||||
mDeviceSupport.onSendConfiguration(config);
|
mDeviceSupport.onSendConfiguration(config);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ACTION_READ_CONFIGURATION: {
|
||||||
|
String config = intent.getStringExtra(EXTRA_CONFIG);
|
||||||
|
mDeviceSupport.onReadConfiguration(config);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ACTION_TEST_NEW_FUNCTION: {
|
case ACTION_TEST_NEW_FUNCTION: {
|
||||||
mDeviceSupport.onTestNewFunction();
|
mDeviceSupport.onTestNewFunction();
|
||||||
break;
|
break;
|
||||||
|
@ -359,6 +359,14 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
|||||||
delegate.onSendConfiguration(config);
|
delegate.onSendConfiguration(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
if (checkBusy("read configuration: " + config)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delegate.onReadConfiguration(config);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
if (checkBusy("test new function event")) {
|
if (checkBusy("test new function event")) {
|
||||||
|
@ -642,6 +642,11 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
LOG.info("Test New Function");
|
LOG.info("Test New Function");
|
||||||
|
@ -1532,6 +1532,11 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
try {
|
try {
|
||||||
|
@ -248,6 +248,11 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
|
|
||||||
|
@ -449,6 +449,11 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
|
|
||||||
|
@ -124,4 +124,9 @@ public class LiveviewSupport extends AbstractSerialDeviceSupport {
|
|||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
//nothing to do ATM
|
//nothing to do ATM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1249,6 +1249,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||||||
// nothing yet
|
// nothing yet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
try {
|
try {
|
||||||
|
@ -373,6 +373,11 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
|
|
||||||
|
@ -238,6 +238,11 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
if (reconnect()) {
|
if (reconnect()) {
|
||||||
|
@ -124,6 +124,11 @@ public class RoidmiSupport extends AbstractSerialDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GBDeviceIoThread createDeviceIOThread() {
|
protected GBDeviceIoThread createDeviceIOThread() {
|
||||||
return new RoidmiIoThread(getDevice(), getContext(), (RoidmiProtocol) getDeviceProtocol(), RoidmiSupport.this, getBluetoothAdapter());
|
return new RoidmiIoThread(getDevice(), getContext(), (RoidmiProtocol) getDeviceProtocol(), RoidmiSupport.this, getBluetoothAdapter());
|
||||||
|
@ -284,6 +284,11 @@ public class VibratissimoSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
|
|
||||||
|
@ -505,6 +505,11 @@ public class Watch9DeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
|
|
||||||
|
@ -371,6 +371,11 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
|||||||
// nothing yet
|
// nothing yet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
//Not supported
|
//Not supported
|
||||||
|
@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.zetime;
|
|||||||
|
|
||||||
import android.bluetooth.BluetoothGatt;
|
import android.bluetooth.BluetoothGatt;
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -438,22 +439,22 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
byte[] strength = {
|
// byte[] strength = {
|
||||||
ZeTimeConstants.CMD_PREAMBLE,
|
// ZeTimeConstants.CMD_PREAMBLE,
|
||||||
ZeTimeConstants.CMD_SHOCK_STRENGTH,
|
// ZeTimeConstants.CMD_SHOCK_STRENGTH,
|
||||||
ZeTimeConstants.CMD_REQUEST,
|
// ZeTimeConstants.CMD_REQUEST,
|
||||||
(byte)0x1,
|
// (byte)0x1,
|
||||||
(byte)0x0,
|
// (byte)0x0,
|
||||||
(byte)0x0,
|
// (byte)0x0,
|
||||||
ZeTimeConstants.CMD_END
|
// ZeTimeConstants.CMD_END
|
||||||
};
|
// };
|
||||||
try {
|
// try {
|
||||||
TransactionBuilder builder = performInitialized("testNewFunction");
|
// TransactionBuilder builder = performInitialized("testNewFunction");
|
||||||
sendMsgToWatch(builder, strength);
|
// sendMsgToWatch(builder, strength);
|
||||||
builder.queue(getQueue());
|
// builder.queue(getQueue());
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
GB.toast(getContext(), "Error on testing new function: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
// GB.toast(getContext(), "Error on testing new function: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -775,8 +776,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
case ZeTimeConstants.CMD_BATTERY_POWER:
|
case ZeTimeConstants.CMD_BATTERY_POWER:
|
||||||
handleBatteryInfo(data);
|
handleBatteryInfo(data);
|
||||||
break;
|
break;
|
||||||
case ZeTimeConstants.CMD_SHOCK_STRENGTH:
|
|
||||||
break;
|
|
||||||
case ZeTimeConstants.CMD_AVAIABLE_DATA:
|
case ZeTimeConstants.CMD_AVAIABLE_DATA:
|
||||||
handleActivityFetching(data);
|
handleActivityFetching(data);
|
||||||
break;
|
break;
|
||||||
@ -792,6 +791,42 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
case ZeTimeConstants.CMD_MUSIC_CONTROL:
|
case ZeTimeConstants.CMD_MUSIC_CONTROL:
|
||||||
handleMusicControl(data);
|
handleMusicControl(data);
|
||||||
break;
|
break;
|
||||||
|
case ZeTimeConstants.CMD_TIME_SURFACE_SETTINGS:
|
||||||
|
getDateTimeFormat(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_SHOCK_MODE:
|
||||||
|
getSignaling(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_DO_NOT_DISTURB:
|
||||||
|
getDoNotDisturb(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_ANALOG_MODE:
|
||||||
|
getAnalogMode(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_CONTROL_DEVICE:
|
||||||
|
getActivityTracking(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_DISPLAY_TIMEOUT:
|
||||||
|
getScreenTime(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_USAGE_HABITS:
|
||||||
|
getWrist(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_AUTO_HEARTRATE:
|
||||||
|
getHeartRateMeasurement(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_HEARTRATE_ALARM_LIMITS:
|
||||||
|
getHeartRateLimits(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_INACTIVITY_ALERT:
|
||||||
|
getInactivityAlert(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_CALORIES_TYPE:
|
||||||
|
getCaloriesType(data);
|
||||||
|
break;
|
||||||
|
case ZeTimeConstants.CMD_SWITCH_SETTINGS:
|
||||||
|
getDisplayOnMovement(data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1661,7 +1696,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
private void setDateFormate(TransactionBuilder builder)
|
private void setDateFormate(TransactionBuilder builder)
|
||||||
{
|
{
|
||||||
Prefs prefs = GBApplication.getPrefs();
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
int type = prefs.getInt(ZeTimeConstants.PREF_TIME_FORMAT, 0);
|
int type = prefs.getInt(ZeTimeConstants.PREF_DATE_FORMAT, 0);
|
||||||
|
|
||||||
byte[] dateformat = {ZeTimeConstants.CMD_PREAMBLE,
|
byte[] dateformat = {ZeTimeConstants.CMD_PREAMBLE,
|
||||||
ZeTimeConstants.CMD_TIME_SURFACE_SETTINGS,
|
ZeTimeConstants.CMD_TIME_SURFACE_SETTINGS,
|
||||||
@ -1817,4 +1852,284 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
sendMsgToWatch(builder, signaling);
|
sendMsgToWatch(builder, signaling);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReadConfiguration(String config) {
|
||||||
|
try {
|
||||||
|
TransactionBuilder builder = performInitialized("readConfiguration");
|
||||||
|
|
||||||
|
if (!getDevice().isBusy()) {
|
||||||
|
getDevice().setBusyTask("readConfiguration");
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] configRead1 = {
|
||||||
|
ZeTimeConstants.CMD_PREAMBLE,
|
||||||
|
ZeTimeConstants.CMD_TIME_SURFACE_SETTINGS,
|
||||||
|
ZeTimeConstants.CMD_REQUEST,
|
||||||
|
(byte)0x1,
|
||||||
|
(byte)0x0,
|
||||||
|
(byte)0x0,
|
||||||
|
ZeTimeConstants.CMD_END
|
||||||
|
};
|
||||||
|
sendMsgToWatch(builder, configRead1);
|
||||||
|
|
||||||
|
byte[] configRead2 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead2, 0, configRead1.length);
|
||||||
|
configRead2[1] = ZeTimeConstants.CMD_SHOCK_MODE;
|
||||||
|
sendMsgToWatch(builder, configRead2);
|
||||||
|
|
||||||
|
byte[] configRead3 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead3, 0, configRead1.length);
|
||||||
|
configRead3[1] = ZeTimeConstants.CMD_DO_NOT_DISTURB;
|
||||||
|
sendMsgToWatch(builder, configRead3);
|
||||||
|
|
||||||
|
byte[] configRead4 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead4, 0, configRead1.length);
|
||||||
|
configRead4[1] = ZeTimeConstants.CMD_ANALOG_MODE;
|
||||||
|
sendMsgToWatch(builder, configRead4);
|
||||||
|
|
||||||
|
byte[] configRead5 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead5, 0, configRead1.length);
|
||||||
|
configRead5[1] = ZeTimeConstants.CMD_CONTROL_DEVICE;
|
||||||
|
sendMsgToWatch(builder, configRead5);
|
||||||
|
|
||||||
|
byte[] configRead6 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead6, 0, configRead1.length);
|
||||||
|
configRead6[1] = ZeTimeConstants.CMD_DISPLAY_TIMEOUT;
|
||||||
|
sendMsgToWatch(builder, configRead6);
|
||||||
|
|
||||||
|
byte[] configRead7 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead7, 0, configRead1.length);
|
||||||
|
configRead7[1] = ZeTimeConstants.CMD_USAGE_HABITS;
|
||||||
|
sendMsgToWatch(builder, configRead7);
|
||||||
|
|
||||||
|
byte[] configRead8 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead8, 0, configRead1.length);
|
||||||
|
configRead8[1] = ZeTimeConstants.CMD_AUTO_HEARTRATE;
|
||||||
|
sendMsgToWatch(builder, configRead8);
|
||||||
|
|
||||||
|
byte[] configRead9 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead9, 0, configRead1.length);
|
||||||
|
configRead9[1] = ZeTimeConstants.CMD_HEARTRATE_ALARM_LIMITS;
|
||||||
|
sendMsgToWatch(builder, configRead9);
|
||||||
|
|
||||||
|
byte[] configRead10 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead10, 0, configRead1.length);
|
||||||
|
configRead10[1] = ZeTimeConstants.CMD_INACTIVITY_ALERT;
|
||||||
|
sendMsgToWatch(builder, configRead10);
|
||||||
|
|
||||||
|
byte[] configRead11 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead11, 0, configRead1.length);
|
||||||
|
configRead11[1] = ZeTimeConstants.CMD_CALORIES_TYPE;
|
||||||
|
sendMsgToWatch(builder, configRead11);
|
||||||
|
|
||||||
|
byte[] configRead12 = new byte[configRead1.length];
|
||||||
|
System.arraycopy(configRead1, 0, configRead12, 0, configRead1.length);
|
||||||
|
configRead12[1] = ZeTimeConstants.CMD_SWITCH_SETTINGS;
|
||||||
|
sendMsgToWatch(builder, configRead12);
|
||||||
|
|
||||||
|
builder.queue(getQueue());
|
||||||
|
} catch (IOException e) {
|
||||||
|
GB.toast(getContext(), "Error reading configuration: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onReadReminders() {
|
||||||
|
try {
|
||||||
|
TransactionBuilder builder = performInitialized("readReminders");
|
||||||
|
|
||||||
|
byte[] reminders = {
|
||||||
|
ZeTimeConstants.CMD_PREAMBLE,
|
||||||
|
ZeTimeConstants.CMD_REMINDERS,
|
||||||
|
ZeTimeConstants.CMD_REQUEST,
|
||||||
|
(byte)0x1,
|
||||||
|
(byte)0x0,
|
||||||
|
(byte)0x0,
|
||||||
|
ZeTimeConstants.CMD_END
|
||||||
|
};
|
||||||
|
sendMsgToWatch(builder, reminders);
|
||||||
|
|
||||||
|
builder.queue(getQueue());
|
||||||
|
} catch (IOException e) {
|
||||||
|
GB.toast(getContext(), "Error reading reminders: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getDateTimeFormat(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_DATE_FORMAT, Integer.toString(msg[5]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_TIME_FORMAT, Integer.toString(msg[6]));
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getSignaling(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING, Integer.toString(msg[5]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_CALL_SIGNALING, Integer.toString(msg[7]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING, Integer.toString(msg[8]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_SMS_SIGNALING, Integer.toString(msg[9]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_SOCIAL_SIGNALING, Integer.toString(msg[10]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_EMAIL_SIGNALING, Integer.toString(msg[11]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_CALENDAR_SIGNALING, Integer.toString(msg[12]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_INACTIVITY_SIGNALING, Integer.toString(msg[13]));
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_LOW_POWER_SIGNALING, Integer.toString(msg[14]));
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getDoNotDisturb(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
String starttime = String.format("%02d:%02d", msg[6], msg[7]);
|
||||||
|
String endtime = String.format("%02d:%02d", msg[8], msg[9]);
|
||||||
|
|
||||||
|
if(0x1 == msg[5]) {
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_DO_NOT_DISTURB, "scheduled");
|
||||||
|
} else {
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_DO_NOT_DISTURB, "off");
|
||||||
|
}
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_DO_NOT_DISTURB_START, starttime);
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_DO_NOT_DISTURB_END, endtime);
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getAnalogMode(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_ANALOG_MODE, Integer.toString(msg[5]));
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getActivityTracking(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
|
||||||
|
if(0x1 == msg[6])
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, false);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, true);
|
||||||
|
}
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getScreenTime(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_SCREENTIME, Integer.toString((msg[5] | (msg[6] << 8))));
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getWrist(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
|
||||||
|
if(ZeTimeConstants.WEAR_ON_LEFT_WRIST == msg[5]) {
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_WRIST, "left");
|
||||||
|
} else if(ZeTimeConstants.WEAR_ON_RIGHT_WRIST == msg[5]) {
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_WRIST, "right");
|
||||||
|
}
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getHeartRateMeasurement(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_ZETIME_HEARTRATE_INTERVAL, Integer.toString((msg[5]*60))); // multiply with 60 because of the conversion from minutes to seconds
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getHeartRateLimits(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getInactivityAlert(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
String starttime = String.format("%02d:%02d", msg[7], msg[8]);
|
||||||
|
String endtime = String.format("%02d:%02d", msg[9], msg[10]);
|
||||||
|
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD, Integer.toString(msg[6]));
|
||||||
|
if(0 != msg[5])
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_ENABLE, true);
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_INACTIVITY_START, starttime);
|
||||||
|
prefs.putString(ZeTimeConstants.PREF_INACTIVITY_END, endtime);
|
||||||
|
if(0 != (msg[5] & (1 << 0))) {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_MO, true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_MO, false);
|
||||||
|
}
|
||||||
|
if(0 != (msg[5] & (1 << 1))) {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_TU, true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_TU, false);
|
||||||
|
}
|
||||||
|
if(0 != (msg[5] & (1 << 2))) {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_WE, true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_WE, false);
|
||||||
|
}
|
||||||
|
if(0 != (msg[5] & (1 << 3))) {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_TH, true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_TH, false);
|
||||||
|
}
|
||||||
|
if(0 != (msg[5] & (1 << 4))) {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_FR, true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_FR, false);
|
||||||
|
}
|
||||||
|
if(0 != (msg[5] & (1 << 5))) {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_SA, true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_SA, false);
|
||||||
|
}
|
||||||
|
if(0 != (msg[5] & (1 << 6))) {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_SU, true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_SU, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getCaloriesType(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences prefs = GBApplication.getPrefs().getPreferences();
|
||||||
|
SharedPreferences.Editor myedit = prefs.edit();
|
||||||
|
|
||||||
|
myedit.putString(ZeTimeConstants.PREF_CALORIES_TYPE, Integer.toString(msg[5]));
|
||||||
|
myedit.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getDisplayOnMovement(byte[] msg)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
|
||||||
|
if(0 != (msg[6] & (1 << 6))) {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_HANDMOVE_DISPLAY, true);
|
||||||
|
} else {
|
||||||
|
prefs.putBoolean(ZeTimeConstants.PREF_HANDMOVE_DISPLAY, false);
|
||||||
|
}
|
||||||
|
prefs.apply();
|
||||||
|
if (getDevice().isBusy()) {
|
||||||
|
getDevice().unsetBusyTask();
|
||||||
|
getDevice().sendDeviceUpdateIntent(getContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user