summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/BaseUI.java
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-11-09 00:08:42 -0800
committerSteve Kondik <steve@cyngn.com>2016-11-13 23:33:36 -0800
commit4538ee80f8a9eb338281db00fb349e111eeb5aaf (patch)
treebb81593e683955db458c96b6b5fb0fdf71b314ae /src/com/android/camera/BaseUI.java
parent0b4b53688f8486537d9d58dc6448ca2db8c67c7d (diff)
downloadandroid_packages_apps_Snap-4538ee80f8a9eb338281db00fb349e111eeb5aaf.tar.gz
android_packages_apps_Snap-4538ee80f8a9eb338281db00fb349e111eeb5aaf.tar.bz2
android_packages_apps_Snap-4538ee80f8a9eb338281db00fb349e111eeb5aaf.zip
snap: UX improvements v1
* Make the camera controls do sane things- get rid of the manual placement of every widget and use layouts * Animate everything correctly * Show ripples when clicking the shutter * Clean up a metric ton of dead code * Moved more code into BaseUI * Make setting up the camera controls less verbose and magical * Fixed up panorama layout Change-Id: Iaed44ca0201a2e2641e1c2460d3ff9ec3eae2d85
Diffstat (limited to 'src/com/android/camera/BaseUI.java')
-rw-r--r--src/com/android/camera/BaseUI.java97
1 files changed, 96 insertions, 1 deletions
diff --git a/src/com/android/camera/BaseUI.java b/src/com/android/camera/BaseUI.java
index 7587c0511..372106258 100644
--- a/src/com/android/camera/BaseUI.java
+++ b/src/com/android/camera/BaseUI.java
@@ -1,11 +1,52 @@
package com.android.camera;
+import android.graphics.Point;
import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.camera.ui.CameraControls;
+import com.android.camera.ui.ModuleSwitcher;
+import com.android.camera.util.CameraUtil;
+
+import org.codeaurora.snapcam.R;
/** we can start accumulating common code between UI classes here
* toward an eventual unification - WF */
public abstract class BaseUI {
- protected View mPreviewCover;
+
+ protected final CameraControls mCameraControls;
+ protected final View mPreviewCover;
+
+ protected final CameraActivity mActivity;
+ protected final ViewGroup mRootView;
+
+ protected int mTopMargin = 0;
+ protected int mBottomMargin = 0;
+ protected int mScreenRatio = CameraUtil.RATIO_UNKNOWN;
+
+ public BaseUI(CameraActivity activity, ViewGroup rootView, int layout) {
+ mActivity = activity;
+ mRootView = rootView;
+
+ mActivity.getLayoutInflater().inflate(layout, mRootView, true);
+
+ mCameraControls = (CameraControls) mRootView.findViewById(R.id.camera_controls);
+ mPreviewCover = mRootView.findViewById(R.id.preview_cover);
+
+ Point size = new Point();
+ mActivity.getWindowManager().getDefaultDisplay().getRealSize(size);
+ mScreenRatio = CameraUtil.determineRatio(size.x, size.y);
+ calculateMargins(size);
+ mCameraControls.setMargins(mTopMargin, mBottomMargin);
+ }
+
+ private void calculateMargins(Point size) {
+ int l = size.x > size.y ? size.x : size.y;
+ int tm = mActivity.getResources().getDimensionPixelSize(R.dimen.preview_top_margin);
+ int bm = mActivity.getResources().getDimensionPixelSize(R.dimen.preview_bottom_margin);
+ mTopMargin = l / 4 * tm / (tm + bm);
+ mBottomMargin = l / 4 - mTopMargin;
+ }
public void showPreviewCover() {
if (mPreviewCover != null && mPreviewCover.getVisibility() != View.VISIBLE) {
@@ -24,4 +65,58 @@ public abstract class BaseUI {
mPreviewCover.setAlpha(alpha);
}
}
+
+ public boolean isPreviewCoverVisible() {
+ return mPreviewCover != null && mPreviewCover.getVisibility() == View.VISIBLE;
+ }
+
+ public void hideUI() {
+ hideUI(false);
+ }
+
+ protected void hideUI(boolean toBlack) {
+ if (mCameraControls != null) {
+ mCameraControls.hideUI(toBlack);
+ }
+ }
+
+ protected void showUI() {
+ if (mCameraControls != null) {
+ mCameraControls.showUI();
+ }
+ }
+
+ public boolean arePreviewControlsVisible() {
+ return mCameraControls != null && mCameraControls.arePreviewControlsVisible();
+ }
+
+ public void hideSwitcher() {
+ if (mCameraControls != null) {
+ mCameraControls.hideSwitcher();
+ }
+ }
+
+ public void showSwitcher() {
+ if (mCameraControls != null) {
+ mCameraControls.showSwitcher();
+ }
+ }
+
+ public void removeControlView(View v) {
+ if (mCameraControls != null) {
+ mCameraControls.removeFromViewList(v);
+ }
+ }
+
+ public void setSwitcherIndex() {
+ int module = ModuleSwitcher.PHOTO_MODULE_INDEX;
+ if (this instanceof WideAnglePanoramaUI) {
+ module = ModuleSwitcher.WIDE_ANGLE_PANO_MODULE_INDEX;
+ } else if (this instanceof VideoUI) {
+ module = ModuleSwitcher.VIDEO_MODULE_INDEX;
+ } else if (this instanceof CaptureUI) {
+ module = ModuleSwitcher.CAPTURE_MODULE_INDEX;
+ }
+ mCameraControls.setModuleIndex(module);
+ }
}