diff --git a/xwords4/android/XWords4/jni/andutils.c b/xwords4/android/XWords4/jni/andutils.c index 33e4689fd..0f96028aa 100644 --- a/xwords4/android/XWords4/jni/andutils.c +++ b/xwords4/android/XWords4/jni/andutils.c @@ -275,13 +275,25 @@ getIntFromArray( JNIEnv* env, jintArray arr, bool del ) { jint* ints = (*env)->GetIntArrayElements(env, arr, 0); int result = ints[0]; - (*env)->ReleaseIntArrayElements( env, arr, ints, 0); + (*env)->ReleaseIntArrayElements( env, arr, ints, 0 ); if ( del ) { deleteLocalRef( env, arr ); } return result; } +void +setIntInArray( JNIEnv* env, jintArray arr, int index, int val ) +{ + jint* ints = (*env)->GetIntArrayElements( env, arr, 0 ); +#ifdef DEBUG + jsize len = (*env)->GetArrayLength( env, arr ); + XP_ASSERT( len > index ); +#endif + ints[index] = val; + (*env)->ReleaseIntArrayElements( env, arr, ints, 0 ); +} + jobjectArray makeStringArray( JNIEnv *env, int siz, const XP_UCHAR** vals ) { diff --git a/xwords4/android/XWords4/jni/andutils.h b/xwords4/android/XWords4/jni/andutils.h index 4d4e62584..82a037714 100644 --- a/xwords4/android/XWords4/jni/andutils.h +++ b/xwords4/android/XWords4/jni/andutils.h @@ -48,6 +48,7 @@ bool getObject( JNIEnv* env, jobject obj, const char* name, const char* sig, jintArray makeIntArray( JNIEnv *env, int size, const jint* vals ); int getIntFromArray( JNIEnv* env, jintArray arr, bool del ); +void setIntInArray( JNIEnv* env, jintArray arr, int index, int val ); jbyteArray makeByteArray( JNIEnv* env, int size, const jbyte* vals ); diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 7735b8c0a..b77a04bbd 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -640,6 +640,29 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1setTrayLoc XWJNI_END(); } +#ifdef XWFEATURE_ACTIVERECT +JNIEXPORT jboolean JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_board_1getActiveRect +( JNIEnv* env, jclass C, jint gamePtr, jobject jrect, jintArray dims ) +{ + jboolean result; + XWJNI_START(); + XP_Rect rect; + XP_U16 nCols, nRows; + result = board_getActiveRect( state->game.board, &rect, &nCols, &nRows ); + if ( result ) { + setInt( env, jrect, "left", rect.left ); + setInt( env, jrect, "top", rect.top ); + setInt( env, jrect, "right", rect.left + rect.width ); + setInt( env, jrect, "bottom", rect.top + rect.height ); + setIntInArray( env, dims, 0, nCols ); + setIntInArray( env, dims, 1, nRows ); + } + XWJNI_END(); + return result; +} +#endif + JNIEXPORT jboolean JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenDown (JNIEnv *env, jclass C, jint gamePtr, jint xx, jint yy, jbooleanArray barray ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index ee0af9289..254e73bce 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -940,12 +940,23 @@ public class BoardView extends View implements DrawCtx, BoardHandler, public Bitmap getScaledBoard() { Bitmap result = null; - int divisor = XWPrefs.getThumbScale( m_context ); - if ( 0 < divisor ) { - result = Bitmap.createScaledBitmap( s_bitmap, - m_layoutWidth / divisor, - m_layoutHeight / divisor, - false ); + if ( GitVersion.THUMBNAIL_SUPPORTED ) { + int divisor = XWPrefs.getThumbScale( m_context ); + + if ( 0 < divisor ) { + int[] dims = new int[2]; + Rect rect = new Rect(); + XwJNI.board_getActiveRect( m_jniGamePtr, rect, dims ); + + Bitmap tmpb = + Bitmap.createBitmap( s_bitmap, rect.left, rect.top, + 1 + rect.width(), 1 + rect.height() ); + + result = Bitmap.createScaledBitmap( tmpb, + rect.width() / divisor, + rect.height() / divisor, + false ); + } } return result; } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java index 32ab6d68d..b11748222 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java @@ -20,6 +20,9 @@ package org.eehouse.android.xw4.jni; +import android.graphics.Rect; + + // Collection of native methods public class XwJNI { @@ -159,6 +162,8 @@ public class XwJNI { public static native void board_setTimerLoc( int gamePtr, int timerLeft, int timerTop, int timerWidth, int timerHeight ); + public static native boolean board_getActiveRect( int gamePtr, Rect rect, + int[] dims ); public static native boolean board_handlePenDown( int gamePtr, int xx, int yy,