summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values-sw600dp/booleans.xml18
-rw-r--r--res/values/bool.xml1
-rw-r--r--src/com/android/camera/ui/RotatableLayout.java32
3 files changed, 25 insertions, 26 deletions
diff --git a/res/values-sw600dp/booleans.xml b/res/values-sw600dp/booleans.xml
deleted file mode 100644
index c7522cfa9..000000000
--- a/res/values-sw600dp/booleans.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <bool name="is_tablet">true</bool>
-</resources> \ No newline at end of file
diff --git a/res/values/bool.xml b/res/values/bool.xml
index 067e3d9a9..464842ab4 100644
--- a/res/values/bool.xml
+++ b/res/values/bool.xml
@@ -15,5 +15,4 @@
-->
<resources>
<bool name="show_action_bar_title">false</bool>
- <bool name="is_tablet">false</bool>
</resources> \ No newline at end of file
diff --git a/src/com/android/camera/ui/RotatableLayout.java b/src/com/android/camera/ui/RotatableLayout.java
index 0997d26ad..04c36331d 100644
--- a/src/com/android/camera/ui/RotatableLayout.java
+++ b/src/com/android/camera/ui/RotatableLayout.java
@@ -19,14 +19,16 @@ package com.android.camera.ui;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
+import android.graphics.Point;
import android.util.AttributeSet;
+import android.view.Display;
import android.view.Gravity;
+import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.android.camera.util.CameraUtil;
-import com.android.camera2.R;
/* RotatableLayout rotates itself as well as all its children when orientation
* changes. Specifically, when going from portrait to landscape, camera
@@ -43,7 +45,7 @@ public class RotatableLayout extends FrameLayout {
// Initial orientation of the layout (ORIENTATION_PORTRAIT, or ORIENTATION_LANDSCAPE)
private int mInitialOrientation;
private int mPrevRotation = UNKOWN_ORIENTATION;
- private boolean mIsTablet = false;
+ private boolean mIsDefaultToPortrait = false;
public RotatableLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
@@ -62,7 +64,6 @@ public class RotatableLayout extends FrameLayout {
private void init() {
mInitialOrientation = getResources().getConfiguration().orientation;
- mIsTablet = getResources().getBoolean(R.bool.is_tablet);
}
@Override
@@ -72,12 +73,13 @@ public class RotatableLayout extends FrameLayout {
// we need to rotate the view if necessary. After that, onConfigurationChanged
// call will track all the subsequent device rotation.
if (mPrevRotation == UNKOWN_ORIENTATION) {
- if (mIsTablet) {
+ calculateDefaultOrientation();
+ if (mIsDefaultToPortrait) {
// Natural orientation for tablet is landscape
- mPrevRotation = mInitialOrientation == Configuration.ORIENTATION_LANDSCAPE ?
+ mPrevRotation = mInitialOrientation == Configuration.ORIENTATION_PORTRAIT ?
0 : 90;
} else {
- mPrevRotation = mInitialOrientation == Configuration.ORIENTATION_PORTRAIT ?
+ mPrevRotation = mInitialOrientation == Configuration.ORIENTATION_LANDSCAPE ?
0 : 90;
}
@@ -86,6 +88,22 @@ public class RotatableLayout extends FrameLayout {
}
}
+ private void calculateDefaultOrientation() {
+ Display currentDisplay = getDisplay();
+ Point displaySize = new Point();
+ currentDisplay.getSize(displaySize);
+ int orientation = currentDisplay.getRotation();
+ int naturalWidth, naturalHeight;
+ if (orientation == Surface.ROTATION_0 || orientation == Surface.ROTATION_180) {
+ naturalWidth = displaySize.x;
+ naturalHeight = displaySize.y;
+ } else {
+ naturalWidth = displaySize.y;
+ naturalHeight = displaySize.x;
+ }
+ mIsDefaultToPortrait = naturalWidth < naturalHeight;
+ }
+
private void rotateIfNeeded() {
if (mPrevRotation == UNKOWN_ORIENTATION) {
return;
@@ -111,7 +129,7 @@ public class RotatableLayout extends FrameLayout {
// all the layout code assumes camera device orientation to be portrait
// adjust rotation for landscape
int rotation = CameraUtil.getDisplayRotation((Activity) getContext());
- if (mIsTablet) {
+ if (!mIsDefaultToPortrait) {
return (rotation + 90) % 360;
}
return rotation;