Layout change for alarm management page
Bug: 16323495
Change-Id: Iab6fb1fd99b2af8d8bad86ad5df01ad89aa91975
diff --git a/res/layout/alarm_time.xml b/res/layout/alarm_time.xml
index 83b60a1..6d9a559 100644
--- a/res/layout/alarm_time.xml
+++ b/res/layout/alarm_time.xml
@@ -15,212 +15,221 @@
-->
<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:dc="http://schemas.android.com/apk/res-auto"
-
android:id="@+id/alarm_item"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+
+ xmlns:dc="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:gravity="center_horizontal|top"
android:background="@drawable/item_background"
- android:clickable="true" >
+ android:gravity="center_horizontal|top"
+ android:orientation="vertical">
+ <!-- TODO~: flatten this layout using gridLayout which supports layout_weight as of 21 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="12dp"
- android:layout_marginStart="12dp"
- android:layout_marginRight="12dp"
android:layout_marginEnd="12dp"
+ android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:orientation="horizontal">
- <com.android.deskclock.widget.TextTime
- android:id="@+id/digital_clock"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/medium_light"
- android:textSize="@dimen/alarm_time_font_size"
- android:textColor="@color/clock_white"
- android:baselineAligned="true"
- android:layout_gravity="center"
- android:gravity="center"
- dc:format12Hour="@string/alarm_time_12_hours_format"
- dc:format24Hour="@string/clock_24_hours_format"/>
- <Space
- android:layout_height="match_parent"
- android:layout_width="0dip"
- android:layout_weight="1"/>
- <Switch
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:id="@+id/onoff"
- android:thumbTextPadding="10dp"
- android:layout_gravity="center_vertical|end"/>
- </LinearLayout>
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
- <ImageView
- android:id="@+id/delete"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="8dp"
- android:paddingBottom="8dp"
- android:paddingRight="8dp"
- android:paddingEnd="8dp"
- android:paddingLeft="8dp"
- android:paddingStart="8dp"
- android:contentDescription="@string/delete_alarm"
- android:src="@drawable/ic_delete"
- android:layout_gravity="top|end" />
+
<LinearLayout
- android:id="@+id/expand_area"
- android:orientation="vertical"
- android:layout_width="match_parent"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:visibility="gone"
- android:layout_marginBottom="@dimen/collapse_expand_height"
- android:layout_gravity="bottom" >
+ android:layout_gravity="center"
+ android:orientation="vertical">
+
<TextView
- android:id="@+id/edit_label"
- style="@style/body_not_caps"
- android:textColor="@color/clock_gray"
- android:hint="@string/label"
+ android:id="@+id/tomorrowLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginRight="16dp"
- android:layout_marginEnd="16dp"
- android:paddingRight="12dp"
- android:paddingEnd="12dp"
- android:paddingLeft="18dp"
- android:paddingStart="18dp"
- android:paddingTop="12dp"
- android:paddingBottom="12dp"
- android:ellipsize="end"
- android:singleLine="true"
- android:background="@drawable/item_background" />
+ android:textColor="@color/clock_white" />
+
+ <com.android.deskclock.widget.TextTime
+ android:id="@+id/digital_clock"
+ style="@style/medium_light"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textColor="@color/clock_white"
+ android:textSize="@dimen/alarm_time_font_size"
+ dc:format12Hour="@string/alarm_time_12_hours_format"
+ dc:format24Hour="@string/clock_24_hours_format" />
+ </LinearLayout>
+
+ <Space
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ <Switch
+ android:id="@+id/onoff"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|end" />
+ </LinearLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout
+ android:id="@+id/expand_area"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:layout_marginBottom="@dimen/collapse_expand_height"
+ android:orientation="vertical"
+ android:visibility="gone">
+
<CheckBox
android:id="@+id/repeat_onoff"
- android:text="@string/alarm_repeat"
- android:layout_height="48dp"
- android:layout_width="wrap_content"
- android:layout_marginLeft="10dp"
- android:layout_marginStart="10dp"
- android:layout_marginRight="16dp"
- android:layout_marginEnd="16dp"
- android:layout_gravity="center_vertical|start"
style="@style/body"
- android:textColor="@color/clock_white"/>
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_gravity="center_vertical|start"
+ android:layout_marginEnd="16dp"
+ android:layout_marginStart="10dp"
+ android:text="@string/alarm_repeat"
+ android:textColor="@color/clock_white" />
+
<LinearLayout
android:id="@+id/repeat_days"
android:layout_width="match_parent"
android:layout_height="48dp"
- android:layout_marginLeft="10dp"
- android:layout_marginStart="10dp"
- android:layout_marginRight="10dp"
- android:layout_marginEnd="10dp"
android:layout_gravity="top"
+ android:layout_marginEnd="10dp"
+ android:layout_marginStart="10dp"
android:orientation="horizontal"
android:visibility="gone">
<!-- Day buttons are put here programatically -->
</LinearLayout>
+
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="64dp"
- android:layout_marginLeft="10dp"
- android:layout_marginStart="10dp"
- android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
+ android:layout_marginStart="10dp"
android:gravity="center_vertical">
+
<TextView
android:id="@+id/choose_ringtone"
- android:layout_height="match_parent"
- android:layout_width="wrap_content"
- android:layout_marginRight="16dp"
- android:layout_marginEnd="16dp"
- android:gravity="center_vertical"
- android:textAlignment="viewStart"
style="@style/body"
- android:background="@drawable/item_background"
- android:clickable="true"
- android:textColor="@color/clock_white"
- android:ellipsize="marquee"
- android:scrollHorizontally="true"
- android:singleLine="true"
- android:marqueeRepeatLimit="marquee_forever"
- android:drawableLeft="@drawable/ic_ringtone"
- android:drawableStart="@drawable/ic_ringtone"
- android:drawablePadding="2dp"
- android:layout_alignParentLeft="true"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
android:layout_alignParentStart="true"
+ android:layout_marginEnd="16dp"
android:layout_toLeftOf="@+id/vibrate_onoff"
android:layout_toStartOf="@+id/vibrate_onoff"
+ android:background="@drawable/item_background"
+ android:clickable="true"
+ android:drawablePadding="2dp"
+ android:drawableStart="@drawable/ic_ringtone"
+ android:ellipsize="marquee"
+ android:gravity="center_vertical"
+ android:marqueeRepeatLimit="marquee_forever"
+ android:scrollHorizontally="true"
+ android:singleLine="true"
+ android:textAlignment="viewStart"
+ android:textColor="@color/clock_white"
/>
+
<CheckBox
android:id="@+id/vibrate_onoff"
- android:text="@string/alarm_vibrate"
- android:includeFontPadding="false"
- android:textColor="@color/clock_gray"
- android:layout_height="wrap_content"
+ style="@style/body"
android:layout_width="wrap_content"
- android:layout_alignParentRight="true"
+ android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
- style="@style/body"/>
+ android:includeFontPadding="false"
+ android:text="@string/alarm_vibrate"
+ android:textColor="@color/clock_gray" />
</RelativeLayout>
+
+ <TextView
+ android:id="@+id/edit_label"
+ style="@style/body_not_caps"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="16dp"
+ android:ellipsize="end"
+ android:hint="@string/label"
+ android:paddingBottom="12dp"
+ android:paddingEnd="12dp"
+ android:paddingLeft="18dp"
+ android:paddingRight="12dp"
+ android:paddingStart="18dp"
+ android:paddingTop="12dp"
+ android:singleLine="true"
+ android:textColor="@color/clock_gray" />
</LinearLayout>
+
<FrameLayout
android:id="@+id/collapse_expand"
android:layout_width="match_parent"
android:layout_height="@dimen/collapse_expand_height"
- android:contentDescription="@string/collapse_alarm"
- android:layout_gravity="bottom" >
+ android:layout_gravity="bottom"
+ android:contentDescription="@string/collapse_alarm">
+
<ImageView
- android:id="@+id/arrow"
- android:layout_width="48dp"
- android:layout_height="32dp"
- android:src="@drawable/ic_expand_down"
+ android:id="@+id/delete"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
- android:contentDescription="@string/expand_alarm" />
+ android:contentDescription="@string/delete_alarm"
+ android:padding="8dp"
+ android:src="@drawable/ic_delete" />
+
<View
android:id="@+id/hairline"
- android:layout_height="1dp"
- android:layout_marginLeft="8dp"
- android:layout_marginStart="8dp"
- android:layout_marginRight="8dp"
- android:layout_marginEnd="8dp"
android:layout_width="match_parent"
- android:background="#28ffffff"
- android:layout_gravity="bottom" />
+ android:layout_height="1dp"
+ android:layout_gravity="bottom"
+ android:layout_marginEnd="8dp"
+ android:layout_marginStart="8dp"
+ android:background="#28ffffff" />
+
<com.android.deskclock.widget.EllipsizeLayout
android:id="@+id/summary"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginLeft="48dp"
- android:layout_marginStart="48dp"
- android:layout_marginRight="104dp"
android:layout_marginEnd="104dp"
- android:gravity="center_vertical" >
- <TextView android:id="@+id/label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/alarm_label_not_caps"
- android:textColor="@color/clock_gray"
- android:ellipsize="end"
- android:singleLine="true" />
- <TextView android:id="@+id/daysOfWeek"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- style="@style/alarm_label_bold"
- android:textColor="@color/clock_white"
- android:ellipsize="none"
- android:singleLine="true" />
+ android:layout_marginStart="16dp"
+ android:gravity="center_vertical">
+
+ <TextView
+ android:id="@+id/label"
+ style="@style/alarm_label_not_caps"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:textColor="@color/clock_gray" />
+
+ <TextView
+ android:id="@+id/daysOfWeek"
+ style="@style/alarm_label_bold"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="none"
+ android:singleLine="true"
+ android:textColor="@color/clock_white" />
</com.android.deskclock.widget.EllipsizeLayout>
+
+ <ImageView
+ android:id="@+id/arrow"
+ android:layout_width="48dp"
+ android:layout_height="32dp"
+ android:layout_gravity="end|center_vertical"
+ android:contentDescription="@string/expand_alarm"
+ android:src="@drawable/ic_expand_down" />
</FrameLayout>
</FrameLayout>
- <View android:id="@+id/alarm_footer_filler"
- android:visibility="gone"
+
+ <View
+ android:id="@+id/alarm_footer_filler"
android:layout_width="match_parent"
- android:layout_height="@dimen/button_footer_height" />
+ android:layout_height="@dimen/button_footer_height"
+ android:visibility="gone" />
</LinearLayout>
diff --git a/src/com/android/deskclock/AlarmClockFragment.java b/src/com/android/deskclock/AlarmClockFragment.java
index 16d489c..0567b75 100644
--- a/src/com/android/deskclock/AlarmClockFragment.java
+++ b/src/com/android/deskclock/AlarmClockFragment.java
@@ -54,6 +54,7 @@
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CursorAdapter;
+import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
@@ -711,6 +712,7 @@
// views for optimization
LinearLayout alarmItem;
TextTime clock;
+ TextView tomorrowLabel;
Switch onoff;
TextView daysOfWeek;
TextView label;
@@ -978,6 +980,7 @@
// standard view holder optimization
final ItemHolder holder = new ItemHolder();
holder.alarmItem = (LinearLayout) view.findViewById(R.id.alarm_item);
+ holder.tomorrowLabel = (TextView) view.findViewById(R.id.tomorrowLabel);
holder.clock = (TextTime) view.findViewById(R.id.digital_clock);
holder.onoff = (Switch) view.findViewById(R.id.onoff);
holder.onoff.setTypeface(mRobotoNormal);
@@ -1075,11 +1078,23 @@
}
};
+ if (mRepeatChecked.contains(alarm.id) || itemHolder.alarm.daysOfWeek.isRepeating()) {
+ itemHolder.tomorrowLabel.setVisibility(View.GONE);
+ } else {
+ itemHolder.tomorrowLabel.setVisibility(View.VISIBLE);
+ final Resources resources = getResources();
+ final String labelText = isTomorrow(alarm) ?
+ resources.getString(R.string.alarm_tomorrow) :
+ resources.getString(R.string.alarm_today);
+ itemHolder.tomorrowLabel.setText(labelText);
+ }
itemHolder.onoff.setOnCheckedChangeListener(onOffListener);
boolean expanded = isAlarmExpanded(alarm);
itemHolder.expandArea.setVisibility(expanded? View.VISIBLE : View.GONE);
+ itemHolder.delete.setVisibility(expanded ? View.VISIBLE : View.GONE);
itemHolder.summary.setVisibility(expanded? View.GONE : View.VISIBLE);
+ itemHolder.hairLine.setVisibility(expanded ? View.GONE : View.VISIBLE);
String labelSpace = "";
// Set the repeat text or leave it blank if it does not repeat.
@@ -1154,6 +1169,14 @@
});
}
+ private boolean isTomorrow(Alarm alarm) {
+ final Calendar now = Calendar.getInstance();
+ final int alarmHour = alarm.hour;
+ final int currHour = now.get(Calendar.HOUR_OF_DAY);
+ return alarmHour < currHour ||
+ (alarmHour == currHour && alarm.minutes < now.get(Calendar.MINUTE));
+ }
+
private void bindExpandArea(final ItemHolder itemHolder, final Alarm alarm) {
// Views in here are not bound until the item is expanded.
@@ -1164,6 +1187,7 @@
itemHolder.clickableLabel.setText(R.string.label);
itemHolder.clickableLabel.setTextColor(mColorDim);
}
+
itemHolder.clickableLabel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -1299,6 +1323,7 @@
holder.expandArea.setAlpha(alpha);
holder.delete.setAlpha(alpha);
holder.daysOfWeek.setAlpha(alpha);
+ holder.tomorrowLabel.setAlpha(alpha);
}
private void updateDaysOfWeekButtons(ItemHolder holder, DaysOfWeek daysOfWeek) {
@@ -1390,27 +1415,11 @@
// Set the expand area to visible so we can measure the height to animate to.
itemHolder.alarmItem.setBackgroundColor(mBackgroundColorExpanded);
itemHolder.expandArea.setVisibility(View.VISIBLE);
+ itemHolder.delete.setVisibility(View.VISIBLE);
if (!animate) {
// Set the "end" layout and don't do the animation.
itemHolder.arrow.setRotation(180);
- // We need to translate the hairline up, so the height of the collapseArea
- // needs to be measured to know how high to translate it.
- final ViewTreeObserver observer = mAlarmsList.getViewTreeObserver();
- observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
- @Override
- public boolean onPreDraw() {
- // We don't want to continue getting called for every listview drawing.
- if (observer.isAlive()) {
- observer.removeOnPreDrawListener(this);
- }
- int hairlineHeight = itemHolder.hairLine.getHeight();
- int collapseHeight =
- itemHolder.collapseExpandArea.getHeight() - hairlineHeight;
- itemHolder.hairLine.setTranslationY(-collapseHeight);
- return true;
- }
- });
return;
}
@@ -1436,8 +1445,6 @@
final int endingHeight = itemHolder.alarmItem.getHeight();
final int distance = endingHeight - startingHeight;
final int collapseHeight = itemHolder.collapseExpandArea.getHeight();
- int hairlineHeight = itemHolder.hairLine.getHeight();
- final int hairlineDistance = collapseHeight - hairlineHeight;
// Set the height back to the start state of the animation.
itemHolder.alarmItem.getLayoutParams().height = startingHeight;
@@ -1469,8 +1476,8 @@
expandParams.setMargins(
0, (int) -((1 - value) * distance), 0, collapseHeight);
itemHolder.arrow.setRotation(180 * value);
- itemHolder.hairLine.setTranslationY(-hairlineDistance * value);
itemHolder.summary.setAlpha(1 - value);
+ itemHolder.hairLine.setAlpha(1 - value);
itemHolder.alarmItem.requestLayout();
}
@@ -1483,8 +1490,9 @@
itemHolder.alarmItem.getLayoutParams().height =
LayoutParams.WRAP_CONTENT;
itemHolder.arrow.setRotation(180);
- itemHolder.hairLine.setTranslationY(-hairlineDistance);
itemHolder.summary.setVisibility(View.GONE);
+ itemHolder.hairLine.setVisibility(View.GONE);
+ itemHolder.delete.setVisibility(View.VISIBLE);
}
@Override
@@ -1548,12 +1556,12 @@
// Calculate some values to help with the animation.
final int endingHeight = itemHolder.alarmItem.getHeight();
final int distance = endingHeight - startingHeight;
- int hairlineHeight = itemHolder.hairLine.getHeight();
- final int hairlineDistance = mCollapseExpandHeight - hairlineHeight;
// Re-set the visibilities for the start state of the animation.
itemHolder.expandArea.setVisibility(View.VISIBLE);
+ itemHolder.delete.setVisibility(View.GONE);
itemHolder.summary.setVisibility(View.VISIBLE);
+ itemHolder.hairLine.setVisibility(View.VISIBLE);
itemHolder.summary.setAlpha(1);
// Set up the animator to animate the expansion.
@@ -1572,8 +1580,9 @@
expandParams.setMargins(
0, (int) (value * distance), 0, mCollapseExpandHeight);
itemHolder.arrow.setRotation(180 * (1 - value));
- itemHolder.hairLine.setTranslationY(-hairlineDistance * (1 - value));
+ itemHolder.delete.setAlpha(value);
itemHolder.summary.setAlpha(value);
+ itemHolder.hairLine.setAlpha(value);
itemHolder.alarmItem.requestLayout();
}
@@ -1593,7 +1602,6 @@
itemHolder.expandArea.setVisibility(View.GONE);
itemHolder.arrow.setRotation(0);
- itemHolder.hairLine.setTranslationY(0);
}
@Override