diff options
Diffstat (limited to 'src/net/hoopajoo/android/SoftKeys/SoftKeysService.java')
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/SoftKeysService.java | 91 |
1 files changed, 77 insertions, 14 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java index 9371814..e75cbf5 100644 --- a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java +++ b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java @@ -64,6 +64,8 @@ public class SoftKeysService extends Service { private View mBumpView; private boolean auto_hide; private boolean auto_hide_after_back; + private boolean mOrientationAdjustable = true; + private boolean mRestoreOrientation = true; private boolean mDraggingView; private View mDraggingViewObj; private int mDraggingOrigX, mDraggingOrigY; @@ -117,12 +119,14 @@ public class SoftKeysService extends Service { return false; } - // rotate - LinearLayout l = (LinearLayout)mView.findViewById( R.id.button_container ); - if( l.getOrientation() == LinearLayout.HORIZONTAL ) { - l.setOrientation( LinearLayout.VERTICAL ); - }else{ - l.setOrientation( LinearLayout.HORIZONTAL ); + if( mOrientationAdjustable ) { + // rotate + LinearLayout l = (LinearLayout)mView.findViewById( R.id.button_container ); + if( l.getOrientation() == LinearLayout.HORIZONTAL ) { + l.setOrientation( LinearLayout.VERTICAL ); + }else{ + l.setOrientation( LinearLayout.HORIZONTAL ); + } } savePosition(); @@ -428,21 +432,24 @@ public class SoftKeysService extends Service { R.id.extra_custom5, R.id.extra_custom6 } ) { i++; - String pref_name = "service_extra_custom" + i + "_keyid"; - int keycode = settings.getInt( pref_name, 0 ); + String pref_name = "service_extra_custom_keyid" + i; + int keycode = Integer.parseInt( settings.getString( pref_name, "0" ) ); String keyname = K.keyIdToName( keycode ); if( keycode > 0 ) { if( keyname == null ) { keyname = "NONE"; }else{ - keyname = ConfigureExtra.prettyPrint( keyname ); + keyname = CustomKey.prettyPrint( keyname ); } }else{ if( keycode == 0 ) { keyname = "NONE"; - } - if( keycode == -1 ) { + }else if( keycode == -1 ) { keyname = "SLEEP"; + }else if( keycode == -2 ) { + keyname = "CB: TAB"; + }else if( keycode == -3 ) { + keyname = "CB: ESCAPE"; } } @@ -464,6 +471,25 @@ public class SoftKeysService extends Service { wm.addView( mView, makeOverlayParams() ); wm.addView( mExtraView, makeOverlayParams() ); + // initialize preference orientation + LinearLayout ll = (LinearLayout)mView.findViewById( R.id.button_container ); + String orientation = settings.getString( "service_orientation", "horizontal_adjust" ); + if( orientation.contains( "adjust" ) ) { + mOrientationAdjustable = true; + }else{ + mOrientationAdjustable = false; + } + + mRestoreOrientation = false; + if( orientation.contains( "save" ) ) { + // init to last saved value + mRestoreOrientation = true; + }else if( orientation.contains( "horizontal" ) ) { + ll.setOrientation( LinearLayout.HORIZONTAL ); + }else{ + ll.setOrientation( LinearLayout.VERTICAL ); + } + mOrientationListener = new OrientationEventListener( this, SensorManager.SENSOR_DELAY_NORMAL ) { @Override public void onOrientationChanged( int orientation ) { @@ -522,6 +548,16 @@ public class SoftKeysService extends Service { params.y = settings.getInt( "service_extra_last_y_" + mOrientation, 0 ); params.gravity = Gravity.TOP | Gravity.LEFT; wm.updateViewLayout( mExtraView, params ); + + if( mRestoreOrientation ) { + String last_orientation = settings.getString( "service_last_orientation_" + mOrientation, "horizontal" ); + LinearLayout l = (LinearLayout)mView.findViewById( R.id.button_container ); + if( last_orientation.equals( "vertical" ) ) { + l.setOrientation( LinearLayout.VERTICAL ); + }else{ + l.setOrientation( LinearLayout.HORIZONTAL ); + } + } } private boolean genericClick( View v, boolean longClick ) { @@ -565,6 +601,18 @@ public class SoftKeysService extends Service { } break; + case R.id.sleep: + keyid = -1; + break; + + case R.id.volume_down: + keyid = K.KEYID_VOLUME_DOWN; + break; + + case R.id.volume_up: + keyid = K.KEYID_VOLUME_UP; + break; + case R.id.exit: hide = true; break; @@ -627,11 +675,19 @@ public class SoftKeysService extends Service { } if( keyid != 0 ) { - if( keyid == -1 ) { - // sleep + if( false && keyid < 0 ) { + // dead, move special keys up to globals + String[] cmds = new String[] {}; + if( keyid == -1 ) { + // sleep + cmds = new String[] { "sleep" }; + } + try { Globals.RootContext cmd = ((Globals)getApplication()).getRootContext(); - cmd.runCommand( "sleep" ); + for( String command : cmds ) { + cmd.runCommand( command ); + } }catch( Exception e ) { // we don't really care if this fails, they should have gotten a shell // error from the sendkeys @@ -751,6 +807,13 @@ public class SoftKeysService extends Service { e.putBoolean( "service_extra_enabled", mExtraEnabled ); + LinearLayout ll = (LinearLayout)mView.findViewById( R.id.button_container ); + String orientation = "horizontal"; + if( ll.getOrientation() == LinearLayout.VERTICAL ) { + orientation = "vertical"; + } + e.putString( "service_last_orientation_" + mOrientation, orientation ); + e.commit(); } |