diff options
-rw-r--r-- | res/drawable-hdpi/bg_options_indicator.9.png | bin | 1056 -> 1003 bytes | |||
-rw-r--r-- | res/drawable-mdpi/bg_options_indicator.9.png | bin | 766 -> 690 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/bg_options_indicator.9.png | bin | 1684 -> 1452 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi/bg_options_indicator.9.png | bin | 2989 -> 2878 bytes | |||
-rw-r--r-- | res/layout/indicators.xml | 34 | ||||
-rw-r--r-- | res/layout/mode_options_bottombar.xml | 49 | ||||
-rw-r--r-- | res/values/styles.xml | 1 | ||||
-rw-r--r-- | src/com/android/camera/app/CameraAppUI.java | 19 | ||||
-rw-r--r-- | src/com/android/camera/widget/IndicatorIconController.java | 87 | ||||
-rw-r--r-- | src/com/android/camera/widget/IndicatorOverlay.java | 143 | ||||
-rw-r--r-- | src/com/android/camera/widget/ModeOptionsOverlay.java | 62 |
11 files changed, 147 insertions, 248 deletions
diff --git a/res/drawable-hdpi/bg_options_indicator.9.png b/res/drawable-hdpi/bg_options_indicator.9.png Binary files differindex 30c1cb568..08b55a4fd 100644 --- a/res/drawable-hdpi/bg_options_indicator.9.png +++ b/res/drawable-hdpi/bg_options_indicator.9.png diff --git a/res/drawable-mdpi/bg_options_indicator.9.png b/res/drawable-mdpi/bg_options_indicator.9.png Binary files differindex c79095b87..67984c96b 100644 --- a/res/drawable-mdpi/bg_options_indicator.9.png +++ b/res/drawable-mdpi/bg_options_indicator.9.png diff --git a/res/drawable-xhdpi/bg_options_indicator.9.png b/res/drawable-xhdpi/bg_options_indicator.9.png Binary files differindex 3dc347ebf..4a6882bee 100644 --- a/res/drawable-xhdpi/bg_options_indicator.9.png +++ b/res/drawable-xhdpi/bg_options_indicator.9.png diff --git a/res/drawable-xxhdpi/bg_options_indicator.9.png b/res/drawable-xxhdpi/bg_options_indicator.9.png Binary files differindex d2bf7c31f..fd2027e48 100644 --- a/res/drawable-xxhdpi/bg_options_indicator.9.png +++ b/res/drawable-xxhdpi/bg_options_indicator.9.png diff --git a/res/layout/indicators.xml b/res/layout/indicators.xml new file mode 100644 index 000000000..bc05852eb --- /dev/null +++ b/res/layout/indicators.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> +<!-- This layout is shared by phone and tablet in landscape orientation. --> +<merge xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_height="match_parent" + android:layout_width="match_parent"> + <!-- TODO: make horizontal once nine patch stretches horizontally --> + <LinearLayout + android:id="@+id/indicator_icons" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:background="@drawable/bg_options_indicator" > + <ImageView + android:id="@+id/hdr_indicator" + style="@style/IndicatorIcon" /> + <ImageView + android:id="@+id/flash_indicator" + style="@style/IndicatorIcon" /> + </LinearLayout> +</merge>
\ No newline at end of file diff --git a/res/layout/mode_options_bottombar.xml b/res/layout/mode_options_bottombar.xml index 4dd623239..95a13155e 100644 --- a/res/layout/mode_options_bottombar.xml +++ b/res/layout/mode_options_bottombar.xml @@ -32,7 +32,7 @@ android:layout_weight="1" android:layout_gravity="center"> <com.android.camera.ui.TopRightWeightedLayout - android:id="@+id/bottombar_options" + android:id="@+id/mode_options" android:layout_width="match_parent" android:layout_height="@dimen/mode_options_height" android:orientation="horizontal" @@ -57,45 +57,22 @@ camera:contentDescriptionIds="@array/camera_id_descriptions" /> </com.android.camera.ui.TopRightWeightedLayout> - <ImageButton - android:id="@+id/bottombar_options_toggle" + <FrameLayout + android:id="@+id/mode_options_toggle" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="bottom|right" - android:padding="20dp" - android:scaleType="center" - android:src="@drawable/ic_options_active" - android:background="@null" - android:contentDescription="@string/more_options_desc" /> - </com.android.camera.widget.ModeOptionsOverlay> - - <!-- TODO: integrate into the mode options overlay --> - <com.android.camera.widget.IndicatorOverlay - android:id="@+id/indicator_overlay" - android:layout_width="match_parent" - android:layout_height="0px" - android:layout_weight="1" - android:visibility="gone" - android:padding="@dimen/indicator_overlay_padding" - android:layout_gravity="top|center_horizontal" > - <LinearLayout - android:id="@+id/indicator_overlay_icons" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - android:background="@drawable/bg_options_indicator" + android:padding="12dp" android:layout_gravity="bottom|right" > <ImageView - android:id="@+id/panorama_indicator" - style="@style/IndicatorIcon" /> - <ImageView - android:id="@+id/hdr_indicator" - style="@style/IndicatorIcon" /> - <ImageView - android:id="@+id/flash_indicator" - style="@style/IndicatorIcon" /> - </LinearLayout> - </com.android.camera.widget.IndicatorOverlay> + android:id="@+id/three_dots" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:scaleType="center" + android:src="@drawable/ic_options_active" + android:background="@null" /> + <include layout="@layout/indicators" /> + </FrameLayout> + </com.android.camera.widget.ModeOptionsOverlay> <include layout="@layout/bottom_bar" /> </com.android.camera.ui.RotatableLinearLayout> diff --git a/res/values/styles.xml b/res/values/styles.xml index b827a2ed9..96908f55b 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -286,6 +286,7 @@ <style name="IndicatorIcon"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> + <item name="android:visibility">gone</item> <item name="android:background">@null</item> </style> <style name="ModeOption"> 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; + } } |