summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/VideoMenu.java
diff options
context:
space:
mode:
authorLikai Ding <likaid@codeaurora.org>2015-01-26 10:07:21 +0800
committerLikai Ding <likaid@codeaurora.org>2015-02-02 13:55:08 +0800
commite2fb5dc7798cf677f6a66b6a697c4a011b0a101f (patch)
tree9250c3a47e27b90e3c094c9d3ffa1365c3914178 /src/com/android/camera/VideoMenu.java
parent07cf80cc97c68f12d5728919fcebba28e750761d (diff)
downloadandroid_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.tar.gz
android_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.tar.bz2
android_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.zip
SnapdragonCamera: fix portrait orientation
Fix camera activity to portrait, so there is no delay when rotation occurs. Main changes are: 1. RotateLayout now supports padding and dynamically added child. 2. Camera controls and gesture detetion are now orientation-aware. 3. Toasts are replaced with RotateTextToast. 4. Obselete layout files are removed. Change-Id: I338849bd7fb84b847eb357f771a24a5cc09bf6fa
Diffstat (limited to 'src/com/android/camera/VideoMenu.java')
-rw-r--r--src/com/android/camera/VideoMenu.java100
1 files changed, 58 insertions, 42 deletions
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java
index 1f9c6d1a0..b8cb5a1fe 100644
--- a/src/com/android/camera/VideoMenu.java
+++ b/src/com/android/camera/VideoMenu.java
@@ -47,6 +47,7 @@ import android.widget.HorizontalScrollView;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.Display;
+import com.android.camera.ui.RotateLayout;
import com.android.camera.util.CameraUtil;
public class VideoMenu extends MenuController
@@ -219,7 +220,21 @@ public class VideoMenu extends MenuController
mPopupStatus = POPUP_IN_ANIMATION_SLIDE;
ViewPropertyAnimator vp = v.animate();
- vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
+ switch (mUI.getOrientation()) {
+ case 0:
+ vp.translationXBy(-v.getWidth());
+ break;
+ case 90:
+ vp.translationYBy(2 * v.getHeight());
+ break;
+ case 180:
+ vp.translationXBy(2 * v.getWidth());
+ break;
+ case 270:
+ vp.translationYBy(-v.getHeight());
+ break;
+ }
+
vp.setListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -259,7 +274,7 @@ public class VideoMenu extends MenuController
}
});
- vp.start();
+ vp.setDuration(ANIMATION_DURATION).start();
}
public void animateFadeIn(final ListView v) {
@@ -268,27 +283,37 @@ public class VideoMenu extends MenuController
vp.start();
}
- public void animateSlideIn(final View v, int delta, boolean settingMenu) {
- int rotation = CameraUtil.getDisplayRotation(mActivity);
- boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
- if (!mIsDefaultToPortrait) {
- rotation = (rotation + 90) % 360;
- }
- boolean portrait = (rotation == 0) || (rotation == 180);
- if (settingMenu)
- portrait = true;
+ public void animateSlideIn(final View v, int delta, boolean adjustOrientation) {
+ int orientation = mUI.getOrientation();
+ if (!adjustOrientation)
+ orientation = 0;
+
ViewPropertyAnimator vp = v.animate();
- if (portrait) {
- float dest = v.getX();
- v.setX(dest - delta);
- vp.translationX(dest).setDuration(ANIMATION_DURATION);
+ float dest;
+ switch (orientation) {
+ case 0:
+ dest = v.getX();
+ v.setX(dest - delta);
+ vp.translationX(dest);
+ break;
+ case 90:
+ dest = v.getY();
+ v.setY(dest + delta);
+ vp.translationY(dest);
+ break;
+ case 180:
+ dest = v.getX();
+ v.setX(dest + delta);
+ vp.translationX(dest);
+ break;
+ case 270:
+ dest = v.getY();
+ v.setY(dest - delta);
+ vp.translationY(dest);
+ break;
}
- else {
- float dest = v.getY();
- v.setY(dest + delta);
- vp.translationY(dest).setDuration(ANIMATION_DURATION);
- }
- vp.start();
+
+ vp.setDuration(ANIMATION_DURATION).start();
}
public void animateSlideOutPreviewMenu() {
@@ -301,20 +326,9 @@ public class VideoMenu extends MenuController
if (v == null || mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION)
return;
mPreviewMenuStatus = PREVIEW_MENU_IN_ANIMATION;
- int rotation = CameraUtil.getDisplayRotation(mActivity);
- boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
- if (!mIsDefaultToPortrait) {
- rotation = (rotation + 90) % 360;
- }
- boolean portrait = (rotation == 0) || (rotation == 180);
- ViewPropertyAnimator vp = v.animate();
- if (portrait) {
- vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
-
- } else {
- vp.translationY(v.getY() + v.getHeight()).setDuration(ANIMATION_DURATION);
- }
+ ViewPropertyAnimator vp = v.animate();
+ vp.translationXBy(-v.getWidth()).setDuration(ANIMATION_DURATION);
vp.setListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -337,7 +351,7 @@ public class VideoMenu extends MenuController
mPreviewMenuStatus = PREVIEW_MENU_NONE;
}
});
- vp.start();
+ vp.setDuration(ANIMATION_DURATION).start();
}
public boolean isOverMenu(MotionEvent ev) {
@@ -404,8 +418,7 @@ public class VideoMenu extends MenuController
// The preference only has a single icon to represent it.
resid = pref.getSingleIcon();
}
- ImageView iv = (ImageView) ((FrameLayout) switcher).getChildAt(0);
- iv.setImageResource(resid);
+ ((ImageView) switcher).setImageResource(resid);
switcher.setVisibility(View.VISIBLE);
mPreferences.add(pref);
mPreferenceMap.put(pref, switcher);
@@ -420,8 +433,8 @@ public class VideoMenu extends MenuController
CharSequence[] values = pref.getEntryValues();
index = (index + 1) % values.length;
pref.setValueIndex(index);
- ImageView iv = (ImageView) ((FrameLayout) v).getChildAt(0);
- iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]);
+ ((ImageView) v).setImageResource(
+ ((IconListPreference) pref).getLargeIconIds()[index]);
if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))
mListener.onCameraPickerClicked(index);
reloadPreference(pref);
@@ -441,14 +454,14 @@ public class VideoMenu extends MenuController
int resid = -1;
// The preference only has a single icon to represent it.
resid = pref.getSingleIcon();
- ImageView iv = (ImageView) ((FrameLayout) button).getChildAt(0);
- iv.setImageResource(resid);
+ ((ImageView) button).setImageResource(resid);
button.setVisibility(View.VISIBLE);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
addFilterMode();
View view = mUI.getPreviewMenuLayout().getChildAt(0);
+ mUI.adjustOrientation();
animateSlideIn(view, previewMenuSize, false);
}
});
@@ -523,7 +536,7 @@ public class VideoMenu extends MenuController
final View[] views = new View[entries.length];
int init = pref.getCurrentIndex();
for (int i = 0; i < entries.length; i++) {
- LinearLayout layout2 = (LinearLayout) inflater.inflate(
+ RotateLayout layout2 = (RotateLayout) inflater.inflate(
R.layout.filter_mode_view, null, false);
ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
@@ -743,4 +756,7 @@ public class VideoMenu extends MenuController
super.onSettingChanged(pref);
}
+ public int getOrientation() {
+ return mUI == null ? 0 : mUI.getOrientation();
+ }
}