OSDN Git Service

Add a black bar symmetric to nav bar
authorDoris Liu <tianliu@google.com>
Tue, 5 Mar 2013 17:54:25 +0000 (09:54 -0800)
committerDoris Liu <tianliu@google.com>
Wed, 6 Mar 2013 02:50:14 +0000 (18:50 -0800)
Also fix bug: 8323926
Change-Id: I4886b285dee8ad71ad72a55e96bf699b7c18c9f4

res/layout-port/camera_controls.xml
res/layout/camera_main.xml
res/values/dimens.xml
src/com/android/camera/CameraActivity.java
src/com/android/camera/PhotoModule.java

index 7108b3c..aa15da1 100644 (file)
@@ -40,7 +40,7 @@
             android:layout_marginBottom="2dip"
             android:contentDescription="@string/accessibility_menu_button" />
 
-       <com.android.camera.ui.CameraSwitcher
+        <com.android.camera.ui.CameraSwitcher
            android:id="@+id/camera_switcher"
            style="@style/SwitcherButton"
            android:layout_gravity="bottom|left"
index 657c06c..710e69d 100644 (file)
@@ -25,6 +25,8 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent" />
 
-    <include layout="@layout/camera_controls" />
+    <include layout="@layout/camera_controls"
+        style="@style/CameraControls"
+        android:layout_centerInParent="true" />
 
 </RelativeLayout>
\ No newline at end of file
index c51b837..d2720d9 100644 (file)
@@ -88,8 +88,8 @@
     <dimen name="face_circle_stroke">2dip</dimen>
     <dimen name="zoom_font_size">14pt</dimen>
     <dimen name="shutter_offset">-22dp</dimen>
-    <dimen name="margin_systemui_offset">6dip</dimen>
     <dimen name="size_thumbnail">200dip</dimen>
     <dimen name="size_preview">600dip</dimen>
     <dimen name="navigation_bar_height">48dip</dimen>
+    <dimen name="navigation_bar_width">42dip</dimen>
 </resources>
index b1f0847..24c49ba 100644 (file)
@@ -117,6 +117,8 @@ public class CameraActivity extends ActivityBase
     }
 
     public void init() {
+        boolean landscape = Util.getDisplayRotation(this) % 180 == 90;
+        setMargins(landscape);
         mControlsBackground = findViewById(R.id.blocker);
         mCameraControls = findViewById(R.id.camera_controls);
         mShutter = (ShutterButton) findViewById(R.id.shutter_button);
@@ -316,28 +318,22 @@ public class CameraActivity extends ActivityBase
     @Override
     public void onConfigurationChanged(Configuration config) {
         super.onConfigurationChanged(config);
+        boolean landscape = (config.orientation == Configuration.ORIENTATION_LANDSCAPE);
+        setMargins(landscape);
+        mCurrentModule.onConfigurationChanged(config);
+    }
 
+    private void setMargins(boolean landscape) {
         ViewGroup appRoot = (ViewGroup) findViewById(R.id.content);
-        boolean landscape = (config.orientation == Configuration.ORIENTATION_LANDSCAPE);
         FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) appRoot.getLayoutParams();
-        int offset = getResources().getDimensionPixelSize(R.dimen.margin_systemui_offset);
+        int navBarWidth = getResources().getDimensionPixelSize(R.dimen.navigation_bar_width);
         int navBarHeight = getResources().getDimensionPixelSize(R.dimen.navigation_bar_height);
         if (landscape) {
-            lp.rightMargin = offset;
+            lp.setMargins(navBarHeight, 0, navBarHeight - navBarWidth, 0);
         } else {
-            lp.rightMargin = 0;
+            lp.setMargins(0, navBarHeight, 0, 0);
         }
         appRoot.setLayoutParams(lp);
-
-        // Set padding to move camera controls away from the edge of the screen
-        // so that they are in the same place as if there was a navigation bar between
-        // the screen edge and the controls
-        if (landscape) {
-            mCameraControls.setPadding(navBarHeight, 0, 0, 0);
-        } else {
-            mCameraControls.setPadding(0, navBarHeight, 0, 0);
-        }
-        mCurrentModule.onConfigurationChanged(config);
     }
 
     @Override
@@ -478,9 +474,10 @@ public class CameraActivity extends ActivityBase
         }
         if ((mSwitcher != null) && mSwitcher.showsPopup() && !mSwitcher.isInsidePopup(m)) {
             return mSwitcher.onTouch(null, m);
+        } else if ((mSwitcher != null) && mSwitcher.isInsidePopup(m)) {
+            return superDispatchTouchEvent(m);
         } else {
-            return mCameraControls.dispatchTouchEvent(m)
-                    || mCurrentModule.dispatchTouchEvent(m);
+            return mCurrentModule.dispatchTouchEvent(m);
         }
     }
 
index 9a45461..4049aa5 100644 (file)
@@ -215,6 +215,8 @@ public class PhotoModule
             onScreenSizeChanged(right - left, bottom - top);
         }
     };
+    private int mPreviewWidth = 0;
+    private int mPreviewHeight = 0;
     private final StringBuilder mBuilder = new StringBuilder();
     private final Formatter mFormatter = new Formatter(mBuilder);
     private final Object[] mFormatterArgs = new Object[1];
@@ -615,12 +617,17 @@ public class PhotoModule
     }
 
     public void onScreenSizeChanged(int width, int height) {
-        if (mFocusManager != null) mFocusManager.setPreviewSize(width, height);
         // Full-screen screennail
-        if (Util.getDisplayRotation(mActivity) % 180 == 0) {
-            ((CameraScreenNail) mActivity.mCameraScreenNail).setPreviewFrameLayoutSize(width, height);
-        } else {
-            ((CameraScreenNail) mActivity.mCameraScreenNail).setPreviewFrameLayoutSize(height, width);
+        int w = width;
+        int h = height;
+        if (Util.getDisplayRotation(mActivity) % 180 != 0) {
+            w = height;
+            h = width;
+        }
+        if (mPreviewWidth != w || mPreviewHeight != h) {
+            Log.d(TAG, "Preview size changed.");
+            if (mFocusManager != null) mFocusManager.setPreviewSize(width, height);
+            ((CameraScreenNail) mActivity.mCameraScreenNail).setPreviewFrameLayoutSize(w, h);
         }
     }
 
@@ -1639,6 +1646,8 @@ public class PhotoModule
         mHandler.removeMessages(CAMERA_DISABLED);
 
         mRootView.removeOnLayoutChangeListener(mLayoutChangeListener);
+        mPreviewWidth = 0;
+        mPreviewHeight = 0;
         mPendingSwitchCameraId = -1;
         if (mFocusManager != null) mFocusManager.removeMessages();
         MediaSaveService s = mActivity.getMediaSaveService();