diff options
| author | Michael Kolb <kolby@google.com> | 2013-05-01 13:28:24 -0700 |
|---|---|---|
| committer | Michael Kolb <kolby@google.com> | 2013-05-01 14:23:29 -0700 |
| commit | f2c86c128401cf92a2e5b351b32dc6f906eed412 (patch) | |
| tree | 1f0909d8d60c90636d12b277cbf5c601394710a6 | |
| parent | c43e5b6bd84f5a7635766f70677097f6958f4058 (diff) | |
| download | android_packages_apps_Gallery2-f2c86c128401cf92a2e5b351b32dc6f906eed412.tar.gz android_packages_apps_Gallery2-f2c86c128401cf92a2e5b351b32dc6f906eed412.tar.bz2 android_packages_apps_Gallery2-f2c86c128401cf92a2e5b351b32dc6f906eed412.zip | |
Fix layout and preview for tablets
Bug: 8253060
Make controls full screen, and layout according to required size
Change-Id: I725547041264457d85d73d470d25caa5cb2cf783
| -rw-r--r-- | res/layout-land/camera_controls.xml | 4 | ||||
| -rw-r--r-- | res/layout-port/camera_controls.xml | 4 | ||||
| -rw-r--r-- | res/layout/camera_main.xml | 4 | ||||
| -rw-r--r-- | res/values-sw600dp-land/styles.xml | 21 | ||||
| -rw-r--r-- | res/values-sw600dp-port/styles.xml | 21 | ||||
| -rw-r--r-- | res/values-sw600dp/dimens.xml | 3 | ||||
| -rw-r--r-- | res/values/dimens.xml | 1 | ||||
| -rw-r--r-- | src/com/android/camera/ui/CameraControls.java | 34 |
8 files changed, 33 insertions, 59 deletions
diff --git a/res/layout-land/camera_controls.xml b/res/layout-land/camera_controls.xml index 04841a013..96f593ace 100644 --- a/res/layout-land/camera_controls.xml +++ b/res/layout-land/camera_controls.xml @@ -16,8 +16,8 @@ <com.android.camera.ui.CameraControls xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/camera_controls" - style="@style/CameraControls" - android:layout_gravity="center" > + android:layout_width="match_parent" + android:layout_height="match_parent" > <View android:id="@+id/blocker" diff --git a/res/layout-port/camera_controls.xml b/res/layout-port/camera_controls.xml index 4ed9e63c3..ebbdf265e 100644 --- a/res/layout-port/camera_controls.xml +++ b/res/layout-port/camera_controls.xml @@ -16,8 +16,8 @@ <com.android.camera.ui.CameraControls xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/camera_controls" - style="@style/CameraControls" - android:layout_gravity="center" > + android:layout_width="match_parent" + android:layout_height="match_parent" > <View android:id="@+id/blocker" diff --git a/res/layout/camera_main.xml b/res/layout/camera_main.xml index fe5913427..99befc08a 100644 --- a/res/layout/camera_main.xml +++ b/res/layout/camera_main.xml @@ -26,8 +26,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> - <include layout="@layout/camera_controls" - style="@style/CameraControls" - android:layout_centerInParent="true" /> + <include layout="@layout/camera_controls" /> </com.android.camera.ui.CameraRootView>
\ No newline at end of file diff --git a/res/values-sw600dp-land/styles.xml b/res/values-sw600dp-land/styles.xml deleted file mode 100644 index 12e45a9d1..000000000 --- a/res/values-sw600dp-land/styles.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 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 xmlns:android="http://schemas.android.com/apk/res/android"> - <style name="CameraControls"> - <item name="android:layout_width">match_parent</item> - <item name="android:layout_height">520dp</item> - </style> -</resources> diff --git a/res/values-sw600dp-port/styles.xml b/res/values-sw600dp-port/styles.xml deleted file mode 100644 index d6eca6602..000000000 --- a/res/values-sw600dp-port/styles.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 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 xmlns:android="http://schemas.android.com/apk/res/android"> - <style name="CameraControls"> - <item name="android:layout_height">match_parent</item> - <item name="android:layout_width">520dp</item> - </style> -</resources> diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index 59d86d900..5ec2f19b4 100644 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -21,5 +21,6 @@ <dimen name="onscreen_indicators_height">@dimen/onscreen_indicators_height_large</dimen> <dimen name="shutter_offset">-33dp</dimen> <dimen name="capture_size">80dip</dimen> - <dimen name="capture_top_margin">16dip</dimen> + <dimen name="capture_margin_top">16dip</dimen> + <dimen name="camera_controls_size">520dip</dimen> </resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 57194167e..a1e237002 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -100,4 +100,5 @@ <dimen name="capture_size">48dip</dimen> <dimen name="capture_margin_right">16dip</dimen> <dimen name="capture_margin_top">16dip</dimen> + <dimen name="camera_controls_size">0dip</dimen> </resources> diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java index e5b90dd51..f7af52c28 100644 --- a/src/com/android/camera/ui/CameraControls.java +++ b/src/com/android/camera/ui/CameraControls.java @@ -68,15 +68,31 @@ public class CameraControls extends RotatableLayout { public void onLayout(boolean changed, int l, int t, int r, int b) { int orientation = getResources().getConfiguration().orientation; int rotation = Util.getDisplayRotation((Activity) getContext()); + int size = getResources().getDimensionPixelSize(R.dimen.camera_controls_size); rotation = correctRotation(rotation, orientation); super.onLayout(changed, l, t, r, b); Rect shutter = new Rect(); + topRight(mPreview, l, t, r, b, orientation, rotation); + if (size > 0) { + // restrict controls to size + switch (rotation) { + case 0: + case 180: + l = (l + r - size) / 2; + r = l + size; + break; + case 90: + case 270: + t = (t + b - size) / 2; + b = t + size; + break; + } + } center(mShutter, l, t, r, b, orientation, rotation, shutter); center(mBackgroundView, l, t, r, b, orientation, rotation, new Rect()); toLeft(mSwitcher, l, t, r, b, orientation, rotation, shutter); toRight(mMenu, l, t, r, b, orientation, rotation, shutter); toRight(mIndicators, l, t, r, b, orientation, rotation, shutter); - topRight(mPreview, l, t, r, b, orientation, rotation); View retake = findViewById(R.id.btn_retake); if (retake != null) { Rect retakeRect = new Rect(); @@ -106,8 +122,8 @@ public class CameraControls extends RotatableLayout { switch (rotation) { case 0: // phone portrait; controls bottom - result.left = (r - l) / 2 - tw / 2 + lp.leftMargin; - result.right = (r - l) / 2 + tw / 2 - lp.rightMargin; + result.left = (r + l) / 2 - tw / 2 + lp.leftMargin; + result.right = (r + l) / 2 + tw / 2 - lp.rightMargin; result.bottom = b - lp.bottomMargin; result.top = b - th + lp.topMargin; break; @@ -115,13 +131,13 @@ public class CameraControls extends RotatableLayout { // phone landscape: controls right result.right = r - lp.rightMargin; result.left = r - tw + lp.leftMargin; - result.top = (b - t) / 2 - th / 2 + lp.topMargin; - result.bottom = (b - t) / 2 + th / 2 - lp.bottomMargin; + result.top = (b + t) / 2 - th / 2 + lp.topMargin; + result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin; break; case 180: // phone upside down: controls top - result.left = (r - l) / 2 - tw / 2 + lp.leftMargin; - result.right = (r - l) / 2 + tw / 2 - lp.rightMargin; + result.left = (r + l) / 2 - tw / 2 + lp.leftMargin; + result.right = (r + l) / 2 + tw / 2 - lp.rightMargin; result.top = t + lp.topMargin; result.bottom = t + th - lp.bottomMargin; break; @@ -129,8 +145,8 @@ public class CameraControls extends RotatableLayout { // reverse landscape: controls left result.left = l + lp.leftMargin; result.right = l + tw - lp.rightMargin; - result.top = (b - t) / 2 - th / 2 + lp.topMargin; - result.bottom = (b - t) / 2 + th / 2 - lp.bottomMargin; + result.top = (b + t) / 2 - th / 2 + lp.topMargin; + result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin; break; } v.layout(result.left, result.top, result.right, result.bottom); |
