android:id="@+id/camera_controls"
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <View
- android:id="@+id/blocker"
- android:clickable="true"
- android:layout_height="match_parent"
- android:layout_width="@dimen/switcher_size"
- android:layout_gravity="right" />
-
- <include layout="@layout/menu_indicators"
- android:layout_width="64dip"
- android:layout_height="64dip"
- android:layout_marginTop="-5dip"
- android:layout_marginRight="6dip"
- android:layout_gravity="top|right"/>
-
- <com.android.camera.ui.PieMenuButton
- android:id="@+id/menu"
- style="@style/SwitcherButton"
- android:contentDescription="@string/accessibility_menu_button"
- android:layout_gravity="right|top"
- android:layout_marginRight="2dip" />
-
<com.android.camera.ShutterButton
android:id="@+id/shutter_button"
android:layout_width="wrap_content"
android:contentDescription="@string/accessibility_shutter_button"
android:focusable="true"
android:scaleType="center"
+ android:visibility="gone"
android:src="@drawable/btn_new_shutter" />
-
- <ImageView
- android:id="@+id/preview_thumb"
- android:visibility="invisible"
- android:layout_width="@dimen/capture_size"
- android:layout_height="@dimen/capture_size"
- android:scaleType="centerInside"
- android:layout_gravity="top|right"
- android:contentDescription="@string/switch_photo_filmstrip" />
-
</com.android.camera.ui.CameraControls>
android:id="@+id/camera_controls"
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <View
- android:id="@+id/blocker"
- android:clickable="true"
- android:layout_width="match_parent"
- android:layout_height="@dimen/switcher_size"
- android:layout_gravity="bottom" />
-
- <include layout="@layout/menu_indicators"
- android:layout_width="64dip"
- android:layout_height="64dip"
- android:layout_gravity="bottom|right"
- android:layout_marginBottom="6dip"
- android:layout_marginRight="-5dip" />
-
- <com.android.camera.ui.PieMenuButton
- android:id="@+id/menu"
- style="@style/SwitcherButton"
- android:layout_gravity="bottom|right"
- android:layout_marginBottom="2dip"
- android:contentDescription="@string/accessibility_menu_button" />
-
<com.android.camera.ShutterButton
android:id="@+id/shutter_button"
android:layout_width="wrap_content"
android:contentDescription="@string/accessibility_shutter_button"
android:focusable="true"
android:scaleType="center"
+ android:visibility="gone"
android:src="@drawable/btn_new_shutter" />
-
- <ImageView
- android:id="@+id/preview_thumb"
- android:visibility="invisible"
- android:layout_width="@dimen/capture_size"
- android:layout_height="@dimen/capture_size"
- android:scaleType="centerInside"
- android:layout_gravity="top|right"
- android:contentDescription="@string/switch_photo_filmstrip" />
-
</com.android.camera.ui.CameraControls>
+++ /dev/null
-<?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.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/panorama_capture_layout"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <!-- The top bar with capture indication -->
- <FrameLayout
- style="@style/PanoViewHorizontalBar"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
-
- <TextView
- android:id="@+id/pano_capture_indicator"
- android:text="@string/pano_capture_indication"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_gravity="center"
- android:visibility="gone"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </FrameLayout>
-
- <FrameLayout
- android:layout_gravity="center"
- android:id="@+id/pano_preview_layout"
- android:layout_weight="@integer/SRI_pano_layout_weight"
- android:layout_width="match_parent"
- android:layout_height="0dp">
-
- <TextureView
- android:id="@+id/pano_preview_textureview"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <View
- android:id="@+id/pano_preview_area_border"
- android:visibility="gone"
- android:background="@drawable/ic_pan_border_fast"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </FrameLayout>
-
- <!-- The bottom bar with progress bar and direction indicators -->
- <FrameLayout
- style="@style/PanoViewHorizontalBar"
- android:paddingTop="20dp"
- android:gravity="top"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <com.android.camera.PanoProgressBar
- android:id="@+id/pano_pan_progress_bar"
- android:visibility="gone"
- android:src="@drawable/ic_pan_progression"
- android:layout_centerInParent="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/pano_pan_left_indicator"
- android:src="@drawable/pano_direction_left_indicator"
- android:visibility="gone"
- android:layout_marginRight="5dp"
- android:layout_toLeftOf="@id/pano_pan_progress_bar"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/pano_pan_right_indicator"
- android:src="@drawable/pano_direction_right_indicator"
- android:visibility="gone"
- android:layout_marginLeft="5dp"
- android:layout_toRightOf="@id/pano_pan_progress_bar"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </RelativeLayout>
- </FrameLayout>
-
-
- </LinearLayout>
-
- <!-- The hint for "Too fast" text view -->
- <TextView
- android:id="@+id/pano_capture_too_fast_textview"
- android:text="@string/pano_too_fast_prompt"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:visibility="gone" />
-</FrameLayout>
+++ /dev/null
-<?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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/pano_review_layout"
- android:orientation="vertical"
- android:visibility="gone"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
-
- <TextView
- style="@style/PanoViewHorizontalBar"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:text="@string/pano_review_rendering"
- android:textAppearance="?android:textAppearanceMedium"
- android:gravity="center" />
-
- <ImageView
- android:id="@+id/pano_reviewarea"
- android:scaleType="fitCenter"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="@integer/SRI_pano_layout_weight" />
-
- <FrameLayout
- android:id="@+id/pano_review_control"
- style="@style/PanoViewHorizontalBar"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
-
- <include layout="@layout/pano_review_control" />
- </FrameLayout>
-</LinearLayout>
-
+++ /dev/null
-<?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.
--->
-
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
- android:clickable="true"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <include layout="@layout/pano_module_capture" />
- <View
- android:id="@+id/preview_cover"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@android:color/black"
- android:visibility="gone" />
- <include layout="@layout/pano_module_review" />
- <include layout="@layout/camera_controls"
- android:layout_gravity="center"
- style="@style/CameraControls"/>
-</merge>
package com.android.camera.app;
import android.content.Context;
-import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
-import android.widget.ImageView;
import com.android.camera.AnimationManager;
import com.android.camera.filmstrip.FilmstripContentPanel;
import com.android.camera.ui.BottomBar;
import com.android.camera.ui.CaptureAnimationOverlay;
-import com.android.camera.widget.FilmstripLayout;
import com.android.camera.ui.MainActivityLayout;
import com.android.camera.ui.ModeListView;
import com.android.camera.ui.ModeTransitionView;
import com.android.camera.ui.PreviewOverlay;
import com.android.camera.ui.PreviewStatusListener;
+import com.android.camera.widget.FilmstripLayout;
import com.android.camera2.R;
/**
private View mFlashOverlay;
private FrameLayout mModuleUI;
- private GestureDetector mGestureDetector;
+ private final GestureDetector mGestureDetector;
private int mSwipeState = IDLE;
- private ImageView mPreviewThumbView;
private PreviewOverlay mPreviewOverlay;
private CaptureAnimationOverlay mCaptureOverlay;
private PreviewStatusListener mPreviewStatusListener;
private int mModeCoverState = COVER_HIDDEN;
- private FilmstripBottomControls mFilmstripBottomControls;
- private FilmstripContentPanel mFilmstripPanel;
+ private final FilmstripBottomControls mFilmstripBottomControls;
+ private final FilmstripContentPanel mFilmstripPanel;
private Runnable mHideCoverRunnable;
// TODO this isn't used by all modules universally, should be part of a util class or something
setPreviewTransformMatrix(matrix);
float previewAspectRatio =
- (float)scaledTextureWidth / (float)scaledTextureHeight;
+ scaledTextureWidth / scaledTextureHeight;
if (previewAspectRatio < 1.0) {
previewAspectRatio = 1.0f/previewAspectRatio;
}
} else {
bottomBar.setAlpha(1.0f);
if (landscape) {
- lp.width = (int)((float) width - scaledTextureWidth);
+ lp.width = (int)(width - scaledTextureWidth);
lp.height = LayoutParams.MATCH_PARENT;
} else {
- lp.height = (int)((float) height - scaledTextureHeight);
+ lp.height = (int)(height - scaledTextureHeight);
lp.width = LayoutParams.MATCH_PARENT;
}
}
int iconRes = ModeListView.getModeIconResourceId(moduleToTransitionTo);
AnimationFinishedListener listener = new AnimationFinishedListener() {
+ @Override
public void onAnimationFinished(boolean success) {
if (success) {
// Go to new module when the previous operation is successful.
mPreviewOverlay.setOnTouchListener(new MyTouchListener());
mCaptureOverlay = (CaptureAnimationOverlay)
mCameraRootView.findViewById(R.id.capture_overlay);
- mPreviewThumbView = (ImageView) mCameraRootView.findViewById(R.id.preview_thumb);
-
}
// TODO: Remove this when refactor is done.
}
/**
- * Starts the post-capture animation with the current preview image.
- */
- public void startPostCaptureAnimation() {
- if (mTextureView == null) {
- Log.e(TAG, "Cannot get a frame from a null TextureView for animation");
- return;
- }
- // TODO: Down sample bitmap
- startPostCaptureAnimation(mTextureView.getBitmap());
- }
-
- /**
- * Starts the post-capture animation with the given thumbnail.
- *
- * @param thumbnail The thumbnail for the animation.
- */
- public void startPostCaptureAnimation(Bitmap thumbnail) {
- mPreviewThumbView.setImageBitmap(thumbnail);
- mAnimationManager.startCaptureAnimation(mPreviewThumbView);
- }
-
- /**
* Cancels the post-capture animation.
*/
public void cancelPostCaptureAnimation() {
package com.android.camera.ui;
import android.content.Context;
-import android.graphics.Rect;
import android.util.AttributeSet;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import com.android.camera2.R;
public class CameraControls extends RotatableLayout {
- private static final String TAG = "CAM_Controls";
-
- private View mBackgroundView;
- private View mShutter;
- private View mMenu;
- private View mIndicators;
- private View mPreview;
-
public CameraControls(Context context, AttributeSet attrs) {
super(context, attrs);
setMeasureAllChildren(true);
@Override
public void onFinishInflate() {
super.onFinishInflate();
- mBackgroundView = findViewById(R.id.blocker);
- mShutter = findViewById(R.id.shutter_button);
- mMenu = findViewById(R.id.menu);
- mIndicators = findViewById(R.id.on_screen_indicators);
- mPreview = findViewById(R.id.preview_thumb);
- }
-
- @Override
- public void onLayout(boolean changed, int l, int t, int r, int b) {
- int orientation = getResources().getConfiguration().orientation;
- int size = getResources().getDimensionPixelSize(R.dimen.camera_controls_size);
- int rotation = getUnifiedRotation();
- adjustBackground();
- // As l,t,r,b are positions relative to parents, we need to convert them
- // to child's coordinates
- r = r - l;
- b = b - t;
- l = 0;
- t = 0;
- for (int i = 0; i < getChildCount(); i++) {
- View v = getChildAt(i);
- v.layout(l, t, r, b);
- }
- Rect shutter = new Rect();
- topRight(mPreview, l, t, r, b);
- 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());
- toRight(mMenu, shutter, rotation);
- toRight(mIndicators, shutter, rotation);
- View retake = findViewById(R.id.btn_retake);
- if (retake != null) {
- center(retake, shutter, rotation);
- View cancel = findViewById(R.id.btn_cancel);
- toLeft(cancel, shutter, rotation);
- View done = findViewById(R.id.btn_done);
- toRight(done, shutter, rotation);
- }
- }
-
- private void center(View v, int l, int t, int r, int b, int orientation, int rotation, Rect result) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
- int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
- int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
- 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.bottom = b - lp.bottomMargin;
- result.top = b - th + lp.topMargin;
- break;
- case 90:
- // 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;
- 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.top = t + lp.topMargin;
- result.bottom = t + th - lp.bottomMargin;
- break;
- case 270:
- // 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;
- break;
- }
- v.layout(result.left, result.top, result.right, result.bottom);
- }
-
- private void center(View v, Rect other, int rotation) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
- int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
- int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
- int cx = (other.left + other.right) / 2;
- int cy = (other.top + other.bottom) / 2;
- v.layout(cx - tw / 2 + lp.leftMargin,
- cy - th / 2 + lp.topMargin,
- cx + tw / 2 - lp.rightMargin,
- cy + th / 2 - lp.bottomMargin);
}
-
- private void toLeft(View v, Rect other, int rotation) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
- int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
- int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
- int cx = (other.left + other.right) / 2;
- int cy = (other.top + other.bottom) / 2;
- int l = 0, r = 0, t = 0, b = 0;
- switch (rotation) {
- case 0:
- // portrait, to left of anchor at bottom
- l = other.left - tw + lp.leftMargin;
- r = other.left - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 90:
- // phone landscape: below anchor on right
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.bottom + lp.topMargin;
- b = other.bottom + th - lp.bottomMargin;
- break;
- case 180:
- // phone upside down: right of anchor at top
- l = other.right + lp.leftMargin;
- r = other.right + tw - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 270:
- // reverse landscape: above anchor on left
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.top - th + lp.topMargin;
- b = other.top - lp.bottomMargin;
- break;
- }
- v.layout(l, t, r, b);
- }
-
- private void toRight(View v, Rect other, int rotation) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
- int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
- int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
- int cx = (other.left + other.right) / 2;
- int cy = (other.top + other.bottom) / 2;
- int l = 0, r = 0, t = 0, b = 0;
- switch (rotation) {
- case 0:
- l = other.right + lp.leftMargin;
- r = other.right + tw - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 90:
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.top - th + lp.topMargin;
- b = other.top - lp.bottomMargin;
- break;
- case 180:
- l = other.left - tw + lp.leftMargin;
- r = other.left - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 270:
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.bottom + lp.topMargin;
- b = other.bottom + th - lp.bottomMargin;
- break;
- }
- v.layout(l, t, r, b);
- }
-
- private void topRight(View v, int l, int t, int r, int b) {
- // layout using the specific margins; the rotation code messes up the others
- int mt = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_top);
- int mr = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_right);
- v.layout(r - v.getMeasuredWidth() - mr, t + mt, r - mr, t + mt + v.getMeasuredHeight());
- }
-
- private void adjustBackground() {
- int rotation = getUnifiedRotation();
- // remove current drawable and reset rotation
- mBackgroundView.setBackgroundDrawable(null);
- mBackgroundView.setRotationX(0);
- mBackgroundView.setRotationY(0);
- // if the switcher background is top aligned we need to flip the background
- // drawable vertically; if left aligned, flip horizontally
- switch (rotation) {
- case 180:
- mBackgroundView.setRotationX(180);
- break;
- case 270:
- mBackgroundView.setRotationY(180);
- break;
- default:
- break;
- }
- mBackgroundView.setBackgroundResource(R.drawable.switcher_bg);
- }
-
}