Loading res/values/strings.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -449,7 +449,10 @@ <string name="timer_delete">Delete</string> <string name="timer_delete">Delete</string> <!-- Describes the purpose of the button increase the remaining time on a timer by one minute. --> <!-- Describes the purpose of the button increase the remaining time on a timer by one minute. --> <string name="timer_plus_one">Add 1 Minute</string> <string name="timer_plus_one">Add 1 Minute</string> <!-- Describes the purpose of the button to stop the timer. --> <string name="timer_stop">Stop</string> <string name="timer_stop">Stop</string> <!-- Describes the purpose of the button to stop and delete the timer. --> <string name="timer_done">Done</string> <!-- Describes the purpose of the button to return the timer to it's original starting value. --> <!-- Describes the purpose of the button to return the timer to it's original starting value. --> <string name="timer_reset">Reset</string> <string name="timer_reset">Reset</string> <!-- Describes the purpose of the button to discard the current dialog values. Will also close the dialog if other time's exist --> <!-- Describes the purpose of the button to discard the current dialog values. Will also close the dialog if other time's exist --> Loading src/com/android/deskclock/HandleApiCalls.java +12 −15 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.deskclock; import static android.provider.AlarmClock.ACTION_SET_ALARM; import static android.provider.AlarmClock.ACTION_SET_ALARM; import static android.provider.AlarmClock.ACTION_SET_TIMER; import static android.provider.AlarmClock.ACTION_SET_TIMER; import static android.provider.AlarmClock.EXTRA_DELETE_AFTER_USE; import static android.provider.AlarmClock.EXTRA_HOUR; import static android.provider.AlarmClock.EXTRA_HOUR; import static android.provider.AlarmClock.EXTRA_LENGTH; import static android.provider.AlarmClock.EXTRA_LENGTH; import static android.provider.AlarmClock.EXTRA_MESSAGE; import static android.provider.AlarmClock.EXTRA_MESSAGE; Loading Loading @@ -139,12 +138,9 @@ public class HandleApiCalls extends Activity { if (label == null) { if (label == null) { label = ""; label = ""; } } final boolean deleteAfterUse = intent.getBooleanExtra(EXTRA_DELETE_AFTER_USE, false); TimerObj timer = null; TimerObj timer = null; // Do not delete existing timers by reusing them and deleting them after use // Find an existing matching time if (!deleteAfterUse) { // Find an existing matching timer final ArrayList<TimerObj> timers = new ArrayList<TimerObj>(); final ArrayList<TimerObj> timers = new ArrayList<TimerObj>(); TimerObj.getTimersFromSharedPrefs(prefs, timers); TimerObj.getTimersFromSharedPrefs(prefs, timers); for (TimerObj t : timers) { for (TimerObj t : timers) { Loading @@ -154,23 +150,24 @@ public class HandleApiCalls extends Activity { break; break; } } } } } boolean skipUi = intent.getBooleanExtra(EXTRA_SKIP_UI, false); if (timer == null) { if (timer == null) { // Use a new timer // Use a new timer timer = new TimerObj(length, label); timer = new TimerObj(length, label); // Timers set without presenting UI to the user will be deleted after use timer.mDeleteAfterUse = skipUi; } } timer.mState = TimerObj.STATE_RUNNING; timer.mState = TimerObj.STATE_RUNNING; timer.mStartTime = Utils.getTimeNow(); timer.mStartTime = Utils.getTimeNow(); timer.mDeleteAfterUse = deleteAfterUse; timer.writeToSharedPref(prefs); timer.writeToSharedPref(prefs); // Tell TimerReceiver that the timer was started // Tell TimerReceiver that the timer was started sendBroadcast(new Intent().setAction(Timers.START_TIMER) sendBroadcast(new Intent().setAction(Timers.START_TIMER) .putExtra(Timers.TIMER_INTENT_EXTRA, timer.mTimerId)); .putExtra(Timers.TIMER_INTENT_EXTRA, timer.mTimerId)); if (intent.getBooleanExtra(EXTRA_SKIP_UI, false)) { if (skipUi) { Utils.showInUseNotifications(this); Utils.showInUseNotifications(this); } else { } else { startActivity(new Intent(this, DeskClock.class) startActivity(new Intent(this, DeskClock.class) Loading src/com/android/deskclock/timer/TimerFragment.java +18 −9 Original line number Original line Diff line number Diff line Loading @@ -806,6 +806,15 @@ public class TimerFragment extends DeskClockFragment updateTimersState(t, Timers.START_TIMER); updateTimersState(t, Timers.START_TIMER); break; break; case TimerObj.STATE_TIMESUP: case TimerObj.STATE_TIMESUP: if (t.mDeleteAfterUse) { cancelTimerNotification(t.mTimerId); animateTimerDeletion(t); // Tell receiver the timer was deleted. // It will stop all activity related to the // timer t.mState = TimerObj.STATE_DELETED; updateTimersState(t, Timers.DELETE_TIMER); } else { t.mState = TimerObj.STATE_DONE; t.mState = TimerObj.STATE_DONE; // Used in a context where the timer could be off-screen and without a view // Used in a context where the timer could be off-screen and without a view if (t.mView != null) { if (t.mView != null) { Loading @@ -814,13 +823,6 @@ public class TimerFragment extends DeskClockFragment updateTimersState(t, Timers.TIMER_DONE); updateTimersState(t, Timers.TIMER_DONE); cancelTimerNotification(t.mTimerId); cancelTimerNotification(t.mTimerId); updateTimesUpMode(t); updateTimesUpMode(t); if (t.mDeleteAfterUse) { animateTimerDeletion(t); // Tell receiver the timer was deleted. // It will stop all activity related to the // timer t.mState = TimerObj.STATE_DELETED; updateTimersState(t, Timers.DELETE_TIMER); } } break; break; case TimerObj.STATE_DONE: case TimerObj.STATE_DONE: Loading Loading @@ -901,6 +903,10 @@ public class TimerFragment extends DeskClockFragment CountingTimerView countingTimerView = (CountingTimerView) CountingTimerView countingTimerView = (CountingTimerView) t.mView.findViewById(R.id.timer_time_text); t.mView.findViewById(R.id.timer_time_text); TextView stop = (TextView) t.mView.findViewById(R.id.timer_stop); TextView stop = (TextView) t.mView.findViewById(R.id.timer_stop); ImageButton delete = (ImageButton) t.mView.findViewById(R.id.timer_delete); // Make sure the delete button is visible in case the view is recycled. delete.setVisibility(View.VISIBLE); Resources r = a.getResources(); Resources r = a.getResources(); switch (t.mState) { switch (t.mState) { case TimerObj.STATE_RUNNING: case TimerObj.STATE_RUNNING: Loading Loading @@ -929,8 +935,11 @@ public class TimerFragment extends DeskClockFragment plusOne.setImageResource(R.drawable.ic_plusone); plusOne.setImageResource(R.drawable.ic_plusone); stop.setVisibility(View.VISIBLE); stop.setVisibility(View.VISIBLE); stop.setContentDescription(r.getString(R.string.timer_stop)); stop.setContentDescription(r.getString(R.string.timer_stop)); stop.setText(R.string.timer_stop); // If the timer is deleted after use , show "done" instead of "stop" on the button // and hide the delete button since pressing done will delete the timer stop.setText(t.mDeleteAfterUse ? R.string.timer_done : R.string.timer_stop); stop.setTextColor(getResources().getColor(R.color.clock_white)); stop.setTextColor(getResources().getColor(R.color.clock_white)); delete.setVisibility(t.mDeleteAfterUse ? View.INVISIBLE : View.VISIBLE); countingTimerView.setVirtualButtonEnabled(true); countingTimerView.setVirtualButtonEnabled(true); break; break; case TimerObj.STATE_DONE: case TimerObj.STATE_DONE: Loading Loading
res/values/strings.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -449,7 +449,10 @@ <string name="timer_delete">Delete</string> <string name="timer_delete">Delete</string> <!-- Describes the purpose of the button increase the remaining time on a timer by one minute. --> <!-- Describes the purpose of the button increase the remaining time on a timer by one minute. --> <string name="timer_plus_one">Add 1 Minute</string> <string name="timer_plus_one">Add 1 Minute</string> <!-- Describes the purpose of the button to stop the timer. --> <string name="timer_stop">Stop</string> <string name="timer_stop">Stop</string> <!-- Describes the purpose of the button to stop and delete the timer. --> <string name="timer_done">Done</string> <!-- Describes the purpose of the button to return the timer to it's original starting value. --> <!-- Describes the purpose of the button to return the timer to it's original starting value. --> <string name="timer_reset">Reset</string> <string name="timer_reset">Reset</string> <!-- Describes the purpose of the button to discard the current dialog values. Will also close the dialog if other time's exist --> <!-- Describes the purpose of the button to discard the current dialog values. Will also close the dialog if other time's exist --> Loading
src/com/android/deskclock/HandleApiCalls.java +12 −15 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.deskclock; import static android.provider.AlarmClock.ACTION_SET_ALARM; import static android.provider.AlarmClock.ACTION_SET_ALARM; import static android.provider.AlarmClock.ACTION_SET_TIMER; import static android.provider.AlarmClock.ACTION_SET_TIMER; import static android.provider.AlarmClock.EXTRA_DELETE_AFTER_USE; import static android.provider.AlarmClock.EXTRA_HOUR; import static android.provider.AlarmClock.EXTRA_HOUR; import static android.provider.AlarmClock.EXTRA_LENGTH; import static android.provider.AlarmClock.EXTRA_LENGTH; import static android.provider.AlarmClock.EXTRA_MESSAGE; import static android.provider.AlarmClock.EXTRA_MESSAGE; Loading Loading @@ -139,12 +138,9 @@ public class HandleApiCalls extends Activity { if (label == null) { if (label == null) { label = ""; label = ""; } } final boolean deleteAfterUse = intent.getBooleanExtra(EXTRA_DELETE_AFTER_USE, false); TimerObj timer = null; TimerObj timer = null; // Do not delete existing timers by reusing them and deleting them after use // Find an existing matching time if (!deleteAfterUse) { // Find an existing matching timer final ArrayList<TimerObj> timers = new ArrayList<TimerObj>(); final ArrayList<TimerObj> timers = new ArrayList<TimerObj>(); TimerObj.getTimersFromSharedPrefs(prefs, timers); TimerObj.getTimersFromSharedPrefs(prefs, timers); for (TimerObj t : timers) { for (TimerObj t : timers) { Loading @@ -154,23 +150,24 @@ public class HandleApiCalls extends Activity { break; break; } } } } } boolean skipUi = intent.getBooleanExtra(EXTRA_SKIP_UI, false); if (timer == null) { if (timer == null) { // Use a new timer // Use a new timer timer = new TimerObj(length, label); timer = new TimerObj(length, label); // Timers set without presenting UI to the user will be deleted after use timer.mDeleteAfterUse = skipUi; } } timer.mState = TimerObj.STATE_RUNNING; timer.mState = TimerObj.STATE_RUNNING; timer.mStartTime = Utils.getTimeNow(); timer.mStartTime = Utils.getTimeNow(); timer.mDeleteAfterUse = deleteAfterUse; timer.writeToSharedPref(prefs); timer.writeToSharedPref(prefs); // Tell TimerReceiver that the timer was started // Tell TimerReceiver that the timer was started sendBroadcast(new Intent().setAction(Timers.START_TIMER) sendBroadcast(new Intent().setAction(Timers.START_TIMER) .putExtra(Timers.TIMER_INTENT_EXTRA, timer.mTimerId)); .putExtra(Timers.TIMER_INTENT_EXTRA, timer.mTimerId)); if (intent.getBooleanExtra(EXTRA_SKIP_UI, false)) { if (skipUi) { Utils.showInUseNotifications(this); Utils.showInUseNotifications(this); } else { } else { startActivity(new Intent(this, DeskClock.class) startActivity(new Intent(this, DeskClock.class) Loading
src/com/android/deskclock/timer/TimerFragment.java +18 −9 Original line number Original line Diff line number Diff line Loading @@ -806,6 +806,15 @@ public class TimerFragment extends DeskClockFragment updateTimersState(t, Timers.START_TIMER); updateTimersState(t, Timers.START_TIMER); break; break; case TimerObj.STATE_TIMESUP: case TimerObj.STATE_TIMESUP: if (t.mDeleteAfterUse) { cancelTimerNotification(t.mTimerId); animateTimerDeletion(t); // Tell receiver the timer was deleted. // It will stop all activity related to the // timer t.mState = TimerObj.STATE_DELETED; updateTimersState(t, Timers.DELETE_TIMER); } else { t.mState = TimerObj.STATE_DONE; t.mState = TimerObj.STATE_DONE; // Used in a context where the timer could be off-screen and without a view // Used in a context where the timer could be off-screen and without a view if (t.mView != null) { if (t.mView != null) { Loading @@ -814,13 +823,6 @@ public class TimerFragment extends DeskClockFragment updateTimersState(t, Timers.TIMER_DONE); updateTimersState(t, Timers.TIMER_DONE); cancelTimerNotification(t.mTimerId); cancelTimerNotification(t.mTimerId); updateTimesUpMode(t); updateTimesUpMode(t); if (t.mDeleteAfterUse) { animateTimerDeletion(t); // Tell receiver the timer was deleted. // It will stop all activity related to the // timer t.mState = TimerObj.STATE_DELETED; updateTimersState(t, Timers.DELETE_TIMER); } } break; break; case TimerObj.STATE_DONE: case TimerObj.STATE_DONE: Loading Loading @@ -901,6 +903,10 @@ public class TimerFragment extends DeskClockFragment CountingTimerView countingTimerView = (CountingTimerView) CountingTimerView countingTimerView = (CountingTimerView) t.mView.findViewById(R.id.timer_time_text); t.mView.findViewById(R.id.timer_time_text); TextView stop = (TextView) t.mView.findViewById(R.id.timer_stop); TextView stop = (TextView) t.mView.findViewById(R.id.timer_stop); ImageButton delete = (ImageButton) t.mView.findViewById(R.id.timer_delete); // Make sure the delete button is visible in case the view is recycled. delete.setVisibility(View.VISIBLE); Resources r = a.getResources(); Resources r = a.getResources(); switch (t.mState) { switch (t.mState) { case TimerObj.STATE_RUNNING: case TimerObj.STATE_RUNNING: Loading Loading @@ -929,8 +935,11 @@ public class TimerFragment extends DeskClockFragment plusOne.setImageResource(R.drawable.ic_plusone); plusOne.setImageResource(R.drawable.ic_plusone); stop.setVisibility(View.VISIBLE); stop.setVisibility(View.VISIBLE); stop.setContentDescription(r.getString(R.string.timer_stop)); stop.setContentDescription(r.getString(R.string.timer_stop)); stop.setText(R.string.timer_stop); // If the timer is deleted after use , show "done" instead of "stop" on the button // and hide the delete button since pressing done will delete the timer stop.setText(t.mDeleteAfterUse ? R.string.timer_done : R.string.timer_stop); stop.setTextColor(getResources().getColor(R.color.clock_white)); stop.setTextColor(getResources().getColor(R.color.clock_white)); delete.setVisibility(t.mDeleteAfterUse ? View.INVISIBLE : View.VISIBLE); countingTimerView.setVirtualButtonEnabled(true); countingTimerView.setVirtualButtonEnabled(true); break; break; case TimerObj.STATE_DONE: case TimerObj.STATE_DONE: Loading