From 33e47109a5ddb9f3011d5c66eed92e6a07722c2b Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Mon, 3 Jan 2011 08:44:09 -0800 Subject: Make only the stop button rotate the service view, added a basic input smoother though the display is still jittery, maybe it's a window management problem 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( 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 implements Iterable { - private ListIterator listIterator; - - public ListReverser(List wrappedList) { - this.listIterator = wrappedList.listIterator(wrappedList.size()); - } - - public Iterator iterator() { - return new Iterator() { - - 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 ) ); -- cgit v0.10.2