Skip to content

Commit

Permalink
Cope with null intent/action in NFC. And a couple of speculative defe…
Browse files Browse the repository at this point in the history
…nses for #228.

Bump version.
  • Loading branch information
chrisboyle committed Nov 9, 2014
1 parent d0082a8 commit 557329f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {

defaultConfig {
applicationId "name.boyle.chris.sgtpuzzles"
versionCode 96
versionCode 97
versionName "${timestamp()}-${idForSimon()}"

if (file(ndkDir.absolutePath + '/platforms/android-15').exists()) { // the last without PIE
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/name/boyle/chris/sgtpuzzles/GamePlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ protected void onNewIntent(Intent intent)

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private boolean handleNFC(Intent intent) {
if (!intent.getAction().equals(NfcAdapter.ACTION_NDEF_DISCOVERED)) return false;
if (intent == null || !NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) return false;
Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
if (rawMsgs.length == 0) return false;
NdefMessage msg = (NdefMessage) rawMsgs[0];
Expand Down Expand Up @@ -742,7 +742,7 @@ private void startGame(final GameLaunch launch)
}

@UsedByJNI
private void clearForNewGame(final String startingBackend, final float[] colours) {
private void clearForNewGame(final String startingBackend, final float[] colours, final boolean canUndo, final boolean canRedo) {
runOnUiThread(new Runnable() {
public void run() {
gameView.colours = new int[colours.length / 3];
Expand Down Expand Up @@ -772,6 +772,7 @@ public void run() {
gameTypes.clear();
gameView.keysHandled = 0;
everCompleted = false;
changedState(canUndo, canRedo);
}
});
}
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/jni/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,7 @@ void notifyClearForNewGame(jstring whichBackend)
jfloatArray jColours = (*env)->NewFloatArray(env, n*3);
if (jColours == NULL) return;
(*env)->SetFloatArrayRegion(env, jColours, 0, n*3, colours);
(*env)->CallVoidMethod(env, obj, clearForNewGame, whichBackend, jColours);
android_changed_state(NULL, midend_can_undo(fe->me), midend_can_redo(fe->me));
(*env)->CallVoidMethod(env, obj, clearForNewGame, whichBackend, jColours, midend_can_undo(fe->me), midend_can_redo(fe->me));
}

void populatePresets()
Expand Down Expand Up @@ -790,8 +789,10 @@ void startPlayingInt(JNIEnv *env, jobject _obj, jobject _gameView, jstring backe
midend_size(fe->me, &x, &y, FALSE);

notifyClearForNewGame(whichBackend);
if ((*env)->ExceptionCheck(env)) return;

populatePresets();
if ((*env)->ExceptionCheck(env)) return;

fe->ox = -1;

Expand Down Expand Up @@ -834,7 +835,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved)
blitterLoad = (*env)->GetMethodID(env, vcls, "blitterLoad", "(III)V");
blitterSave = (*env)->GetMethodID(env, vcls, "blitterSave", "(III)V");
changedState = (*env)->GetMethodID(env, cls, "changedState", "(ZZ)V");
clearForNewGame = (*env)->GetMethodID(env, cls, "clearForNewGame", "(Ljava/lang/String;[F)V");
clearForNewGame = (*env)->GetMethodID(env, cls, "clearForNewGame", "(Ljava/lang/String;[FZZ)V");
clipRect = (*env)->GetMethodID(env, vcls, "clipRect", "(IIII)V");
dialogAdd = (*env)->GetMethodID(env, cls, "dialogAdd", "(IILjava/lang/String;Ljava/lang/String;I)V");
dialogInit = (*env)->GetMethodID(env, cls, "dialogInit", "(ILjava/lang/String;)V");
Expand Down

0 comments on commit 557329f

Please sign in to comment.