1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 09:17:29 +01:00

Get rid of the Checkedtextview because they weren't in line with the our style

This commit is contained in:
Daniele Gobbetti 2015-06-27 18:32:13 +02:00
parent 900511760c
commit 371a7bb4af
2 changed files with 232 additions and 178 deletions

View File

@ -5,8 +5,7 @@ import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.TimePicker; import android.widget.TimePicker;
import nodomain.freeyourgadget.gadgetbridge.GBAlarm; import nodomain.freeyourgadget.gadgetbridge.GBAlarm;
@ -17,17 +16,14 @@ public class AlarmDetails extends Activity {
private GBAlarm alarm; private GBAlarm alarm;
private TimePicker timePicker; private TimePicker timePicker;
//using CheckedTextView allows for vertically aligned text private CheckBox cbSmartWakeup;
private CheckedTextView ctvSmartWakeup; private CheckBox cbMonday;
private CheckedTextView ctvMonday; private CheckBox cbTuesday;
private CheckedTextView ctvTuesday; private CheckBox cbWednesday;
private CheckedTextView ctvWednesday; private CheckBox cbThursday;
private CheckedTextView ctvThursday; private CheckBox cbFriday;
private CheckedTextView ctvFriday; private CheckBox cbSaturday;
private CheckedTextView ctvSaturday; private CheckBox cbSunday;
private CheckedTextView ctvSunday;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -38,77 +34,28 @@ public class AlarmDetails extends Activity {
alarm = (GBAlarm) p; alarm = (GBAlarm) p;
timePicker = (TimePicker) findViewById(R.id.alarm_time_picker); timePicker = (TimePicker) findViewById(R.id.alarm_time_picker);
ctvSmartWakeup = (CheckedTextView) findViewById(R.id.alarm_ctv_smart_wakeup); cbSmartWakeup = (CheckBox) findViewById(R.id.alarm_cb_smart_wakeup);
ctvMonday = (CheckedTextView) findViewById(R.id.alarm_ctv_mon); cbMonday = (CheckBox) findViewById(R.id.alarm_cb_mon);
ctvTuesday = (CheckedTextView) findViewById(R.id.alarm_ctv_tue); cbTuesday = (CheckBox) findViewById(R.id.alarm_cb_tue);
ctvWednesday = (CheckedTextView) findViewById(R.id.alarm_ctv_wed); cbWednesday = (CheckBox) findViewById(R.id.alarm_cb_wed);
ctvThursday = (CheckedTextView) findViewById(R.id.alarm_ctv_thu); cbThursday = (CheckBox) findViewById(R.id.alarm_cb_thu);
ctvFriday = (CheckedTextView) findViewById(R.id.alarm_ctv_fri); cbFriday = (CheckBox) findViewById(R.id.alarm_cb_fri);
ctvSaturday = (CheckedTextView) findViewById(R.id.alarm_ctv_sat); cbSaturday = (CheckBox) findViewById(R.id.alarm_cb_sat);
ctvSunday = (CheckedTextView) findViewById(R.id.alarm_ctv_sun); cbSunday = (CheckBox) findViewById(R.id.alarm_cb_sun);
timePicker.setIs24HourView(DateFormat.is24HourFormat(GBApplication.getContext())); timePicker.setIs24HourView(DateFormat.is24HourFormat(GBApplication.getContext()));
timePicker.setCurrentHour(alarm.getHour()); timePicker.setCurrentHour(alarm.getHour());
timePicker.setCurrentMinute(alarm.getMinute()); timePicker.setCurrentMinute(alarm.getMinute());
ctvSmartWakeup.setChecked(alarm.isSmartWakeup()); cbSmartWakeup.setChecked(alarm.isSmartWakeup());
ctvSmartWakeup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((CheckedTextView) v).toggle();
}
});
ctvMonday.setChecked(alarm.getRepetition(GBAlarm.ALARM_MON)); cbMonday.setChecked(alarm.getRepetition(GBAlarm.ALARM_MON));
ctvTuesday.setChecked(alarm.getRepetition(GBAlarm.ALARM_TUE)); cbTuesday.setChecked(alarm.getRepetition(GBAlarm.ALARM_TUE));
ctvWednesday.setChecked(alarm.getRepetition(GBAlarm.ALARM_WED)); cbWednesday.setChecked(alarm.getRepetition(GBAlarm.ALARM_WED));
ctvThursday.setChecked(alarm.getRepetition(GBAlarm.ALARM_THU)); cbThursday.setChecked(alarm.getRepetition(GBAlarm.ALARM_THU));
ctvFriday.setChecked(alarm.getRepetition(GBAlarm.ALARM_FRI)); cbFriday.setChecked(alarm.getRepetition(GBAlarm.ALARM_FRI));
ctvSaturday.setChecked(alarm.getRepetition(GBAlarm.ALARM_SAT)); cbSaturday.setChecked(alarm.getRepetition(GBAlarm.ALARM_SAT));
ctvSunday.setChecked(alarm.getRepetition(GBAlarm.ALARM_SUN)); cbSunday.setChecked(alarm.getRepetition(GBAlarm.ALARM_SUN));
ctvMonday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((CheckedTextView) v).toggle();
}
});
ctvTuesday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((CheckedTextView) v).toggle();
}
});
ctvWednesday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((CheckedTextView) v).toggle();
}
});
ctvThursday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((CheckedTextView) v).toggle();
}
});
ctvFriday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((CheckedTextView) v).toggle();
}
});
ctvSaturday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((CheckedTextView) v).toggle();
}
});
ctvSunday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((CheckedTextView) v).toggle();
}
});
} }
@ -125,8 +72,8 @@ public class AlarmDetails extends Activity {
} }
private void updateAlarm() { private void updateAlarm() {
alarm.setSmartWakeup(ctvSmartWakeup.isChecked()); alarm.setSmartWakeup(cbSmartWakeup.isChecked());
alarm.setRepetition(ctvMonday.isChecked(), ctvTuesday.isChecked(), ctvWednesday.isChecked(), ctvThursday.isChecked(), ctvFriday.isChecked(), ctvSaturday.isChecked(), ctvSunday.isChecked()); alarm.setRepetition(cbMonday.isChecked(), cbTuesday.isChecked(), cbWednesday.isChecked(), cbThursday.isChecked(), cbFriday.isChecked(), cbSaturday.isChecked(), cbSunday.isChecked());
alarm.setHour(timePicker.getCurrentHour()); alarm.setHour(timePicker.getCurrentHour());
alarm.setMinute(timePicker.getCurrentMinute()); alarm.setMinute(timePicker.getCurrentMinute());
alarm.store(); alarm.store();

View File

@ -22,17 +22,31 @@
android:timePickerMode="clock" android:timePickerMode="clock"
android:layout_weight="1" /> android:layout_weight="1" />
<CheckedTextView <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/alarm_smart_wakeup"
android:orientation="vertical" android:orientation="vertical"
android:id="@+id/alarm_ctv_smart_wakeup" android:layout_width="wrap_content"
android:checked="false" android:layout_height="match_parent">
android:drawableTop="@drawable/abc_btn_check_material"
android:layout_gravity="center_vertical" <CheckBox
android:gravity="center_horizontal" android:layout_width="wrap_content"
android:layout_weight="1" /> android:layout_height="wrap_content"
android:id="@+id/alarm_cb_smart_wakeup"
android:layout_gravity="center_horizontal|bottom"
android:gravity="center_horizontal|bottom"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/alarm_smart_wakeup"
android:id="@+id/alarm_label_smart_wakeup"
android:layout_gravity="center_horizontal|top"
android:labelFor="@id/alarm_cb_smart_wakeup"
android:gravity="center_horizontal|top"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -41,103 +55,196 @@
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:id="@+id/dowSelector"> android:id="@+id/dowSelector">
<CheckedTextView <LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/alarm_mon_short"
android:orientation="vertical" android:orientation="vertical"
android:id="@+id/alarm_ctv_mon" android:layout_width="wrap_content"
android:checked="false" android:layout_height="match_parent"
android:clickable="true" android:layout_weight="1">
android:focusable="true"
android:drawableTop="@drawable/abc_btn_check_material"
android:layout_weight="1"
android:enabled="true"
android:gravity="center_horizontal" />
<CheckedTextView <CheckBox
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:text="@string/alarm_tue_short" android:id="@+id/alarm_cb_mon"
android:orientation="vertical" android:layout_gravity="center_horizontal|bottom"
android:id="@+id/alarm_ctv_tue" android:gravity="center_horizontal|bottom"
android:checked="false" android:layout_weight="1" />
android:clickable="true"
android:focusable="true"
android:drawableTop="@drawable/abc_btn_check_material"
android:layout_weight="1"
android:enabled="true"
android:gravity="center_horizontal" />
<CheckedTextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:text="@string/alarm_wed_short" android:textAppearance="?android:attr/textAppearanceMedium"
android:orientation="vertical" android:text="@string/alarm_mon_short"
android:id="@+id/alarm_ctv_wed" android:id="@+id/alarm_label_cb_mon"
android:checked="false" android:layout_gravity="center_horizontal|top"
android:clickable="true" android:labelFor="@id/alarm_cb_mon"
android:focusable="true" android:gravity="center_horizontal|top"
android:drawableTop="@drawable/abc_btn_check_material" android:layout_weight="1" />
android:layout_weight="1"
android:enabled="true"
android:gravity="center_horizontal" />
<CheckedTextView </LinearLayout>
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/alarm_thu_short"
android:orientation="vertical"
android:id="@+id/alarm_ctv_thu"
android:checked="false"
android:clickable="true"
android:focusable="true"
android:drawableTop="@drawable/abc_btn_check_material"
android:layout_weight="1"
android:enabled="true"
android:gravity="center_horizontal" />
<CheckedTextView <LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/alarm_fri_short"
android:orientation="vertical" android:orientation="vertical"
android:id="@+id/alarm_ctv_fri" android:layout_width="wrap_content"
android:checked="false" android:layout_height="match_parent"
android:clickable="true" android:layout_weight="1">
android:focusable="true"
android:drawableTop="@drawable/abc_btn_check_material"
android:layout_weight="1"
android:enabled="true"
android:gravity="center_horizontal" />
<CheckedTextView <CheckBox
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:text="@string/alarm_sat_short" android:id="@+id/alarm_cb_tue"
android:orientation="vertical" android:layout_gravity="center_horizontal|bottom"
android:id="@+id/alarm_ctv_sat" android:gravity="center_horizontal|bottom"
android:checked="false" android:layout_weight="1" />
android:clickable="true"
android:focusable="true"
android:drawableTop="@drawable/abc_btn_check_material"
android:layout_weight="1"
android:enabled="true"
android:gravity="center_horizontal" />
<CheckedTextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:text="@string/alarm_sun_short" android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/alarm_tue_short"
android:id="@+id/alarm_label_cb_tue"
android:layout_gravity="center_horizontal|top"
android:labelFor="@id/alarm_cb_tue"
android:gravity="center_horizontal|top"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:id="@+id/alarm_ctv_sun" android:layout_width="wrap_content"
android:checked="false" android:layout_height="match_parent"
android:clickable="true" android:layout_weight="1">
android:focusable="true"
android:drawableTop="@drawable/abc_btn_check_material" <CheckBox
android:layout_weight="1" android:layout_width="wrap_content"
android:enabled="true" android:layout_height="wrap_content"
android:gravity="center_horizontal" /> android:id="@+id/alarm_cb_wed"
android:layout_gravity="center_horizontal|bottom"
android:gravity="center_horizontal|bottom"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/alarm_wed_short"
android:id="@+id/alarm_label_cb_wed"
android:layout_gravity="center_horizontal|top"
android:labelFor="@id/alarm_cb_wed"
android:gravity="center_horizontal|top"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/alarm_cb_thu"
android:layout_gravity="center_horizontal|bottom"
android:gravity="center_horizontal|bottom"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/alarm_thu_short"
android:id="@+id/alarm_label_cb_thu"
android:layout_gravity="center_horizontal|top"
android:labelFor="@id/alarm_cb_thu"
android:gravity="center_horizontal|top"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/alarm_cb_fri"
android:layout_gravity="center_horizontal|bottom"
android:gravity="center_horizontal|bottom"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/alarm_fri_short"
android:id="@+id/alarm_label_cb_fri"
android:layout_gravity="center_horizontal|top"
android:labelFor="@id/alarm_cb_fri"
android:gravity="center_horizontal|top"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/alarm_cb_sat"
android:layout_gravity="center_horizontal|bottom"
android:gravity="center_horizontal|bottom"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/alarm_sat_short"
android:id="@+id/alarm_label_cb_sat"
android:layout_gravity="center_horizontal|top"
android:labelFor="@id/alarm_cb_sat"
android:gravity="center_horizontal|top"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/alarm_cb_sun"
android:layout_gravity="center_horizontal|bottom"
android:gravity="center_horizontal|bottom"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/alarm_sun_short"
android:id="@+id/alarm_label_cb_sun"
android:layout_gravity="center_horizontal|top"
android:labelFor="@id/alarm_cb_sun"
android:gravity="center_horizontal|top"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout> </LinearLayout>