mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-11 01:21:56 +01:00
Remove the checkboxes in the alarms cardview and simplify layout of details activity
- rename the layout file of the alarm item to better organize the files - add a color selector for the item view, this replicates the old behavior of using the color to highlight enabled days - remove the nested linearlayouts in the alarm details activity layout and use CheckedTextView instead
This commit is contained in:
parent
1a88858c6f
commit
fe626eb11e
@ -21,8 +21,7 @@ import android.os.Bundle;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
import android.widget.CheckedTextView;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
@ -36,16 +35,15 @@ public class AlarmDetails extends GBActivity {
|
||||
|
||||
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;
|
||||
private CheckedTextView cbSmartWakeup;
|
||||
private CheckedTextView cbMonday;
|
||||
private CheckedTextView cbTuesday;
|
||||
private CheckedTextView cbWednesday;
|
||||
private CheckedTextView cbThursday;
|
||||
private CheckedTextView cbFriday;
|
||||
private CheckedTextView cbSaturday;
|
||||
private CheckedTextView cbSunday;
|
||||
private GBDevice device;
|
||||
private TextView smartAlarmLabel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -56,15 +54,56 @@ public class AlarmDetails extends GBActivity {
|
||||
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||
|
||||
timePicker = (TimePicker) findViewById(R.id.alarm_time_picker);
|
||||
smartAlarmLabel = (TextView) findViewById(R.id.alarm_label_smart_wakeup);
|
||||
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);
|
||||
cbSmartWakeup = (CheckedTextView) findViewById(R.id.alarm_cb_smart_wakeup);
|
||||
cbMonday = (CheckedTextView) findViewById(R.id.alarm_cb_monday);
|
||||
cbTuesday = (CheckedTextView) findViewById(R.id.alarm_cb_tuesday);
|
||||
cbWednesday = (CheckedTextView) findViewById(R.id.alarm_cb_wednesday);
|
||||
cbThursday = (CheckedTextView) findViewById(R.id.alarm_cb_thursday);
|
||||
cbFriday = (CheckedTextView) findViewById(R.id.alarm_cb_friday);
|
||||
cbSaturday = (CheckedTextView) findViewById(R.id.alarm_cb_saturday);
|
||||
cbSunday = (CheckedTextView) findViewById(R.id.alarm_cb_sunday);
|
||||
|
||||
|
||||
cbSmartWakeup.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
((CheckedTextView) v).toggle();
|
||||
}
|
||||
});
|
||||
cbMonday.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
((CheckedTextView) v).toggle();
|
||||
}
|
||||
});
|
||||
cbTuesday.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
((CheckedTextView) v).toggle();
|
||||
}
|
||||
});
|
||||
cbWednesday.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
((CheckedTextView) v).toggle();
|
||||
}
|
||||
});
|
||||
cbThursday.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
((CheckedTextView) v).toggle();
|
||||
}
|
||||
});
|
||||
cbFriday.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
((CheckedTextView) v).toggle();
|
||||
}
|
||||
});
|
||||
cbSaturday.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
((CheckedTextView) v).toggle();
|
||||
}
|
||||
});
|
||||
cbSunday.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
((CheckedTextView) v).toggle();
|
||||
}
|
||||
});
|
||||
|
||||
timePicker.setIs24HourView(DateFormat.is24HourFormat(GBApplication.getContext()));
|
||||
timePicker.setCurrentHour(alarm.getHour());
|
||||
@ -73,7 +112,6 @@ public class AlarmDetails extends GBActivity {
|
||||
cbSmartWakeup.setChecked(alarm.isSmartWakeup());
|
||||
int smartAlarmVisibility = supportsSmartWakeup() ? View.VISIBLE : View.GONE;
|
||||
cbSmartWakeup.setVisibility(smartAlarmVisibility);
|
||||
smartAlarmLabel.setVisibility(smartAlarmVisibility);
|
||||
|
||||
cbMonday.setChecked(alarm.getRepetition(GBAlarm.ALARM_MON));
|
||||
cbTuesday.setChecked(alarm.getRepetition(GBAlarm.ALARM_TUE));
|
||||
|
@ -93,7 +93,7 @@ public class GBAlarmListAdapter extends RecyclerView.Adapter<GBAlarmListAdapter.
|
||||
|
||||
@Override
|
||||
public GBAlarmListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.alarm_item, parent, false);
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_alarm, parent, false);
|
||||
ViewHolder vh = new ViewHolder(view);
|
||||
return vh;
|
||||
}
|
||||
|
5
app/src/main/res/color/alarm_dow.xml
Normal file
5
app/src/main/res/color/alarm_dow.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorAccent" android:state_checked="true" />
|
||||
<item android:color="?attr/textColorPrimary" />
|
||||
</selector>
|
@ -9,32 +9,21 @@
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.AlarmDetails">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<CheckBox
|
||||
<android.support.v7.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_smart_wakeup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm_label_smart_wakeup"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@id/alarm_cb_smart_wakeup"
|
||||
android:text="@string/alarm_smart_wakeup" />
|
||||
</LinearLayout>
|
||||
android:layout_marginStart="4dp"
|
||||
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_smart_wakeup"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TimePicker
|
||||
android:id="@+id/alarm_time_picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:timePickerMode="clock" />
|
||||
android:layout_marginBottom="20dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dowSelector"
|
||||
@ -43,174 +32,83 @@
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/alarm_cb_mon"
|
||||
<android.support.v7.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_monday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm_label_cb_mon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:labelFor="@id/alarm_cb_mon"
|
||||
android:text="@string/alarm_mon_short" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_mon_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/alarm_cb_tue"
|
||||
<android.support.v7.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_tuesday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm_label_cb_tue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:labelFor="@id/alarm_cb_tue"
|
||||
android:text="@string/alarm_tue_short" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_tue_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/alarm_cb_wed"
|
||||
<android.support.v7.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_wednesday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm_label_cb_wed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:labelFor="@id/alarm_cb_wed"
|
||||
android:text="@string/alarm_wed_short" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_wed_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/alarm_cb_thu"
|
||||
<android.support.v7.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_thursday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm_label_cb_thu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:labelFor="@id/alarm_cb_thu"
|
||||
android:text="@string/alarm_thu_short" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_thu_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/alarm_cb_fri"
|
||||
<android.support.v7.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_friday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm_label_cb_fri"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:labelFor="@id/alarm_cb_fri"
|
||||
android:text="@string/alarm_fri_short" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_fri_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/alarm_cb_sat"
|
||||
<android.support.v7.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_saturday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm_label_cb_sat"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:labelFor="@id/alarm_cb_sat"
|
||||
android:text="@string/alarm_sat_short" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_sat_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/alarm_cb_sun"
|
||||
<android.support.v7.widget.AppCompatCheckedTextView
|
||||
android:id="@+id/alarm_cb_sunday"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm_label_cb_sun"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:labelFor="@id/alarm_cb_sun"
|
||||
android:text="@string/alarm_sun_short" />
|
||||
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>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -25,7 +25,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:text="00:00"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
@ -43,7 +46,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true" />
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_margin="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dowSelector"
|
||||
@ -59,8 +63,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:textColor="@color/alarm_dow"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_mon_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
@ -71,8 +74,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:textColor="@color/alarm_dow"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_tue_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
@ -83,8 +85,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:textColor="@color/alarm_dow"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_wed_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
@ -95,8 +96,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:textColor="@color/alarm_dow"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_thu_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
@ -107,8 +107,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:textColor="@color/alarm_dow"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_fri_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
@ -119,8 +118,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:textColor="@color/alarm_dow"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_sat_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
@ -131,8 +129,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:textColor="@color/alarm_dow"
|
||||
android:gravity="center"
|
||||
android:text="@string/alarm_sun_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
Loading…
Reference in New Issue
Block a user