summaryrefslogtreecommitdiffstats
path: root/src/net/hoopajoo
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2011-01-10 18:25:26 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2011-01-10 18:25:26 (GMT)
commit1b44b66b0aca6142aa85d19861473925b4db029e (patch)
tree14b13bd4e6d271c710a926979ebac8cd204e02d4 /src/net/hoopajoo
parentac417db0f40fadd575b3e5be5d8b9f108eeb27c2 (diff)
downloadSoftKeys-1b44b66b0aca6142aa85d19861473925b4db029e.zip
SoftKeys-1b44b66b0aca6142aa85d19861473925b4db029e.tar.gz
SoftKeys-1b44b66b0aca6142aa85d19861473925b4db029e.tar.bz2
Pretty print key names, long press to toggle dpad view
Diffstat (limited to 'src/net/hoopajoo')
-rw-r--r--src/net/hoopajoo/android/SoftKeys/ConfigureExtra.java31
-rw-r--r--src/net/hoopajoo/android/SoftKeys/Keys.java9
-rw-r--r--src/net/hoopajoo/android/SoftKeys/SoftKeysService.java16
3 files changed, 45 insertions, 11 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/ConfigureExtra.java b/src/net/hoopajoo/android/SoftKeys/ConfigureExtra.java
index 811ffff..85bd35a 100644
--- a/src/net/hoopajoo/android/SoftKeys/ConfigureExtra.java
+++ b/src/net/hoopajoo/android/SoftKeys/ConfigureExtra.java
@@ -75,10 +75,7 @@ public class ConfigureExtra extends Activity implements OnClickListener {
i++;
String pref_name = "service_extra_custom" + i + "_keyid";
int keycode = settings.getInt( pref_name, 0 );
- String keyname = K.keyIdToName( keycode );
- if( keyname == null ) {
- keyname = "NONE";
- }
+
Spinner s = (Spinner)findViewById( id );
s.setAdapter( adapter );
@@ -122,7 +119,7 @@ public class ConfigureExtra extends Activity implements OnClickListener {
public int mId;
CustomKey( int id, String name ) {
- mName = name;
+ mName = prettyPrint( name );
mId = id;
}
@@ -130,4 +127,28 @@ public class ConfigureExtra extends Activity implements OnClickListener {
return mName;
}
}
+
+ public static String prettyPrint( String n ) {
+ // replace _ with space, initcap
+ String s = n.replace( "_", " " );
+
+ boolean bound = true;
+ StringBuilder r = new StringBuilder();
+ for( int i = 0; i < s.length(); i++ ) {
+ if( bound ) {
+ // cap
+ r.append( Character.toUpperCase( s.charAt( i ) ) );
+ bound = false;
+ }else{
+ r.append( Character.toLowerCase( s.charAt( i ) ) );
+ }
+
+ // check for boundry
+ if( Character.isSpace( s.charAt( i ) ) ) {
+ bound = true;
+ }
+ }
+
+ return r.toString();
+ }
}
diff --git a/src/net/hoopajoo/android/SoftKeys/Keys.java b/src/net/hoopajoo/android/SoftKeys/Keys.java
index c5b98bc..33615b3 100644
--- a/src/net/hoopajoo/android/SoftKeys/Keys.java
+++ b/src/net/hoopajoo/android/SoftKeys/Keys.java
@@ -398,6 +398,11 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen
generic_click( R.id.settings, false );
return true;
+ case R.id.menu_quit:
+ ((Globals)getApplication()).stopService( new Intent( this, SoftKeysService.class ) );
+ this.finish();
+ return true;
+
default:
return super.onOptionsItemSelected( item );
}
@@ -540,8 +545,8 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen
// if we sent back, and didn't backout (so it was from main ui) and they
// want to return, run am to get us back
if( id == R.id.back && backout && return_after_back ) {
- Globals.CommandShell cmd = ((Globals)getApplication()).getCommandShell();
- cmd.system( "am start -a android.intent.action.MAIN -n net.hoopajoo.android.SoftKeys/.Keys" );
+ Globals.RootContext cmd = ((Globals)getApplication()).getRootContext();
+ cmd.runCommand( "system am start -a android.intent.action.MAIN -n net.hoopajoo.android.SoftKeys/.Keys" );
}
}catch( Exception e ) {
// we don't really care if this fails, they should have gotten a shell
diff --git a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java
index 3ba62ba..8184ef1 100644
--- a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java
+++ b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java
@@ -66,9 +66,8 @@ public class SoftKeysService extends Service {
private View mDraggingViewObj;
private int mDraggingOrigX, mDraggingOrigY;
private int mDraggingViewX, mDraggingViewY;
- private boolean mPendingDragEvent;
private boolean mDidDrag;
- private boolean mExtraEnabled = true;
+ private boolean mExtraEnabled = false;
private int mNumDrags;
private OrientationEventListener mOrientationListener;
private Runnable mUpdateDrag;
@@ -244,8 +243,6 @@ public class SoftKeysService extends Service {
WindowManager wm = (WindowManager)getSystemService(WINDOW_SERVICE);
wm.updateViewLayout( root, l );
-
- mPendingDragEvent = false;
}
};
@@ -325,6 +322,15 @@ public class SoftKeysService extends Service {
}
} );
+ b.setOnLongClickListener( new OnLongClickListener() {
+ @Override
+ public boolean onLongClick( View v ) {
+ mExtraEnabled = ! mExtraEnabled;
+ matchExtraView();
+ return true;
+ }
+ } );
+
// extra view (dpad, customizable buttons)
mExtraView = l.inflate( R.layout.service_extra, null );
Generator.applyContainerExtras( mExtraView, "service_extra",
@@ -419,6 +425,8 @@ public class SoftKeysService extends Service {
if( keycode > 0 ) {
if( keyname == null ) {
keyname = "NONE";
+ }else{
+ keyname = ConfigureExtra.prettyPrint( keyname );
}
}else{
if( keycode == 0 ) {