From 750861a411cd44eef5c56cd7f0a1a3d46ef00a32 Mon Sep 17 00:00:00 2001 From: Likai Ding Date: Mon, 15 Dec 2014 16:05:14 +0800 Subject: SnapdragonCamera: show how many more pictures can be taken Prompt to user an estimation of how many more pictures can be taken, calculated based on available storage. Change-Id: Iabc8268d548d3f6d86a6d065b511641b837a1de5 --- src/com/android/camera/ui/CameraControls.java | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/com/android/camera/ui/CameraControls.java') diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java index 1c9419569..181bd991e 100644 --- a/src/com/android/camera/ui/CameraControls.java +++ b/src/com/android/camera/ui/CameraControls.java @@ -26,6 +26,7 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewPropertyAnimator; import android.widget.FrameLayout; +import android.widget.TextView; import java.util.ArrayList; import org.codeaurora.snapcam.R; @@ -66,6 +67,8 @@ public class CameraControls extends RotatableLayout { private boolean[] mTempEnabled = new boolean[9]; private boolean mLocSet = false; + private TextView mRemainingPhotos; + AnimatorListener outlistener = new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { @@ -205,6 +208,7 @@ public class CameraControls extends RotatableLayout { mPreview = findViewById(R.id.preview_thumb); mSceneModeSwitcher = findViewById(R.id.scene_mode_switcher); mFilterModeSwitcher = findViewById(R.id.filter_mode_switcher); + mRemainingPhotos = (TextView) findViewById(R.id.remaining_photos); } @Override @@ -238,6 +242,8 @@ public class CameraControls extends RotatableLayout { View done = findViewById(R.id.btn_done); toRight(done, shutter, rotation); } + + layoutRemaingPhotos(); } private void setLocation(int w, int h) { @@ -388,6 +394,7 @@ public class CameraControls extends RotatableLayout { mPreview.animate().translationXBy(-mSize).setDuration(ANIME_DURATION); break; } + mRemainingPhotos.setVisibility(View.INVISIBLE); } public void showUI() { @@ -475,6 +482,9 @@ public class CameraControls extends RotatableLayout { mPreview.animate().translationXBy(mSize).setDuration(ANIME_DURATION); break; } + if (mRemainingPhotos.getVisibility() == View.INVISIBLE) { + mRemainingPhotos.setVisibility(View.VISIBLE); + } } private void center(View v, Rect other, int rotation) { @@ -646,4 +656,45 @@ public class CameraControls extends RotatableLayout { mBackgroundView.setBackgroundResource(R.drawable.switcher_bg); } + private void layoutRemaingPhotos() { + int rl = mPreview.getLeft(); + int rt = mPreview.getTop(); + int rr = mPreview.getRight(); + int rb = mPreview.getBottom(); + int w = mRemainingPhotos.getMeasuredWidth(); + int h = mRemainingPhotos.getMeasuredHeight(); + int m = getResources().getDimensionPixelSize(R.dimen.remaining_photos_margin); + + int hc, vc; + int rotation = getUnifiedRotation(); + switch (rotation) { + case 90: + hc = (rl + rr) / 2 - m; + vc = (rt + rb) / 2; + break; + case 180: + hc = (rl + rr) / 2; + vc = (rt + rb) / 2 + m; + break; + case 270: + hc = (rl + rr) / 2 + m; + vc = (rt + rb) / 2; + break; + default: + hc = (rl + rr) / 2; + vc = (rt + rb) / 2 - m; + break; + } + mRemainingPhotos.layout(hc - w / 2, vc - h / 2, hc + w / 2, vc + h / 2); + } + + public void updateRemainingPhotos(int remaining) { + if (remaining < 0) { + mRemainingPhotos.setVisibility(View.GONE); + } else { + mRemainingPhotos.setVisibility(View.VISIBLE); + mRemainingPhotos.setText(String.format( + getResources().getString(R.string.remaining_photos_format), remaining)); + } + } } -- cgit v1.2.3