mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-26 01:00:52 +02:00
Fix bugs, cleanup, test device
Implemented the TestDevice, which showed some bugs. Solved these bugs and cleaned up a bit in the process.
This commit is contained in:
parent
71ea39efde
commit
0eb2bf7dfa
@ -130,11 +130,12 @@ public class AlarmDetails extends AbstractGBActivity {
|
|||||||
timePicker.setCurrentHour(alarm.getHour());
|
timePicker.setCurrentHour(alarm.getHour());
|
||||||
timePicker.setCurrentMinute(alarm.getMinute());
|
timePicker.setCurrentMinute(alarm.getMinute());
|
||||||
|
|
||||||
|
boolean smartAlarmSupported = supportsSmartWakeup(alarm.getPosition());
|
||||||
boolean smartAlarmForced = forcedSmartWakeup(alarm.getPosition());
|
boolean smartAlarmForced = forcedSmartWakeup(alarm.getPosition());
|
||||||
|
boolean smartAlarmIntervalSupported = supportsSmartWakeupInterval(alarm.getPosition());
|
||||||
|
|
||||||
cbSmartWakeup.setChecked(alarm.getSmartWakeup() || smartAlarmForced);
|
cbSmartWakeup.setChecked(alarm.getSmartWakeup() || smartAlarmForced);
|
||||||
boolean smartAlarmVisible = supportsSmartWakeup(alarm.getPosition());
|
cbSmartWakeup.setVisibility(smartAlarmSupported ? View.VISIBLE : View.GONE);
|
||||||
int smartAlarmVisibility = smartAlarmVisible ? View.VISIBLE : View.GONE;
|
|
||||||
cbSmartWakeup.setVisibility(smartAlarmVisibility);
|
|
||||||
if (smartAlarmForced) {
|
if (smartAlarmForced) {
|
||||||
cbSmartWakeup.setEnabled(false);
|
cbSmartWakeup.setEnabled(false);
|
||||||
// Force the text to be visible for the "interval" part
|
// Force the text to be visible for the "interval" part
|
||||||
@ -145,10 +146,10 @@ public class AlarmDetails extends AbstractGBActivity {
|
|||||||
else
|
else
|
||||||
cbSmartWakeup.setTextColor(getResources().getColor(R.color.primarytext_light));
|
cbSmartWakeup.setTextColor(getResources().getColor(R.color.primarytext_light));
|
||||||
}
|
}
|
||||||
if (smartAlarmVisible)
|
if (smartAlarmIntervalSupported)
|
||||||
cbSmartWakeup.setText(R.string.alarm_smart_wakeup_interval);
|
cbSmartWakeup.setText(R.string.alarm_smart_wakeup_interval);
|
||||||
|
|
||||||
smartWakeupInterval.setVisibility(supportsSmartWakeupInterval(alarm.getPosition()) ? smartAlarmVisibility : View.GONE);
|
smartWakeupInterval.setVisibility(smartAlarmSupported && smartAlarmIntervalSupported ? View.VISIBLE : View.GONE);
|
||||||
smartWakeupInterval.setEnabled(alarm.getSmartWakeup() || smartAlarmForced);
|
smartWakeupInterval.setEnabled(alarm.getSmartWakeup() || smartAlarmForced);
|
||||||
if (alarm.getSmartWakeupInterval() != null)
|
if (alarm.getSmartWakeupInterval() != null)
|
||||||
smartWakeupInterval.setText(NumberFormat.getInstance().format(alarm.getSmartWakeupInterval()));
|
smartWakeupInterval.setText(NumberFormat.getInstance().format(alarm.getSmartWakeupInterval()));
|
||||||
|
@ -203,17 +203,29 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAlarmSlotCount(final GBDevice device) {
|
public int getAlarmSlotCount(final GBDevice device) {
|
||||||
|
/*
|
||||||
|
0: Forced smart, no interval
|
||||||
|
1: Forced smart, with interval
|
||||||
|
2: Unforced smart, no interval
|
||||||
|
3: Unforced smart, with interval
|
||||||
|
4: Not smart
|
||||||
|
*/
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsSmartWakeup(final GBDevice device, int position) {
|
public boolean supportsSmartWakeup(final GBDevice device, int position) {
|
||||||
return supports(getTestDevice(), TestFeature.SMART_WAKEUP) && position <= 2;
|
return supports(getTestDevice(), TestFeature.SMART_WAKEUP) && position <= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsSmartWakeupInterval(GBDevice device, int alarmPosition) {
|
||||||
|
return supports(getTestDevice(), TestFeature.SMART_WAKEUP_INTERVAL) && (alarmPosition == 1 || alarmPosition == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean forcedSmartWakeup(final GBDevice device, final int alarmPosition) {
|
public boolean forcedSmartWakeup(final GBDevice device, final int alarmPosition) {
|
||||||
return supports(getTestDevice(), TestFeature.SMART_WAKEUP_FORCED_SLOT) && alarmPosition == 0;
|
return supports(getTestDevice(), TestFeature.SMART_WAKEUP_FORCED_SLOT) && alarmPosition <= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,6 +56,7 @@ public enum TestFeature {
|
|||||||
SCREENSHOTS,
|
SCREENSHOTS,
|
||||||
SLEEP_RESPIRATORY_RATE,
|
SLEEP_RESPIRATORY_RATE,
|
||||||
SMART_WAKEUP,
|
SMART_WAKEUP,
|
||||||
|
SMART_WAKEUP_INTERVAL,
|
||||||
SMART_WAKEUP_FORCED_SLOT,
|
SMART_WAKEUP_FORCED_SLOT,
|
||||||
SPO2,
|
SPO2,
|
||||||
STRESS_MEASUREMENT,
|
STRESS_MEASUREMENT,
|
||||||
|
Loading…
Reference in New Issue
Block a user