diff options
author | Doris Liu <tianliu@google.com> | 2013-03-04 22:19:10 -0800 |
---|---|---|
committer | Doris Liu <tianliu@google.com> | 2013-03-05 14:11:05 -0800 |
commit | 48239f4dd39040a9ab2ffc977586035a8784fd78 (patch) | |
tree | c7221012018ef477e04262befecee5ff43c9beb5 /src/com/android/camera/ui/CameraSwitcher.java | |
parent | 72db7ea0c18e5cc2f465252b53d9b6d2a8dcc6a0 (diff) | |
download | android_packages_apps_Snap-48239f4dd39040a9ab2ffc977586035a8784fd78.tar.gz android_packages_apps_Snap-48239f4dd39040a9ab2ffc977586035a8784fd78.tar.bz2 android_packages_apps_Snap-48239f4dd39040a9ab2ffc977586035a8784fd78.zip |
Keep camera controls on the same physical side
Change-Id: I09c50650c77a89fadfeb376564ef43e750994f8a
Diffstat (limited to 'src/com/android/camera/ui/CameraSwitcher.java')
-rw-r--r-- | src/com/android/camera/ui/CameraSwitcher.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/com/android/camera/ui/CameraSwitcher.java b/src/com/android/camera/ui/CameraSwitcher.java index 3fa4a01d5..897729b46 100644 --- a/src/com/android/camera/ui/CameraSwitcher.java +++ b/src/com/android/camera/ui/CameraSwitcher.java @@ -19,11 +19,13 @@ package com.android.camera.ui; import android.animation.Animator; import android.animation.Animator.AnimatorListener; import android.animation.AnimatorListenerAdapter; +import android.app.Activity; import android.content.Context; import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.util.AttributeSet; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -33,6 +35,7 @@ import android.view.ViewGroup; import android.widget.FrameLayout.LayoutParams; import android.widget.LinearLayout; +import com.android.camera.Util; import com.android.gallery3d.R; import com.android.gallery3d.common.ApiHelper; @@ -120,6 +123,13 @@ public class CameraSwitcher extends RotateImageView (ViewGroup) getParent()); LinearLayout content = (LinearLayout) mParent.findViewById(R.id.content); mPopup = content; + // Set the gravity of the popup, so that it shows up at the right position + // on screen + LayoutParams lp = ((LayoutParams) mPopup.getLayoutParams()); + lp.gravity = ((LayoutParams) mParent.findViewById(R.id.camera_switcher) + .getLayoutParams()).gravity; + mPopup.setLayoutParams(lp); + mPopup.setVisibility(View.INVISIBLE); mNeedsAnimationSetup = true; for (int i = mDrawIds.length - 1; i >= 0; i--) { @@ -224,15 +234,22 @@ public class CameraSwitcher extends RotateImageView } private void updateInitialTranslations() { - if (getResources().getConfiguration().orientation - == Configuration.ORIENTATION_PORTRAIT) { + int orientation = Util.getDisplayRotation((Activity) getContext()); + if (orientation == 0) { mTranslationX = -getWidth() / 2; mTranslationY = getHeight(); - } else { + } else if (orientation == 90) { mTranslationX = getWidth(); mTranslationY = getHeight() / 2; + } else if (orientation == 180) { + mTranslationX = getWidth(); + mTranslationY = -getHeight() / 2; + } else { + mTranslationX = -getWidth(); + mTranslationY = -getHeight() / 2; } } + private void popupAnimationSetup() { if (!ApiHelper.HAS_VIEW_PROPERTY_ANIMATOR) { return; |