OSDN Git Service

Fix issue of focus indicator staying on without being hidden
authorSascha Haeberling <haeberling@google.com>
Thu, 14 Nov 2013 03:04:21 +0000 (19:04 -0800)
committerSascha Haeberling <haeberling@google.com>
Thu, 14 Nov 2013 03:05:34 +0000 (19:05 -0800)
  Bug: 11505806

A mix up in the previous 100% CL caused this. This CL here also
makes it more robust by making the 100% extra time time-based instead
of frame-based.

Change-Id: I52c53d4b5816570c2c805e0e8ff193de684f2a64

src/com/android/camera/ui/PieRenderer.java
src/com/android/camera/ui/ProgressRenderer.java

index 60d33c3..f1a5a9a 100644 (file)
@@ -1026,15 +1026,15 @@ public class PieRenderer extends OverlayRenderer
         cancelFocus();
 
         if (waitUntilProgressIsHidden) {
-            mOverlay.post(mDisappear);
-            mProgressRenderer.setVisibilityListener(null);
-        } else {
             mProgressRenderer.setVisibilityListener(new VisibilityListener() {
                 @Override
                 public void onHidden() {
                     mOverlay.post(mDisappear);
                 }
             });
+        } else {
+            mOverlay.post(mDisappear);
+            mProgressRenderer.setVisibilityListener(null);
         }
     }
 
index 1945dcf..5002931 100644 (file)
@@ -43,11 +43,13 @@ public class ProgressRenderer {
     private VisibilityListener mVisibilityListener;
 
     /**
-     * After we reach 100%, keep on painting the progress for nother x frames
+     * After we reach 100%, keep on painting the progress for another x milliseconds
      * before hiding it.
      */
-    private static final int SHOW_PROGRESS_X_ADDITIONAL_FRAMES = 5;
-    private int showProgressXMoreFrames;
+    private static final int SHOW_PROGRESS_X_ADDITIONAL_MS = 100;
+
+    /** When to hide the progress indicator. */
+    private long mTimeToHide = 0;
 
     public ProgressRenderer(Context context) {
         mProgressRadius = context.getResources().getDimensionPixelSize(R.dimen.pie_progress_radius);
@@ -78,6 +80,7 @@ public class ProgressRenderer {
         // We hide the progress once we drew the 100% state once.
         if (percent < 100) {
             mVisible = true;
+            mTimeToHide = System.currentTimeMillis() + SHOW_PROGRESS_X_ADDITIONAL_MS;
         }
     }
 
@@ -96,17 +99,11 @@ public class ProgressRenderer {
         canvas.drawArc(mArcBounds, -90, mProgressAngleDegrees, false, mProgressPaint);
 
         // After we reached 100%, we paint the progress renderer for another x
-        // frames until we hide it.
-        if (mProgressAngleDegrees == 360) {
-            if (showProgressXMoreFrames <= 0) {
-                showProgressXMoreFrames = SHOW_PROGRESS_X_ADDITIONAL_FRAMES;
-            } else {
-                if (--showProgressXMoreFrames == 0) {
-                    mVisible = false;
-                    if (mVisibilityListener != null) {
-                        mVisibilityListener.onHidden();
-                    }
-                }
+        // milliseconds until we hide it.
+        if (mProgressAngleDegrees == 360 && System.currentTimeMillis() > mTimeToHide) {
+            mVisible = false;
+            if (mVisibilityListener != null) {
+                mVisibilityListener.onHidden();
             }
         }
     }