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
committerMichael Bestas <mikeioannina@gmail.com>2017-01-04 22:00:40 +0200
commitaa0ed8c3c2985f1f2efcc1d40717c18f509cfb5c (patch)
tree6bd03d6ff4f7fcb7053808cb437f7abe0779f628 /src/com/android/camera/BaseUI.java
parent13ca178c2f1c614bc6c615b29986fc6002a89d5a (diff)
downloadandroid_packages_apps_Snap-aa0ed8c3c2985f1f2efcc1d40717c18f509cfb5c.tar.gz
android_packages_apps_Snap-aa0ed8c3c2985f1f2efcc1d40717c18f509cfb5c.tar.bz2
android_packages_apps_Snap-aa0ed8c3c2985f1f2efcc1d40717c18f509cfb5c.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);
+ }
}