mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
Merge branch 'android_branch' into android_thumbnail
Conflicts: xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java
This commit is contained in:
commit
bb80cdfb08
16 changed files with 204 additions and 279 deletions
|
@ -22,7 +22,7 @@
|
|||
to come from a domain that you own or have control over. -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.eehouse.android.xw4"
|
||||
android:versionCode="63"
|
||||
android:versionCode="64"
|
||||
android:versionName="@string/app_version"
|
||||
>
|
||||
|
||||
|
|
|
@ -51,6 +51,9 @@
|
|||
|
||||
<property name="INITIAL_CLIENT_VERS" value="3"/>
|
||||
<target name="-pre-clean">
|
||||
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null">
|
||||
<arg value="${build.target}"/>
|
||||
</exec>
|
||||
<exec dir="." executable="../scripts/ndkbuild.sh" output="/dev/null">
|
||||
<arg value="clean"/>
|
||||
</exec>
|
||||
|
@ -62,6 +65,10 @@
|
|||
</target>
|
||||
|
||||
<target name="-pre-build">
|
||||
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null">
|
||||
<arg value="${build.target}"/>
|
||||
</exec>
|
||||
|
||||
<property name="CHAT_ENABLED" value="true" />
|
||||
<property name="THUMBNAIL_ENABLED" value="true" />
|
||||
<exec dir="." executable="../scripts/ndkbuild.sh" failonerror="true">
|
||||
|
|
1
xwords4/android/XWords4/jni/.gitignore
vendored
Normal file
1
xwords4/android/XWords4/jni/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Application.mk
|
|
@ -639,7 +639,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1draw
|
|||
JNIEXPORT void JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1figureLayout
|
||||
( JNIEnv* env, jclass C, jint gamePtr, jobject jgi,
|
||||
jint scorePct, jint trayPct, jint fontHt, jint fontWidth,
|
||||
jint scorePct, jint trayPct, jint fontWidth, jint fontHt,
|
||||
jboolean squareTiles, jobject jbounds, jobject jdims )
|
||||
{
|
||||
LOG_FUNC();
|
||||
|
@ -654,7 +654,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1figureLayout
|
|||
|
||||
BoardDims dims;
|
||||
board_figureLayout( state->game.board, gi, scorePct, trayPct,
|
||||
fontHt, fontWidth, squareTiles, &bounds,
|
||||
fontWidth, fontHt, squareTiles, &bounds,
|
||||
((!!jdims) ? &dims : NULL) );
|
||||
|
||||
destroyGI( MPPARM(mpool) &gi );
|
||||
|
@ -676,7 +676,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1applyLayout
|
|||
board_applyLayout( state->game.board, &dims );
|
||||
XWJNI_END();
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setPos
|
||||
|
@ -689,20 +690,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1setPos
|
|||
XWJNI_END();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1zoom
|
||||
( JNIEnv* env, jclass C, jint gamePtr, jint zoomBy, jbooleanArray jCanZoom )
|
||||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
XP_Bool canInOut[2];
|
||||
result = board_zoom( state->game.board, zoomBy, canInOut );
|
||||
jboolean canZoom[2] = { canInOut[0], canInOut[1] };
|
||||
setBoolArray( env, jCanZoom, VSIZE(canZoom), canZoom );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setScoreboardLoc
|
||||
( JNIEnv *env, jclass C, jint gamePtr, jint left, jint top,
|
||||
|
@ -737,6 +724,21 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1setTrayLoc
|
|||
minDividerWidth );
|
||||
XWJNI_END();
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1zoom
|
||||
( JNIEnv* env, jclass C, jint gamePtr, jint zoomBy, jbooleanArray jCanZoom )
|
||||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
XP_Bool canInOut[2];
|
||||
result = board_zoom( state->game.board, zoomBy, canInOut );
|
||||
jboolean canZoom[2] = { canInOut[0], canInOut[1] };
|
||||
setBoolArray( env, jCanZoom, VSIZE(canZoom), canZoom );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_ACTIVERECT
|
||||
JNIEXPORT jboolean JNICALL
|
||||
|
|
|
@ -5,47 +5,23 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<b>Crosswords 4.4 beta 71 release</b>
|
||||
<b>Crosswords 4.4 beta 72 release</b>
|
||||
|
||||
<p>For this release I've redone how you work with games and groups of
|
||||
games in the main Games List screen. Now you select one or more
|
||||
games, and then the screen's main menu (including the right of the
|
||||
action bar for newer devices) changes based on the
|
||||
selection. Long-tap to select. "Context menus" are gone.</p>
|
||||
<p>This release is for the new x86-processor-based Android devices
|
||||
just coming out. Otherwise identical to beta 71, it adds support for
|
||||
x86 processors to existing support for ARM (which has been
|
||||
99.9% of the market until now.)</p>
|
||||
|
||||
<p>Please let me know what you think of this. Suggest tweaks. Should I
|
||||
redo the rest of the screens in this style; or, to the contrary, put
|
||||
things back the way they were? As always, you
|
||||
can <a href="mailto:xwords@eehouse.org">email me here</a>.</p>
|
||||
<p>Thanks to Brendan Le Foll for the patches!</p>
|
||||
|
||||
<h3>New with this release</h3>
|
||||
<ul>
|
||||
<li>More closely follow Android UI guidelines for main Games List
|
||||
screen<ul>
|
||||
<li>Show count of selected games or groups in title bar</li>
|
||||
<li>Long-tap on games and groups selects or deselects rather
|
||||
than bringing up a menu</li>
|
||||
<li>Tap on icon at left of game row selects or deselects</li>
|
||||
<li>Tap on selected game deselects</li>
|
||||
<li>Selecting any group deselects all games, and vice versa</li>
|
||||
<li>Back button clears any selection, or exits if there is
|
||||
none</li>
|
||||
<li>Most common actions now have icons for the action bar</li>
|
||||
<li>A new game created when a group is selected is placed in
|
||||
that group</li>
|
||||
<li>Clear selected games inside collapsing group</li>
|
||||
</ul></li>
|
||||
|
||||
<li>Add a couple of menu items to action bar for Board screen, as
|
||||
text for now pending getting icons</li>
|
||||
|
||||
<li>Remove introductory verbiage from main Games List screen</li>
|
||||
|
||||
<li>Fix bug on tiny-screen phones (Thanks O!)</li>
|
||||
<li>Add support for x86 processors.
|
||||
</ul>
|
||||
|
||||
<h3>Next up</h3>
|
||||
<ul>
|
||||
<li>Add thumbnail of board to main screen</li>
|
||||
<li>Use Actionbar and select/act pattern on more screens</li>
|
||||
<li>Offer "Rematch" when game's over</li>
|
||||
</ul>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<resources>
|
||||
<string name="app_version">4.4 beta 71</string>
|
||||
<string name="app_version">4.4 beta 72</string>
|
||||
</resources>
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
<string name="key_na_browseall">key_na_browseall</string>
|
||||
<string name="key_na_values">key_na_values</string>
|
||||
<string name="key_enable_debug">key_enable_debug</string>
|
||||
<string name="key_enable_commlayt">key_enable_commlayt</string>
|
||||
<string name="key_download_path">key_download_path</string>
|
||||
|
||||
<!-- Nor is my email address -->
|
||||
|
|
|
@ -307,11 +307,6 @@
|
|||
android:summary="Menuitems etc."
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_enable_commlayt"
|
||||
android:title="Use common layout"
|
||||
android:summary="(rather than android-specific)"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
|
||||
<!-- For broken devices like my Blaze 4G that report a download
|
||||
directory that doesn't exist, allow users to set it. Mine:
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.app.Activity;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Rect;
|
||||
|
@ -76,7 +77,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
private boolean m_blackArrow;
|
||||
private Drawable m_rightArrow;
|
||||
private Drawable m_downArrow;
|
||||
private Context m_context;
|
||||
private Activity m_activity;
|
||||
private int m_trayOwner = -1;
|
||||
private int m_pendingScore;
|
||||
private int m_dictPtr = 0;
|
||||
|
@ -118,14 +119,14 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
}
|
||||
private FontDims m_fontDims;
|
||||
|
||||
public BoardCanvas( Context context, Bitmap bitmap, JNIThread jniThread )
|
||||
public BoardCanvas( Activity activity, Bitmap bitmap, JNIThread jniThread )
|
||||
{
|
||||
super( bitmap );
|
||||
m_context = context;
|
||||
m_activity = activity;
|
||||
m_bitmap = bitmap;
|
||||
m_jniThread = jniThread;
|
||||
|
||||
m_hasSmallScreen = Utils.hasSmallScreen( context );
|
||||
m_hasSmallScreen = Utils.hasSmallScreen( activity );
|
||||
|
||||
m_drawPaint = new Paint();
|
||||
m_fillPaint = new Paint( Paint.ANTI_ALIAS_FLAG );
|
||||
|
@ -140,25 +141,31 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
}
|
||||
m_tileStrokePaint.setStrokeWidth( curWidth );
|
||||
|
||||
Resources res = context.getResources();
|
||||
Resources res = activity.getResources();
|
||||
m_origin = res.getDrawable( R.drawable.origin );
|
||||
|
||||
m_prefs = CommonPrefs.get( context );
|
||||
m_prefs = CommonPrefs.get( activity );
|
||||
m_playerColors = m_prefs.playerColors;
|
||||
m_bonusColors = m_prefs.bonusColors;
|
||||
m_otherColors = m_prefs.otherColors;
|
||||
|
||||
fillRect( new Rect( 0, 0, bitmap.getWidth(), bitmap.getHeight() ),
|
||||
WHITE );
|
||||
|
||||
m_bonusSummaries = new String[5];
|
||||
int[] ids = { R.string.bonus_l2x_summary,
|
||||
R.string.bonus_w2x_summary ,
|
||||
R.string.bonus_l3x_summary,
|
||||
R.string.bonus_w3x_summary };
|
||||
res = activity.getResources();
|
||||
for ( int ii = 0; ii < ids.length; ++ii ) {
|
||||
m_bonusSummaries[ ii+1 ] = res.getString( ids[ii] );
|
||||
}
|
||||
|
||||
m_boundsScratch.set( 0, 0, bitmap.getWidth(), bitmap.getHeight() );
|
||||
fillRect( m_boundsScratch, WHITE );
|
||||
}
|
||||
|
||||
public int getCurPlayer()
|
||||
{
|
||||
return m_trayOwner;
|
||||
}
|
||||
|
||||
// DrawCtxt interface implementation
|
||||
|
@ -569,7 +576,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
drawCentered( text, rect, null );
|
||||
|
||||
rect.offset( 0, rect.height() );
|
||||
drawCentered( m_context.getResources().getString( R.string.pts ),
|
||||
drawCentered( m_activity.getResources().getString( R.string.pts ),
|
||||
rect, null );
|
||||
}
|
||||
|
||||
|
@ -587,7 +594,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
}
|
||||
}
|
||||
|
||||
public void dictChanged( int dictPtr )
|
||||
public void dictChanged( final int dictPtr )
|
||||
{
|
||||
if ( m_dictPtr != dictPtr ) {
|
||||
if ( 0 == dictPtr ) {
|
||||
|
@ -596,7 +603,12 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
} else if ( m_dictPtr == 0 ||
|
||||
!XwJNI.dict_tilesAreSame( m_dictPtr, dictPtr ) ) {
|
||||
m_fontDims = null;
|
||||
m_dictChars = XwJNI.dict_getChars( dictPtr );
|
||||
m_dictChars = null;
|
||||
m_activity.runOnUiThread( new Runnable() {
|
||||
public void run() {
|
||||
m_dictChars = XwJNI.dict_getChars( dictPtr );
|
||||
}
|
||||
});
|
||||
}
|
||||
m_dictPtr = dictPtr;
|
||||
}
|
||||
|
@ -870,7 +882,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
|
||||
private Drawable loadAndRecolor( int resID, boolean useDark )
|
||||
{
|
||||
Resources res = m_context.getResources();
|
||||
Resources res = m_activity.getResources();
|
||||
Drawable arrow = res.getDrawable( resID );
|
||||
|
||||
if ( !useDark ) {
|
||||
|
|
|
@ -35,7 +35,6 @@ import android.graphics.drawable.Drawable;
|
|||
import android.content.res.Resources;
|
||||
import android.graphics.Paint.FontMetricsInt;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import java.nio.IntBuffer;
|
||||
import android.util.FloatMath;
|
||||
|
||||
|
@ -58,22 +57,13 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
|||
private int m_layoutWidth;
|
||||
private int m_layoutHeight;
|
||||
private BoardCanvas m_canvas; // owns the bitmap
|
||||
private int m_trayOwner = -1;
|
||||
private boolean m_blackArrow;
|
||||
private boolean m_inTrade = false;
|
||||
// m_backgroundUsed: alpha not set ensures inequality
|
||||
private int m_backgroundUsed = 0x00000000;
|
||||
private JNIThread m_jniThread;
|
||||
private XWActivity m_parent;
|
||||
private String[][] m_scores;
|
||||
private String[] m_dictChars;
|
||||
private Rect m_boundsScratch;
|
||||
private String m_remText;
|
||||
private int m_dictPtr = 0;
|
||||
private int m_lastSecsLeft;
|
||||
private int m_lastTimerPlayer;
|
||||
private int m_pendingScore;
|
||||
private boolean m_useCommon;
|
||||
private boolean m_measuredFromDims = false;
|
||||
private BoardDims m_dims;
|
||||
private CommsAddrRec.CommsConnType m_connType =
|
||||
CommsAddrRec.CommsConnType.COMMS_CONN_NONE;
|
||||
|
||||
|
@ -183,29 +173,17 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
|||
// int d = w == 0 ? h : h == 0 ? w : w < h ? w : h;
|
||||
// setMeasuredDimension(d, d);
|
||||
|
||||
int width = View.MeasureSpec.getSize( widthMeasureSpec );
|
||||
int height = View.MeasureSpec.getSize( heightMeasureSpec );
|
||||
|
||||
int heightMode = View.MeasureSpec.getMode( heightMeasureSpec );
|
||||
// printMode( "heightMode", heightMode );
|
||||
|
||||
m_useCommon =
|
||||
XWPrefs.getPrefsBoolean( m_context,
|
||||
R.string.key_enable_commlayt, false );
|
||||
BoardDims dims = figureBoardDims( width, height );
|
||||
// If I let the spec tell me whether I can reduce the width
|
||||
// then I don't change it on the second pass, but if I ignore
|
||||
// that it works (even though the docs say my change is what
|
||||
// will be ignored.) I'm probably specifying something
|
||||
// incorrectly in the layout xml file.
|
||||
if ( false ) {
|
||||
height = resolveSize( dims.height, heightMeasureSpec );
|
||||
width = resolveSize( dims.width, widthMeasureSpec );
|
||||
int width, height;
|
||||
m_measuredFromDims = null != m_dims;
|
||||
if ( m_measuredFromDims ) {
|
||||
height = m_dims.height;
|
||||
width = m_dims.width;
|
||||
} else {
|
||||
height = dims.height;
|
||||
width = dims.width;
|
||||
width = View.MeasureSpec.getSize( widthMeasureSpec );
|
||||
height = View.MeasureSpec.getSize( heightMeasureSpec );
|
||||
}
|
||||
|
||||
int heightMode = View.MeasureSpec.getMode( heightMeasureSpec );
|
||||
int minHeight = getSuggestedMinimumHeight();
|
||||
if ( height < minHeight ) {
|
||||
height = minHeight;
|
||||
|
@ -217,133 +195,25 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
|||
setMeasuredDimension( width, height );
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected void onLayout( boolean changed, int left, int top,
|
||||
// int right, int bottom )
|
||||
// {
|
||||
// DbgUtils.logf( "BoardView.onLayout(%b, %d, %d, %d, %d)",
|
||||
// changed, left, top, right, bottom );
|
||||
// super.onLayout( changed, left, top, right, bottom );
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// protected void onSizeChanged( int width, int height,
|
||||
// int oldWidth, int oldHeight )
|
||||
// {
|
||||
// DbgUtils.logf( "BoardView.onSizeChanged(%d,%d,%d,%d)", width, height,
|
||||
// oldWidth, oldHeight );
|
||||
// super.onSizeChanged( width, height, oldWidth, oldHeight );
|
||||
// }
|
||||
|
||||
// This will be called from the UI thread
|
||||
@Override
|
||||
protected void onDraw( Canvas canvas )
|
||||
{
|
||||
synchronized( this ) {
|
||||
if ( layoutBoardOnce() ) {
|
||||
if ( layoutBoardOnce() && m_measuredFromDims ) {
|
||||
DbgUtils.logf( "BoardCanvas.onDraw() copying bitmap" );
|
||||
canvas.drawBitmap( s_bitmap, 0, 0, m_drawPaint );
|
||||
ConnStatusHandler.draw( m_context, canvas, getResources(),
|
||||
0, 0, m_connType );
|
||||
} else {
|
||||
DbgUtils.logf( "board not laid out yet" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BoardDims figureBoardDims( int width, int height )
|
||||
{
|
||||
BoardDims result = new BoardDims();
|
||||
boolean squareTiles = XWPrefs.getSquareTiles( m_context );
|
||||
|
||||
Paint paint = new Paint();
|
||||
paint.setTextSize( m_mediumFontHt );
|
||||
paint.getTextBounds( "-00:00", 0, 6, m_boundsScratch );
|
||||
int timerWidth = m_boundsScratch.width();
|
||||
|
||||
if ( m_useCommon ) {
|
||||
Rect bounds = new Rect( 0, 0, width, height );
|
||||
int fontWidth = timerWidth / 6;
|
||||
XwJNI.board_figureLayout( m_jniGamePtr, m_gi, 150, 200,
|
||||
m_defaultFontHt, fontWidth, squareTiles,
|
||||
bounds, result );
|
||||
|
||||
} else {
|
||||
int nCells = m_gi.boardSize;
|
||||
int maxCellSize = 4 * m_defaultFontHt;
|
||||
int trayHt;
|
||||
int scoreHt;
|
||||
int wantHt;
|
||||
int nToScroll;
|
||||
|
||||
for ( boolean firstPass = true; ; ) {
|
||||
result.width = width;
|
||||
|
||||
int cellSize = width / nCells;
|
||||
if ( cellSize > maxCellSize ) {
|
||||
cellSize = maxCellSize;
|
||||
|
||||
int boardWidth = nCells * cellSize;
|
||||
result.width = boardWidth;
|
||||
}
|
||||
result.maxCellSize = maxCellSize;
|
||||
|
||||
// Now determine if vertical scrolling will be necessary.
|
||||
// There's a minimum tray and scoreboard height. If we can
|
||||
// fit them and all cells no scrolling's needed. Otherwise
|
||||
// determine the minimum number that must be hidden to fit.
|
||||
// Finally grow scoreboard and tray to use whatever's left.
|
||||
trayHt = 2 * cellSize;
|
||||
scoreHt = (cellSize * 3) / 2;
|
||||
wantHt = trayHt + scoreHt + (cellSize * nCells);
|
||||
if ( wantHt <= height ) {
|
||||
nToScroll = 0;
|
||||
} else {
|
||||
// Scrolling's required if we use cell width sufficient to
|
||||
// fill the screen. But perhaps we don't need to.
|
||||
int cellWidth = 2 * (height / ( 4 + 3 + (2*nCells)));
|
||||
if ( firstPass && cellWidth >= m_defaultFontHt ) {
|
||||
firstPass = false;
|
||||
width = nCells * cellWidth;
|
||||
continue;
|
||||
} else {
|
||||
nToScroll = nCells - ((height - trayHt - scoreHt) / cellSize);
|
||||
}
|
||||
}
|
||||
|
||||
int heightUsed = trayHt + scoreHt + (nCells - nToScroll) * cellSize;
|
||||
int heightLeft = height - heightUsed;
|
||||
if ( 0 < heightLeft ) {
|
||||
if ( heightLeft > (cellSize * 3 / 2) ) {
|
||||
heightLeft = cellSize * 3 / 2;
|
||||
}
|
||||
heightLeft /= 3;
|
||||
scoreHt += heightLeft;
|
||||
|
||||
trayHt += heightLeft * 2;
|
||||
if ( squareTiles && trayHt > (width / 7) ) {
|
||||
trayHt = width / 7;
|
||||
}
|
||||
heightUsed = trayHt + scoreHt + ((nCells - nToScroll) * cellSize);
|
||||
}
|
||||
|
||||
result.trayHt = trayHt;
|
||||
result.scoreHt = scoreHt;
|
||||
|
||||
result.boardHt = cellSize * nCells;
|
||||
result.trayTop = scoreHt + (cellSize * (nCells-nToScroll));
|
||||
result.height = heightUsed;
|
||||
result.cellSize = cellSize;
|
||||
|
||||
if ( m_gi.timerEnabled ) {
|
||||
result.timerWidth = timerWidth;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} // figureBoardDims
|
||||
|
||||
private boolean layoutBoardOnce()
|
||||
{
|
||||
DbgUtils.logf( "layoutBoardOnce()" );
|
||||
final int width = getWidth();
|
||||
final int height = getHeight();
|
||||
boolean layoutDone = width == m_layoutWidth && height == m_layoutHeight;
|
||||
|
@ -351,38 +221,48 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
|||
// nothing to do
|
||||
} else if ( null == m_gi ) {
|
||||
// nothing to do either
|
||||
} else if ( null == m_dims ) {
|
||||
// m_canvas = null;
|
||||
// need to synchronize??
|
||||
Paint paint = new Paint();
|
||||
paint.setTextSize( m_mediumFontHt );
|
||||
paint.getTextBounds( "-00:00", 0, 6, m_boundsScratch );
|
||||
int timerWidth = m_boundsScratch.width();
|
||||
int fontWidth = timerWidth / 6;
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_LAYOUT, width, height,
|
||||
fontWidth, m_defaultFontHt );
|
||||
// We'll be back....
|
||||
} else {
|
||||
m_layoutWidth = width;
|
||||
m_layoutHeight = height;
|
||||
// m_fontDims = null; // force recalc of font
|
||||
// m_letterRect = null;
|
||||
// m_valRect = null;
|
||||
|
||||
BoardDims dims = figureBoardDims( width, height );
|
||||
|
||||
// If board size has changed we need a new bitmap
|
||||
int bmHeight = 1 + dims.height;
|
||||
int bmWidth = 1 + dims.width;
|
||||
int bmHeight = 1 + m_dims.height;
|
||||
int bmWidth = 1 + m_dims.width;
|
||||
if ( null != s_bitmap ) {
|
||||
if ( s_bitmap.getHeight() != bmHeight
|
||||
|| s_bitmap.getWidth() != bmWidth ) {
|
||||
s_bitmap = null;
|
||||
m_canvas = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ( null == s_bitmap ) {
|
||||
DbgUtils.logf( "making %dx%d static bitmap", bmWidth, bmHeight );
|
||||
s_bitmap = Bitmap.createBitmap( bmWidth, bmHeight,
|
||||
Bitmap.Config.ARGB_8888 );
|
||||
}
|
||||
m_canvas = new BoardCanvas( m_context, s_bitmap, m_jniThread );
|
||||
XwJNI.board_setDraw( m_jniGamePtr, m_canvas );
|
||||
|
||||
// need to synchronize??
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_LAYOUT, dims,
|
||||
m_useCommon );
|
||||
if ( null == m_canvas ) {
|
||||
DbgUtils.logf( "layoutBoardOnce: allocating canvas for %d, %d",
|
||||
bmWidth, bmHeight );
|
||||
m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread );
|
||||
}
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_SETDRAW, m_canvas );
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_DRAW );
|
||||
|
||||
// set so we know we're done
|
||||
m_layoutWidth = width;
|
||||
m_layoutHeight = height;
|
||||
layoutDone = true;
|
||||
}
|
||||
DbgUtils.logf( "layoutBoardOnce()=>%b", layoutDone );
|
||||
return layoutDone;
|
||||
} // layoutBoardOnce
|
||||
|
||||
|
@ -391,6 +271,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
|||
int gamePtr, CurGameInfo gi,
|
||||
CommsAddrRec.CommsConnType connType )
|
||||
{
|
||||
DbgUtils.logf( "startHandling()" );
|
||||
m_parent = parent;
|
||||
m_jniThread = thread;
|
||||
m_jniGamePtr = gamePtr;
|
||||
|
@ -407,15 +288,36 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
|||
// SyncedDraw interface implementation
|
||||
public void doJNIDraw()
|
||||
{
|
||||
DbgUtils.logf( "doJNIDraw() called" );
|
||||
boolean drew;
|
||||
synchronized( this ) {
|
||||
drew = XwJNI.board_draw( m_jniGamePtr );
|
||||
}
|
||||
if ( !drew ) {
|
||||
if ( drew ) {
|
||||
// Force update now that we have bits to copy
|
||||
// m_parent.runOnUiThread( new Runnable() {
|
||||
// public void run() {
|
||||
// invalidate();
|
||||
// }
|
||||
// });
|
||||
} else {
|
||||
DbgUtils.logf( "doJNIDraw: draw not complete" );
|
||||
}
|
||||
}
|
||||
|
||||
public void dimsChanged( BoardDims dims )
|
||||
{
|
||||
m_dims = dims;
|
||||
DbgUtils.logf( "BoardView.dimsChanged() called; new dims %dx%d",
|
||||
dims.width, dims.height );
|
||||
m_parent.runOnUiThread( new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
invalidate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setInTrade( boolean inTrade )
|
||||
{
|
||||
m_inTrade = inTrade;
|
||||
|
@ -424,7 +326,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
|||
|
||||
public int getCurPlayer()
|
||||
{
|
||||
return m_trayOwner;
|
||||
return null == m_canvas? -1 : m_canvas.getCurPlayer();
|
||||
}
|
||||
|
||||
public int curPending()
|
||||
|
|
|
@ -32,21 +32,25 @@ import java.util.Arrays;
|
|||
import java.util.Iterator;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.eehouse.android.xw4.R;
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
import org.eehouse.android.xw4.ConnStatusHandler;
|
||||
import org.eehouse.android.xw4.BoardDims;
|
||||
import org.eehouse.android.xw4.ConnStatusHandler;
|
||||
import org.eehouse.android.xw4.DBUtils;
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
import org.eehouse.android.xw4.GameLock;
|
||||
import org.eehouse.android.xw4.GameUtils;
|
||||
import org.eehouse.android.xw4.DBUtils;
|
||||
import org.eehouse.android.xw4.R;
|
||||
import org.eehouse.android.xw4.Toolbar;
|
||||
import org.eehouse.android.xw4.XWPrefs;
|
||||
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
||||
import org.eehouse.android.xw4.jni.DrawCtx;
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class JNIThread extends Thread {
|
||||
|
||||
public enum JNICmd { CMD_NONE,
|
||||
// CMD_RUN,
|
||||
CMD_DRAW,
|
||||
CMD_SETDRAW,
|
||||
CMD_INVALALL,
|
||||
CMD_LAYOUT,
|
||||
CMD_START,
|
||||
|
@ -233,36 +237,24 @@ public class JNIThread extends Thread {
|
|||
Message.obtain( m_handler, DIALOG, titleArg, 0, text ).sendToTarget();
|
||||
}
|
||||
|
||||
private void doLayout( BoardDims dims, boolean useCommon )
|
||||
private void doLayout( int width, int height, int fontWidth,
|
||||
int fontHeight )
|
||||
{
|
||||
if ( useCommon ) {
|
||||
XwJNI.board_applyLayout( m_jniGamePtr, dims );
|
||||
} else {
|
||||
int scoreWidth = dims.width - dims.cellSize;
|
||||
ConnStatusHandler.setRect( scoreWidth, 0, scoreWidth + dims.cellSize,
|
||||
dims.scoreHt );
|
||||
BoardDims dims = new BoardDims();
|
||||
|
||||
if ( m_gi.timerEnabled ) {
|
||||
scoreWidth -= dims.timerWidth;
|
||||
XwJNI.board_setTimerLoc( m_jniGamePtr, scoreWidth, 0,
|
||||
dims.timerWidth, dims.scoreHt );
|
||||
}
|
||||
XwJNI.board_setScoreboardLoc( m_jniGamePtr, 0, 0, scoreWidth,
|
||||
dims.scoreHt, true );
|
||||
boolean squareTiles = XWPrefs.getSquareTiles( m_context );
|
||||
Rect bounds = new Rect( 0, 0, width, height );
|
||||
XwJNI.board_figureLayout( m_jniGamePtr, m_gi, 150, 200,
|
||||
fontWidth, fontHeight, squareTiles,
|
||||
bounds, dims );
|
||||
|
||||
// Have no idea why I was doing -1 below, but it breaks layout
|
||||
// for small (QVGA) boards. If it needs to be done, do it
|
||||
// early in figureBoardDims so the calculations that follow
|
||||
// are consistent.
|
||||
XwJNI.board_setPos( m_jniGamePtr, 0, dims.scoreHt,
|
||||
dims.width/*-1*/, dims.boardHt, dims.maxCellSize,
|
||||
false );
|
||||
int scoreWidth = dims.width - dims.cellSize;
|
||||
ConnStatusHandler.setRect( scoreWidth, 0, scoreWidth + dims.cellSize,
|
||||
dims.scoreHt );
|
||||
|
||||
XwJNI.board_setTrayLoc( m_jniGamePtr, 0, dims.trayTop,
|
||||
dims.width/*-1*/, dims.trayHt, kMinDivWidth );
|
||||
XwJNI.board_applyLayout( m_jniGamePtr, dims );
|
||||
|
||||
XwJNI.board_invalAll( m_jniGamePtr );
|
||||
}
|
||||
m_drawer.dimsChanged( dims );
|
||||
}
|
||||
|
||||
private boolean nextSame( JNICmd cmd )
|
||||
|
@ -337,6 +329,11 @@ public class JNIThread extends Thread {
|
|||
args = elem.m_args;
|
||||
switch( elem.m_cmd ) {
|
||||
|
||||
// case CMD_RUN:
|
||||
// Runnable proc = (Runnable)args[0];
|
||||
// proc.run();
|
||||
// break;
|
||||
|
||||
case CMD_SAVE:
|
||||
if ( nextSame( JNICmd.CMD_SAVE ) ) {
|
||||
continue;
|
||||
|
@ -356,13 +353,19 @@ public class JNIThread extends Thread {
|
|||
draw = true;
|
||||
break;
|
||||
|
||||
case CMD_SETDRAW:
|
||||
XwJNI.board_setDraw( m_jniGamePtr, (DrawCtx)args[0] );
|
||||
XwJNI.board_invalAll( m_jniGamePtr );
|
||||
break;
|
||||
|
||||
case CMD_INVALALL:
|
||||
XwJNI.board_invalAll( m_jniGamePtr );
|
||||
draw = true;
|
||||
break;
|
||||
|
||||
case CMD_LAYOUT:
|
||||
doLayout( (BoardDims)args[0], (Boolean)args[1] );
|
||||
doLayout( (Integer)args[0], (Integer)args[1], (Integer)args[2],
|
||||
(Integer)args[3] );
|
||||
draw = true;
|
||||
// check and disable zoom button at limit
|
||||
handle( JNICmd.CMD_ZOOM, 0 );
|
||||
|
@ -650,4 +653,10 @@ public class JNIThread extends Thread {
|
|||
m_queue.add( elem );
|
||||
}
|
||||
|
||||
// public void run( boolean isUI, Runnable runnable )
|
||||
// {
|
||||
// Object[] args = { runnable };
|
||||
// QueueElem elem = new QueueElem( JNICmd.CMD_RUN, isUI, args );
|
||||
// m_queue.add( elem );
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
package org.eehouse.android.xw4.jni;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import org.eehouse.android.xw4.BoardDims;
|
||||
|
||||
public interface SyncedDraw {
|
||||
void doJNIDraw();
|
||||
void dimsChanged( BoardDims dims );
|
||||
}
|
||||
|
|
|
@ -152,27 +152,28 @@ public class XwJNI {
|
|||
// Only if COMMON_LAYOUT defined
|
||||
public static native void board_figureLayout( int gamePtr, CurGameInfo gi,
|
||||
int scorePct, int trayPct,
|
||||
int fontHt, int fontWidth,
|
||||
int fontWidth, int fontHt,
|
||||
boolean squareTiles,
|
||||
Rect bounds, BoardDims dims );
|
||||
// Only if COMMON_LAYOUT defined
|
||||
public static native void board_applyLayout( int gamePtr, BoardDims dims );
|
||||
|
||||
public static native void board_setPos( int gamePtr, int left, int top,
|
||||
int width, int height,
|
||||
int maxCellHt, boolean lefty );
|
||||
// public static native void board_setPos( int gamePtr, int left, int top,
|
||||
// int width, int height,
|
||||
// int maxCellHt, boolean lefty );
|
||||
// public static native void board_setScoreboardLoc( int gamePtr, int left,
|
||||
// int top, int width,
|
||||
// int height,
|
||||
// boolean divideHorizontally );
|
||||
// public static native void board_setTrayLoc( int gamePtr, int left,
|
||||
// int top, int width,
|
||||
// int height, int minDividerWidth );
|
||||
// public static native void board_setTimerLoc( int gamePtr,
|
||||
// int timerLeft, int timerTop,
|
||||
// int timerWidth,
|
||||
// int timerHeight );
|
||||
public static native boolean board_zoom( int gamePtr, int zoomBy,
|
||||
boolean[] canZoom );
|
||||
public static native void board_setScoreboardLoc( int gamePtr, int left,
|
||||
int top, int width,
|
||||
int height,
|
||||
boolean divideHorizontally );
|
||||
public static native void board_setTrayLoc( int gamePtr, int left,
|
||||
int top, int width,
|
||||
int height, int minDividerWidth );
|
||||
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 );
|
||||
|
||||
|
|
19
xwords4/android/scripts/ndksetup.sh
Executable file
19
xwords4/android/scripts/ndksetup.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -u -e
|
||||
|
||||
APPMK=./jni/Application.mk
|
||||
XWORDS_DEBUG_ARMONLY=${XWORDS_DEBUG_ARMONLY:-""}
|
||||
XWORDS_DEBUG_X86ONLY=${XWORDS_DEBUG_X86ONLYx:-""}
|
||||
|
||||
echo "# Generated by $0; do not edit!!!" > $APPMK
|
||||
|
||||
if [ "$1" = "release" ]; then
|
||||
echo "APP_ABI := armeabi x86" >> $APPMK
|
||||
elif [ -n "$XWORDS_DEBUG_ARMONLY" ]; then
|
||||
echo "APP_ABI := armeabi" >> $APPMK
|
||||
elif [ -n "$XWORDS_DEBUG_X86ONLY" ]; then
|
||||
echo "APP_ABI := x86" >> $APPMK
|
||||
else
|
||||
echo "APP_ABI := armeabi x86" >> $APPMK
|
||||
fi
|
|
@ -393,7 +393,7 @@ board_reset( BoardCtxt* board )
|
|||
void
|
||||
board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
|
||||
XP_U16 scorePct, XP_U16 trayPct,
|
||||
XP_U16 fontHt, XP_U16 fontWidth, XP_Bool squareTiles,
|
||||
XP_U16 fontWidth, XP_U16 fontHt, XP_Bool squareTiles,
|
||||
const XP_Rect* bounds, BoardDims* dimsp )
|
||||
{
|
||||
BoardDims ldims;
|
||||
|
|
|
@ -87,7 +87,7 @@ typedef struct _BoardDims {
|
|||
|
||||
void board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
|
||||
XP_U16 scorePct, XP_U16 trayPct,
|
||||
XP_U16 fontHt, XP_U16 fontWidth,
|
||||
XP_U16 fontWidth, XP_U16 fontHt,
|
||||
XP_Bool squareTiles, const XP_Rect* bounds,
|
||||
/* out */ BoardDims* dims );
|
||||
void board_applyLayout( BoardCtxt* board, const BoardDims* dims );
|
||||
|
|
Loading…
Add table
Reference in a new issue