Slightly reluctant to scroll candidate strip to be able to easily choose the suggestion
Also fixed the comment of mMinTouchableWidth Bug: 2581826 Change-Id: Idc79186b0647b0e7e7ec889488b019b7db5241admain
parent
2a118d844e
commit
353c20a62f
|
@ -144,9 +144,13 @@ public class CandidateView extends View {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
mPaint.setTextAlign(Align.CENTER);
|
mPaint.setTextAlign(Align.CENTER);
|
||||||
mDescent = (int) mPaint.descent();
|
mDescent = (int) mPaint.descent();
|
||||||
// 80 pixels for a 160dpi device would mean half an inch
|
// 50 pixels for a 160dpi device would mean about 0.3 inch
|
||||||
mMinTouchableWidth = (int) (getResources().getDisplayMetrics().density * 50);
|
mMinTouchableWidth = (int) (getResources().getDisplayMetrics().density * 50);
|
||||||
|
|
||||||
|
// Slightly reluctant to scroll to be able to easily choose the suggestion
|
||||||
|
// 50 pixels for a 160dpi device would mean about 0.3 inch
|
||||||
|
final int touchSlop = (int) (getResources().getDisplayMetrics().density * 50);
|
||||||
|
final int touchSlopSquare = touchSlop * touchSlop;
|
||||||
mGestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
|
mGestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLongPress(MotionEvent me) {
|
public void onLongPress(MotionEvent me) {
|
||||||
|
@ -160,6 +164,13 @@ public class CandidateView extends View {
|
||||||
@Override
|
@Override
|
||||||
public boolean onScroll(MotionEvent e1, MotionEvent e2,
|
public boolean onScroll(MotionEvent e1, MotionEvent e2,
|
||||||
float distanceX, float distanceY) {
|
float distanceX, float distanceY) {
|
||||||
|
final int deltaX = (int) (e2.getX() - e1.getX());
|
||||||
|
final int deltaY = (int) (e2.getY() - e1.getY());
|
||||||
|
final int distance = (deltaX * deltaX) + (deltaY * deltaY);
|
||||||
|
if (distance < touchSlopSquare) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final int width = getWidth();
|
final int width = getWidth();
|
||||||
mScrolled = true;
|
mScrolled = true;
|
||||||
int scrollX = getScrollX();
|
int scrollX = getScrollX();
|
||||||
|
|
Loading…
Reference in New Issue