diff options
author | Patrick Scott <phanna@android.com> | 2009-11-23 14:46:44 -0500 |
---|---|---|
committer | Patrick Scott <phanna@android.com> | 2009-11-30 15:56:10 -0500 |
commit | 90c4833f94f4775f747333f8bd67107364a1d9c1 (patch) | |
tree | c81e0a814968eed0900ca38e78f67cca31513af7 | |
parent | 77f3d897765faaa640add814852c7b4ccee33655 (diff) | |
download | android_packages_apps_DeskClock-90c4833f94f4775f747333f8bd67107364a1d9c1.tar.gz android_packages_apps_DeskClock-90c4833f94f4775f747333f8bd67107364a1d9c1.tar.bz2 android_packages_apps_DeskClock-90c4833f94f4775f747333f8bd67107364a1d9c1.zip |
UI changes based on feedback from Jeff and Amar.
Bug: 2278206
-rw-r--r-- | res/drawable-hdpi/ic_clock_strip_desk_clock.png | bin | 0 -> 3513 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_clock_strip_desk_clock.png | bin | 0 -> 2110 bytes | |||
-rw-r--r-- | res/drawable/clock_selector.xml | 22 | ||||
-rw-r--r-- | res/drawable/indicator_clock_onoff.xml | 2 | ||||
-rw-r--r-- | res/layout/alarm_clock.xml | 6 | ||||
-rw-r--r-- | res/layout/alarm_time.xml | 12 | ||||
-rw-r--r-- | res/layout/save_cancel_alarm.xml | 7 | ||||
-rw-r--r-- | res/values/strings.xml | 8 | ||||
-rw-r--r-- | res/values/styles.xml | 2 | ||||
-rw-r--r-- | res/xml/alarm_prefs.xml | 17 | ||||
-rw-r--r-- | src/com/android/deskclock/AlarmClock.java | 20 | ||||
-rw-r--r-- | src/com/android/deskclock/DontPressWithParentLayout.java | 43 | ||||
-rw-r--r-- | src/com/android/deskclock/SetAlarm.java | 45 |
13 files changed, 142 insertions, 42 deletions
diff --git a/res/drawable-hdpi/ic_clock_strip_desk_clock.png b/res/drawable-hdpi/ic_clock_strip_desk_clock.png Binary files differnew file mode 100644 index 000000000..ddc2d317d --- /dev/null +++ b/res/drawable-hdpi/ic_clock_strip_desk_clock.png diff --git a/res/drawable-mdpi/ic_clock_strip_desk_clock.png b/res/drawable-mdpi/ic_clock_strip_desk_clock.png Binary files differnew file mode 100644 index 000000000..76ebbd21c --- /dev/null +++ b/res/drawable-mdpi/ic_clock_strip_desk_clock.png diff --git a/res/drawable/clock_selector.xml b/res/drawable/clock_selector.xml new file mode 100644 index 000000000..efc9e5bde --- /dev/null +++ b/res/drawable/clock_selector.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="false" + android:drawable="@android:color/background_dark" /> + <item android:state_pressed="true" + android:drawable="@*android:drawable/list_selector_background_pressed" /> +</selector> diff --git a/res/drawable/indicator_clock_onoff.xml b/res/drawable/indicator_clock_onoff.xml index 3fea6c099..e3a2d8d1f 100644 --- a/res/drawable/indicator_clock_onoff.xml +++ b/res/drawable/indicator_clock_onoff.xml @@ -15,7 +15,7 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_selected="true" android:state_window_focused="true" + <item android:state_pressed="true" android:state_window_focused="true" android:drawable="@drawable/ic_clock_alarm_selected" /> <item android:drawable="@drawable/ic_clock_alarm_on" /> </selector> diff --git a/res/layout/alarm_clock.xml b/res/layout/alarm_clock.xml index 6e702596f..a66fd594d 100644 --- a/res/layout/alarm_clock.xml +++ b/res/layout/alarm_clock.xml @@ -26,8 +26,6 @@ android:background="@android:drawable/list_selector_background" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:paddingTop="4dip" - android:paddingBottom="4dip" android:orientation="horizontal"> <ImageView @@ -41,7 +39,7 @@ android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center_vertical" - android:textAppearance="?android:attr/textAppearanceMedium" + android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="?android:attr/textColorPrimary" android:text="@string/add_alarm" /> @@ -69,7 +67,7 @@ style="@style/ButtonStripLeft" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_menu_desk_clock" + android:src="@drawable/ic_clock_strip_desk_clock" android:contentDescription="@string/desk_clock_button_description"/> <com.android.deskclock.DigitalClock diff --git a/res/layout/alarm_time.xml b/res/layout/alarm_time.xml index 9f8c12a6f..5c3b19b78 100644 --- a/res/layout/alarm_time.xml +++ b/res/layout/alarm_time.xml @@ -16,8 +16,6 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:paddingTop="4dip" - android:paddingBottom="4dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> @@ -30,13 +28,16 @@ minimum height. If the bar is a checkbox, it is too tall and is clipped on the right. --> - <LinearLayout android:id="@+id/indicator" + <com.android.deskclock.DontPressWithParentLayout android:id="@+id/indicator" style="@style/alarm_list_left_column" + android:background="@drawable/clock_selector" android:gravity="center" android:orientation="vertical"> <CheckBox android:id="@+id/clock_onoff" android:focusable="false" + android:clickable="false" android:background="@drawable/indicator_clock_onoff" + android:duplicateParentState="true" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center" @@ -47,12 +48,15 @@ android:layout_gravity="center" android:paddingTop="4dip" android:src="@drawable/ic_indicator_off" /> - </LinearLayout> + </com.android.deskclock.DontPressWithParentLayout> <ImageView android:src="@*android:drawable/divider_vertical_dark" + android:background="?android:attr/windowBackground" android:layout_width="wrap_content" android:layout_height="fill_parent" + android:paddingTop="4dip" + android:paddingBottom="4dip" android:scaleType="fitXY" android:gravity="fill_vertical" /> diff --git a/res/layout/save_cancel_alarm.xml b/res/layout/save_cancel_alarm.xml index 73e9f84b2..837d95194 100644 --- a/res/layout/save_cancel_alarm.xml +++ b/res/layout/save_cancel_alarm.xml @@ -34,4 +34,11 @@ android:layout_weight="1" android:text="@string/revert"/> + <Button android:id="@+id/alarm_delete" + android:focusable="true" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_weight="1" + android:text="@string/delete"/> + </LinearLayout> diff --git a/res/values/strings.xml b/res/values/strings.xml index 574b45c9e..1cf4057c8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -35,7 +35,10 @@ <string name="delete_alarm">Delete alarm</string> <!-- Context Menu Item on Alarm Settings screen: Enable alarm --> - <string name="enable_alarm">Turn alarm on/off</string> + <string name="enable_alarm">Turn alarm on</string> + + <!-- Context Menu Item on Alarm Settings screen: Disable alarm --> + <string name="disable_alarm">Turn alarm off</string> <!-- Delete alarm confirmation dialog message. --> <string name="delete_alarm_confirm">This alarm will be deleted.</string> @@ -187,6 +190,9 @@ <!-- Revert button when editing an alarm. --> <string name="revert">Revert</string> + <!-- Delete button when editing an alarm. --> + <string name="delete">Delete</string> + <!-- Setting title for changing the alarm volume. --> <string name="alarm_volume_title">Alarm volume</string> diff --git a/res/values/styles.xml b/res/values/styles.xml index 3cfb5c99a..edacfeac4 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -55,6 +55,6 @@ <style name="alarm_list_left_column"> <item name="android:layout_width">68dip</item> - <item name="android:layout_height">60dip</item> + <item name="android:layout_height">68dip</item> </style> </resources> diff --git a/res/xml/alarm_prefs.xml b/res/xml/alarm_prefs.xml index 3619836f1..b70a0b8dd 100644 --- a/res/xml/alarm_prefs.xml +++ b/res/xml/alarm_prefs.xml @@ -16,23 +16,26 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:title="@string/set_alarm"> - <Preference android:key="time" + <CheckBoxPreference android:key="enabled" + android:persistent="false" + android:title="@string/enable_alarm" /> + <Preference android:key="time" android:persistent="false" android:title="@string/time"/> + <com.android.deskclock.RepeatPreference + android:persistent="false" + android:key="setRepeat" + android:title="@string/alarm_repeat" /> <com.android.deskclock.AlarmPreference - android:key="alarm" + android:key="alarm" android:title="@string/alert" android:ringtoneType="alarm|ringtone" android:persistent="false" android:showDefault="false" android:showSilent="true" /> - <CheckBoxPreference android:key="vibrate" + <CheckBoxPreference android:key="vibrate" android:persistent="false" android:title="@string/alarm_vibrate"/> - <com.android.deskclock.RepeatPreference - android:persistent="false" - android:key="setRepeat" - android:title="@string/alarm_repeat" /> <EditTextPreference android:key="label" android:persistent="false" android:title="@string/label" diff --git a/src/com/android/deskclock/AlarmClock.java b/src/com/android/deskclock/AlarmClock.java index 4e4db1883..adfe74096 100644 --- a/src/com/android/deskclock/AlarmClock.java +++ b/src/com/android/deskclock/AlarmClock.java @@ -86,7 +86,7 @@ public class AlarmClock extends Activity implements OnItemClickListener { public View newView(Context context, Cursor cursor, ViewGroup parent) { View ret = mFactory.inflate(R.layout.alarm_time, parent, false); - DigitalClock digitalClock = (DigitalClock)ret.findViewById(R.id.digitalClock); + DigitalClock digitalClock = (DigitalClock) ret.findViewById(R.id.digitalClock); digitalClock.setLive(false); if (Log.LOGV) Log.v("newView " + cursor.getPosition()); return ret; @@ -108,14 +108,6 @@ public class AlarmClock extends Activity implements OnItemClickListener { (CheckBox) indicator.findViewById(R.id.clock_onoff); clockOnOff.setChecked(alarm.enabled); - // Handle the "checkbox" click and toggle the alarm. - clockOnOff.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - boolean isChecked = ((CheckBox) v).isChecked(); - updateIndicatorAndAlarm(isChecked, barOnOff, alarm); - } - }); - // Clicking outside the "checkbox" should also change the state. indicator.setOnClickListener(new OnClickListener() { public void onClick(View v) { @@ -230,6 +222,12 @@ public class AlarmClock extends Activity implements OnItemClickListener { addNewAlarm(); } }); + // Make the entire view selected when focused. + addAlarm.setOnFocusChangeListener(new View.OnFocusChangeListener() { + public void onFocusChange(View v, boolean hasFocus) { + v.setSelected(hasFocus); + } + }); ImageButton deskClock = (ImageButton) findViewById(R.id.desk_clock_button); @@ -291,6 +289,10 @@ public class AlarmClock extends Activity implements OnItemClickListener { // Set the custom view on the menu. menu.setHeaderView(v); + // Change the text based on the state of the alarm. + if (alarm.enabled) { + menu.findItem(R.id.enable_alarm).setTitle(R.string.disable_alarm); + } } @Override diff --git a/src/com/android/deskclock/DontPressWithParentLayout.java b/src/com/android/deskclock/DontPressWithParentLayout.java new file mode 100644 index 000000000..6c139983a --- /dev/null +++ b/src/com/android/deskclock/DontPressWithParentLayout.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.deskclock; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.widget.LinearLayout; + +/** + * Special class to to allow the parent to be pressed without being pressed + * itself. This way the time in the alarm list can be pressed without changing + * the background of the indicator. + */ +public class DontPressWithParentLayout extends LinearLayout { + + public DontPressWithParentLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void setPressed(boolean pressed) { + // If the parent is pressed, do not set to pressed. + if (pressed && ((View) getParent()).isPressed()) { + return; + } + super.setPressed(pressed); + } +} diff --git a/src/com/android/deskclock/SetAlarm.java b/src/com/android/deskclock/SetAlarm.java index 7d84bb493..ce07cc15c 100644 --- a/src/com/android/deskclock/SetAlarm.java +++ b/src/com/android/deskclock/SetAlarm.java @@ -16,8 +16,10 @@ package com.android.deskclock; +import android.app.AlertDialog; import android.app.TimePickerDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.media.RingtoneManager; import android.net.Uri; @@ -47,15 +49,14 @@ public class SetAlarm extends PreferenceActivity implements TimePickerDialog.OnTimeSetListener { private EditTextPreference mLabel; + private CheckBoxPreference mEnabledPref; private Preference mTimePref; private AlarmPreference mAlarmPref; private CheckBoxPreference mVibratePref; private RepeatPreference mRepeatPref; - private MenuItem mDeleteAlarmItem; private MenuItem mTestAlarmItem; private int mId; - private boolean mEnabled; private int mHour; private int mMinutes; @@ -80,6 +81,7 @@ public class SetAlarm extends PreferenceActivity return true; } }); + mEnabledPref = (CheckBoxPreference) findPreference("enabled"); mTimePref = findPreference("time"); mAlarmPref = (AlarmPreference) findPreference("alarm"); mVibratePref = (CheckBoxPreference) findPreference("vibrate"); @@ -93,7 +95,7 @@ public class SetAlarm extends PreferenceActivity /* load alarm details from database */ Alarm alarm = Alarms.getAlarm(getContentResolver(), mId); - mEnabled = alarm.enabled; + mEnabledPref.setChecked(alarm.enabled); mLabel.setText(alarm.label); mLabel.setSummary(alarm.label); mHour = alarm.hour; @@ -147,6 +149,12 @@ public class SetAlarm extends PreferenceActivity finish(); } }); + b = (Button) v.findViewById(R.id.alarm_delete); + b.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + deleteAlarm(); + } + }); // Replace the old content view with our new one. setContentView(ll); @@ -174,7 +182,7 @@ public class SetAlarm extends PreferenceActivity mMinutes = minute; updateTime(); // If the time has been changed, enable the alarm. - mEnabled = true; + mEnabledPref.setChecked(true); } private void updateTime() { @@ -187,15 +195,30 @@ public class SetAlarm extends PreferenceActivity private void saveAlarm() { final String alert = mAlarmPref.getAlertString(); - long time = Alarms.setAlarm(this, mId, mEnabled, mHour, mMinutes, - mRepeatPref.getDaysOfWeek(), mVibratePref.isChecked(), + long time = Alarms.setAlarm(this, mId, mEnabledPref.isChecked(), mHour, + mMinutes, mRepeatPref.getDaysOfWeek(), mVibratePref.isChecked(), mLabel.getText(), alert); - if (mEnabled) { + if (mEnabledPref.isChecked()) { popAlarmSetToast(this, time); } } + private void deleteAlarm() { + new AlertDialog.Builder(this) + .setTitle(getString(R.string.delete_alarm)) + .setMessage(getString(R.string.delete_alarm_confirm)) + .setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface d, int w) { + Alarms.deleteAlarm(SetAlarm.this, mId); + finish(); + } + }) + .setNegativeButton(android.R.string.cancel, null) + .show(); + } + /** * Write alarm out to persistent store and pops toast if alarm * enabled. @@ -273,9 +296,6 @@ public class SetAlarm extends PreferenceActivity public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); - mDeleteAlarmItem = menu.add(0, 0, 0, R.string.delete_alarm); - mDeleteAlarmItem.setIcon(android.R.drawable.ic_menu_delete); - if (AlarmClock.DEBUG) { mTestAlarmItem = menu.add(0, 0, 0, "test alarm"); } @@ -284,11 +304,6 @@ public class SetAlarm extends PreferenceActivity } public boolean onOptionsItemSelected(MenuItem item) { - if (item == mDeleteAlarmItem) { - Alarms.deleteAlarm(this, mId); - finish(); - return true; - } if (AlarmClock.DEBUG) { if (item == mTestAlarmItem) { setTestAlarm(); |