summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2011-01-10 20:21:09 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2011-01-10 20:21:09 (GMT)
commit30facff015d37b1b71a0bb80f64718d376c1c1c9 (patch)
tree9bd1a123b3f36296023b568cda871be7e67023f1
parent4998d9ed31ba276cb64d9bfa9046d1ef147d5898 (diff)
downloadSoftKeys-30facff015d37b1b71a0bb80f64718d376c1c1c9.zip
SoftKeys-30facff015d37b1b71a0bb80f64718d376c1c1c9.tar.gz
SoftKeys-30facff015d37b1b71a0bb80f64718d376c1c1c9.tar.bz2
changed back to just sending keypress not keydown/up since there is a
keyrepeat issue. Here we can now detect longpress so we should modify the response based on that. Also init the shell early
-rw-r--r--src/net/hoopajoo/android/SoftKeys/Globals.java19
-rw-r--r--src/net/hoopajoo/android/SoftKeys/Keys.java3
-rw-r--r--src/net/hoopajoo/android/SoftKeys/SoftKeysService.java76
3 files changed, 78 insertions, 20 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/Globals.java b/src/net/hoopajoo/android/SoftKeys/Globals.java
index 607e9a3..d715e30 100644
--- a/src/net/hoopajoo/android/SoftKeys/Globals.java
+++ b/src/net/hoopajoo/android/SoftKeys/Globals.java
@@ -53,7 +53,7 @@ public class Globals extends Application {
// set up env and run the context
String wd = getFilesDir().getAbsolutePath();
File jar = new File( wd + "/RemoteContext.jar" );
- if( ! jar.exists() ) {
+ if( true ) {
AssetManager m = getResources().getAssets();
InputStream in = m.open( "input/RemoteContext.jar" );
FileOutputStream out = new FileOutputStream( jar );
@@ -78,7 +78,6 @@ public class Globals extends Application {
}else{
mRootContext = new RootContext( "su", wd );
}
-
}
return( mRootContext );
@@ -142,12 +141,11 @@ public class Globals extends Application {
// spawn our context
system( "export CLASSPATH=" + workingDir + "/RemoteContext.jar" );
system( "exec app_process " + workingDir + " net.hoopajoo.android.RemoteContext" );
- runCommand( "" );
}
private void system( String cmd ) throws Exception {
//Log.d( "SoftKeys.RootContext", "Running command: '" + cmd + "'" );
- o.write( (cmd + "\n" ).getBytes( "ASCII" ) );
+ o.write( (cmd + "\n" ).getBytes( "ASCII" ) );
}
// slightly renamed since we're not running system("cmd") anymore but
@@ -180,6 +178,14 @@ public class Globals extends Application {
}
android_id = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
+
+ // init the shell
+ try{
+ getRootContext();
+ }catch( Exception e ) {
+ Toast.makeText( this, "Failed to initialize root context", Toast.LENGTH_LONG );
+ }
+
restartService();
}
@@ -242,4 +248,9 @@ public class Globals extends Application {
}
return( defaultLauncher );
}
+
+ public void quit() {
+ this.stopService( new Intent( this, SoftKeysService.class ) );
+ System.exit( 0 );
+ }
}
diff --git a/src/net/hoopajoo/android/SoftKeys/Keys.java b/src/net/hoopajoo/android/SoftKeys/Keys.java
index 33615b3..c2a4a8c 100644
--- a/src/net/hoopajoo/android/SoftKeys/Keys.java
+++ b/src/net/hoopajoo/android/SoftKeys/Keys.java
@@ -399,8 +399,7 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen
return true;
case R.id.menu_quit:
- ((Globals)getApplication()).stopService( new Intent( this, SoftKeysService.class ) );
- this.finish();
+ ((Globals)getApplication()).quit();
return true;
default:
diff --git a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java
index 8184ef1..c9e19ca 100644
--- a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java
+++ b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java
@@ -35,6 +35,7 @@ import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.OrientationEventListener;
@@ -53,6 +54,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Spinner;
+import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
public class SoftKeysService extends Service {
@@ -99,6 +101,15 @@ public class SoftKeysService extends Service {
}
};
+ /* TODO: fix this
+ OnTouchListener click = new OnTouchListener() {
+ @Override
+ public boolean onTouch( View view, MotionEvent me ) {
+ return genericClick( view, false, me );
+ }
+ };
+ */
+
OnLongClickListener longpress_rotate = new OnLongClickListener() {
@Override
public boolean onLongClick( View v ) {
@@ -288,10 +299,20 @@ 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, lc, touch, true );
+ Keys.applyButtons( settings, mView, c, lc, null, true );
mView.setOnTouchListener( touch );
mView.setOnLongClickListener( longpress_rotate );
- mView.findViewById( R.id.exit ).setOnLongClickListener( longpress_rotate );
+
+ // only drag by the exit button now
+ mView.findViewById( R.id.exit ).setOnTouchListener( touch );
+ mView.findViewById( R.id.exit ).setOnLongClickListener( longpress_rotate );
+
+ /* For when long click motionevent is fixed
+ // home button uses old generic click
+ mView.findViewById( R.id.home ).setOnTouchListener( null );
+ mView.findViewById( R.id.home ).setOnClickListener( c );
+ mView.findViewById( R.id.home ).setOnLongClickListener( lc );
+ */
applyTransparency( mView, settings.getInt( "service_transparency", 0 ) );
@@ -361,7 +382,7 @@ public class SoftKeysService extends Service {
} ) {
View v = mExtraView.findViewById( id );
v.setOnClickListener( c );
- v.setOnTouchListener( touch );
+ //v.setOnTouchListener( click );
String name = null;
switch( id ) {
@@ -396,19 +417,18 @@ public class SoftKeysService extends Service {
Generator.scaledIconSize( this, 0, buttonMult ) );
}
- // if it's one of the custom buttons add the custom updater
+ // long press on more/less to configure customs
switch( id ) {
- case R.id.extra_custom1:
- case R.id.extra_custom2:
- case R.id.extra_custom3:
- case R.id.extra_custom4:
- case R.id.extra_custom5:
- case R.id.extra_custom6:
+ case R.id.extra_more:
+ case R.id.extra_less:
+ //v.setOnTouchListener( null );
+ //v.setOnClickListener( c );
v.setOnLongClickListener( configButtons );
break;
}
}
mNumRows = settings.getInt( "service_extra_num_custom", 0 );
+ mExtraEnabled = settings.getBoolean( "service_extra_enabled", false );
updateExtraRows();
// update the button configs, they are simply mapped by id in to a hashmap
@@ -502,7 +522,19 @@ public class SoftKeysService extends Service {
wm.updateViewLayout( mExtraView, params );
}
- private boolean genericClick( View v, boolean longClick) {
+ private boolean genericClick( View v, boolean longClick ) {
+ return genericClick( v, longClick, null );
+ }
+
+ // note: from testing keyup/keydown don't work the way I expect, we need
+ // to also insert keyrepeat, so long-press volume, etc doesn't work the
+ // way you'd think. We should fix that someday, but for now you can just
+ // mash the key a bunch of times
+ private boolean genericClick( View v, boolean longClick, MotionEvent me ) {
+ if( me != null ) {
+ Toast.makeText( this, "Warning: MotionEvent is broken", Toast.LENGTH_LONG );
+ }
+
// send an intent to the main window
int keyid = 0;
Globals app = (Globals)getApplication();
@@ -599,7 +631,23 @@ public class SoftKeysService extends Service {
// error from the sendkeys
}
}else{
- app.sendKeys( new int[] { keyid } );
+ if( me != null ) {
+ // do down/up
+ if( me.getAction() == KeyEvent.ACTION_DOWN ) {
+ app.sendKeyDown( keyid );
+ }else if( me.getAction() == KeyEvent.ACTION_UP ) {
+ app.sendKeyUp( keyid );
+ }
+ }else{
+ app.sendKeys( new int[] { keyid } );
+ }
+ }
+ }
+
+ if( me != null ) {
+ // hide always false unless keyup
+ if( me.getAction() != KeyEvent.ACTION_UP ) {
+ hide = false;
}
}
@@ -672,11 +720,9 @@ public class SoftKeysService extends Service {
}
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences( this );
-
SharedPreferences.Editor e = settings.edit();
e.putInt( "service_extra_num_custom", mNumRows );
e.commit();
-
}
private void savePosition() {
@@ -695,6 +741,8 @@ public class SoftKeysService extends Service {
e.putInt( "service_extra_last_x_" + mOrientation, l.x );
e.putInt( "service_extra_last_y_" + mOrientation, l.y );
+ e.putBoolean( "service_extra_enabled", mExtraEnabled );
+
e.commit();
}