summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ShutterButton.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/ShutterButton.java')
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/ShutterButton.java32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/com/android/camera/ShutterButton.java b/src/com/android/camera/ShutterButton.java
index e1499a6..e44afe5 100644..100755
--- a/src/com/android/camera/ShutterButton.java
+++ b/src/com/android/camera/ShutterButton.java
@@ -18,6 +18,7 @@ package com.android.camera;
import android.content.Context;
import android.util.AttributeSet;
+import android.view.View;
import android.widget.ImageView;
/**
@@ -25,7 +26,7 @@ import android.widget.ImageView;
* It's currently an {@code ImageView} that can call a delegate when the
* pressed state changes.
*/
-public class ShutterButton extends ImageView {
+public class ShutterButton extends ImageView implements View.OnLongClickListener {
/**
* A callback to be invoked when a ShutterButton's pressed state changes.
*/
@@ -39,25 +40,30 @@ public class ShutterButton extends ImageView {
void onShutterButtonClick(ShutterButton b);
}
+ /**
+ * A callback to be invoked when a ShutterButton's long pressed.
+ */
+ public interface OnShutterButtonLongPressListener {
+ void onShutterButtonLongPressed(ShutterButton b);
+ }
+
private OnShutterButtonListener mListener;
+ private OnShutterButtonLongPressListener mLongPressListener;
private boolean mOldPressed;
- public ShutterButton(Context context) {
- super(context);
- }
-
public ShutterButton(Context context, AttributeSet attrs) {
super(context, attrs);
- }
-
- public ShutterButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
+ setOnLongClickListener(this);
}
public void setOnShutterButtonListener(OnShutterButtonListener listener) {
mListener = listener;
}
+ public void setOnShutterButtonLongPressListener(OnShutterButtonLongPressListener listener) {
+ mLongPressListener = listener;
+ }
+
/**
* Hook into the drawable state changing to get changes to isPressed -- the
* onPressed listener doesn't always get called when the pressed state
@@ -116,4 +122,12 @@ public class ShutterButton extends ImageView {
}
return result;
}
+
+ @Override
+ public boolean onLongClick(View v) {
+ if (mLongPressListener != null) {
+ mLongPressListener.onShutterButtonLongPressed(this);
+ }
+ return false;
+ }
}