mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-05 01:37:03 +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);
|
||||
|
||||
/**
|
||||
* 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 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_MAX_HEARTRATE = "alarm_max_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_START = "zetime_do_not_disturb_start";
|
||||
|
@ -1,392 +1,394 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.zetime;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.widget.Toast;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.zetime_preferences);
|
||||
|
||||
//addTryListeners();
|
||||
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
|
||||
final Preference heartrateMeasurementInterval = findPreference("heartrate_measurement_interval");
|
||||
heartrateMeasurementInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSetHeartRateMeasurementInterval(Integer.parseInt((String) newVal));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference screenOnDuration = findPreference(ZeTimeConstants.PREF_SCREENTIME);
|
||||
screenOnDuration.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SCREENTIME);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference wearSide = findPreference(ZeTimeConstants.PREF_WRIST);
|
||||
wearSide.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_WRIST);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference analogMode = findPreference(ZeTimeConstants.PREF_ANALOG_MODE);
|
||||
analogMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANALOG_MODE);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference activity = findPreference(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
|
||||
activity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference handmove = findPreference(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
|
||||
handmove.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference dnd = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||
dnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference dnd_start = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_START);
|
||||
dnd_start.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference dnd_end = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_END);
|
||||
dnd_end.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference caloriesType = findPreference(ZeTimeConstants.PREF_CALORIES_TYPE);
|
||||
caloriesType.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALORIES_TYPE);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference timeFormat = findPreference(ZeTimeConstants.PREF_TIME_FORMAT);
|
||||
timeFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_TIME_FORMAT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference dateFormat = findPreference(ZeTimeConstants.PREF_DATE_FORMAT);
|
||||
dateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DATE_FORMAT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlert = findPreference(ZeTimeConstants.PREF_INACTIVITY_ENABLE);
|
||||
inactivityAlert.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertStart = findPreference(ZeTimeConstants.PREF_INACTIVITY_START);
|
||||
inactivityAlertStart.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertEnd = findPreference(ZeTimeConstants.PREF_INACTIVITY_END);
|
||||
inactivityAlertEnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertThreshold = findPreference(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD);
|
||||
inactivityAlertThreshold.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertMo = findPreference(ZeTimeConstants.PREF_INACTIVITY_MO);
|
||||
inactivityAlertMo.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertTu = findPreference(ZeTimeConstants.PREF_INACTIVITY_TU);
|
||||
inactivityAlertTu.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertWe = findPreference(ZeTimeConstants.PREF_INACTIVITY_WE);
|
||||
inactivityAlertWe.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertTh = findPreference(ZeTimeConstants.PREF_INACTIVITY_TH);
|
||||
inactivityAlertTh.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertFr = findPreference(ZeTimeConstants.PREF_INACTIVITY_FR);
|
||||
inactivityAlertFr.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertSa = findPreference(ZeTimeConstants.PREF_INACTIVITY_SA);
|
||||
inactivityAlertSa.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertSu = findPreference(ZeTimeConstants.PREF_INACTIVITY_SU);
|
||||
inactivityAlertSu.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference smsSignaling = findPreference(ZeTimeConstants.PREF_SMS_SIGNALING);
|
||||
smsSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SMS_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference antiSignaling = findPreference(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
|
||||
antiSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference calendarSignaling = findPreference(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
|
||||
calendarSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference callSignaling = findPreference(ZeTimeConstants.PREF_CALL_SIGNALING);
|
||||
callSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALL_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference missedSignaling = findPreference(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
|
||||
missedSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference emailSignaling = findPreference(ZeTimeConstants.PREF_EMAIL_SIGNALING);
|
||||
emailSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_EMAIL_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference inactivitySignaling = findPreference(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
|
||||
inactivitySignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference powerSignaling = findPreference(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
|
||||
powerSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference socialSignaling = findPreference(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
|
||||
socialSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* delayed execution so that the preferences are applied first
|
||||
*/
|
||||
private void invokeLater(Runnable runnable) {
|
||||
getListView().post(runnable);
|
||||
}
|
||||
|
||||
// private void addTryListeners() {
|
||||
// for (final NotificationType type : NotificationType.values()) {
|
||||
// String prefKey = "zetime_try_" + type.getGenericType();
|
||||
// final Preference tryPref = findPreference(prefKey);
|
||||
// if (tryPref != null) {
|
||||
// tryPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
// @Override
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void tryVibration(NotificationType type) {
|
||||
// NotificationSpec spec = new NotificationSpec();
|
||||
// spec.type = type;
|
||||
// GBApplication.deviceService().onNotification(spec);
|
||||
// }
|
||||
}
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.zetime;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.widget.Toast;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.zetime_preferences);
|
||||
|
||||
//addTryListeners();
|
||||
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
|
||||
final Preference heartrateMeasurementInterval = findPreference(ZeTimeConstants.PREF_ZETIME_HEARTRATE_INTERVAL);
|
||||
heartrateMeasurementInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSetHeartRateMeasurementInterval(Integer.parseInt((String) newVal));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference screenOnDuration = findPreference(ZeTimeConstants.PREF_SCREENTIME);
|
||||
screenOnDuration.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SCREENTIME);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference wearSide = findPreference(ZeTimeConstants.PREF_WRIST);
|
||||
wearSide.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_WRIST);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference analogMode = findPreference(ZeTimeConstants.PREF_ANALOG_MODE);
|
||||
analogMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANALOG_MODE);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference activity = findPreference(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
|
||||
activity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference handmove = findPreference(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
|
||||
handmove.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference dnd = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||
dnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference dnd_start = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_START);
|
||||
dnd_start.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference dnd_end = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_END);
|
||||
dnd_end.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference caloriesType = findPreference(ZeTimeConstants.PREF_CALORIES_TYPE);
|
||||
caloriesType.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALORIES_TYPE);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference timeFormat = findPreference(ZeTimeConstants.PREF_TIME_FORMAT);
|
||||
timeFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_TIME_FORMAT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference dateFormat = findPreference(ZeTimeConstants.PREF_DATE_FORMAT);
|
||||
dateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DATE_FORMAT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlert = findPreference(ZeTimeConstants.PREF_INACTIVITY_ENABLE);
|
||||
inactivityAlert.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertStart = findPreference(ZeTimeConstants.PREF_INACTIVITY_START);
|
||||
inactivityAlertStart.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertEnd = findPreference(ZeTimeConstants.PREF_INACTIVITY_END);
|
||||
inactivityAlertEnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertThreshold = findPreference(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD);
|
||||
inactivityAlertThreshold.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertMo = findPreference(ZeTimeConstants.PREF_INACTIVITY_MO);
|
||||
inactivityAlertMo.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertTu = findPreference(ZeTimeConstants.PREF_INACTIVITY_TU);
|
||||
inactivityAlertTu.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertWe = findPreference(ZeTimeConstants.PREF_INACTIVITY_WE);
|
||||
inactivityAlertWe.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertTh = findPreference(ZeTimeConstants.PREF_INACTIVITY_TH);
|
||||
inactivityAlertTh.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertFr = findPreference(ZeTimeConstants.PREF_INACTIVITY_FR);
|
||||
inactivityAlertFr.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertSa = findPreference(ZeTimeConstants.PREF_INACTIVITY_SA);
|
||||
inactivityAlertSa.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference inactivityAlertSu = findPreference(ZeTimeConstants.PREF_INACTIVITY_SU);
|
||||
inactivityAlertSu.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_KEY);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final Preference smsSignaling = findPreference(ZeTimeConstants.PREF_SMS_SIGNALING);
|
||||
smsSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SMS_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference antiSignaling = findPreference(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
|
||||
antiSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference calendarSignaling = findPreference(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
|
||||
calendarSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference callSignaling = findPreference(ZeTimeConstants.PREF_CALL_SIGNALING);
|
||||
callSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALL_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference missedSignaling = findPreference(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
|
||||
missedSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference emailSignaling = findPreference(ZeTimeConstants.PREF_EMAIL_SIGNALING);
|
||||
emailSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_EMAIL_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference inactivitySignaling = findPreference(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
|
||||
inactivitySignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference powerSignaling = findPreference(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
|
||||
powerSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final Preference socialSignaling = findPreference(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
|
||||
socialSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
GBApplication.deviceService().onReadConfiguration("do_it");
|
||||
}
|
||||
|
||||
/**
|
||||
* delayed execution so that the preferences are applied first
|
||||
*/
|
||||
private void invokeLater(Runnable runnable) {
|
||||
getListView().post(runnable);
|
||||
}
|
||||
|
||||
// private void addTryListeners() {
|
||||
// for (final NotificationType type : NotificationType.values()) {
|
||||
// String prefKey = "zetime_try_" + type.getGenericType();
|
||||
// final Preference tryPref = findPreference(prefKey);
|
||||
// if (tryPref != null) {
|
||||
// tryPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
// @Override
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void tryVibration(NotificationType type) {
|
||||
// NotificationSpec spec = new NotificationSpec();
|
||||
// spec.type = type;
|
||||
// GBApplication.deviceService().onNotification(spec);
|
||||
// }
|
||||
}
|
||||
|
@ -377,6 +377,13 @@ public class GBDeviceService implements DeviceService {
|
||||
invokeService(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
Intent intent = createIntent().setAction(ACTION_READ_CONFIGURATION)
|
||||
.putExtra(EXTRA_CONFIG, config);
|
||||
invokeService(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
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_DELETE_CALENDAREVENT = PREFIX + ".action.delete_calendarevent";
|
||||
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_TEST_NEW_FUNCTION = PREFIX + ".action.test_new_function";
|
||||
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_SCREENSHOT;
|
||||
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_SETCANNEDMESSAGES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICINFO;
|
||||
@ -556,6 +557,11 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
mDeviceSupport.onSendConfiguration(config);
|
||||
break;
|
||||
}
|
||||
case ACTION_READ_CONFIGURATION: {
|
||||
String config = intent.getStringExtra(EXTRA_CONFIG);
|
||||
mDeviceSupport.onReadConfiguration(config);
|
||||
break;
|
||||
}
|
||||
case ACTION_TEST_NEW_FUNCTION: {
|
||||
mDeviceSupport.onTestNewFunction();
|
||||
break;
|
||||
|
@ -359,6 +359,14 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
||||
delegate.onSendConfiguration(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
if (checkBusy("read configuration: " + config)) {
|
||||
return;
|
||||
}
|
||||
delegate.onReadConfiguration(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
if (checkBusy("test new function event")) {
|
||||
|
@ -642,6 +642,11 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
LOG.info("Test New Function");
|
||||
|
@ -1532,6 +1532,11 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
try {
|
||||
|
@ -248,6 +248,11 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
|
||||
|
@ -449,6 +449,11 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
|
||||
|
@ -124,4 +124,9 @@ public class LiveviewSupport extends AbstractSerialDeviceSupport {
|
||||
public void onTestNewFunction() {
|
||||
//nothing to do ATM
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1249,6 +1249,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
// nothing yet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
try {
|
||||
|
@ -373,6 +373,11 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
|
||||
|
@ -238,6 +238,11 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
if (reconnect()) {
|
||||
|
@ -124,6 +124,11 @@ public class RoidmiSupport extends AbstractSerialDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GBDeviceIoThread createDeviceIOThread() {
|
||||
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
|
||||
public void onTestNewFunction() {
|
||||
|
||||
|
@ -505,6 +505,11 @@ public class Watch9DeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
|
||||
|
@ -371,6 +371,11 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
// nothing yet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
//Not supported
|
||||
|
@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.zetime;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -438,22 +439,22 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
byte[] strength = {
|
||||
ZeTimeConstants.CMD_PREAMBLE,
|
||||
ZeTimeConstants.CMD_SHOCK_STRENGTH,
|
||||
ZeTimeConstants.CMD_REQUEST,
|
||||
(byte)0x1,
|
||||
(byte)0x0,
|
||||
(byte)0x0,
|
||||
ZeTimeConstants.CMD_END
|
||||
};
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("testNewFunction");
|
||||
sendMsgToWatch(builder, strength);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error on testing new function: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
// byte[] strength = {
|
||||
// ZeTimeConstants.CMD_PREAMBLE,
|
||||
// ZeTimeConstants.CMD_SHOCK_STRENGTH,
|
||||
// ZeTimeConstants.CMD_REQUEST,
|
||||
// (byte)0x1,
|
||||
// (byte)0x0,
|
||||
// (byte)0x0,
|
||||
// ZeTimeConstants.CMD_END
|
||||
// };
|
||||
// try {
|
||||
// TransactionBuilder builder = performInitialized("testNewFunction");
|
||||
// sendMsgToWatch(builder, strength);
|
||||
// builder.queue(getQueue());
|
||||
// } catch (IOException e) {
|
||||
// GB.toast(getContext(), "Error on testing new function: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -775,8 +776,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
case ZeTimeConstants.CMD_BATTERY_POWER:
|
||||
handleBatteryInfo(data);
|
||||
break;
|
||||
case ZeTimeConstants.CMD_SHOCK_STRENGTH:
|
||||
break;
|
||||
case ZeTimeConstants.CMD_AVAIABLE_DATA:
|
||||
handleActivityFetching(data);
|
||||
break;
|
||||
@ -792,6 +791,42 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
case ZeTimeConstants.CMD_MUSIC_CONTROL:
|
||||
handleMusicControl(data);
|
||||
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;
|
||||
@ -1661,7 +1696,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
private void setDateFormate(TransactionBuilder builder)
|
||||
{
|
||||
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,
|
||||
ZeTimeConstants.CMD_TIME_SURFACE_SETTINGS,
|
||||
@ -1817,4 +1852,284 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
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