diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2016-05-17 13:18:09 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-05-17 13:18:09 -0700 |
commit | 10fe3fc19d185f0160dcd85c38a6155c979a9d5c (patch) | |
tree | d925c1fc5cea73e4e9d05c9ac9679588f93548bd | |
parent | 584aa9b015429bf7346fd44b5252c7ece98e675f (diff) | |
parent | 377456cde5b0c385ea6635a989df68b6f84cc6cb (diff) | |
download | android_packages_apps_Snap-10fe3fc19d185f0160dcd85c38a6155c979a9d5c.tar.gz android_packages_apps_Snap-10fe3fc19d185f0160dcd85c38a6155c979a9d5c.tar.bz2 android_packages_apps_Snap-10fe3fc19d185f0160dcd85c38a6155c979a9d5c.zip |
Merge "SnapdragonCamera: Support rotation for image review layout" into camera.lnx.1.0-dev.1.0
-rw-r--r-- | res/layout/camera_controls.xml | 1 | ||||
-rw-r--r-- | res/layout/photo_module.xml | 2 | ||||
-rw-r--r-- | res/layout/review_module_control.xml (renamed from res/layout-port/review_module_control.xml) | 34 | ||||
-rw-r--r-- | src/com/android/camera/PhotoUI.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/ui/CameraControls.java | 28 | ||||
-rw-r--r-- | src/com/android/camera/ui/ModuleSwitcher.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/ui/RotateImageView.java | 32 |
7 files changed, 73 insertions, 30 deletions
diff --git a/res/layout/camera_controls.xml b/res/layout/camera_controls.xml index 66519d41c..c1def502f 100644 --- a/res/layout/camera_controls.xml +++ b/res/layout/camera_controls.xml @@ -50,6 +50,7 @@ style="@style/SwitcherButton" android:layout_gravity="bottom|left" android:layout_marginBottom="2dip" + android:scaleType="center" android:contentDescription="@string/accessibility_mode_picker" /> <com.android.camera.ShutterButton diff --git a/res/layout/photo_module.xml b/res/layout/photo_module.xml index 9c5b2c0d0..2e3fb8aa0 100644 --- a/res/layout/photo_module.xml +++ b/res/layout/photo_module.xml @@ -68,7 +68,7 @@ android:layout_marginTop="50dip" android:layout_marginLeft="15dip" /> </RelativeLayout> - <ImageView + <com.android.camera.ui.RotateImageView android:id="@+id/review_image" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/res/layout-port/review_module_control.xml b/res/layout/review_module_control.xml index 3c4280ed2..8280b3101 100644 --- a/res/layout-port/review_module_control.xml +++ b/res/layout/review_module_control.xml @@ -18,16 +18,16 @@ style="@style/CameraControls" android:layout_gravity="bottom|center_horizontal" android:layout_marginBottom="2dip"> - <ImageView android:id="@+id/btn_done" - style="@style/ReviewControlIcon" - android:contentDescription="@string/accessibility_review_ok" - android:visibility="gone" - android:scaleType="center" - android:layout_gravity="right|bottom" - android:background="@drawable/bg_pressed" - android:src="@drawable/ic_menu_done_holo_light" /> + <com.android.camera.ui.RotateImageView android:id="@+id/btn_done" + style="@style/ReviewControlIcon" + android:contentDescription="@string/accessibility_review_ok" + android:visibility="gone" + android:scaleType="center" + android:layout_gravity="right|bottom" + android:background="@drawable/bg_pressed" + android:src="@drawable/ic_menu_done_holo_light" /> - <ImageView android:id="@+id/btn_retake" + <com.android.camera.ui.RotateImageView android:id="@+id/btn_retake" style="@style/ReviewControlIcon" android:contentDescription="@string/accessibility_review_retake" android:layout_gravity="bottom|center_horizontal" @@ -37,12 +37,12 @@ android:background="@drawable/bg_pressed" android:src="@drawable/ic_btn_shutter_retake" /> - <ImageView android:id="@+id/btn_cancel" - style="@style/ReviewControlIcon" - android:contentDescription="@string/accessibility_review_cancel" - android:visibility="gone" - android:scaleType="center" - android:layout_gravity="left|bottom" - android:background="@drawable/bg_pressed" - android:src="@drawable/ic_menu_cancel_holo_light" /> + <com.android.camera.ui.RotateImageView android:id="@+id/btn_cancel" + style="@style/ReviewControlIcon" + android:contentDescription="@string/accessibility_review_cancel" + android:visibility="gone" + android:scaleType="center" + android:layout_gravity="left|bottom" + android:background="@drawable/bg_pressed" + android:src="@drawable/ic_menu_cancel_holo_light" /> </com.android.camera.ui.RotatableLayout> diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index 312615492..c736cbc7d 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -1403,6 +1403,10 @@ public class PhotoUI implements PieListener, if (mZoomRenderer != null) { mZoomRenderer.setOrientation(orientation); } + if (mReviewImage != null) { + RotateImageView v = (RotateImageView) mReviewImage; + v.setOrientation(orientation, animation); + } } public void tryToCloseSubList() { diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java index 989568953..9f2a5ebb8 100644 --- a/src/com/android/camera/ui/CameraControls.java +++ b/src/com/android/camera/ui/CameraControls.java @@ -61,6 +61,9 @@ public class CameraControls extends RotatableLayout { private View mPreview; private View mSceneModeSwitcher; private View mFilterModeSwitcher; + private View mReviewDoneButton; + private View mReviewCancelButton; + private View mReviewRetakeButton; private ArrowTextView mRefocusToast; private int mSize; @@ -314,13 +317,18 @@ public class CameraControls extends RotatableLayout { View retake = findViewById(R.id.btn_retake); if (retake != null) { - center(retake, shutter, rotation); - View cancel = findViewById(R.id.btn_cancel); - toLeft(cancel, shutter, rotation); - View done = findViewById(R.id.btn_done); - toRight(done, shutter, rotation); - } + mReviewRetakeButton = retake; + mReviewCancelButton = findViewById(R.id.btn_cancel); + mReviewDoneButton = findViewById(R.id.btn_done); + center(mReviewRetakeButton, shutter, rotation); + toLeft(mReviewCancelButton, shutter, rotation); + toRight(mReviewDoneButton, shutter, rotation); + } else { + mReviewRetakeButton = null; + mReviewCancelButton = null; + mReviewDoneButton = null; + } layoutRemaingPhotos(); } @@ -972,10 +980,14 @@ public class CameraControls extends RotatableLayout { View[] views = { mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher, TsMakeupManager.HAS_TS_MAKEUP ? mTsMakeupSwitcher : mHdrSwitcher, - mMenu, mShutter, mPreview, mSwitcher, mMute + mMenu, mShutter, mPreview, mSwitcher, mMute, mReviewRetakeButton, + mReviewCancelButton, mReviewDoneButton }; for (View v : views) { - ((RotateImageView) v).setOrientation(orientation, animation); + if (v != null) { + ((RotateImageView) v).setOrientation(orientation, + animation); + } } layoutRemaingPhotos(); } diff --git a/src/com/android/camera/ui/ModuleSwitcher.java b/src/com/android/camera/ui/ModuleSwitcher.java index 189342a1b..603f81d4d 100644 --- a/src/com/android/camera/ui/ModuleSwitcher.java +++ b/src/com/android/camera/ui/ModuleSwitcher.java @@ -33,6 +33,7 @@ import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.widget.FrameLayout.LayoutParams; import android.widget.LinearLayout; +import android.widget.ImageView; import com.android.camera.util.CameraUtil; import com.android.camera.util.GcamHelper; @@ -203,6 +204,7 @@ public class ModuleSwitcher extends RotateImageView for (int i = mDrawIds.length - 1; i >= 0; i--) { RotateImageView item = new RotateImageView(getContext()); item.setImageResource(mDrawIds[i]); + item.setScaleType(ImageView.ScaleType.CENTER); item.setBackgroundResource(R.drawable.bg_pressed); final int index = i; item.setOnClickListener(new OnClickListener() { diff --git a/src/com/android/camera/ui/RotateImageView.java b/src/com/android/camera/ui/RotateImageView.java index 05e1a7c5b..a8065c0a3 100644 --- a/src/com/android/camera/ui/RotateImageView.java +++ b/src/com/android/camera/ui/RotateImageView.java @@ -16,6 +16,7 @@ package com.android.camera.ui; +import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; @@ -28,6 +29,7 @@ import android.util.AttributeSet; import android.view.ViewGroup.LayoutParams; import android.view.animation.AnimationUtils; import android.widget.ImageView; +import com.android.camera.util.CameraUtil; /** * A @{code ImageView} which can rotate it's content. @@ -47,6 +49,8 @@ public class RotateImageView extends TwoStateImageView implements Rotatable { private long mAnimationStartTime = 0; private long mAnimationEndTime = 0; + private boolean mNaturalPortrait = CameraUtil.isDefaultToPortrait( + (Activity) getContext()); public RotateImageView(Context context, AttributeSet attrs) { super(context, attrs); @@ -60,6 +64,19 @@ public class RotateImageView extends TwoStateImageView implements Rotatable { return mTargetDegree; } + private boolean isOrientationPortrait() { + int mapTo180Degree = (mCurrentDegree % 180); + + // Assumging the devic's natural orientation is portrait and + // check if the current orienataion is within the landscape range + boolean isLandscape = ((mapTo180Degree > 45) && + (mapTo180Degree < 135)); + if (mNaturalPortrait) + return !isLandscape; + else + return isLandscape; + } + // Rotate the view counter-clockwise @Override public void setOrientation(int degree, boolean animation) { @@ -124,10 +141,17 @@ public class RotateImageView extends TwoStateImageView implements Rotatable { int saveCount = canvas.getSaveCount(); - // Scale down the image first if required. - if ((getScaleType() == ImageView.ScaleType.FIT_CENTER) && - ((width < w) || (height < h))) { - float ratio = Math.min((float) width / w, (float) height / h); + // Scale down or up the image first if required. + if (getScaleType() == ImageView.ScaleType.FIT_CENTER) { + float ratio; + + // As camera layout is fixed to portrait, we need to + // swap canvas width and height when calculating the + // ratio for landscape mode. + if (isOrientationPortrait()) + ratio = Math.min((float) width / w, (float) height / h); + else + ratio = Math.min((float) height / w, (float) width / h); canvas.scale(ratio, ratio, width / 2.0f, height / 2.0f); } canvas.translate(left + width / 2, top + height / 2); |