summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/app/CameraAppUI.java19
-rw-r--r--src/com/android/camera/widget/IndicatorIconController.java87
-rw-r--r--src/com/android/camera/widget/IndicatorOverlay.java143
-rw-r--r--src/com/android/camera/widget/ModeOptionsOverlay.java62
4 files changed, 99 insertions, 212 deletions
diff --git a/src/com/android/camera/app/CameraAppUI.java b/src/com/android/camera/app/CameraAppUI.java
index a4af75f10..4e240b62a 100644
--- a/src/com/android/camera/app/CameraAppUI.java
+++ b/src/com/android/camera/app/CameraAppUI.java
@@ -53,7 +53,6 @@ import com.android.camera.util.PhotoSphereHelper;
import com.android.camera.util.UsageStatistics;
import com.android.camera.widget.FilmstripLayout;
import com.android.camera.widget.IndicatorIconController;
-import com.android.camera.widget.IndicatorOverlay;
import com.android.camera.widget.ModeOptionsOverlay;
import com.android.camera2.R;
import com.google.common.logging.eventprotos;
@@ -383,7 +382,6 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
private FrameLayout mModuleUI;
private BottomBar mBottomBar;
private ModeOptionsOverlay mModeOptionsOverlay;
- private IndicatorOverlay mIndicatorOverlay;
private boolean mShouldShowShimmy = false;
private IndicatorIconController mIndicatorIconController;
@@ -742,7 +740,6 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
* set on the following app ui elements:
* {@link com.android.camera.ui.PreviewOverlay},
* {@link com.android.camera.ui.BottomBar},
- * {@link com.android.camera.ui.IndicatorOverlay},
* {@link com.android.camera.ui.IndicatorIconController}.
*/
private void onPreviewListenerChanged() {
@@ -761,18 +758,6 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
mTextureViewHelper.addPreviewAreaSizeChangedListener(mBottomBar);
mTextureViewHelper.addPreviewAreaSizeChangedListener(mModeOptionsOverlay);
}
-
- // Set a listener for resizing the indicator overlay on
- // preview size changes.
- mIndicatorOverlay = (IndicatorOverlay) mAppRootView.findViewById(
- R.id.indicator_overlay);
- mTextureViewHelper.addPreviewAreaSizeChangedListener(mIndicatorOverlay);
-
- if (mIndicatorIconController == null) {
- mIndicatorIconController =
- new IndicatorIconController(mController, mAppRootView);
- }
- mController.getSettingsManager().addListener(mIndicatorIconController);
}
/**
@@ -847,14 +832,17 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
mIndicatorIconController =
new IndicatorIconController(mController, mAppRootView);
}
+ mIndicatorIconController.setListener(mModeOptionsOverlay);
mController.getButtonManager().load(mCameraRootView);
mController.getButtonManager().setListener(mIndicatorIconController);
+ mController.getSettingsManager().addListener(mIndicatorIconController);
}
// TODO: Remove this when refactor is done.
// This is here to ensure refactored modules can work with not-yet-refactored ones.
public void clearCameraUI() {
+ mController.getSettingsManager().removeListener(mIndicatorIconController);
mCameraRootView.removeAllViews();
mModuleUI = null;
mTextureView = null;
@@ -862,7 +850,6 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
mPreviewOverlay = null;
mBottomBar = null;
mModeOptionsOverlay = null;
- mIndicatorOverlay = null;
mIndicatorIconController = null;
setBottomBarShutterListener(null);
}
diff --git a/src/com/android/camera/widget/IndicatorIconController.java b/src/com/android/camera/widget/IndicatorIconController.java
index d628fa25c..8d81618ea 100644
--- a/src/com/android/camera/widget/IndicatorIconController.java
+++ b/src/com/android/camera/widget/IndicatorIconController.java
@@ -48,13 +48,13 @@ public class IndicatorIconController
private ImageView mFlashIndicator;
private ImageView mHdrIndicator;
- private ImageView mPanoramaIndicator;
private TypedArray mFlashIndicatorPhotoIcons;
private TypedArray mFlashIndicatorVideoIcons;
private TypedArray mHdrPlusIndicatorIcons;
private TypedArray mHdrIndicatorIcons;
- private TypedArray mPanoramaIndicatorIcons;
+
+ private OnIndicatorVisibilityChangedListener mListener;
private AppController mController;
@@ -64,7 +64,6 @@ public class IndicatorIconController
mFlashIndicator = (ImageView) root.findViewById(R.id.flash_indicator);
mHdrIndicator = (ImageView) root.findViewById(R.id.hdr_indicator);
- mPanoramaIndicator = (ImageView) root.findViewById(R.id.panorama_indicator);
mFlashIndicatorPhotoIcons = context.getResources().obtainTypedArray(
R.array.camera_flashmode_indicator_icons);
@@ -74,10 +73,22 @@ public class IndicatorIconController
R.array.pref_camera_hdr_plus_indicator_icons);
mHdrIndicatorIcons = context.getResources().obtainTypedArray(
R.array.pref_camera_hdr_indicator_icons);
- if (PhotoSphereHelper.getPanoramaIndicatorArrayId() > 0) {
- mPanoramaIndicatorIcons = context.getResources().obtainTypedArray(
- PhotoSphereHelper.getPanoramaIndicatorArrayId());
- }
+ }
+
+ /**
+ * A listener for responding to changes in indicator visibility.
+ */
+ public interface OnIndicatorVisibilityChangedListener {
+ public void onIndicatorVisibilityChanged(View indicator);
+ }
+
+ /**
+ * Set an {@link OnIndicatorVisibilityChangedListener} which will be
+ * called whenever an indicator changes visibility, caused by this
+ * controller.
+ */
+ public void setListener(OnIndicatorVisibilityChangedListener listener) {
+ mListener = listener;
}
@Override
@@ -112,14 +123,6 @@ public class IndicatorIconController
syncHdrIndicator();
break;
}
- case ButtonManager.BUTTON_PANO_HORIZONTAL: {
- syncPanoramaIndicator();
- break;
- }
- case ButtonManager.BUTTON_PANO_VERTICAL: {
- syncPanoramaIndicator();
- break;
- }
default:
// Do nothing. The indicator doesn't care
// about button that don't correspond to indicators.
@@ -133,7 +136,6 @@ public class IndicatorIconController
public void syncIndicators() {
syncFlashIndicator();
syncHdrIndicator();
- syncPanoramaIndicator();
}
/**
@@ -158,7 +160,12 @@ public class IndicatorIconController
mFlashIndicator, mFlashIndicatorPhotoIcons, false);
}
} else {
- mFlashIndicator.setVisibility(View.GONE);
+ if (mFlashIndicator.getVisibility() != View.GONE) {
+ mFlashIndicator.setVisibility(View.GONE);
+ if (mListener != null) {
+ mListener.onIndicatorVisibilityChanged(mFlashIndicator);
+ }
+ }
}
}
@@ -180,27 +187,12 @@ public class IndicatorIconController
SettingsManager.SETTING_CAMERA_HDR,
mHdrIndicator, mHdrIndicatorIcons, false);
} else {
- mHdrIndicator.setVisibility(View.GONE);
- }
- }
-
- /**
- * Sync the icon and the visibility of the panorama indicator.
- */
- private void syncPanoramaIndicator() {
- ButtonManager buttonManager = mController.getButtonManager();
- // If refocus isn't an enabled and visible option,
- // do not show the indicator.
- boolean panoEnabled = (buttonManager.isEnabled(ButtonManager.BUTTON_PANO_HORIZONTAL)
- && buttonManager.isEnabled(ButtonManager.BUTTON_PANO_VERTICAL));
- boolean panoVisible = (buttonManager.isVisible(ButtonManager.BUTTON_PANO_HORIZONTAL)
- && buttonManager.isVisible(ButtonManager.BUTTON_PANO_VERTICAL));
- if (panoEnabled && panoVisible && mPanoramaIndicatorIcons != null) {
- setIndicatorState(mController.getSettingsManager(),
- SettingsManager.SETTING_CAMERA_PANO_ORIENTATION,
- mPanoramaIndicator, mPanoramaIndicatorIcons, true);
- } else {
- mPanoramaIndicator.setVisibility(View.GONE);
+ if (mHdrIndicator.getVisibility() != View.GONE) {
+ mHdrIndicator.setVisibility(View.GONE);
+ if (mListener != null) {
+ mListener.onIndicatorVisibilityChanged(mHdrIndicator);
+ }
+ }
}
}
@@ -229,10 +221,21 @@ public class IndicatorIconController
imageView.setImageDrawable(drawable);
// Set the indicator visible if not in default state.
+ boolean visibilityChanged = false;
if (!showDefault && settingsManager.isDefault(id)) {
- imageView.setVisibility(View.GONE);
+ if (imageView.getVisibility() != View.GONE) {
+ imageView.setVisibility(View.GONE);
+ visibilityChanged = true;
+ }
} else {
- imageView.setVisibility(View.VISIBLE);
+ if (imageView.getVisibility() != View.VISIBLE) {
+ imageView.setVisibility(View.VISIBLE);
+ visibilityChanged = true;
+ }
+ }
+
+ if (mListener != null && visibilityChanged) {
+ mListener.onIndicatorVisibilityChanged(imageView);
}
}
@@ -251,10 +254,6 @@ public class IndicatorIconController
syncHdrIndicator();
break;
}
- case SettingsManager.SETTING_CAMERA_PANO_ORIENTATION: {
- syncPanoramaIndicator();
- break;
- }
default: {
// Do nothing.
}
diff --git a/src/com/android/camera/widget/IndicatorOverlay.java b/src/com/android/camera/widget/IndicatorOverlay.java
deleted file mode 100644
index 703c8f396..000000000
--- a/src/com/android/camera/widget/IndicatorOverlay.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-package com.android.camera.widget;
-
-import android.content.Context;
-import android.content.res.Configuration;
-import android.graphics.RectF;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-import com.android.camera.ui.PreviewStatusListener;
-
-import com.android.camera2.R;
-
-/**
- * IndicatorOverlay is a FrameLayout which positions indicator icons in
- * in the bottom right corner of the preview that is visible
- * above the bottom bar. This overlay takes its horizontal dimension from
- * the preview, and its vertical dimension relative to the bottom bar.
- */
-public class IndicatorOverlay extends FrameLayout
- implements PreviewStatusListener.PreviewAreaSizeChangedListener {
-
- private final static String TAG = "IndicatorOverlay";
- private final static int BOTTOM_RIGHT = Gravity.BOTTOM | Gravity.RIGHT;
- private final static int TOP_RIGHT = Gravity.TOP | Gravity.RIGHT;
-
- private int mPreviewWidth;
- private int mPreviewHeight;
-
- private LinearLayout mIndicatorOverlayIcons;
-
- /**
- * A listener for setting a {@link android.view.ViewGroup} invisible
- * once all of its children are gone.
- *
- * This is necessary if the group has a background with a minimum height
- * and width greater than zero. Otherwise, the background would show
- * despite an empty group.
- */
- private View.OnLayoutChangeListener mLayoutChangeListener =
- new View.OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- ViewGroup group = (ViewGroup) v;
- if (group.getChildCount() > 0) {
- int visibility = View.INVISIBLE;
- for (int i = 0; i < group.getChildCount(); i++) {
- View child = group.getChildAt(i);
- if (child != null && child.getVisibility() != View.GONE) {
- visibility = View.VISIBLE;
- break;
- }
- }
- v.setVisibility(visibility);
- }
- }
- };
-
- public IndicatorOverlay(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- public void onFinishInflate() {
- mIndicatorOverlayIcons = (LinearLayout) findViewById(R.id.indicator_overlay_icons);
- mIndicatorOverlayIcons.addOnLayoutChangeListener(mLayoutChangeListener);
- Configuration configuration = getContext().getResources().getConfiguration();
- checkOrientation(configuration.orientation);
- }
-
- @Override
- public void onConfigurationChanged(Configuration configuration) {
- super.onConfigurationChanged(configuration);
- checkOrientation(configuration.orientation);
- }
-
- @Override
- public void onPreviewAreaSizeChanged(RectF previewArea) {
- mPreviewWidth = (int) previewArea.width();
- mPreviewHeight = (int) previewArea.height();
- setLayoutDimensions();
- }
-
- /**
- * The overlay takes its horizontal dimension from the preview. The vertical
- * dimension of the overlay is determined by its parent layout, which has
- * knowledge of the bottom bar dimensions.
- */
- private void setLayoutDimensions() {
- if (mPreviewWidth == 0 || mPreviewHeight == 0) {
- return;
- }
-
- boolean isPortrait = Configuration.ORIENTATION_PORTRAIT
- == getResources().getConfiguration().orientation;
-
- ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) getLayoutParams();
- if (isPortrait) {
- params.width = mPreviewWidth;
- } else {
- params.height = mPreviewHeight;
- }
- setLayoutParams(params);
- }
-
- /**
- * Set the layout gravity of the child layout to be bottom or top right
- * depending on orientation.
- */
- private void checkOrientation(int orientation) {
- final boolean isPortrait = Configuration.ORIENTATION_PORTRAIT == orientation;
- FrameLayout.LayoutParams params
- = (FrameLayout.LayoutParams) mIndicatorOverlayIcons.getLayoutParams();
-
- if (isPortrait && params.gravity != BOTTOM_RIGHT) {
- params.gravity = BOTTOM_RIGHT;
- requestLayout();
- } else if (!isPortrait && params.gravity != TOP_RIGHT) {
- params.gravity = TOP_RIGHT;
- requestLayout();
- }
- }
-}
diff --git a/src/com/android/camera/widget/ModeOptionsOverlay.java b/src/com/android/camera/widget/ModeOptionsOverlay.java
index ee2f60739..66cb172fe 100644
--- a/src/com/android/camera/widget/ModeOptionsOverlay.java
+++ b/src/com/android/camera/widget/ModeOptionsOverlay.java
@@ -26,7 +26,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
import com.android.camera.ui.PreviewOverlay;
import com.android.camera.ui.PreviewStatusListener;
@@ -40,7 +41,8 @@ import com.android.camera2.R;
*/
public class ModeOptionsOverlay extends FrameLayout
implements PreviewStatusListener.PreviewAreaSizeChangedListener,
- PreviewOverlay.OnPreviewTouchedListener {
+ PreviewOverlay.OnPreviewTouchedListener,
+ IndicatorIconController.OnIndicatorVisibilityChangedListener {
private final static String TAG = "ModeOptionsOverlay";
@@ -52,7 +54,14 @@ public class ModeOptionsOverlay extends FrameLayout
private int mPreviewHeight;
private TopRightWeightedLayout mModeOptions;
- private ImageButton mModeOptionsToggle;
+
+ // The mode options toggle can be either a default image, or a
+ // group of on screen indicators.
+ private FrameLayout mModeOptionsToggle;
+ // Default image for mode options toggle.
+ private ImageView mThreeDots;
+ // Group of on screen indicators for mode options toggle.
+ private LinearLayout mIndicators;
/**
* A generic Runnable for setting the options toggle to the capture
@@ -62,10 +71,8 @@ public class ModeOptionsOverlay extends FrameLayout
new Runnable() {
@Override
public void run() {
- if (mModeOptions != null && mModeOptionsToggle != null) {
- mModeOptions.setVisibility(View.INVISIBLE);
- mModeOptionsToggle.setVisibility(View.VISIBLE);
- }
+ mModeOptions.setVisibility(View.INVISIBLE);
+ mModeOptionsToggle.setVisibility(View.VISIBLE);
}
};
@@ -75,7 +82,7 @@ public class ModeOptionsOverlay extends FrameLayout
@Override
public void onFinishInflate() {
- mModeOptions = (TopRightWeightedLayout) findViewById(R.id.bottombar_options);
+ mModeOptions = (TopRightWeightedLayout) findViewById(R.id.mode_options);
mModeOptions.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -88,7 +95,7 @@ public class ModeOptionsOverlay extends FrameLayout
}
});
- mModeOptionsToggle = (ImageButton) findViewById(R.id.bottombar_options_toggle);
+ mModeOptionsToggle = (FrameLayout) findViewById(R.id.mode_options_toggle);
mModeOptionsToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -96,6 +103,10 @@ public class ModeOptionsOverlay extends FrameLayout
mModeOptions.setVisibility(View.VISIBLE);
}
});
+
+ mThreeDots = (ImageView) findViewById(R.id.three_dots);
+ mIndicators = (LinearLayout) findViewById(R.id.indicator_icons);
+ showCorrectToggleView(mThreeDots, mIndicators);
}
@Override
@@ -104,6 +115,11 @@ public class ModeOptionsOverlay extends FrameLayout
closeModeOptionsDelayed(0);
}
+ @Override
+ public void onIndicatorVisibilityChanged(View indicator) {
+ showCorrectToggleView(mThreeDots, mIndicators);
+ }
+
/**
* Schedule (or re-schedule) the options menu to be closed after a number
* of milliseconds. If the options menu is already closed, nothing is
@@ -196,4 +212,32 @@ public class ModeOptionsOverlay extends FrameLayout
requestLayout();
}
+
+ /**
+ * Show the correct toggle view: the default view if the group has
+ * no visible children, otherwise the default view.
+ */
+ private void showCorrectToggleView(View defaultView, ViewGroup group) {
+ if (getVisibleChildCount(group) > 0) {
+ defaultView.setVisibility(View.GONE);
+ group.setVisibility(View.VISIBLE);
+ } else {
+ group.setVisibility(View.GONE);
+ defaultView.setVisibility(View.VISIBLE);
+ }
+ }
+
+ /**
+ * Get the number of a ViewGroup's visible children.
+ */
+ private int getVisibleChildCount(ViewGroup group) {
+ int visible = 0;
+ for (int i = 0; i < group.getChildCount(); i++) {
+ View child = group.getChildAt(i);
+ if (child != null && child.getVisibility() == View.VISIBLE) {
+ visible++;
+ }
+ }
+ return visible;
+ }
}