diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2011-01-11 21:12:57 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2011-01-11 21:12:57 (GMT) |
commit | 1b5472cc453df8c88b564582136b66d50186a970 (patch) | |
tree | 7a8b844cc9d4fd933bbc859c751f8c4aa6cb9ec7 /src | |
parent | bc2ba9aa2d6db5ce31570a9ef1182efcf8a00835 (diff) | |
download | SoftKeys-1b5472cc453df8c88b564582136b66d50186a970.zip SoftKeys-1b5472cc453df8c88b564582136b66d50186a970.tar.gz SoftKeys-1b5472cc453df8c88b564582136b66d50186a970.tar.bz2 |
Move all the key actions stuff back in the main keys activity
Diffstat (limited to 'src')
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/Keys.java | 44 | ||||
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/SendInput.java | 11 |
2 files changed, 43 insertions, 12 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/Keys.java b/src/net/hoopajoo/android/SoftKeys/Keys.java index 424c7f6..8960940 100644 --- a/src/net/hoopajoo/android/SoftKeys/Keys.java +++ b/src/net/hoopajoo/android/SoftKeys/Keys.java @@ -59,6 +59,11 @@ import android.widget.RemoteViews; import android.widget.Toast; public class Keys extends Activity implements OnClickListener, OnLongClickListener { + public static String ACTION_HOME = "net.hoopajoo.android.SoftKeys.KEY_HOME"; + public static String ACTION_MENU = "net.hoopajoo.android.SoftKeys.KEY_MENU"; + public static String ACTION_SEARCH = "net.hoopajoo.android.SoftKeys.KEY_SEARCH"; + public static String ACTION_BACK = "net.hoopajoo.android.SoftKeys.KEY_BACK"; + private String defaultLauncher; private boolean isPreTap = false; private final String LOG = "SoftKeys"; @@ -254,22 +259,22 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen theme.getRemoteViews( new String[] { "notification_menu" } ), theme.getDrawable( new String[] { "notification_menu" } ), R.drawable.button_menu, - SendInput.ACTION_MENU ); + ACTION_MENU ); nb[ 2 ] = new NotificationButton( "Home", "nb_home", theme.getRemoteViews( new String[] { "notification_home" } ), theme.getDrawable( new String[] { "notification_home" } ), R.drawable.button_home, - SendInput.ACTION_HOME ); + ACTION_HOME ); nb[ 3 ] = new NotificationButton( "Back", "nb_back", theme.getRemoteViews( new String[] { "notification_back" } ), theme.getDrawable( new String[] { "notification_back" } ), R.drawable.button_back, - SendInput.ACTION_BACK ); + ACTION_BACK ); nb[ 4 ] = new NotificationButton( "Search", "nb_search", theme.getRemoteViews( new String[] { "notification_search" } ), theme.getDrawable( new String[] { "notification_search" } ), R.drawable.button_search, - SendInput.ACTION_SEARCH ); + ACTION_SEARCH ); for( NotificationButton b : nb ) { if( settings.getBoolean( b.mPrefKey, false ) ) { @@ -280,7 +285,7 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen si.setPackage( getPackageName() ); }else{ //si.setPackage( getPackageName() ); - si.setClass( this, SendInput.class ); + si.setClass( this, Keys.class ); } PendingIntent i = PendingIntent.getActivity( this, 0, si, 0 ); @@ -426,6 +431,35 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen } } + if( true ) { + String action = i.getAction(); + int keyid = 0; + if( action.equals( ACTION_HOME ) ) { + app.doHomeAction( false ); + this.finish(); + return; + } + + if( action.equals( ACTION_BACK ) ) { + keyid = K.KEYID_BACK; + } + + if( action.equals( ACTION_MENU ) ) { + keyid = K.KEYID_MENU; + } + + if( action.equals( ACTION_SEARCH ) ) { + keyid = K.KEYID_SEARCH; + } + + if( keyid != 0 ) { + //Log.d( "SoftKeys.SendInput", "resolved key: " + keyid ); + app.sendKeys( new int[] { keyid } ); + this.finish(); + return; + } + } + if( isPaused ) { //d( "detected paused, resetting counter" ); app.homeCounter = 0; diff --git a/src/net/hoopajoo/android/SoftKeys/SendInput.java b/src/net/hoopajoo/android/SoftKeys/SendInput.java index 7e56521..e54d0e8 100644 --- a/src/net/hoopajoo/android/SoftKeys/SendInput.java +++ b/src/net/hoopajoo/android/SoftKeys/SendInput.java @@ -86,7 +86,7 @@ public class SendInput extends Activity { String key = e.getString( "keyname" ); //Log.d( "SoftKeys.SendInput", "resolving: " + key ); if( key.equals( "home" ) ) { - ((Globals)getApplication()).doHomeAction( longClick ); + app.doHomeAction( longClick ); this.finish(); return; }else{ @@ -99,7 +99,7 @@ public class SendInput extends Activity { } if( action.equals( ACTION_HOME ) ) { - ((Globals)getApplication()).doHomeAction( false ); + app.doHomeAction( false ); this.finish(); return; } @@ -118,12 +118,9 @@ public class SendInput extends Activity { if( keyid != 0 ) { //Log.d( "SoftKeys.SendInput", "resolved key: " + keyid ); - ((Globals)getApplication()).sendKeys( new int[] { keyid } ); + app.sendKeys( new int[] { keyid } ); } - // todo: make me a broadcast receiver.. or maybe this should be removed all together? - // any good reasons to allow other apps to call hw keys? - this.finish(); - + this.finish(); } } |