// Path: src/us/shandian/blacklight/support/HackyMovementMethod.java
// public class HackyMovementMethod extends LinkMovementMethod
// {
// 	private static final String TAG = HackyMovementMethod.class.getSimpleName();
// 	
// 	private static HackyMovementMethod sInstance;
// 	
// 	private BackgroundColorSpan mGray;
// 	
// 	private boolean mIsLinkHit = false;
// 	
// 	public static HackyMovementMethod getInstance() {
// 		if (sInstance == null) {
// 			sInstance = new HackyMovementMethod();
// 		}
// 		
// 		return sInstance;
// 	}
// 
// 	@Override
// 	public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
// 		if (mGray == null) {
// 			mGray = new BackgroundColorSpan(widget.getContext().getResources().getColor(R.color.selector_gray));
// 		}
// 		
// 		mIsLinkHit = false;
// 		
// 		int action = event.getAction();
// 		
// 		if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
// 			int x = (int) event.getX();
// 			int y = (int) event.getY();
// 			
// 			if (DEBUG) {
// 				Log.d(TAG, "x = " + x + " y = " + y);
// 			}
// 			
// 			x -= widget.getTotalPaddingLeft();
// 			y -= widget.getTotalPaddingTop();
// 			
// 			if (DEBUG) {
// 				Log.d(TAG, "x = " + x + " y = " + y);
// 			}
// 			
// 			x += widget.getScrollX();
// 			y += widget.getScrollY();
// 			
// 			int line = widget.getLayout().getLineForVertical(y);
// 			int offset = widget.getLayout().getOffsetForHorizontal(line, x);
// 			
// 			ClickableSpan[] spans = buffer.getSpans(offset, offset, ClickableSpan.class);
// 			
// 			if (DEBUG) {
// 				Log.d(TAG, "x = " + x + " y = " + y);
// 				Log.d(TAG, "line = " + line + " offset = " + offset);
// 				Log.d(TAG, "spans.lenth = " + spans.length);
// 			}
// 			
// 			if (spans.length != 0) {
// 				int start = buffer.getSpanStart(spans[0]);
// 				int end = buffer.getSpanEnd(spans[0]);
// 				
// 				mIsLinkHit = true;
// 				
// 				if (action == MotionEvent.ACTION_DOWN) {
// 					if (DEBUG) {
// 						Log.d(TAG, "Down event detected");
// 					}
// 					
// 					buffer.setSpan(mGray, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// 				} else if (action == MotionEvent.ACTION_UP) {
// 					if (DEBUG) {
// 						Log.d(TAG, "Up event detected");
// 					}
// 					
// 					spans[0].onClick(widget);
// 					
// 					buffer.removeSpan(mGray);
// 				}
// 				
// 				return true;
// 			}
// 		} else {
// 			buffer.removeSpan(mGray);
// 		}
// 		
// 		return Touch.onTouchEvent(widget, buffer, event);
// 	}
// 	
// 	public boolean isLinkHit() {
// 		boolean ret = mIsLinkHit;
// 		mIsLinkHit = false;
// 		return ret;
// 	}
// }


import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.TextView;
import android.text.method.MovementMethod;
import us.shandian.blacklight.support.HackyMovementMethod;
/* 
 * Copyright (C) 2014 Peter Cai
 *
 * This file is part of BlackLight
 *
 * BlackLight is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * BlackLight is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with BlackLight.  If not, see <http://www.gnu.org/licenses/>.
 */

package us.shandian.blacklight.ui.common;



/*
  Hack to fix conflict between MovementMethod and OnClickListener
*/
public class HackyTextView extends TextView
{
	public HackyTextView(Context context) {
		super(context);
	}
	
	public HackyTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		boolean ret = super.onTouchEvent(event);
		
		MovementMethod method = getMovementMethod();
// Path: src/us/shandian/blacklight/support/HackyMovementMethod.java
// public class HackyMovementMethod extends LinkMovementMethod
// {
// 	private static final String TAG = HackyMovementMethod.class.getSimpleName();
// 	
// 	private static HackyMovementMethod sInstance;
// 	
// 	private BackgroundColorSpan mGray;
// 	
// 	private boolean mIsLinkHit = false;
// 	
// 	public static HackyMovementMethod getInstance() {
// 		if (sInstance == null) {
// 			sInstance = new HackyMovementMethod();
// 		}
// 		
// 		return sInstance;
// 	}
// 
// 	@Override
// 	public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
// 		if (mGray == null) {
// 			mGray = new BackgroundColorSpan(widget.getContext().getResources().getColor(R.color.selector_gray));
// 		}
// 		
// 		mIsLinkHit = false;
// 		
// 		int action = event.getAction();
// 		
// 		if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
// 			int x = (int) event.getX();
// 			int y = (int) event.getY();
// 			
// 			if (DEBUG) {
// 				Log.d(TAG, "x = " + x + " y = " + y);
// 			}
// 			
// 			x -= widget.getTotalPaddingLeft();
// 			y -= widget.getTotalPaddingTop();
// 			
// 			if (DEBUG) {
// 				Log.d(TAG, "x = " + x + " y = " + y);
// 			}
// 			
// 			x += widget.getScrollX();
// 			y += widget.getScrollY();
// 			
// 			int line = widget.getLayout().getLineForVertical(y);
// 			int offset = widget.getLayout().getOffsetForHorizontal(line, x);
// 			
// 			ClickableSpan[] spans = buffer.getSpans(offset, offset, ClickableSpan.class);
// 			
// 			if (DEBUG) {
// 				Log.d(TAG, "x = " + x + " y = " + y);
// 				Log.d(TAG, "line = " + line + " offset = " + offset);
// 				Log.d(TAG, "spans.lenth = " + spans.length);
// 			}
// 			
// 			if (spans.length != 0) {
// 				int start = buffer.getSpanStart(spans[0]);
// 				int end = buffer.getSpanEnd(spans[0]);
// 				
// 				mIsLinkHit = true;
// 				
// 				if (action == MotionEvent.ACTION_DOWN) {
// 					if (DEBUG) {
// 						Log.d(TAG, "Down event detected");
// 					}
// 					
// 					buffer.setSpan(mGray, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// 				} else if (action == MotionEvent.ACTION_UP) {
// 					if (DEBUG) {
// 						Log.d(TAG, "Up event detected");
// 					}
// 					
// 					spans[0].onClick(widget);
// 					
// 					buffer.removeSpan(mGray);
// 				}
// 				
// 				return true;
// 			}
// 		} else {
// 			buffer.removeSpan(mGray);
// 		}
// 		
// 		return Touch.onTouchEvent(widget, buffer, event);
// 	}
// 	
// 	public boolean isLinkHit() {
// 		boolean ret = mIsLinkHit;
// 		mIsLinkHit = false;
// 		return ret;
// 	}
// }


// Path: src/us/shandian/blacklight/ui/common/HackyTextView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.TextView;
import android.text.method.MovementMethod;
import us.shandian.blacklight.support.HackyMovementMethod;

/* 
 * Copyright (C) 2014 Peter Cai
 *
 * This file is part of BlackLight
 *
 * BlackLight is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * BlackLight is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with BlackLight.  If not, see <http://www.gnu.org/licenses/>.
 */

package us.shandian.blacklight.ui.common;



/*
  Hack to fix conflict between MovementMethod and OnClickListener
*/
public class HackyTextView extends TextView
{
	public HackyTextView(Context context) {
		super(context);
	}
	
	public HackyTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		boolean ret = super.onTouchEvent(event);
		
		MovementMethod method = getMovementMethod();
		if (method instanceof HackyMovementMethod) {