From 00c5dffd03424fb9b2db3cb8dc66f463d25e655e Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Tue, 4 Jan 2011 15:33:32 -0800 Subject: Fixed service to call global sendkeys directly, fixed sendkeys to build the send string 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 ) { -- cgit v0.10.2