From fe626eb11e448a0539f67fea5bdbad7db9d26fb0 Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Sun, 9 Apr 2017 16:01:48 +0200 Subject: [PATCH] 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 --- .../gadgetbridge/activities/AlarmDetails.java | 80 ++++-- .../adapter/GBAlarmListAdapter.java | 2 +- app/src/main/res/color/alarm_dow.xml | 5 + .../res/layout/activity_alarm_details.xml | 236 +++++------------- .../layout/{alarm_item.xml => item_alarm.xml} | 29 +-- 5 files changed, 145 insertions(+), 207 deletions(-) create mode 100644 app/src/main/res/color/alarm_dow.xml rename app/src/main/res/layout/{alarm_item.xml => item_alarm.xml} (85%) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AlarmDetails.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AlarmDetails.java index d14db9dc6..543673de3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AlarmDetails.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AlarmDetails.java @@ -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)); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBAlarmListAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBAlarmListAdapter.java index a63606d14..92292aca3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBAlarmListAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBAlarmListAdapter.java @@ -93,7 +93,7 @@ public class GBAlarmListAdapter extends RecyclerView.Adapter + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_alarm_details.xml b/app/src/main/res/layout/activity_alarm_details.xml index 5cc1b4703..276e8d003 100644 --- a/app/src/main/res/layout/activity_alarm_details.xml +++ b/app/src/main/res/layout/activity_alarm_details.xml @@ -9,32 +9,21 @@ android:paddingTop="@dimen/activity_vertical_margin" tools:context="nodomain.freeyourgadget.gadgetbridge.activities.AlarmDetails"> - - - - - - - + android:layout_marginStart="4dp" + android:drawableStart="?android:attr/listChoiceIndicatorMultiple" + android:gravity="center" + android:text="@string/alarm_smart_wakeup" + android:textAppearance="?android:attr/textAppearanceSmall" /> + android:layout_marginBottom="20dp" /> - - - - - - - - - + android:drawableTop="?android:attr/listChoiceIndicatorMultiple" + android:gravity="center" + android:text="@string/alarm_mon_short" + android:textAppearance="?android:attr/textAppearanceSmall" /> - - - - - - - + android:drawableTop="?android:attr/listChoiceIndicatorMultiple" + android:gravity="center" + android:text="@string/alarm_tue_short" + android:textAppearance="?android:attr/textAppearanceSmall" /> - - - - - - - + android:drawableTop="?android:attr/listChoiceIndicatorMultiple" + android:gravity="center" + android:text="@string/alarm_wed_short" + android:textAppearance="?android:attr/textAppearanceSmall" /> - - - - - - - + android:drawableTop="?android:attr/listChoiceIndicatorMultiple" + android:gravity="center" + android:text="@string/alarm_thu_short" + android:textAppearance="?android:attr/textAppearanceSmall" /> - - - - - - - + android:drawableTop="?android:attr/listChoiceIndicatorMultiple" + android:gravity="center" + android:text="@string/alarm_fri_short" + android:textAppearance="?android:attr/textAppearanceSmall" /> - - - - - - - - - - - - - + android:drawableTop="?android:attr/listChoiceIndicatorMultiple" + android:gravity="center" + android:text="@string/alarm_sat_short" + android:textAppearance="?android:attr/textAppearanceSmall" /> + - diff --git a/app/src/main/res/layout/alarm_item.xml b/app/src/main/res/layout/item_alarm.xml similarity index 85% rename from app/src/main/res/layout/alarm_item.xml rename to app/src/main/res/layout/item_alarm.xml index 470abf959..875b5f469 100644 --- a/app/src/main/res/layout/alarm_item.xml +++ b/app/src/main/res/layout/item_alarm.xml @@ -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" /> @@ -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" />