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"
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
<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>
}
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);
@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
}
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);
}
}
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];
}
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);
}
}
mHandler.removeMessages(CAMERA_DISABLED);
mRootView.removeOnLayoutChangeListener(mLayoutChangeListener);
+ mPreviewWidth = 0;
+ mPreviewHeight = 0;
mPendingSwitchCameraId = -1;
if (mFocusManager != null) mFocusManager.removeMessages();
MediaSaveService s = mActivity.getMediaSaveService();