diff options
-rw-r--r-- | res/layout/refocus_editor.xml | 5 | ||||
-rw-r--r-- | res/values-zh-rCN/strings.xml | 4 | ||||
-rw-r--r-- | res/values/colors.xml | 3 | ||||
-rw-r--r-- | res/values/dimens.xml | 6 | ||||
-rw-r--r-- | res/values/qcomstrings.xml | 3 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/PhotoModule.java | 1 | ||||
-rw-r--r-- | src/com/android/camera/PhotoUI.java | 22 | ||||
-rw-r--r-- | src/com/android/camera/RefocusActivity.java | 104 |
10 files changed, 150 insertions, 2 deletions
diff --git a/res/layout/refocus_editor.xml b/res/layout/refocus_editor.xml index c4b42bb4c..454d44a46 100644 --- a/res/layout/refocus_editor.xml +++ b/res/layout/refocus_editor.xml @@ -65,4 +65,9 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. android:layout_height="wrap_content" android:layout_alignParentRight="true" /> </RelativeLayout> + + <view class="com.android.camera.RefocusActivity$Indicator" + android:id="@+id/refocus_indicator" + android:layout_width="match_parent" + android:layout_height="match_parent" /> </FrameLayout> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 37128e275..13337684b 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -541,4 +541,8 @@ <string name="text_tsmakeup_alert_continue">继续</string> <string name="text_tsmakeup_alert_quit">退出</string> + <string name="all_in_focus">全焦</string> + <string name="refocus_toast">点击此处可重新对焦照片</string> + <string name="refocus_prompt_title">Macro+</string> + <string name="refocus_prompt_message">开启Macro+模式后,相机会连续拍摄5张照片并将其合成一张全焦照片。您还可以事后重新对焦。</string> </resources> diff --git a/res/values/colors.xml b/res/values/colors.xml index dba33f40d..3ed0ba889 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -76,4 +76,7 @@ <color name="camera_control_bg_opaque">#ff191919</color> <color name="camera_control_bg_transparent">#4d191919</color> + + <color name="refocus_indicator_1">#a0ffffff</color> + <color name="refocus_indicator_2">#ff29b6f6</color> </resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 1ba60c825..564cd099f 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -173,4 +173,10 @@ <!-- Margins for 4:3 preview on 16:9 screen with 640dp height --> <dimen name="preview_top_margin">57dp</dimen> <dimen name="preview_bottom_margin">103dp</dimen> + + <dimen name="refocus_circle_diameter_1">113dp</dimen> + <dimen name="refocus_circle_diameter_2">81dp</dimen> + <dimen name="refocus_circle_diameter_3">95dp</dimen> + <dimen name="refocus_cross_length">19dp</dimen> + <dimen name="refocus_stroke_width">2dp</dimen> </resources> diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml index 157546b43..50179e83b 100644 --- a/res/values/qcomstrings.xml +++ b/res/values/qcomstrings.xml @@ -888,6 +888,9 @@ <string name="text_tsmakeup_alert_quit">Quit</string> <string name="all_in_focus">All in Focus</string> + <string name="refocus_toast">To re-focus last photo, tap here</string> + <string name="refocus_prompt_title">Macro+</string> + <string name="refocus_prompt_message">With Macro+, your camera will take 5 pictures, each time that you press the shutter button. The 5 pictures will be combined into 1 picture, where everything is in focus. You can choose to re-focus, after you take the picture.</string> <string name="camera_thermal_shutdown">Phone overheated, closing camera.</string> <string name="camera_server_died">Media server died, closing camera.</string> diff --git a/res/values/strings.xml b/res/values/strings.xml index d2c3a7036..6959a4253 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -725,6 +725,4 @@ CHAR LIMIT = NONE] --> <string name="pref_camera_video_rotation_label_270">270</string> <string name="remaining_photos_format">%d left</string> - - <string name="refocus_toast">To re-focus last photo, tap here</string> </resources> diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index cfc52a7ea..b5c264b96 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -240,6 +240,8 @@ public class CameraSettings { public static final String KEY_TS_MAKEUP_LEVEL_WHITEN = "pref_camera_tsmakeup_whiten"; public static final String KEY_TS_MAKEUP_LEVEL_CLEAN = "pref_camera_tsmakeup_clean"; + public static final String KEY_REFOCUS_PROMPT = "refocus-prompt"; + public static final String EXPOSURE_DEFAULT_VALUE = "0"; public static final int CURRENT_VERSION = 5; diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index e2fc34b0c..865ea9889 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -3496,6 +3496,7 @@ public class PhotoModule if (refocusOn.equals(mSceneMode)) { try { mUI.setPreference(CameraSettings.KEY_ADVANCED_FEATURES, refocusOn); + mUI.showRefocusDialog(); } catch (NullPointerException e) { } } else { diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index d2e2345e6..b013c9837 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -22,6 +22,7 @@ import java.util.List; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.res.Configuration; +import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Matrix; @@ -32,6 +33,7 @@ import android.hardware.Camera; import android.hardware.Camera.Face; import android.os.AsyncTask; import android.os.Handler; +import android.preference.PreferenceManager; import android.util.Log; import android.view.Gravity; import android.view.Surface; @@ -1313,4 +1315,24 @@ public class PhotoUI implements PieListener, public void adjustOrientation() { setOrientation(mOrientation, true); } + + public void showRefocusDialog() { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity); + int prompt = prefs.getInt(CameraSettings.KEY_REFOCUS_PROMPT, 1); + if (prompt == 1) { + AlertDialog dialog = new AlertDialog.Builder(mActivity) + .setTitle(R.string.refocus_prompt_title) + .setMessage(R.string.refocus_prompt_message) + .setPositiveButton(R.string.dialog_ok, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int arg1) { + SharedPreferences.Editor editor = prefs.edit(); + editor.putInt(CameraSettings.KEY_REFOCUS_PROMPT, 0); + editor.apply(); + } + }) + .show(); + } + } } diff --git a/src/com/android/camera/RefocusActivity.java b/src/com/android/camera/RefocusActivity.java index 2102d1a78..8c18db977 100644 --- a/src/com/android/camera/RefocusActivity.java +++ b/src/com/android/camera/RefocusActivity.java @@ -32,19 +32,29 @@ import java.io.File; import java.io.FileInputStream; import java.io.OutputStream; +import android.animation.Animator; +import android.animation.Keyframe; +import android.animation.PropertyValuesHolder; +import android.animation.ValueAnimator; import android.app.Activity; +import android.content.Context; +import android.content.res.Resources; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Paint; import android.graphics.Point; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Build; +import android.util.AttributeSet; import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; +import android.widget.FrameLayout; import org.codeaurora.snapcam.R; @@ -59,6 +69,7 @@ public class RefocusActivity extends Activity { private ImageView mImageView; private int mWidth; private int mHeight; + private Indicator mIndicator; private DepthMap mDepthMap; private int mCurrentImage = -1; @@ -79,6 +90,8 @@ public class RefocusActivity extends Activity { setResult(RESULT_CANCELED, new Intent()); setContentView(R.layout.refocus_editor); + mIndicator = (Indicator) findViewById(R.id.refocus_indicator); + mImageView = (ImageView) findViewById(R.id.refocus_image); mImageView.setOnTouchListener(new View.OnTouchListener() { @Override @@ -89,6 +102,8 @@ public class RefocusActivity extends Activity { float y = event.getY(); int w = v.getWidth(); int h = v.getHeight(); + mIndicator.startAnimation(x + mImageView.getLeft(), + y + mImageView.getTop()); if (mDepthMap != null) { int depth = mDepthMap.getDepth(x / (float) w, y / (float) h); setCurrentImage(depth); @@ -246,4 +261,93 @@ public class RefocusActivity extends Activity { return result; } } + + public static class Indicator extends FrameLayout { + private float mX; + private float mY; + private ValueAnimator mAnimator; + private Paint mPaint; + private float mCrossLength; + private float mStrokeWidth; + private int mColor1; + private int mColor2; + + public Indicator(Context context, AttributeSet attr) { + super(context, attr); + final Resources res = context.getResources(); + + float r1 = res.getDimensionPixelSize(R.dimen.refocus_circle_diameter_1) / 2; + float r2 = res.getDimensionPixelSize(R.dimen.refocus_circle_diameter_2) / 2; + float r3 = res.getDimensionPixelSize(R.dimen.refocus_circle_diameter_3) / 2; + mCrossLength = res.getDimensionPixelSize(R.dimen.refocus_cross_length) / 2; + mStrokeWidth = res.getDimensionPixelSize(R.dimen.refocus_stroke_width) / 2; + mColor1 = res.getColor(R.color.refocus_indicator_1); + mColor2 = res.getColor(R.color.refocus_indicator_2); + + Keyframe k0 = Keyframe.ofFloat(0f, r1); + Keyframe k1 = Keyframe.ofFloat(5f / 12f, r2); + Keyframe k2 = Keyframe.ofFloat(0.5f, r2); + Keyframe k3 = Keyframe.ofFloat(0.75f, r3); + Keyframe k4 = Keyframe.ofFloat(1f, r2); + PropertyValuesHolder holder = PropertyValuesHolder.ofKeyframe( + "radius", k0, k1, k2, k3, k4); + mAnimator = ValueAnimator.ofPropertyValuesHolder(holder); + + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mPaint.setStrokeCap(Paint.Cap.BUTT); + mPaint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.refocus_stroke_width)); + } + + @Override + protected void onDraw(Canvas canvas) { + if (mAnimator != null && mAnimator.isStarted()) { + mPaint.setColor(mAnimator.getAnimatedFraction() < 0.5f ? mColor1 : mColor2); + + mPaint.setStyle(Paint.Style.STROKE); + canvas.drawCircle(mX, mY, (Float) mAnimator.getAnimatedValue(), mPaint); + canvas.drawLine(mX - mCrossLength, mY, mX + mCrossLength, mY, mPaint); + canvas.drawLine(mX, mY - mCrossLength, mX, mY + mCrossLength, mPaint); + } + } + + public void startAnimation(float x, float y) { + mX = x; + mY = y; + + if (mAnimator != null) { + mAnimator.cancel(); + } + + mAnimator.setDuration(720); + mAnimator.removeAllUpdateListeners(); + mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + invalidate(); + } + }); + mAnimator.removeAllListeners(); + mAnimator.addListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { + setWillNotDraw(false); + } + + @Override + public void onAnimationEnd(Animator animation) { + setWillNotDraw(true); + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + + @Override + public void onAnimationCancel(Animator animation) { + setWillNotDraw(true); + } + }); + mAnimator.start(); + } + } } |