Merge "Import translations. DO NOT MERGE" into ics-ub-clock-amazon
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f7d7152..4bfd2c5 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -66,7 +66,7 @@
     <dimen name="alarm_timeline_layout_padding_top">50dp</dimen>
     <dimen name="alarm_timeline_title_margin_bottom">10dp</dimen>
     <dimen name="alarm_timeline_title_text_size">24dp</dimen>
-    <dimen name="circletimer_diamond_size">12dip</dimen>
+    <dimen name="circletimer_dot_size">12dip</dimen>
     <dimen name="circletimer_circle_size">4dip</dimen>
     <dimen name="circletimer_marker_size">16dip</dimen>
 
diff --git a/res/values/strings.xml b/res/values/strings.xml
index eceba40..9398d66 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -449,7 +449,10 @@
     <string name="timer_delete">Delete</string>
     <!-- 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>
+    <!-- Describes the purpose of the button to stop the timer. -->
     <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. -->
     <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 -->
diff --git a/src/com/android/deskclock/CircleButtonsLayout.java b/src/com/android/deskclock/CircleButtonsLayout.java
index e19b1c5..6734937 100644
--- a/src/com/android/deskclock/CircleButtonsLayout.java
+++ b/src/com/android/deskclock/CircleButtonsLayout.java
@@ -30,6 +30,7 @@
     private FrameLayout mLabel;
     private TextView mLabelText;
 
+    @SuppressWarnings("unused")
     public CircleButtonsLayout(Context context) {
         this(context, null);
         mContext = context;
@@ -52,13 +53,11 @@
         mLeftButtonPadding = mContext.getResources().getDimension(leftButtonPaddingDimenId);
         mRightButtonPadding = mContext.getResources().getDimension(rightButtonPaddingDimenId);
 
-        float diamondStrokeSize =
-                mContext.getResources().getDimension(R.dimen.circletimer_diamond_size);
+        float dotStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_dot_size);
         float markerStrokeSize =
                 mContext.getResources().getDimension(R.dimen.circletimer_marker_size);
         mStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_circle_size);
-        mDiamOffset =
-                Utils.calculateRadiusOffset(mStrokeSize, diamondStrokeSize, markerStrokeSize) * 2;
+        mDiamOffset = Utils.calculateRadiusOffset(mStrokeSize, dotStrokeSize, markerStrokeSize) * 2;
     }
 
     @Override
diff --git a/src/com/android/deskclock/CircleTimerView.java b/src/com/android/deskclock/CircleTimerView.java
index 16e891f..0317c5a 100644
--- a/src/com/android/deskclock/CircleTimerView.java
+++ b/src/com/android/deskclock/CircleTimerView.java
@@ -2,7 +2,6 @@
 
 import android.content.Context;
 import android.content.SharedPreferences;
-import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.Canvas;
 import android.graphics.Paint;
@@ -13,7 +12,10 @@
 import com.android.deskclock.stopwatch.Stopwatches;
 
 /**
- * TODO: Insert description here. (generated by isaackatz)
+ * Class to draw a circle for timers and stopwatches.
+ * These two usages require two different animation modes:
+ * Timer counts down. In this mode the animation is counter-clockwise and stops at 0.
+ * Stopwatch counts up. In this mode the animation is clockwise and will run until stopped.
  */
 public class CircleTimerView extends View {
 
@@ -27,24 +29,19 @@
     private long mAccumulatedTime = 0;
     private boolean mPaused = false;
     private boolean mAnimate = false;
-    private static float mCircleXCenterLeftPadding = 0;
     private static float mStrokeSize = 4;
-    private static float mDiamondStrokeSize = 12;
+    private static float mDotRadius = 6;
     private static float mMarkerStrokeSize = 2;
     private final Paint mPaint = new Paint();
     private final Paint mFill = new Paint();
     private final RectF mArcRect = new RectF();
-    private float mRectHalfWidth = 6f;
-    private Resources mResources;
     private float mRadiusOffset;   // amount to remove from radius to account for markers on circle
     private float mScreenDensity;
 
-    // Class has 2 modes:
-    // Timer mode - counting down. in this mode the animation is counter-clockwise and stops at 0
-    // Stop watch mode - counting up - in this mode the animation is clockwise and will keep the
-    //                   animation until stopped.
-    private boolean mTimerMode = false; // default is stop watch view
+    // Stopwatch mode is the default.
+    private boolean mTimerMode = false;
 
+    @SuppressWarnings("unused")
     public CircleTimerView(Context context) {
         this(context, null);
     }
@@ -115,23 +112,21 @@
 
     private void init(Context c) {
 
-        mResources = c.getResources();
-        mCircleXCenterLeftPadding = (mResources.getDimension(R.dimen.timer_circle_width)
-                - mResources.getDimension(R.dimen.timer_circle_diameter)) / 2;
-        mStrokeSize = mResources.getDimension(R.dimen.circletimer_circle_size);
-        mDiamondStrokeSize = mResources.getDimension(R.dimen.circletimer_diamond_size);
-        mMarkerStrokeSize = mResources.getDimension(R.dimen.circletimer_marker_size);
+        Resources resources = c.getResources();
+        mStrokeSize = resources.getDimension(R.dimen.circletimer_circle_size);
+        float dotDiameter = resources.getDimension(R.dimen.circletimer_dot_size);
+        mMarkerStrokeSize = resources.getDimension(R.dimen.circletimer_marker_size);
         mRadiusOffset = Utils.calculateRadiusOffset(
-                mStrokeSize, mDiamondStrokeSize, mMarkerStrokeSize);
+                mStrokeSize, dotDiameter, mMarkerStrokeSize);
         mPaint.setAntiAlias(true);
         mPaint.setStyle(Paint.Style.STROKE);
-        mWhiteColor = mResources.getColor(R.color.clock_white);
-        mRedColor = mResources.getColor(R.color.clock_red);
-        mScreenDensity = mResources.getDisplayMetrics().density;
+        mWhiteColor = resources.getColor(R.color.clock_white);
+        mRedColor = resources.getColor(R.color.clock_red);
+        mScreenDensity = resources.getDisplayMetrics().density;
         mFill.setAntiAlias(true);
         mFill.setStyle(Paint.Style.FILL);
         mFill.setColor(mRedColor);
-        mRectHalfWidth = mDiamondStrokeSize / 2f;
+        mDotRadius = dotDiameter / 2f;
     }
 
     public void setTimerMode(boolean mode) {
@@ -151,7 +146,7 @@
             mPaint.setColor(mWhiteColor);
             canvas.drawCircle (xCenter, yCenter, radius, mPaint);
             if (mTimerMode) {
-                drawRedDiamond(canvas, 0f, xCenter, yCenter, radius);
+                drawRedDot(canvas, 0f, xCenter, yCenter, radius);
             }
         } else {
             if (mAnimate) {
@@ -195,30 +190,26 @@
                 canvas.drawArc (mArcRect, 270 + angle, mScreenDensity *
                         (float) (360 / (radius * Math.PI)) , false, mPaint);
             }
-            drawRedDiamond(canvas, redPercent, xCenter, yCenter, radius);
+            drawRedDot(canvas, redPercent, xCenter, yCenter, radius);
         }
         if (mAnimate) {
             invalidate();
         }
    }
 
-    protected void drawRedDiamond(
+    protected void drawRedDot(
             Canvas canvas, float degrees, int xCenter, int yCenter, float radius) {
         mPaint.setColor(mRedColor);
-        float diamondPercent;
+        float dotPercent;
         if (mTimerMode) {
-            diamondPercent = 270 - degrees * 360;
+            dotPercent = 270 - degrees * 360;
         } else {
-            diamondPercent = 270 + degrees * 360;
+            dotPercent = 270 + degrees * 360;
         }
 
-        canvas.save();
-        final double diamondRadians = Math.toRadians(diamondPercent);
-        canvas.translate(xCenter + (float) (radius * Math.cos(diamondRadians)),
-                yCenter + (float) (radius * Math.sin(diamondRadians)));
-        canvas.rotate(diamondPercent + 45f);
-        canvas.drawRect(-mRectHalfWidth, -mRectHalfWidth, mRectHalfWidth, mRectHalfWidth, mFill);
-        canvas.restore();
+        final double dotRadians = Math.toRadians(dotPercent);
+        canvas.drawCircle(xCenter + (float) (radius * Math.cos(dotRadians)),
+                yCenter + (float) (radius * Math.sin(dotRadians)), mDotRadius, mFill);
     }
 
     public static final String PREF_CTV_PAUSED  = "_ctv_paused";
diff --git a/src/com/android/deskclock/HandleApiCalls.java b/src/com/android/deskclock/HandleApiCalls.java
index 4d60054..08ec2df 100644
--- a/src/com/android/deskclock/HandleApiCalls.java
+++ b/src/com/android/deskclock/HandleApiCalls.java
@@ -18,7 +18,6 @@
 
 import static android.provider.AlarmClock.ACTION_SET_ALARM;
 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_LENGTH;
 import static android.provider.AlarmClock.EXTRA_MESSAGE;
@@ -139,38 +138,36 @@
         if (label == null) {
             label = "";
         }
-        final boolean deleteAfterUse = intent.getBooleanExtra(EXTRA_DELETE_AFTER_USE, false);
 
         TimerObj timer = null;
-        // Do not delete existing timers by reusing them and deleting them after use
-        if (!deleteAfterUse) {
-            // Find an existing matching timer
-            final ArrayList<TimerObj> timers = new ArrayList<TimerObj>();
-            TimerObj.getTimersFromSharedPrefs(prefs, timers);
-            for (TimerObj t : timers) {
-                if (t.mSetupLength == length && (TextUtils.equals(label, t.mLabel))
-                        && t.mState == TimerObj.STATE_RESTART) {
-                    timer = t;
-                    break;
-                }
+        // Find an existing matching time
+        final ArrayList<TimerObj> timers = new ArrayList<TimerObj>();
+        TimerObj.getTimersFromSharedPrefs(prefs, timers);
+        for (TimerObj t : timers) {
+            if (t.mSetupLength == length && (TextUtils.equals(label, t.mLabel))
+                    && t.mState == TimerObj.STATE_RESTART) {
+                timer = t;
+                break;
             }
         }
 
+        boolean skipUi = intent.getBooleanExtra(EXTRA_SKIP_UI, false);
         if (timer == null) {
             // Use a new timer
             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.mStartTime = Utils.getTimeNow();
-        timer.mDeleteAfterUse = deleteAfterUse;
         timer.writeToSharedPref(prefs);
 
         // Tell TimerReceiver that the timer was started
         sendBroadcast(new Intent().setAction(Timers.START_TIMER)
                 .putExtra(Timers.TIMER_INTENT_EXTRA, timer.mTimerId));
 
-        if (intent.getBooleanExtra(EXTRA_SKIP_UI, false)) {
+        if (skipUi) {
             Utils.showInUseNotifications(this);
         } else {
             startActivity(new Intent(this, DeskClock.class)
diff --git a/src/com/android/deskclock/Utils.java b/src/com/android/deskclock/Utils.java
index 46e4296..76980a5 100644
--- a/src/com/android/deskclock/Utils.java
+++ b/src/com/android/deskclock/Utils.java
@@ -38,11 +38,9 @@
 import android.os.SystemClock;
 import android.preference.PreferenceManager;
 import android.provider.Settings;
-import android.text.Spannable;
 import android.text.TextUtils;
 import android.text.format.DateFormat;
 import android.text.format.DateUtils;
-import android.text.style.ForegroundColorSpan;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.animation.AccelerateInterpolator;
@@ -61,8 +59,6 @@
 
 
 public class Utils {
-    private final static String TAG = Utils.class.getName();
-
     private final static String PARAM_LANGUAGE_CODE = "hl";
 
     /**
@@ -86,13 +82,6 @@
     public static final String CLOCK_TYPE_ANALOG = "analog";
 
     /**
-     * time format constants
-     */
-    public final static String HOURS_24 = "kk";
-    public final static String HOURS = "h";
-    public final static String MINUTES = ":mm";
-
-    /**
      * Returns whether the SDK is the KeyLimePie release or later.
      */
     public static boolean isKeyLimePieOrLater() {
@@ -125,7 +114,7 @@
 
     /**
      * Adds two query parameters into the Uri, namely the language code and the version code
-     * of the app's package as gotten via the context.
+     * of the application's package as gotten via the context.
      * @return the uri with added query parameters
      */
     private static Uri uriWithAddedParameters(Context context, Uri baseUri) {
@@ -167,8 +156,8 @@
      * of the extra painted objects.
      */
     public static float calculateRadiusOffset(
-            float strokeSize, float diamondStrokeSize, float markerStrokeSize) {
-        return Math.max(strokeSize, Math.max(diamondStrokeSize, markerStrokeSize));
+            float strokeSize, float dotStrokeSize, float markerStrokeSize) {
+        return Math.max(strokeSize, Math.max(dotStrokeSize, markerStrokeSize));
     }
 
     /**
@@ -178,9 +167,9 @@
     public static float calculateRadiusOffset(Resources resources) {
         if (resources != null) {
             float strokeSize = resources.getDimension(R.dimen.circletimer_circle_size);
-            float diamondStrokeSize = resources.getDimension(R.dimen.circletimer_diamond_size);
+            float dotStrokeSize = resources.getDimension(R.dimen.circletimer_dot_size);
             float markerStrokeSize = resources.getDimension(R.dimen.circletimer_marker_size);
-            return calculateRadiusOffset(strokeSize, diamondStrokeSize, markerStrokeSize);
+            return calculateRadiusOffset(strokeSize, dotStrokeSize, markerStrokeSize);
         } else {
             return 0f;
         }
@@ -268,7 +257,6 @@
 
             final float xrange = mContentView.getWidth() - mSaverView.getWidth();
             final float yrange = mContentView.getHeight() - mSaverView.getHeight();
-            Log.v("xrange: "+xrange+" yrange: "+yrange);
 
             if (xrange == 0 && yrange == 0) {
                 delay = 500; // back in a split second
diff --git a/src/com/android/deskclock/timer/TimerFragment.java b/src/com/android/deskclock/timer/TimerFragment.java
index f076af4..657f629 100644
--- a/src/com/android/deskclock/timer/TimerFragment.java
+++ b/src/com/android/deskclock/timer/TimerFragment.java
@@ -806,21 +806,23 @@
                 updateTimersState(t, Timers.START_TIMER);
                 break;
             case TimerObj.STATE_TIMESUP:
-                t.mState = TimerObj.STATE_DONE;
-                // Used in a context where the timer could be off-screen and without a view
-                if (t.mView != null) {
-                    ((TimerListItem) t.mView).done();
-                }
-                updateTimersState(t, Timers.TIMER_DONE);
-                cancelTimerNotification(t.mTimerId);
-                updateTimesUpMode(t);
                 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;
+                    // Used in a context where the timer could be off-screen and without a view
+                    if (t.mView != null) {
+                        ((TimerListItem) t.mView).done();
+                    }
+                    updateTimersState(t, Timers.TIMER_DONE);
+                    cancelTimerNotification(t.mTimerId);
+                    updateTimesUpMode(t);
                 }
                 break;
             case TimerObj.STATE_DONE:
@@ -901,6 +903,10 @@
         CountingTimerView countingTimerView = (CountingTimerView)
                 t.mView.findViewById(R.id.timer_time_text);
         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();
         switch (t.mState) {
             case TimerObj.STATE_RUNNING:
@@ -929,8 +935,11 @@
                 plusOne.setImageResource(R.drawable.ic_plusone);
                 stop.setVisibility(View.VISIBLE);
                 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));
+                delete.setVisibility(t.mDeleteAfterUse ? View.INVISIBLE : View.VISIBLE);
                 countingTimerView.setVirtualButtonEnabled(true);
                 break;
             case TimerObj.STATE_DONE: