mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 09:17:29 +01:00
7c597b325a
- model package contains mostly shared interfaces (UI+service), not named GB* - impl package contains implementations of those interfaces, named GB* the impl classes should not be used by the service (not completely done) - the service classes should mostly use classes inside the service and deviceevents packages (tbd) Every device now has two packages: - devices/[device name] for UI related functionality - service[device name] for lowlevel communication
82 lines
3.1 KiB
Java
82 lines
3.1 KiB
Java
package nodomain.freeyourgadget.gadgetbridge.activities;
|
|
|
|
import android.app.Activity;
|
|
import android.os.Bundle;
|
|
import android.os.Parcelable;
|
|
import android.text.format.DateFormat;
|
|
import android.view.MenuItem;
|
|
import android.widget.CheckBox;
|
|
import android.widget.TimePicker;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBAlarm;
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
|
|
public class AlarmDetails extends Activity {
|
|
|
|
private GBAlarm alarm;
|
|
private TimePicker timePicker;
|
|
private CheckBox cbSmartWakeup;
|
|
private CheckBox cbMonday;
|
|
private CheckBox cbTuesday;
|
|
private CheckBox cbWednesday;
|
|
private CheckBox cbThursday;
|
|
private CheckBox cbFriday;
|
|
private CheckBox cbSaturday;
|
|
private CheckBox cbSunday;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_alarm_details);
|
|
|
|
Parcelable p = getIntent().getExtras().getParcelable("alarm");
|
|
alarm = (GBAlarm) p;
|
|
|
|
timePicker = (TimePicker) findViewById(R.id.alarm_time_picker);
|
|
cbSmartWakeup = (CheckBox) findViewById(R.id.alarm_cb_smart_wakeup);
|
|
cbMonday = (CheckBox) findViewById(R.id.alarm_cb_mon);
|
|
cbTuesday = (CheckBox) findViewById(R.id.alarm_cb_tue);
|
|
cbWednesday = (CheckBox) findViewById(R.id.alarm_cb_wed);
|
|
cbThursday = (CheckBox) findViewById(R.id.alarm_cb_thu);
|
|
cbFriday = (CheckBox) findViewById(R.id.alarm_cb_fri);
|
|
cbSaturday = (CheckBox) findViewById(R.id.alarm_cb_sat);
|
|
cbSunday = (CheckBox) findViewById(R.id.alarm_cb_sun);
|
|
|
|
timePicker.setIs24HourView(DateFormat.is24HourFormat(GBApplication.getContext()));
|
|
timePicker.setCurrentHour(alarm.getHour());
|
|
timePicker.setCurrentMinute(alarm.getMinute());
|
|
|
|
cbSmartWakeup.setChecked(alarm.isSmartWakeup());
|
|
|
|
cbMonday.setChecked(alarm.getRepetition(GBAlarm.ALARM_MON));
|
|
cbTuesday.setChecked(alarm.getRepetition(GBAlarm.ALARM_TUE));
|
|
cbWednesday.setChecked(alarm.getRepetition(GBAlarm.ALARM_WED));
|
|
cbThursday.setChecked(alarm.getRepetition(GBAlarm.ALARM_THU));
|
|
cbFriday.setChecked(alarm.getRepetition(GBAlarm.ALARM_FRI));
|
|
cbSaturday.setChecked(alarm.getRepetition(GBAlarm.ALARM_SAT));
|
|
cbSunday.setChecked(alarm.getRepetition(GBAlarm.ALARM_SUN));
|
|
|
|
}
|
|
|
|
@Override
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
switch (item.getItemId()) {
|
|
case android.R.id.home:
|
|
// back button
|
|
updateAlarm();
|
|
finish();
|
|
return true;
|
|
}
|
|
return super.onOptionsItemSelected(item);
|
|
}
|
|
|
|
private void updateAlarm() {
|
|
alarm.setSmartWakeup(cbSmartWakeup.isChecked());
|
|
alarm.setRepetition(cbMonday.isChecked(), cbTuesday.isChecked(), cbWednesday.isChecked(), cbThursday.isChecked(), cbFriday.isChecked(), cbSaturday.isChecked(), cbSunday.isChecked());
|
|
alarm.setHour(timePicker.getCurrentHour());
|
|
alarm.setMinute(timePicker.getCurrentMinute());
|
|
alarm.store();
|
|
}
|
|
}
|