mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 09:17:29 +01: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.setCurrentMinute(alarm.getMinute());
|
||||
|
||||
boolean smartAlarmSupported = supportsSmartWakeup(alarm.getPosition());
|
||||
boolean smartAlarmForced = forcedSmartWakeup(alarm.getPosition());
|
||||
boolean smartAlarmIntervalSupported = supportsSmartWakeupInterval(alarm.getPosition());
|
||||
|
||||
cbSmartWakeup.setChecked(alarm.getSmartWakeup() || smartAlarmForced);
|
||||
boolean smartAlarmVisible = supportsSmartWakeup(alarm.getPosition());
|
||||
int smartAlarmVisibility = smartAlarmVisible ? View.VISIBLE : View.GONE;
|
||||
cbSmartWakeup.setVisibility(smartAlarmVisibility);
|
||||
cbSmartWakeup.setVisibility(smartAlarmSupported ? View.VISIBLE : View.GONE);
|
||||
if (smartAlarmForced) {
|
||||
cbSmartWakeup.setEnabled(false);
|
||||
// Force the text to be visible for the "interval" part
|
||||
@ -145,10 +146,10 @@ public class AlarmDetails extends AbstractGBActivity {
|
||||
else
|
||||
cbSmartWakeup.setTextColor(getResources().getColor(R.color.primarytext_light));
|
||||
}
|
||||
if (smartAlarmVisible)
|
||||
if (smartAlarmIntervalSupported)
|
||||
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);
|
||||
if (alarm.getSmartWakeupInterval() != null)
|
||||
smartWakeupInterval.setText(NumberFormat.getInstance().format(alarm.getSmartWakeupInterval()));
|
||||
|
@ -203,17 +203,29 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
|
@ -56,6 +56,7 @@ public enum TestFeature {
|
||||
SCREENSHOTS,
|
||||
SLEEP_RESPIRATORY_RATE,
|
||||
SMART_WAKEUP,
|
||||
SMART_WAKEUP_INTERVAL,
|
||||
SMART_WAKEUP_FORCED_SLOT,
|
||||
SPO2,
|
||||
STRESS_MEASUREMENT,
|
||||
|
Loading…
Reference in New Issue
Block a user