diff options
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 56adcb1e9..4200ec75e 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -22,6 +22,7 @@ import android.hardware.Camera; import android.os.Build; import android.provider.MediaStore.MediaColumns; import android.view.View; +import android.view.WindowManager; import java.lang.reflect.Field; @@ -179,6 +180,9 @@ public class ApiHelper { public static final boolean HAS_GLES20_REQUIRED = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static final boolean HAS_ROTATION_ANIMATION = + hasField(WindowManager.LayoutParams.class, "rotationAnimation"); + public static int getIntFieldIfExists(Class<?> klass, String fieldName, Class<?> obj, int defaultVal) { try { diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index a207b2b71..b5ff0114c 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -19,8 +19,8 @@ package com.android.camera; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; -import android.content.Context; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.ActivityInfo; @@ -30,13 +30,14 @@ import android.os.Bundle; import android.os.IBinder; import android.provider.MediaStore; import android.provider.Settings; -import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.OrientationEventListener; import android.view.View; import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; import android.widget.FrameLayout; import com.android.camera.ui.CameraSwitcher; @@ -62,6 +63,7 @@ public class CameraActivity extends ActivityBase private int mCurrentModuleIndex; private MotionEvent mDown; private boolean mAutoRotateScreen; + private int mHeightOrWidth = -1; private MyOrientationEventListener mOrientationListener; // The degrees of the device rotated clockwise from its natural orientation. @@ -299,6 +301,15 @@ public class CameraActivity extends ActivityBase super.onConfigurationChanged(config); ViewGroup appRoot = (ViewGroup) findViewById(R.id.content); + boolean landscape = (config.orientation == Configuration.ORIENTATION_LANDSCAPE); + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) appRoot.getLayoutParams(); + if (landscape) { + lp.rightMargin = getResources().getDimensionPixelSize(R.dimen.margin_systemui_offset); + } else { + lp.rightMargin = 0; + } + appRoot.setLayoutParams(lp); + // remove old switcher, shutter and shutter icon View cameraControlsView = findViewById(R.id.camera_shutter_switcher); appRoot.removeView(cameraControlsView); @@ -362,9 +373,23 @@ public class CameraActivity extends ActivityBase hideUI(); } super.onFullScreenChanged(full); + if (ApiHelper.HAS_ROTATION_ANIMATION) { + setRotationAnimation(full); + } mCurrentModule.onFullScreenChanged(full); } + private void setRotationAnimation(boolean fullscreen) { + int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE; + if (fullscreen) { + rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_CROSSFADE; + } + Window win = getWindow(); + WindowManager.LayoutParams winParams = win.getAttributes(); + winParams.rotationAnimation = rotationAnimation; + win.setAttributes(winParams); + } + @Override protected void onStop() { super.onStop(); |