diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/InputSmoother.java | 50 | ||||
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/SoftKeysService.java | 7 |
2 files changed, 25 insertions, 32 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/InputSmoother.java b/src/net/hoopajoo/android/SoftKeys/InputSmoother.java index 812c3b4..12283be 100644 --- a/src/net/hoopajoo/android/SoftKeys/InputSmoother.java +++ b/src/net/hoopajoo/android/SoftKeys/InputSmoother.java @@ -50,10 +50,29 @@ public class InputSmoother { for( PointCheck p : mPoints ) { p.outlier = false; } - + + // currently this just checks to see if we delta'd farther than 10 pixels, + // it would be nice to add something smarter like curve fitting someday + // but it probably doesn't matter + int lastx = mPoints.get( 0 ).x; + int lasty = mPoints.get( 0 ).y; + + for( PointCheck p : mPoints ) { + if( Math.abs( lastx - p.x ) > 10 ) { + p.outlier = true; + } + if( Math.abs( lasty - p.y ) > 10 ) { + p.outlier = true; + } + lastx = p.x; + lasty = p.y; + } + // set current as the last non-outlier mCurrent = null; - for( PointCheck p : new ListReverser<PointCheck>( mPoints ) ) { + for( int i = mPoints.size() - 1; i >= 0; i-- ) { + PointCheck p = mPoints.get( i ); + if( mCurrent != null ) { if( p.outlier == false ) { mCurrent = p; @@ -79,31 +98,4 @@ public class InputSmoother { public int y; public boolean outlier; } - - class ListReverser<T> implements Iterable<T> { - private ListIterator<T> listIterator; - - public ListReverser(List<T> wrappedList) { - this.listIterator = wrappedList.listIterator(wrappedList.size()); - } - - public Iterator<T> iterator() { - return new Iterator<T>() { - - public boolean hasNext() { - return listIterator.hasPrevious(); - } - - public T next() { - return listIterator.previous(); - } - - public void remove() { - listIterator.remove(); - } - - }; - } - - } } diff --git a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java index d5e15d7..aea1634 100644 --- a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java +++ b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java @@ -108,7 +108,7 @@ public class SoftKeysService extends Service { } }; - OnLongClickListener longpress = new OnLongClickListener() { + OnLongClickListener longpress_rotate = new OnLongClickListener() { @Override public boolean onLongClick( View v ) { if( mDraggingView || mDidDrag ) { @@ -267,10 +267,11 @@ public class SoftKeysService extends Service { ((LinearLayout)mView.findViewById( R.id.button_container )).removeView( container.findViewById( R.id.settings ) ); // no settings in service // arrange buttons - Keys.applyButtons( settings, mView, c, longpress, touch, true ); + Keys.applyButtons( settings, mView, c, null, touch, true ); mView.setVisibility( View.INVISIBLE ); mView.setOnTouchListener( touch ); - mView.setOnLongClickListener( longpress ); + mView.setOnLongClickListener( longpress_rotate ); + mView.findViewById( R.id.exit ).setOnLongClickListener( longpress_rotate ); applyTransparency( mView, settings.getInt( "service_transparency", 0 ) ); |