mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Add alarm title and description field to alarm configuation
Wire it up and enable for Fossil Hybrid HR
This commit is contained in:
parent
ca5d177608
commit
fa2d954552
@ -22,6 +22,7 @@ import android.text.format.DateFormat;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.CheckedTextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
@ -46,6 +47,8 @@ public class AlarmDetails extends AbstractGBActivity {
|
||||
private CheckedTextView cbFriday;
|
||||
private CheckedTextView cbSaturday;
|
||||
private CheckedTextView cbSunday;
|
||||
private EditText title;
|
||||
private EditText description;
|
||||
private GBDevice device;
|
||||
|
||||
@Override
|
||||
@ -56,6 +59,9 @@ public class AlarmDetails extends AbstractGBActivity {
|
||||
alarm = (Alarm) getIntent().getSerializableExtra(nodomain.freeyourgadget.gadgetbridge.model.Alarm.EXTRA_ALARM);
|
||||
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||
|
||||
title = findViewById(R.id.alarm_title);
|
||||
description = findViewById(R.id.alarm_description);
|
||||
|
||||
timePicker = findViewById(R.id.alarm_time_picker);
|
||||
cbSmartWakeup = findViewById(R.id.alarm_cb_smart_wakeup);
|
||||
cbSnooze = findViewById(R.id.alarm_cb_snooze);
|
||||
@ -126,6 +132,12 @@ public class AlarmDetails extends AbstractGBActivity {
|
||||
int snoozeVisibility = supportsSnoozing() ? View.VISIBLE : View.GONE;
|
||||
cbSnooze.setVisibility(snoozeVisibility);
|
||||
|
||||
int descriptionVisibility = supportsDescription() ? View.VISIBLE : View.GONE;
|
||||
title.setVisibility(descriptionVisibility);
|
||||
title.setText(alarm.getTitle());
|
||||
description.setVisibility(descriptionVisibility);
|
||||
description.setText(alarm.getDescription());
|
||||
|
||||
cbMonday.setChecked(alarm.getRepetition(Alarm.ALARM_MON));
|
||||
cbTuesday.setChecked(alarm.getRepetition(Alarm.ALARM_TUE));
|
||||
cbWednesday.setChecked(alarm.getRepetition(Alarm.ALARM_WED));
|
||||
@ -144,6 +156,14 @@ public class AlarmDetails extends AbstractGBActivity {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean supportsDescription() {
|
||||
if (device != null) {
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
|
||||
return coordinator.supportsAlarmDescription(device);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean supportsSnoozing() {
|
||||
if (device != null) {
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
|
||||
@ -170,6 +190,8 @@ public class AlarmDetails extends AbstractGBActivity {
|
||||
alarm.setRepetition(repetitionMask);
|
||||
alarm.setHour(timePicker.getCurrentHour());
|
||||
alarm.setMinute(timePicker.getCurrentMinute());
|
||||
alarm.setTitle(title.getText().toString());
|
||||
alarm.setDescription(description.getText().toString());
|
||||
DBHelper.store(alarm);
|
||||
}
|
||||
|
||||
|
@ -152,6 +152,11 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAlarmDescription(GBDevice device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsMusicInfo() {
|
||||
return false;
|
||||
|
@ -207,6 +207,12 @@ public interface DeviceCoordinator {
|
||||
*/
|
||||
boolean supportsAlarmSnoozing();
|
||||
|
||||
/**
|
||||
* Returns true if this device/coordinator supports alarm descriptions
|
||||
* @return
|
||||
*/
|
||||
boolean supportsAlarmDescription(GBDevice device);
|
||||
|
||||
/**
|
||||
* Returns true if the given device supports heart rate measurements.
|
||||
* @return
|
||||
|
@ -125,6 +125,11 @@ public class QHybridCoordinator extends AbstractDeviceCoordinator {
|
||||
return this.supportsAlarmConfiguration() ? 5 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAlarmDescription(GBDevice device) {
|
||||
return isHybridHR();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsSmartWakeup(GBDevice device) {
|
||||
return false;
|
||||
|
@ -52,4 +52,8 @@ public interface Alarm extends Serializable {
|
||||
int getHour();
|
||||
|
||||
int getMinute();
|
||||
|
||||
String getTitle();
|
||||
|
||||
String getDescription();
|
||||
}
|
@ -9,133 +9,153 @@
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true">
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_smart_wakeup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_smart_wakeup"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_snooze"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_snooze"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TimePicker
|
||||
android:id="@+id/alarm_time_picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleX="1"
|
||||
android:scaleY="1"
|
||||
android:layout_marginBottom="20dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dowSelector"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_monday"
|
||||
android:id="@+id/alarm_cb_smart_wakeup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_mon_short"
|
||||
android:text="@string/alarm_smart_wakeup"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_tuesday"
|
||||
android:id="@+id/alarm_cb_snooze"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_tue_short"
|
||||
android:text="@string/alarm_snooze"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_wednesday"
|
||||
android:layout_width="wrap_content"
|
||||
<EditText
|
||||
android:id="@+id/alarm_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_wed_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:ems="10"
|
||||
android:hint="Title"
|
||||
android:inputType="text"
|
||||
android:maxLength="32" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_thursday"
|
||||
android:layout_width="wrap_content"
|
||||
<EditText
|
||||
android:id="@+id/alarm_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_thu_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:ems="10"
|
||||
android:gravity="start|top"
|
||||
android:hint="Description"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLength="256"
|
||||
android:singleLine="false" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_friday"
|
||||
android:layout_width="wrap_content"
|
||||
<TimePicker
|
||||
android:id="@+id/alarm_time_picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_fri_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:layout_marginBottom="20dp"
|
||||
android:scaleX="1"
|
||||
android:scaleY="1" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_saturday"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/dowSelector"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_sat_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_sunday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_sun_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_monday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_mon_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_tuesday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_tue_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_wednesday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_wed_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_thursday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_thu_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_friday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_fri_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_saturday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_sat_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_sunday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_sun_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
Loading…
Reference in New Issue
Block a user