lots of in-practice tweaks with making android more usable

This commit is contained in:
benfry
2010-07-26 13:30:33 +00:00
parent 1685eb24fc
commit e6f515543b
6 changed files with 78 additions and 10 deletions
+41 -4
View File
@@ -2016,10 +2016,10 @@ public class PApplet extends Activity implements PConstants, Runnable {
// which is a problem if the space bar or tab key are used.
key = (char) event.getUnicodeChar();
// if not mappable to a unicode character, instead mark as coded key
if (key == 0) {
if (key == 0 || key == 0xFFFF) {
// System.out.println(" key is coded");
key = CODED;
} else {
// } else {
// System.out.println(" key is unicode");
}
@@ -2039,8 +2039,8 @@ public class PApplet extends Activity implements PConstants, Runnable {
// set key to zero (or something besides the "ESC").
// println(event);
if (action == KeyEvent.ACTION_DOWN) {
if (key == KeyEvent.KEYCODE_BACK) {
// println("KEYCODE_BACK, calling exit()");
if (keyCode == KeyEvent.KEYCODE_BACK) {
println("KEYCODE_BACK, calling exit()");
exit();
}
}
@@ -2422,6 +2422,43 @@ public class PApplet extends Activity implements PConstants, Runnable {
}
}
//////////////////////////////////////////////////////////////
public void method(String name) {
// final Object o = this;
// final Class<?> c = getClass();
try {
Method method = getClass().getMethod(name, new Class[] {});
method.invoke(this, new Object[] { });
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.getTargetException().printStackTrace();
} catch (NoSuchMethodException nsme) {
System.err.println("There is no public " + name + "() method " +
"in the class " + getClass().getName());
} catch (Exception e) {
e.printStackTrace();
}
}
public void thread(final String name) {
Thread later = new Thread() {
public void run() {
method(name);
}
};
later.start();
}
//////////////////////////////////////////////////////////////
@@ -444,15 +444,18 @@ public interface PConstants {
static final int CODED = 0xffff;
// key will be CODED and keyCode will be this value
// static final int UP = KeyEvent.VK_UP;
// static final int DOWN = KeyEvent.VK_DOWN;
// static final int LEFT = KeyEvent.VK_LEFT;
// static final int RIGHT = KeyEvent.VK_RIGHT;
static final int UP = KeyEvent.KEYCODE_DPAD_UP;
static final int DOWN = KeyEvent.KEYCODE_DPAD_DOWN;
static final int LEFT = KeyEvent.KEYCODE_DPAD_LEFT;
static final int RIGHT = KeyEvent.KEYCODE_DPAD_RIGHT;
// These seem essential for most sketches, so they're included.
// Others can be found in the KeyEvent reference:
// http://developer.android.com/reference/android/view/KeyEvent.html
static final int BACK = KeyEvent.KEYCODE_BACK;
static final int MENU = KeyEvent.KEYCODE_MENU;
static final int DPAD = KeyEvent.KEYCODE_DPAD_CENTER;
// key will be CODED and keyCode will be this value
// static final int ALT = KeyEvent.VK_ALT;
@@ -265,7 +265,6 @@ public class PFont implements PConstants {
descent = PApplet.round(lazyPaint.descent());
}
}
PApplet.println("ascent/descent = " + ascent + " " + descent);
}
@@ -2467,7 +2467,6 @@ public class PGraphics extends PImage implements PConstants {
}
*/
textSize(which.size);
PApplet.println("size should be " + which.size);
} else {
throw new RuntimeException(ERROR_TEXTFONT_NULL_PFONT);
+23
View File
@@ -29,6 +29,20 @@ X http://code.google.com/p/processing/issues/detail?id=221
X change skewX/Y to shearX/Y
_ need updated reference for this
http://developer.android.com/reference/android/view/KeyEvent.html
key == KeyEvent.KEYCODE_BACK (why not keyCode?)
included
KEYCODE_MENU
KEYCODE_BACK
KEYCODE_DPAD_CENTER --> DPAD?
not included
KEYCODE_VOLUME_DOWN
KEYCODE_VOLUME_UP
KEYCODE_CAMERA
KEYCODE_HOME
P1 _ exceptions with StreamPump and adb devices on osx and linux
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1545
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1527
@@ -43,8 +57,14 @@ P3 _ example sketch added to bug report
P3 _ http://dev.processing.org/bugs/show_bug.cgi?id=1472
P3 _ http://code.google.com/p/processing/issues/detail?id=232
_ seems to have problems on 64-bit windows
_ removing local version of java helped someone fix it
_ remove 'import processing.opengl.*' in the preprocessor?
_ may need to add screen orientation as a built-in function
_ fairly common to use, and otherwise needs an obscure import
_ additional manifest gui necessary:
_ icons are apparently important
_ android:icon and android:label in <application>
@@ -333,6 +353,9 @@ _ or programmatically specify:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
get the dpi of the screen
http://developer.android.com/reference/android/util/DisplayMetrics.html
_ show/hide the virtual keyboard
InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -133,8 +133,15 @@ public class Manifest {
writer.println("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" ");
// writer.println(" package=\"" + defaultPackageName() + "\" ");
writer.println(" package=\"\" ");
// Tempting to use 'preferExternal' here, but might annoy some users.
// 'auto' at least enables it to be moved back and forth
// http://developer.android.com/guide/appendix/install-location.html
writer.println(" android:installLocation=\"auto\" ");
writer.println(" android:versionCode=\"1\" ");
writer.println(" android:versionName=\"1.0\">");
// for now including this... we're wiring to a particular SDK version anyway...
writer.println(" <uses-sdk android:minSdkVersion=\"" + Build.sdkVersion + "\" />");
// writer.println(" <uses-sdk android:minSdkVersion=\"\" />"); // insert sdk version