diff --git a/xwords4/android/XWords4/res/drawable/downarrow.png b/xwords4/android/XWords4/res/drawable/downarrow.png new file mode 100644 index 000000000..5741aa313 Binary files /dev/null and b/xwords4/android/XWords4/res/drawable/downarrow.png differ diff --git a/xwords4/android/XWords4/res/drawable/rightarrow.png b/xwords4/android/XWords4/res/drawable/rightarrow.png new file mode 100644 index 000000000..f75427932 Binary files /dev/null and b/xwords4/android/XWords4/res/drawable/rightarrow.png differ diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index a38fd2863..4808a1bea 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -75,7 +75,7 @@ public class BoardActivity extends Activity implements XW_UtilCtxt, Runnable { Utils.logf( "calling game_makeNewGame; passing bytes: " + dictBytes.length ); m_jniGamePtr = XwJNI.game_makeNewGame( m_gi, this, m_view, 0, m_prefs, null, dictBytes ); - m_view.startHandling( m_jniGamePtr, m_gi ); + m_view.startHandling( this, m_jniGamePtr, m_gi ); XwJNI.server_do( m_jniGamePtr ); } 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 5ecd94934..68bb61087 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -10,6 +10,8 @@ import android.content.Context; import android.util.AttributeSet; import org.eehouse.android.xw4.jni.*; import android.view.MotionEvent; +import android.graphics.drawable.Drawable; +import android.content.res.Resources; public class BoardView extends View implements DrawCtx, BoardHandler { @@ -23,6 +25,8 @@ public class BoardView extends View implements DrawCtx, private int m_trayOwner; private Rect m_valRect; private Rect m_letterRect; + Drawable m_rightArrow; + Drawable m_downArrow; private static final int BLACK = 0xFF000000; private static final int WHITE = 0xFFFFFFFF; @@ -142,9 +146,13 @@ public class BoardView extends View implements DrawCtx, return m_boardSet; } - public void startHandling( int gamePtr, CurGameInfo gi ) { + public void startHandling( Context context, int gamePtr, CurGameInfo gi ) { m_jniGamePtr = gamePtr; m_gi = gi; + + Resources res = context.getResources(); + m_downArrow = res.getDrawable( R.drawable.downarrow ); + m_rightArrow = res.getDrawable( R.drawable.rightarrow ); } // DrawCtxt interface implementation @@ -210,6 +218,16 @@ public class BoardView extends View implements DrawCtx, return true; } + public void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts, + int flags ) + { + rect.inset( 2, 2 ); + Utils.logf( "drawBoardArrow" ); + Drawable arrow = vert? m_downArrow : m_rightArrow; + arrow.setBounds( rect ); + arrow.draw( m_canvas ); + } + public boolean trayBegin ( Rect rect, int owner, int dfs ) { m_trayOwner = owner; return true; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/BoardHandler.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/BoardHandler.java index fe6098502..c7c35dd04 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/BoardHandler.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/BoardHandler.java @@ -1,8 +1,10 @@ package org.eehouse.android.xw4.jni; +import android.content.Context; + public interface BoardHandler { - void startHandling( int gamePtr, CurGameInfo gi ); + void startHandling( Context context, int gamePtr, CurGameInfo gi ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DrawCtx.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DrawCtx.java index 16ab939e4..36e1c9593 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DrawCtx.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DrawCtx.java @@ -23,6 +23,8 @@ public interface DrawCtx { boolean drawCell( Rect rect, String text, Object[] bitmaps, int tile, int owner, int bonus, int hintAtts, int flags ); + void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts, + int flags ); boolean trayBegin ( Rect rect, int owner, int dfs ); void drawTile( Rect rect, String text, Object[] bitmaps, int val, int flags ); diff --git a/xwords4/android/drawwrapper.c b/xwords4/android/drawwrapper.c index 65138595d..2d773cea3 100644 --- a/xwords4/android/drawwrapper.c +++ b/xwords4/android/drawwrapper.c @@ -223,6 +223,22 @@ and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text, return XP_TRUE; } +static void +and_draw_drawBoardArrow(DrawCtx* dctx, const XP_Rect* rect, XWBonusType bonus, + XP_Bool vert, HintAtts hintAtts, CellFlags flags ) +{ + LOG_FUNC(); + AndDraw* draw = (AndDraw*)dctx; + JNIEnv* env = draw->env; + const char* sig = "(Landroid/graphics/Rect;IZII)V"; + jmethodID mid = getMethodID( env, draw->j_draw, "drawBoardArrow", sig ); + + jobject jrect = makeJRect( env, rect ); + (*env)->CallVoidMethod( env, draw->j_draw, mid, + jrect, bonus, vert, hintAtts, flags ); + (*env)->DeleteLocalRef( env, jrect ); +} + static XP_Bool and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner, DrawFocusState dfs ) @@ -406,6 +422,7 @@ makeDraw( MPFORMAL JNIEnv *env, jobject j_draw ) SET_PROC(drawRemText); SET_PROC(score_drawPlayer); SET_PROC(drawCell); + SET_PROC(drawBoardArrow); SET_PROC(trayBegin); SET_PROC(drawTile);