aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/widget
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/widget')
-rw-r--r--src/main/java/de/pixart/messenger/ui/widget/ClickableMovementMethod.java56
-rw-r--r--src/main/java/de/pixart/messenger/ui/widget/Switch.java102
2 files changed, 79 insertions, 79 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/widget/ClickableMovementMethod.java b/src/main/java/de/pixart/messenger/ui/widget/ClickableMovementMethod.java
index dbf88f1d7..c399a7864 100644
--- a/src/main/java/de/pixart/messenger/ui/widget/ClickableMovementMethod.java
+++ b/src/main/java/de/pixart/messenger/ui/widget/ClickableMovementMethod.java
@@ -9,34 +9,34 @@ import android.widget.TextView;
public class ClickableMovementMethod extends ArrowKeyMovementMethod {
- @Override
- public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
- // Just copied from android.text.method.LinkMovementMethod
- if (event.getAction() == MotionEvent.ACTION_UP) {
- int x = (int) event.getX();
- int y = (int) event.getY();
- x -= widget.getTotalPaddingLeft();
- y -= widget.getTotalPaddingTop();
- x += widget.getScrollX();
- y += widget.getScrollY();
- Layout layout = widget.getLayout();
- int line = layout.getLineForVertical(y);
- int off = layout.getOffsetForHorizontal(line, x);
- ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
- if (link.length != 0) {
- link[0].onClick(widget);
- return true;
- }
- }
- return super.onTouchEvent(widget, buffer, event);
- }
+ @Override
+ public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
+ // Just copied from android.text.method.LinkMovementMethod
+ if (event.getAction() == MotionEvent.ACTION_UP) {
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+ x -= widget.getTotalPaddingLeft();
+ y -= widget.getTotalPaddingTop();
+ x += widget.getScrollX();
+ y += widget.getScrollY();
+ Layout layout = widget.getLayout();
+ int line = layout.getLineForVertical(y);
+ int off = layout.getOffsetForHorizontal(line, x);
+ ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
+ if (link.length != 0) {
+ link[0].onClick(widget);
+ return true;
+ }
+ }
+ return super.onTouchEvent(widget, buffer, event);
+ }
- public static ClickableMovementMethod getInstance() {
- if (sInstance == null) {
- sInstance = new ClickableMovementMethod();
- }
- return sInstance;
- }
+ public static ClickableMovementMethod getInstance() {
+ if (sInstance == null) {
+ sInstance = new ClickableMovementMethod();
+ }
+ return sInstance;
+ }
- private static ClickableMovementMethod sInstance;
+ private static ClickableMovementMethod sInstance;
} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/ui/widget/Switch.java b/src/main/java/de/pixart/messenger/ui/widget/Switch.java
index 2bd4eda3d..40d8f4c99 100644
--- a/src/main/java/de/pixart/messenger/ui/widget/Switch.java
+++ b/src/main/java/de/pixart/messenger/ui/widget/Switch.java
@@ -9,60 +9,60 @@ import com.kyleduo.switchbutton.SwitchButton;
public class Switch extends SwitchButton {
- private int mTouchSlop;
- private int mClickTimeout;
- private float mStartX;
- private float mStartY;
- private OnClickListener mOnClickListener;
+ private int mTouchSlop;
+ private int mClickTimeout;
+ private float mStartX;
+ private float mStartY;
+ private OnClickListener mOnClickListener;
- public Switch(Context context) {
- super(context);
- mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
- mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
- }
+ public Switch(Context context) {
+ super(context);
+ mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
+ mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
+ }
- public Switch(Context context, AttributeSet attrs) {
- super(context, attrs);
- mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
- mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
- }
+ public Switch(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
+ mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
+ }
- public Switch(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
- mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
- }
+ public Switch(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
+ mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
+ }
- @Override
- public void setOnClickListener(OnClickListener onClickListener) {
- this.mOnClickListener = onClickListener;
- }
+ @Override
+ public void setOnClickListener(OnClickListener onClickListener) {
+ this.mOnClickListener = onClickListener;
+ }
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (!isEnabled()) {
- float deltaX = event.getX() - mStartX;
- float deltaY = event.getY() - mStartY;
- int action = event.getAction();
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- mStartX = event.getX();
- mStartY = event.getY();
- break;
- case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_UP:
- float time = event.getEventTime() - event.getDownTime();
- if (deltaX < mTouchSlop && deltaY < mTouchSlop && time < mClickTimeout) {
- if (mOnClickListener != null) {
- this.mOnClickListener.onClick(this);
- }
- }
- break;
- default:
- break;
- }
- return true;
- }
- return super.onTouchEvent(event);
- }
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (!isEnabled()) {
+ float deltaX = event.getX() - mStartX;
+ float deltaY = event.getY() - mStartY;
+ int action = event.getAction();
+ switch (action) {
+ case MotionEvent.ACTION_DOWN:
+ mStartX = event.getX();
+ mStartY = event.getY();
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ case MotionEvent.ACTION_UP:
+ float time = event.getEventTime() - event.getDownTime();
+ if (deltaX < mTouchSlop && deltaY < mTouchSlop && time < mClickTimeout) {
+ if (mOnClickListener != null) {
+ this.mOnClickListener.onClick(this);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+ return super.onTouchEvent(event);
+ }
}