diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2011-01-04 23:33:32 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2011-01-04 23:33:32 (GMT) |
commit | 00c5dffd03424fb9b2db3cb8dc66f463d25e655e (patch) | |
tree | 93a0bb967ea5f8e0de3868ba00679de1f12aa96d /src | |
parent | db5e0f0310b74ac5d054c1f92a0de74c73ae6ab7 (diff) | |
download | SoftKeys-00c5dffd03424fb9b2db3cb8dc66f463d25e655e.zip SoftKeys-00c5dffd03424fb9b2db3cb8dc66f463d25e655e.tar.gz SoftKeys-00c5dffd03424fb9b2db3cb8dc66f463d25e655e.tar.bz2 |
Fixed service to call global sendkeys directly, fixed sendkeys to build the
send string
Diffstat (limited to 'src')
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/Globals.java | 7 | ||||
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/Keys.java | 13 | ||||
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/SoftKeysService.java | 25 |
3 files changed, 15 insertions, 30 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/Globals.java b/src/net/hoopajoo/android/SoftKeys/Globals.java index 50f23a1..dc8d356 100644 --- a/src/net/hoopajoo/android/SoftKeys/Globals.java +++ b/src/net/hoopajoo/android/SoftKeys/Globals.java @@ -69,6 +69,7 @@ public class Globals extends Application { return sendKeys( listToInt( a ) ); } + // TODO: replace this with monkey script, then we can do longpresses public int sendKeys( int[] keyids ) { try { Globals.CommandShell cmd = getCommandShell(); @@ -91,7 +92,11 @@ public class Globals extends Application { } // source the file since datadata might be noexec - String keyid = ""; + StringBuilder keyid = new StringBuilder(); + for( int i = 0; i < keyids.length; i++ ) { + keyid.append( " " ); + keyid.append( keyids[ i ] ); + } cmd.system( "sh " + script.getAbsolutePath() + " " + keyid ); }catch( Exception e ) { Log.e( LOG, "Error: " + e.getMessage() ); diff --git a/src/net/hoopajoo/android/SoftKeys/Keys.java b/src/net/hoopajoo/android/SoftKeys/Keys.java index 32d2136..48a6927 100644 --- a/src/net/hoopajoo/android/SoftKeys/Keys.java +++ b/src/net/hoopajoo/android/SoftKeys/Keys.java @@ -190,19 +190,6 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen setContentView( R.layout.main ); - // warn if we don't notice some binaries we need - for( String name : new String[] { "/system/bin/su", "/system/bin/input" } ) { - File check = new File( name ); - try { - if( ! check.exists() ) { - Toast.makeText( this, "Failed to find file: " + name + ", SoftKeys may not function", Toast.LENGTH_LONG ).show(); - } - }catch( Exception e ) { - Toast.makeText( this, "Unable to check for file: " + name, Toast.LENGTH_LONG ).show(); - } - - } - // long click outside buttons == config View main = findViewById( R.id.main_view ); main.setLongClickable( true ); diff --git a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java index bdfe63e..899cfe7 100644 --- a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java +++ b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java @@ -387,32 +387,29 @@ public class SoftKeysService extends Service { } - private boolean genericClick( View v, boolean longclick) { + private boolean genericClick( View v, boolean longClick) { // send an intent to the main window - Intent i = null; + int keyid = 0; + Globals app = (Globals)getApplication(); boolean hide = auto_hide; switch( v.getId() ) { case R.id.home: - i = new Intent( SendInput.ACTION_CODE ); - i.putExtra( "keyname", "home" ); + app.doHomeAction( longClick ); break; case R.id.back: - i = new Intent( SendInput.ACTION_CODE ); - i.putExtra( "keyname", "back" ); + keyid = K.KEYID_BACK; if( hide ) { hide = auto_hide_after_back; } break; case R.id.menu: - i = new Intent( SendInput.ACTION_CODE ); - i.putExtra( "keyname", "menu" ); + keyid = K.KEYID_MENU; break; case R.id.search: - i = new Intent( SendInput.ACTION_CODE ); - i.putExtra( "keyname", "search" ); + keyid = K.KEYID_SEARCH; break; case R.id.exit: @@ -420,12 +417,8 @@ public class SoftKeysService extends Service { break; } - if( i != null ) { - i.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); - i.putExtra( "long", longclick ); - - //i.setClass( v.getContext(), Keys.class ); - v.getContext().startActivity( i ); + if( keyid != 0 ) { + app.sendKeys( new int[] { keyid } ); } if( hide ) { |