diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-08-16 23:38:59 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-08-31 18:00:01 +0800 |
commit | 0341c03529f04351534a15d06facb096aab7a95f (patch) | |
tree | 48b7e6a5634ab7d55a1d3d8e06052fc4966e02ac /src | |
parent | 6229b81d1fb6e8307d85ab5de35f5a6b48d27c23 (diff) | |
download | packages_apps_LegacyCamera-0341c03529f04351534a15d06facb096aab7a95f.zip packages_apps_LegacyCamera-0341c03529f04351534a15d06facb096aab7a95f.tar.gz packages_apps_LegacyCamera-0341c03529f04351534a15d06facb096aab7a95f.tar.bz2 |
Close the camera setting when an option is tapped.
bug:5141477
Change-Id: I3428922ae6343d5c26f3d85808aeeb6923335802
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/ui/AbstractIndicatorButton.java | 26 | ||||
-rw-r--r-- | src/com/android/camera/ui/BasicSettingPopup.java | 18 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorButton.java | 3 |
3 files changed, 34 insertions, 13 deletions
diff --git a/src/com/android/camera/ui/AbstractIndicatorButton.java b/src/com/android/camera/ui/AbstractIndicatorButton.java index 2bed377..311a3f5 100644 --- a/src/com/android/camera/ui/AbstractIndicatorButton.java +++ b/src/com/android/camera/ui/AbstractIndicatorButton.java @@ -19,6 +19,8 @@ package com.android.camera.ui; import com.android.camera.R; import android.content.Context; +import android.os.Handler; +import android.os.Message; import android.view.MotionEvent; import android.view.View; import android.view.animation.Animation; @@ -33,6 +35,8 @@ public abstract class AbstractIndicatorButton extends RotateImageView { protected final int HIGHLIGHT_COLOR; protected final int DISABLED_COLOR; protected AbstractSettingPopup mPopup; + protected Handler mHandler = new MainHandler(); + private final int MSG_DISMISS_POPUP = 0; public AbstractIndicatorButton(Context context) { super(context); @@ -101,6 +105,7 @@ public abstract class AbstractIndicatorButton extends RotateImageView { abstract protected void initializePopup(); private void showPopup() { + mHandler.removeMessages(MSG_DISMISS_POPUP); if (mPopup == null) initializePopup(); mPopup.setVisibility(View.VISIBLE); @@ -111,12 +116,16 @@ public abstract class AbstractIndicatorButton extends RotateImageView { } public boolean dismissPopup() { + mHandler.removeMessages(MSG_DISMISS_POPUP); if (mPopup != null && mPopup.getVisibility() == View.VISIBLE) { mPopup.clearAnimation(); mPopup.startAnimation(mFadeOut); mPopup.setVisibility(View.GONE); clearColorFilter(); invalidate(); + // Indicator wheel needs to update the highlight indicator if this + // is dismissed by MSG_DISMISS_POPUP. + ((View) getParent()).invalidate(); return true; } return false; @@ -133,4 +142,21 @@ public abstract class AbstractIndicatorButton extends RotateImageView { public void reloadPreference() { if (mPopup != null) mPopup.reloadPreference(); } + + protected void dismissPopupDelayed() { + if (!mHandler.hasMessages(MSG_DISMISS_POPUP)) { + mHandler.sendEmptyMessage(MSG_DISMISS_POPUP); + } + } + + private class MainHandler extends Handler { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_DISMISS_POPUP: + dismissPopup(); + break; + } + } + } } diff --git a/src/com/android/camera/ui/BasicSettingPopup.java b/src/com/android/camera/ui/BasicSettingPopup.java index df7ca1c..6991bae 100644 --- a/src/com/android/camera/ui/BasicSettingPopup.java +++ b/src/com/android/camera/ui/BasicSettingPopup.java @@ -16,6 +16,9 @@ package com.android.camera.ui; +import com.android.camera.IconListPreference; +import com.android.camera.R; + import android.content.Context; import android.util.AttributeSet; import android.view.View; @@ -23,9 +26,6 @@ import android.widget.AdapterView; import android.widget.ListView; import android.widget.SimpleAdapter; -import com.android.camera.IconListPreference; -import com.android.camera.R; - import java.util.ArrayList; import java.util.HashMap; @@ -72,7 +72,6 @@ public class BasicSettingPopup extends AbstractSettingPopup implements new int[] {R.id.text, R.id.image}); ((ListView) mSettingList).setAdapter(listItemAdapter); ((ListView) mSettingList).setOnItemClickListener(this); - ((ListView) mSettingList).setSelector(android.R.color.transparent); reloadPreference(); } @@ -93,14 +92,7 @@ public class BasicSettingPopup extends AbstractSettingPopup implements @Override public void onItemClick(AdapterView<?> parent, View view, int index, long id) { - // If popup window is dismissed, ignore the event. This may happen when - // users press home and then select a setting immediately. - if (getVisibility() != View.VISIBLE) return; - - int oldIndex = mPreference.findIndexOfValue(mPreference.getValue()); - if (oldIndex != index) { - mPreference.setValueIndex(index); - if (mListener != null) mListener.onSettingChanged(); - } + mPreference.setValueIndex(index); + if (mListener != null) mListener.onSettingChanged(); } } diff --git a/src/com/android/camera/ui/IndicatorButton.java b/src/com/android/camera/ui/IndicatorButton.java index ff4703c..6685358 100644 --- a/src/com/android/camera/ui/IndicatorButton.java +++ b/src/com/android/camera/ui/IndicatorButton.java @@ -110,8 +110,11 @@ public class IndicatorButton extends AbstractIndicatorButton implements BasicSet mPopup = popup; } + @Override public void onSettingChanged() { reloadPreference(); + // Dismiss later so the activated state can be updated before dismiss. + dismissPopupDelayed(); if (mListener != null) { mListener.onSettingChanged(); } |