cleanup: remove EOL whitespace from java files

New diff tool is complaining about it, and sed is so easy...
This commit is contained in:
Eric House 2016-07-14 07:37:11 -07:00
parent 15256ac2ad
commit db0fb8e2f1
110 changed files with 1674 additions and 1674 deletions

View file

@ -25,13 +25,13 @@ import android.content.Context;
import android.view.ViewConfiguration;
public class ABUtils {
private static int s_sdkVersion =
private static int s_sdkVersion =
Integer.valueOf( android.os.Build.VERSION.SDK );
private static interface SafeInvalOptionsMenu {
public void doInval( Activity activity );
}
private static class SafeInvalOptionsMenuImpl
private static class SafeInvalOptionsMenuImpl
implements SafeInvalOptionsMenu {
public void doInval( Activity activity ) {
activity.invalidateOptionsMenu();
@ -42,7 +42,7 @@ public class ABUtils {
private static interface SafeHasMenuKey {
public boolean hasMenuKey( Context context );
}
private static class SafeHasMenuKeyImpl
private static class SafeHasMenuKeyImpl
implements SafeHasMenuKey {
public boolean hasMenuKey( Context context )
{

View file

@ -84,9 +84,9 @@ public class BTInviteDelegate extends InviteDelegate {
m_counts = new HashMap<String, Integer>();
String msg = getString( R.string.bt_pick_addall_button );
msg = getQuantityString( R.plurals.invite_bt_desc_fmt, m_nMissing,
msg = getQuantityString( R.plurals.invite_bt_desc_fmt, m_nMissing,
m_nMissing, msg );
super.init( R.id.button_invite, R.id.button_rescan,
super.init( R.id.button_invite, R.id.button_rescan,
R.id.button_clear, R.id.invite_desc, msg );
BTService.clearDevices( m_activity, null ); // will return names
}
@ -134,7 +134,7 @@ public class BTInviteDelegate extends InviteDelegate {
if ( 0 < count ) {
BTService.scan( m_activity );
} else {
showConfirmThen( R.string.bt_no_devs, R.string.button_go_settings,
showConfirmThen( R.string.bt_no_devs, R.string.button_go_settings,
Action.OPEN_BT_PREFS_ACTION );
}
}
@ -171,7 +171,7 @@ public class BTInviteDelegate extends InviteDelegate {
}
}
protected void tryEnable()
protected void tryEnable()
{
String[][] devs = new String[1][];
int[][] counts = new int[1][];
@ -210,7 +210,7 @@ public class BTInviteDelegate extends InviteDelegate {
if ( XWPrefs.getCanInviteMulti( m_activity ) && 1 < m_nMissing ) {
Spinner spinner = (Spinner)
layout.findViewById(R.id.nperdev_spinner);
ArrayAdapter<String> adapter =
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( m_activity, android.R.layout
.simple_spinner_item );
for ( int ii = 1; ii <= m_nMissing; ++ii ) {
@ -220,8 +220,8 @@ public class BTInviteDelegate extends InviteDelegate {
spinner.setAdapter( adapter );
spinner.setVisibility( View.VISIBLE );
spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
long id )
{
m_counts.put( btAddr, 1 + pos );
@ -232,9 +232,9 @@ public class BTInviteDelegate extends InviteDelegate {
} );
}
CompoundButton.OnCheckedChangeListener listener =
CompoundButton.OnCheckedChangeListener listener =
new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton buttonView,
public void onCheckedChanged( CompoundButton buttonView,
boolean isChecked ) {
if ( isChecked ) {
m_checked.add( layout );

View file

@ -39,7 +39,7 @@ public class BTReceiver extends BroadcastReceiver {
if ( action.equals( BluetoothDevice.ACTION_ACL_CONNECTED ) ) {
BTService.startService( context );
} else if ( action.equals( BluetoothAdapter.ACTION_STATE_CHANGED ) ) {
int newState =
int newState =
intent.getIntExtra( BluetoothAdapter.EXTRA_STATE, -1 );
switch ( newState ) {
case BluetoothAdapter.STATE_OFF:

View file

@ -97,7 +97,7 @@ public class BTService extends XWService {
private static final String BT_NAME_KEY = "BT_NAME";
private static final String BT_ADDRESS_KEY = "BT_ADDRESS";
private enum BTCmd {
private enum BTCmd {
BAD_PROTO,
PING,
PONG,
@ -134,7 +134,7 @@ public class BTService extends XWService {
public BTQueueElem( BTCmd cmd, byte[] buf, String btAddr, int gameID ) {
this( cmd );
Assert.assertTrue( null != btAddr && 0 < btAddr.length() );
m_msg = buf; m_btAddr = btAddr;
m_msg = buf; m_btAddr = btAddr;
m_gameID = gameID;
checkAddr();
}
@ -193,7 +193,7 @@ public class BTService extends XWService {
public static String[] getBTNameAndAddress()
{
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
return null == adapter ? null
return null == adapter ? null
: new String[] { adapter.getName(), adapter.getAddress() };
}
@ -212,7 +212,7 @@ public class BTService extends XWService {
{
Intent intent = new Intent();
intent.setAction( android.provider.Settings.ACTION_BLUETOOTH_SETTINGS );
activity.startActivity( intent );
activity.startActivity( intent );
}
public static String nameForAddr( String btAddr )
@ -264,9 +264,9 @@ public class BTService extends XWService {
intent.putExtra( ADDR_KEY, hostAddr );
intent.putExtra( GAMEID_KEY, gameID );
context.startService( intent );
}
}
public static void inviteRemote( Context context, String btAddr,
public static void inviteRemote( Context context, String btAddr,
NetLaunchInfo nli )
{
Assert.assertTrue( null != btAddr && 0 < btAddr.length() );
@ -291,7 +291,7 @@ public class BTService extends XWService {
context.startService( intent );
}
public static int enqueueFor( Context context, byte[] buf,
public static int enqueueFor( Context context, byte[] buf,
CommsAddrRec targetAddr, int gameID )
{
int nSent = -1;
@ -312,7 +312,7 @@ public class BTService extends XWService {
}
return nSent;
}
public static void gameDied( Context context, int gameID )
{
Intent intent = getIntentTo( context, BTAction.REMOVE );
@ -334,7 +334,7 @@ public class BTService extends XWService {
? BluetoothAdapter.getDefaultAdapter() : null;
if ( null != adapter && adapter.isEnabled() ) {
m_adapter = adapter;
DbgUtils.logf( "BTService.onCreate(); bt name = %s; bt addr = %s",
DbgUtils.logf( "BTService.onCreate(); bt name = %s; bt addr = %s",
adapter.getName(), adapter.getAddress() );
initAddrs();
startListener();
@ -389,7 +389,7 @@ public class BTService extends XWService {
int nPlayersT = intent.getIntExtra( NTO_KEY, -1 );
String btName = intent.getStringExtra( BT_NAME_KEY );
btAddr = intent.getStringExtra( BT_ADDRESS_KEY );
// /*(void)*/makeOrNotify( this, gameID, null, lang, dict,
// /*(void)*/makeOrNotify( this, gameID, null, lang, dict,
// nPlayersT, 1, btName, btAddr );
Assert.fail();
break;
@ -399,7 +399,7 @@ public class BTService extends XWService {
btAddr = intent.getStringExtra( ADDR_KEY );
gameID = intent.getIntExtra( GAMEID_KEY, -1 );
if ( -1 != gameID ) {
m_sender.add( new BTQueueElem( BTCmd.MESG_SEND, buf,
m_sender.add( new BTQueueElem( BTCmd.MESG_SEND, buf,
btAddr, gameID ) );
}
break;
@ -413,7 +413,7 @@ public class BTService extends XWService {
false );
} else {
ConnStatusHandler.updateStatus( this, null,
CommsConnType.COMMS_CONN_BT,
CommsConnType.COMMS_CONN_BT,
false );
stopListener();
stopSender();
@ -453,7 +453,7 @@ public class BTService extends XWService {
try {
BluetoothSocket socket = m_serverSocket.accept(); // blocks
addAddr( socket );
DataInputStream inStream =
DataInputStream inStream =
new DataInputStream( socket.getInputStream() );
byte proto = inStream.readByte();
@ -476,7 +476,7 @@ public class BTService extends XWService {
}
updateStatusIn( true );
} else {
DataOutputStream os =
DataOutputStream os =
new DataOutputStream( socket.getOutputStream() );
os.writeByte( BTCmd.BAD_PROTO.ordinal() );
os.flush();
@ -574,16 +574,16 @@ public class BTService extends XWService {
BluetoothDevice host = socket.getRemoteDevice();
addAddr( host );
CommsAddrRec addr = new CommsAddrRec( host.getName(),
CommsAddrRec addr = new CommsAddrRec( host.getName(),
host.getAddress() );
ReceiveResult rslt
= BTService.this.receiveMessage( BTService.this, gameID,
= BTService.this.receiveMessage( BTService.this, gameID,
m_btMsgSink, buffer, addr );
BTCmd result = rslt == ReceiveResult.GAME_GONE ?
BTCmd result = rslt == ReceiveResult.GAME_GONE ?
BTCmd.MESG_GAMEGONE : BTCmd.MESG_ACCPT;
DataOutputStream os =
DataOutputStream os =
new DataOutputStream( socket.getOutputStream() );
os.writeByte( result.ordinal() );
os.flush();
@ -766,7 +766,7 @@ public class BTService extends XWService {
os.flush();
Thread killer = killSocketIn( socket, 5 );
DataInputStream is =
DataInputStream is =
new DataInputStream( socket.getInputStream() );
BTCmd reply = BTCmd.values()[is.readByte()];
if ( BTCmd.BAD_PROTO == reply ) {
@ -803,9 +803,9 @@ public class BTService extends XWService {
private void sendInvite( BTQueueElem elem )
{
try {
BluetoothDevice dev =
BluetoothDevice dev =
m_adapter.getRemoteDevice( elem.m_btAddr );
BluetoothSocket socket =
BluetoothSocket socket =
dev.createRfcommSocketToServiceRecord( XWApp.getAppUUID() );
if ( null != socket ) {
BTCmd reply = null;
@ -821,7 +821,7 @@ public class BTService extends XWService {
DbgUtils.logf( "<eeh>sending invite for %d players", elem.m_nPlayersH );
outStream.flush();
DataInputStream inStream =
DataInputStream inStream =
new DataInputStream( socket.getInputStream() );
reply = BTCmd.values()[inStream.readByte()];
}
@ -861,19 +861,19 @@ public class BTService extends XWService {
MultiEvent evt;
if ( success ) {
evt = MultiEvent.MESSAGE_DROPPED;
DbgUtils.logf( "BTService.sendMsg: dropping message %s because game %X dead",
DbgUtils.logf( "BTService.sendMsg: dropping message %s because game %X dead",
elem.m_cmd, elem.m_gameID );
} else {
evt = MultiEvent.MESSAGE_REFUSED;
}
if ( !success ) {
try {
BluetoothDevice dev =
BluetoothDevice dev =
m_adapter.getRemoteDevice( elem.m_btAddr );
BluetoothSocket socket = dev.
createRfcommSocketToServiceRecord( XWApp.getAppUUID() );
if ( null != socket ) {
DataOutputStream outStream =
DataOutputStream outStream =
connect( socket, BTCmd.MESG_SEND );
if ( null != outStream ) {
outStream.writeInt( elem.m_gameID );
@ -885,7 +885,7 @@ public class BTService extends XWService {
outStream.flush();
Thread killer = killSocketIn( socket );
DataInputStream inStream =
DataInputStream inStream =
new DataInputStream( socket.getInputStream() );
BTCmd reply = BTCmd.values()[inStream.readByte()];
killer.interrupt();
@ -941,7 +941,7 @@ public class BTService extends XWService {
iter.remove();
}
}
}
return success;
}
@ -1072,7 +1072,7 @@ public class BTService extends XWService {
m_sender = null;
}
private BTCmd makeOrNotify( NetLaunchInfo nli, String btName,
private BTCmd makeOrNotify( NetLaunchInfo nli, String btName,
String btAddr )
{
BTCmd result;
@ -1081,27 +1081,27 @@ public class BTService extends XWService {
result = makeGame( nli, btName, btAddr );
} else {
Intent intent = MultiService
.makeMissingDictIntent( this, nli,
.makeMissingDictIntent( this, nli,
DictFetchOwner.OWNER_BT );
// NetLaunchInfo.putExtras( intent, gameID, btName, btAddr );
MultiService.postMissingDictNotification( this, intent,
MultiService.postMissingDictNotification( this, intent,
nli.gameID() );
result = BTCmd.INVITE_ACCPT; // ???
}
} else {
result = BTCmd.INVITE_DUP_INVITE; // dupe of rematch
result = BTCmd.INVITE_DUP_INVITE; // dupe of rematch
}
return result;
}
private BTCmd makeGame( NetLaunchInfo nli, String sender,
private BTCmd makeGame( NetLaunchInfo nli, String sender,
String senderAddress )
{
BTCmd result;
long[] rowids = DBUtils.getRowIDsFor( BTService.this, nli.gameID() );
if ( null == rowids || 0 == rowids.length ) {
CommsAddrRec addr = nli.makeAddrRec( BTService.this );
long rowid = GameUtils.makeNewMultiGame( BTService.this, nli,
long rowid = GameUtils.makeNewMultiGame( BTService.this, nli,
m_btMsgSink,
getUtilCtxt() );
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
@ -1111,11 +1111,11 @@ public class BTService extends XWService {
DBUtils.setName( BTService.this, rowid, nli.gameName );
}
result = BTCmd.INVITE_ACCPT;
String body = LocUtils.getString( BTService.this,
R.string.new_bt_body_fmt,
String body = LocUtils.getString( BTService.this,
R.string.new_bt_body_fmt,
sender );
GameUtils.postInvitedNotification( this, nli.gameID(), body,
GameUtils.postInvitedNotification( this, nli.gameID(), body,
rowid );
sendResult( MultiEvent.BT_GAME_CREATED, rowid );
@ -1132,9 +1132,9 @@ public class BTService extends XWService {
// DbgUtils.logf( "connecting to %s to send cmd %s", name, cmd.toString() );
// Docs say always call cancelDiscovery before trying to connect
m_adapter.cancelDiscovery();
DataOutputStream dos;
try {
try {
socket.connect();
dos = new DataOutputStream( socket.getOutputStream() );
dos.writeByte( BT_PROTO );

View file

@ -34,13 +34,13 @@ public class BoardActivity extends XWActivity {
private BoardDelegate m_dlgt;
@Override
protected void onCreate( Bundle savedInstanceState )
protected void onCreate( Bundle savedInstanceState )
{
if ( CommonPrefs.getHideTitleBar( this )
&& ABUtils.haveMenuKey( this ) ) {
requestWindowFeature( Window.FEATURE_NO_TITLE );
}
m_dlgt = new BoardDelegate( this, savedInstanceState );
super.onCreate( savedInstanceState, m_dlgt );

View file

@ -136,7 +136,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
this( activity, activity, bitmap, jniThread, dims );
}
private BoardCanvas( Context context, Activity activity, Bitmap bitmap,
private BoardCanvas( Context context, Activity activity, Bitmap bitmap,
JNIThread jniThread, BoardDims dims )
{
super( bitmap );
@ -193,12 +193,12 @@ public class BoardCanvas extends Canvas implements DrawCtx {
return m_trayOwner;
}
public int curPending()
public int curPending()
{
return m_pendingScore;
}
public void setInTrade( boolean inTrade )
public void setInTrade( boolean inTrade )
{
if ( m_inTrade != inTrade ) {
m_inTrade = inTrade;
@ -207,7 +207,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
// DrawCtxt interface implementation
public boolean scoreBegin( Rect rect, int numPlayers, int[] scores,
public boolean scoreBegin( Rect rect, int numPlayers, int[] scores,
int remCount )
{
fillRectOther( rect, CommonPrefs.COLOR_BACKGRND );
@ -215,15 +215,15 @@ public class BoardCanvas extends Canvas implements DrawCtx {
return true;
}
public boolean measureRemText( Rect r, int nTilesLeft, int[] width,
int[] height )
public boolean measureRemText( Rect r, int nTilesLeft, int[] width,
int[] height )
{
boolean showREM = 0 <= nTilesLeft;
if ( showREM ) {
// should cache a formatter
m_remText = String.format( "%d", nTilesLeft );
m_fillPaint.setTextSize( m_mediumFontHt );
m_fillPaint.getTextBounds( m_remText, 0, m_remText.length(),
m_fillPaint.getTextBounds( m_remText, 0, m_remText.length(),
m_boundsScratch );
int minWidth = m_boundsScratch.width();
@ -236,7 +236,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
return showREM;
}
public void drawRemText( Rect rInner, Rect rOuter, int nTilesLeft,
public void drawRemText( Rect rInner, Rect rOuter, int nTilesLeft,
boolean focussed )
{
int indx = focussed ? CommonPrefs.COLOR_FOCUS
@ -247,7 +247,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
drawCentered( m_remText, rInner, null );
}
public void measureScoreText( Rect rect, DrawScoreInfo dsi,
public void measureScoreText( Rect rect, DrawScoreInfo dsi,
int[] width, int[] height )
{
String[] scoreInfo = new String[dsi.isTurn?1:2];
@ -283,7 +283,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
int needWidth = 0;
for ( int ii = 0; ii < scoreInfo.length; ++ii ) {
m_fillPaint.getTextBounds( scoreInfo[ii], 0, scoreInfo[ii].length(),
m_fillPaint.getTextBounds( scoreInfo[ii], 0, scoreInfo[ii].length(),
m_boundsScratch );
if ( needWidth < m_boundsScratch.width() ) {
needWidth = m_boundsScratch.width();
@ -297,7 +297,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
height[0] = rect.height();
}
public void score_drawPlayer( Rect rInner, Rect rOuter,
public void score_drawPlayer( Rect rInner, Rect rOuter,
int gotPct, DrawScoreInfo dsi )
{
if ( 0 != (dsi.flags & CELL_ISCURSOR) ) {
@ -332,7 +332,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
String negSign = secondsLeft < 0? "-":"";
secondsLeft = Math.abs( secondsLeft );
String time = String.format( "%s%d:%02d", negSign, secondsLeft/60,
String time = String.format( "%s%d:%02d", negSign, secondsLeft/60,
secondsLeft%60 );
fillRectOther( rect, CommonPrefs.COLOR_BACKGRND );
@ -352,8 +352,8 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
public boolean drawCell( final Rect rect, String text, int tile, int value,
int owner, int bonus, int hintAtts,
final int flags )
int owner, int bonus, int hintAtts,
final int flags )
{
boolean canDraw = figureFontDims();
if ( canDraw ) {
@ -425,7 +425,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
} // drawCell
private boolean m_arrowHintShown = false;
public void drawBoardArrow( Rect rect, int bonus, boolean vert,
public void drawBoardArrow( Rect rect, int bonus, boolean vert,
int hintAtts, int flags )
{
// figure out if the background is more dark than light
@ -458,7 +458,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
// handler.post( new Runnable() {
// public void run() {
// m_parent.
// showNotAgainDlgThen( R.string.not_again_arrow,
// showNotAgainDlgThen( R.string.not_again_arrow,
// R.string.
// key_notagain_arrow );
// } } );
@ -466,30 +466,30 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
}
public boolean trayBegin( Rect rect, int owner, int score )
public boolean trayBegin( Rect rect, int owner, int score )
{
m_trayOwner = owner;
m_pendingScore = score;
return true;
}
public boolean drawTile( Rect rect, String text, int val, int flags )
public boolean drawTile( Rect rect, String text, int val, int flags )
{
return drawTileImpl( rect, text, val, flags, true );
}
public boolean drawTileMidDrag( Rect rect, String text, int val, int owner,
int flags )
public boolean drawTileMidDrag( Rect rect, String text, int val, int owner,
int flags )
{
return drawTileImpl( rect, text, val, flags, false );
}
public boolean drawTileBack( Rect rect, int flags )
public boolean drawTileBack( Rect rect, int flags )
{
return drawTileImpl( rect, "?", -1, flags, true );
}
public void drawTrayDivider( Rect rect, int flags )
public void drawTrayDivider( Rect rect, int flags )
{
boolean isCursor = 0 != (flags & CELL_ISCURSOR);
boolean selected = 0 != (flags & CELL_HIGHLIGHT);
@ -505,11 +505,11 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
}
public void score_pendingScore( Rect rect, int score, int playerNum,
int curTurn, int flags )
public void score_pendingScore( Rect rect, int score, int playerNum,
int curTurn, int flags )
{
String text = score >= 0? String.format( "%d", score ) : "??";
int otherIndx = (0 == (flags & CELL_ISCURSOR))
int otherIndx = (0 == (flags & CELL_ISCURSOR))
? CommonPrefs.COLOR_BACKGRND : CommonPrefs.COLOR_FOCUS;
++rect.top;
fillRectOther( rect, otherIndx );
@ -524,7 +524,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
drawCentered( text, rect, null );
rect.offset( 0, rect.height() );
drawCentered( LocUtils.getString( m_context, R.string.pts ),
drawCentered( LocUtils.getString( m_context, R.string.pts ),
rect, null );
}
@ -569,7 +569,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
}
private boolean drawTileImpl( Rect rect, String text, int val,
private boolean drawTileImpl( Rect rect, String text, int val,
int flags, boolean clearBack )
{
boolean canDraw = figureFontDims();
@ -587,7 +587,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
if ( isCursor || notEmpty ) {
int color = m_otherColors[isCursor? CommonPrefs.COLOR_FOCUS
int color = m_otherColors[isCursor? CommonPrefs.COLOR_FOCUS
: CommonPrefs.COLOR_TILE_BACK];
if ( !clearBack ) {
color &= 0x7FFFFFFF; // translucent if being dragged.
@ -628,23 +628,23 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
}
private void drawCentered( String text, Rect rect, FontDims fontDims )
private void drawCentered( String text, Rect rect, FontDims fontDims )
{
drawIn( text, rect, fontDims, Paint.Align.CENTER );
}
private void drawIn( String text, Rect rect, FontDims fontDims,
Paint.Align align )
private void drawIn( String text, Rect rect, FontDims fontDims,
Paint.Align align )
{
int descent = -1;
int textSize;
if ( null == fontDims ) {
textSize = rect.height() - SCORE_HT_DROP;
} else {
int height = rect.height() - 4; // borders and padding, 2 each
int height = rect.height() - 4; // borders and padding, 2 each
descent = fontDims.descentFor( height );
textSize = fontDims.heightFor( height );
// DbgUtils.logf( "using descent: " + descent + " and textSize: "
// DbgUtils.logf( "using descent: " + descent + " and textSize: "
// + textSize + " in height " + height );
}
m_fillPaint.setTextSize( textSize );
@ -671,13 +671,13 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
} // drawCentered
private void drawScaled( String text, final Rect rect,
private void drawScaled( String text, final Rect rect,
Rect textBounds, int descent )
{
textBounds.bottom = rect.height();
Bitmap bitmap = Bitmap.createBitmap( textBounds.width(),
rect.height(),
rect.height(),
Bitmap.Config.ARGB_8888 );
Canvas canvas = new Canvas( bitmap );
@ -705,7 +705,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
if ( val >= 0 ) {
int divisor = m_hasSmallScreen ? 3 : 4;
if ( null == m_valRect ) {
m_valRect = new Rect( 0, 0, rect.width() / divisor,
m_valRect = new Rect( 0, 0, rect.width() / divisor,
rect.height() / divisor );
m_valRect.inset( offset, offset );
}
@ -714,7 +714,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
text = String.format( "%d", val );
m_fillPaint.setTextSize( m_valRect.height() );
m_fillPaint.setTextAlign( Paint.Align.RIGHT );
drawText( text, m_valRect.right, m_valRect.bottom,
drawText( text, m_valRect.right, m_valRect.bottom,
m_fillPaint );
if ( FRAME_TRAY_RECTS ) {
drawRect( m_valRect, m_strokePaint );
@ -745,7 +745,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
paint.setTextAlign( Paint.Align.LEFT );
paint.setTextSize( ht );
Bitmap bitmap = Bitmap.createBitmap( width, (ht*3)/2,
Bitmap bitmap = Bitmap.createBitmap( width, (ht*3)/2,
Bitmap.Config.ARGB_8888 );
Canvas canvas = new Canvas( bitmap );
@ -800,7 +800,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
}
}
m_fontDims = new FontDims( ht, topRow, bottomRow, maxWidth );
}
return null != m_fontDims;
@ -855,7 +855,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
}
arrow = new BitmapDrawable(bitmap);
arrow = new BitmapDrawable(bitmap);
}
return arrow;
}

View file

@ -65,7 +65,7 @@ import org.eehouse.android.xw4.jni.XwJNI.GamePtr;
public class BoardDelegate extends DelegateBase
implements TransportProcs.TPMsgHandler, View.OnClickListener,
DwnldDelegate.DownloadFinishedListener,
DwnldDelegate.DownloadFinishedListener,
ConnStatusHandler.ConnStatusCBacks,
NFCUtils.NFCActor {
@ -155,11 +155,11 @@ public class BoardDelegate extends DelegateBase
public void run() {
m_timers[m_why] = null;
if ( null != m_jniThread ) {
m_jniThread.handleBkgrnd( JNICmd.CMD_TIMER_FIRED,
m_jniThread.handleBkgrnd( JNICmd.CMD_TIMER_FIRED,
m_why, m_when, m_handle );
}
}
}
}
protected Dialog onCreateDialog( int id )
{
@ -179,7 +179,7 @@ public class BoardDelegate extends DelegateBase
.setPositiveButton( android.R.string.ok, null );
if ( DlgID.DLG_RETRY == dlgID ) {
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int whichButton ) {
handleViaThread( JNICmd.CMD_RESET );
}
@ -188,7 +188,7 @@ public class BoardDelegate extends DelegateBase
} else if ( DlgID.GAME_OVER == dlgID
&& rematchSupported( true ) ) {
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int whichButton ) {
doRematchIf();
}
@ -198,7 +198,7 @@ public class BoardDelegate extends DelegateBase
&& BuildConfig.DEBUG && null != m_connTypes
&& m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int whichButton ) {
NetStateCache.reset( m_activity );
RelayService.reset( m_activity );
@ -213,7 +213,7 @@ public class BoardDelegate extends DelegateBase
case DLG_USEDICT:
case DLG_GETDICT:
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int whichButton ) {
if ( DlgID.DLG_USEDICT == dlgID ) {
setGotGameDict( m_getDict );
@ -239,7 +239,7 @@ public class BoardDelegate extends DelegateBase
.setMessage( R.string.msg_dev_deleted )
.setPositiveButton( android.R.string.ok, null );
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int whichButton ) {
deleteAndClose();
}
@ -251,13 +251,13 @@ public class BoardDelegate extends DelegateBase
case QUERY_REQUEST_BLK:
case QUERY_INFORM_BLK:
case DLG_SCORES:
case DLG_BADWORDS_BLK:
case DLG_BADWORDS_BLK:
ab = ab.setMessage( m_dlgBytes );
if ( 0 != m_dlgTitle ) {
ab.setTitle( m_dlgTitle );
}
lstnr = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int whichButton ) {
m_resultCode = 1;
}
@ -267,7 +267,7 @@ public class BoardDelegate extends DelegateBase
lstnr );
if ( DlgID.QUERY_REQUEST_BLK == dlgID ) {
lstnr = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int whichButton ) {
m_resultCode = 0;
}
@ -278,7 +278,7 @@ public class BoardDelegate extends DelegateBase
String buttonTxt;
boolean studyOn = XWPrefs.getStudyEnabled( m_activity );
if ( m_words.length == 1 ) {
int resID = studyOn
int resID = studyOn
? R.string.button_lookup_study_fmt
: R.string.button_lookup_fmt;
buttonTxt = getString( resID, m_words[0] );
@ -288,11 +288,11 @@ public class BoardDelegate extends DelegateBase
buttonTxt = getString( resID );
}
lstnr = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int whichButton ) {
showNotAgainDlgThen( R.string.not_again_lookup,
showNotAgainDlgThen( R.string.not_again_lookup,
R.string.
key_na_lookup,
key_na_lookup,
Action.LOOKUP_ACTION );
}
};
@ -307,7 +307,7 @@ public class BoardDelegate extends DelegateBase
case PICK_TILE_REQUESTBLANK_BLK:
case PICK_TILE_REQUESTTRAY_BLK:
lstnr = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int item ) {
m_resultCode = item;
}
@ -320,17 +320,17 @@ public class BoardDelegate extends DelegateBase
ab.setTitle( getString( R.string.cur_tiles_fmt, m_curTiles ) );
if ( m_canUndoTiles ) {
OnClickListener undoClicked = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int whichButton ) {
m_resultCode = UtilCtxt.PICKER_BACKUP;
removeDialog( dlgID );
}
};
ab.setPositiveButton( R.string.tilepick_undo,
ab.setPositiveButton( R.string.tilepick_undo,
undoClicked );
}
OnClickListener doAllClicked = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int whichButton ) {
m_resultCode = UtilCtxt.PICKER_PICKALL;
removeDialog( dlgID );
@ -345,7 +345,7 @@ public class BoardDelegate extends DelegateBase
case ASK_PASSWORD_BLK:
m_dlgTitleStr = getString( R.string.msg_ask_password_fmt, m_pwdName );
LinearLayout pwdLayout =
LinearLayout pwdLayout =
(LinearLayout)inflate( R.layout.passwd_view );
m_passwdEdit = (EditText)pwdLayout.findViewById( R.id.edit );
m_passwdEdit.setText( "", TextView.BufferType.EDITABLE );
@ -353,7 +353,7 @@ public class BoardDelegate extends DelegateBase
.setView( pwdLayout )
.setPositiveButton( android.R.string.ok,
new OnClickListener() {
public void
public void
onClick( DialogInterface dlg,
int whichButton ) {
m_resultCode = 1;
@ -368,8 +368,8 @@ public class BoardDelegate extends DelegateBase
.setMessage( R.string.ids_endnow )
.setPositiveButton( R.string.button_yes,
new OnClickListener() {
public void
onClick( DialogInterface dlg,
public void
onClick( DialogInterface dlg,
int item ) {
handleViaThread(JNICmd.CMD_ENDGAME);
}
@ -379,14 +379,14 @@ public class BoardDelegate extends DelegateBase
break;
case DLG_INVITE:
lstnr = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int item ) {
if ( !m_relayMissing ||
! m_connTypes.contains(CommsConnType.COMMS_CONN_RELAY) ) {
Assert.assertTrue( 0 < m_nMissing );
if ( m_summary.hasRematchInfo() ) {
tryRematchInvites( true );
} else {
} else {
showInviteChoicesThen( Action.LAUNCH_INVITE_ACTION,
m_sentInfo );
}
@ -396,18 +396,18 @@ public class BoardDelegate extends DelegateBase
}
};
OnClickListener lstnrWait = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int item ) {
finish();
}
};
OnClickListener lstnrMore = new OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int item ) {
showOKOnlyDialog( m_sentInfo.getAsText( m_activity ) );
}
};
dialog = ab.setTitle( "foo" )
.setMessage( "" )
.setPositiveButton( "", lstnr )
@ -458,8 +458,8 @@ public class BoardDelegate extends DelegateBase
CommsConnTypeSet without = (CommsConnTypeSet)
m_connTypes.clone();
without.remove( CommsConnType.COMMS_CONN_RELAY );
message += "\n\n"
+ getString( R.string.drop_relay_warning_fmt,
message += "\n\n"
+ getString( R.string.drop_relay_warning_fmt,
without.toString( m_activity ) );
buttonTxt = R.string.newgame_drop_relay;
}
@ -473,7 +473,7 @@ public class BoardDelegate extends DelegateBase
message = getString( R.string.rematch_msg );
} else {
titleID = R.string.waiting_invite_title;
message = getQuantityString( R.plurals.invite_sent_fmt,
message = getQuantityString( R.plurals.invite_sent_fmt,
nSent, nSent, m_nMissing );
}
buttonTxt = R.string.button_reinvite;
@ -485,7 +485,7 @@ public class BoardDelegate extends DelegateBase
nukeInviteButton = true;
} else {
titleID = R.string.waiting_title;
message = getQuantityString( R.plurals.invite_msg_fmt,
message = getQuantityString( R.plurals.invite_msg_fmt,
m_nMissing, m_nMissing );
}
@ -517,7 +517,7 @@ public class BoardDelegate extends DelegateBase
}
button = ad.getButton( AlertDialog.BUTTON_NEUTRAL );
button.setVisibility( nukeNeutButton ? View.GONE : View.VISIBLE );
break;
default:
super.prepareDialog( dlgID, dialog );
@ -531,7 +531,7 @@ public class BoardDelegate extends DelegateBase
m_activity = delegator.getActivity();
}
protected void init( Bundle savedInstanceState )
protected void init( Bundle savedInstanceState )
{
getBundledData( savedInstanceState );
@ -577,7 +577,7 @@ public class BoardDelegate extends DelegateBase
break;
case JNIThread.TOOLBAR_STATES:
if ( null != m_jniThread ) {
m_gsi =
m_gsi =
m_jniThread.getGameStateInfo();
updateToolbar();
if ( m_inTrade != m_gsi.inTrade ) {
@ -590,7 +590,7 @@ public class BoardDelegate extends DelegateBase
break;
case JNIThread.GOT_WORDS:
CurGameInfo gi = m_jniThreadRef.getGI();
launchLookup( wordsToArray((String)msg.obj),
launchLookup( wordsToArray((String)msg.obj),
gi.dictLang );
break;
case JNIThread.GAME_OVER:
@ -600,7 +600,7 @@ public class BoardDelegate extends DelegateBase
break;
case JNIThread.MSGS_SENT:
int nSent = (Integer)msg.obj;
showToast( getQuantityString( R.plurals.resent_msgs_fmt,
showToast( getQuantityString( R.plurals.resent_msgs_fmt,
nSent, nSent ) );
break;
}
@ -636,7 +636,7 @@ public class BoardDelegate extends DelegateBase
super.onResume();
doResume( false );
}
protected void onPause()
{
closeIfFinishing( false );
@ -670,7 +670,7 @@ public class BoardDelegate extends DelegateBase
super.onDestroy();
}
protected void onSaveInstanceState( Bundle outState )
protected void onSaveInstanceState( Bundle outState )
{
outState.putInt( DLG_TITLE, m_dlgTitle );
outState.putString( DLG_TITLESTR, m_dlgTitleStr );
@ -809,7 +809,7 @@ public class BoardDelegate extends DelegateBase
}
@Override
public boolean onPrepareOptionsMenu( Menu menu )
public boolean onPrepareOptionsMenu( Menu menu )
{
boolean inTrade = false;
MenuItem item;
@ -829,31 +829,31 @@ public class BoardDelegate extends DelegateBase
item = menu.findItem( R.id.board_menu_tray );
item.setTitle( getString( strId ) );
Utils.setItemVisible( menu, R.id.board_menu_flip,
Utils.setItemVisible( menu, R.id.board_menu_flip,
m_gsi.visTileCount >= 1 );
Utils.setItemVisible( menu, R.id.board_menu_toggle,
Utils.setItemVisible( menu, R.id.board_menu_toggle,
m_gsi.visTileCount >= 1 );
Utils.setItemVisible( menu, R.id.board_menu_juggle,
Utils.setItemVisible( menu, R.id.board_menu_juggle,
m_gsi.canShuffle );
Utils.setItemVisible( menu, R.id.board_menu_undo_current,
Utils.setItemVisible( menu, R.id.board_menu_undo_current,
m_gsi.canRedo );
Utils.setItemVisible( menu, R.id.board_menu_hint_prev,
Utils.setItemVisible( menu, R.id.board_menu_hint_prev,
m_gsi.canHint );
Utils.setItemVisible( menu, R.id.board_menu_hint_next,
Utils.setItemVisible( menu, R.id.board_menu_hint_next,
m_gsi.canHint );
Utils.setItemVisible( menu, R.id.board_menu_chat,
Utils.setItemVisible( menu, R.id.board_menu_chat,
BuildConstants.CHAT_SUPPORTED
&& m_gsi.canChat );
Utils.setItemVisible( menu, R.id.board_menu_tray,
Utils.setItemVisible( menu, R.id.board_menu_tray,
!inTrade && m_gsi.canHideRack );
Utils.setItemVisible( menu, R.id.board_menu_trade,
Utils.setItemVisible( menu, R.id.board_menu_trade,
m_gsi.canTrade );
Utils.setItemVisible( menu, R.id.board_menu_undo_last,
Utils.setItemVisible( menu, R.id.board_menu_undo_last,
m_gsi.canUndo );
}
Utils.setItemVisible( menu, R.id.board_menu_trade_cancel, inTrade );
Utils.setItemVisible( menu, R.id.board_menu_trade_commit,
Utils.setItemVisible( menu, R.id.board_menu_trade_commit,
inTrade && m_gsi.tradeTilesSelected
&& m_gsi.curTurnSelected );
Utils.setItemVisible( menu, R.id.board_menu_game_resign, !inTrade );
@ -890,7 +890,7 @@ public class BoardDelegate extends DelegateBase
|| XWPrefs.getDebugEnabled( m_activity ) );
Utils.setItemVisible( menu, R.id.board_menu_game_netstats, enable );
Utils.setItemVisible( menu, R.id.board_menu_game_invites, enable );
enable = XWPrefs.getStudyEnabled( m_activity );
Utils.setItemVisible( menu, R.id.games_menu_study, enable );
@ -898,7 +898,7 @@ public class BoardDelegate extends DelegateBase
} // onPrepareOptionsMenu
@Override
public boolean onOptionsItemSelected( MenuItem item )
public boolean onOptionsItemSelected( MenuItem item )
{
boolean handled = true;
JNICmd cmd = JNICmd.CMD_NONE;
@ -907,11 +907,11 @@ public class BoardDelegate extends DelegateBase
int id = item.getItemId();
switch ( id ) {
case R.id.board_menu_done:
int nTiles = XwJNI.model_getNumTilesInTray( m_jniGamePtr,
int nTiles = XwJNI.model_getNumTilesInTray( m_jniGamePtr,
m_view.getCurPlayer() );
if ( XWApp.MAX_TRAY_TILES > nTiles ) {
showNotAgainDlgThen( R.string.not_again_done,
R.string.key_notagain_done,
showNotAgainDlgThen( R.string.not_again_done,
R.string.key_notagain_done,
Action.COMMIT_ACTION );
} else {
dlgButtonClicked( Action.COMMIT_ACTION, AlertDialog.BUTTON_POSITIVE, null );
@ -987,7 +987,7 @@ public class BoardDelegate extends DelegateBase
break;
case R.id.board_menu_game_counts:
handleViaThread( JNICmd.CMD_COUNTS_VALUES,
handleViaThread( JNICmd.CMD_COUNTS_VALUES,
R.string.counts_values_title );
break;
case R.id.board_menu_game_left:
@ -1077,7 +1077,7 @@ public class BoardDelegate extends DelegateBase
String curDict = m_gi.dictName( m_view.getCurPlayer() );
View button = m_toolbar.getViewFor( Toolbar.BUTTON_BROWSE_DICT );
if ( Action.BUTTON_BROWSEALL_ACTION == action &&
DictsDelegate.handleDictsPopup( getDelegator(), button,
DictsDelegate.handleDictsPopup( getDelegator(), button,
curDict, m_gi.dictLang ) ){
break;
}
@ -1133,7 +1133,7 @@ public class BoardDelegate extends DelegateBase
}
} );
break;
default:
handled = false;
}
@ -1148,7 +1148,7 @@ public class BoardDelegate extends DelegateBase
}
} // dlgButtonClicked
public void inviteChoiceMade( Action action, InviteMeans means,
public void inviteChoiceMade( Action action, InviteMeans means,
Object[] params )
{
if ( action == Action.LAUNCH_INVITE_ACTION ) {
@ -1173,7 +1173,7 @@ public class BoardDelegate extends DelegateBase
RequestCode.SMS_INVITE_RESULT );
break;
case RELAY:
RelayInviteDelegate.launchForResult( m_activity, m_nMissing,
RelayInviteDelegate.launchForResult( m_activity, m_nMissing,
RequestCode.RELAY_INVITE_RESULT );
break;
case EMAIL:
@ -1201,7 +1201,7 @@ public class BoardDelegate extends DelegateBase
// View.OnClickListener interface
//////////////////////////////////////////////////
@Override
public void onClick( View view )
public void onClick( View view )
{
if ( view == m_exchCommmitButton ) {
handleViaThread( JNICmd.CMD_COMMIT );
@ -1221,7 +1221,7 @@ public class BoardDelegate extends DelegateBase
case MESSAGE_ACCEPTED:
case MESSAGE_REFUSED:
ConnStatusHandler.
updateStatusIn( m_activity, this, CommsConnType.COMMS_CONN_BT,
updateStatusIn( m_activity, this, CommsConnType.COMMS_CONN_BT,
MultiService.MultiEvent.MESSAGE_ACCEPTED == event);
break;
case MESSAGE_NOGAME:
@ -1249,7 +1249,7 @@ public class BoardDelegate extends DelegateBase
m_progressShown = false;
stopProgress(); // in case it's a BT invite
}
final String msg =
final String msg =
getString( R.string.err_dup_invite_fmt, (String)args[0] );
post( new Runnable() {
public void run() {
@ -1268,7 +1268,7 @@ public class BoardDelegate extends DelegateBase
case SMS_SEND_FAILED_NORADIO:
// if ( null != m_jniThread ) {
// boolean accepted =
// boolean accepted =
// MultiService.MultiEvent.SMS_RECEIVE_OK == event
// || MultiService.MultiEvent.SMS_SEND_OK == event;
// m_jniThread.handle( JNICmd.CMD_DRAW_SMS_STATUS, accepted );
@ -1358,7 +1358,7 @@ public class BoardDelegate extends DelegateBase
//////////////////////////////////////////////////
// DwnldActivity.DownloadFinishedListener interface
//////////////////////////////////////////////////
public void downloadFinished( String lang, final String name,
public void downloadFinished( String lang, final String name,
boolean success )
{
if ( success ) {
@ -1366,7 +1366,7 @@ public class BoardDelegate extends DelegateBase
public void run() {
setGotGameDict( name );
}
} );
} );
}
}
@ -1453,7 +1453,7 @@ public class BoardDelegate extends DelegateBase
private void askNoAddrsDelete()
{
showConfirmThen( R.string.connstat_net_noaddr,
showConfirmThen( R.string.connstat_net_noaddr,
R.string.list_item_delete,
Action.DELETE_AND_EXIT );
}
@ -1508,10 +1508,10 @@ public class BoardDelegate extends DelegateBase
case KeyEvent.KEYCODE_DPAD_RIGHT:
xpKey = XwJNI.XP_Key.XP_CURSOR_KEY_RIGHT;
break;
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_UP:
xpKey = XwJNI.XP_Key.XP_CURSOR_KEY_UP;
break;
case KeyEvent.KEYCODE_SPACE:
case KeyEvent.KEYCODE_SPACE:
xpKey = XwJNI.XP_Key.XP_RAISEFOCUS_KEY;
break;
}
@ -1615,7 +1615,7 @@ public class BoardDelegate extends DelegateBase
if ( null != toastStr ) {
m_toastStr = toastStr;
if ( naMsg == 0 ) {
dlgButtonClicked( Action.SHOW_EXPL_ACTION,
dlgButtonClicked( Action.SHOW_EXPL_ACTION,
AlertDialog.BUTTON_POSITIVE, null );
} else {
showNotAgainDlgThen( naMsg, naKey, Action.SHOW_EXPL_ACTION );
@ -1633,7 +1633,7 @@ public class BoardDelegate extends DelegateBase
}
@Override
public void requestTime()
public void requestTime()
{
runOnUiThread( new Runnable() {
public void run() {
@ -1645,7 +1645,7 @@ public class BoardDelegate extends DelegateBase
}
@Override
public void remSelected()
public void remSelected()
{
handleViaThread( JNICmd.CMD_REMAINING, R.string.tiles_left_title );
}
@ -1745,7 +1745,7 @@ public class BoardDelegate extends DelegateBase
}
@Override
public void clearTimer( int why )
public void clearTimer( int why )
{
if ( null != m_timers[why] ) {
removeCallbacks( m_timers[why] );
@ -1763,13 +1763,13 @@ public class BoardDelegate extends DelegateBase
}
@Override
public int userPickTileTray( int playerNum, String[] texts,
public int userPickTileTray( int playerNum, String[] texts,
String[] curTiles, int nPicked )
{
m_texts = texts;
m_curTiles = TextUtils.join( ", ", curTiles );
m_canUndoTiles = 0 < nPicked;
waitBlockingDialog( DlgID.PICK_TILE_REQUESTTRAY_BLK,
waitBlockingDialog( DlgID.PICK_TILE_REQUESTTRAY_BLK,
UtilCtxt.PICKER_PICKALL );
return m_resultCode;
}
@ -1795,7 +1795,7 @@ public class BoardDelegate extends DelegateBase
m_nMissing = 0;
post( new Runnable() {
public void run() {
showNotAgainDlg( R.string.not_again_turnchanged,
showNotAgainDlg( R.string.not_again_turnchanged,
R.string.key_notagain_turnchanged );
}
} );
@ -1844,7 +1844,7 @@ public class BoardDelegate extends DelegateBase
public boolean confirmTrade( String[] tiles )
{
m_dlgTitle = R.string.info_title;
m_dlgBytes =
m_dlgBytes =
getQuantityString( R.plurals.query_trade_fmt, tiles.length,
tiles.length, TextUtils.join( ", ", tiles ));
return 0 != waitBlockingDialog( DlgID.QUERY_REQUEST_BLK, 0 );
@ -1928,7 +1928,7 @@ public class BoardDelegate extends DelegateBase
{
m_connTypes = connTypes;
Assert.assertTrue( isServer || 0 == nMissing );
// DbgUtils.logf( "BoardDelegate.informMissing(isServer=%b, nDevs=%d, nMissing=%d)",
// DbgUtils.logf( "BoardDelegate.informMissing(isServer=%b, nDevs=%d, nMissing=%d)",
// isServer, nDevs, nMissing );
m_nGuestDevs = nDevs;
@ -1961,7 +1961,7 @@ public class BoardDelegate extends DelegateBase
GameUtils.BackMoveResult bmr = new GameUtils.BackMoveResult();
bmr.m_lmi = lmi;
boolean[] locals = m_gi.playersLocal();
GameUtils.postMoveNotification( m_activity, m_rowid,
GameUtils.postMoveNotification( m_activity, m_rowid,
bmr, locals[turn] );
}
}
@ -1969,13 +1969,13 @@ public class BoardDelegate extends DelegateBase
@Override
public void informUndo()
{
nonBlockingDialog( DlgID.DLG_OKONLY,
nonBlockingDialog( DlgID.DLG_OKONLY,
getString( R.string.remote_undone ) );
}
@Override
public void informNetDict( int code, String oldName,
String newName, String newSum,
public void informNetDict( int code, String oldName,
String newName, String newSum,
CurGameInfo.XWPhoniesChoice phonies )
{
// If it's same dict and same sum, we're good. That
@ -1997,7 +1997,7 @@ public class BoardDelegate extends DelegateBase
DlgID dlgID;
msg = getString( R.string.inform_dict_diffdict_fmt,
oldName, newName, newName );
if ( DictLangCache.haveDict( m_activity, code,
if ( DictLangCache.haveDict( m_activity, code,
newName ) ) {
dlgID = DlgID.DLG_USEDICT;
} else {
@ -2022,13 +2022,13 @@ public class BoardDelegate extends DelegateBase
// m_view.setVerticalScrollBarEnabled( maxOffset > 0 );
// }
@Override
public boolean warnIllegalWord( String dict, String[] words, int turn,
public boolean warnIllegalWord( String dict, String[] words, int turn,
boolean turnLost )
{
boolean accept = turnLost;
String wordsString = TextUtils.join( ", ", words );
String message =
String message =
getString( R.string.ids_badwords_fmt, wordsString, dict );
if ( turnLost ) {
@ -2057,7 +2057,7 @@ public class BoardDelegate extends DelegateBase
public void run() {
DBUtils.appendChatHistory( m_activity, m_rowid, msg,
fromIndx );
if ( ! ChatDelegate.append( m_rowid, msg,
if ( ! ChatDelegate.append( m_rowid, msg,
fromIndx ) ) {
startChatActivity();
}
@ -2065,7 +2065,7 @@ public class BoardDelegate extends DelegateBase
} );
}
}
} // class BoardUtilCtxt
} // class BoardUtilCtxt
private void doResume( boolean isStart )
{
@ -2151,7 +2151,7 @@ public class BoardDelegate extends DelegateBase
case COMMS_CONN_SMS:
break;
default:
DbgUtils.logf( "tickle: unexpected type %s",
DbgUtils.logf( "tickle: unexpected type %s",
typ.toString() );
Assert.fail();
}
@ -2171,7 +2171,7 @@ public class BoardDelegate extends DelegateBase
}
if ( 0 == nMissing || !m_relayMissing ) {
dismissDialog( DlgID.DLG_INVITE );
}
}
}
} );
}
@ -2201,7 +2201,7 @@ public class BoardDelegate extends DelegateBase
R.string.not_again_browse,
R.string.key_na_browse,
Action.BUTTON_BROWSE_ACTION );
m_toolbar.setListener( Toolbar.BUTTON_HINT_PREV,
m_toolbar.setListener( Toolbar.BUTTON_HINT_PREV,
R.string.not_again_hintprev,
R.string.key_notagain_hintprev,
Action.PREV_HINT_ACTION );
@ -2231,7 +2231,7 @@ public class BoardDelegate extends DelegateBase
Action.UNDO_ACTION );
if ( BuildConstants.CHAT_SUPPORTED ) {
m_toolbar.setListener( Toolbar.BUTTON_CHAT,
R.string.not_again_chat,
R.string.not_again_chat,
R.string.key_notagain_chat,
Action.CHAT_ACTION );
}
@ -2287,7 +2287,7 @@ public class BoardDelegate extends DelegateBase
return result;
}
private void nonBlockingDialog( final DlgID dlgID, String txt )
private void nonBlockingDialog( final DlgID dlgID, String txt )
{
switch ( dlgID ) {
case DLG_OKONLY:
@ -2359,7 +2359,7 @@ public class BoardDelegate extends DelegateBase
if ( XWPrefs.getThumbEnabled( m_activity ) ) {
// Before we dispose, and after JNIThread has
// relinquished interest, redraw on smaller scale.
Bitmap thumb =
Bitmap thumb =
GameUtils.takeSnapshot( m_activity, m_jniGamePtr, m_gi );
DBUtils.saveThumbnail( m_activity, m_gameLock, thumb );
}
@ -2367,7 +2367,7 @@ public class BoardDelegate extends DelegateBase
m_gameLock = null;
}
}
private void waitCloseGame( boolean save )
{
pauseGame();
@ -2384,7 +2384,7 @@ public class BoardDelegate extends DelegateBase
{
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_SMS ) ) {
if ( XWApp.SMSSUPPORTED && !XWPrefs.getSMSEnabled( m_activity ) ) {
showConfirmThen( R.string.warn_sms_disabled,
showConfirmThen( R.string.warn_sms_disabled,
R.string.button_enable_sms,
R.string.button_later,
Action.ENABLE_SMS_ASK );
@ -2401,7 +2401,7 @@ public class BoardDelegate extends DelegateBase
}
}
}
private void trySendChats()
{
if ( BuildConstants.CHAT_SUPPORTED && null != m_jniThread ) {
@ -2426,7 +2426,7 @@ public class BoardDelegate extends DelegateBase
int nPlayers = m_missingCounts[ii];
Assert.assertTrue( 0 <= m_nGuestDevs );
int forceChannel = ii + m_nGuestDevs + 1;
NetLaunchInfo nli = new NetLaunchInfo( m_summary, m_gi,
NetLaunchInfo nli = new NetLaunchInfo( m_summary, m_gi,
nPlayers, forceChannel );
if ( m_relayMissing ) {
nli.removeAddress( CommsConnType.COMMS_CONN_RELAY );
@ -2455,7 +2455,7 @@ public class BoardDelegate extends DelegateBase
case RELAY:
try {
int destDevID = Integer.parseInt( dev ); // failing
RelayService.inviteRemote( m_activity, destDevID,
RelayService.inviteRemote( m_activity, destDevID,
null, nli );
} catch (NumberFormatException nfi) {
DbgUtils.loge( nfi );
@ -2482,9 +2482,9 @@ public class BoardDelegate extends DelegateBase
m_toolbar.update( Toolbar.BUTTON_UNDO, m_gsi.canRedo );
m_toolbar.update( Toolbar.BUTTON_HINT_PREV, m_gsi.canHint );
m_toolbar.update( Toolbar.BUTTON_HINT_NEXT, m_gsi.canHint );
m_toolbar.update( Toolbar.BUTTON_CHAT,
m_toolbar.update( Toolbar.BUTTON_CHAT,
BuildConstants.CHAT_SUPPORTED && m_gsi.canChat );
m_toolbar.update( Toolbar.BUTTON_BROWSE_DICT,
m_toolbar.update( Toolbar.BUTTON_BROWSE_DICT,
null != m_gi.dictName( m_view.getCurPlayer() ) );
}
}
@ -2560,7 +2560,7 @@ public class BoardDelegate extends DelegateBase
if ( null != m_handler ) {
m_handler.removeCallbacks( which );
} else {
DbgUtils.logf( "removeCallbacks: dropping %h because handler null",
DbgUtils.logf( "removeCallbacks: dropping %h because handler null",
which );
}
}
@ -2588,7 +2588,7 @@ public class BoardDelegate extends DelegateBase
return null != summary && rematchSupported( null, summary );
}
private static boolean rematchSupported( Context context,
private static boolean rematchSupported( Context context,
GameSummary summary )
{
boolean supported = false;
@ -2607,8 +2607,8 @@ public class BoardDelegate extends DelegateBase
} else if ( null != context ) {
// show the button if people haven't dismissed the hint yet
supported = ! XWPrefs
.getPrefsBoolean( context,
R.string.key_na_rematch_two_only,
.getPrefsBoolean( context,
R.string.key_na_rematch_two_only,
false );
}
}
@ -2618,14 +2618,14 @@ public class BoardDelegate extends DelegateBase
private void doRematchIf()
{
if ( doRematchIf( m_activity, this, m_rowid, m_summary, m_gi,
if ( doRematchIf( m_activity, this, m_rowid, m_summary, m_gi,
m_jniGamePtr ) ) {
finish();
}
}
private static boolean doRematchIf( Activity activity, DelegateBase dlgt,
long rowid, GameSummary summary,
private static boolean doRematchIf( Activity activity, DelegateBase dlgt,
long rowid, GameSummary summary,
CurGameInfo gi, GamePtr jniGamePtr )
{
boolean success = false;
@ -2639,7 +2639,7 @@ public class BoardDelegate extends DelegateBase
} else if ( 2 != gi.nPlayers ) {
Assert.assertNotNull( dlgt );
if ( null != dlgt ) {
dlgt.showNotAgainDlg( R.string.not_again_rematch_two_only,
dlgt.showNotAgainDlg( R.string.not_again_rematch_two_only,
R.string.key_na_rematch_two_only );
}
doIt = false;
@ -2650,7 +2650,7 @@ public class BoardDelegate extends DelegateBase
if ( addr.contains( CommsConnType.COMMS_CONN_BT ) ) {
Assert.assertNull( btAddr );
btAddr = addr.bt_btAddr;
}
}
if ( addr.contains( CommsConnType.COMMS_CONN_SMS ) ) {
Assert.assertNull( phone );
phone = addr.sms_phone;
@ -2666,7 +2666,7 @@ public class BoardDelegate extends DelegateBase
CommsConnTypeSet connTypes = summary.conTypes;
String newName = summary.getRematchName();
Intent intent = GamesListDelegate
.makeRematchIntent( activity, rowid, gi, connTypes, btAddr,
.makeRematchIntent( activity, rowid, gi, connTypes, btAddr,
phone, relayID, newName );
if ( null != intent ) {
activity.startActivity( intent );
@ -2708,7 +2708,7 @@ public class BoardDelegate extends DelegateBase
// only supports a single invite for now!
int numHere = 1;
int forceChannel = 1;
NetLaunchInfo nli = new NetLaunchInfo( m_summary, m_gi, numHere,
NetLaunchInfo nli = new NetLaunchInfo( m_summary, m_gi, numHere,
forceChannel );
String value;
@ -2748,7 +2748,7 @@ public class BoardDelegate extends DelegateBase
private void retrySMSInvites( Object[] params )
{
if ( null != params && 2 == params.length
if ( null != params && 2 == params.length
&& params[0] instanceof NetLaunchInfo
&& params[1] instanceof String ) {
sendSMSInviteIf( (String)params[1], (NetLaunchInfo)params[0],
@ -2757,7 +2757,7 @@ public class BoardDelegate extends DelegateBase
DbgUtils.logf( "retrySMSInvites: tests failed" );
}
}
private void recordInviteSent( InviteMeans means, String dev )
{
DBUtils.recordInviteSent( m_activity, m_rowid, means, dev );

View file

@ -69,7 +69,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
// called when inflating xml
public BoardView( Context context, AttributeSet attrs )
public BoardView( Context context, AttributeSet attrs )
{
super( context, attrs );
@ -86,14 +86,14 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
}
@Override
public boolean onTouchEvent( MotionEvent event )
public boolean onTouchEvent( MotionEvent event )
{
boolean wantMore = null != m_jniThread;
if ( wantMore ) {
int action = event.getAction();
int xx = (int)event.getX();
int yy = (int)event.getY();
switch ( action ) {
case MotionEvent.ACTION_DOWN:
m_lastSpacing = MULTI_INACTIVE;
@ -108,7 +108,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
} else {
int zoomBy = figureZoom( event );
if ( 0 != zoomBy ) {
handle( JNIThread.JNICmd.CMD_ZOOM,
handle( JNIThread.JNICmd.CMD_ZOOM,
zoomBy < 0 ? -2 : 2 );
}
}
@ -140,7 +140,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
@Override
protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec )
{
// DbgUtils.logf( "onMeasure(width: %s, height: %s)",
// DbgUtils.logf( "onMeasure(width: %s, height: %s)",
// MeasureSpec.toString( widthMeasureSpec ),
// MeasureSpec.toString( heightMeasureSpec ) );
@ -189,12 +189,12 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
// This will be called from the UI thread
@Override
protected void onDraw( Canvas canvas )
protected void onDraw( Canvas canvas )
{
synchronized( this ) {
if ( layoutBoardOnce() && m_measuredFromDims ) {
canvas.drawBitmap( s_bitmap, 0, 0, new Paint() );
ConnStatusHandler.draw( m_context, canvas, getResources(),
ConnStatusHandler.draw( m_context, canvas, getResources(),
m_connTypes, m_isSolo );
} else {
DbgUtils.logdf( "BoardView.onDraw(): board not laid out yet" );
@ -202,7 +202,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
}
}
private boolean layoutBoardOnce()
private boolean layoutBoardOnce()
{
final int width = getWidth();
final int height = getHeight();
@ -225,10 +225,10 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
String timerTxt = "-00:00";
paint.getTextBounds( timerTxt, 0, timerTxt.length(), scratch );
int timerWidth = scratch.width();
int fontWidth =
int fontWidth =
Math.min(m_defaultFontHt, timerWidth / timerTxt.length());
DbgUtils.logdf( "layoutBoardOnce(): posting JNICmd.CMD_LAYOUT(w=%d, h=%d)", width, height );
handle( JNIThread.JNICmd.CMD_LAYOUT, width, height,
handle( JNIThread.JNICmd.CMD_LAYOUT, width, height,
fontWidth, m_defaultFontHt );
// We'll be back....
} else {
@ -253,7 +253,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
s_bitmap.eraseColor( 0 );
}
if ( null == m_canvas ) {
m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread,
m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread,
m_dims );
} else {
m_canvas.setJNIThread( m_jniThread );
@ -276,8 +276,8 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
}
// BoardHandler interface implementation
public void startHandling( Activity parent, JNIThread thread,
CommsConnTypeSet connTypes )
public void startHandling( Activity parent, JNIThread thread,
CommsConnTypeSet connTypes )
{
DbgUtils.logdf( "BoardView.startHandling(thread=%H)", thread );
m_parent = parent;
@ -347,7 +347,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
requestLayout();
}
public void setInTrade( boolean inTrade )
public void setInTrade( boolean inTrade )
{
if ( null != m_canvas ) {
m_canvas.setInTrade( inTrade );
@ -359,12 +359,12 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
return null == m_canvas? -1 : m_canvas.getCurPlayer();
}
public int curPending()
public int curPending()
{
return null == m_canvas? 0 : m_canvas.curPending();
}
private int getSpacing( MotionEvent event )
private int getSpacing( MotionEvent event )
{
int result;
if ( 1 == event.getPointerCount() ) {

View file

@ -25,7 +25,7 @@ import android.os.Bundle;
public class ChatActivity extends XWActivity {
@Override
public void onCreate( Bundle savedInstanceState )
public void onCreate( Bundle savedInstanceState )
{
if ( BuildConstants.CHAT_SUPPORTED ) {
ChatDelegate dlgt = new ChatDelegate( this, savedInstanceState );

View file

@ -47,7 +47,7 @@ public class ChatDelegate extends DelegateBase {
private static final String INTENT_KEY_PLAYER = "intent_key_player";
private static final String INTENT_KEY_NAMES = "intent_key_names";
private static final String INTENT_KEY_LOCS = "intent_key_locs";
private static ChatDelegate s_visibleThis;
private long m_rowid;
private int m_curPlayer;
@ -110,7 +110,7 @@ public class ChatDelegate extends DelegateBase {
}
} );
}
DBUtils.HistoryPair[] pairs
= DBUtils.getChatHistory( m_activity, m_rowid, locals );
if ( null != pairs ) {
@ -125,7 +125,7 @@ public class ChatDelegate extends DelegateBase {
} // init
@Override
protected void onResume()
protected void onResume()
{
super.onResume();
m_jniThreadRef = JNIThread.getRetained( m_rowid );
@ -135,7 +135,7 @@ public class ChatDelegate extends DelegateBase {
} else {
s_visibleThis = this;
int[] startAndEnd = new int[2];
String curMsg = DBUtils.getCurChat( m_activity, m_rowid,
String curMsg = DBUtils.getCurChat( m_activity, m_rowid,
m_curPlayer, startAndEnd );
if ( null != curMsg && 0 < curMsg.length() ) {
m_edit.setText( curMsg );
@ -169,7 +169,7 @@ public class ChatDelegate extends DelegateBase {
TextView view = (TextView)row.findViewById( R.id.chat_row_text );
view.setText( msg );
view = (TextView)row.findViewById( R.id.chat_row_name );
view.setText( getString( R.string.chat_sender_fmt,
view.setText( getString( R.string.chat_sender_fmt,
m_names[playerIndx] ) );
m_layout.addView( row );
@ -210,7 +210,7 @@ public class ChatDelegate extends DelegateBase {
}
@Override
public boolean onOptionsItemSelected( MenuItem item )
public boolean onOptionsItemSelected( MenuItem item )
{
boolean handled = true;
switch ( item.getItemId() ) {
@ -236,7 +236,7 @@ public class ChatDelegate extends DelegateBase {
case CLEAR_ACTION:
if ( AlertDialog.BUTTON_POSITIVE == which ) {
DBUtils.clearChatHistory( m_activity, m_rowid );
TableLayout layout =
TableLayout layout =
(TableLayout)findViewById( R.id.chat_history );
layout.removeAllViews();
}
@ -257,9 +257,9 @@ public class ChatDelegate extends DelegateBase {
return handled;
}
public static void startForResult( Delegator delegator,
public static void startForResult( Delegator delegator,
RequestCode requestCode,
long rowID, int curPlayer,
long rowID, int curPlayer,
String[] names, boolean[] locs )
{
Assert.assertFalse( -1 == curPlayer );

View file

@ -38,7 +38,7 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
import org.eehouse.android.xw4.jni.JNIThread.*;
public class CommsTransport implements TransportProcs,
public class CommsTransport implements TransportProcs,
NetStateCache.StateChangedIf {
private Selector m_selector;
private SocketChannel m_socketChannel;
@ -80,7 +80,7 @@ public class CommsTransport implements TransportProcs,
if ( !XWApp.UDP_ENABLED ) {
m_done = false;
boolean failed = true;
try {
try {
if ( XWApp.onEmulator() ) {
System.setProperty("java.net.preferIPv6Addresses", "false");
}
@ -94,13 +94,13 @@ public class CommsTransport implements TransportProcs,
DbgUtils.loge( ioe );
} catch ( UnresolvedAddressException uae ) {
DbgUtils.logf( "bad address: name: %s; port: %s; exception: %s",
m_useHost, m_relayAddr.ip_relay_port,
m_useHost, m_relayAddr.ip_relay_port,
uae.toString() );
}
m_thread = null;
if ( failed ) {
m_jniThread.handle( JNICmd.CMD_TRANSFAIL,
m_jniThread.handle( JNICmd.CMD_TRANSFAIL,
CommsConnType.COMMS_CONN_RELAY );
}
}
@ -121,10 +121,10 @@ public class CommsTransport implements TransportProcs,
try {
m_socketChannel = SocketChannel.open();
m_socketChannel.configureBlocking( false );
DbgUtils.logf( "connecting to %s:%d",
m_useHost,
DbgUtils.logf( "connecting to %s:%d",
m_useHost,
m_relayAddr.ip_relay_port );
InetSocketAddress isa = new
InetSocketAddress isa = new
InetSocketAddress(m_useHost,
m_relayAddr.ip_relay_port );
m_socketChannel.connect( isa );
@ -163,10 +163,10 @@ public class CommsTransport implements TransportProcs,
SelectionKey key = iter.next();
SocketChannel channel = (SocketChannel)key.channel();
iter.remove();
try {
try {
if (key.isValid() && key.isConnectable()) {
if ( !channel.finishConnect() ) {
key.cancel();
key.cancel();
}
}
if (key.isValid() && key.isReadable()) {
@ -181,7 +181,7 @@ public class CommsTransport implements TransportProcs,
}
ConnStatusHandler.
updateStatusIn( m_context, null,
CommsConnType.COMMS_CONN_RELAY,
CommsConnType.COMMS_CONN_RELAY,
0 <= nRead );
}
if (key.isValid() && key.isWritable()) {
@ -196,7 +196,7 @@ public class CommsTransport implements TransportProcs,
}
} catch ( java.io.IOException ioe ) {
DbgUtils.logf( "%s: cancelling key", ioe.toString() );
key.cancel();
key.cancel();
failed = true;
break outer_loop;
} catch ( java.nio.channels.
@ -210,7 +210,7 @@ public class CommsTransport implements TransportProcs,
return failed;
} // loop
}
public void setReceiver( JNIThread jnit )
{
m_jniThread = jnit;
@ -229,7 +229,7 @@ public class CommsTransport implements TransportProcs,
{
if ( !nowAvailable ) {
waitToStopImpl();
m_jniThread.handle( JNICmd.CMD_TRANSFAIL,
m_jniThread.handle( JNICmd.CMD_TRANSFAIL,
CommsConnType.COMMS_CONN_RELAY );
}
}
@ -295,7 +295,7 @@ public class CommsTransport implements TransportProcs,
{
if ( !XWApp.UDP_ENABLED ) {
m_bytesIn.flip();
for ( ; ; ) {
int len = m_bytesIn.remaining();
if ( len <= 0 ) {
@ -306,7 +306,7 @@ public class CommsTransport implements TransportProcs,
Assert.assertTrue( len > 1 ); // tell me if I see this case
if ( len == 1 ) { // half a length byte...
break; // can I leave it in the buffer?
} else {
} else {
m_packetIn = new byte[m_bytesIn.getShort()];
m_haveLen = 0;
}
@ -349,16 +349,16 @@ public class CommsTransport implements TransportProcs,
public int getFlags() { return COMMS_XPORT_FLAGS_NONE; }
public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
CommsConnType conType, int gameID )
{
DbgUtils.logdf( "CommsTransport.transportSend(len=%d, typ=%s)",
DbgUtils.logdf( "CommsTransport.transportSend(len=%d, typ=%s)",
buf.length, conType.toString() );
int nSent = -1;
Assert.assertNotNull( addr );
Assert.assertTrue( addr.contains( conType ) );
if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY
if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY
&& null == m_relayAddr ) {
m_relayAddr = new CommsAddrRec( addr );
m_useHost = NetUtils.forceHost( m_relayAddr.ip_relay_hostName );
@ -374,7 +374,7 @@ public class CommsTransport implements TransportProcs,
nSent = buf.length;
}
} else {
nSent = sendForAddr( m_context, addr, conType, m_rowid,
nSent = sendForAddr( m_context, addr, conType, m_rowid,
gameID, buf );
}
@ -388,30 +388,30 @@ public class CommsTransport implements TransportProcs,
public void relayStatus( CommsRelayState newState )
{
DbgUtils.logf( "relayStatus called; state=%s", newState.toString() );
switch( newState ) {
case COMMS_RELAYSTATE_UNCONNECTED:
case COMMS_RELAYSTATE_DENIED:
case COMMS_RELAYSTATE_CONNECT_PENDING:
ConnStatusHandler.updateStatus( m_context, null,
CommsConnType.COMMS_CONN_RELAY,
CommsConnType.COMMS_CONN_RELAY,
false );
break;
case COMMS_RELAYSTATE_CONNECTED:
case COMMS_RELAYSTATE_RECONNECTED:
case COMMS_RELAYSTATE_CONNECTED:
case COMMS_RELAYSTATE_RECONNECTED:
ConnStatusHandler.updateStatusOut( m_context, null,
CommsConnType.COMMS_CONN_RELAY,
CommsConnType.COMMS_CONN_RELAY,
true );
break;
case COMMS_RELAYSTATE_ALLCONNECTED:
ConnStatusHandler.updateStatusIn( m_context, null,
CommsConnType.COMMS_CONN_RELAY,
CommsConnType.COMMS_CONN_RELAY,
true );
break;
}
}
public void relayConnd( String room, int devOrder, boolean allHere,
public void relayConnd( String room, int devOrder, boolean allHere,
int nMissing )
{
m_tpHandler.tpmRelayConnd( room, devOrder, allHere, nMissing );
@ -428,8 +428,8 @@ public class CommsTransport implements TransportProcs,
return false;
}
private static int sendForAddr( Context context, CommsAddrRec addr,
CommsConnType conType, long rowID,
private static int sendForAddr( Context context, CommsAddrRec addr,
CommsConnType conType, long rowID,
int gameID, byte[] buf )
{
int nSent = -1;
@ -439,7 +439,7 @@ public class CommsTransport implements TransportProcs,
nSent = RelayService.sendPacket( context, rowID, buf );
break;
case COMMS_CONN_SMS:
nSent = SMSService.sendPacket( context, addr.sms_phone,
nSent = SMSService.sendPacket( context, addr.sms_phone,
gameID, buf );
break;
case COMMS_CONN_BT:

View file

@ -101,7 +101,7 @@ public class ConnStatusHandler {
return format( context, m_time );
}
public void update( boolean success )
public void update( boolean success )
{
long now = System.currentTimeMillis();
if ( success ) {
@ -112,19 +112,19 @@ public class ConnStatusHandler {
successNewer = success;
}
private String format( Context context, Time time )
private String format( Context context, Time time )
{
CharSequence seq =
DateUtils.getRelativeDateTimeString( context,
CharSequence seq =
DateUtils.getRelativeDateTimeString( context,
time.toMillis(true),
DateUtils.SECOND_IN_MILLIS,
DateUtils.WEEK_IN_MILLIS,
DateUtils.WEEK_IN_MILLIS,
0 );
return seq.toString();
}
// called during deserialization
private void readObject( ObjectInputStream in )
private void readObject( ObjectInputStream in )
throws java.io.IOException, java.lang.ClassNotFoundException
{
in.defaultReadObject();
@ -134,7 +134,7 @@ public class ConnStatusHandler {
private ConnStatusHandler() {}
private static HashMap<CommsConnType,SuccessRecord[]> s_records =
private static HashMap<CommsConnType,SuccessRecord[]> s_records =
new HashMap<CommsConnType,SuccessRecord[]>();
private static Class s_lockObj = ConnStatusHandler.class;
private static boolean s_needsSave = false;
@ -184,20 +184,20 @@ public class ConnStatusHandler {
StringBuffer sb = new StringBuffer();
String tmp;
synchronized( s_lockObj ) {
sb.append( LocUtils.getString( context,
sb.append( LocUtils.getString( context,
R.string.connstat_net_fmt,
connTypes.toString( context )));
for ( CommsConnType typ : connTypes.getTypes() ) {
String did = "";
if ( BuildConfig.DEBUG
&& CommsConnType.COMMS_CONN_RELAY == typ ) {
did = String.format( "(DevID: %d) ",
did = String.format( "(DevID: %d) ",
DevID.getRelayDevIDInt(context) );
}
sb.append( String.format( "\n\n*** %s %s***\n",
sb.append( String.format( "\n\n*** %s %s***\n",
typ.longName( context ), did ) );
SuccessRecord record = recordFor( typ, false );
tmp = LocUtils.getString( context, record.successNewer?
tmp = LocUtils.getString( context, record.successNewer?
R.string.connstat_succ :
R.string.connstat_unsucc );
sb.append( LocUtils
@ -215,14 +215,14 @@ public class ConnStatusHandler {
}
}
if ( 0 != fmtId ) {
sb.append( LocUtils.getString( context, fmtId,
sb.append( LocUtils.getString( context, fmtId,
record.olderStr( context )));
}
sb.append( "\n\n" );
record = recordFor( typ, true );
if ( record.haveSuccess() ) {
sb.append( LocUtils.getString( context,
sb.append( LocUtils.getString( context,
R.string.connstat_lastreceipt_fmt,
record.newerStr( context ) ) );
} else {
@ -300,7 +300,7 @@ public class ConnStatusHandler {
showSuccessOut( s_cbacks );
}
public static void draw( Context context, Canvas canvas, Resources res,
public static void draw( Context context, Canvas canvas, Resources res,
CommsConnTypeSet connTypes, boolean isSolo )
{
if ( !isSolo && null != s_rect ) {
@ -347,8 +347,8 @@ public class ConnStatusHandler {
}
}
private static void drawQuarter( Canvas canvas, Resources res, Rect rect,
CommsConnTypeSet connTypes,
private static void drawQuarter( Canvas canvas, Resources res, Rect rect,
CommsConnTypeSet connTypes,
boolean enabled, boolean isIn )
{
enabled = enabled && null != newestSuccess( connTypes, isIn );
@ -358,10 +358,10 @@ public class ConnStatusHandler {
int arrowID;
boolean showSuccesses = s_showSuccesses[isIn? SUCCESS_IN : SUCCESS_OUT];
if ( isIn ) {
arrowID = showSuccesses ?
arrowID = showSuccesses ?
R.drawable.in_arrow_active : R.drawable.in_arrow;
} else {
arrowID = showSuccesses ?
arrowID = showSuccesses ?
R.drawable.out_arrow_active : R.drawable.out_arrow;
}
drawIn( canvas, res, arrowID, rect );
@ -373,14 +373,14 @@ public class ConnStatusHandler {
public static void loadState( Context context )
{
synchronized( s_lockObj ) {
String as64 = XWPrefs.getPrefsString( context,
String as64 = XWPrefs.getPrefsString( context,
R.string.key_connstat_data );
if ( null != as64 && 0 < as64.length() ) {
try {
byte[] bytes = XwJNI.base64Decode( as64 );
ObjectInputStream ois =
ObjectInputStream ois =
new ObjectInputStream( new ByteArrayInputStream(bytes) );
s_records =
s_records =
(HashMap<CommsConnType,SuccessRecord[]>)ois.readObject();
// } catch ( java.io.StreamCorruptedException sce ) {
// DbgUtils.logf( "loadState: %s", sce.toString() );
@ -397,7 +397,7 @@ public class ConnStatusHandler {
}
}
private static void saveState( final Context context,
private static void saveState( final Context context,
ConnStatusCBacks cbcks )
{
if ( null == cbcks ) {
@ -463,7 +463,7 @@ public class ConnStatusHandler {
icon.draw( canvas );
}
private static SuccessRecord newestSuccess( CommsConnTypeSet connTypes,
private static SuccessRecord newestSuccess( CommsConnTypeSet connTypes,
boolean isIn )
{
SuccessRecord result = null;
@ -486,7 +486,7 @@ public class ConnStatusHandler {
{
SuccessRecord[] records = s_records.get( connType );
if ( null == records ) {
records = new SuccessRecord[] { new SuccessRecord(),
records = new SuccessRecord[] { new SuccessRecord(),
new SuccessRecord(),
};
s_records.put( connType, records );
@ -505,9 +505,9 @@ public class ConnStatusHandler {
= new ObjectOutputStream( bas );
out.writeObject(s_records);
out.flush();
String as64 =
String as64 =
XwJNI.base64Encode( bas.toByteArray() );
XWPrefs.setPrefsString( context, R.string.key_connstat_data,
XWPrefs.setPrefsString( context, R.string.key_connstat_data,
as64 );
} catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe );
@ -515,7 +515,7 @@ public class ConnStatusHandler {
s_needsSave = false;
}
}
private static boolean anyTypeEnabled( Context context, CommsConnTypeSet connTypes )
{
boolean enabled = false;
@ -553,7 +553,7 @@ public class ConnStatusHandler {
return result;
}
private static boolean getAirplaneModeOn( Context context )
private static boolean getAirplaneModeOn( Context context )
{
boolean result =
0 != Settings.System.getInt( context.getContentResolver(),

View file

@ -54,7 +54,7 @@ public class ConnViaViewLayout extends LinearLayout {
}
protected void configure( CommsConnTypeSet types,
CheckEnabledWarner cew,
CheckEnabledWarner cew,
SetEmptyWarner sew,
DlgDelegate.HasDlgDelegate dlgDlgt )
{
@ -87,10 +87,10 @@ public class ConnViaViewLayout extends LinearLayout {
box.setText( typ.longName( context ) );
box.setChecked( m_curSet.contains( typ ) );
list.addView( item );
final CommsConnType typf = typ;
box.setOnCheckedChangeListener( new OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton buttonView,
public void onCheckedChanged( CompoundButton buttonView,
boolean isChecked ) {
if ( isChecked ) {
showNotAgainTypeTip( typf );
@ -153,7 +153,7 @@ public class ConnViaViewLayout extends LinearLayout {
Assert.fail();
break;
}
m_dlgDlgt.showNotAgainDlgThen( msgID, keyID,
m_dlgDlgt.showNotAgainDlgThen( msgID, keyID,
DlgDelegate.Action.SKIP_CALLBACK );
}

View file

@ -87,7 +87,7 @@ public class DBHelper extends SQLiteOpenHelper {
public static final String WORDCOUNT = "WORDCOUNT";
public static final String WORDCOUNTS = "WORDCOUNTS";
public static final String LANGCODE = "LANGCODE";
public static final String LOC = "LOC";
public static final String LOC = "LOC";
public static final String ITERMIN = "ITERMIN";
public static final String ITERMAX = "ITERMAX";
public static final String ITERPOS = "ITERPOS";
@ -236,7 +236,7 @@ public class DBHelper extends SQLiteOpenHelper {
}
@Override
public void onCreate( SQLiteDatabase db )
public void onCreate( SQLiteDatabase db )
{
createTable( db, TABLE_NAME_SUM, s_summaryColsAndTypes );
createTable( db, TABLE_NAME_OBITS, s_obitsColsAndTypes );
@ -254,7 +254,7 @@ public class DBHelper extends SQLiteOpenHelper {
@Override
@SuppressWarnings("fallthrough")
public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion )
public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion )
{
DbgUtils.logf( false, "onUpgrade: old: %d; new: %d", oldVersion, newVersion );
@ -359,9 +359,9 @@ public class DBHelper extends SQLiteOpenHelper {
db.execSQL( cmd );
}
private void createTable( SQLiteDatabase db, String name, String[][] data )
private void createTable( SQLiteDatabase db, String name, String[][] data )
{
StringBuilder query =
StringBuilder query =
new StringBuilder( String.format("CREATE TABLE %s (", name ) );
for ( int ii = 0; ii < data.length; ++ii ) {
@ -438,11 +438,11 @@ public class DBHelper extends SQLiteOpenHelper {
// Move all existing games to the row previously named "cur games'
private void moveToCurGames( SQLiteDatabase db )
{
String name = LocUtils.getString( m_context, false,
String name = LocUtils.getString( m_context, false,
R.string.group_cur_games );
String[] columns = { "rowid" };
String selection = String.format( "%s = '%s'", GROUPNAME, name );
Cursor cursor = db.query( DBHelper.TABLE_NAME_GROUPS, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_GROUPS, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
long rowid = cursor.getLong( cursor.getColumnIndex("rowid") );
@ -454,7 +454,7 @@ public class DBHelper extends SQLiteOpenHelper {
cursor.close();
}
private void makeAutoincrement( SQLiteDatabase db, String name,
private void makeAutoincrement( SQLiteDatabase db, String name,
String[][] data )
{
db.beginTransaction();
@ -468,9 +468,9 @@ public class DBHelper extends SQLiteOpenHelper {
}
createTable( db, name, data );
forceRowidHigh( db, name );
if ( null != columnNames ) {
ArrayList<String> oldCols =
ArrayList<String> oldCols =
new ArrayList<String>( Arrays.asList( columnNames ) );
// Make a list of columns in the new DB, using it to
@ -488,23 +488,23 @@ public class DBHelper extends SQLiteOpenHelper {
oldCols.retainAll( newCols );
String cols = TextUtils.join( ",", oldCols );
query =
query =
String.format( "INSERT INTO %s (%s) SELECT %s from temp_%s",
name, cols, cols, name );
db.execSQL( query );
}
db.execSQL( String.format( "DROP table temp_%s", name ) );
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
private void setColumnsEqual( SQLiteDatabase db, String table,
private void setColumnsEqual( SQLiteDatabase db, String table,
String dest, String src )
{
String query = String.format( "UPDATE %s set %s = %s", table,
String query = String.format( "UPDATE %s set %s = %s", table,
dest, src );
db.execSQL( query );
}

View file

@ -85,7 +85,7 @@ public class DBUtils {
public static interface DBChangeListener {
public void gameSaved( long rowid, GameChangeType change );
}
private static HashSet<DBChangeListener> s_listeners =
private static HashSet<DBChangeListener> s_listeners =
new HashSet<DBChangeListener>();
private static SQLiteOpenHelper s_dbHelper = null;
@ -117,7 +117,7 @@ public class DBUtils {
public int[] m_counts;
}
public static GameSummary getSummary( Context context, long rowid,
public static GameSummary getSummary( Context context, long rowid,
long maxMillis )
{
GameSummary result = null;
@ -138,7 +138,7 @@ public class DBUtils {
return getSummary( context, rowid, 0L );
}
public static GameSummary getSummary( Context context,
public static GameSummary getSummary( Context context,
GameLock lock )
{
initDB( context );
@ -149,10 +149,10 @@ public class DBUtils {
DBHelper.GAME_OVER, DBHelper.PLAYERS,
DBHelper.TURN, DBHelper.GIFLAGS,
DBHelper.CONTYPE, DBHelper.SERVERROLE,
DBHelper.ROOMNAME, DBHelper.RELAYID,
/*DBHelper.SMSPHONE,*/ DBHelper.SEED,
DBHelper.ROOMNAME, DBHelper.RELAYID,
/*DBHelper.SMSPHONE,*/ DBHelper.SEED,
DBHelper.DICTLANG, DBHelper.GAMEID,
DBHelper.SCORES,
DBHelper.SCORES,
DBHelper.LASTPLAY_TIME, DBHelper.REMOTEDEVS,
DBHelper.LASTMOVE, DBHelper.NPACKETSPENDING,
DBHelper.EXTRAS,
@ -161,16 +161,16 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
summary = new GameSummary( context );
summary.nMoves = cursor.getInt(cursor.
getColumnIndex(DBHelper.NUM_MOVES));
summary.nPlayers =
summary.nPlayers =
cursor.getInt(cursor.
getColumnIndex(DBHelper.NUM_PLAYERS));
summary.missingPlayers =
summary.missingPlayers =
cursor.getInt(cursor.
getColumnIndex(DBHelper.MISSINGPLYRS));
summary.
@ -178,36 +178,36 @@ public class DBUtils {
getString( cursor.
getColumnIndex( DBHelper.
PLAYERS ) ) );
summary.turn =
summary.turn =
cursor.getInt(cursor.
getColumnIndex(DBHelper.TURN));
summary.
setGiFlags( cursor.getInt(cursor.
getColumnIndex(DBHelper.GIFLAGS))
);
summary.gameID =
cursor.getInt(cursor.getColumnIndex(DBHelper.GAMEID) );
summary.gameID =
cursor.getInt(cursor.getColumnIndex(DBHelper.GAMEID) );
String players = cursor.
getString(cursor.getColumnIndex( DBHelper.PLAYERS ));
summary.readPlayers( players );
summary.dictLang =
summary.dictLang =
cursor.getInt(cursor.
getColumnIndex(DBHelper.DICTLANG));
summary.modtime =
summary.modtime =
cursor.getLong(cursor.
getColumnIndex(DBHelper.LASTPLAY_TIME));
int tmp = cursor.getInt(cursor.
getColumnIndex(DBHelper.GAME_OVER));
summary.gameOver = tmp != 0;
summary.lastMoveTime =
summary.lastMoveTime =
cursor.getInt(cursor.getColumnIndex(DBHelper.LASTMOVE));
String str = cursor
.getString(cursor.getColumnIndex(DBHelper.EXTRAS));
summary.setExtras( str );
String scoresStr =
String scoresStr =
cursor.getString( cursor.getColumnIndex(DBHelper.SCORES));
int[] scores = new int[summary.nPlayers];
if ( null != scoresStr && scoresStr.length() > 0 ) {
@ -254,7 +254,7 @@ public class DBUtils {
case COMMS_CONN_SMS:
col = cursor.getColumnIndex( DBHelper.REMOTEDEVS );
if ( col >= 0 ) {
summary.setRemoteDevs( context,
summary.setRemoteDevs( context,
cursor.getString( col ) );
}
break;
@ -292,7 +292,7 @@ public class DBUtils {
values.put( DBHelper.MISSINGPLYRS, summary.missingPlayers );
values.put( DBHelper.TURN, summary.turn );
values.put( DBHelper.GIFLAGS, summary.giflags() );
values.put( DBHelper.PLAYERS,
values.put( DBHelper.PLAYERS,
summary.summarizePlayers() );
values.put( DBHelper.DICTLANG, summary.dictLang );
values.put( DBHelper.GAMEID, summary.gameID );
@ -308,11 +308,11 @@ public class DBUtils {
values.put( DBHelper.EXTRAS, summary.getExtras() );
}
long nextNag = summary.nextTurnIsLocal() ?
NagTurnReceiver.figureNextNag( context,
NagTurnReceiver.figureNextNag( context,
1000*(long)summary.lastMoveTime )
: 0;
values.put( DBHelper.NEXTNAG, nextNag );
values.put( DBHelper.DICTLIST, summary.dictNames(DICTS_SEP) );
if ( null != summary.scores ) {
@ -338,7 +338,7 @@ public class DBUtils {
break;
case COMMS_CONN_BT:
case COMMS_CONN_SMS:
values.put( DBHelper.REMOTEDEVS,
values.put( DBHelper.REMOTEDEVS,
summary.summarizeDevs() );
break;
}
@ -373,7 +373,7 @@ public class DBUtils {
}
} // saveSummary
public static void addRematchInfo( Context context, long rowid, String btAddr,
public static void addRematchInfo( Context context, long rowid, String btAddr,
String phone, String relayID )
{
if ( XWApp.REMATCH_SUPPORTED ) {
@ -403,7 +403,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
result = cursor.getCount();
@ -416,17 +416,17 @@ public class DBUtils {
public static int countGamesUsingDict( Context context, String dict )
{
int result = 0;
String pattern = String.format( "%%%s%s%s%%",
String pattern = String.format( "%%%s%s%s%%",
DICTS_SEP, dict, DICTS_SEP );
String selection = String.format( "%s LIKE '%s'",
String selection = String.format( "%s LIKE '%s'",
DBHelper.DICTLIST, pattern );
// null for columns will return whole rows: bad. But
// might as well make it an int for speed
String[] columns = { DBHelper.DICTLANG };
String[] columns = { DBHelper.DICTLANG };
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
result = cursor.getCount();
cursor.close();
@ -549,26 +549,26 @@ public class DBUtils {
}
return result;
}
}
public static SentInvitesInfo getInvitesFor( Context context, long rowid )
{
SentInvitesInfo result = new SentInvitesInfo( rowid );
String[] columns = { DBHelper.MEANS, DBHelper.TIMESTAMP, DBHelper.TARGET };
String[] columns = { DBHelper.MEANS, DBHelper.TIMESTAMP, DBHelper.TARGET };
String selection = String.format( "%s = %d", DBHelper.ROW, rowid );
String orderBy = DBHelper.TIMESTAMP + " DESC";
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_INVITES, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_INVITES, columns,
selection, null, null, null, orderBy );
if ( 0 < cursor.getCount() ) {
int indxMns = cursor.getColumnIndex( DBHelper.MEANS );
int indxTS = cursor.getColumnIndex( DBHelper.TIMESTAMP );
int indxTrgt = cursor.getColumnIndex( DBHelper.TARGET );
while ( cursor.moveToNext() ) {
InviteMeans means = InviteMeans.values()[cursor.getInt( indxMns )];
Timestamp ts = Timestamp.valueOf(cursor.getString(indxTS));
@ -579,7 +579,7 @@ public class DBUtils {
cursor.close();
db.close();
}
return result;
}
@ -629,7 +629,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result =
@ -643,7 +643,7 @@ public class DBUtils {
public static int getMsgFlags( Context context, long rowid )
{
return getInt( context, rowid, DBHelper.HASMSGS,
return getInt( context, rowid, DBHelper.HASMSGS,
GameSummary.MSG_FLAGS_NONE );
}
@ -652,12 +652,12 @@ public class DBUtils {
return 0 == getInt( context, rowid, DBHelper.CONTRACTED, 0 );
}
public static boolean gameOver( Context context, long rowid )
public static boolean gameOver( Context context, long rowid )
{
return 0 != getInt( context, rowid, DBHelper.GAME_OVER, 0 );
}
public static void saveThumbnail( Context context, GameLock lock,
public static void saveThumbnail( Context context, GameLock lock,
Bitmap thumb )
{
if ( BuildConstants.THUMBNAIL_SUPPORTED ) {
@ -713,10 +713,10 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result =
result =
cursor.getString( cursor.getColumnIndex(DBHelper.RELAYID) );
}
cursor.close();
@ -725,7 +725,7 @@ public class DBUtils {
return result;
}
public static HashMap<Long,CommsConnTypeSet>
public static HashMap<Long,CommsConnTypeSet>
getGamesWithSendsPending( Context context )
{
HashMap<Long, CommsConnTypeSet> result = new HashMap<Long,CommsConnTypeSet>();
@ -734,7 +734,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
int indx1 = cursor.getColumnIndex( ROW_ID );
int indx2 = cursor.getColumnIndex( DBHelper.CONTYPE );
@ -759,7 +759,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
int indx = cursor.getColumnIndex( DBHelper.CONTYPE );
while ( cursor.moveToNext() ) {
@ -782,7 +782,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
result = new long[cursor.getCount()];
for ( int ii = 0; cursor.moveToNext(); ++ii ) {
@ -802,7 +802,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
result = new long[cursor.getCount()];
for ( int ii = 0; cursor.moveToNext(); ++ii ) {
@ -818,13 +818,13 @@ public class DBUtils {
return result;
}
public static boolean haveGame( Context context, int gameID )
public static boolean haveGame( Context context, int gameID )
{
long[] rows = getRowIDsFor( context, gameID );
return rows != null && 0 < rows.length;
}
public static boolean haveGame( Context context, long rowid )
public static boolean haveGame( Context context, long rowid )
{
boolean result = false;
String[] columns = { ROW_ID };
@ -832,7 +832,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
Assert.assertTrue( 1 >= cursor.getCount() );
result = 1 == cursor.getCount();
@ -842,18 +842,18 @@ public class DBUtils {
return result;
}
public static void listBTGames( Context context,
public static void listBTGames( Context context,
HashMap<String, int[]> result )
{
HashSet<Integer> set;
String[] columns = { DBHelper.GAMEID, DBHelper.REMOTEDEVS };
String selection = DBHelper.GAMEID + "!=0";
HashMap<String, HashSet<Integer> > map =
HashMap<String, HashSet<Integer> > map =
new HashMap<String, HashSet<Integer> >();
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
while ( cursor.moveToNext() ) {
int col = cursor.getColumnIndex( DBHelper.GAMEID );
@ -904,7 +904,7 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( cursor.moveToNext() ) {
int indx = cursor.getColumnIndex( columns[0] );
@ -917,7 +917,7 @@ public class DBUtils {
return result;
}
public static String[] getRelayIDs( Context context, long[][] rowIDs )
public static String[] getRelayIDs( Context context, long[][] rowIDs )
{
String[] result = null;
String[] columns = { ROW_ID, DBHelper.RELAYID };
@ -928,7 +928,7 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
int count = cursor.getCount();
if ( 0 < count ) {
@ -961,7 +961,7 @@ public class DBUtils {
return result;
}
public static void addDeceased( Context context, String relayID,
public static void addDeceased( Context context, String relayID,
int seed )
{
ContentValues values = new ContentValues();
@ -991,7 +991,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_OBITS, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_OBITS, columns,
null, null, null, null, null );
if ( 0 < cursor.getCount() ) {
int idIndex = cursor.getColumnIndex( DBHelper.RELAYID );
@ -1015,7 +1015,7 @@ public class DBUtils {
public static void clearObits( Context context, Obit[] obits )
{
String fmt = DBHelper.RELAYID + "= \"%s\" AND + "
String fmt = DBHelper.RELAYID + "= \"%s\" AND + "
+ DBHelper.SEED + " = %d";
initDB( context );
@ -1023,7 +1023,7 @@ public class DBUtils {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
for ( Obit obit: obits ) {
String selection = String.format( fmt, obit.m_relayID,
String selection = String.format( fmt, obit.m_relayID,
obit.m_seed );
db.delete( DBHelper.TABLE_NAME_OBITS, selection, null );
}
@ -1068,7 +1068,7 @@ public class DBUtils {
return lock;
} // saveNewGame
public static long saveGame( Context context, GameLock lock,
public static long saveGame( Context context, GameLock lock,
byte[] bytes, boolean setCreate )
{
Assert.assertTrue( lock.canWrite() );
@ -1105,7 +1105,7 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result = cursor.getBlob( cursor
@ -1152,7 +1152,7 @@ public class DBUtils {
db.delete( DBHelper.TABLE_NAME_CHAT, selInvites, null );
deleteCurChatsSync( db, rowid );
db.close();
}
notifyListeners( lock.getRowid(), GameChangeType.GAME_DELETED );
@ -1168,7 +1168,7 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result = cursor.getInt( cursor
@ -1191,7 +1191,7 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result = cursor.getString( cursor
@ -1278,7 +1278,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_CHAT, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_CHAT, columns,
selection, null, null, null, null );
if ( 0 < cursor.getCount() ) {
result = new HistoryPair[cursor.getCount()];
@ -1294,7 +1294,7 @@ public class DBUtils {
cursor.close();
db.close();
}
if ( null == result ) {
result = convertChatString( context, rowid, playersLocal );
}
@ -1320,17 +1320,17 @@ public class DBUtils {
String[] parts = TextUtils.split( all, ":" );
if ( 3 <= parts.length ) {
result = all.substring( 2 + parts[0].length() + parts[1].length() );
startAndEndOut[0] = Math.min( result.length(),
startAndEndOut[0] = Math.min( result.length(),
Integer.parseInt( parts[0] ) );
startAndEndOut[1] = Math.min( result.length(),
startAndEndOut[1] = Math.min( result.length(),
Integer.parseInt( parts[1] ) );
}
DbgUtils.logdf( "getCurChat(): => %s [%d,%d]", result,
DbgUtils.logdf( "getCurChat(): => %s [%d,%d]", result,
startAndEndOut[0], startAndEndOut[1] );
return result;
}
public static void setCurChat( Context context, long rowid, int player,
public static void setCurChat( Context context, long rowid, int player,
String text, int start, int end ) {
String key = formatCurChatKey( rowid, player );
text = String.format( "%d:%d:%s", start, end, text );
@ -1348,7 +1348,7 @@ public class DBUtils {
public long m_lastMoveMillis;
private boolean m_isSolo;
public NeedsNagInfo( long rowid, long nextNag, long lastMove,
public NeedsNagInfo( long rowid, long nextNag, long lastMove,
CurGameInfo.DeviceRole role ) {
m_rowid = rowid;
m_nextNag = nextNag;
@ -1365,16 +1365,16 @@ public class DBUtils {
{
NeedsNagInfo[] result = null;
long now = new Date().getTime(); // in milliseconds
String[] columns = { ROW_ID, DBHelper.NEXTNAG, DBHelper.LASTMOVE,
String[] columns = { ROW_ID, DBHelper.NEXTNAG, DBHelper.LASTMOVE,
DBHelper.SERVERROLE };
// where nextnag > 0 AND nextnag < now
String selection =
String.format( "%s > 0 AND %s < %s", DBHelper.NEXTNAG,
String selection =
String.format( "%s > 0 AND %s < %s", DBHelper.NEXTNAG,
DBHelper.NEXTNAG, now );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
int count = cursor.getCount();
if ( 0 < count ) {
@ -1387,7 +1387,7 @@ public class DBUtils {
long rowid = cursor.getLong( rowIndex );
long nextNag = cursor.getLong( nagIndex );
long lastMove = cursor.getLong( lastMoveIndex );
CurGameInfo.DeviceRole role =
CurGameInfo.DeviceRole role =
CurGameInfo.DeviceRole.values()[cursor.getInt( roleIndex )];
result[ii] = new NeedsNagInfo( rowid, nextNag, lastMove, role );
}
@ -1407,7 +1407,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( cursor.moveToNext() ) {
result = cursor.getLong( cursor.getColumnIndex( "min" ) );
@ -1457,7 +1457,7 @@ public class DBUtils {
private static HashMap<Long,GameGroupInfo> s_groupsCache = null;
private static void invalGroupsCache()
private static void invalGroupsCache()
{
s_groupsCache = null;
}
@ -1473,7 +1473,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
data = cursor.getBlob( cursor.
@ -1496,7 +1496,7 @@ public class DBUtils {
String query = "SELECT %s, count(%s) as cnt FROM %s GROUP BY %s";
query = String.format( query, DBHelper.GROUPID, DBHelper.GROUPID,
DBHelper.TABLE_NAME_SUM, DBHelper.GROUPID );
Cursor cursor = db.rawQuery( query, null );
int rowIndex = cursor.getColumnIndex( DBHelper.GROUPID );
int cntIndex = cursor.getColumnIndex( "cnt" );
@ -1513,7 +1513,7 @@ public class DBUtils {
protected static HashMap<Long,GameGroupInfo> getGroups( Context context )
{
if ( null == s_groupsCache ) {
HashMap<Long,GameGroupInfo> result =
HashMap<Long,GameGroupInfo> result =
new HashMap<Long,GameGroupInfo>();
// Select all groups. For each group get the number of games in
@ -1576,21 +1576,21 @@ public class DBUtils {
// }
// }
private static void readTurnInfo( SQLiteDatabase db, long groupID,
private static void readTurnInfo( SQLiteDatabase db, long groupID,
GameGroupInfo ggi )
{
String[] columns = { DBHelper.LASTMOVE, DBHelper.GIFLAGS,
String[] columns = { DBHelper.LASTMOVE, DBHelper.GIFLAGS,
DBHelper.TURN };
String orderBy = DBHelper.LASTMOVE;
String selection = String.format( "%s=%d", DBHelper.GROUPID, groupID );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection,
null, // args
null, // groupBy,
null, // having
orderBy
);
// We want the earliest LASTPLAY_TIME (i.e. the first we see
// since they're in order) that's a local turn, if any,
// otherwise a non-local turn.
@ -1622,9 +1622,9 @@ public class DBUtils {
} else {
ggi.m_lastMoveTime = lastPlayTimeRemote;
}
// DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT,
// DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT,
// DateFormat.SHORT );
// DbgUtils.logf( "using last play time %s for",
// DbgUtils.logf( "using last play time %s for",
// df.format( new Date( 1000 * ggi.m_lastMoveTime ) ) );
}
}
@ -1636,7 +1636,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
null, // selection
null, // args
null, // groupBy
@ -1659,7 +1659,7 @@ public class DBUtils {
String orderBy = DBHelper.CREATE_TIME + " DESC";
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, // selection
null, // args
null, // groupBy
@ -1696,12 +1696,12 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, // selection
null, // args
null, // groupBy
null, // having
null //orderby
null //orderby
);
if ( cursor.moveToNext() ) {
int index = cursor.getColumnIndex( DBHelper.GROUPID );
@ -1738,7 +1738,7 @@ public class DBUtils {
// initDB( context ); <- getGroups will have called this
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
rowid = db.insert( DBHelper.TABLE_NAME_GROUPS, null,
rowid = db.insert( DBHelper.TABLE_NAME_GROUPS, null,
values );
db.close();
}
@ -1747,11 +1747,11 @@ public class DBUtils {
}
return rowid;
}
public static void deleteGroup( Context context, long groupid )
{
// Nuke games having this group id
String selectionGames =
String selectionGames =
String.format( "%s=%d", DBHelper.GROUPID, groupid );
// And nuke the group record itself
@ -1768,7 +1768,7 @@ public class DBUtils {
invalGroupsCache();
}
public static void setGroupName( Context context, long groupid,
public static void setGroupName( Context context, long groupid,
String name )
{
ContentValues values = new ContentValues();
@ -1777,7 +1777,7 @@ public class DBUtils {
invalGroupsCache();
}
public static void setGroupExpanded( Context context, long groupid,
public static void setGroupExpanded( Context context, long groupid,
boolean expanded )
{
ContentValues values = new ContentValues();
@ -1805,10 +1805,10 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result =
result =
cursor.getString( cursor
.getColumnIndex(DBHelper
.CHAT_HISTORY));
@ -1820,7 +1820,7 @@ public class DBUtils {
return result;
}
private static void appendChatHistory( Context context,
private static void appendChatHistory( Context context,
ArrayList<ContentValues> valuess )
{
initDB( context );
@ -1850,7 +1850,7 @@ public class DBUtils {
ArrayList<ContentValues> valuess = new ArrayList<ContentValues>();
valuess.add( cvForChat( rowid, msg, fromPlayer ) );
appendChatHistory( context, valuess );
DbgUtils.logf( "appendChatHistory: inserted \"%s\" from player %d",
DbgUtils.logf( "appendChatHistory: inserted \"%s\" from player %d",
msg, fromPlayer );
} // appendChatHistory
@ -1934,13 +1934,13 @@ public class DBUtils {
String[] columns = { DBHelper.ITERPOS, DBHelper.ITERTOP,
DBHelper.ITERMIN, DBHelper.ITERMAX,
DBHelper.WORDCOUNTS, DBHelper.ITERPREFIX };
String selection =
String.format( NAMELOC_FMT, DBHelper.DICTNAME,
String selection =
String.format( NAMELOC_FMT, DBHelper.DICTNAME,
name, DBHelper.LOC, loc.ordinal() );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTBROWSE, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTBROWSE, columns,
selection, null, null, null, null );
if ( 1 >= cursor.getCount() && cursor.moveToFirst() ) {
result = new DictBrowseState();
@ -1948,16 +1948,16 @@ public class DBUtils {
.getColumnIndex(DBHelper.ITERPOS));
result.m_top = cursor.getInt( cursor
.getColumnIndex(DBHelper.ITERTOP));
result.m_minShown =
result.m_minShown =
cursor.getInt( cursor
.getColumnIndex(DBHelper.ITERMIN));
result.m_maxShown =
result.m_maxShown =
cursor.getInt( cursor
.getColumnIndex(DBHelper.ITERMAX));
result.m_prefix =
result.m_prefix =
cursor.getString( cursor
.getColumnIndex(DBHelper.ITERPREFIX));
String counts =
String counts =
cursor.getString( cursor.getColumnIndex(DBHelper.WORDCOUNTS));
if ( null != counts ) {
String[] nums = TextUtils.split( counts, ":" );
@ -1974,12 +1974,12 @@ public class DBUtils {
return result;
}
public static void dictsSetOffset( Context context, String name,
public static void dictsSetOffset( Context context, String name,
DictLoc loc, DictBrowseState state )
{
Assert.assertTrue( DictLoc.UNKNOWN != loc );
String selection =
String.format( NAMELOC_FMT, DBHelper.DICTNAME,
String selection =
String.format( NAMELOC_FMT, DBHelper.DICTNAME,
name, DBHelper.LOC, loc.ordinal() );
ContentValues values = new ContentValues();
values.put( DBHelper.ITERPOS, state.m_pos );
@ -2047,14 +2047,14 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTINFO, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTINFO, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result = new DictInfo();
result.name = name;
result.langCode =
result.langCode =
cursor.getInt( cursor.getColumnIndex(DBHelper.LANGCODE));
result.wordCount =
result.wordCount =
cursor.getInt( cursor.getColumnIndex(DBHelper.WORDCOUNT));
result.md5Sum =
cursor.getString( cursor.getColumnIndex(DBHelper.MD5SUM));
@ -2068,7 +2068,7 @@ public class DBUtils {
public static void dictsSetInfo( Context context, DictUtils.DictAndLoc dal,
DictInfo info )
{
String selection =
String selection =
String.format( NAME_FMT, DBHelper.DICTNAME, dal.name );
ContentValues values = new ContentValues();
@ -2093,8 +2093,8 @@ public class DBUtils {
public static void dictsMoveInfo( Context context, String name,
DictLoc fromLoc, DictLoc toLoc )
{
String selection =
String.format( NAMELOC_FMT, DBHelper.DICTNAME,
String selection =
String.format( NAMELOC_FMT, DBHelper.DICTNAME,
name, DBHelper.LOC, fromLoc.ordinal() );
ContentValues values = new ContentValues();
values.put( DBHelper.LOC, toLoc.ordinal() );
@ -2108,11 +2108,11 @@ public class DBUtils {
}
}
public static void dictsRemoveInfo( Context context,
public static void dictsRemoveInfo( Context context,
DictUtils.DictAndLoc dal )
{
String selection =
String.format( NAMELOC_FMT, DBHelper.DICTNAME,
String selection =
String.format( NAMELOC_FMT, DBHelper.DICTNAME,
dal.name, DBHelper.LOC, dal.loc.ordinal() );
initDB( context );
@ -2162,7 +2162,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_STUDYLIST, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_STUDYLIST, columns,
null, null, groupBy, null, null );
int count = cursor.getCount();
result = new int[count];
@ -2189,7 +2189,7 @@ public class DBUtils {
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_STUDYLIST, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_STUDYLIST, columns,
selection, null, null, null, orderBy );
int count = cursor.getCount();
result = new String[count];
@ -2239,11 +2239,11 @@ public class DBUtils {
insertQuery = String.format( insertQuery, DBHelper.TABLE_NAME_LOC,
DBHelper.KEY, DBHelper.LOCALE,
DBHelper.BLESSED, DBHelper.XLATION );
String updateQuery = "update %s set %s = ? "
+ " WHERE %s = ? and %s = ? and %s = ?";
updateQuery = String.format( updateQuery, DBHelper.TABLE_NAME_LOC,
DBHelper.XLATION, DBHelper.KEY,
DBHelper.XLATION, DBHelper.KEY,
DBHelper.LOCALE, DBHelper.BLESSED );
initDB( context );
@ -2262,7 +2262,7 @@ public class DBUtils {
insertStmt.bindString( 2, locale );
insertStmt.bindLong( 3, blessedLong );
insertStmt.bindString( 4, xlation );
try {
insertStmt.execute();
} catch ( SQLiteConstraintException sce ) {
@ -2292,14 +2292,14 @@ public class DBUtils {
HashMap<String, String> local = new HashMap<String, String>();
HashMap<String, String> blessed = new HashMap<String, String>();
String selection = String.format( "%s = '%s'", DBHelper.LOCALE,
String selection = String.format( "%s = '%s'", DBHelper.LOCALE,
locale );
String[] columns = { DBHelper.KEY, DBHelper.XLATION, DBHelper.BLESSED };
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_LOC, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_LOC, columns,
selection, null, null, null, null );
int keyIndex = cursor.getColumnIndex( DBHelper.KEY );
int valueIndex = cursor.getColumnIndex( DBHelper.XLATION );
@ -2321,7 +2321,7 @@ public class DBUtils {
public static void dropXLations( Context context, String locale )
{
String selection = String.format( "%s = '%s'", DBHelper.LOCALE,
String selection = String.format( "%s = '%s'", DBHelper.LOCALE,
locale );
initDB( context );
@ -2357,7 +2357,7 @@ public class DBUtils {
String selection = String.format( "%s = '%s'", DBHelper.KEY, key );
String[] columns = { DBHelper.VALUE };
Cursor cursor = db.query( DBHelper.TABLE_NAME_PAIRS, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_PAIRS, columns,
selection, null, null, null, null );
Assert.assertTrue( 1 >= cursor.getCount() );
int indx = cursor.getColumnIndex( DBHelper.VALUE );
@ -2498,7 +2498,7 @@ public class DBUtils {
long rowid = db.insert( DBHelper.TABLE_NAME_LOGS, null, values );
if ( 0 == (rowid % (LOGLIMIT / 10)) ) {
String where =
String where =
String.format( "not rowid in (select rowid from %s order by TIMESTAMP desc limit %d)",
DBHelper.TABLE_NAME_LOGS, LOGLIMIT );
int nGone = db.delete( DBHelper.TABLE_NAME_LOGS, where, null );
@ -2522,12 +2522,12 @@ public class DBUtils {
sdcardDB = new File( Environment.getExternalStorageDirectory(),
name );
}
try {
File srcDB = toSDCard? gamesDB : sdcardDB;
if ( srcDB.exists() ) {
FileInputStream src = new FileInputStream( srcDB );
FileOutputStream dest =
FileOutputStream dest =
new FileOutputStream( toSDCard? sdcardDB : gamesDB );
copyFileStream( dest, src );
invalGroupsCache();
@ -2542,7 +2542,7 @@ public class DBUtils {
return String.format( "%s_%s", DBHelper.getDBName(),
BuildConstants.VARIANT );
}
// private static void clearChatHistoryString( Context context, long rowid )
// {
// ContentValues values = new ContentValues();
@ -2600,7 +2600,7 @@ public class DBUtils {
}
return result;
}
private static void notifyListeners( long rowid, GameChangeType change )
{
synchronized( s_listeners ) {

View file

@ -66,7 +66,7 @@ public class DbgUtils {
logf( true, msg );
}
public static void logf( boolean persist, String msg )
public static void logf( boolean persist, String msg )
{
if ( s_doLog ) {
String time = "";
@ -162,7 +162,7 @@ public class DbgUtils {
// }
// }
public static void dumpCursor( Cursor cursor )
public static void dumpCursor( Cursor cursor )
{
if ( s_doLog ) {
String dump = DatabaseUtils.dumpCursorToString( cursor );

View file

@ -64,7 +64,7 @@ public class DelegateBase implements DlgClickNotify,
this( delegator, bundle, layoutID, R.menu.empty );
}
public DelegateBase( Delegator delegator, Bundle bundle,
public DelegateBase( Delegator delegator, Bundle bundle,
int layoutID, int menuID )
{
Assert.assertTrue( 0 < menuID );
@ -90,7 +90,7 @@ public class DelegateBase implements DlgClickNotify,
protected void onWindowFocusChanged( boolean hasFocus ) {}
protected boolean handleBackPressed() { return false; }
public void orientationChanged() {}
protected void requestWindowFeature( int feature ) {}
// Fragments only
@ -106,13 +106,13 @@ public class DelegateBase implements DlgClickNotify,
return view;
}
protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data )
protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data )
{
DbgUtils.logf( "DelegateBase.onActivityResult(): subclass responsibility!!!" );
}
protected void onResume()
protected void onResume()
{
m_isVisible = true;
XWService.setListener( this );
@ -203,7 +203,7 @@ public class DelegateBase implements DlgClickNotify,
return m_activity.getTitle().toString();
}
protected void startActivityForResult( Intent intent,
protected void startActivityForResult( Intent intent,
RequestCode requestCode )
{
m_activity.startActivityForResult( intent, requestCode.ordinal() );
@ -253,7 +253,7 @@ public class DelegateBase implements DlgClickNotify,
{
Point size = getContainerSize();
boolean result = size.x < size.y;
DbgUtils.logdf( "%s.isPortrait() => %b",
DbgUtils.logdf( "%s.isPortrait() => %b",
getClass().getSimpleName(), result );
return result;
}
@ -288,10 +288,10 @@ public class DelegateBase implements DlgClickNotify,
return LocUtils.xlateLang( m_activity, langCode, caps );
}
protected String getQuantityString( int resID, int quantity,
protected String getQuantityString( int resID, int quantity,
Object... params )
{
return LocUtils.getQuantityString( m_activity, resID, quantity,
return LocUtils.getQuantityString( m_activity, resID, quantity,
params );
}
@ -472,7 +472,7 @@ public class DelegateBase implements DlgClickNotify,
m_dlgDelegate.showConfirmThen( null, msg, action, params );
}
protected void showConfirmThen( Runnable onNA, String msg, int posButton,
protected void showConfirmThen( Runnable onNA, String msg, int posButton,
Action action, Object... params )
{
m_dlgDelegate.showConfirmThen( onNA, msg, posButton, action, params );
@ -500,7 +500,7 @@ public class DelegateBase implements DlgClickNotify,
m_dlgDelegate.showConfirmThen( msg, posButton, negButton, action, params );
}
protected void showConfirmThen( int msg, int posButton, Action action,
protected void showConfirmThen( int msg, int posButton, Action action,
Object... params )
{
m_dlgDelegate.showConfirmThen( msg, posButton, action, params );
@ -511,10 +511,10 @@ public class DelegateBase implements DlgClickNotify,
m_dlgDelegate.showConfirmThen( msgID, action );
}
public void showConfirmThen( Runnable onNA, String msg, int posButton,
public void showConfirmThen( Runnable onNA, String msg, int posButton,
int negButton, Action action, Object... params )
{
m_dlgDelegate.showConfirmThen( onNA, msg, posButton, negButton, action,
m_dlgDelegate.showConfirmThen( onNA, msg, posButton, negButton, action,
params );
}
@ -560,13 +560,13 @@ public class DelegateBase implements DlgClickNotify,
m_dlgDelegate.startProgress( titleID, msg, null );
}
protected void startProgress( int titleID, int msgID,
protected void startProgress( int titleID, int msgID,
OnCancelListener lstnr )
{
m_dlgDelegate.startProgress( titleID, msgID, lstnr );
}
protected void startProgress( int titleID, String msg,
protected void startProgress( int titleID, String msg,
OnCancelListener lstnr )
{
m_dlgDelegate.startProgress( titleID, msg, lstnr );
@ -595,11 +595,11 @@ public class DelegateBase implements DlgClickNotify,
protected boolean isVisible() { return m_isVisible; }
protected boolean handleNewIntent( Intent intent ) {
DbgUtils.logf( "%s.handleNewIntent(%s): not handling",
DbgUtils.logf( "%s.handleNewIntent(%s): not handling",
getClass().getSimpleName(), intent.toString() );
return false; // not handled
}
//////////////////////////////////////////////////
// MultiService.MultiEventListener interface
//////////////////////////////////////////////////
@ -624,7 +624,7 @@ public class DelegateBase implements DlgClickNotify,
m_dlgDelegate.eventOccurred( event, args );
break;
default:
DbgUtils.logdf( "DelegateBase.eventOccurred(event=%s) (DROPPED)",
DbgUtils.logdf( "DelegateBase.eventOccurred(event=%s) (DROPPED)",
event.toString() );
break;
}

View file

@ -30,7 +30,7 @@ public interface Delegator {
void finish();
boolean inDPMode();
void addFragment( XWFragment fragment, Bundle extras );
void addFragmentForResult( XWFragment fragment, Bundle extras,
void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode requestCode );
// For activities with lists
void setListAdapter( ListAdapter adapter );

View file

@ -126,7 +126,7 @@ public class DevID {
int storedVers = DBUtils.getIntFor( context, GCM_REGVERS_KEY, 0 );
// TRANSITIONAL
if ( 0 == storedVers ) {
storedVers = XWPrefs.getPrefsInt( context,
storedVers = XWPrefs.getPrefsInt( context,
R.string.key_gcmvers_regid, 0 );
if ( 0 != storedVers ) {
DBUtils.setIntFor( context, GCM_REGVERS_KEY, storedVers );

View file

@ -27,7 +27,7 @@ public class DictBrowseActivity extends XWActivity {
private DictBrowseDelegate m_dlgt;
@Override
protected void onCreate( Bundle savedInstanceState )
protected void onCreate( Bundle savedInstanceState )
{
m_dlgt = new DictBrowseDelegate( this, savedInstanceState );
super.onCreate( savedInstanceState, m_dlgt );

View file

@ -87,11 +87,11 @@ public class DictBrowseDelegate extends ListDelegateBase
XwJNI.dict_iter_setMinMax( m_dictClosure, m_browseState.m_minShown,
m_browseState.m_maxShown );
m_nWords = XwJNI.dict_iter_wordCount( m_dictClosure );
int format = m_browseState.m_minShown == m_browseState.m_maxShown ?
R.string.dict_browse_title1_fmt : R.string.dict_browse_title_fmt;
setTitle( getString( format, m_name, m_nWords,
m_browseState.m_minShown,
setTitle( getString( format, m_name, m_nWords,
m_browseState.m_minShown,
m_browseState.m_maxShown ));
String desc = XwJNI.dict_iter_getDesc( m_dictClosure );
@ -103,7 +103,7 @@ public class DictBrowseDelegate extends ListDelegateBase
}
}
public Object getItem( int position )
public Object getItem( int position )
{
TextView text = (TextView)
inflate( android.R.layout.simple_list_item_1 );
@ -121,7 +121,7 @@ public class DictBrowseDelegate extends ListDelegateBase
public long getItemId( int position ) { return position; }
public int getCount() {
public int getCount() {
Assert.assertTrue( 0 != m_dictClosure );
return m_nWords;
}
@ -134,7 +134,7 @@ public class DictBrowseDelegate extends ListDelegateBase
}
return m_indices[section];
}
public int getSectionForPosition( int position )
{
int section = Arrays.binarySearch( m_indices, position );
@ -146,8 +146,8 @@ public class DictBrowseDelegate extends ListDelegateBase
}
return section;
}
public Object[] getSections()
public Object[] getSections()
{
m_prefixes = XwJNI.dict_iter_getPrefixes( m_dictClosure );
m_indices = XwJNI.dict_iter_getIndices( m_dictClosure );
@ -161,7 +161,7 @@ public class DictBrowseDelegate extends ListDelegateBase
m_activity = delegator.getActivity();
}
protected void init( Bundle savedInstanceState )
protected void init( Bundle savedInstanceState )
{
Bundle args = getArguments();
String name = null == args? null : args.getString( DICT_NAME );
@ -170,7 +170,7 @@ public class DictBrowseDelegate extends ListDelegateBase
finish();
} else {
m_name = name;
m_loc =
m_loc =
DictUtils.DictLoc.values()[args.getInt( DICT_LOC, 0 )];
m_lang = DictLangCache.getDictLangCode( m_activity, name );
@ -188,7 +188,7 @@ public class DictBrowseDelegate extends ListDelegateBase
m_browseState.m_top = 0;
}
if ( null == m_browseState.m_counts ) {
m_browseState.m_counts =
m_browseState.m_counts =
XwJNI.dict_iter_getCounts( m_dictClosure );
}
@ -281,7 +281,7 @@ public class DictBrowseDelegate extends ListDelegateBase
//////////////////////////////////////////////////
// AdapterView.OnItemSelectedListener interface
//////////////////////////////////////////////////
public void onItemSelected( AdapterView<?> parent, View view,
public void onItemSelected( AdapterView<?> parent, View view,
int position, long id )
{
TextView text = (TextView)view;
@ -306,7 +306,7 @@ public class DictBrowseDelegate extends ListDelegateBase
@Override
public void dlgButtonClicked( Action action, int which, Object[] params )
{
Assert.assertTrue( Action.FINISH_ACTION == action );
Assert.assertTrue( Action.FINISH_ACTION == action );
finish();
}
@ -331,7 +331,7 @@ public class DictBrowseDelegate extends ListDelegateBase
edit.setText( text );
}
private void showPrefix()
private void showPrefix()
{
String text = m_browseState.m_prefix;
if ( null != text && 0 < text.length() ) {
@ -339,7 +339,7 @@ public class DictBrowseDelegate extends ListDelegateBase
if ( 0 <= pos ) {
getListView().setSelection( pos );
} else {
DbgUtils.showf( m_activity, R.string.dict_browse_nowords_fmt,
DbgUtils.showf( m_activity, R.string.dict_browse_nowords_fmt,
m_name, text );
}
}
@ -352,7 +352,7 @@ public class DictBrowseDelegate extends ListDelegateBase
// adapter/making it recognized a changed dataset. So, as a
// workaround, relaunch the activity with different
// parameters.
if ( m_browseState.m_minShown != min ||
if ( m_browseState.m_minShown != min ||
m_browseState.m_maxShown != max ) {
m_browseState.m_pos = 0;
@ -377,7 +377,7 @@ public class DictBrowseDelegate extends ListDelegateBase
++m_minAvail;
}
m_maxAvail = XwJNI.MAX_COLS_DICT;
while ( 0 == counts[m_maxAvail] ) { //
while ( 0 == counts[m_maxAvail] ) { //
--m_maxAvail;
}
}
@ -394,7 +394,7 @@ public class DictBrowseDelegate extends ListDelegateBase
nums[ii] = String.format( "%d", min + ii );
}
ArrayAdapter<String> adapter = new
ArrayAdapter<String>( m_activity,
ArrayAdapter<String>( m_activity,
//android.R.layout.simple_spinner_dropdown_item,
android.R.layout.simple_spinner_item,
nums );
@ -411,12 +411,12 @@ public class DictBrowseDelegate extends ListDelegateBase
// current max the largest min allowed, and the current
// min the smallest max allowed.
m_minSpinner = (Spinner)findViewById( R.id.wordlen_min );
makeAdapter( m_minSpinner, m_minAvail, m_browseState.m_maxShown,
makeAdapter( m_minSpinner, m_minAvail, m_browseState.m_maxShown,
m_browseState.m_minShown );
m_minSpinner.setOnItemSelectedListener( this );
m_maxSpinner = (Spinner)findViewById( R.id.wordlen_max );
makeAdapter( m_maxSpinner, m_browseState.m_minShown,
makeAdapter( m_maxSpinner, m_browseState.m_minShown,
m_maxAvail, m_browseState.m_maxShown );
m_maxSpinner.setOnItemSelectedListener( this );
}
@ -433,7 +433,7 @@ public class DictBrowseDelegate extends ListDelegateBase
}
}
public static void launch( Delegator delegator, String name,
public static void launch( Delegator delegator, String name,
DictUtils.DictLoc loc )
{
Bundle bundle = new Bundle();

View file

@ -72,7 +72,7 @@ public class DictLangCache {
String lang = getLangName( m_context, dal.name );
if ( null != lang && 0 != lang.length() ) {
if ( ! m_map.containsValue( lang ) ) {
String locName = LocUtils.xlateLang( m_context, lang,
String locName = LocUtils.xlateLang( m_context, lang,
true );
m_map.put( locName, lang );
}
@ -81,7 +81,7 @@ public class DictLangCache {
// Now build the array data
clear();
for ( Iterator<String> iter = m_map.keySet().iterator();
for ( Iterator<String> iter = m_map.keySet().iterator();
iter.hasNext(); ) {
String locName = iter.next();
add( locName );
@ -113,7 +113,7 @@ public class DictLangCache {
}
}
private static Comparator<String> KeepLast =
private static Comparator<String> KeepLast =
new Comparator<String>() {
public int compare( String str1, String str2 )
{
@ -133,10 +133,10 @@ public class DictLangCache {
DictInfo info = getInfo( context, dal );
if ( null != info ) {
int wordCount = info.wordCount;
String langName = getLangName( context, dal.name );
String locName = LocUtils.xlateLang( context, langName );
result = LocUtils.getString( context, R.string.dict_desc_fmt,
result = LocUtils.getString( context, R.string.dict_desc_fmt,
dal.name, locName,
wordCount );
}
@ -259,7 +259,7 @@ public class DictLangCache {
return result;
}
private static Comparator<DictInfo> s_ByCount =
private static Comparator<DictInfo> s_ByCount =
new Comparator<DictInfo>() {
public int compare( DictInfo di1, DictInfo di2 )
{
@ -337,9 +337,9 @@ public class DictLangCache {
s_handler.post( new Runnable() {
public void run() {
if ( null != s_dictsAdapter ) {
rebuildAdapter( s_dictsAdapter,
rebuildAdapter( s_dictsAdapter,
DictLangCache.
getHaveLang( context,
getHaveLang( context,
s_adaptedLang ) );
}
if ( null != s_langsAdapter ) {
@ -370,7 +370,7 @@ public class DictLangCache {
return langs.toArray( result );
}
public static String getBestDefault( Context context, int lang,
public static String getBestDefault( Context context, int lang,
boolean human )
{
String dict = human? CommonPrefs.getDefaultHumanDict( context )
@ -410,19 +410,19 @@ public class DictLangCache {
public static LangsArrayAdapter getLangsAdapter( Context context )
{
if ( null == s_langsAdapter ) {
s_langsAdapter =
new LangsArrayAdapter( context,
s_langsAdapter =
new LangsArrayAdapter( context,
android.R.layout.simple_spinner_item );
s_langsAdapter.rebuild();
}
return s_langsAdapter;
}
public static ArrayAdapter<String> getDictsAdapter( Context context,
public static ArrayAdapter<String> getDictsAdapter( Context context,
int lang )
{
if ( lang != s_adaptedLang ) {
s_dictsAdapter =
s_dictsAdapter =
new ArrayAdapter<String>( context,
android.R.layout.simple_spinner_item );
rebuildAdapter( s_dictsAdapter, getHaveLang( context, lang ) );
@ -473,7 +473,7 @@ public class DictLangCache {
// Tmp test that recovers from problem with new background download code
if ( null != info && 0 == info.langCode ) {
DbgUtils.logf( "getInfo: dropping info for %s b/c lang code wrong",
DbgUtils.logf( "getInfo: dropping info for %s b/c lang code wrong",
dal.name );
info = null;
}
@ -483,9 +483,9 @@ public class DictLangCache {
DictUtils.DictPairs pairs = DictUtils.openDicts( context, names );
info = new DictInfo();
if ( XwJNI.dict_getInfo( pairs.m_bytes[0], dal.name,
pairs.m_paths[0],
JNIUtilsImpl.get( context ),
if ( XwJNI.dict_getInfo( pairs.m_bytes[0], dal.name,
pairs.m_paths[0],
JNIUtilsImpl.get( context ),
DictLoc.DOWNLOAD == dal.loc,
info ) ) {

View file

@ -56,7 +56,7 @@ public class DictListPreference extends XWListPreference {
String name = dals[ii].name;
if ( langCode == DictLangCache.getDictLangCode( context, name ) ) {
values.add( name );
dictEntries.add( DictLangCache.annotatedDictName( context,
dictEntries.add( DictLangCache.annotatedDictName( context,
dals[ii] ) );
}
}

View file

@ -81,7 +81,7 @@ public class DictUtils {
}
} );
}
public static class DictPairs {
public byte[][] m_bytes;
public String[] m_paths;
@ -113,13 +113,13 @@ public class DictUtils {
public String name;
public DictLoc loc;
@Override
public boolean equals( Object obj )
@Override
public boolean equals( Object obj )
{
boolean result = false;
if ( obj instanceof DictAndLoc ) {
DictAndLoc other = (DictAndLoc)obj;
result = name.equals( other.name )
&& loc.equals( other.loc );
}
@ -131,7 +131,7 @@ public class DictUtils {
return name.compareTo( other.name );
}
}
public static void invalDictList()
{
s_dictListCache = null;
@ -139,7 +139,7 @@ public class DictUtils {
// changes?
}
private static void tryDir( Context context, File dir, boolean strict,
private static void tryDir( Context context, File dir, boolean strict,
DictLoc loc, ArrayList<DictAndLoc> al )
{
if ( null != dir ) {
@ -161,7 +161,7 @@ public class DictUtils {
for ( String file : getAssets( context ) ) {
if ( isDict( context, file, null ) ) {
al.add( new DictAndLoc( removeDictExtn( file ),
al.add( new DictAndLoc( removeDictExtn( file ),
DictLoc.BUILT_IN ) );
}
}
@ -174,10 +174,10 @@ public class DictUtils {
}
tryDir( context, getSDDir( context ), false, DictLoc.EXTERNAL, al );
tryDir( context, getDownloadDir( context ), true,
tryDir( context, getDownloadDir( context ), true,
DictLoc.DOWNLOAD, al );
s_dictListCache =
s_dictListCache =
al.toArray( new DictUtils.DictAndLoc[al.size()] );
}
return s_dictListCache;
@ -221,7 +221,7 @@ public class DictUtils {
}
}
// DbgUtils.logf( "getDictLoc(%s)=>%h(%s)", name, loc,
// DbgUtils.logf( "getDictLoc(%s)=>%h(%s)", name, loc,
// ((null != loc)?loc.toString():"UNKNOWN") );
return loc;
}
@ -262,12 +262,12 @@ public class DictUtils {
boolean success = false;
try {
FileInputStream fis = DictLoc.INTERNAL == from
FileInputStream fis = DictLoc.INTERNAL == from
? context.openFileInput( name )
: new FileInputStream( getDictFile( context, name, from ) );
FileOutputStream fos = DictLoc.INTERNAL == to
? context.openFileOutput( name, Context.MODE_PRIVATE )
FileOutputStream fos = DictLoc.INTERNAL == to
? context.openFileOutput( name, Context.MODE_PRIVATE )
: new FileOutputStream( getDictFile( context, name, to ) );
success = DBUtils.copyFileStream( fos, fis );
@ -376,7 +376,7 @@ public class DictUtils {
DbgUtils.loge( ioe );
}
}
return bytes;
} // openDict
@ -447,7 +447,7 @@ public class DictUtils {
}
public static boolean saveDict( Context context, InputStream in,
String name, DictLoc loc,
String name, DictLoc loc,
DownProgListener dpl )
{
boolean success = false;
@ -524,13 +524,13 @@ public class DictUtils {
DbgUtils.logf( "uri: %s", uri.toString() );
intent.putExtra( Intent.EXTRA_STREAM, uri );
intent.putExtra( Intent.EXTRA_SUBJECT,
intent.putExtra( Intent.EXTRA_SUBJECT,
context.getString( R.string.share_subject ) );
intent.putExtra( Intent.EXTRA_TEXT,
intent.putExtra( Intent.EXTRA_TEXT,
Utils.format( context, R.string.share_bodyf, name ) );
String title = context.getString( R.string.share_chooser );
context.startActivity( Intent.createChooser( intent, title ) );
context.startActivity( Intent.createChooser( intent, title ) );
}
*/
@ -538,7 +538,7 @@ public class DictUtils {
{
return file.endsWith( XWConstants.GAME_EXTN );
}
private static boolean isDict( Context context, String file, File dir )
{
boolean ok = file.endsWith( XWConstants.DICT_EXTN );
@ -559,7 +559,7 @@ public class DictUtils {
return str;
}
public static String addDictExtn( String str )
public static String addDictExtn( String str )
{
if ( ! str.endsWith( XWConstants.DICT_EXTN ) ) {
str += XWConstants.DICT_EXTN;
@ -577,7 +577,7 @@ public class DictUtils {
return new String[0];
}
}
public static boolean haveWriteableSD()
{
String state = Environment.getExternalStorageState();

View file

@ -39,7 +39,7 @@ public class DictsActivity extends XWActivity {
private DictsDelegate m_dlgt;
@Override
protected void onCreate( Bundle savedInstanceState )
protected void onCreate( Bundle savedInstanceState )
{
m_dlgt = new DictsDelegate( this, savedInstanceState );
super.onCreate( savedInstanceState, m_dlgt );

View file

@ -74,7 +74,7 @@ import org.eehouse.android.xw4.DwnldDelegate.OnGotLcDictListener;
public class DictsDelegate extends ListDelegateBase
implements View.OnClickListener, AdapterView.OnItemLongClickListener,
SelectableItem, MountEventReceiver.SDCardNotifiee,
SelectableItem, MountEventReceiver.SDCardNotifiee,
DlgDelegate.DlgClickNotify, GroupStateListener,
DownloadFinishedListener, XWListItem.ExpandedListener {
@ -109,25 +109,25 @@ public class DictsDelegate extends ListDelegateBase
private String m_noteNone;
private static interface SafePopup {
public void doPopup( Delegator dlgtor, View button,
public void doPopup( Delegator dlgtor, View button,
String curDict, int lang );
}
private static SafePopup s_safePopup = null;
private static class SafePopupImpl implements SafePopup {
public void doPopup( final Delegator dlgtor, View button,
public void doPopup( final Delegator dlgtor, View button,
String curDict, int lang ) {
final HashMap<MenuItem, DictAndLoc> itemData
= new HashMap<MenuItem, DictAndLoc>();
MenuItem.OnMenuItemClickListener listener =
MenuItem.OnMenuItemClickListener listener =
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick( MenuItem item )
{
DictAndLoc dal = itemData.get( item );
DictBrowseDelegate.launch( dlgtor, dal.name,
DictBrowseDelegate.launch( dlgtor, dal.name,
dal.loc );
return true;
}
@ -140,7 +140,7 @@ public class DictsDelegate extends ListDelegateBase
// Add at top but save until have dal info
MenuItem curItem =
menu.add( LocUtils.getString( context,
R.string.cur_menu_marker_fmt,
R.string.cur_menu_marker_fmt,
curDict ) );
DictAndLoc[] dals = DictLangCache.getDALsHaveLang( context, lang );
@ -161,7 +161,7 @@ public class DictsDelegate extends ListDelegateBase
public int m_nWords;
public long m_nBytes;
public String m_note;
public DictInfo( String name, String lang, int nWords,
public DictInfo( String name, String lang, int nWords,
long nBytes, String note )
{
m_name = name;
@ -178,7 +178,7 @@ public class DictsDelegate extends ListDelegateBase
private static class LangInfo {
int m_numDicts;
int m_posn;
public LangInfo( int posn, int numDicts )
public LangInfo( int posn, int numDicts )
{
m_posn = posn;
m_numDicts = numDicts;
@ -191,7 +191,7 @@ public class DictsDelegate extends ListDelegateBase
private class DictListAdapter extends XWExpListAdapter {
private Context m_context;
public DictListAdapter( Context context )
public DictListAdapter( Context context )
{
super( new Class[] { LangInfo.class,
DictAndLoc.class,
@ -207,7 +207,7 @@ public class DictsDelegate extends ListDelegateBase
int nLangs = m_langs.length;
for ( int ii = 0; ii < nLangs; ++ii ) {
String langName = m_langs[ii];
if ( null != m_filterLang &&
if ( null != m_filterLang &&
! m_filterLang.equals(langName) ) {
continue;
}
@ -235,12 +235,12 @@ public class DictsDelegate extends ListDelegateBase
langName );
boolean expanded = ! m_closedLangs.contains( langName );
String locLangName = xlateLang( langName );
String name = getQuantityString( R.plurals.lang_name_fmt,
String name = getQuantityString( R.plurals.lang_name_fmt,
info.m_numDicts,
locLangName, info.m_numDicts );
name = Utils.capitalize( name );
result = ListGroup.make( m_context, convertView,
DictsDelegate.this, groupPos, name,
result = ListGroup.make( m_context, convertView,
DictsDelegate.this, groupPos, name,
expanded );
} else {
XWListItem item;
@ -286,7 +286,7 @@ public class DictsDelegate extends ListDelegateBase
} else {
Assert.fail();
}
}
}
return result;
}
@ -349,7 +349,7 @@ public class DictsDelegate extends ListDelegateBase
protected DictsDelegate( Delegator delegator, Bundle savedInstanceState )
{
super( delegator, savedInstanceState, R.layout.dict_browse,
super( delegator, savedInstanceState, R.layout.dict_browse,
R.menu.dicts_menu );
m_activity = delegator.getActivity();
}
@ -374,8 +374,8 @@ public class DictsDelegate extends ListDelegateBase
public void onClick( DialogInterface dlgi, int item ) {
moveTo[0] = item;
AlertDialog dlg = (AlertDialog)dlgi;
Button btn =
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
Button btn =
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
btn.setEnabled( true );
}
};
@ -389,12 +389,12 @@ public class DictsDelegate extends ListDelegateBase
if ( fromLoc == toLoc ) {
DbgUtils.logf( "not moving %s: same loc", name );
} else if ( DictUtils.moveDict( m_activity,
name, fromLoc,
name, fromLoc,
toLoc ) ) {
selItem.setComment( m_locNames[toLoc.ordinal()] );
selItem.setCached( toLoc );
selItem.invalidate();
DBUtils.dictsMoveInfo( m_activity, name,
DBUtils.dictsMoveInfo( m_activity, name,
fromLoc, toLoc );
} else {
DbgUtils.logf( "moveDict(%s) failed", name );
@ -418,12 +418,12 @@ public class DictsDelegate extends ListDelegateBase
public void onClick( DialogInterface dlg, int item ) {
if ( DialogInterface.BUTTON_NEGATIVE == item
|| DialogInterface.BUTTON_POSITIVE == item ) {
setDefault( row, R.string.key_default_dict,
setDefault( row, R.string.key_default_dict,
R.string.key_default_robodict );
}
if ( DialogInterface.BUTTON_NEGATIVE == item
if ( DialogInterface.BUTTON_NEGATIVE == item
|| DialogInterface.BUTTON_NEUTRAL == item ) {
setDefault( row, R.string.key_default_robodict,
setDefault( row, R.string.key_default_robodict,
R.string.key_default_dict );
}
}
@ -449,7 +449,7 @@ public class DictsDelegate extends ListDelegateBase
String name = intent.getStringExtra( MultiService.DICT );
m_launchedForMissing = true;
DwnldDelegate
.downloadDictInBack( m_activity, lang,
.downloadDictInBack( m_activity, lang,
name, DictsDelegate.this );
}
};
@ -459,7 +459,7 @@ public class DictsDelegate extends ListDelegateBase
}
};
dialog = MultiService.missingDictDialog( m_activity, getIntent(),
dialog = MultiService.missingDictDialog( m_activity, getIntent(),
lstnr, lstnr2 );
break;
@ -488,7 +488,7 @@ public class DictsDelegate extends ListDelegateBase
}
}
protected void init( Bundle savedInstanceState )
protected void init( Bundle savedInstanceState )
{
m_onServerStr = getString( R.string.dict_on_server );
m_closedLangs = new HashSet<String>();
@ -504,7 +504,7 @@ public class DictsDelegate extends ListDelegateBase
m_listView = getListView();
m_listView.setOnItemLongClickListener( this );
m_checkbox = (CheckBox)findViewById( R.id.show_remote );
m_checkbox.setOnClickListener( this );
@ -515,7 +515,7 @@ public class DictsDelegate extends ListDelegateBase
if ( MultiService.isMissingDictIntent( intent ) ) {
showDialog( DlgID.DICT_OR_DECLINE );
} else {
boolean showRemote = intent.getBooleanExtra( DICT_SHOWREMOTE,
boolean showRemote = intent.getBooleanExtra( DICT_SHOWREMOTE,
false );
if ( showRemote ) {
m_quickFetchMode = true;
@ -555,18 +555,18 @@ public class DictsDelegate extends ListDelegateBase
setTitleBar();
}
protected void onStop()
protected void onStop()
{
MountEventReceiver.unregister( this );
}
public void onClick( View view )
public void onClick( View view )
{
if ( view == m_checkbox ) {
switchShowingRemote( m_checkbox.isChecked() );
} else {
XWListItem item = (XWListItem)view;
DictBrowseDelegate.launch( getDelegator(), item.getText(),
DictBrowseDelegate.launch( getDelegator(), item.getText(),
(DictLoc)item.getCached() );
}
}
@ -591,22 +591,22 @@ public class DictsDelegate extends ListDelegateBase
}
@Override
public boolean onPrepareOptionsMenu( Menu menu )
public boolean onPrepareOptionsMenu( Menu menu )
{
// int nSel = m_selDicts.size();
int[] nSels = countSelDicts();
Utils.setItemVisible( menu, R.id.dicts_select,
Utils.setItemVisible( menu, R.id.dicts_select,
1 == nSels[SEL_LOCAL] && 0 == nSels[SEL_REMOTE] );
// NO -- test if any downloadable selected
Utils.setItemVisible( menu, R.id.dicts_download,
Utils.setItemVisible( menu, R.id.dicts_download,
0 == nSels[SEL_LOCAL] && 0 < nSels[SEL_REMOTE] );
Utils.setItemVisible( menu, R.id.dicts_deselect_all,
Utils.setItemVisible( menu, R.id.dicts_deselect_all,
0 < nSels[SEL_LOCAL] || 0 < nSels[SEL_REMOTE] );
boolean allVolatile = 0 == nSels[SEL_REMOTE] && selItemsVolatile();
Utils.setItemVisible( menu, R.id.dicts_move,
Utils.setItemVisible( menu, R.id.dicts_move,
allVolatile && DictUtils.haveWriteableSD() );
Utils.setItemVisible( menu, R.id.dicts_delete, allVolatile );
@ -635,14 +635,14 @@ public class DictsDelegate extends ListDelegateBase
Uri[] uris = new Uri[countNeedDownload()];
String[] names = new String[uris.length];
int count = 0;
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
iter.hasNext(); ) {
XWListItem litm = iter.next();
Object cached = litm.getCached();
if ( cached instanceof DictInfo ) {
DictInfo info = (DictInfo)cached;
String name = litm.getText();
Uri uri = Utils.makeDictUri( m_activity, info.m_lang,
Uri uri = Utils.makeDictUri( m_activity, info.m_lang,
name );
uris[count] = uri;
names[count] = name;
@ -676,7 +676,7 @@ public class DictsDelegate extends ListDelegateBase
private int countNeedDownload()
{
int result = 0;
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
iter.hasNext(); ) {
XWListItem litm = iter.next();
Object obj = litm.getCached();
@ -691,9 +691,9 @@ public class DictsDelegate extends ListDelegateBase
{
int loci = intent.getIntExtra( UpdateCheckReceiver.NEW_DICT_LOC, 0 );
if ( 0 < loci ) {
String name =
String name =
intent.getStringExtra( UpdateCheckReceiver.NEW_DICT_NAME );
String url =
String url =
intent.getStringExtra( UpdateCheckReceiver.NEW_DICT_URL );
Uri uri = Uri.parse( url );
DwnldDelegate.downloadDictInBack( m_activity, uri, name, null );
@ -745,11 +745,11 @@ public class DictsDelegate extends ListDelegateBase
}
saveClosed();
}
//////////////////////////////////////////////////////////////////////
// OnItemLongClickListener interface
//////////////////////////////////////////////////////////////////////
public boolean onItemLongClick( AdapterView<?> parent, View view,
public boolean onItemLongClick( AdapterView<?> parent, View view,
int position, long id ) {
boolean success = view instanceof SelectableItem.LongClickHandler;
if ( success ) {
@ -758,10 +758,10 @@ public class DictsDelegate extends ListDelegateBase
return success;
}
private boolean selItemsVolatile()
private boolean selItemsVolatile()
{
boolean result = 0 < m_selDicts.size();
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
result && iter.hasNext(); ) {
Object obj = iter.next().getCached();
if ( obj instanceof DictLoc ) {
@ -779,7 +779,7 @@ public class DictsDelegate extends ListDelegateBase
private void deleteSelected()
{
XWListItem[] items = getSelItems();
String msg = getQuantityString( R.plurals.confirm_delete_dict_fmt,
String msg = getQuantityString( R.plurals.confirm_delete_dict_fmt,
items.length, getJoinedNames( items ) );
// Confirm. And for each dict, warn if (after ALL are deleted) any
@ -796,7 +796,7 @@ public class DictsDelegate extends ListDelegateBase
public String dictsStr()
{
if ( null == m_asArray ) {
String[] arr = delDicts.toArray(new String[delDicts.size()]);
String[] arr = delDicts.toArray(new String[delDicts.size()]);
m_asArray = TextUtils.join( ", ", arr );
}
return m_asArray;
@ -962,7 +962,7 @@ public class DictsDelegate extends ListDelegateBase
{
XWListItem[] items = new XWListItem[m_selDicts.size()];
int indx = 0;
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
iter.hasNext(); ) {
items[indx++] = iter.next();
}
@ -974,7 +974,7 @@ public class DictsDelegate extends ListDelegateBase
{
int[] results = new int[2];
Assert.assertTrue( 0 == results[0] && 0 == results[1] );
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
for ( Iterator<XWListItem> iter = m_selDicts.values().iterator();
iter.hasNext(); ) {
Object obj = iter.next().getCached();
if ( obj instanceof DictLoc ) {
@ -1000,7 +1000,7 @@ public class DictsDelegate extends ListDelegateBase
}
}
private String[] makeDictDirItems()
private String[] makeDictDirItems()
{
boolean showDownload = DictUtils.haveDownloadDir( m_activity );
int nItems = showDownload ? 3 : 2;
@ -1033,7 +1033,7 @@ public class DictsDelegate extends ListDelegateBase
// return mkDownloadIntent( context, dict_url );
}
public static void downloadForResult( Activity activity, RequestCode requestCode,
public static void downloadForResult( Activity activity, RequestCode requestCode,
int lang, String name )
{
Intent intent = new Intent( activity, DictsActivity.class );
@ -1093,25 +1093,25 @@ public class DictsDelegate extends ListDelegateBase
final DictInfo info = (DictInfo)me.getCached();
if ( expanded ) {
m_expandedItems.add( info ); // may already be there
LinearLayout view =
LinearLayout view =
(LinearLayout)inflate( R.layout.remote_dict_details );
Button button = (Button)view.findViewById( R.id.download_button );
button.setOnClickListener( new View.OnClickListener() {
public void onClick( View view ) {
DwnldDelegate.
downloadDictInBack( m_activity, info.m_lang,
info.m_name,
downloadDictInBack( m_activity, info.m_lang,
info.m_name,
DictsDelegate.this );
}
} );
long kBytes = (info.m_nBytes + 999) / 1000;
String note = null == info.m_note ? m_noteNone : info.m_note;
String msg = getString( R.string.dict_info_fmt, info.m_nWords,
String msg = getString( R.string.dict_info_fmt, info.m_nWords,
kBytes, note );
TextView summary = (TextView)view.findViewById( R.id.details );
summary.setText( msg );
me.addExpandedView( view );
} else {
me.removeExpandedView();
@ -1122,7 +1122,7 @@ public class DictsDelegate extends ListDelegateBase
//////////////////////////////////////////////////////////////////////
// DwnldActivity.DownloadFinishedListener interface
//////////////////////////////////////////////////////////////////////
public void downloadFinished( String lang, final String name,
public void downloadFinished( String lang, final String name,
final boolean success )
{
if ( success && m_showRemote ) {
@ -1161,7 +1161,7 @@ public class DictsDelegate extends ListDelegateBase
DbgUtils.logf( "itemClicked not implemented" );
}
public void itemToggled( SelectableItem.LongClickHandler toggled,
public void itemToggled( SelectableItem.LongClickHandler toggled,
boolean selected )
{
XWListItem dictView = (XWListItem)toggled;
@ -1188,14 +1188,14 @@ public class DictsDelegate extends ListDelegateBase
private String m_langName;
private OnGotLcDictListener m_lstnr;
public GetDefaultDictTask( Context context, String lc,
public GetDefaultDictTask( Context context, String lc,
OnGotLcDictListener lnr ) {
m_context = context;
m_lc = lc;
m_lstnr = lnr;
}
@Override
@Override
public String doInBackground( Void... unused )
{
// FIXME: this should pass up the language code to retrieve and
@ -1231,7 +1231,7 @@ public class DictsDelegate extends ListDelegateBase
break;
} else {
int nWords = dict.getInt( "nWords" );
if ( null == theOne
if ( null == theOne
|| nWords > theOneNWords ) {
theOne = dict;
theOneNWords = nWords;
@ -1245,8 +1245,8 @@ public class DictsDelegate extends ListDelegateBase
// the flag so we don't try again, even though
// we've failed.
if ( null == theOne ) {
XWPrefs.setPrefsBoolean( m_context,
R.string.key_got_langdict,
XWPrefs.setPrefsBoolean( m_context,
R.string.key_got_langdict,
true );
}
@ -1270,7 +1270,7 @@ public class DictsDelegate extends ListDelegateBase
}
}
private class FetchListTask extends AsyncTask<Void, Void, Boolean>
private class FetchListTask extends AsyncTask<Void, Void, Boolean>
implements OnCancelListener {
private Context m_context;
@ -1280,7 +1280,7 @@ public class DictsDelegate extends ListDelegateBase
startProgress( R.string.progress_title, R.string.remote_empty, this );
}
@Override
@Override
public Boolean doInBackground( Void... unused )
{
boolean success = false;
@ -1300,21 +1300,21 @@ public class DictsDelegate extends ListDelegateBase
}
return new Boolean( success );
}
@Override
@Override
protected void onCancelled()
{
m_remoteInfo = null;
m_showRemote = false;
}
@Override
@Override
protected void onCancelled( Boolean success )
{
onCancelled();
}
@Override
@Override
protected void onPostExecute( Boolean success )
{
if ( success ) {
@ -1326,7 +1326,7 @@ public class DictsDelegate extends ListDelegateBase
String joined = TextUtils.join( ", ", names );
showConfirmThen( getString( R.string.update_dicts_fmt,
joined ),
R.string.button_download,
R.string.button_download,
Action.UPDATE_DICTS_ACTION );
}
} else {
@ -1359,8 +1359,8 @@ public class DictsDelegate extends ListDelegateBase
for ( int ii = 0; !isCancelled() && ii < nLangs; ++ii ) {
JSONObject langObj = langs.getJSONObject( ii );
String langName = langObj.getString( "lang" );
if ( null != m_filterLang &&
if ( null != m_filterLang &&
! m_filterLang.equals( langName ) ) {
continue;
}
@ -1371,9 +1371,9 @@ public class DictsDelegate extends ListDelegateBase
JSONArray dicts = langObj.getJSONArray( "dicts" );
int nDicts = dicts.length();
ArrayList<DictInfo> dictNames =
ArrayList<DictInfo> dictNames =
new ArrayList<DictInfo>();
for ( int jj = 0; !isCancelled() && jj < nDicts;
for ( int jj = 0; !isCancelled() && jj < nDicts;
++jj ) {
JSONObject dict = dicts.getJSONObject( jj );
String name = dict.getString( "xwd" );
@ -1389,18 +1389,18 @@ public class DictsDelegate extends ListDelegateBase
if ( !m_quickFetchMode ) {
// Check if we have it and it needs an update
if ( DictLangCache.haveDict( m_activity,
if ( DictLangCache.haveDict( m_activity,
langName, name )){
boolean matches = true;
String curSum = DictLangCache
.getDictMD5Sum( m_activity, name );
if ( null != curSum ) {
JSONArray sums =
JSONArray sums =
dict.getJSONArray("md5sums");
if ( null != sums ) {
matches = false;
for ( int kk = 0;
!matches && kk < sums.length();
for ( int kk = 0;
!matches && kk < sums.length();
++kk ) {
String sum = sums.getString( kk );
matches = sum.equals( curSum );
@ -1408,8 +1408,8 @@ public class DictsDelegate extends ListDelegateBase
}
}
if ( !matches ) {
Uri uri =
Utils.makeDictUri( m_activity,
Uri uri =
Utils.makeDictUri( m_activity,
langName, name );
m_needUpdates.put( name, uri );
}

View file

@ -34,7 +34,7 @@ import org.eehouse.android.xw4.jni.GameSummary;
public class DispatchNotify extends Activity {
@Override
protected void onCreate( Bundle savedInstanceState )
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );

View file

@ -127,7 +127,7 @@ public class DlgDelegate {
}
public static class ActionPair {
public ActionPair( Action act, int str ) {
public ActionPair( Action act, int str ) {
buttonStr = str; action = act;
}
public int buttonStr;
@ -168,8 +168,8 @@ public class DlgDelegate {
private HashMap<DlgID, DlgState> m_dlgStates;
public DlgDelegate( Activity activity, DelegateBase dlgt,
DlgClickNotify callback, Bundle bundle )
public DlgDelegate( Activity activity, DelegateBase dlgt,
DlgClickNotify callback, Bundle bundle )
{
m_activity = activity;
m_dlgt = dlgt;
@ -188,7 +188,7 @@ public class DlgDelegate {
}
}
public void onSaveInstanceState( Bundle outState )
public void onSaveInstanceState( Bundle outState )
{
int[] ids = new int[m_dlgStates.size()];
if ( 0 < ids.length ) {
@ -212,7 +212,7 @@ public class DlgDelegate {
m_activity.showDialog( dlgID.ordinal() );
}
}
public Dialog createDialog( int id )
{
Dialog dialog = null;
@ -297,8 +297,8 @@ public class DlgDelegate {
showDialog( DlgID.DIALOG_ENABLESMS );
}
public void showNotAgainDlgThen( String msg, int prefsKey,
final Action action, ActionPair more,
public void showNotAgainDlgThen( String msg, int prefsKey,
final Action action, ActionPair more,
final Object[] params )
{
if ( XWPrefs.getPrefsBoolean( m_activity, prefsKey, false ) ) {
@ -315,18 +315,18 @@ public class DlgDelegate {
});
}
} else {
DlgState state =
new DlgState( DlgID.DIALOG_NOTAGAIN, msg, prefsKey, action, more,
DlgState state =
new DlgState( DlgID.DIALOG_NOTAGAIN, msg, prefsKey, action, more,
params );
addState( state );
showDialog( DlgID.DIALOG_NOTAGAIN );
}
}
public void showNotAgainDlgThen( int msgID, int prefsKey, Action action,
public void showNotAgainDlgThen( int msgID, int prefsKey, Action action,
ActionPair more, Object[] params )
{
showNotAgainDlgThen( getString( msgID ), prefsKey, action, more,
showNotAgainDlgThen( getString( msgID ), prefsKey, action, more,
params );
}
@ -335,7 +335,7 @@ public class DlgDelegate {
showNotAgainDlgThen( msgID, prefsKey, action, null, null );
}
public void showNotAgainDlgThen( int msgID, int prefsKey, Action action,
public void showNotAgainDlgThen( int msgID, int prefsKey, Action action,
ActionPair more )
{
showNotAgainDlgThen( msgID, prefsKey, action, more, null );
@ -390,21 +390,21 @@ public class DlgDelegate {
public void showConfirmThen( int msg, int posButton, Action action,
Object[] params )
{
showConfirmThen( null, getString(msg), posButton, android.R.string.cancel,
showConfirmThen( null, getString(msg), posButton, android.R.string.cancel,
action, params );
}
public void showConfirmThen( Runnable onNA, String msg, int posButton, Action action,
Object[] params )
{
showConfirmThen( onNA, msg, posButton, android.R.string.cancel, action,
showConfirmThen( onNA, msg, posButton, android.R.string.cancel, action,
params );
}
public void showConfirmThen( Runnable onNA, String msg, int posButton,
public void showConfirmThen( Runnable onNA, String msg, int posButton,
int negButton, Action action, Object[] params )
{
DlgState state = new DlgState( DlgID.CONFIRM_THEN, onNA, msg, posButton,
DlgState state = new DlgState( DlgID.CONFIRM_THEN, onNA, msg, posButton,
negButton, action, 0, params );
addState( state );
showDialog( DlgID.CONFIRM_THEN );
@ -426,7 +426,7 @@ public class DlgDelegate {
DlgClickNotify.InviteMeans means
= DlgClickNotify.InviteMeans.EMAIL;
m_clickCallback.inviteChoiceMade( action, means, null );
}
}
});
}
}
@ -461,7 +461,7 @@ public class DlgDelegate {
{
String title = getString( titleID );
m_progress = ProgressDialog.show( m_activity, title, msg, true, true );
if ( null != lstnr ) {
m_progress.setCancelable( true );
m_progress.setOnCancelListener( lstnr );
@ -487,14 +487,14 @@ public class DlgDelegate {
return true;
}
public void eventOccurred( MultiService.MultiEvent event,
public void eventOccurred( MultiService.MultiEvent event,
final Object ... args )
{
String msg = null;
boolean asToast = true;
switch( event ) {
case MESSAGE_RESEND:
msg = getString( R.string.bt_resend_fmt, (String)args[0],
msg = getString( R.string.bt_resend_fmt, (String)args[0],
(Long)args[1], (Integer)args[2] );
break;
case MESSAGE_FAILOUT:
@ -530,7 +530,7 @@ public class DlgDelegate {
final View view = LocUtils.inflate( m_activity, R.layout.about_dlg );
TextView vers = (TextView)view.findViewById( R.id.version_string );
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.FULL,
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.FULL,
DateFormat.FULL );
String dateString
= df.format( new Date( BuildConstants.BUILD_STAMP * 1000 ) );
@ -553,7 +553,7 @@ public class DlgDelegate {
builder.setNegativeButton( R.string.changes_button,
new OnClickListener() {
@Override
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int which )
{
FirstRunDialog.show( m_activity );
@ -600,7 +600,7 @@ public class DlgDelegate {
public void onClick( DialogInterface dlg, int item ) {
checkNotAgainCheck( state, naView );
m_clickCallback.
dlgButtonClicked( more.action,
dlgButtonClicked( more.action,
AlertDialog.BUTTON_POSITIVE,
more.params );
}
@ -627,13 +627,13 @@ public class DlgDelegate {
.setPositiveButton( state.m_posButton, lstnr )
.setNegativeButton( state.m_negButton, lstnr );
Dialog dialog = builder.create();
return setCallbackDismissListener( dialog, state, dlgID );
}
private Dialog createInviteChoicesDialog( final DlgState state, DlgID dlgID )
{
final ArrayList<DlgClickNotify.InviteMeans> means =
final ArrayList<DlgClickNotify.InviteMeans> means =
new ArrayList<DlgClickNotify.InviteMeans>();
ArrayList<String> items = new ArrayList<String>();
DlgClickNotify.InviteMeans lastMeans = null;
@ -641,7 +641,7 @@ public class DlgDelegate {
&& state.m_params[0] instanceof SentInvitesInfo ) {
lastMeans =((SentInvitesInfo)state.m_params[0]).getLastMeans();
}
if ( XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS(m_activity) ) {
items.add( getString( R.string.invite_choice_sms ) );
means.add( DlgClickNotify.InviteMeans.SMS );
@ -652,7 +652,7 @@ public class DlgDelegate {
items.add( getString( R.string.invite_choice_bt ) );
means.add( DlgClickNotify.InviteMeans.BLUETOOTH );
}
if ( XWPrefs.getNFCToSelfEnabled( m_activity )
if ( XWPrefs.getNFCToSelfEnabled( m_activity )
|| NFCUtils.nfcAvail( m_activity )[0] ) {
items.add( getString( R.string.invite_choice_nfc ) );
means.add( DlgClickNotify.InviteMeans.NFC );
@ -679,7 +679,7 @@ public class DlgDelegate {
sel[0] = view;
switch ( means.get(view) ) {
case CLIPBOARD:
String msg =
String msg =
getString( R.string.not_again_clip_expl_fmt,
getString(R.string.slmenu_copy_sel) );
showNotAgainDlgThen( msg, R.string.key_na_clip_expl );
@ -703,8 +703,8 @@ public class DlgDelegate {
Assert.assertTrue( Action.SKIP_CALLBACK != state.m_action );
int indx = sel[0];
if ( 0 <= indx ) {
m_clickCallback.inviteChoiceMade( state.m_action,
means.get(indx),
m_clickCallback.inviteChoiceMade( state.m_action,
means.get(indx),
state.m_params );
}
}
@ -751,14 +751,14 @@ public class DlgDelegate {
{
final View layout = LocUtils.inflate( m_activity, R.layout.confirm_sms );
DialogInterface.OnClickListener lstnr =
DialogInterface.OnClickListener lstnr =
new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
Spinner reasons = (Spinner)
layout.findViewById( R.id.confirm_sms_reasons );
boolean enabled = 0 < reasons.getSelectedItemPosition();
Assert.assertTrue( enabled );
m_clickCallback.dlgButtonClicked( state.m_action,
m_clickCallback.dlgButtonClicked( state.m_action,
AlertDialog.BUTTON_POSITIVE,
state.m_params );
}
@ -782,13 +782,13 @@ public class DlgDelegate {
button.setEnabled( enabled );
}
private void prepareEnableSMSDialog( final Dialog dialog )
private void prepareEnableSMSDialog( final Dialog dialog )
{
final Spinner reasons = (Spinner)
dialog.findViewById( R.id.confirm_sms_reasons );
OnItemSelectedListener onItemSel = new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent, View view,
OnItemSelectedListener onItemSel = new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent, View view,
int position, long id )
{
checkEnableButton( dialog, reasons );
@ -809,8 +809,8 @@ public class DlgDelegate {
checkNotAgainCheck( state, naView );
if ( Action.SKIP_CALLBACK != state.m_action ) {
m_clickCallback.dlgButtonClicked( state.m_action,
button,
m_clickCallback.dlgButtonClicked( state.m_action,
button,
state.m_params );
}
}
@ -822,7 +822,7 @@ public class DlgDelegate {
{
if ( null != naView && naView.getChecked() ) {
if ( 0 != state.m_prefsKey ) {
XWPrefs.setPrefsBoolean( m_activity, state.m_prefsKey,
XWPrefs.setPrefsBoolean( m_activity, state.m_prefsKey,
true );
} else if ( null != state.m_onNAChecked ) {
state.m_onNAChecked.run();
@ -830,7 +830,7 @@ public class DlgDelegate {
}
}
private Dialog setCallbackDismissListener( final Dialog dialog,
private Dialog setCallbackDismissListener( final Dialog dialog,
final DlgState state,
DlgID dlgID )
{
@ -840,8 +840,8 @@ public class DlgDelegate {
public void onDismiss( DialogInterface di ) {
dropState( state );
if ( Action.SKIP_CALLBACK != state.m_action ) {
m_clickCallback.dlgButtonClicked( state.m_action,
DISMISS_BUTTON,
m_clickCallback.dlgButtonClicked( state.m_action,
DISMISS_BUTTON,
state.m_params );
}
m_activity.removeDialog( id );
@ -865,7 +865,7 @@ public class DlgDelegate {
Assert.assertNotNull( state );
// Assert.assertTrue( state == m_dlgStates.get( state.m_id ) );
m_dlgStates.remove( state.m_id );
// DbgUtils.logf( "dropState: active dialogs now %d from %d ",
// DbgUtils.logf( "dropState: active dialogs now %d from %d ",
// m_dlgStates.size(), nDlgs );
}
@ -874,7 +874,7 @@ public class DlgDelegate {
// I'm getting serialization failures on devices pointing at
// DlgState but the code below says the object's fine (as it
// should be.) Just to have a record....
//
//
// Bundle bundle = new Bundle();
// DbgUtils.logf( "addState: testing serializable" );
// bundle.putSerializable( "foo", state );

View file

@ -47,7 +47,7 @@ public class DlgState implements Parcelable {
this( dlgID, msg, android.R.string.ok, action, prefsKey );
}
public DlgState( DlgID dlgID, String msg, int prefsKey, Action action,
public DlgState( DlgID dlgID, String msg, int prefsKey, Action action,
ActionPair more, Object[] params )
{
this( dlgID, msg, android.R.string.ok, action, prefsKey );
@ -55,20 +55,20 @@ public class DlgState implements Parcelable {
m_pair = more;
}
public DlgState( DlgID dlgID, String msg, int posButton,
public DlgState( DlgID dlgID, String msg, int posButton,
Action action, int prefsKey )
{
this( dlgID, msg, posButton, action, prefsKey, null );
}
public DlgState( DlgID dlgID, String msg, int posButton,
public DlgState( DlgID dlgID, String msg, int posButton,
Action action, int prefsKey, Object[] params )
{
this( dlgID, null, msg, posButton, android.R.string.cancel,
this( dlgID, null, msg, posButton, android.R.string.cancel,
action, prefsKey, params );
}
public DlgState( DlgID dlgID, Runnable onNA, String msg, int posButton, int negButton,
public DlgState( DlgID dlgID, Runnable onNA, String msg, int posButton, int negButton,
Action action, int prefsKey, Object[] params )
{
m_id = dlgID;

View file

@ -27,7 +27,7 @@ import android.view.View;
public class DrawSelDelegate {
private View m_view;
private Drawable m_origDrawable;
private static ColorDrawable s_selDrawable =
private static ColorDrawable s_selDrawable =
new ColorDrawable( XWApp.SEL_COLOR );
protected DrawSelDelegate( View view )

View file

@ -35,7 +35,7 @@ public class DualpaneDelegate extends DelegateBase {
}
@Override
protected void init( Bundle savedInstanceState )
protected void init( Bundle savedInstanceState )
{
}

View file

@ -27,14 +27,14 @@ import android.view.Window;
public class DwnldActivity extends XWActivity {
@Override
protected void onCreate( Bundle savedInstanceState )
protected void onCreate( Bundle savedInstanceState )
{
requestWindowFeature( Window.FEATURE_NO_TITLE );
requestWindowFeature( Window.FEATURE_LEFT_ICON );
getWindow().setFeatureDrawableResource( Window.FEATURE_LEFT_ICON,
R.drawable.icon48x48 );
DwnldDelegate dlgt =
DwnldDelegate dlgt =
new DwnldDelegate( this, savedInstanceState );
super.onCreate( savedInstanceState, dlgt );

View file

@ -89,7 +89,7 @@ public class DwnldDelegate extends ListDelegateBase {
private static Map<Uri,ListenerData> s_listeners =
new HashMap<Uri,ListenerData>();
private class DownloadFilesTask extends AsyncTask<Void, Void, Void>
private class DownloadFilesTask extends AsyncTask<Void, Void, Void>
implements DictUtils.DownProgListener {
private String m_savedDict = null;
private Uri m_uri = null;
@ -122,8 +122,8 @@ public class DwnldDelegate extends ListDelegateBase {
m_appFile = null;
try {
URI jUri = new URI( m_uri.getScheme(),
m_uri.getSchemeSpecificPart(),
URI jUri = new URI( m_uri.getScheme(),
m_uri.getSchemeSpecificPart(),
m_uri.getFragment() );
URLConnection conn = jUri.toURL().openConnection();
final int fileLen = conn.getContentLength();
@ -150,7 +150,7 @@ public class DwnldDelegate extends ListDelegateBase {
return null;
}
@Override
@Override
protected void onCancelled()
{
callListener( m_uri, false );
@ -160,9 +160,9 @@ public class DwnldDelegate extends ListDelegateBase {
protected void onPostExecute( Void unused )
{
if ( null != m_savedDict ) {
DictUtils.DictLoc loc =
DictUtils.DictLoc loc =
XWPrefs.getDefaultLoc( m_activity );
DictLangCache.inval( m_activity, m_savedDict,
DictLangCache.inval( m_activity, m_savedDict,
loc, true );
callListener( m_uri, true );
} else if ( null != m_appFile ) {
@ -196,7 +196,7 @@ public class DwnldDelegate extends ListDelegateBase {
});
}
private File saveToDownloads( InputStream is, String name,
private File saveToDownloads( InputStream is, String name,
DictUtils.DownProgListener dpl )
{
boolean success = false;
@ -271,7 +271,7 @@ public class DwnldDelegate extends ListDelegateBase {
m_views.add( item );
}
}
} else if ( (null != intent.getType()
} else if ( (null != intent.getType()
&& intent.getType().equals( "application/x-xwordsdict" ))
|| uri.toString().endsWith( XWConstants.DICT_EXTN ) ) {
item = (LinearLayout)inflate( R.layout.import_dict_item );
@ -296,9 +296,9 @@ public class DwnldDelegate extends ListDelegateBase {
for ( int ii = 0; ii < uris.length; ++ii ) {
String showName = basename( uris[ii].getPath() );
showName = DictUtils.removeDictExtn( showName );
String msg =
String msg =
getString( R.string.downloading_dict_fmt, showName );
dft = m_dfts.get( ii );
dft.setLabel( msg );
dft.execute();
@ -308,9 +308,9 @@ public class DwnldDelegate extends ListDelegateBase {
@Override
protected boolean handleBackPressed()
{
{
// cancel any tasks that remain
for ( Iterator<DownloadFilesTask> iter = m_dfts.iterator();
for ( Iterator<DownloadFilesTask> iter = m_dfts.iterator();
iter.hasNext(); ) {
DownloadFilesTask dft = iter.next();
dft.cancel( true );
@ -323,7 +323,7 @@ public class DwnldDelegate extends ListDelegateBase {
setListAdapter( new ImportListAdapter() );
}
private String saveDict( InputStream inputStream, String name,
private String saveDict( InputStream inputStream, String name,
DictUtils.DownProgListener dpl )
{
DictUtils.DictLoc loc = XWPrefs.getDefaultLoc( m_activity );
@ -345,7 +345,7 @@ public class DwnldDelegate extends ListDelegateBase {
return result;
}
private static void rememberListener( Uri uri, String name,
private static void rememberListener( Uri uri, String name,
DownloadFinishedListener lstnr )
{
ListenerData ld = new ListenerData( uri, name, lstnr );
@ -354,7 +354,7 @@ public class DwnldDelegate extends ListDelegateBase {
}
}
private static void callListener( Uri uri, boolean success )
private static void callListener( Uri uri, boolean success )
{
if ( null != uri ) {
ListenerData ld;
@ -375,16 +375,16 @@ public class DwnldDelegate extends ListDelegateBase {
}
}
public static void downloadDictInBack( Context context, String langName,
String name,
public static void downloadDictInBack( Context context, String langName,
String name,
DownloadFinishedListener lstnr )
{
Uri uri = Utils.makeDictUri( context, langName, name );
downloadDictInBack( context, uri, name, lstnr );
}
public static void downloadDictInBack( Context context, int lang,
String name,
public static void downloadDictInBack( Context context, int lang,
String name,
DownloadFinishedListener lstnr )
{
Uri uri = Utils.makeDictUri( context, lang, name );
@ -392,7 +392,7 @@ public class DwnldDelegate extends ListDelegateBase {
}
public static void downloadDictInBack( Context context, Uri uri,
String name,
String name,
DownloadFinishedListener lstnr )
{
Uri[] uris = new Uri[] { uri };
@ -401,7 +401,7 @@ public class DwnldDelegate extends ListDelegateBase {
}
public static void downloadDictsInBack( Context context, Uri[] uris,
String[] names,
String[] names,
DownloadFinishedListener lstnr )
{
if ( null != lstnr ) {

View file

@ -43,9 +43,9 @@ public class EditColorPreference extends DialogPreference {
private int m_curColor;
// m_updateText: prevent loop that resets edittext cursor
private boolean m_updateText = true;
private static final int m_seekbarIds[] = { R.id.seek_red, R.id.seek_green,
private static final int m_seekbarIds[] = { R.id.seek_red, R.id.seek_green,
R.id.seek_blue };
private static final int m_editIds[] = { R.id.edit_red, R.id.edit_green,
private static final int m_editIds[] = { R.id.edit_red, R.id.edit_green,
R.id.edit_blue };
private class SBCL implements SeekBar.OnSeekBarChangeListener {
@ -59,7 +59,7 @@ public class EditColorPreference extends DialogPreference {
m_editTxt = editTxt;
}
public void onProgressChanged( SeekBar seekBar, int progress,
public void onProgressChanged( SeekBar seekBar, int progress,
boolean fromUser )
{
if ( m_updateText ) {
@ -87,11 +87,11 @@ public class EditColorPreference extends DialogPreference {
{
}
public void beforeTextChanged( CharSequence s, int st, int cnt, int a )
public void beforeTextChanged( CharSequence s, int st, int cnt, int a )
{
}
public void onTextChanged( CharSequence s, int start,
public void onTextChanged( CharSequence s, int start,
int before, int count )
{
int val;
@ -110,7 +110,7 @@ public class EditColorPreference extends DialogPreference {
{
super( context, attrs );
m_context = context;
setWidgetLayoutResource( R.layout.color_display );
setDialogLayoutResource( R.layout.color_edit );
@ -134,9 +134,9 @@ public class EditColorPreference extends DialogPreference {
persistInt( (Integer)defaultValue );
}
}
@Override
protected void onBindView( View parent )
protected void onBindView( View parent )
{
super.onBindView( parent );
View sample = parent.findViewById( R.id.color_display_sample );
@ -156,11 +156,11 @@ public class EditColorPreference extends DialogPreference {
View sample = view.findViewById( R.id.color_edit_sample );
sample.setBackgroundColor( m_curColor );
}
@Override
protected void onPrepareDialogBuilder( AlertDialog.Builder builder )
{
DialogInterface.OnClickListener lstnr =
DialogInterface.OnClickListener lstnr =
new DialogInterface.OnClickListener() {
@Override
public void onClick( DialogInterface dialog, int which )
@ -179,7 +179,7 @@ public class EditColorPreference extends DialogPreference {
super.onPrepareDialogBuilder( builder );
}
private void setOneByte( View parent, int indx )
private void setOneByte( View parent, int indx )
{
int shift = 16 - (indx*8);
int byt = (m_curColor >> shift) & 0xFF;

View file

@ -42,7 +42,7 @@ public class ExpiringDelegate {
private static final long INTERVAL_SECS = 3 * 24 * 60 * 60;
// private static final long INTERVAL_SECS = 60 * 10; // for testing
private static boolean s_kitkat =
private static boolean s_kitkat =
19 <= Integer.valueOf( android.os.Build.VERSION.SDK );
private Context m_context;
@ -90,7 +90,7 @@ public class ExpiringDelegate {
}
}
DbgUtils.logdf( "ExpUpdater: ref had %d refs, now has %d expiringdelegate views",
DbgUtils.logdf( "ExpUpdater: ref had %d refs, now has %d expiringdelegate views",
sizeBefore, dlgts.size() );
for ( ExpiringDelegate dlgt : dlgts ) {
@ -100,7 +100,7 @@ public class ExpiringDelegate {
reschedule();
}
private void reschedule()
private void reschedule()
{
m_handler.postDelayed( this, INTERVAL_SECS * 1000 / 100 );
}
@ -130,8 +130,8 @@ public class ExpiringDelegate {
private static ExpUpdater s_updater;
static {
s_rect = new Rect();
s_paint = new Paint();
s_paint.setStyle(Paint.Style.STROKE);
s_paint = new Paint();
s_paint.setStyle(Paint.Style.STROKE);
s_paint.setStrokeWidth( 1 );
s_points = new float[4*6];
s_updater = new ExpUpdater();
@ -149,7 +149,7 @@ public class ExpiringDelegate {
s_updater.setHandler( handler );
}
public void configure( boolean haveTurn, boolean haveTurnLocal,
public void configure( boolean haveTurn, boolean haveTurnLocal,
long startSecs )
{
m_active = haveTurn;
@ -173,7 +173,7 @@ public class ExpiringDelegate {
m_dsdel.showSelected( m_selected );
}
public void onDraw( Canvas canvas )
public void onDraw( Canvas canvas )
{
if ( m_selected ) {
// do nothing; the drawable's set already
@ -194,14 +194,14 @@ public class ExpiringDelegate {
s_rect.left, s_rect.bottom - 1 );
// left horizontals
addPoints( 1, s_rect.left, s_rect.top,
addPoints( 1, s_rect.left, s_rect.top,
s_rect.left + redWidth, s_rect.top );
addPoints( 2, s_rect.left, s_rect.bottom - 1,
s_rect.left + redWidth,
s_rect.bottom - 1 );
// right horizontals
addPoints( 3, s_rect.left + redWidth, s_rect.top,
addPoints( 3, s_rect.left + redWidth, s_rect.top,
s_rect.right - 1, s_rect.top );
addPoints( 4, s_rect.left + redWidth, s_rect.bottom - 1,
s_rect.right - 1, s_rect.bottom - 1 );
@ -253,11 +253,11 @@ public class ExpiringDelegate {
Bitmap bm = Bitmap.createBitmap( 100, 1, Bitmap.Config.ARGB_8888 );
Canvas canvas = new Canvas(bm);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor( Color.RED );
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor( Color.RED );
canvas.drawRect( 0, 0, pct, 1, paint );
paint.setColor( Utils.TURN_COLOR );
paint.setColor( Utils.TURN_COLOR );
canvas.drawRect( pct, 0, 100, 1, paint );
return new BitmapDrawable( m_context.getResources(), bm );
}

View file

@ -32,7 +32,7 @@ public class ExpiringLinearLayout extends LinearLayout {
super( context, as );
}
public void setPct( Handler handler, boolean haveTurn,
public void setPct( Handler handler, boolean haveTurn,
boolean haveTurnLocal, long startSecs )
{
if ( null == m_delegate ) {
@ -49,7 +49,7 @@ public class ExpiringLinearLayout extends LinearLayout {
@Override
// not called unless setWillNotDraw( false ) called
protected void onDraw( Canvas canvas )
protected void onDraw( Canvas canvas )
{
super.onDraw( canvas );
if ( null != m_delegate ) {

View file

@ -35,7 +35,7 @@ class ExpiringTextView extends TextView {
m_context = context;
}
public void setPct( Handler handler, boolean haveTurn,
public void setPct( Handler handler, boolean haveTurn,
boolean haveTurnLocal, long startSecs )
{
ExpiringDelegate delegate = getDelegate();
@ -44,7 +44,7 @@ class ExpiringTextView extends TextView {
setPct( haveTurn, haveTurnLocal, startSecs );
}
public void setPct( boolean haveTurn, boolean haveTurnLocal,
public void setPct( boolean haveTurn, boolean haveTurnLocal,
long startSecs )
{
if ( null != m_delegate ) {
@ -53,7 +53,7 @@ class ExpiringTextView extends TextView {
}
@Override
protected void onDraw( Canvas canvas )
protected void onDraw( Canvas canvas )
{
super.onDraw( canvas );
if ( null != m_delegate ) {

View file

@ -42,7 +42,7 @@ public class FirstRunDialog {
view.setWebViewClient( new WebViewClient() {
private boolean m_loaded = false;
@Override
public boolean shouldOverrideUrlLoading( WebView view,
public boolean shouldOverrideUrlLoading( WebView view,
String url ) {
boolean result = false;
if ( url.startsWith("mailto:") ){

View file

@ -37,7 +37,7 @@
// import junit.framework.Assert;
// public class FragActivity extends FragmentActivity
// public class FragActivity extends FragmentActivity
// implements FragmentManager.OnBackStackChangedListener {
// private static final int MAX_PANES_LANDSCAPE = 3;
@ -54,7 +54,7 @@
// private Boolean m_isPortrait;
// @Override
// public void onCreate( Bundle savedInstanceState )
// public void onCreate( Bundle savedInstanceState )
// {
// s_this = this;
// super.onCreate( savedInstanceState );
@ -74,7 +74,7 @@
// }
// @Override
// public void onBackPressed()
// public void onBackPressed()
// {
// DbgUtils.logf( "FragActivity.onBackPressed()" );
// super.onBackPressed();
@ -165,8 +165,8 @@
// getSupportFragmentManager().popBackStack();
// }
// private void addFragmentImpl( Fragment fragment, Bundle bundle,
// Delegator parent )
// private void addFragmentImpl( Fragment fragment, Bundle bundle,
// Delegator parent )
// {
// fragment.setArguments( bundle );
// addFragmentImpl( fragment, parent );
@ -275,7 +275,7 @@
// {
// int result;
// int orientation = getResources().getConfiguration().orientation;
// if ( XWPrefs.getIsTablet( this )
// if ( XWPrefs.getIsTablet( this )
// && Configuration.ORIENTATION_LANDSCAPE == orientation ) {
// result = 2;
// } else {
@ -295,14 +295,14 @@
// addFragment( fragment, bundle, null );
// }
// public static void addFragment( Fragment fragment, Bundle bundle,
// Delegator parent )
// public static void addFragment( Fragment fragment, Bundle bundle,
// Delegator parent )
// {
// getThis().addFragmentImpl( fragment, bundle, parent );
// }
// public static void addFragmentForResult( Fragment fragment, Bundle bundle,
// RequestCode requestCode, Delegator parent )
// public static void addFragmentForResult( Fragment fragment, Bundle bundle,
// RequestCode requestCode, Delegator parent )
// {
// getThis().addFragmentImpl( fragment, bundle, parent );
// }

View file

@ -35,13 +35,13 @@ public class GCMIntentService extends GCMBaseIntentService {
}
@Override
protected void onError( Context context, String error )
protected void onError( Context context, String error )
{
DbgUtils.logdf("GCMIntentService.onError(%s)", error );
}
@Override
protected void onRegistered( Context context, String regId )
protected void onRegistered( Context context, String regId )
{
DbgUtils.logdf( "GCMIntentService.onRegistered(%s)", regId );
DevID.setGCMDevID( context, regId );
@ -49,7 +49,7 @@ public class GCMIntentService extends GCMBaseIntentService {
}
@Override
protected void onUnregistered( Context context, String regId )
protected void onUnregistered( Context context, String regId )
{
DbgUtils.logdf( "GCMIntentService.onUnregistered(%s)", regId );
DevID.clearGCMDevID( context );
@ -58,7 +58,7 @@ public class GCMIntentService extends GCMBaseIntentService {
}
@Override
protected void onMessage( Context context, Intent intent )
protected void onMessage( Context context, Intent intent )
{
DbgUtils.logdf( "GCMIntentService.onMessage()" );
notifyRelayService( context, true );
@ -108,7 +108,7 @@ public class GCMIntentService extends GCMBaseIntentService {
Intent alertIntent = GamesListDelegate
.makeAlertIntent( this, value );
int code = value.hashCode() ^ title.hashCode();
Utils.postNotification( context, alertIntent, title,
Utils.postNotification( context, alertIntent, title,
teaser, code );
}
}

View file

@ -27,7 +27,7 @@ public class GameConfigActivity extends XWActivity {
@Override
public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState,
super.onCreate( savedInstanceState,
new GameConfigDelegate( this, savedInstanceState ) );
} // onCreate
}

View file

@ -140,12 +140,12 @@ public class GameConfigDelegate extends DelegateBase
public RemoteChoices() { super( m_gi.nPlayers ); }
public Object getItem( int position) { return m_gi.players[position]; }
public View getView( final int position, View convertView,
public View getView( final int position, View convertView,
ViewGroup parent ) {
OnCheckedChangeListener lstnr;
lstnr = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged( CompoundButton buttonView,
public void onCheckedChanged( CompoundButton buttonView,
boolean isChecked )
{
m_gi.players[position].isLocal = !isChecked;
@ -178,8 +178,8 @@ public class GameConfigDelegate extends DelegateBase
.setView(playerEditView)
.setPositiveButton( android.R.string.ok,
new DialogInterface.OnClickListener() {
public void
onClick( DialogInterface dlg,
public void
onClick( DialogInterface dlg,
int button ) {
getPlayerSettings( dlg );
loadPlayersList();
@ -197,7 +197,7 @@ public class GameConfigDelegate extends DelegateBase
// .inflate( layoutForDlg(id), null ))
// .setPositiveButton( android.R.string.ok,
// new DialogInterface.OnClickListener() {
// public void onClick( DialogInterface dlg,
// public void onClick( DialogInterface dlg,
// int whichButton ) {
// getRoleSettings();
// }
@ -208,7 +208,7 @@ public class GameConfigDelegate extends DelegateBase
case FORCE_REMOTE:
dlpos = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int whichButton ) {
loadPlayersList();
}
@ -218,10 +218,10 @@ public class GameConfigDelegate extends DelegateBase
.setView( inflate( layoutForDlg(dlgID) ) )
.setPositiveButton( android.R.string.ok, dlpos )
.create();
DialogInterface.OnDismissListener dismiss =
DialogInterface.OnDismissListener dismiss =
new DialogInterface.OnDismissListener() {
@Override
public void onDismiss( DialogInterface di )
public void onDismiss( DialogInterface di )
{
if ( m_gi.forceRemoteConsistent() ) {
showToast( R.string.forced_consistent );
@ -234,7 +234,7 @@ public class GameConfigDelegate extends DelegateBase
case CONFIRM_CHANGE_PLAY:
case CONFIRM_CHANGE:
dlpos = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int whichButton ) {
applyChanges( true );
if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) {
@ -248,7 +248,7 @@ public class GameConfigDelegate extends DelegateBase
.setPositiveButton( R.string.button_save, dlpos );
if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) {
dlpos = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg,
public void onClick( DialogInterface dlg,
int whichButton ) {
launchGame();
}
@ -267,7 +267,7 @@ public class GameConfigDelegate extends DelegateBase
});
break;
case NO_NAME_FOUND:
String langName = DictLangCache.getLangName( m_activity,
String langName = DictLangCache.getLangName( m_activity,
m_gi.dictLang );
String msg = getString( R.string.no_name_found_fmt,
m_gi.nPlayers, xlateLang( langName ) );
@ -285,7 +285,7 @@ public class GameConfigDelegate extends DelegateBase
.findViewById(R.id.default_check);
cb.setVisibility( View.VISIBLE );
final DialogInterface.OnClickListener lstnr =
final DialogInterface.OnClickListener lstnr =
new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int button ) {
m_conTypes = items.getTypes();
@ -300,7 +300,7 @@ public class GameConfigDelegate extends DelegateBase
showHideRelayStuff();
}
};
dialog = makeAlertBuilder()
.setTitle( R.string.title_addrs_pref )
.setView( layout )
@ -315,7 +315,7 @@ public class GameConfigDelegate extends DelegateBase
@Override
protected void prepareDialog( DlgID dlgID, Dialog dialog )
{
{
switch ( dlgID ) {
case PLAYER_EDIT:
setPlayerSettings( dialog );
@ -339,13 +339,13 @@ public class GameConfigDelegate extends DelegateBase
public void warnDisabled( CommsConnType typ ) {
switch( typ ) {
case COMMS_CONN_SMS:
showConfirmThen( R.string.warn_sms_disabled,
showConfirmThen( R.string.warn_sms_disabled,
R.string.button_enable_sms,
R.string.button_later,
Action.ENABLE_SMS_ASK );
break;
case COMMS_CONN_BT:
showConfirmThen( R.string.warn_bt_disabled,
showConfirmThen( R.string.warn_bt_disabled,
R.string.button_enable_bt,
R.string.button_later,
Action.ENABLE_BT_DO );
@ -406,9 +406,9 @@ public class GameConfigDelegate extends DelegateBase
if ( isServer ) {
OnCheckedChangeListener lstnr =
new OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton buttonView,
public void onCheckedChanged( CompoundButton buttonView,
boolean checked ) {
localSet.setVisibility( checked ?
localSet.setVisibility( checked ?
View.GONE : View.VISIBLE );
}
};
@ -422,7 +422,7 @@ public class GameConfigDelegate extends DelegateBase
check = (CheckBox)dialog.findViewById( R.id.robot_check );
OnCheckedChangeListener lstnr =
new OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton buttonView,
public void onCheckedChanged( CompoundButton buttonView,
boolean checked ) {
View view = dialog.findViewById( R.id.password_set );
view.setVisibility( checked ? View.GONE : View.VISIBLE );
@ -496,9 +496,9 @@ public class GameConfigDelegate extends DelegateBase
// This should only be in for one ship! Remove it and all associated
// strings immediately after shipping it.
if ( !Utils.onFirstVersion( m_activity )
if ( !Utils.onFirstVersion( m_activity )
&& !XWPrefs.getPublicRoomsEnabled( m_activity ) ) {
ActionPair pair = new ActionPair( Action.SET_ENABLE_PUBLIC,
ActionPair pair = new ActionPair( Action.SET_ENABLE_PUBLIC,
R.string.enable_pubroom_title );
showNotAgainDlgThen( R.string.not_again_enablepublic,
R.string.key_notagain_enablepublic,
@ -519,7 +519,7 @@ public class GameConfigDelegate extends DelegateBase
super.onPause();
}
protected void onSaveInstanceState( Bundle outState )
protected void onSaveInstanceState( Bundle outState )
{
outState.putInt( WHICH_PLAYER, m_whichPlayer );
}
@ -561,7 +561,7 @@ public class GameConfigDelegate extends DelegateBase
if ( m_gameStarted ) {
if ( null == m_gameLockedCheck ) {
m_gameLockedCheck =
m_gameLockedCheck =
(CheckBox)findViewById( R.id.game_locked_check );
m_gameLockedCheck.setVisibility( View.VISIBLE );
m_gameLockedCheck.setOnClickListener( this );
@ -580,7 +580,7 @@ public class GameConfigDelegate extends DelegateBase
} else if ( !localOnlyGame() ) {
String relayName = XWPrefs.getDefaultRelayHost( m_activity );
int relayPort = XWPrefs.getDefaultRelayPort( m_activity );
XwJNI.comms_getInitialAddr( m_carOrig, relayName,
XwJNI.comms_getInitialAddr( m_carOrig, relayName,
relayPort );
}
m_conTypes = (CommsConnTypeSet)m_carOrig.conTypes.clone();
@ -613,13 +613,13 @@ public class GameConfigDelegate extends DelegateBase
setChecked( R.id.hints_allowed, !m_gi.hintsNotAllowed );
setChecked( R.id.pick_faceup, m_gi.allowPickTiles );
setInt( R.id.timer_minutes_edit,
setInt( R.id.timer_minutes_edit,
m_gi.gameSeconds/60/m_gi.nPlayers );
CheckBox check = (CheckBox)findViewById( R.id.use_timer );
OnCheckedChangeListener lstnr =
new OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton buttonView,
public void onCheckedChanged( CompoundButton buttonView,
boolean checked ) {
View view = findViewById( R.id.timer_set );
view.setVisibility( checked ? View.VISIBLE : View.GONE );
@ -689,7 +689,7 @@ public class GameConfigDelegate extends DelegateBase
callSuper = true;
break;
}
} else {
} else {
callSuper = true;
}
@ -698,7 +698,7 @@ public class GameConfigDelegate extends DelegateBase
}
}
public void onClick( View view )
public void onClick( View view )
{
if ( isFinishing() ) {
// do nothing; we're on the way out
@ -714,7 +714,7 @@ public class GameConfigDelegate extends DelegateBase
} else if ( m_joinPublicCheck == view ) {
adjustConnectStuff();
} else if ( m_gameLockedCheck == view ) {
showNotAgainDlgThen( R.string.not_again_unlock,
showNotAgainDlgThen( R.string.not_again_unlock,
R.string.key_notagain_unlock,
Action.LOCKED_CHANGE_ACTION );
} else if ( m_refreshRoomsButton == view ) {
@ -729,7 +729,7 @@ public class GameConfigDelegate extends DelegateBase
saveChanges();
if ( !localOnlyGame() && 0 == m_conTypes.size() ) {
showConfirmThen( R.string.config_no_connvia,
R.string.button_discard,
R.string.button_discard,
R.string.button_edit,
Action.DELETE_AND_EXIT );
} else if ( m_forResult ) {
@ -738,10 +738,10 @@ public class GameConfigDelegate extends DelegateBase
intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_rowid );
setResult( Activity.RESULT_OK, intent );
finish();
} else if ( !m_gameStarted ) { // no confirm needed
} else if ( !m_gameStarted ) { // no confirm needed
applyChanges( true );
launchGame();
} else if ( m_giOrig.changesMatter(m_gi)
} else if ( m_giOrig.changesMatter(m_gi)
|| m_carOrig.changesMatter(m_car) ) {
showDialog( DlgID.CONFIRM_CHANGE_PLAY );
} else {
@ -763,9 +763,9 @@ public class GameConfigDelegate extends DelegateBase
deleteGame();
} else {
saveChanges();
if ( !m_gameStarted ) { // no confirm needed
if ( !m_gameStarted ) { // no confirm needed
applyChanges( true );
} else if ( m_giOrig.changesMatter(m_gi)
} else if ( m_giOrig.changesMatter(m_gi)
|| m_carOrig.changesMatter(m_car) ) {
showDialog( DlgID.CONFIRM_CHANGE );
consumed = true; // don't dismiss activity yet!
@ -799,7 +799,7 @@ public class GameConfigDelegate extends DelegateBase
showDialog( DlgID.PLAYER_EDIT );
}
};
boolean localGame = localOnlyGame();
boolean unlocked = null == m_gameLockedCheck
|| !m_gameLockedCheck.isChecked();
@ -845,20 +845,20 @@ public class GameConfigDelegate extends DelegateBase
{
if ( null != dictsSpinner ) {
String langName = DictLangCache.getLangName( m_activity, lang );
dictsSpinner.setPrompt( getString( R.string.dicts_list_prompt_fmt,
dictsSpinner.setPrompt( getString( R.string.dicts_list_prompt_fmt,
langName ) );
OnItemSelectedListener onSel =
OnItemSelectedListener onSel =
new OnItemSelectedListener() {
@Override
public void onItemSelected( AdapterView<?> parentView,
View selectedItemView,
public void onItemSelected( AdapterView<?> parentView,
View selectedItemView,
int position, long id ) {
String chosen =
String chosen =
(String)parentView.getItemAtPosition( position );
if ( chosen.equals( m_browseText ) ) {
DictsDelegate.downloadForResult( m_activity,
DictsDelegate.downloadForResult( m_activity,
RequestCode.REQUEST_DICT,
m_gi.dictLang );
}
@ -868,7 +868,7 @@ public class GameConfigDelegate extends DelegateBase
public void onNothingSelected(AdapterView<?> parentView) {}
};
ArrayAdapter<String> adapter =
ArrayAdapter<String> adapter =
DictLangCache.getDictsAdapter( m_activity, lang );
configSpinnerWDownload( dictsSpinner, adapter, onSel, curDict );
@ -882,17 +882,17 @@ public class GameConfigDelegate extends DelegateBase
final LangsArrayAdapter adapter = DictLangCache.getLangsAdapter( m_activity );
OnItemSelectedListener onSel =
OnItemSelectedListener onSel =
new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView,
View selectedItemView,
public void onItemSelected(AdapterView<?> parentView,
View selectedItemView,
int position, long id ) {
if ( ! isFinishing() ) { // not on the way out?
String chosen =
String chosen =
(String)parentView.getItemAtPosition( position );
if ( chosen.equals( m_browseText ) ) {
DictsDelegate.downloadForResult( m_activity,
DictsDelegate.downloadForResult( m_activity,
RequestCode
.REQUEST_LANG_GC );
} else {
@ -918,7 +918,7 @@ public class GameConfigDelegate extends DelegateBase
configDictSpinner( m_dictSpinner, m_gi.dictLang, m_gi.dictName );
}
private void configSpinnerWDownload( Spinner spinner,
private void configSpinnerWDownload( Spinner spinner,
ArrayAdapter adapter,
OnItemSelectedListener onSel,
String curSel )
@ -972,7 +972,7 @@ public class GameConfigDelegate extends DelegateBase
setting = 2;
break;
default:
DbgUtils.logf( "setSmartnessSpinner got %d from getRobotSmartness()",
DbgUtils.logf( "setSmartnessSpinner got %d from getRobotSmartness()",
m_gi.getRobotSmartness() );
Assert.fail();
}
@ -1021,7 +1021,7 @@ public class GameConfigDelegate extends DelegateBase
} else {
int remoteCount = m_gi.remoteCount();
label = getString( R.string.players_label_host_fmt,
m_gi.nPlayers - remoteCount,
m_gi.nPlayers - remoteCount,
remoteCount );
}
((TextView)findViewById( R.id.players_label )).setText( label );
@ -1062,8 +1062,8 @@ public class GameConfigDelegate extends DelegateBase
}
}
}
private int layoutForDlg( DlgID dlgID )
private int layoutForDlg( DlgID dlgID )
{
switch( dlgID ) {
// case ROLE_EDIT_RELAY:
@ -1079,7 +1079,7 @@ public class GameConfigDelegate extends DelegateBase
return 0;
}
// private int titleForDlg( int id )
// private int titleForDlg( int id )
// {
// switch( id ) {
// // case ROLE_EDIT_RELAY:
@ -1127,7 +1127,7 @@ public class GameConfigDelegate extends DelegateBase
m_gi.hintsNotAllowed = !getChecked( R.id.hints_allowed );
m_gi.allowPickTiles = getChecked( R.id.pick_faceup );
m_gi.timerEnabled = getChecked( R.id.use_timer );
m_gi.gameSeconds =
m_gi.gameSeconds =
60 * m_gi.nPlayers * getInt( R.id.timer_minutes_edit );
int position = m_phoniesSpinner.getSelectedItemPosition();
@ -1141,7 +1141,7 @@ public class GameConfigDelegate extends DelegateBase
if ( m_conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
m_car.ip_relay_seeksPublicRoom = m_joinPublicCheck.isChecked();
m_car.ip_relay_advertiseRoom =
m_car.ip_relay_advertiseRoom =
getChecked( R.id.advertise_new_room_check );
if ( m_car.ip_relay_seeksPublicRoom ) {
SpinnerAdapter adapter = m_roomChoose.getAdapter();
@ -1163,7 +1163,7 @@ public class GameConfigDelegate extends DelegateBase
{
if ( !isFinishing() ) {
GameLock gameLock = new GameLock( m_rowid, true ).lock();
GameUtils.applyChanges( m_activity, m_gi, m_car, gameLock,
GameUtils.applyChanges( m_activity, m_gi, m_car, gameLock,
forceNew );
DBUtils.saveThumbnail( m_activity, gameLock, null ); // clear it
gameLock.unlock();
@ -1174,7 +1174,7 @@ public class GameConfigDelegate extends DelegateBase
{
if ( m_conTypes.contains( CommsConnType.COMMS_CONN_RELAY )
&& 0 == m_car.ip_relay_invite.length() ) {
showOKOnlyDialog( R.string.no_empty_rooms );
showOKOnlyDialog( R.string.no_empty_rooms );
} else {
GameUtils.launchGameAndFinish( getDelegator(), m_rowid );
}
@ -1183,7 +1183,7 @@ public class GameConfigDelegate extends DelegateBase
private void refreshNames()
{
if ( !m_isLocked ) {
new RefreshNamesTask( m_activity, this, m_gi.dictLang,
new RefreshNamesTask( m_activity, this, m_gi.dictLang,
m_gi.nPlayers, m_roomChoose ).execute();
}
}
@ -1205,14 +1205,14 @@ public class GameConfigDelegate extends DelegateBase
return DeviceRole.SERVER_STANDALONE == m_giOrig.serverRole;
}
public static void editForResult( Delegator delegator,
RequestCode requestCode,
public static void editForResult( Delegator delegator,
RequestCode requestCode,
long rowID )
{
Bundle bundle = new Bundle();
bundle.putLong( GameUtils.INTENT_KEY_ROWID, rowID );
bundle.putBoolean( INTENT_FORRESULT_ROWID, true );
if ( false && delegator.inDPMode() ) {
delegator.addFragmentForResult( new GameConfigFrag(), bundle, requestCode );
} else {
@ -1241,7 +1241,7 @@ public class GameConfigDelegate extends DelegateBase
boolean publicEnabled = XWPrefs.getPublicRoomsEnabled( m_activity );
int vis = publicEnabled ? View.VISIBLE : View.GONE;
if ( reset || null == m_joinPublicCheck ) {
m_joinPublicCheck =
m_joinPublicCheck =
(CheckBox)findViewById(R.id.join_public_room_check);
m_joinPublicCheck.setVisibility( vis );
@ -1252,18 +1252,18 @@ public class GameConfigDelegate extends DelegateBase
m_joinPublicCheck.setOnClickListener( this );
m_joinPublicCheck.setChecked( m_car.ip_relay_seeksPublicRoom );
advertise.setChecked( m_car.ip_relay_advertiseRoom );
m_publicRoomsSet =
m_publicRoomsSet =
(LinearLayout)findViewById(R.id.public_rooms_set );
m_privateRoomsSet =
m_privateRoomsSet =
(LinearLayout)findViewById(R.id.private_rooms_set );
}
setText( R.id.room_edit, m_car.ip_relay_invite );
m_roomChoose = (Spinner)findViewById( R.id.room_spinner );
m_roomChoose.setVisibility( vis );
m_refreshRoomsButton =
m_refreshRoomsButton =
(ImageButton)findViewById( R.id.refresh_button );
m_refreshRoomsButton.setVisibility( vis );
m_refreshRoomsButton.setOnClickListener( this );

View file

@ -31,7 +31,7 @@ import android.widget.TextView;
import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
import org.eehouse.android.xw4.loc.LocUtils;
public class GameListGroup extends ExpiringLinearLayout
public class GameListGroup extends ExpiringLinearLayout
implements SelectableItem.LongClickHandler,
View.OnClickListener,
View.OnLongClickListener
@ -81,7 +81,7 @@ public class GameListGroup extends ExpiringLinearLayout
return result;
}
public GameListGroup( Context cx, AttributeSet as )
public GameListGroup( Context cx, AttributeSet as )
{
super( cx, as );
}
@ -137,7 +137,7 @@ public class GameListGroup extends ExpiringLinearLayout
//////////////////////////////////////////////////
// View.OnLongClickListener interface
//////////////////////////////////////////////////
public boolean onLongClick( View view )
public boolean onLongClick( View view )
{
boolean handled = ! XWApp.CONTEXT_MENUS_ENABLED;
if ( handled ) {
@ -149,7 +149,7 @@ public class GameListGroup extends ExpiringLinearLayout
//////////////////////////////////////////////////
// View.OnClickListener interface
//////////////////////////////////////////////////
public void onClick( View view )
public void onClick( View view )
{
if ( 0 < m_nGames ) {
m_expanded = !m_expanded;
@ -161,7 +161,7 @@ public class GameListGroup extends ExpiringLinearLayout
private void setButton()
{
if ( null != m_expandButton ) {
m_expandButton.setVisibility( 0 == m_nGames ?
m_expandButton.setVisibility( 0 == m_nGames ?
View.GONE : View.VISIBLE );
m_expandButton.setImageResource( m_expanded ?
R.drawable.expander_ic_maximized :

View file

@ -48,11 +48,11 @@ import org.eehouse.android.xw4.jni.GameSummary;
import org.eehouse.android.xw4.jni.JNIThread;
import org.eehouse.android.xw4.loc.LocUtils;
public class GameListItem extends LinearLayout
public class GameListItem extends LinearLayout
implements View.OnClickListener, SelectableItem.LongClickHandler {
private static final int SUMMARY_WAIT_MSECS = 1000;
private static HashSet<Long> s_invalRows = new HashSet<Long>();
private Activity m_activity;
@ -81,7 +81,7 @@ public class GameListItem extends LinearLayout
private boolean m_selected = false;
private DrawSelDelegate m_dsdel;
public GameListItem( Context cx, AttributeSet as )
public GameListItem( Context cx, AttributeSet as )
{
super( cx, as );
m_context = cx;
@ -111,7 +111,7 @@ public class GameListItem extends LinearLayout
return m_summary;
}
private void init( Handler handler, long rowid, int fieldID,
private void init( Handler handler, long rowid, int fieldID,
SelectableItem cb )
{
m_handler = handler;
@ -149,7 +149,7 @@ public class GameListItem extends LinearLayout
}
@Override
protected void onDraw( Canvas canvas )
protected void onDraw( Canvas canvas )
{
super.onDraw( canvas );
if ( DBUtils.ROWID_NOTFOUND != m_rowid ) {
@ -228,7 +228,7 @@ public class GameListItem extends LinearLayout
}
m_name.setBackgroundColor( android.R.color.transparent );
m_name.setPct( m_handler, m_haveTurn && !m_expanded,
m_name.setPct( m_handler, m_haveTurn && !m_expanded,
m_haveTurnLocal, m_lastMoveTime );
}
@ -251,8 +251,8 @@ public class GameListItem extends LinearLayout
value = String.format( "%d", m_summary.nPacketsPending );
break;
case R.string.game_summary_field_language:
value =
DictLangCache.getLangName( m_context,
value =
DictLangCache.getLangName( m_context,
m_summary.dictLang );
value = LocUtils.xlateLang( m_context, value, true );
break;
@ -266,12 +266,12 @@ public class GameListItem extends LinearLayout
String name = GameUtils.getName( m_context, m_rowid );
if ( null != value ) {
value = LocUtils.getString( m_context, R.string.str_game_name_fmt,
value = LocUtils.getString( m_context, R.string.str_game_name_fmt,
name, value );
} else {
value = name;
}
m_name.setText( value );
}
return state;
@ -300,7 +300,7 @@ public class GameListItem extends LinearLayout
haveALocalTurn = true;
}
}
tmp.setPct( m_handler, thisHasTurn, isLocal[0],
tmp.setPct( m_handler, thisHasTurn, isLocal[0],
summary.lastMoveTime );
m_list.addView( tmp, ii );
}
@ -309,7 +309,7 @@ public class GameListItem extends LinearLayout
long lastMoveTime = summary.lastMoveTime;
lastMoveTime *= 1000;
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT,
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT,
DateFormat.SHORT );
m_modTime.setText( df.format( new Date( lastMoveTime ) ) );
@ -330,7 +330,7 @@ public class GameListItem extends LinearLayout
m_role.setVisibility( View.GONE );
}
update( expanded, summary.lastMoveTime, haveATurn,
update( expanded, summary.lastMoveTime, haveATurn,
haveALocalTurn );
}
}
@ -352,7 +352,7 @@ public class GameListItem extends LinearLayout
private class LoadItemTask extends AsyncTask<Void, Void, GameSummary> {
@Override
protected GameSummary doInBackground( Void... unused )
protected GameSummary doInBackground( Void... unused )
{
return DBUtils.getSummary( m_context, m_rowid, SUMMARY_WAIT_MSECS );
} // doInBackground
@ -365,7 +365,7 @@ public class GameListItem extends LinearLayout
// Try again. Maybe it's open
JNIThread thread = JNIThread.getRetained( m_rowid );
if ( null != thread ) {
summary = DBUtils.getSummary( m_context,
summary = DBUtils.getSummary( m_context,
thread.getLock() );
thread.release();
}
@ -380,7 +380,7 @@ public class GameListItem extends LinearLayout
setLoaded( null != m_summary );
if ( null == summary ) {
m_viewUnloaded
.setText( LocUtils.getString( m_context,
.setText( LocUtils.getString( m_context,
R.string.summary_busy ) );
}
synchronized( s_invalRows ) {
@ -391,14 +391,14 @@ public class GameListItem extends LinearLayout
} // class LoadItemTask
public static GameListItem makeForRow( Context context, View convertView,
long rowid, Handler handler,
long rowid, Handler handler,
int fieldID, SelectableItem cb )
{
GameListItem result;
if ( null != convertView && convertView instanceof GameListItem ) {
result = (GameListItem)convertView;
} else {
result = (GameListItem)LocUtils.inflate( context,
result = (GameListItem)LocUtils.inflate( context,
R.layout.game_list_item );
result.findViews();
}
@ -406,7 +406,7 @@ public class GameListItem extends LinearLayout
return result;
}
public static void inval( long rowid )
public static void inval( long rowid )
{
synchronized( s_invalRows ) {
s_invalRows.add( rowid );

View file

@ -44,10 +44,10 @@ public class GameLock {
public static class GameLockedException extends RuntimeException {}
private static HashMap<Long, GameLock>
private static HashMap<Long, GameLock>
s_locks = new HashMap<Long,GameLock>();
public GameLock( long rowid, boolean isForWrite )
public GameLock( long rowid, boolean isForWrite )
{
Assert.assertTrue( DBUtils.ROWID_NOTFOUND != rowid );
m_rowid = rowid;
@ -78,7 +78,7 @@ public class GameLock {
s_locks.put( m_rowid, this );
++m_lockCount;
gotIt = true;
if ( DEBUG_LOCKS ) {
StackTraceElement[] trace
= Thread.currentThread().getStackTrace();
@ -94,17 +94,17 @@ public class GameLock {
gotIt = true;
owner = null;
} else if ( DEBUG_LOCKS ) {
DbgUtils.logf( "tryLock(): rowid %d already held by lock %H",
DbgUtils.logf( "tryLock(): rowid %d already held by lock %H",
m_rowid, owner );
}
}
if ( DEBUG_LOCKS ) {
DbgUtils.logf( "GameLock.tryLock %H (rowid=%d) => %b",
DbgUtils.logf( "GameLock.tryLock %H (rowid=%d) => %b",
this, m_rowid, gotIt );
}
return owner;
}
// Wait forever (but may assert if too long)
public GameLock lock()
{
@ -120,7 +120,7 @@ public class GameLock {
long sleptTime = 0;
if ( DEBUG_LOCKS ) {
DbgUtils.logf( "lock %H (rowid:%d, maxMillis=%d)", this, m_rowid,
DbgUtils.logf( "lock %H (rowid:%d, maxMillis=%d)", this, m_rowid,
maxMillis );
}
@ -180,13 +180,13 @@ public class GameLock {
--m_lockCount;
if ( DEBUG_LOCKS ) {
DbgUtils.logf( "GameLock.unlock: this: %H (rowid:%d) unlocked",
DbgUtils.logf( "GameLock.unlock: this: %H (rowid:%d) unlocked",
this, m_rowid );
}
}
}
public long getRowid()
public long getRowid()
{
return m_rowid;
}

View file

@ -101,7 +101,7 @@ public class GameUtils {
* Open an existing game, and use its gi and comms addr as the
* basis for a new one.
*/
public static GameLock resetGame( Context context, GameLock lockSrc,
public static GameLock resetGame( Context context, GameLock lockSrc,
GameLock lockDest, boolean juggle )
{
CurGameInfo gi = new CurGameInfo( context );
@ -112,7 +112,7 @@ public class GameUtils {
GamePtr gamePtr = loadMakeGame( context, gi, lockSrc );
String[] dictNames = gi.dictNames();
DictUtils.DictPairs pairs = DictUtils.openDicts( context, dictNames );
if ( XwJNI.game_hasComms( gamePtr ) ) {
addr = new CommsAddrRec();
XwJNI.comms_getAddr( gamePtr, addr );
@ -123,12 +123,12 @@ public class GameUtils {
}
}
gamePtr.release();
gamePtr = XwJNI.initJNI();
XwJNI.game_makeNewGame( gamePtr, gi, JNIUtilsImpl.get( context ),
XwJNI.game_makeNewGame( gamePtr, gi, JNIUtilsImpl.get( context ),
CommonPrefs.get( context ), dictNames,
pairs.m_bytes, pairs.m_paths, gi.langName() );
if ( juggle ) {
gi.juggle();
}
@ -169,7 +169,7 @@ public class GameUtils {
int result = GameSummary.MSG_FLAGS_NONE;
if ( feedImpl.m_gotChat ) {
result |= GameSummary.MSG_FLAGS_CHAT;
}
}
if ( feedImpl.m_gotMsg ) {
result |= GameSummary.MSG_FLAGS_TURN;
}
@ -179,9 +179,9 @@ public class GameUtils {
return result;
}
private static GameSummary summarizeAndClose( Context context,
private static GameSummary summarizeAndClose( Context context,
GameLock lock,
GamePtr gamePtr,
GamePtr gamePtr,
CurGameInfo gi )
{
GameSummary summary = new GameSummary( context, gi );
@ -227,7 +227,7 @@ public class GameUtils {
DBUtils.deleteGame( context, lock );
}
public static boolean deleteGame( Context context, long rowid,
public static boolean deleteGame( Context context, long rowid,
boolean informNow )
{
boolean success;
@ -274,20 +274,20 @@ public class GameUtils {
return LocUtils.getString( context, R.string.game_fmt, count );
}
public static GamePtr loadMakeGame( Context context, CurGameInfo gi,
public static GamePtr loadMakeGame( Context context, CurGameInfo gi,
TransportProcs tp, GameLock lock )
{
return loadMakeGame( context, gi, null, tp, lock );
}
public static GamePtr loadMakeGame( Context context, CurGameInfo gi,
public static GamePtr loadMakeGame( Context context, CurGameInfo gi,
GameLock lock )
{
return loadMakeGame( context, gi, null, null, lock );
}
public static GamePtr loadMakeGame( Context context, CurGameInfo gi,
UtilCtxt util, TransportProcs tp,
public static GamePtr loadMakeGame( Context context, CurGameInfo gi,
UtilCtxt util, TransportProcs tp,
GameLock lock )
{
GamePtr gamePtr = null;
@ -300,23 +300,23 @@ public class GameUtils {
String[] dictNames = gi.dictNames();
DictUtils.DictPairs pairs = DictUtils.openDicts( context, dictNames );
if ( pairs.anyMissing( dictNames ) ) {
DbgUtils.logf( "loadMakeGame() failing: dicts %s unavailable",
DbgUtils.logf( "loadMakeGame() failing: dicts %s unavailable",
TextUtils.join( ",", dictNames ) );
} else {
gamePtr = XwJNI.initJNI( lock.getRowid() );
String langName = gi.langName();
boolean madeGame =
XwJNI.game_makeFromStream( gamePtr, stream, gi,
dictNames, pairs.m_bytes,
boolean madeGame =
XwJNI.game_makeFromStream( gamePtr, stream, gi,
dictNames, pairs.m_bytes,
pairs.m_paths, langName,
util, JNIUtilsImpl.get( context ),
util, JNIUtilsImpl.get( context ),
CommonPrefs.get(context),
tp);
if ( !madeGame ) {
XwJNI.game_makeNewGame( gamePtr, gi, JNIUtilsImpl.get(context),
XwJNI.game_makeNewGame( gamePtr, gi, JNIUtilsImpl.get(context),
CommonPrefs.get(context), dictNames,
pairs.m_bytes, pairs.m_paths,
pairs.m_bytes, pairs.m_paths,
langName );
}
}
@ -341,7 +341,7 @@ public class GameUtils {
return thumb;
}
public static Bitmap takeSnapshot( Context context, GamePtr gamePtr,
public static Bitmap takeSnapshot( Context context, GamePtr gamePtr,
CurGameInfo gi )
{
Bitmap thumb = null;
@ -354,8 +354,8 @@ public class GameUtils {
if ( null == s_minScreen ) {
if ( context instanceof Activity ) {
Activity activity = (Activity)context;
Display display =
activity.getWindowManager().getDefaultDisplay();
Display display =
activity.getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
s_minScreen = new Integer( Math.min( width, height ) );
@ -365,7 +365,7 @@ public class GameUtils {
int dim = s_minScreen * pct / 100;
int size = dim - (dim % nCols);
thumb = Bitmap.createBitmap( size, size,
thumb = Bitmap.createBitmap( size, size,
Bitmap.Config.ARGB_8888 );
XwJNI.board_figureLayout( gamePtr, gi, 0, 0, size, size,
@ -397,7 +397,7 @@ public class GameUtils {
}
if ( force ) {
HashMap<Long,CommsConnTypeSet> games =
HashMap<Long,CommsConnTypeSet> games =
DBUtils.getGamesWithSendsPending( context );
if ( 0 < games.size() ) {
new ResendTask( context, games, filter, showUI ).execute();
@ -410,7 +410,7 @@ public class GameUtils {
}
}
public static long saveGame( Context context, GamePtr gamePtr,
public static long saveGame( Context context, GamePtr gamePtr,
CurGameInfo gi, GameLock lock,
boolean setCreate )
{
@ -428,7 +428,7 @@ public class GameUtils {
return rowid;
}
public static long saveGame( Context context, byte[] bytes,
public static long saveGame( Context context, byte[] bytes,
GameLock lock, boolean setCreate )
{
return DBUtils.saveGame( context, lock, bytes, setCreate );
@ -455,7 +455,7 @@ public class GameUtils {
long rowid = DBUtils.ROWID_NOTFOUND;
byte[] bytes = XwJNI.gi_to_stream( gi );
if ( null != bytes ) {
GameLock lock = DBUtils.saveNewGame( context, bytes, groupID,
GameLock lock = DBUtils.saveNewGame( context, bytes, groupID,
gameName );
rowid = lock.getRowid();
lock.unlock();
@ -465,7 +465,7 @@ public class GameUtils {
public static long makeNewMultiGame( Context context, NetLaunchInfo nli )
{
return makeNewMultiGame( context, nli, (MultiMsgSink)null,
return makeNewMultiGame( context, nli, (MultiMsgSink)null,
(UtilCtxt)null );
}
@ -475,33 +475,33 @@ public class GameUtils {
DbgUtils.logdf( "makeNewMultiGame(nli=%s)", nli.toString() );
CommsAddrRec addr = nli.makeAddrRec( context );
return makeNewMultiGame( context, sink, util, DBUtils.GROUPID_UNSPEC,
addr, new int[] {nli.lang},
new String[] { nli.dict }, null, nli.nPlayersT,
return makeNewMultiGame( context, sink, util, DBUtils.GROUPID_UNSPEC,
addr, new int[] {nli.lang},
new String[] { nli.dict }, null, nli.nPlayersT,
nli.nPlayersH, nli.forceChannel,
nli.inviteID(), nli.gameID(),
nli.gameName, false );
}
public static long makeNewMultiGame( Context context, long groupID,
public static long makeNewMultiGame( Context context, long groupID,
String gameName )
{
return makeNewMultiGame( context, groupID, null, 0, null,
(CommsConnTypeSet)null, gameName );
}
public static long makeNewMultiGame( Context context, long groupID,
public static long makeNewMultiGame( Context context, long groupID,
String dict, int lang, String jsonData,
CommsConnTypeSet addrSet,
CommsConnTypeSet addrSet,
String gameName )
{
String inviteID = makeRandomID();
return makeNewMultiGame( context, groupID, inviteID, dict, lang,
return makeNewMultiGame( context, groupID, inviteID, dict, lang,
jsonData, addrSet, gameName );
}
private static long makeNewMultiGame( Context context, long groupID,
String inviteID, String dict,
private static long makeNewMultiGame( Context context, long groupID,
String inviteID, String dict,
int lang, String jsonData,
CommsConnTypeSet addrSet,
String gameName )
@ -520,14 +520,14 @@ public class GameUtils {
true );
}
private static long makeNewMultiGame( Context context, MultiMsgSink sink,
UtilCtxt util, long groupID,
private static long makeNewMultiGame( Context context, MultiMsgSink sink,
UtilCtxt util, long groupID,
CommsAddrRec addr,
int[] lang, String[] dict,
String jsonData,
int nPlayersT, int nPlayersH,
String jsonData,
int nPlayersT, int nPlayersH,
int forceChannel, String inviteID,
int gameID, String gameName,
int gameID, String gameName,
boolean isHost )
{
long rowid = -1;
@ -565,52 +565,52 @@ public class GameUtils {
}
public static long makeNewGame( Context context, MultiMsgSink sink,
int gameID, CommsAddrRec addr, int lang,
String dict, int nPlayersT,
int nPlayersH, int forceChannel,
int gameID, CommsAddrRec addr, int lang,
String dict, int nPlayersT,
int nPlayersH, int forceChannel,
String gameName )
{
return makeNewGame( context, sink, DBUtils.GROUPID_UNSPEC, gameID, addr,
lang, dict, nPlayersT, nPlayersH, forceChannel,
return makeNewGame( context, sink, DBUtils.GROUPID_UNSPEC, gameID, addr,
lang, dict, nPlayersT, nPlayersH, forceChannel,
gameName );
}
public static long makeNewGame( Context context, int gameID,
CommsAddrRec addr, int lang,
String dict, int nPlayersT,
int nPlayersH, int forceChannel,
public static long makeNewGame( Context context, int gameID,
CommsAddrRec addr, int lang,
String dict, int nPlayersT,
int nPlayersH, int forceChannel,
String gameName )
{
return makeNewGame( context, DBUtils.GROUPID_UNSPEC, gameID, addr,
lang, dict, nPlayersT, nPlayersH, forceChannel,
return makeNewGame( context, DBUtils.GROUPID_UNSPEC, gameID, addr,
lang, dict, nPlayersT, nPlayersH, forceChannel,
gameName );
}
public static long makeNewGame( Context context, long groupID, int gameID,
public static long makeNewGame( Context context, long groupID, int gameID,
CommsAddrRec addr, int lang, String dict,
int nPlayersT, int nPlayersH,
int nPlayersT, int nPlayersH,
int forceChannel, String gameName )
{
return makeNewGame( context, null, groupID, gameID, addr, lang, dict,
nPlayersT, nPlayersH, forceChannel, gameName );
}
public static long makeNewGame( Context context, MultiMsgSink sink,
public static long makeNewGame( Context context, MultiMsgSink sink,
long groupID, int gameID, CommsAddrRec addr,
int lang, String dict,
int nPlayersT, int nPlayersH,
int lang, String dict,
int nPlayersT, int nPlayersH,
int forceChannel, String gameName )
{
long rowid = -1;
int[] langa = { lang };
String[] dicta = { dict };
boolean isHost = null == addr;
if ( isHost ) {
if ( isHost ) {
addr = new CommsAddrRec( null, null );
}
String inviteID = GameUtils.formatGameID( gameID );
return makeNewMultiGame( context, sink, (UtilCtxt)null, groupID, addr,
langa, dicta, null, nPlayersT, nPlayersH,
return makeNewMultiGame( context, sink, (UtilCtxt)null, groupID, addr,
langa, dicta, null, nPlayersT, nPlayersH,
forceChannel, inviteID, gameID, gameName,
isHost );
}
@ -625,14 +625,14 @@ public class GameUtils {
int sdk = android.os.Build.VERSION.SDK_INT;
if ( sdk < android.os.Build.VERSION_CODES.HONEYCOMB ) {
android.text.ClipboardManager clipboard =
(android.text.ClipboardManager)
android.text.ClipboardManager clipboard =
(android.text.ClipboardManager)
context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText( asStr );
} else {
android.content.ClipboardManager clipboard =
(android.content.ClipboardManager)
context.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipboardManager clipboard =
(android.content.ClipboardManager)
context.getSystemService(Context.CLIPBOARD_SERVICE);
String label = LocUtils.getString( context, R.string.clip_label );
android.content.ClipData clip = android.content.ClipData
.newPlainText( label, asStr );
@ -656,13 +656,13 @@ public class GameUtils {
Intent intent = new Intent();
intent.setAction( Intent.ACTION_SEND );
String subject =
LocUtils.getString( activity, R.string.invite_subject_fmt,
LocUtils.getString( activity, R.string.invite_subject_fmt,
nli.room );
intent.putExtra( Intent.EXTRA_SUBJECT, subject );
intent.putExtra( Intent.EXTRA_TEXT, Html.fromHtml(message) );
File attach = null;
File tmpdir = XWApp.ATTACH_SUPPORTED ?
File tmpdir = XWApp.ATTACH_SUPPORTED ?
DictUtils.getDownloadDir( activity ) : null;
if ( null != tmpdir ) { // no attachment
attach = makeJsonFor( tmpdir, nli );
@ -678,17 +678,17 @@ public class GameUtils {
}
String choiceType = LocUtils.getString( activity, R.string.invite_chooser_email );
String chooserMsg =
LocUtils.getString( activity, R.string.invite_chooser_fmt,
String chooserMsg =
LocUtils.getString( activity, R.string.invite_chooser_fmt,
choiceType );
activity.startActivity( Intent.createChooser( intent, chooserMsg ) );
}
}
// public static void launchInviteActivity( Activity activity,
// InviteMeans means,
// public static void launchInviteActivity( Activity activity,
// InviteMeans means,
// String room, String inviteID,
// int lang, String dict,
// int lang, String dict,
// int nPlayers )
// {
// Assert.assertNotNull( inviteID );
@ -713,16 +713,16 @@ public class GameUtils {
// if ( choseEmail ) {
// intent.setAction( Intent.ACTION_SEND );
// String subject =
// LocUtils.getString( activity, R.string.invite_subject_fmt,
// LocUtils.getString( activity, R.string.invite_subject_fmt,
// room );
// intent.putExtra( Intent.EXTRA_SUBJECT, subject );
// intent.putExtra( Intent.EXTRA_TEXT, Html.fromHtml(message) );
// File attach = null;
// File tmpdir = XWApp.ATTACH_SUPPORTED ?
// File tmpdir = XWApp.ATTACH_SUPPORTED ?
// DictUtils.getDownloadDir( activity ) : null;
// if ( null != tmpdir ) { // no attachment
// attach = makeJsonFor( tmpdir, room, inviteID, lang,
// attach = makeJsonFor( tmpdir, room, inviteID, lang,
// dict, nPlayers );
// }
@ -744,8 +744,8 @@ public class GameUtils {
// }
// String choiceType = LocUtils.getString( activity, choiceID );
// String chooserMsg =
// LocUtils.getString( activity, R.string.invite_chooser_fmt,
// String chooserMsg =
// LocUtils.getString( activity, R.string.invite_chooser_fmt,
// choiceType );
// activity.startActivity( Intent.createChooser( intent, chooserMsg ) );
// }
@ -762,7 +762,7 @@ public class GameUtils {
}
public static String[] dictNames( Context context, long rowid,
int[] missingLang )
int[] missingLang )
{
byte[] stream = savedGame( context, rowid );
CurGameInfo gi = new CurGameInfo( context );
@ -773,11 +773,11 @@ public class GameUtils {
return gi.dictNames();
}
public static String[] dictNames( Context context, long rowid )
public static String[] dictNames( Context context, long rowid )
{
return dictNames( context, rowid, null );
}
public static boolean gameDictsHere( Context context, long rowid )
{
return gameDictsHere( context, rowid, null, null );
@ -786,7 +786,7 @@ public class GameUtils {
// Return true if all dicts present. Return list of those that
// are not.
public static boolean gameDictsHere( Context context, long rowid,
String[][] missingNames,
String[][] missingNames,
int[] missingLang )
{
String[] gameDicts = dictNames( context, rowid, missingLang );
@ -805,14 +805,14 @@ public class GameUtils {
DbgUtils.logf( "gameDictsHere: game has no dicts!" );
}
if ( null != missingNames ) {
missingNames[0] =
missingNames[0] =
missingSet.toArray( new String[missingSet.size()] );
}
return allHere;
}
public static String newName( Context context )
public static String newName( Context context )
{
return "untitled";
// String name = null;
@ -1004,14 +1004,14 @@ public class GameUtils {
gi.replaceDicts( newDict );
String[] dictNames = gi.dictNames();
DictUtils.DictPairs pairs = DictUtils.openDicts( context,
DictUtils.DictPairs pairs = DictUtils.openDicts( context,
dictNames );
GamePtr gamePtr = XwJNI.initJNI( rowid );
XwJNI.game_makeFromStream( gamePtr, stream, gi, dictNames,
XwJNI.game_makeFromStream( gamePtr, stream, gi, dictNames,
pairs.m_bytes, pairs.m_paths,
gi.langName(),
JNIUtilsImpl.get(context),
gi.langName(),
JNIUtilsImpl.get(context),
CommonPrefs.get( context ) );
// second time required as game_makeFromStream can overwrite
gi.replaceDicts( newDict );
@ -1027,16 +1027,16 @@ public class GameUtils {
return success;
} // replaceDicts
public static void applyChanges( Context context, CurGameInfo gi,
public static void applyChanges( Context context, CurGameInfo gi,
CommsAddrRec car, GameLock lock,
boolean forceNew )
{
applyChanges( context, (MultiMsgSink)null, gi, (UtilCtxt)null, car,
applyChanges( context, (MultiMsgSink)null, gi, (UtilCtxt)null, car,
lock, forceNew );
}
public static void applyChanges( Context context, MultiMsgSink sink,
CurGameInfo gi, UtilCtxt util,
CurGameInfo gi, UtilCtxt util,
CommsAddrRec car, GameLock lock,
boolean forceNew )
{
@ -1056,8 +1056,8 @@ public class GameUtils {
} else {
byte[] stream = savedGame( context, lock );
// Will fail if there's nothing in the stream but a gi.
madeGame = XwJNI.game_makeFromStream( gamePtr, stream,
new CurGameInfo(context),
madeGame = XwJNI.game_makeFromStream( gamePtr, stream,
new CurGameInfo(context),
dictNames, pairs.m_bytes,
pairs.m_paths, langName,
JNIUtilsImpl.get(context),
@ -1065,8 +1065,8 @@ public class GameUtils {
}
if ( forceNew || !madeGame ) {
XwJNI.game_makeNewGame( gamePtr, gi, dictNames, pairs.m_bytes,
pairs.m_paths, langName, util,
XwJNI.game_makeNewGame( gamePtr, gi, dictNames, pairs.m_bytes,
pairs.m_paths, langName, util,
JNIUtilsImpl.get(context), (DrawCtx)null,
cp, sink );
}
@ -1126,7 +1126,7 @@ public class GameUtils {
return rint;
}
public static void postMoveNotification( Context context, long rowid,
public static void postMoveNotification( Context context, long rowid,
BackMoveResult bmr,
boolean isTurnNow )
{
@ -1170,8 +1170,8 @@ public class GameUtils {
Utils.postNotification( context, intent, R.string.invite_notice_title,
body, (int)rowid );
}
private static void tellDied( Context context, GameLock lock,
private static void tellDied( Context context, GameLock lock,
boolean informNow )
{
GameSummary summary = DBUtils.getSummary( context, lock );
@ -1273,7 +1273,7 @@ public class GameUtils {
}
lock.unlock();
} else {
DbgUtils.logf( "ResendTask.doInBackground: unable to unlock %d",
DbgUtils.logf( "ResendTask.doInBackground: unable to unlock %d",
rowid );
}
}
@ -1285,7 +1285,7 @@ public class GameUtils {
{
if ( m_showUI ) {
int nSent = null == m_sink ? 0 : m_sink.numSent();
String msg =
String msg =
LocUtils.getQuantityString( m_context,
R.plurals.resend_finished_fmt,
nSent, nSent );

View file

@ -72,10 +72,10 @@ import org.eehouse.android.xw4.loc.LocUtils;
public class GamesListDelegate extends ListDelegateBase
implements OnItemLongClickListener,
DBUtils.DBChangeListener, SelectableItem,
DownloadFinishedListener, DlgDelegate.HasDlgDelegate,
DBUtils.DBChangeListener, SelectableItem,
DownloadFinishedListener, DlgDelegate.HasDlgDelegate,
GroupStateListener {
private static final String SAVE_ROWID = "SAVE_ROWID";
private static final String SAVE_ROWIDS = "SAVE_ROWIDS";
@ -145,7 +145,7 @@ public class GamesListDelegate extends ListDelegateBase
return alist.toArray( new Object[alist.size()] );
}
@Override
public View getView( Object dataObj, View convertView )
{
@ -155,16 +155,16 @@ public class GamesListDelegate extends ListDelegateBase
GameGroupInfo ggi = DBUtils.getGroups( m_activity )
.get( rec.m_groupID );
GameListGroup group =
GameListGroup.makeForPosition( m_activity, convertView,
rec.m_groupID, ggi.m_count,
ggi.m_expanded,
GamesListDelegate.this,
GameListGroup.makeForPosition( m_activity, convertView,
rec.m_groupID, ggi.m_count,
ggi.m_expanded,
GamesListDelegate.this,
GamesListDelegate.this );
updateGroupPct( group, ggi );
String name =
LocUtils.getQuantityString( m_activity,
R.plurals.group_name_fmt,
String name =
LocUtils.getQuantityString( m_activity,
R.plurals.group_name_fmt,
ggi.m_count, ggi.m_name,
ggi.m_count );
group.setText( name );
@ -172,9 +172,9 @@ public class GamesListDelegate extends ListDelegateBase
result = group;
} else if ( dataObj instanceof GameRec ) {
GameRec rec = (GameRec)dataObj;
GameListItem item =
GameListItem.makeForRow( m_activity, convertView,
rec.m_rowID, m_handler,
GameListItem item =
GameListItem.makeForRow( m_activity, convertView,
rec.m_rowID, m_handler,
m_fieldID, GamesListDelegate.this );
item.setSelected( m_selGames.contains( rec.m_rowID ) );
result = item;
@ -211,7 +211,7 @@ public class GamesListDelegate extends ListDelegateBase
GroupRec rec = (GroupRec)
findParent( makeChildTestFor( rowID ) );
if ( null != rec ) {
GameGroupInfo ggi =
GameGroupInfo ggi =
DBUtils.getGroups( m_activity ).get( rec.m_groupID );
expanded = ggi.m_expanded;
}
@ -241,7 +241,7 @@ public class GamesListDelegate extends ListDelegateBase
String groupName( long groupID )
{
final Map<Long,GameGroupInfo> gameInfo =
final Map<Long,GameGroupInfo> gameInfo =
DBUtils.getGroups( m_activity );
return gameInfo.get(groupID).m_name;
}
@ -254,7 +254,7 @@ public class GamesListDelegate extends ListDelegateBase
String[] groupNames()
{
long[] positions = getGroupPositions();
final Map<Long,GameGroupInfo> gameInfo =
final Map<Long,GameGroupInfo> gameInfo =
DBUtils.getGroups( m_activity );
Assert.assertTrue( positions.length == gameInfo.size() );
String[] names = new String[positions.length];
@ -285,7 +285,7 @@ public class GamesListDelegate extends ListDelegateBase
// do not modify!!!!
final Set<Long> keys = DBUtils.getGroups( m_activity ).keySet();
if ( null == m_groupPositions ||
if ( null == m_groupPositions ||
m_groupPositions.length != keys.size() ) {
HashSet<Long> unused = new HashSet<Long>( keys );
@ -378,7 +378,7 @@ public class GamesListDelegate extends ListDelegateBase
private void updateGroupPct( GameListGroup group, GameGroupInfo ggi )
{
if ( !ggi.m_expanded ) {
group.setPct( m_handler, ggi.m_hasTurn, ggi.m_turnLocal,
group.setPct( m_handler, ggi.m_hasTurn, ggi.m_turnLocal,
ggi.m_lastMoveTime );
}
}
@ -435,7 +435,7 @@ public class GamesListDelegate extends ListDelegateBase
};
}
private ArrayList<Object> removeRange( ArrayList<Object> list,
private ArrayList<Object> removeRange( ArrayList<Object> list,
int start, int len )
{
DbgUtils.logf( "removeRange(start=%d, len=%d)", start, len );
@ -525,7 +525,7 @@ public class GamesListDelegate extends ListDelegateBase
long[] result = XWPrefs.getGroupPositions( m_activity );
if ( null != result ) {
final Map<Long,GameGroupInfo> gameInfo =
final Map<Long,GameGroupInfo> gameInfo =
DBUtils.getGroups( m_activity );
Set<Long> posns = gameInfo.keySet();
if ( result.length != posns.size() ) {
@ -543,11 +543,11 @@ public class GamesListDelegate extends ListDelegateBase
}
} // class GameListAdapter
private static final int[] DEBUG_ITEMS = {
private static final int[] DEBUG_ITEMS = {
// R.id.games_menu_loaddb,
R.id.games_menu_storedb,
};
private static final int[] NOSEL_ITEMS = {
private static final int[] NOSEL_ITEMS = {
R.id.games_menu_newgroup,
R.id.games_menu_prefs,
R.id.games_menu_dicts,
@ -622,7 +622,7 @@ public class GamesListDelegate extends ListDelegateBase
public void onClick( DialogInterface dlg, int item ) {
// no name, so user must pick
if ( null == m_missingDictName ) {
DictsDelegate.downloadForResult( m_activity,
DictsDelegate.downloadForResult( m_activity,
RequestCode
.REQUEST_LANG_GL,
m_missingDictLang );
@ -636,7 +636,7 @@ public class GamesListDelegate extends ListDelegateBase
}
};
String message;
String langName =
String langName =
DictLangCache.getLangName( m_activity, m_missingDictLang );
String locLang = xlateLang( langName );
String gameName = GameUtils.getName( m_activity, m_missingDictRowId );
@ -647,7 +647,7 @@ public class GamesListDelegate extends ListDelegateBase
null, m_missingDictName, locLang );
} else {
// WARN_NODICT_SUBST
message = getString( R.string.no_dict_subst_fmt, gameName,
message = getString( R.string.no_dict_subst_fmt, gameName,
m_missingDictName, locLang );
}
@ -669,7 +669,7 @@ public class GamesListDelegate extends ListDelegateBase
setRemoveOnDismiss( dialog, dlgID );
break;
case SHOW_SUBST:
m_sameLangDicts =
m_sameLangDicts =
DictLangCache.getHaveLangCounts( m_activity, m_missingDictLang );
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg,
@ -760,7 +760,7 @@ public class GamesListDelegate extends ListDelegateBase
public void onClick( DialogInterface dlgi, int item ) {
selItem[0] = item;
AlertDialog dlg = (AlertDialog)dlgi;
Button btn =
Button btn =
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
boolean enabled = startGroup == -1;
if ( !enabled ) {
@ -781,7 +781,7 @@ public class GamesListDelegate extends ListDelegateBase
mkListAdapter();
}
};
OnClickListener lstnr3 =
OnClickListener lstnr3 =
new OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
m_moveAfterNewGroup = true;
@ -884,7 +884,7 @@ public class GamesListDelegate extends ListDelegateBase
ad.getButton( AlertDialog.BUTTON_POSITIVE ).setEnabled( false );
break;
case GAMES_LIST_NEWGAME:
boolean canDoDefaults = m_nextIsSolo
boolean canDoDefaults = m_nextIsSolo
|| 0 < XWPrefs.getAddrTypes( m_activity ).size();
ad.getButton( AlertDialog.BUTTON_NEGATIVE )
.setVisibility( canDoDefaults ? View.VISIBLE : View.GONE );
@ -921,7 +921,7 @@ public class GamesListDelegate extends ListDelegateBase
}
@Override
protected void init( Bundle savedInstanceState )
protected void init( Bundle savedInstanceState )
{
m_origTitle = getTitle();
@ -963,7 +963,7 @@ public class GamesListDelegate extends ListDelegateBase
@Override
protected boolean handleNewIntent( Intent intent )
{
DbgUtils.logf( "GamesListDelegate.handleNewIntent(%s)",
DbgUtils.logf( "GamesListDelegate.handleNewIntent(%s)",
intent.toString() );
m_launchedGames.clear();
@ -976,7 +976,7 @@ public class GamesListDelegate extends ListDelegateBase
protected void onStop()
{
// TelephonyManager mgr =
// TelephonyManager mgr =
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
// mgr.listen( m_phoneStateListener, PhoneStateListener.LISTEN_NONE );
// m_phoneStateListener = null;
@ -993,7 +993,7 @@ public class GamesListDelegate extends ListDelegateBase
}
}
protected void onSaveInstanceState( Bundle outState )
protected void onSaveInstanceState( Bundle outState )
{
// super.onSaveInstanceState( outState );
outState.putLong( SAVE_ROWID, m_rowid );
@ -1051,7 +1051,7 @@ public class GamesListDelegate extends ListDelegateBase
}
// OnItemLongClickListener interface
public boolean onItemLongClick( AdapterView<?> parent, View view,
public boolean onItemLongClick( AdapterView<?> parent, View view,
int position, long id ) {
boolean success = ! XWApp.CONTEXT_MENUS_ENABLED
&& view instanceof SelectableItem.LongClickHandler;
@ -1106,14 +1106,14 @@ public class GamesListDelegate extends ListDelegateBase
if ( clicked instanceof GameListItem ) {
long rowid = ((GameListItem)clicked).getRowID();
if ( ! m_launchedGames.contains( rowid ) ) {
showNotAgainDlgThen( R.string.not_again_newselect,
showNotAgainDlgThen( R.string.not_again_newselect,
R.string.key_notagain_newselect,
Action.OPEN_GAME, rowid, summary );
}
}
}
public void itemToggled( SelectableItem.LongClickHandler toggled,
public void itemToggled( SelectableItem.LongClickHandler toggled,
boolean selected )
{
if ( toggled instanceof GameListItem ) {
@ -1155,7 +1155,7 @@ public class GamesListDelegate extends ListDelegateBase
}
// BTService.MultiEventListener interface
public void eventOccurred( MultiService.MultiEvent event,
public void eventOccurred( MultiService.MultiEvent event,
final Object ... args )
{
switch( event ) {
@ -1164,7 +1164,7 @@ public class GamesListDelegate extends ListDelegateBase
public void run() {
DbgUtils.showf( m_activity,
"Pong from %s", args[0].toString() );
}
}
});
break;
case BT_GAME_CREATED:
@ -1174,7 +1174,7 @@ public class GamesListDelegate extends ListDelegateBase
if ( checkWarnNoDict( rowid ) ) {
launchGame( rowid, true );
}
}
}
});
break;
default:
@ -1243,18 +1243,18 @@ public class GamesListDelegate extends ListDelegateBase
public void downloadFinished( String lang, String name, boolean success )
{
if ( success ) {
XWPrefs.setPrefsString( m_activity,
R.string.key_default_language,
XWPrefs.setPrefsString( m_activity,
R.string.key_default_language,
lang );
name = DictUtils.removeDictExtn( name );
int[] ids = { R.string.key_default_dict,
int[] ids = { R.string.key_default_dict,
R.string.key_default_robodict };
for ( int id : ids ) {
XWPrefs.setPrefsString( m_activity, id, name );
}
XWPrefs.setPrefsBoolean( m_activity,
R.string.key_got_langdict,
XWPrefs.setPrefsBoolean( m_activity,
R.string.key_got_langdict,
true );
}
}
@ -1277,7 +1277,7 @@ public class GamesListDelegate extends ListDelegateBase
}
@Override
protected void onActivityResult( RequestCode requestCode, int resultCode,
protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data )
{
boolean cancelled = Activity.RESULT_CANCELED == resultCode;
@ -1301,7 +1301,7 @@ public class GamesListDelegate extends ListDelegateBase
}
@Override
protected void onResume()
protected void onResume()
{
super.onResume();
setupButtons();
@ -1312,7 +1312,7 @@ public class GamesListDelegate extends ListDelegateBase
{
boolean handled = 0 < m_selGames.size() || 0 < m_selGroupIDs.size();
if ( handled ) {
showNotAgainDlgThen( R.string.not_again_backclears,
showNotAgainDlgThen( R.string.not_again_backclears,
R.string.key_notagain_backclears,
Action.CLEAR_SELS );
}
@ -1320,7 +1320,7 @@ public class GamesListDelegate extends ListDelegateBase
}
@Override
public boolean onPrepareOptionsMenu( Menu menu )
public boolean onPrepareOptionsMenu( Menu menu )
{
int nGamesSelected = m_selGames.size();
int nGroupsSelected = m_selGroupIDs.size();
@ -1328,12 +1328,12 @@ public class GamesListDelegate extends ListDelegateBase
m_menuPrepared = 0 == nGamesSelected || 0 == nGroupsSelected;
if ( m_menuPrepared ) {
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
final boolean showDbg = BuildConfig.DEBUG
|| XWPrefs.getDebugEnabled( m_activity );
showItemsIf( DEBUG_ITEMS, menu, nothingSelected && showDbg );
Utils.setItemVisible( menu, R.id.games_menu_loaddb,
showDbg && nothingSelected &&
Utils.setItemVisible( menu, R.id.games_menu_loaddb,
showDbg && nothingSelected &&
DBUtils.gameDBExists( m_activity ) );
showItemsIf( NOSEL_ITEMS, menu, nothingSelected );
@ -1354,7 +1354,7 @@ public class GamesListDelegate extends ListDelegateBase
// You can't delete the default group, nor make it the default.
// But we enable delete so a warning message later can explain.
Utils.setItemVisible( menu, R.id.games_group_delete,
Utils.setItemVisible( menu, R.id.games_group_delete,
1 <= nGroupsSelected );
enable = (1 == nGroupsSelected) && ! m_selGroupIDs
.contains( XWPrefs.getDefaultNewGameGroup( m_activity ) );
@ -1363,7 +1363,7 @@ public class GamesListDelegate extends ListDelegateBase
// Rematch supported if there's one game selected
enable = 1 == nGamesSelected;
if ( enable ) {
enable = BoardDelegate.rematchSupported( m_activity,
enable = BoardDelegate.rematchSupported( m_activity,
getSelRowIDs()[0] );
}
Utils.setItemVisible( menu, R.id.games_game_rematch, enable );
@ -1371,7 +1371,7 @@ public class GamesListDelegate extends ListDelegateBase
// Move up/down enabled for groups if not the top-most or bottommost
// selected
enable = 1 == nGroupsSelected;
Utils.setItemVisible( menu, R.id.games_group_moveup,
Utils.setItemVisible( menu, R.id.games_group_moveup,
enable && 0 < selGroupPos );
Utils.setItemVisible( menu, R.id.games_group_movedown, enable
&& (selGroupPos + 1) < groupCount );
@ -1381,7 +1381,7 @@ public class GamesListDelegate extends ListDelegateBase
nothingSelected || 1 == nGroupsSelected );
Utils.setItemVisible( menu, R.id.games_menu_newgame_net,
nothingSelected || 1 == nGroupsSelected );
// Multiples can be deleted, but disable if any selected game is
// currently open
enable = 0 < nGamesSelected;
@ -1391,9 +1391,9 @@ public class GamesListDelegate extends ListDelegateBase
Utils.setItemVisible( menu, R.id.games_game_delete, enable );
// multiple games can be regrouped/reset.
Utils.setItemVisible( menu, R.id.games_game_move,
Utils.setItemVisible( menu, R.id.games_game_move,
0 < nGamesSelected );
Utils.setItemVisible( menu, R.id.games_game_reset,
Utils.setItemVisible( menu, R.id.games_game_reset,
0 < nGamesSelected );
// Hide rate-me if not a google play app
@ -1403,10 +1403,10 @@ public class GamesListDelegate extends ListDelegateBase
enable = nothingSelected && XWPrefs.getStudyEnabled( m_activity );
Utils.setItemVisible( menu, R.id.games_menu_study, enable );
enable = nothingSelected &&
enable = nothingSelected &&
0 < DBUtils.getGamesWithSendsPending( m_activity ).size();
Utils.setItemVisible( menu, R.id.games_menu_resend, enable );
Assert.assertTrue( m_menuPrepared );
} else {
DbgUtils.logf( "onPrepareOptionsMenu: incomplete so bailing" );
@ -1517,7 +1517,7 @@ public class GamesListDelegate extends ListDelegateBase
return handled;// || super.onOptionsItemSelected( item );
}
public void onCreateContextMenu( ContextMenu menu, View view,
public void onCreateContextMenu( ContextMenu menu, View view,
ContextMenuInfo menuInfo )
{
boolean enable;
@ -1529,7 +1529,7 @@ public class GamesListDelegate extends ListDelegateBase
AdapterView.AdapterContextMenuInfo info
= (AdapterView.AdapterContextMenuInfo)menuInfo;
View targetView = info.targetView;
DbgUtils.logf( "onCreateContextMenu(t=%s)",
DbgUtils.logf( "onCreateContextMenu(t=%s)",
targetView.getClass().getSimpleName() );
if ( targetView instanceof GameListItem ) {
item = (GameListItem)targetView;
@ -1540,7 +1540,7 @@ public class GamesListDelegate extends ListDelegateBase
id = R.menu.games_list_group_menu;
long groupID = ((GameListGroup)targetView).getGroupID();
selected = m_selGroupIDs.contains( groupID );
selected = m_selGroupIDs.contains( groupID );
} else {
Assert.fail();
}
@ -1553,7 +1553,7 @@ public class GamesListDelegate extends ListDelegateBase
Utils.setItemVisible( menu, hideId, false );
if ( null != item ) {
enable = BoardDelegate.rematchSupported( m_activity,
enable = BoardDelegate.rematchSupported( m_activity,
item.getRowID() );
Utils.setItemVisible( menu, R.id.games_game_rematch, enable );
@ -1565,7 +1565,7 @@ public class GamesListDelegate extends ListDelegateBase
}
public boolean onContextItemSelected( MenuItem item )
public boolean onContextItemSelected( MenuItem item )
{
boolean handled = true;
AdapterView.AdapterContextMenuInfo info
@ -1585,14 +1585,14 @@ public class GamesListDelegate extends ListDelegateBase
Assert.fail();
}
}
return handled || super.onContextItemSelected( item );
}
//////////////////////////////////////////////////////////////////////
// DwnldActivity.DownloadFinishedListener interface
//////////////////////////////////////////////////////////////////////
public void downloadFinished( String lang, String name,
public void downloadFinished( String lang, String name,
final boolean success )
{
post( new Runnable() {
@ -1602,7 +1602,7 @@ public class GamesListDelegate extends ListDelegateBase
madeGame = makeNewNetGameIf() || launchGameIf();
}
if ( ! madeGame ) {
int id = success ? R.string.download_done
int id = success ? R.string.download_done
: R.string.download_failed;
showToast( id );
}
@ -1647,7 +1647,7 @@ public class GamesListDelegate extends ListDelegateBase
switch( itemID ) {
case R.id.games_game_select:
case R.id.games_game_deselect:
SelectableItem.LongClickHandler toggled
SelectableItem.LongClickHandler toggled
= (SelectableItem.LongClickHandler)target;
toggled.longClicked();
handled = true;
@ -1666,9 +1666,9 @@ public class GamesListDelegate extends ListDelegateBase
switch( itemID ) {
case R.id.games_game_delete:
String msg = getQuantityString( R.plurals.confirm_seldeletes_fmt,
String msg = getQuantityString( R.plurals.confirm_seldeletes_fmt,
selRowIDs.length, selRowIDs.length );
showConfirmThen( msg, R.string.button_delete,
showConfirmThen( msg, R.string.button_delete,
Action.DELETE_GAMES, selRowIDs );
break;
@ -1688,7 +1688,7 @@ public class GamesListDelegate extends ListDelegateBase
case R.id.games_game_new_from:
dropSels = true; // will select the new game instead
showNotAgainDlgThen( R.string.not_again_newfrom,
R.string.key_notagain_newfrom,
R.string.key_notagain_newfrom,
Action.NEW_FROM, selRowIDs[0] );
break;
case R.id.games_game_copy:
@ -1704,7 +1704,7 @@ public class GamesListDelegate extends ListDelegateBase
GameUtils.savedGame( self, selRowIDs[0] );
long groupID = XWPrefs
.getDefaultNewGameGroup( self );
GameLock lock =
GameLock lock =
GameUtils.saveNewGame( self, stream, groupID );
DBUtils.saveSummary( self, lock, smry );
m_selGames.add( lock.getRowid() );
@ -1729,7 +1729,7 @@ public class GamesListDelegate extends ListDelegateBase
msg = DBUtils.getSummary( m_activity, selRowIDs[0] )
.conTypes.toString( m_activity );
msg = getString( R.string.invites_net_fmt, msg );
SentInvitesInfo info = DBUtils.getInvitesFor( m_activity,
selRowIDs[0] );
if ( null != info ) {
@ -1737,7 +1737,7 @@ public class GamesListDelegate extends ListDelegateBase
}
showOKOnlyDialog( msg );
break;
default:
handled = false;
}
@ -1764,7 +1764,7 @@ public class GamesListDelegate extends ListDelegateBase
showOKOnlyDialog( msg );
} else {
Assert.assertTrue( 0 < groupIDs.length );
msg = getQuantityString( R.plurals.groups_confirm_del_fmt,
msg = getQuantityString( R.plurals.groups_confirm_del_fmt,
groupIDs.length, groupIDs.length );
int nGames = 0;
@ -1809,7 +1809,7 @@ public class GamesListDelegate extends ListDelegateBase
button.setVisibility( View.VISIBLE );
final boolean solo = isSolos[ii];
button.setOnClickListener( new View.OnClickListener() {
public void onClick( View view ) {
public void onClick( View view ) {
handleNewGameButton( solo );
}
} );
@ -1832,7 +1832,7 @@ public class GamesListDelegate extends ListDelegateBase
if ( skipOffer ) {
handleNewGame( solo );
} else {
ActionPair pair = new ActionPair( Action.SET_HIDE_NEWGAME_BUTTONS,
ActionPair pair = new ActionPair( Action.SET_HIDE_NEWGAME_BUTTONS,
R.string.set_pref );
showNotAgainDlgThen( R.string.not_again_hidenewgamebuttons,
R.string.key_notagain_hidenewgamebuttons,
@ -1871,10 +1871,10 @@ public class GamesListDelegate extends ListDelegateBase
// Just pick one -- good enough for the period when
// users aren't using new clients that include the
// dict name.
nli.dict = dicts[0];
nli.dict = dicts[0];
}
} else {
haveDict =
haveDict =
DictLangCache.haveDict( m_activity, nli.lang, nli.dict );
}
if ( !haveDict ) {
@ -1896,7 +1896,7 @@ public class GamesListDelegate extends ListDelegateBase
String[][] missingNames = new String[1][];
int[] missingLang = new int[1];
boolean hasDicts;
try {
try {
hasDicts = GameUtils.gameDictsHere( m_activity, rowid, missingNames,
missingLang );
} catch ( GameUtils.NoSuchGameException nsge ) {
@ -1917,9 +1917,9 @@ public class GamesListDelegate extends ListDelegateBase
} else if ( null != m_missingDictName ) {
showDialog( DlgID.WARN_NODICT_SUBST );
} else {
String dict =
String dict =
DictLangCache.getHaveLang( m_activity, m_missingDictLang)[0];
if ( GameUtils.replaceDicts( m_activity, m_missingDictRowId,
if ( GameUtils.replaceDicts( m_activity, m_missingDictRowId,
null, dict ) ) {
launchGameIf();
}
@ -1928,7 +1928,7 @@ public class GamesListDelegate extends ListDelegateBase
return hasDicts;
}
private void invalRelayIDs( String[] relayIDs )
private void invalRelayIDs( String[] relayIDs )
{
if ( null != relayIDs ) {
for ( String relayID : relayIDs ) {
@ -2003,7 +2003,7 @@ public class GamesListDelegate extends ListDelegateBase
makeNewNetGame( nli );
}
} else if ( XWPrefs.getSecondInviteAllowed( m_activity ) ) {
String msg = getString( R.string.dup_game_query_fmt,
String msg = getString( R.string.dup_game_query_fmt,
create.toString() );
m_netLaunchInfo = nli;
showConfirmThen( msg, Action.NEW_NET_GAME, nli );
@ -2048,7 +2048,7 @@ public class GamesListDelegate extends ListDelegateBase
// used to connect.
private void startRematch( Intent intent )
{
if ( XWApp.REMATCH_SUPPORTED
if ( XWApp.REMATCH_SUPPORTED
&& ( -1 != intent.getLongExtra( REMATCH_ROWID_EXTRA, -1 ) ) ) {
m_rematchIntent = intent;
showDialog( DlgID.GAMES_LIST_NAME_REMATCH );
@ -2078,7 +2078,7 @@ public class GamesListDelegate extends ListDelegateBase
long groupID = DBUtils.getGroupForGame( m_activity, srcRowID );
newid = GameUtils.makeNewMultiGame( m_activity, groupID, dict,
lang, json, addrs, gameName );
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
relayID );
}
launchGame( newid );
@ -2113,9 +2113,9 @@ public class GamesListDelegate extends ListDelegateBase
}
private void getDictForLangIf()
{
if ( ! m_haveShownGetDict &&
! XWPrefs.getPrefsBoolean( m_activity, R.string.key_got_langdict,
{
if ( ! m_haveShownGetDict &&
! XWPrefs.getPrefsBoolean( m_activity, R.string.key_got_langdict,
false ) ) {
m_haveShownGetDict = true;
@ -2128,22 +2128,22 @@ public class GamesListDelegate extends ListDelegateBase
final Runnable onNA = new Runnable() {
public void run() {
XWPrefs.setPrefsBoolean( m_activity, R.string
.key_got_langdict,
.key_got_langdict,
true );
}
};
OnGotLcDictListener lstnr = new OnGotLcDictListener() {
public void gotDictInfo( boolean success, String lang,
public void gotDictInfo( boolean success, String lang,
String name ) {
stopProgress();
if ( success ) {
String msg =
getString( R.string.confirm_get_locdict_fmt,
String msg =
getString( R.string.confirm_get_locdict_fmt,
xlateLang( lang ) );
showConfirmThen( onNA, msg, R.string
.button_download,
Action.DWNLD_LOC_DICT,
.button_download,
Action.DWNLD_LOC_DICT,
lang, name );
}
}
@ -2176,13 +2176,13 @@ public class GamesListDelegate extends ListDelegateBase
}
private Dialog buildNamerDlg( String curname, int labelID, int titleID,
OnClickListener lstnr1, OnClickListener lstnr2,
OnClickListener lstnr1, OnClickListener lstnr2,
DlgID dlgID )
{
m_namer = (GameNamer)inflate( R.layout.rename_game );
m_namer.setName( curname );
m_namer.setLabel( labelID );
Dialog dialog = makeAlertBuilder()
.setTitle( titleID )
.setPositiveButton( android.R.string.ok, lstnr1 )
@ -2350,7 +2350,7 @@ public class GamesListDelegate extends ListDelegateBase
{
long[] result = new long[m_selGames.size()];
int ii = 0;
for ( Iterator<Long> iter = m_selGames.iterator();
for ( Iterator<Long> iter = m_selGames.iterator();
iter.hasNext(); ) {
result[ii++] = iter.next();
}
@ -2371,7 +2371,7 @@ public class GamesListDelegate extends ListDelegateBase
{
long[] result = new long[m_selGroupIDs.size()];
int ii = 0;
for ( Iterator<Long> iter = m_selGroupIDs.iterator();
for ( Iterator<Long> iter = m_selGroupIDs.iterator();
iter.hasNext(); ) {
result[ii++] = iter.next();
}
@ -2387,9 +2387,9 @@ public class GamesListDelegate extends ListDelegateBase
private void doConfirmReset( long[] rowIDs )
{
String msg = getQuantityString( R.plurals.confirm_reset_fmt,
String msg = getQuantityString( R.plurals.confirm_reset_fmt,
rowIDs.length, rowIDs.length );
showConfirmThen( msg, R.string.button_reset, Action.RESET_GAMES,
showConfirmThen( msg, R.string.button_reset, Action.RESET_GAMES,
rowIDs );
}
@ -2404,8 +2404,8 @@ public class GamesListDelegate extends ListDelegateBase
// String field = CommonPrefs.getSummaryField( m_activity );
// long[] positions = XWPrefs.getGroupPositions( m_activity );
// GameListAdapter adapter =
// new GameListAdapter( m_activity, listview, new Handler(),
// GameListAdapter adapter =
// new GameListAdapter( m_activity, listview, new Handler(),
// this, positions, field );
// setListAdapter( adapter );
// adapter.expandGroups( listview );
@ -2418,10 +2418,10 @@ public class GamesListDelegate extends ListDelegateBase
{
boolean asking = false;
boolean skipAsk = XWPrefs
.getPrefsBoolean( m_activity, R.string.key_notagain_dfltname,
.getPrefsBoolean( m_activity, R.string.key_notagain_dfltname,
false );
if ( ! skipAsk ) {
String name1 = CommonPrefs.getDefaultPlayerName( m_activity, 0,
String name1 = CommonPrefs.getDefaultPlayerName( m_activity, 0,
false );
String name2 = CommonPrefs.getDefaultOriginalPlayerName( m_activity, 0 );
if ( null == name1 || name1.equals( name2 ) ) {
@ -2434,12 +2434,12 @@ public class GamesListDelegate extends ListDelegateBase
Runnable onChecked = new Runnable() {
public void run() {
XWPrefs
.setPrefsBoolean( m_activity,
.setPrefsBoolean( m_activity,
R.string.key_notagain_dfltname,
true );
}
};
showConfirmThen( onChecked, msg, android.R.string.ok,
showConfirmThen( onChecked, msg, android.R.string.ok,
R.string.button_later, Action.NEW_GAME_DFLT_NAME,
edit, doConfigure );
}
@ -2459,7 +2459,7 @@ public class GamesListDelegate extends ListDelegateBase
return handled;
}
private void makeThenLaunchOrConfigure( EditText edit, boolean doConfigure,
private void makeThenLaunchOrConfigure( EditText edit, boolean doConfigure,
boolean skipAsk )
{
if ( skipAsk || !askingChangeName( edit, doConfigure ) ) {
@ -2471,8 +2471,8 @@ public class GamesListDelegate extends ListDelegateBase
// Ideally we'd check here whether user has set player name.
if ( m_nextIsSolo ) {
rowID = GameUtils.saveNew( m_activity,
new CurGameInfo( m_activity ),
rowID = GameUtils.saveNew( m_activity,
new CurGameInfo( m_activity ),
groupID, name );
} else {
rowID = GameUtils.makeNewMultiGame( m_activity, groupID, name );
@ -2480,8 +2480,8 @@ public class GamesListDelegate extends ListDelegateBase
if ( doConfigure ) {
// configure it
GameConfigDelegate.editForResult( getDelegator(),
RequestCode.CONFIG_GAME,
GameConfigDelegate.editForResult( getDelegator(),
RequestCode.CONFIG_GAME,
rowID );
} else {
// launch it
@ -2527,7 +2527,7 @@ public class GamesListDelegate extends ListDelegateBase
public static Intent makeRematchIntent( Context context, long rowid,
CurGameInfo gi,
CommsConnTypeSet addrTypes,
CommsConnTypeSet addrTypes,
String btAddr, String phone,
String relayID, String newName )
{

View file

@ -31,7 +31,7 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.loc.LocUtils;
public class HeaderWithExpander extends LinearLayout
public class HeaderWithExpander extends LinearLayout
implements View.OnClickListener {
private boolean m_expanded;
@ -43,7 +43,7 @@ public class HeaderWithExpander extends LinearLayout
public void expanded( boolean expanded );
}
public HeaderWithExpander( Context cx, AttributeSet as )
public HeaderWithExpander( Context cx, AttributeSet as )
{
super( cx, as );
}
@ -55,7 +55,7 @@ public class HeaderWithExpander extends LinearLayout
m_label = (TextView)findViewById( R.id.label );
}
public void setExpanded( boolean expanded )
public void setExpanded( boolean expanded )
{
m_expanded = expanded;
if ( null != m_listener ) {
@ -81,7 +81,7 @@ public class HeaderWithExpander extends LinearLayout
//////////////////////////////////////////////////
// View.OnClickListener interface
//////////////////////////////////////////////////
public void onClick( View view )
public void onClick( View view )
{
setExpanded( !m_expanded );
}

View file

@ -61,7 +61,7 @@ abstract class InviteDelegate extends ListDelegateBase
m_lastDev = intent.getStringExtra( INTENT_KEY_LASTDEV );
}
protected void init( int button_invite, int button_rescan,
protected void init( int button_invite, int button_rescan,
int button_clear, int desc_id, String descTxt )
{
m_okButton = (Button)findViewById( button_invite );
@ -87,7 +87,7 @@ abstract class InviteDelegate extends ListDelegateBase
////////////////////////////////////////
// View.OnClickListener
////////////////////////////////////////
public void onClick( View view )
public void onClick( View view )
{
if ( m_okButton == view ) {
Intent intent = new Intent();

View file

@ -26,7 +26,7 @@ import android.widget.ListAdapter;
import android.widget.ListView;
public class ListDelegateBase extends DelegateBase {
private Activity m_activity;
private Delegator m_delegator;

View file

@ -29,7 +29,7 @@ import android.widget.TextView;
import org.eehouse.android.xw4.loc.LocUtils;
public class ListGroup extends LinearLayout
public class ListGroup extends LinearLayout
implements View.OnClickListener {
private boolean m_expanded;
@ -39,7 +39,7 @@ public class ListGroup extends LinearLayout
private GroupStateListener m_listener;
private int m_posn;
public ListGroup( Context cx, AttributeSet as )
public ListGroup( Context cx, AttributeSet as )
{
super( cx, as );
}
@ -50,7 +50,7 @@ public class ListGroup extends LinearLayout
super.onFinishInflate();
m_expandButton = (ImageButton)findViewById( R.id.expander );
m_text = (TextView)findViewById( R.id.game_name );
m_expandButton.setOnClickListener( this );
setOnClickListener( this );
@ -66,7 +66,7 @@ public class ListGroup extends LinearLayout
//////////////////////////////////////////////////
// View.OnClickListener interface
//////////////////////////////////////////////////
public void onClick( View view )
public void onClick( View view )
{
m_expanded = !m_expanded;
m_listener.onGroupExpandedChanged( this, m_expanded );
@ -89,8 +89,8 @@ public class ListGroup extends LinearLayout
}
}
public static ListGroup make( Context context, View convertView,
GroupStateListener lstnr, int posn,
public static ListGroup make( Context context, View convertView,
GroupStateListener lstnr, int posn,
String desc, boolean expanded )
{
ListGroup result;

View file

@ -72,7 +72,7 @@ public class LookupAlert extends LinearLayout
private static String[] s_lookupUrls;
private static ArrayAdapter<String> s_urlsAdapter;
private static final int LIST_LAYOUT = android.R.layout.simple_list_item_1;
private static int s_lang = -1;
private static String s_langName;
@ -115,7 +115,7 @@ public class LookupAlert extends LinearLayout
// m_state = STATE_DONE;
// adjustState( 1 );
// m_wordsAdapter = new ArrayAdapter<String>( this, LIST_LAYOUT,
// m_wordsAdapter = new ArrayAdapter<String>( this, LIST_LAYOUT,
// m_words );
// getListView().setOnItemClickListener( this );
@ -147,7 +147,7 @@ public class LookupAlert extends LinearLayout
m_state = STATE_DONE;
adjustState( 1 );
m_wordsAdapter = new ArrayAdapter<String>( m_context, LIST_LAYOUT,
m_wordsAdapter = new ArrayAdapter<String>( m_context, LIST_LAYOUT,
m_words );
m_listView = (ListView)findViewById( android.R.id.list );
m_listView.setOnItemClickListener( this );
@ -167,7 +167,7 @@ public class LookupAlert extends LinearLayout
}
// @Override
// protected void onSaveInstanceState( Bundle outState )
// protected void onSaveInstanceState( Bundle outState )
// {
// super.onSaveInstanceState( outState );
// outState.putInt( STATE, m_state );
@ -188,9 +188,9 @@ public class LookupAlert extends LinearLayout
// }
//////////////////////////////////////////////////////////////////////
// View.OnClickListener
// View.OnClickListener
//////////////////////////////////////////////////////////////////////
public void onClick( View view )
public void onClick( View view )
{
if ( view == m_doneButton ) {
switchState( -1 );
@ -198,16 +198,16 @@ public class LookupAlert extends LinearLayout
String word = m_words[m_wordIndex];
DBUtils.addToStudyList( m_context, word, s_lang );
String msg = LocUtils.getString( m_context, R.string.add_done_fmt,
String msg = LocUtils.getString( m_context, R.string.add_done_fmt,
word, s_langName );
Utils.showToast( m_context, msg );
}
}
//////////////////////////////////////////////////////////////////////
// AdapterView.OnItemClickListener
// AdapterView.OnItemClickListener
//////////////////////////////////////////////////////////////////////
public void onItemClick( AdapterView<?> parentView, View view,
public void onItemClick( AdapterView<?> parentView, View view,
int position, long id )
{
if ( STATE_WORDS == m_state ) {
@ -252,7 +252,7 @@ public class LookupAlert extends LinearLayout
break;
case STATE_WORDS:
m_listView.setAdapter( m_wordsAdapter );
setSummary( m_studyOn ?
setSummary( m_studyOn ?
R.string.title_lookup_study : R.string.title_lookup );
m_doneButton.setText( R.string.button_done );
m_studyButton.setVisibility( View.GONE );
@ -271,7 +271,7 @@ public class LookupAlert extends LinearLayout
}
break;
case STATE_LOOKUP:
lookupWord( m_context, m_words[m_wordIndex],
lookupWord( m_context, m_words[m_wordIndex],
s_lookupUrls[m_urlIndex] );
switchState( -1 );
break;
@ -291,7 +291,7 @@ public class LookupAlert extends LinearLayout
Uri uri = Uri.parse( dict_url );
Intent intent = new Intent( Intent.ACTION_VIEW, uri );
intent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
try {
context.startActivity( intent );
} catch ( android.content.ActivityNotFoundException anfe ) {
@ -323,7 +323,7 @@ public class LookupAlert extends LinearLayout
}
s_lookupNames = tmpNames.toArray( new String[tmpNames.size()] );
s_lookupUrls = tmpUrls.toArray( new String[tmpUrls.size()] );
s_urlsAdapter = new ArrayAdapter<String>( context, LIST_LAYOUT,
s_urlsAdapter = new ArrayAdapter<String>( context, LIST_LAYOUT,
s_lookupNames );
s_lang = lang;
String langName = DictLangCache.getLangName( context, lang );
@ -338,7 +338,7 @@ public class LookupAlert extends LinearLayout
private void setSummary( String word )
{
String title =
String title =
LocUtils.getString( m_context, R.string.pick_url_title_fmt, word );
m_summary.setText( title );
}
@ -356,7 +356,7 @@ public class LookupAlert extends LinearLayout
return handled;
}
public static boolean needAlert( Context context, String[] words,
public static boolean needAlert( Context context, String[] words,
int langCode, boolean noStudy )
{
boolean result = !noStudy || 1 < words.length;
@ -367,7 +367,7 @@ public class LookupAlert extends LinearLayout
return result;
}
public static Bundle makeParams( String[] words, int lang,
public static Bundle makeParams( String[] words, int lang,
boolean noStudyOption )
{
Bundle bundle = new Bundle();
@ -391,7 +391,7 @@ public class LookupAlert extends LinearLayout
return result;
}
protected static void launchWordLookup( Context context, String word,
protected static void launchWordLookup( Context context, String word,
int langCode )
{
setLang( context, langCode );

View file

@ -43,7 +43,7 @@ import org.eehouse.android.xw4.jni.CurGameInfo;
import junit.framework.Assert;
public class MainActivity extends XWActivity
public class MainActivity extends XWActivity
implements FragmentManager.OnBackStackChangedListener {
private static final int MAX_PANES_LANDSCAPE = 2;
@ -151,7 +151,7 @@ public class MainActivity extends XWActivity
for ( int ii = hiddenCount; ii >= 0; --ii ) {
View child = m_root.getChildAt( ii );
Fragment frag = fm.findFragmentById( child.getId() );
// DbgUtils.logf( "left-most case (child %d): %s", hiddenCount,
// DbgUtils.logf( "left-most case (child %d): %s", hiddenCount,
// frag.getClass().getSimpleName() );
handled = ((XWFragment)frag).getDelegate()
.handleNewIntent( intent );
@ -159,7 +159,7 @@ public class MainActivity extends XWActivity
if ( handled ) {
break;
} else if ( ii > 0 ) {
DbgUtils.logf( "popping %s",
DbgUtils.logf( "popping %s",
frag.getClass().getSimpleName() );
fm.popBackStackImmediate(); // callback removes view
}
@ -177,7 +177,7 @@ public class MainActivity extends XWActivity
View child = m_root.getChildAt( m_root.getChildCount() - 1 );
Fragment frag = getSupportFragmentManager()
.findFragmentById( child.getId() );
boolean handled = null != frag
boolean handled = null != frag
&&((XWFragment)frag).getDelegate().handleBackPressed();
return handled;
}
@ -206,13 +206,13 @@ public class MainActivity extends XWActivity
}
@Override
public void addFragment( XWFragment fragment, Bundle extras )
public void addFragment( XWFragment fragment, Bundle extras )
{
addFragmentImpl( fragment, extras, this );
}
@Override
public void addFragmentForResult( XWFragment fragment, Bundle extras,
public void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode requestCode )
{
DbgUtils.logf( "addFragmentForResult(): dropping requestCode" );
@ -236,7 +236,7 @@ public class MainActivity extends XWActivity
finish();
} else if ( fragCount == m_root.getChildCount() - 1 ) {
// View child = m_root.getChildAt( fragCount );
// DbgUtils.logf( "onBackStackChanged(): removing view with id %x",
// DbgUtils.logf( "onBackStackChanged(): removing view with id %x",
// child.getId() );
m_root.removeViewAt( fragCount );
setVisiblePanes();
@ -268,7 +268,7 @@ public class MainActivity extends XWActivity
{
int result;
int orientation = getResources().getConfiguration().orientation;
if ( XWPrefs.getIsTablet( this )
if ( XWPrefs.getIsTablet( this )
&& Configuration.ORIENTATION_LANDSCAPE == orientation ) {
result = MAX_PANES_LANDSCAPE;
} else {
@ -301,8 +301,8 @@ public class MainActivity extends XWActivity
}
}
private void addFragmentImpl( Fragment fragment, Bundle bundle,
Delegator parent )
private void addFragmentImpl( Fragment fragment, Bundle bundle,
Delegator parent )
{
fragment.setArguments( bundle );
addFragmentImpl( fragment, parent );

View file

@ -79,7 +79,7 @@ public class MultiMsgSink implements TransportProcs {
public int getFlags() { return COMMS_XPORT_FLAGS_HASNOCONN; }
public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
CommsConnType typ, int gameID )
{
int nSent = -1;
@ -97,7 +97,7 @@ public class MultiMsgSink implements TransportProcs {
Assert.fail();
break;
}
DbgUtils.logf( "MultiMsgSink.transportSend(): sent %d via %s",
DbgUtils.logf( "MultiMsgSink.transportSend(): sent %d via %s",
nSent, typ.toString() );
if ( 0 < nSent ) {
DbgUtils.logdf( "MultiMsgSink.transportSend: adding %s", msgNo );
@ -115,7 +115,7 @@ public class MultiMsgSink implements TransportProcs {
{
}
public void relayConnd( String room, int devOrder, boolean allHere,
public void relayConnd( String room, int devOrder, boolean allHere,
int nMissing )
{
}
@ -123,7 +123,7 @@ public class MultiMsgSink implements TransportProcs {
public boolean relayNoConnProc( byte[] buf, String msgNo, String relayID )
{
// Assert.fail();
int nSent = RelayService.sendNoConnPacket( m_context, getRowID(),
int nSent = RelayService.sendNoConnPacket( m_context, getRowID(),
relayID, buf );
boolean success = buf.length == nSent;
if ( success ) {

View file

@ -149,7 +149,7 @@ public class MultiService {
String inviter = intent.getStringExtra( INVITER );
int msgID = (null == inviter) ? R.string.invite_dict_missing_body_noname_fmt
: R.string.invite_dict_missing_body_fmt;
String msg = LocUtils.getString( context, msgID, inviter, dict,
String msg = LocUtils.getString( context, msgID, inviter, dict,
LocUtils.xlateLang( context, langStr));
return LocUtils.makeAlertBuilder( context )
@ -160,10 +160,10 @@ public class MultiService {
.create();
}
public static void postMissingDictNotification( Context content,
public static void postMissingDictNotification( Context content,
Intent intent, int id )
{
Utils.postNotification( content, intent, R.string.missing_dict_title,
Utils.postNotification( content, intent, R.string.missing_dict_title,
R.string.missing_dict_detail, id );
}

View file

@ -64,12 +64,12 @@ public class NFCUtils {
private static class SafeNFCImpl implements SafeNFC {
public void register( final Activity activity, final NFCActor actor )
{
NfcManager manager =
NfcManager manager =
(NfcManager)activity.getSystemService( Context.NFC_SERVICE );
if ( null != manager ) {
NfcAdapter adapter = manager.getDefaultAdapter();
if ( null != adapter ) {
NfcAdapter.CreateNdefMessageCallback cb =
NfcAdapter.CreateNdefMessageCallback cb =
new NfcAdapter.CreateNdefMessageCallback() {
public NdefMessage createNdefMessage( NfcEvent evt )
{
@ -93,7 +93,7 @@ public class NFCUtils {
public static boolean[] nfcAvail( Context context )
{
if ( null == s_nfcAvail ) {
s_nfcAvail = new boolean[] {
s_nfcAvail = new boolean[] {
s_inSDK && null != getNFCAdapter( context ),
false
};
@ -110,7 +110,7 @@ public class NFCUtils {
String action = intent.getAction();
if ( NfcAdapter.ACTION_NDEF_DISCOVERED.equals( action ) ) {
Parcelable[] rawMsgs =
Parcelable[] rawMsgs =
intent.getParcelableArrayExtra( NfcAdapter.EXTRA_NDEF_MESSAGES );
// only one message sent during the beam
NdefMessage msg = (NdefMessage)rawMsgs[0];
@ -140,7 +140,7 @@ public class NFCUtils {
{
DialogInterface.OnClickListener lstnr
= new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog,
public void onClick( DialogInterface dialog,
int item ) {
activity.
startActivity( new Intent("android.settings"
@ -159,8 +159,8 @@ public class NFCUtils {
{
String mimeType = LocUtils.getString( activity, R.string.xwords_nfc_mime );
NdefMessage msg = new NdefMessage( new NdefRecord[] {
new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
mimeType.getBytes(), new byte[0],
new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
mimeType.getBytes(), new byte[0],
data.getBytes())
,NdefRecord.
createApplicationRecord( activity.getPackageName() )
@ -170,9 +170,9 @@ public class NFCUtils {
private static NfcAdapter getNFCAdapter( Context context )
{
NfcManager manager =
NfcManager manager =
(NfcManager)context.getSystemService( Context.NFC_SERVICE );
return manager.getDefaultAdapter();
}
}

View file

@ -76,31 +76,31 @@ public class NagTurnReceiver extends BroadcastReceiver {
continue;
}
info.m_nextNag = figureNextNag( context,
info.m_nextNag = figureNextNag( context,
info.m_lastMoveMillis );
boolean lastWarning = 0 == info.m_nextNag;
long rowid = info.m_rowid;
GameSummary summary = DBUtils.getSummary( context, rowid,
GameSummary summary = DBUtils.getSummary( context, rowid,
10 );
String prevPlayer = null == summary
String prevPlayer = null == summary
? LocUtils.getString(context, R.string.prev_player)
: summary.getPrevPlayer();
Intent msgIntent =
Intent msgIntent =
GamesListDelegate.makeRowidIntent( context, rowid );
String millis = formatMillis( context,
now - info.m_lastMoveMillis);
String body =
String.format( LocUtils.getString(context,
String.format( LocUtils.getString(context,
R.string.nag_body_fmt),
prevPlayer, millis );
if ( lastWarning ) {
body = LocUtils
.getString( context, R.string.nag_warn_last_fmt, body );
}
Utils.postNotification( context, msgIntent,
R.string.nag_title, body,
Utils.postNotification( context, msgIntent,
R.string.nag_title, body,
(int)rowid );
}
@ -162,7 +162,7 @@ public class NagTurnReceiver extends BroadcastReceiver {
private static long[] getIntervals( Context context )
{
long[] result = null;
String pref =
String pref =
XWPrefs.getPrefsString( context, R.string.key_nag_intervals );
if ( null != pref && 0 < pref.length() ) {
if ( pref.equals( s_lastStr ) ) {
@ -205,7 +205,7 @@ public class NagTurnReceiver extends BroadcastReceiver {
for ( int[] datum : s_fmtData ) {
long val = seconds / datum[0];
if ( 1 <= val ) {
results.add( LocUtils.getQuantityString( context, datum[1],
results.add( LocUtils.getQuantityString( context, datum[1],
(int)val, val ) );
seconds %= datum[0];
}
@ -217,13 +217,13 @@ public class NagTurnReceiver extends BroadcastReceiver {
private static boolean getNagsDisabled( Context context )
{
if ( null == s_nagsDisabledNet ) {
boolean nagsDisabled =
XWPrefs.getPrefsBoolean( context, R.string.key_disable_nag,
boolean nagsDisabled =
XWPrefs.getPrefsBoolean( context, R.string.key_disable_nag,
false );
s_nagsDisabledNet = new Boolean( nagsDisabled );
}
if ( null == s_nagsDisabledSolo ) {
boolean nagsDisabled =
boolean nagsDisabled =
XWPrefs.getPrefsBoolean( context, R.string.key_disable_nag_solo,
true );
s_nagsDisabledSolo = new Boolean( nagsDisabled );

View file

@ -204,7 +204,7 @@ public class NetLaunchInfo {
calcValid();
}
private NetLaunchInfo( int gamID, String gamNam, int dictLang,
private NetLaunchInfo( int gamID, String gamNam, int dictLang,
String dictName, int nPlayers )
{
this();
@ -262,7 +262,7 @@ public class NetLaunchInfo {
}
public String inviteID()
{
{
String result = inviteID;
if ( null == result ) {
result = GameUtils.formatGameID( gameID );
@ -272,7 +272,7 @@ public class NetLaunchInfo {
}
public int gameID()
{
{
int result = gameID;
if ( 0 == result ) {
Assert.assertNotNull( inviteID );
@ -369,12 +369,12 @@ public class NetLaunchInfo {
private void init( Context context, String data )
{
CommsConnTypeSet supported = CommsConnTypeSet.getSupported( context );
try {
try {
JSONObject json = new JSONObject( data );
int flags = json.optInt(ADDRS_KEY, -1);
boolean hasAddrs = -1 != flags;
m_addrs = hasAddrs ?
m_addrs = hasAddrs ?
new CommsConnTypeSet( flags ) : new CommsConnTypeSet();
lang = json.optInt( MultiService.LANG, -1 );
@ -475,7 +475,7 @@ public class NetLaunchInfo {
return result;
}
public void addRelayInfo( String aRoom, String inviteID )
{
room = aRoom;

View file

@ -79,7 +79,7 @@ public class NetStateCache {
}
if ( now - s_lastNetCheck > (1000 * 20) ) { // 20 seconds
s_lastNetCheck = now;
boolean netAvail = getIsConnected( context );
if ( netAvail ) {
DbgUtils.logf( "netAvail(): second-guessing successful!!!" );
@ -168,7 +168,7 @@ public class NetStateCache {
}
}
}
private static class PvtBroadcastReceiver extends BroadcastReceiver {
private Runnable mNotifyLater;
private Handler mHandler;
@ -182,7 +182,7 @@ public class NetStateCache {
}
@Override
public void onReceive( Context context, Intent intent )
public void onReceive( Context context, Intent intent )
{
DbgUtils.assertOnUIThread();
@ -192,7 +192,7 @@ public class NetStateCache {
NetworkInfo ni = (NetworkInfo)intent.
getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
NetworkInfo.State state = ni.getState();
DbgUtils.logdf( "NetStateCache.PvtBroadcastReceiver.onReceive(state=%s)",
DbgUtils.logdf( "NetStateCache.PvtBroadcastReceiver.onReceive(state=%s)",
state.toString() );
boolean netAvail;

View file

@ -57,7 +57,7 @@ public class NetUtils {
public static byte PRX_GET_MSGS = 4;
public static byte PRX_PUT_MSGS = 5;
public static Socket makeProxySocket( Context context,
public static Socket makeProxySocket( Context context,
int timeoutMillis )
{
Socket socket = null;
@ -101,7 +101,7 @@ public class NetUtils {
}
try {
DataOutputStream outStream =
DataOutputStream outStream =
new DataOutputStream( socket.getOutputStream() );
outStream.writeShort( 2 + 2 + (2*nObits) + strLens );
outStream.writeByte( NetUtils.PROTOCOL_VERSION );
@ -119,7 +119,7 @@ public class NetUtils {
outStream.flush();
DataInputStream dis =
DataInputStream dis =
new DataInputStream( socket.getInputStream() );
short resLen = dis.readShort();
socket.close();
@ -149,7 +149,7 @@ public class NetUtils {
try {
Socket socket = makeProxySocket( context, 8000 );
if ( null != socket ) {
DataOutputStream outStream =
DataOutputStream outStream =
new DataOutputStream( socket.getOutputStream() );
// total packet size
@ -168,7 +168,7 @@ public class NetUtils {
}
outStream.flush();
DataInputStream dis =
DataInputStream dis =
new DataInputStream(socket.getInputStream());
short resLen = dis.readShort(); // total message length
short nameCount = dis.readShort();
@ -213,12 +213,12 @@ public class NetUtils {
return host;
}
protected static HttpURLConnection makeHttpConn( Context context,
protected static HttpURLConnection makeHttpConn( Context context,
String proc )
{
HttpURLConnection result = null;
try {
String url = String.format( "%s/%s",
String url = String.format( "%s/%s",
XWPrefs.getDefaultUpdateUrl( context ),
proc );
result = (HttpURLConnection)new URL(url).openConnection();
@ -239,7 +239,7 @@ public class NetUtils {
params.put( k_PARAMS, param.toString() );
String paramsString = getPostDataString( params );
if ( null != paramsString ) {
if ( null != paramsString ) {
try {
conn.setReadTimeout( 15000 );
conn.setConnectTimeout( 15000 );
@ -249,7 +249,7 @@ public class NetUtils {
conn.setFixedLengthStreamingMode( paramsString.length() );
OutputStream os = conn.getOutputStream();
BufferedWriter writer
BufferedWriter writer
= new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
writer.write( paramsString );
writer.flush();
@ -284,7 +284,7 @@ public class NetUtils {
return result;
}
private static String getPostDataString( Map<String, String> params )
private static String getPostDataString( Map<String, String> params )
{
String result = null;
try {

View file

@ -29,7 +29,7 @@ public class OnBootReceiver extends BroadcastReceiver {
@Override
public void onReceive( Context context, Intent intent )
{
if ( null != intent && null != intent.getAction()
if ( null != intent && null != intent.getAction()
&& intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED ) ) {
DbgUtils.logdf( "OnBootReceiver: got ACTION_BOOT_COMPLETED" );
startTimers( context );

View file

@ -49,23 +49,23 @@ public class PrefsActivity extends PreferenceActivity
m_dlgt.init( savedInstanceState );
}
@Override
protected void onStart()
protected void onStart()
{
LocUtils.xlatePreferences( this );
super.onStart();
}
@Override
protected void onResume()
protected void onResume()
{
super.onResume();
m_dlgt.onResume();
}
@Override
protected void onPause()
protected void onPause()
{
super.onPause();
m_dlgt.onPause();

View file

@ -163,22 +163,22 @@ public class PrefsDelegate extends DelegateBase
hideStuff();
}
@Override
protected void onResume()
protected void onResume()
{
super.onResume();
getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
protected void onPause()
protected void onPause()
{
getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
super.onPause();
}
@Override
public void onSharedPreferenceChanged( SharedPreferences sp, String key )
public void onSharedPreferenceChanged( SharedPreferences sp, String key )
{
if ( s_keysHash.containsKey( key ) ) {
switch( s_keysHash.get( key ) ) {
@ -305,17 +305,17 @@ public class PrefsDelegate extends DelegateBase
lp.setEntryValues( langs );
}
private void forceDictsMatch( String newLang )
private void forceDictsMatch( String newLang )
{
int code = DictLangCache.getLangLangCode( m_activity, newLang );
int[] keyIds = { R.string.key_default_dict,
int[] keyIds = { R.string.key_default_dict,
R.string.key_default_robodict };
for ( int id : keyIds ) {
String key = getString( id );
DictListPreference pref = (DictListPreference)m_activity.findPreference( key );
String curDict = pref.getValue().toString();
if ( ! DictUtils.dictExists( m_activity, curDict )
|| code != DictLangCache.getDictLangCode( m_activity,
|| code != DictLangCache.getDictLangCode( m_activity,
curDict ) ) {
pref.invalidate();
}

View file

@ -47,7 +47,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
private NoNameFound m_nnf;
public RefreshNamesTask( Context context, NoNameFound nnf,
int lang, int nInGame,
int lang, int nInGame,
Spinner getsResults )
{
super();
@ -65,7 +65,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
}
@Override
protected String[] doInBackground( Void...unused )
protected String[] doInBackground( Void...unused )
{
ArrayList<String> names = new ArrayList<String>();
DbgUtils.logf( "doInBackground()" );
@ -73,9 +73,9 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
try {
Socket socket = NetUtils.makeProxySocket( m_context, 15000 );
if ( null != socket ) {
DataOutputStream outStream =
DataOutputStream outStream =
new DataOutputStream( socket.getOutputStream() );
outStream.writeShort( 4 ); // total packet length
outStream.writeByte( NetUtils.PROTOCOL_VERSION );
outStream.writeByte( NetUtils.PRX_PUB_ROOMS );
@ -84,7 +84,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
outStream.flush();
// read result -- will block
DataInputStream dis =
DataInputStream dis =
new DataInputStream(socket.getInputStream());
short len = dis.readShort();
short nRooms = dis.readShort();
@ -112,7 +112,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
DbgUtils.loge( ioe );
}
DbgUtils.logf( "doInBackground() returning" );
return names.toArray( new String[names.size()] );
return names.toArray( new String[names.size()] );
}
// protected void onProgressUpdate(Integer... progress) {
@ -123,7 +123,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
protected void onPostExecute( String[] result )
{
DbgUtils.logf( "onPostExecute()" );
ArrayAdapter<String> adapter =
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( m_context,
android.R.layout.simple_spinner_item,
result );

View file

@ -43,9 +43,9 @@ public class RelayCheckBoxPreference extends ConfirmingCheckBoxPreference {
PrefsActivity activity = (PrefsActivity)getContext();
int count = DBUtils.getRelayGameCount( activity );
if ( 0 < count ) {
String msg = LocUtils.getString( activity,
String msg = LocUtils.getString( activity,
R.string.warn_relay_havegames );
msg += LocUtils.getQuantityString( activity, R.plurals.warn_relay_games_fmt,
msg += LocUtils.getQuantityString( activity, R.plurals.warn_relay_games_fmt,
count, count );
activity.showConfirmThen( msg, R.string.button_disable_relay,
android.R.string.cancel,

View file

@ -70,7 +70,7 @@ public class RelayInviteDelegate extends InviteDelegate {
private boolean m_immobileConfirmed;
private Activity m_activity;
public static void launchForResult( Activity activity, int nMissing,
public static void launchForResult( Activity activity, int nMissing,
RequestCode requestCode )
{
Intent intent = new Intent( activity, RelayInviteActivity.class );
@ -87,9 +87,9 @@ public class RelayInviteDelegate extends InviteDelegate {
protected void init( Bundle savedInstanceState )
{
String msg = getString( R.string.button_invite );
msg = getQuantityString( R.plurals.invite_relay_desc_fmt, m_nMissing,
msg = getQuantityString( R.plurals.invite_relay_desc_fmt, m_nMissing,
m_nMissing, msg );
super.init( R.id.button_invite, R.id.button_add, R.id.button_clear,
super.init( R.id.button_invite, R.id.button_add, R.id.button_clear,
R.id.invite_desc, msg );
// getBundledData( savedInstanceState );
@ -120,7 +120,7 @@ public class RelayInviteDelegate extends InviteDelegate {
rebuildList( true );
}
// protected void onSaveInstanceState( Bundle outState )
// protected void onSaveInstanceState( Bundle outState )
// {
// outState.putString( SAVE_NAME, m_pendingName );
// outState.putString( SAVE_NUMBER, m_pendingNumber );
@ -133,8 +133,8 @@ public class RelayInviteDelegate extends InviteDelegate {
// m_pendingNumber = bundle.getString( SAVE_NUMBER );
// }
// }
// protected void onActivityResult( int requestCode, int resultCode,
// protected void onActivityResult( int requestCode, int resultCode,
// Intent data )
// {
// // super.onActivityResult( requestCode, resultCode, data );
@ -148,7 +148,7 @@ public class RelayInviteDelegate extends InviteDelegate {
// }
// protected Dialog onCreateDialog( int id )
// {
// {
// Dialog dialog = super.onCreateDialog( id );
// if ( null == dialog ) {
// DialogInterface.OnClickListener lstnr;
@ -196,7 +196,7 @@ public class RelayInviteDelegate extends InviteDelegate {
new ListOpponentsTask( m_activity, relayIDs, rowIDss[0] ).execute();
}
// Intent intent = new Intent( Intent.ACTION_PICK,
// Intent intent = new Intent( Intent.ACTION_PICK,
// ContactsContract.Contacts.CONTENT_URI );
// intent.setType( Phone.CONTENT_TYPE );
// startActivityForResult( intent, GET_CONTACT );
@ -230,7 +230,7 @@ public class RelayInviteDelegate extends InviteDelegate {
}
@Override
protected void tryEnable()
protected void tryEnable()
{
if ( null != m_devIDRecs ) {
int nPlayers = 0;
@ -265,8 +265,8 @@ public class RelayInviteDelegate extends InviteDelegate {
break;
case DlgDelegate.DISMISS_BUTTON:
if ( Action.USE_IMMOBILE_ACTION == action && m_immobileConfirmed ) {
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
Action.POST_WARNING_ACTION );
}
break;
@ -291,9 +291,9 @@ public class RelayInviteDelegate extends InviteDelegate {
// {
// Uri data = intent.getData();
// Cursor cursor = m_activity
// .managedQuery( data,
// new String[] { Phone.DISPLAY_NAME,
// Phone.NUMBER,
// .managedQuery( data,
// new String[] { Phone.DISPLAY_NAME,
// Phone.NUMBER,
// Phone.TYPE },
// null, null, null );
// // Have seen a crash reporting
@ -302,10 +302,10 @@ public class RelayInviteDelegate extends InviteDelegate {
// // long time to return. Be safe.
// if ( null != cursor && !cursor.isClosed() ) {
// if ( cursor.moveToFirst() ) {
// String name =
// String name =
// cursor.getString( cursor.
// getColumnIndex( Phone.DISPLAY_NAME));
// String number =
// String number =
// cursor.getString( cursor.
// getColumnIndex( Phone.NUMBER ) );
@ -314,14 +314,14 @@ public class RelayInviteDelegate extends InviteDelegate {
// // m_pendingName = name;
// // m_pendingNumber = number;
// if ( Phone.TYPE_MOBILE == type ) {
// showConfirmThen( R.string.warn_unlimited,
// R.string.button_yes,
// showConfirmThen( R.string.warn_unlimited,
// R.string.button_yes,
// Action.POST_WARNING_ACTION );
// } else {
// m_immobileConfirmed = false;
// String msg = getString( R.string.warn_nomobile_fmt,
// String msg = getString( R.string.warn_nomobile_fmt,
// number, name );
// showConfirmThen( msg, R.string.button_yes,
// showConfirmThen( msg, R.string.button_yes,
// Action.USE_IMMOBILE_ACTION );
// }
// }
@ -426,7 +426,7 @@ public class RelayInviteDelegate extends InviteDelegate {
m_items = new SMSListItem[m_devIDRecs.size()];
}
public Object getItem( final int position )
public Object getItem( final int position )
{
// For some reason I can't cache items to be returned.
// Checking/unchecking breaks for some but not all items,
@ -434,13 +434,13 @@ public class RelayInviteDelegate extends InviteDelegate {
// view. So build them anew each time (but still cache
// for by-index access.)
SMSListItem item =
SMSListItem item =
(SMSListItem)inflate( R.layout.smsinviter_item );
item.setChecked( m_devIDRecs.get(position).m_isChecked );
CompoundButton.OnCheckedChangeListener lstnr =
new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton bv,
public void onCheckedChanged( CompoundButton bv,
boolean isChecked ) {
m_devIDRecs.get(position).m_isChecked = isChecked;
tryEnable();
@ -456,7 +456,7 @@ public class RelayInviteDelegate extends InviteDelegate {
if ( XWPrefs.getCanInviteMulti( m_activity ) && 1 < m_nMissing ) {
Spinner spinner = (Spinner)
item.findViewById(R.id.nperdev_spinner);
ArrayAdapter<String> adapter =
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( m_activity, android.R.layout
.simple_spinner_item );
for ( int ii = 1; ii <= m_nMissing; ++ii ) {
@ -466,8 +466,8 @@ public class RelayInviteDelegate extends InviteDelegate {
spinner.setAdapter( adapter );
spinner.setVisibility( View.VISIBLE );
spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
long id )
{
rec.m_nPlayers = 1 + pos;
@ -481,7 +481,7 @@ public class RelayInviteDelegate extends InviteDelegate {
return item;
}
public View getView( final int position, View convertView,
public View getView( final int position, View convertView,
ViewGroup parent ) {
return (View)getItem( position );
}

View file

@ -57,7 +57,7 @@ import org.eehouse.android.xw4.jni.XwJNI;
import org.eehouse.android.xw4.jni.JNIThread;
import org.eehouse.android.xw4.loc.LocUtils;
public class RelayService extends XWService
public class RelayService extends XWService
implements NetStateCache.StateChangedIf {
private static final int MAX_SEND = 1024;
private static final int MAX_BUF = MAX_SEND - 2;
@ -96,14 +96,14 @@ public class RelayService extends XWService
private static int s_nextPacketID = 1;
private static boolean s_gcmWorking = false;
private static boolean s_registered = false;
private static CommsAddrRec s_addr =
private static CommsAddrRec s_addr =
new CommsAddrRec( CommsConnType.COMMS_CONN_RELAY );
private Thread m_fetchThread = null;
private Thread m_UDPReadThread = null;
private Thread m_UDPWriteThread = null;
private DatagramSocket m_UDPSocket;
private LinkedBlockingQueue<PacketData> m_queue =
private LinkedBlockingQueue<PacketData> m_queue =
new LinkedBlockingQueue<PacketData>();
private Handler m_handler;
private Runnable m_onInactivity;
@ -190,7 +190,7 @@ public class RelayService extends XWService
context.startService( intent );
}
public static void inviteRemote( Context context, int destDevID,
public static void inviteRemote( Context context, int destDevID,
String relayID, NetLaunchInfo nli )
{
int myDevID = DevID.getRelayDevIDInt( context );
@ -231,7 +231,7 @@ public class RelayService extends XWService
return result;
}
public static int sendNoConnPacket( Context context, long rowid, String relayID,
public static int sendNoConnPacket( Context context, long rowid, String relayID,
byte[] msg )
{
int result = -1;
@ -251,7 +251,7 @@ public class RelayService extends XWService
s_registered = false;
}
private void receiveInvitation( int srcDevID, NetLaunchInfo nli )
private void receiveInvitation( int srcDevID, NetLaunchInfo nli )
{
DbgUtils.logdf( "receiveInvitation: got nli from %d: %s", srcDevID,
nli.toString() );
@ -266,9 +266,9 @@ public class RelayService extends XWService
makeGame( nli );
} else {
Intent intent = MultiService
.makeMissingDictIntent( this, nli,
.makeMissingDictIntent( this, nli,
DictFetchOwner.OWNER_RELAY );
MultiService.postMissingDictNotification( this, intent,
MultiService.postMissingDictNotification( this, intent,
nli.gameID() );
}
}
@ -280,23 +280,23 @@ public class RelayService extends XWService
|| XWPrefs.getRelayInviteToSelfEnabled( this )) {
if ( DictLangCache.haveDict( this, nli.lang, nli.dict ) ) {
long rowid = GameUtils.makeNewMultiGame( this, nli,
long rowid = GameUtils.makeNewMultiGame( this, nli,
new RelayMsgSink(),
getUtilCtxt() );
if ( DBUtils.ROWID_NOTFOUND != rowid ) {
if ( null != nli.gameName && 0 < nli.gameName.length() ) {
DBUtils.setName( this, rowid, nli.gameName );
}
String body = LocUtils.getString( this,
String body = LocUtils.getString( this,
R.string.new_relay_body );
GameUtils.postInvitedNotification( this, nli.gameID(), body,
GameUtils.postInvitedNotification( this, nli.gameID(), body,
rowid );
}
} else {
Intent intent = MultiService
.makeMissingDictIntent( this, nli,
.makeMissingDictIntent( this, nli,
DictFetchOwner.OWNER_RELAY );
MultiService.postMissingDictNotification( this, intent,
MultiService.postMissingDictNotification( this, intent,
nli.gameID() );
}
}
@ -305,7 +305,7 @@ public class RelayService extends XWService
// Exists to get incoming data onto the main thread
private static void postData( Context context, long rowid, byte[] msg )
{
DbgUtils.logdf( "RelayService::postData: packet of length %d for token %d",
DbgUtils.logdf( "RelayService::postData: packet of length %d for token %d",
msg.length, rowid );
if ( DBUtils.haveGame( context, rowid ) ) {
Intent intent = getIntentTo( context, MsgCmds.RECEIVE )
@ -323,7 +323,7 @@ public class RelayService extends XWService
startService( context );
}
public static void processGameMsgs( Context context, String relayId,
public static void processGameMsgs( Context context, String relayId,
String[] msgs64 )
{
Intent intent = getIntentTo( context, MsgCmds.PROCESS_GAME_MSGS )
@ -356,8 +356,8 @@ public class RelayService extends XWService
public void onCreate()
{
super.onCreate();
m_lastGamePacketReceived =
XWPrefs.getPrefsLong( this, R.string.key_last_packet,
m_lastGamePacketReceived =
XWPrefs.getPrefsLong( this, R.string.key_last_packet,
Utils.getCurSeconds() );
m_handler = new Handler();
@ -365,7 +365,7 @@ public class RelayService extends XWService
public void run() {
DbgUtils.logdf( "RelayService: m_onInactivity fired" );
if ( !shouldMaintainConnection() ) {
NetStateCache.unregister( RelayService.this,
NetStateCache.unregister( RelayService.this,
RelayService.this );
stopSelf();
} else {
@ -387,7 +387,7 @@ public class RelayService extends XWService
cmd = null;
}
if ( null != cmd ) {
DbgUtils.logdf( "RelayService::onStartCommand: cmd=%s",
DbgUtils.logdf( "RelayService::onStartCommand: cmd=%s",
cmd.toString() );
switch( cmd ) {
case PROCESS_GAME_MSGS:
@ -419,7 +419,7 @@ public class RelayService extends XWService
break;
case GOT_INVITE:
int srcDevID = intent.getIntExtra( INVITE_FROM, 0 );
NetLaunchInfo nli
NetLaunchInfo nli
= new NetLaunchInfo( this, intent.getStringExtra(NLI_DATA) );
receiveInvitation( srcDevID, nli );
break;
@ -470,7 +470,7 @@ public class RelayService extends XWService
if ( null == result ) {
result = Service.START_STICKY_COMPATIBILITY;
}
}
NetStateCache.register( this, this );
resetExitTimer();
@ -552,7 +552,7 @@ public class RelayService extends XWService
DbgUtils.logf( "RelayService:read thread running" );
byte[] buf = new byte[1024];
for ( ; ; ) {
DatagramPacket packet =
DatagramPacket packet =
new DatagramPacket( buf, buf.length );
try {
m_UDPSocket.receive( packet );
@ -628,8 +628,8 @@ public class RelayService extends XWService
m_UDPSocket.send( outPacket );
int pid = outData.m_packetID;
DbgUtils.logdf( "Sent udp packet, cmd=%s, id=%d,"
+ " of length %d",
outData.m_cmd.toString(),
+ " of length %d",
outData.m_cmd.toString(),
pid, outPacket.getLength());
synchronized( s_packetsSent ) {
s_packetsSent.add( pid );
@ -700,10 +700,10 @@ public class RelayService extends XWService
sendAckIf( header );
}
DbgUtils.logdf( "RelayService.gotPacket: cmd=%s", header.m_cmd.toString() );
switch ( header.m_cmd ) {
switch ( header.m_cmd ) {
case XWPDEV_UNAVAIL:
int unavail = dis.readInt();
DbgUtils.logf( "relay unvailable for another %d seconds",
DbgUtils.logf( "relay unvailable for another %d seconds",
unavail );
String str = getVLIString( dis );
sendResult( MultiEvent.RELAY_ALERT, str );
@ -711,7 +711,7 @@ public class RelayService extends XWService
case XWPDEV_ALERT:
str = getVLIString( dis );
Intent intent = GamesListDelegate.makeAlertIntent( this, str );
Utils.postNotification( this, intent,
Utils.postNotification( this, intent,
R.string.relay_alert_title,
str, str.hashCode() );
break;
@ -725,8 +725,8 @@ public class RelayService extends XWService
case XWPDEV_REGRSP:
str = getVLIString( dis );
short maxIntervalSeconds = dis.readShort();
DbgUtils.logdf( "got relayid %s (%d), maxInterval %d", str,
Integer.parseInt( str, 16 ),
DbgUtils.logdf( "got relayid %s (%d), maxInterval %d", str,
Integer.parseInt( str, 16 ),
maxIntervalSeconds );
setMaxIntervalSeconds( maxIntervalSeconds );
DevID.setRelayDevID( this, str );
@ -811,7 +811,7 @@ public class RelayService extends XWService
// if none has been assigned yet) and the deviceID IFF it's
// changed since we last registered (Otherwise just ID_TYPE_NONE
// and no string)
//
//
// How do we know if we need to register? We keep a timestamp
// indicating when we last got a reg-response. When the GCM id
// changes, that timestamp is cleared.
@ -841,7 +841,7 @@ public class RelayService extends XWService
writeVLIString( out, devid );
}
DbgUtils.logdf( "registering devID \"%s\" (type=%s)", devid,
DbgUtils.logdf( "registering devID \"%s\" (type=%s)", devid,
typ.toString() );
out.writeShort( BuildConstants.CLIENT_VERS_RELAY );
@ -902,7 +902,7 @@ public class RelayService extends XWService
postPacket( bas, XWRelayReg.XWPDEV_MSG );
} catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe );
}
}
}
private void sendNoConnMessage( long rowid, String relayID, byte[] msg )
@ -918,7 +918,7 @@ public class RelayService extends XWService
postPacket( bas, XWRelayReg.XWPDEV_MSGNOCONN );
} catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe );
}
}
}
private void sendInvitation( int srcDevID, int destDevID, String relayID,
@ -931,7 +931,7 @@ public class RelayService extends XWService
byte[] nliData = XwJNI.nliToStream( nli );
if ( BuildConfig.DEBUG ) {
NetLaunchInfo tmp = XwJNI.nliFromStream( nliData );
DbgUtils.logdf( "sendInvitation: compare these: %s vs %s",
DbgUtils.logdf( "sendInvitation: compare these: %s vs %s",
nli.toString(), tmp.toString() );
}
@ -952,7 +952,7 @@ public class RelayService extends XWService
postPacket( bas, XWRelayReg.XWPDEV_INVITE );
} catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe );
}
}
}
private void sendAckIf( PacketHeader header )
@ -1046,7 +1046,7 @@ public class RelayService extends XWService
int nameCount = relayIDs.length;
ArrayList<String> idsWMsgs = new ArrayList<String>( nameCount );
ArrayList<Boolean> isLocals = new ArrayList<Boolean>( nameCount );
ArrayList<BackMoveResult> bmrs =
ArrayList<BackMoveResult> bmrs =
new ArrayList<BackMoveResult>( nameCount );
boolean[] isLocalP = new boolean[1];
@ -1068,7 +1068,7 @@ public class RelayService extends XWService
private Context m_context;
private HashMap<String,ArrayList<byte[]>> m_msgHash;
public AsyncSender( Context context,
public AsyncSender( Context context,
HashMap<String,ArrayList<byte[]>> msgHash )
{
m_context = context;
@ -1088,12 +1088,12 @@ public class RelayService extends XWService
// Build up a buffer containing everything but the total
// message length and number of relayIDs in the message.
try {
ByteArrayOutputStream store =
ByteArrayOutputStream store =
new ByteArrayOutputStream( MAX_BUF ); // mem
DataOutputStream outBuf = new DataOutputStream( store );
int msgLen = 4; // relayID count + protocol stuff
int nRelayIDs = 0;
Iterator<String> iter = m_msgHash.keySet().iterator();
while ( iter.hasNext() ) {
String relayID = iter.next();
@ -1127,7 +1127,7 @@ public class RelayService extends XWService
// copy in the formatted buffer
Socket socket = NetUtils.makeProxySocket( m_context, 8000 );
if ( null != socket ) {
DataOutputStream outStream =
DataOutputStream outStream =
new DataOutputStream( socket.getOutputStream() );
outStream.writeShort( msgLen );
outStream.writeByte( NetUtils.PROTOCOL_VERSION );
@ -1167,7 +1167,7 @@ public class RelayService extends XWService
Assert.assertNull( m_msgLists );
}
}
@Override
public int sendViaRelay( byte[] buf, int gameID )
{
@ -1217,7 +1217,7 @@ public class RelayService extends XWService
DbgUtils.logf( "Weird: got ack %d but never sent", packetID );
}
DbgUtils.logdf( "RelayService.noteAck(): Got ack for %d; "
+ "there are %d unacked packets",
+ "there are %d unacked packets",
packetID, s_packetsSent.size() );
}
}
@ -1230,7 +1230,7 @@ public class RelayService extends XWService
// UDP socket's no good as a return address after several
// minutes of inactivity, so do something after that time.
m_handler.postDelayed( m_onInactivity,
m_handler.postDelayed( m_onInactivity,
getMaxIntervalSeconds() * 1000 );
}
@ -1256,7 +1256,7 @@ public class RelayService extends XWService
stopUDPThreadsIf();
}
private static void un2vli( int nn, OutputStream os )
private static void un2vli( int nn, OutputStream os )
throws java.io.IOException
{
int indx = 0;
@ -1289,7 +1289,7 @@ public class RelayService extends XWService
done = 0 != (byt & 0x80);
if ( done ) {
byt &= 0x7F;
}
}
result |= byt << (7 * count);
}
@ -1312,7 +1312,7 @@ public class RelayService extends XWService
{
if ( m_maxIntervalSeconds != maxIntervalSeconds ) {
m_maxIntervalSeconds = maxIntervalSeconds;
XWPrefs.setPrefsInt( this, R.string.key_udp_interval,
XWPrefs.setPrefsInt( this, R.string.key_udp_interval,
maxIntervalSeconds );
}
}
@ -1320,7 +1320,7 @@ public class RelayService extends XWService
private int getMaxIntervalSeconds()
{
if ( 0 == m_maxIntervalSeconds ) {
m_maxIntervalSeconds =
m_maxIntervalSeconds =
XWPrefs.getPrefsInt( this, R.string.key_udp_interval, 60 );
}
return m_maxIntervalSeconds;
@ -1412,7 +1412,7 @@ public class RelayService extends XWService
try {
m_packetID = nextPacketID( m_cmd );
DataOutputStream out = new DataOutputStream( bas );
DbgUtils.logdf( "RelayService.makeHeader(): building packet with cmd %s",
DbgUtils.logdf( "RelayService.makeHeader(): building packet with cmd %s",
m_cmd.toString() );
out.writeByte( XWPDevProto.XWPDEV_PROTO_VERSION_1.ordinal() );
un2vli( m_packetID, out );

View file

@ -86,9 +86,9 @@ public class SMSInviteDelegate extends InviteDelegate {
protected void init( Bundle savedInstanceState )
{
String msg = getString( R.string.button_invite );
msg = getQuantityString( R.plurals.invite_sms_desc_fmt, m_nMissing,
msg = getQuantityString( R.plurals.invite_sms_desc_fmt, m_nMissing,
m_nMissing, msg );
super.init( R.id.button_invite, R.id.button_add, R.id.button_clear,
super.init( R.id.button_invite, R.id.button_add, R.id.button_clear,
R.id.invite_desc, msg );
getBundledData( savedInstanceState );
@ -105,7 +105,7 @@ public class SMSInviteDelegate extends InviteDelegate {
rebuildList( true );
}
protected void onSaveInstanceState( Bundle outState )
protected void onSaveInstanceState( Bundle outState )
{
outState.putString( SAVE_NAME, m_pendingName );
outState.putString( SAVE_NUMBER, m_pendingNumber );
@ -118,9 +118,9 @@ public class SMSInviteDelegate extends InviteDelegate {
m_pendingNumber = bundle.getString( SAVE_NUMBER );
}
}
@Override
protected void onActivityResult( RequestCode requestCode, int resultCode,
protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data )
{
// super.onActivityResult( requestCode, resultCode, data );
@ -134,7 +134,7 @@ public class SMSInviteDelegate extends InviteDelegate {
}
protected Dialog onCreateDialog( int id )
{
{
Dialog dialog = super.onCreateDialog( id );
if ( null == dialog ) {
DialogInterface.OnClickListener lstnr;
@ -151,8 +151,8 @@ public class SMSInviteDelegate extends InviteDelegate {
PhoneRec rec = new PhoneRec( number );
m_pendingNumber = number;
m_pendingName = null;
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
Action.POST_WARNING_ACTION );
}
};
@ -170,7 +170,7 @@ public class SMSInviteDelegate extends InviteDelegate {
protected void scan()
{
Intent intent = new Intent( Intent.ACTION_PICK,
Intent intent = new Intent( Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI );
intent.setType( Phone.CONTENT_TYPE );
startActivityForResult( intent, RequestCode.GET_CONTACT );
@ -179,7 +179,7 @@ public class SMSInviteDelegate extends InviteDelegate {
protected void clearSelected()
{
int count = countChecks();
String msg = getQuantityString( R.plurals.confirm_clear_sms_fmt,
String msg = getQuantityString( R.plurals.confirm_clear_sms_fmt,
count, count );
showConfirmThen( msg, Action.CLEAR_ACTION );
}
@ -207,7 +207,7 @@ public class SMSInviteDelegate extends InviteDelegate {
}
@Override
protected void tryEnable()
protected void tryEnable()
{
if ( null != m_phoneRecs ) {
int nPlayers = 0;
@ -246,8 +246,8 @@ public class SMSInviteDelegate extends InviteDelegate {
break;
case DlgDelegate.DISMISS_BUTTON:
if ( Action.USE_IMMOBILE_ACTION == action && m_immobileConfirmed ) {
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
Action.POST_WARNING_ACTION );
}
break;
@ -272,9 +272,9 @@ public class SMSInviteDelegate extends InviteDelegate {
{
Uri data = intent.getData();
Cursor cursor = m_activity
.managedQuery( data,
new String[] { Phone.DISPLAY_NAME,
Phone.NUMBER,
.managedQuery( data,
new String[] { Phone.DISPLAY_NAME,
Phone.NUMBER,
Phone.TYPE },
null, null, null );
// Have seen a crash reporting
@ -283,10 +283,10 @@ public class SMSInviteDelegate extends InviteDelegate {
// long time to return. Be safe.
if ( null != cursor && !cursor.isClosed() ) {
if ( cursor.moveToFirst() ) {
String name =
String name =
cursor.getString( cursor.
getColumnIndex( Phone.DISPLAY_NAME));
String number =
String number =
cursor.getString( cursor.
getColumnIndex( Phone.NUMBER ) );
@ -295,14 +295,14 @@ public class SMSInviteDelegate extends InviteDelegate {
m_pendingName = name;
m_pendingNumber = number;
if ( Phone.TYPE_MOBILE == type ) {
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
Action.POST_WARNING_ACTION );
} else {
m_immobileConfirmed = false;
String msg = getString( R.string.warn_nomobile_fmt,
String msg = getString( R.string.warn_nomobile_fmt,
number, name );
showConfirmThen( msg, R.string.button_yes,
showConfirmThen( msg, R.string.button_yes,
Action.USE_IMMOBILE_ACTION );
}
}
@ -415,7 +415,7 @@ public class SMSInviteDelegate extends InviteDelegate {
m_items = new SMSListItem[m_phoneRecs.size()];
}
public Object getItem( final int position )
public Object getItem( final int position )
{
// For some reason I can't cache items to be returned.
// Checking/unchecking breaks for some but not all items,
@ -423,13 +423,13 @@ public class SMSInviteDelegate extends InviteDelegate {
// view. So build them anew each time (but still cache
// for by-index access.)
SMSListItem item =
SMSListItem item =
(SMSListItem)inflate( R.layout.smsinviter_item );
item.setChecked( m_phoneRecs.get(position).m_isChecked );
CompoundButton.OnCheckedChangeListener lstnr =
new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton bv,
public void onCheckedChanged( CompoundButton bv,
boolean isChecked ) {
m_phoneRecs.get(position).m_isChecked = isChecked;
tryEnable();
@ -445,7 +445,7 @@ public class SMSInviteDelegate extends InviteDelegate {
if ( XWPrefs.getCanInviteMulti( m_activity ) && 1 < m_nMissing ) {
Spinner spinner = (Spinner)
item.findViewById(R.id.nperdev_spinner);
ArrayAdapter<String> adapter =
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( m_activity, android.R.layout
.simple_spinner_item );
for ( int ii = 1; ii <= m_nMissing; ++ii ) {
@ -455,8 +455,8 @@ public class SMSInviteDelegate extends InviteDelegate {
spinner.setAdapter( adapter );
spinner.setVisibility( View.VISIBLE );
spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
long id )
{
rec.m_nPlayers = 1 + pos;
@ -470,7 +470,7 @@ public class SMSInviteDelegate extends InviteDelegate {
return item;
}
public View getView( final int position, View convertView,
public View getView( final int position, View convertView,
ViewGroup parent ) {
return (View)getItem( position );
}

View file

@ -28,8 +28,8 @@ import android.util.AttributeSet;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class SMSListItem extends LinearLayout {
public SMSListItem( Context cx, AttributeSet as )
public SMSListItem( Context cx, AttributeSet as )
{
super( cx, as );
}

View file

@ -96,11 +96,11 @@ public class SMSService extends XWService {
private static final String PHONE = "PHONE";
private static final String GAMEDATA_STR = "GD";
private static final String PHONE_RECS_KEY =
private static final String PHONE_RECS_KEY =
SMSService.class.getName() + "_PHONES";
private static Boolean s_showToasts = null;
// All messages are base64-encoded byte arrays. The first byte is
// always one of these. What follows depends.
private enum SMS_CMD { NONE, INVITE, DATA, DEATH, ACK, };
@ -184,7 +184,7 @@ public class SMSService extends XWService {
s_phoneInfo = null;
}
public static void smsToastEnable( boolean newVal )
public static void smsToastEnable( boolean newVal )
{
s_showToasts = newVal;
}
@ -196,7 +196,7 @@ public class SMSService extends XWService {
}
// NBS case
public static void handleFrom( Context context, byte[] buffer,
public static void handleFrom( Context context, byte[] buffer,
String phone )
{
Intent intent = getIntentTo( context, SMSAction.HANDLEDATA );
@ -216,7 +216,7 @@ public class SMSService extends XWService {
context.startService( intent );
}
public static int sendPacket( Context context, String phone,
public static int sendPacket( Context context, String phone,
int gameID, byte[] binmsg )
{
int nSent = -1;
@ -258,7 +258,7 @@ public class SMSService extends XWService {
String tmp = msg.substring( 1 + msg.lastIndexOf( " " ) );
int headerLen = XWApp.SMS_PUBLIC_HEADER.length();
String hashString =
String hashString =
msg.substring( headerLen, headerLen + 4 );
int hashRead = Integer.parseInt( hashString, 16 );
int hashCode = 0xFFFF & tmp.hashCode();
@ -283,7 +283,7 @@ public class SMSService extends XWService {
private static boolean showToasts( Context context )
{
if ( null == s_showToasts ) {
s_showToasts =
s_showToasts =
XWPrefs.getPrefsBoolean( context, R.string.key_show_sms, false );
}
return s_showToasts;
@ -378,8 +378,8 @@ public class SMSService extends XWService {
result = Service.START_STICKY;
}
if ( Service.START_NOT_STICKY == result
if ( Service.START_NOT_STICKY == result
|| !XWPrefs.getSMSEnabled( this ) ) {
stopSelf( startId );
}
@ -469,7 +469,7 @@ public class SMSService extends XWService {
return result;
}
private byte[][] breakAndEncode( byte msg[] ) throws java.io.IOException
private byte[][] breakAndEncode( byte msg[] ) throws java.io.IOException
{
byte[][] result = null;
int count = (msg.length + (MAX_LEN_BINARY-1)) / MAX_LEN_BINARY;
@ -485,7 +485,7 @@ public class SMSService extends XWService {
len = MAX_LEN_BINARY;
}
end += len;
byte[] part = new byte[4 + len];
byte[] part = new byte[4 + len];
part[0] = (byte)SMS_PROTO_VERSION;
part[1] = (byte)msgID;
part[2] = (byte)ii;
@ -505,7 +505,7 @@ public class SMSService extends XWService {
private void receive( SMS_CMD cmd, byte[] data, String phone )
{
DbgUtils.logf( "SMSService.receive(cmd=%s)", cmd.toString() );
DataInputStream dis =
DataInputStream dis =
new DataInputStream( new ByteArrayInputStream(data) );
try {
switch( cmd ) {
@ -517,9 +517,9 @@ public class SMSService extends XWService {
makeForInvite( phone, nli );
} else {
Intent intent = MultiService
.makeMissingDictIntent( this, nli,
.makeMissingDictIntent( this, nli,
DictFetchOwner.OWNER_SMS );
MultiService.postMissingDictNotification( this, intent,
MultiService.postMissingDictNotification( this, intent,
nli.gameID() );
}
} else {
@ -538,7 +538,7 @@ public class SMSService extends XWService {
break;
case ACK:
gameID = dis.readInt();
sendResult( MultiEvent.NEWGAME_SUCCESS,
sendResult( MultiEvent.NEWGAME_SUCCESS,
gameID );
break;
default:
@ -566,7 +566,7 @@ public class SMSService extends XWService {
}
}
private boolean tryAssemble( String senderPhone, int id, int index,
private boolean tryAssemble( String senderPhone, int id, int index,
int count, byte[] msg )
{
boolean success = true;
@ -574,8 +574,8 @@ public class SMSService extends XWService {
success = disAssemble( senderPhone, msg );
} else if ( count > 0 && count < MAX_MSG_COUNT && index < count ) {
// required? Should always be in main thread.
synchronized( s_partialMsgs ) {
HashMap<Integer, MsgStore> perPhone =
synchronized( s_partialMsgs ) {
HashMap<Integer, MsgStore> perPhone =
s_partialMsgs.get( senderPhone );
if ( null == perPhone ) {
perPhone = new HashMap <Integer, MsgStore>();
@ -601,7 +601,7 @@ public class SMSService extends XWService {
private boolean disAssemble( String senderPhone, byte[] fullMsg )
{
boolean success = false;
DataInputStream dis =
DataInputStream dis =
new DataInputStream( new ByteArrayInputStream(fullMsg) );
try {
byte proto = dis.readByte();
@ -638,7 +638,7 @@ public class SMSService extends XWService {
private void postNotification( String phone, int gameID, long rowid )
{
String owner = Utils.phoneToContact( this, phone, true );
String body = LocUtils.getString( this, R.string.new_name_body_fmt,
String body = LocUtils.getString( this, R.string.new_name_body_fmt,
owner );
GameUtils.postInvitedNotification( this, gameID, body, rowid );
}
@ -681,7 +681,7 @@ public class SMSService extends XWService {
PendingIntent sent = makeStatusIntent( MSG_SENT );
PendingIntent delivery = makeStatusIntent( MSG_DELIVERED );
for ( byte[] fragment : fragments ) {
mgr.sendDataMessage( phone, null, nbsPort, fragment, sent,
mgr.sendDataMessage( phone, null, nbsPort, fragment, sent,
delivery );
DbgUtils.logf( "SMSService.sendBuffers(): sent %d byte fragment",
fragment.length );
@ -703,8 +703,8 @@ public class SMSService extends XWService {
DbgUtils.showf( this, "Sent msg %d", s_nSent );
}
ConnStatusHandler.updateStatusOut( this, null,
CommsConnType.COMMS_CONN_SMS,
ConnStatusHandler.updateStatusOut( this, null,
CommsConnType.COMMS_CONN_SMS,
success );
return success;
}
@ -721,7 +721,7 @@ public class SMSService extends XWService {
{
m_sentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1)
public void onReceive(Context arg0, Intent arg1)
{
switch ( getResultCode() ) {
case Activity.RESULT_OK:
@ -830,7 +830,7 @@ public class SMSService extends XWService {
m_msgsData[index] = msg;
return this;
}
public boolean isComplete()
{
int count = null != m_msgsText ? m_msgsText.length : m_msgsData.length;
@ -838,7 +838,7 @@ public class SMSService extends XWService {
return complete;
}
public String messageText()
public String messageText()
{
StringBuffer sb = new StringBuffer(m_fullLength);
for ( String msg : m_msgsText ) {
@ -847,7 +847,7 @@ public class SMSService extends XWService {
return sb.toString();
}
public byte[] messageData()
public byte[] messageData()
{
byte[] result = new byte[m_fullLength];
int indx = 0;

View file

@ -24,9 +24,9 @@ import android.os.Bundle;
public class StudyListActivity extends XWActivity {
@Override
protected void onCreate( Bundle savedInstanceState )
protected void onCreate( Bundle savedInstanceState )
{
StudyListDelegate dlgt =
StudyListDelegate dlgt =
new StudyListDelegate( this, savedInstanceState );
super.onCreate( savedInstanceState, dlgt );
}

View file

@ -55,7 +55,7 @@ public class StudyListDelegate extends ListDelegateBase
protected static final int NO_LANG = -1;
protected static final String START_LANG = "START_LANG";
private Activity m_activity;
private Spinner m_spinner;
private View m_pickView; // LinearLayout, actually
@ -73,7 +73,7 @@ public class StudyListDelegate extends ListDelegateBase
m_activity = delegator.getActivity();
}
protected void init( Bundle savedInstanceState )
protected void init( Bundle savedInstanceState )
{
m_list = (ListView)findViewById( android.R.id.list );
@ -96,17 +96,17 @@ public class StudyListDelegate extends ListDelegateBase
}
@Override
public boolean onPrepareOptionsMenu( Menu menu )
public boolean onPrepareOptionsMenu( Menu menu )
{
int nSel = m_checkeds.size();
Utils.setItemVisible( menu, R.id.slmenu_copy_sel, 0 < nSel );
Utils.setItemVisible( menu, R.id.slmenu_clear_sel, 0 < nSel );
Utils.setItemVisible( menu, R.id.slmenu_select_all,
Utils.setItemVisible( menu, R.id.slmenu_select_all,
m_words.length > nSel );
Utils.setItemVisible( menu, R.id.slmenu_deselect_all, 0 < nSel );
boolean enable = 1 == nSel;
if ( enable ) {
String title = getString( R.string.button_lookup_fmt,
String title = getString( R.string.button_lookup_fmt,
getSelWords()[0] );
menu.findItem( R.id.slmenu_lookup_sel ).setTitle( title );
}
@ -121,11 +121,11 @@ public class StudyListDelegate extends ListDelegateBase
switch ( item.getItemId() ) {
case R.id.slmenu_copy_sel:
showNotAgainDlgThen( R.string.not_again_studycopy,
R.string.key_na_studycopy,
R.string.key_na_studycopy,
Action.SL_COPY_ACTION );
break;
case R.id.slmenu_clear_sel:
String msg = getQuantityString( R.plurals.confirm_studylist_clear_fmt,
String msg = getQuantityString( R.plurals.confirm_studylist_clear_fmt,
m_checkeds.size(), m_checkeds.size() );
showConfirmThen( msg, Action.SL_CLEAR_ACTION );
break;
@ -163,7 +163,7 @@ public class StudyListDelegate extends ListDelegateBase
if ( selWords.length == m_words.length ) {
selWords = null; // all: easier on DB :-)
}
DBUtils.studyListClear( m_activity, m_langCodes[m_langPosition],
DBUtils.studyListClear( m_activity, m_langCodes[m_langPosition],
selWords );
initOrFinish( null );
break;
@ -173,7 +173,7 @@ public class StudyListDelegate extends ListDelegateBase
getSystemService( Context.CLIPBOARD_SERVICE );
clipboard.setText( TextUtils.join( "\n", selWords ) );
String msg = getQuantityString( R.plurals.paste_done_fmt,
String msg = getQuantityString( R.plurals.paste_done_fmt,
selWords.length, selWords.length );
showToast( msg );
break;
@ -187,7 +187,7 @@ public class StudyListDelegate extends ListDelegateBase
//////////////////////////////////////////////////
// AdapterView.OnItemSelectedListener interface
//////////////////////////////////////////////////
public void onItemSelected( AdapterView<?> parent, View view,
public void onItemSelected( AdapterView<?> parent, View view,
int position, long id )
{
m_langPosition = position;
@ -201,7 +201,7 @@ public class StudyListDelegate extends ListDelegateBase
//////////////////////////////////////////////////
// View.OnLongClickListener interface
//////////////////////////////////////////////////
public boolean onLongClick( View view )
public boolean onLongClick( View view )
{
boolean success = view instanceof SelectableItem.LongClickHandler;
if ( success ) {
@ -213,7 +213,7 @@ public class StudyListDelegate extends ListDelegateBase
//////////////////////////////////////////////////
// View.OnClickListener interface
//////////////////////////////////////////////////
public void onClick( View view )
public void onClick( View view )
{
XWListItem item = (XWListItem)view;
String[] words = { m_words[item.getPosition()] };
@ -229,7 +229,7 @@ public class StudyListDelegate extends ListDelegateBase
m_checkeds.add( ((XWListItem)clicked).getPosition() );
}
public void itemToggled( SelectableItem.LongClickHandler toggled,
public void itemToggled( SelectableItem.LongClickHandler toggled,
boolean selected )
{
int position = ((XWListItem)toggled).getPosition();
@ -256,7 +256,7 @@ public class StudyListDelegate extends ListDelegateBase
makeAdapter();
String langName = DictLangCache.getLangName( m_activity, lang );
m_origTitle = getString( R.string.studylist_title_fmt,
m_origTitle = getString( R.string.studylist_title_fmt,
xlateLang( langName ) );
setTitleBar();
}
@ -294,7 +294,7 @@ public class StudyListDelegate extends ListDelegateBase
}
ArrayAdapter<String> adapter = new
ArrayAdapter<String>( m_activity,
ArrayAdapter<String>( m_activity,
android.R.layout.simple_spinner_item,
myNames );
adapter.setDropDownViewResource( android.R.layout.
@ -344,17 +344,17 @@ public class StudyListDelegate extends ListDelegateBase
setTitleBar();
}
public static void launchOrAlert( Delegator delegator, int lang,
public static void launchOrAlert( Delegator delegator, int lang,
DlgDelegate.HasDlgDelegate dlg )
{
String msg = null;
Activity activity = delegator.getActivity();
if ( 0 == DBUtils.studyListLangs( activity ).length ) {
msg = LocUtils.getString( activity, R.string.study_no_lists );
} else if ( NO_LANG != lang &&
} else if ( NO_LANG != lang &&
0 == DBUtils.studyListWords( activity, lang ).length ) {
String langname = DictLangCache.getLangName( activity, lang );
msg = LocUtils.getString( activity, R.string.study_no_lang_fmt,
msg = LocUtils.getString( activity, R.string.study_no_lang_fmt,
langname );
} else {
Bundle bundle = new Bundle();
@ -384,7 +384,7 @@ public class StudyListDelegate extends ListDelegateBase
}
public View getView( int position, View convertView, ViewGroup parent ){
XWListItem item =
XWListItem item =
XWListItem.inflate( m_activity, StudyListDelegate.this );
item.setPosition( position );
item.setText( m_words[position] );

View file

@ -36,14 +36,14 @@ public class ThumbCanvas extends BoardCanvas {
// These should not be needed if common code gets fixed! So the
// whole class should go away. PENDING
@Override
public boolean scoreBegin( Rect rect, int numPlayers, int[] scores,
public boolean scoreBegin( Rect rect, int numPlayers, int[] scores,
int remCount )
{
return false;
}
@Override
public boolean trayBegin( Rect rect, int owner, int score )
public boolean trayBegin( Rect rect, int owner, int score )
{
return false;
}

View file

@ -95,7 +95,7 @@ public class Toolbar {
return button;
}
public void setListener( int index, final int msgID, final int prefsKey,
public void setListener( int index, final int msgID, final int prefsKey,
final Action action )
{
View.OnClickListener listener = new View.OnClickListener() {
@ -106,7 +106,7 @@ public class Toolbar {
setListener( index, listener );
}
public void setLongClickListener( int index, final int msgID,
public void setLongClickListener( int index, final int msgID,
final int prefsKey, final Action action )
{
View.OnLongClickListener listener = new View.OnLongClickListener() {
@ -166,7 +166,7 @@ public class Toolbar {
}
}
private void setLongClickListener( int index,
private void setLongClickListener( int index,
View.OnLongClickListener listener )
{
ImageButton button = getViewFor( index );

View file

@ -66,14 +66,14 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
private static final String k_INDEX = "index";
private static final String k_URL = "url";
private static final String k_DEVID = "did";
private static final String k_DEBUG = "dbg";
private static final String k_DEBUG = "dbg";
private static final String k_XLATEINFO = "xlatinfo";
private static final String k_STRINGSHASH = "strings";
@Override
public void onReceive( Context context, Intent intent )
{
if ( null != intent && null != intent.getAction()
if ( null != intent && null != intent.getAction()
&& intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED ) ) {
restartTimer( context );
} else {
@ -97,7 +97,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
}
interval_millis = (interval_millis / 2)
+ Math.abs(Utils.nextRandomInt() % interval_millis);
am.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP,
am.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + interval_millis,
interval_millis, pi );
}
@ -112,13 +112,13 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
return result;
}
public static void checkVersions( Context context, boolean fromUI )
public static void checkVersions( Context context, boolean fromUI )
{
JSONObject params = new JSONObject();
PackageManager pm = context.getPackageManager();
String packageName = context.getPackageName();
int versionCode;
try {
try {
versionCode = pm.getPackageInfo( packageName, 0 ).versionCode;
} catch ( PackageManager.NameNotFoundException nnfe ) {
DbgUtils.loge( nnfe );
@ -131,7 +131,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
} else {
String installer = pm.getInstallerPackageName( packageName );
try {
try {
JSONObject appParams = new JSONObject();
appParams.put( k_AVERS, versionCode );
@ -180,7 +180,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
params.put( k_NAME, packageName );
params.put( k_AVERS, versionCode );
DbgUtils.logdf( "current update: %s", params.toString() );
new UpdateQueryTask( context, params, fromUI, pm,
new UpdateQueryTask( context, params, fromUI, pm,
packageName, dals ).execute();
} catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse );
@ -212,8 +212,8 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
return result;
}
private static JSONObject makeDictParams( Context context,
DictUtils.DictAndLoc dal,
private static JSONObject makeDictParams( Context context,
DictUtils.DictAndLoc dal,
int index )
{
JSONObject params = new JSONObject();
@ -245,9 +245,9 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
private String m_packageName;
private DictUtils.DictAndLoc[] m_dals;
public UpdateQueryTask( Context context, JSONObject params,
boolean fromUI, PackageManager pm,
String packageName,
public UpdateQueryTask( Context context, JSONObject params,
boolean fromUI, PackageManager pm,
String packageName,
DictUtils.DictAndLoc[] dals )
{
m_context = context;
@ -287,7 +287,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
if ( jobj.has( k_APP ) ) {
JSONObject app = jobj.getJSONObject( k_APP );
if ( app.has( k_URL ) ) {
ApplicationInfo ai =
ApplicationInfo ai =
m_pm.getApplicationInfo( m_packageName, 0);
String label = m_pm.getApplicationLabel( ai ).toString();
@ -299,7 +299,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
if ( null == downloads ) {
useBrowser = true;
} else {
File tmp = new File( downloads,
File tmp = new File( downloads,
"xx" + XWConstants.APK_EXTN );
useBrowser = !Utils.canInstall( m_context, tmp );
}
@ -307,25 +307,25 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
Intent intent;
String url = app.getString( k_URL );
if ( useBrowser ) {
intent = new Intent( Intent.ACTION_VIEW,
intent = new Intent( Intent.ACTION_VIEW,
Uri.parse(url) );
} else {
intent = DwnldDelegate
.makeAppDownloadIntent( m_context, url );
}
String title =
String title =
LocUtils.getString( m_context, R.string.new_app_avail_fmt,
label );
String body =
LocUtils.getString( m_context,
String body =
LocUtils.getString( m_context,
R.string.new_app_avail );
Utils.postNotification( m_context, intent, title,
Utils.postNotification( m_context, intent, title,
body, url.hashCode() );
gotOne = true;
}
}
// dictionaries upgrade
if ( jobj.has( k_DICTS ) ) {
JSONArray dicts = jobj.getJSONArray( k_DICTS );
@ -335,17 +335,17 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
String url = dict.getString( k_URL );
int index = dict.getInt( k_INDEX );
DictUtils.DictAndLoc dal = m_dals[index];
Intent intent =
Intent intent =
new Intent( m_context, DictsActivity.class );
intent.putExtra( NEW_DICT_URL, url );
intent.putExtra( NEW_DICT_NAME, dal.name );
intent.putExtra( NEW_DICT_LOC, dal.loc.ordinal() );
String body =
LocUtils.getString( m_context,
String body =
LocUtils.getString( m_context,
R.string.new_dict_avail_fmt,
dal.name );
Utils.postNotification( m_context, intent,
R.string.new_dict_avail,
Utils.postNotification( m_context, intent,
R.string.new_dict_avail,
body, url.hashCode() );
gotOne = true;
}
@ -359,7 +359,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
if ( 0 < nAdded ) {
gotOne = true;
String msg = LocUtils
.getQuantityString( m_context, R.plurals.new_xlations_fmt,
.getQuantityString( m_context, R.plurals.new_xlations_fmt,
nAdded, nAdded );
Utils.showToast( m_context, msg );
}

View file

@ -70,7 +70,7 @@ public class Utils {
private static Boolean s_deviceSupportSMS = null;
private static Boolean s_isFirstBootEver = null;
private static Integer s_appVersion = null;
private static HashMap<String,String> s_phonesHash =
private static HashMap<String,String> s_phonesHash =
new HashMap<String,String>();
private static Boolean s_hasSmallScreen = null;
private static Random s_random = new Random();
@ -127,7 +127,7 @@ public class Utils {
s_deviceSupportSMS = null; // force to check again
}
public static void notImpl( Context context )
public static void notImpl( Context context )
{
String text = "Feature coming soon";
showToast( context, text );
@ -149,7 +149,7 @@ public class Utils {
showToast( context, msg );
}
public static void setRemoveOnDismiss( final Activity activity,
public static void setRemoveOnDismiss( final Activity activity,
Dialog dialog, DlgID dlgID )
{
final int id = dlgID.ordinal();
@ -171,9 +171,9 @@ public class Utils {
Intent intent = new Intent( Intent.ACTION_SEND );
intent.setType( "message/rfc822" ); // force email
intent.putExtra( Intent.EXTRA_SUBJECT,
LocUtils.getString( context,
LocUtils.getString( context,
R.string.email_author_subject ) );
String[] addrs = { LocUtils.getString( context,
String[] addrs = { LocUtils.getString( context,
R.string.email_author_email ) };
intent.putExtra( Intent.EXTRA_EMAIL, addrs );
String body = LocUtils.getString( context, R.string.email_body_rev_fmt,
@ -184,22 +184,22 @@ public class Utils {
context.startActivity( Intent.createChooser( intent, chooserMsg ) );
}
public static void postNotification( Context context, Intent intent,
public static void postNotification( Context context, Intent intent,
int titleID, int bodyID, int id )
{
postNotification( context, intent, titleID,
postNotification( context, intent, titleID,
LocUtils.getString( context, bodyID ), id );
}
public static void postNotification( Context context, Intent intent,
public static void postNotification( Context context, Intent intent,
int titleID, String body, int id )
{
String title = LocUtils.getString( context, titleID );
postNotification( context, intent, title, body, id );
}
public static void postNotification( Context context, Intent intent,
String title, String body,
public static void postNotification( Context context, Intent intent,
String title, String body,
int id )
{
/* nextRandomInt: per this link
@ -209,10 +209,10 @@ public class Utils {
though the docs say that param's ignored.
*/
PendingIntent pi = null == intent ? null
: PendingIntent.getActivity( context, Utils.nextRandomInt(), intent,
: PendingIntent.getActivity( context, Utils.nextRandomInt(), intent,
PendingIntent.FLAG_ONE_SHOT );
Notification notification =
Notification notification =
new Notification( R.drawable.icon48x48, title,
System.currentTimeMillis() );
@ -249,7 +249,7 @@ public class Utils {
// adapted from
// http://stackoverflow.com/questions/2174048/how-to-look-up-a-contacts-name-from-their-phone-number-on-android
public static String phoneToContact( Context context, String phone,
public static String phoneToContact( Context context, String phone,
boolean phoneStandsIn )
{
// I'm assuming that since context is passed this needn't
@ -265,9 +265,9 @@ public class Utils {
ContentResolver contentResolver = context.getContentResolver();
Cursor cursor =
contentResolver
.query( Uri.withAppendedPath( PhoneLookup.CONTENT_FILTER_URI,
Uri.encode( phone )),
new String[] { PhoneLookup.DISPLAY_NAME },
.query( Uri.withAppendedPath( PhoneLookup.CONTENT_FILTER_URI,
Uri.encode( phone )),
new String[] { PhoneLookup.DISPLAY_NAME },
null, null, null );
if ( cursor.moveToNext() ) {
int indx = cursor.getColumnIndex( PhoneLookup.DISPLAY_NAME );
@ -361,7 +361,7 @@ public class Utils {
if ( null == s_hasSmallScreen ) {
int screenLayout = context.getResources().
getConfiguration().screenLayout;
boolean hasSmallScreen =
boolean hasSmallScreen =
(screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
== Configuration.SCREENLAYOUT_SIZE_SMALL;
s_hasSmallScreen = new Boolean( hasSmallScreen );
@ -450,7 +450,7 @@ public class Utils {
PackageManager pm = context.getPackageManager();
Intent intent = makeInstallIntent( path );
List<ResolveInfo> doers =
pm.queryIntentActivities( intent,
pm.queryIntentActivities( intent,
PackageManager.MATCH_DEFAULT_ONLY );
result = 0 < doers.size();
return result;
@ -466,7 +466,7 @@ public class Utils {
PackageManager pm = context.getPackageManager();
String packageName = context.getPackageName();
String installer = pm.getInstallerPackageName( packageName );
boolean result = "com.google.android.feedback".equals( installer )
boolean result = "com.google.android.feedback".equals( installer )
|| "com.android.vending".equals( installer );
return result;
}
@ -476,18 +476,18 @@ public class Utils {
if ( null == s_isFirstBootThisVersion ) {
final int thisVersion = getAppVersion( context );
int prevVersion = 0;
SharedPreferences prefs =
context.getSharedPreferences( HIDDEN_PREFS,
SharedPreferences prefs =
context.getSharedPreferences( HIDDEN_PREFS,
Context.MODE_PRIVATE );
if ( 0 < thisVersion ) {
prefs = context.getSharedPreferences( HIDDEN_PREFS,
prefs = context.getSharedPreferences( HIDDEN_PREFS,
Context.MODE_PRIVATE );
prevVersion = prefs.getInt( SHOWN_VERSION_KEY, -1 );
}
boolean newVersion = prevVersion != thisVersion;
s_isFirstBootThisVersion = new Boolean( newVersion );
s_isFirstBootEver = new Boolean( -1 == prevVersion );

View file

@ -43,7 +43,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onCreate( Bundle savedInstanceState, DelegateBase dlgt )
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onCreate(this=%H)",
DbgUtils.logf( "%s.onCreate(this=%H)",
getClass().getSimpleName(), this );
}
super.onCreate( savedInstanceState );
@ -58,7 +58,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
}
@Override
protected void onSaveInstanceState( Bundle outState )
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
@ -68,7 +68,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onPause()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onPause(this=%H)",
DbgUtils.logf( "%s.onPause(this=%H)",
getClass().getSimpleName(), this );
}
m_dlgt.onPause();
@ -79,7 +79,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onResume()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onResume(this=%H)",
DbgUtils.logf( "%s.onResume(this=%H)",
getClass().getSimpleName(), this );
}
super.onResume();
@ -90,7 +90,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onStart()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onStart(this=%H)",
DbgUtils.logf( "%s.onStart(this=%H)",
getClass().getSimpleName(), this );
}
super.onStart();
@ -101,7 +101,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onStop()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onStop(this=%H)",
DbgUtils.logf( "%s.onStop(this=%H)",
getClass().getSimpleName(), this );
}
m_dlgt.onStop();
@ -112,7 +112,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onDestroy()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onDestroy(this=%H)",
DbgUtils.logf( "%s.onDestroy(this=%H)",
getClass().getSimpleName(), this );
}
m_dlgt.onDestroy();
@ -134,20 +134,20 @@ public class XWActivity extends FragmentActivity implements Delegator {
}
@Override
public boolean onCreateOptionsMenu( Menu menu )
public boolean onCreateOptionsMenu( Menu menu )
{
return m_dlgt.onCreateOptionsMenu( menu );
}
@Override
public boolean onPrepareOptionsMenu( Menu menu )
public boolean onPrepareOptionsMenu( Menu menu )
{
return m_dlgt.onPrepareOptionsMenu( menu )
|| super.onPrepareOptionsMenu( menu );
} // onPrepareOptionsMenu
@Override
public boolean onOptionsItemSelected( MenuItem item )
public boolean onOptionsItemSelected( MenuItem item )
{
return m_dlgt.onOptionsItemSelected( item )
|| super.onOptionsItemSelected( item );
@ -192,10 +192,10 @@ public class XWActivity extends FragmentActivity implements Delegator {
}
@Override
protected void onActivityResult( int requestCode, int resultCode,
protected void onActivityResult( int requestCode, int resultCode,
Intent data )
{
RequestCode rc = RequestCode.values()[requestCode];
RequestCode rc = RequestCode.values()[requestCode];
m_dlgt.onActivityResult( rc, resultCode, data );
}
@ -219,7 +219,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
}
public void setListAdapter( ListAdapter adapter )
{
{
getListView().setAdapter( adapter );
}
@ -232,13 +232,13 @@ public class XWActivity extends FragmentActivity implements Delegator {
return false;
}
public void addFragment( XWFragment fragment, Bundle extras )
public void addFragment( XWFragment fragment, Bundle extras )
{
Assert.fail();
}
public void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode request )
public void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode request )
{
Assert.fail();
}

View file

@ -48,7 +48,7 @@ public class XWApp extends Application {
public static final boolean OFFER_DUALPANE = false;
// BT class "COMPUTERS" includes tablets like the Nexus 9
public static final boolean BT_SCAN_COMPUTERS = true;
public static final String SMS_PUBLIC_HEADER = "-XW4";
public static final int MAX_TRAY_TILES = 7; // comtypes.h
public static final int SEL_COLOR = Color.argb( 0xFF, 0x09, 0x70, 0x93 );
@ -66,7 +66,7 @@ public class XWApp extends Application {
// This one line should always get logged even if logging is
// off -- because logging is on by default until logEnable is
// called.
DbgUtils.logf( "XWApp.onCreate(); git_rev=%s",
DbgUtils.logf( "XWApp.onCreate(); git_rev=%s",
getString( R.string.git_rev ) );
DbgUtils.logEnable( this );
@ -108,7 +108,7 @@ public class XWApp extends Application {
return s_UUID;
}
public static String getAppName( Context context )
public static String getAppName( Context context )
{
return context.getString( R.string.app_name );
}

View file

@ -63,13 +63,13 @@ public class XWConnAddrPreference extends DialogPreference {
public void warnDisabled( CommsConnType typ ) {
switch( typ ) {
case COMMS_CONN_SMS:
activity.showConfirmThen( R.string.warn_sms_disabled,
activity.showConfirmThen( R.string.warn_sms_disabled,
R.string.button_enable_sms,
R.string.button_later,
Action.ENABLE_SMS_ASK );
break;
case COMMS_CONN_BT:
activity.showConfirmThen( R.string.warn_bt_disabled,
activity.showConfirmThen( R.string.warn_bt_disabled,
R.string.button_enable_bt,
R.string.button_later,
Action.ENABLE_BT_DO );
@ -78,7 +78,7 @@ public class XWConnAddrPreference extends DialogPreference {
.getString( m_context, R.string
.warn_relay_disabled );
msg += "\n\n" + LocUtils
.getString( m_context,
.getString( m_context,
R.string.warn_relay_later );
activity.showConfirmThen( msg, R.string.button_enable_relay,
R.string.button_later,
@ -97,7 +97,7 @@ public class XWConnAddrPreference extends DialogPreference {
}
}, activity );
}
@Override
public void onClick( DialogInterface dialog, int which )
{

View file

@ -58,7 +58,7 @@ abstract class XWExpListAdapter extends XWListAdapter {
abstract View getView( Object dataObj, View convertView );
@Override
public int getCount()
public int getCount()
{
if ( null == m_listObjs ) {
m_listObjs = makeListData();
@ -74,7 +74,7 @@ abstract class XWExpListAdapter extends XWListAdapter {
@Override
public int getItemViewType( int position )
{
{
return m_types.get( m_listObjs[position].getClass() );
}
@ -82,12 +82,12 @@ abstract class XWExpListAdapter extends XWListAdapter {
{
return m_types.size();
}
@Override
public View getView( int position, View convertView, ViewGroup parent )
{
View result = getView( m_listObjs[position], convertView );
// DbgUtils.logf( "getView(position=%d) => %H (%s)", position, result,
// DbgUtils.logf( "getView(position=%d) => %H (%s)", position, result,
// result.getClass().getName() );
return result;
}
@ -142,13 +142,13 @@ abstract class XWExpListAdapter extends XWListAdapter {
System.arraycopy( m_listObjs, 0, newArray, 0, groupIndex + 1 ); // 1: include parent
int nAbove = m_listObjs.length - (groupIndex + nChildren + 1);
if ( end < m_listObjs.length ) {
System.arraycopy( m_listObjs, end, newArray, groupIndex + 1,
System.arraycopy( m_listObjs, end, newArray, groupIndex + 1,
m_listObjs.length - end );
}
m_listObjs = newArray;
notifyDataSetChanged();
}
protected void addChildrenOf( int groupIndex, List<Object> children )
{
int nToAdd = children.size();
@ -161,7 +161,7 @@ abstract class XWExpListAdapter extends XWListAdapter {
}
System.arraycopy( m_listObjs, groupIndex + 1,
newArray, groupIndex + 1 + nToAdd,
m_listObjs.length - groupIndex - 1 );
m_listObjs.length - groupIndex - 1 );
m_listObjs = newArray;
notifyDataSetChanged();
}
@ -181,7 +181,7 @@ abstract class XWExpListAdapter extends XWListAdapter {
}
if ( 0 < nLost ) {
m_listObjs = Arrays.copyOfRange( m_listObjs,
m_listObjs = Arrays.copyOfRange( m_listObjs,
0, m_listObjs.length - nLost );
notifyDataSetChanged();
}
@ -207,7 +207,7 @@ abstract class XWExpListAdapter extends XWListAdapter {
protected void swapGroups( int groupPosn1, int groupPosn2 )
{
// switch if needed so we know the direction
// switch if needed so we know the direction
if ( groupPosn1 > groupPosn2 ) {
int tmp = groupPosn2;
groupPosn2 = groupPosn1;
@ -216,7 +216,7 @@ abstract class XWExpListAdapter extends XWListAdapter {
int groupIndx1 = indexForPosition( groupPosn1 );
int groupIndx2 = indexForPosition( groupPosn2 );
// copy out the lower group subarray
int groupEnd1 = findGroupEnd( groupIndx1 );
Object[] tmp1 = Arrays.copyOfRange( m_listObjs, groupIndx1, groupEnd1 );

View file

@ -53,8 +53,8 @@ public class XWFragment extends Fragment implements Delegator {
}
@Override
public View onCreateView( LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState )
public View onCreateView( LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState )
{
DbgUtils.logdf( "%s.onCreateView() called", this.getClass().getSimpleName() );
return m_dlgt.inflateView( inflater, container );
@ -63,7 +63,7 @@ public class XWFragment extends Fragment implements Delegator {
@Override
public void onActivityCreated( Bundle savedInstanceState )
{
DbgUtils.logdf( "%s.onActivityCreated() called",
DbgUtils.logdf( "%s.onActivityCreated() called",
this.getClass().getSimpleName() );
m_dlgt.init( savedInstanceState );
super.onActivityCreated( savedInstanceState );
@ -75,7 +75,7 @@ public class XWFragment extends Fragment implements Delegator {
@Override
public void onPause()
{
DbgUtils.logdf( "%s.onPause() called",
DbgUtils.logdf( "%s.onPause() called",
this.getClass().getSimpleName() );
m_dlgt.onPause();
super.onPause();
@ -91,7 +91,7 @@ public class XWFragment extends Fragment implements Delegator {
@Override
public void onStart()
{
DbgUtils.logdf( "%s.onStart() called",
DbgUtils.logdf( "%s.onStart() called",
this.getClass().getSimpleName() );
super.onStart();
m_dlgt.onStart();
@ -100,7 +100,7 @@ public class XWFragment extends Fragment implements Delegator {
@Override
public void onStop()
{
DbgUtils.logdf( "%s.onStop() called",
DbgUtils.logdf( "%s.onStop() called",
this.getClass().getSimpleName() );
m_dlgt.onStop();
super.onStop();
@ -109,7 +109,7 @@ public class XWFragment extends Fragment implements Delegator {
@Override
public void onDestroy()
{
DbgUtils.logdf( "%s.onDestroy() called",
DbgUtils.logdf( "%s.onDestroy() called",
this.getClass().getSimpleName() );
m_dlgt.onDestroy();
super.onDestroy();
@ -128,7 +128,7 @@ public class XWFragment extends Fragment implements Delegator {
}
@Override
public boolean onOptionsItemSelected( MenuItem item )
public boolean onOptionsItemSelected( MenuItem item )
{
return m_dlgt.onOptionsItemSelected( item );
}
@ -142,20 +142,20 @@ public class XWFragment extends Fragment implements Delegator {
public boolean inDPMode() {
MainActivity main = (MainActivity)getActivity();
Assert.assertTrue( main.inDPMode() ); // otherwise should be somewhere else
return true;
return true;
}
@Override
public void addFragment( XWFragment fragment, Bundle extras )
{
public void addFragment( XWFragment fragment, Bundle extras )
{
MainActivity main = (MainActivity)getActivity();
main.addFragment( fragment, extras );
}
@Override
public void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode code )
{
public void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode code )
{
MainActivity main = (MainActivity)getActivity();
main.addFragmentForResult( fragment, extras, code );
}
@ -169,7 +169,7 @@ public class XWFragment extends Fragment implements Delegator {
}
public void setListAdapter( ListAdapter adapter )
{
{
getListView().setAdapter( adapter );
}

View file

@ -44,8 +44,8 @@ public abstract class XWListAdapter extends BaseAdapter
public int getCount() { return m_count; }
public Object getItem( int position ) { return null; }
public long getItemId( int position ) { return position; }
public int getItemViewType( int position ) {
return ListAdapter.IGNORE_ITEM_VIEW_TYPE;
public int getItemViewType( int position ) {
return ListAdapter.IGNORE_ITEM_VIEW_TYPE;
}
public int getViewTypeCount() { return 1; }
public boolean hasStableIds() { return true; }

View file

@ -33,7 +33,7 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.loc.LocUtils;
public class XWListItem extends LinearLayout
public class XWListItem extends LinearLayout
implements SelectableItem.LongClickHandler, View.OnClickListener {
private int m_position;
private Object m_cached;
@ -123,7 +123,7 @@ public class XWListItem extends LinearLayout
}
}
public void setDeleteCallback( DeleteCallback cb )
public void setDeleteCallback( DeleteCallback cb )
{
m_delCb = cb;
ImageButton button = (ImageButton)findViewById( R.id.del );
@ -150,7 +150,7 @@ public class XWListItem extends LinearLayout
}
@Override
public void setEnabled( boolean enabled )
public void setEnabled( boolean enabled )
{
ImageButton button = (ImageButton)findViewById( R.id.del );
button.setEnabled( enabled );
@ -174,14 +174,14 @@ public class XWListItem extends LinearLayout
return m_cached;
}
// SelectableItem.LongClickHandler interface
// SelectableItem.LongClickHandler interface
public void longClicked()
{
toggleSelected();
}
// View.OnClickListener interface
public void onClick( View view )
public void onClick( View view )
{
if ( m_checkbox == view ) {
setSelected( m_checkbox.isChecked() );

View file

@ -74,7 +74,7 @@ public class XWPrefs {
public static boolean getHideNewgameButtons( Context context )
{
return getPrefsBoolean( context, R.string.key_hide_newgames,
return getPrefsBoolean( context, R.string.key_hide_newgames,
false );
}
@ -101,7 +101,7 @@ public class XWPrefs {
try {
result = Integer.parseInt( val );
} catch ( Exception ex ) {
}
}
return result;
}
@ -117,7 +117,7 @@ public class XWPrefs {
try {
result = Integer.parseInt( val );
} catch ( Exception ex ) {
}
}
// DbgUtils.logf( "getDefaultProxyPort=>%d", result );
return result;
}
@ -139,7 +139,7 @@ public class XWPrefs {
public static int getDefaultPlayerMinutes( Context context )
{
String value =
String value =
getPrefsString( context, R.string.key_initial_player_minutes );
int result;
try {
@ -195,14 +195,14 @@ public class XWPrefs {
return sp.getBoolean( key, defaultValue );
}
public static void setPrefsBoolean( Context context, int keyID,
public static void setPrefsBoolean( Context context, int keyID,
boolean newValue )
{
String key = context.getString( keyID );
setPrefsBoolean( context, key, newValue );
}
private static void setPrefsBoolean( Context context, String key,
private static void setPrefsBoolean( Context context, String key,
boolean newValue )
{
SharedPreferences sp = PreferenceManager
@ -233,7 +233,7 @@ public class XWPrefs {
public static void setClosedLangs( Context context, String[] langs )
{
setPrefsString( context, R.string.key_closed_langs,
setPrefsString( context, R.string.key_closed_langs,
TextUtils.join( "\n", langs ) );
}
@ -277,7 +277,7 @@ public class XWPrefs {
{
String id = getPrefsString( context, R.string.key_dev_id );
if ( null == id || 0 == id.length() ) {
id = String.format( "%08X-%08X", Utils.nextRandomInt(),
id = String.format( "%08X-%08X", Utils.nextRandomInt(),
Utils.nextRandomInt() );
setPrefsString( context, R.string.key_dev_id, id );
}
@ -296,7 +296,7 @@ public class XWPrefs {
{
return getPrefsString( context, R.string.key_download_path );
}
public static boolean getDefaultLocInternal( Context context )
{
return getPrefsBoolean( context, R.string.key_default_loc, true );
@ -304,7 +304,7 @@ public class XWPrefs {
public static long getDefaultNewGameGroup( Context context )
{
long groupID = getPrefsLong( context, R.string.key_default_group,
long groupID = getPrefsLong( context, R.string.key_default_group,
DBUtils.GROUPID_UNSPEC );
if ( DBUtils.GROUPID_UNSPEC == groupID ) {
groupID = DBUtils.getAnyGroup( context );
@ -337,7 +337,7 @@ public class XWPrefs {
public static long[] getGroupPositions( Context context )
{
long[] posns = null;
String[] longStrs = getPrefsStringArray( context,
String[] longStrs = getPrefsStringArray( context,
R.string.key_group_posns );
if ( null != longStrs ) {
posns = new long[longStrs.length];
@ -384,7 +384,7 @@ public class XWPrefs {
return sp.getString( key, "" );
}
protected static void setPrefsString( Context context, int keyID,
protected static void setPrefsString( Context context, int keyID,
String newValue )
{
SharedPreferences sp = PreferenceManager
@ -412,7 +412,7 @@ public class XWPrefs {
return result;
}
protected static void setPrefsStringArray( Context context, int keyID,
protected static void setPrefsStringArray( Context context, int keyID,
String[] value )
{
setPrefsString( context, keyID, TextUtils.join( "\n", value ) );
@ -490,12 +490,12 @@ public class XWPrefs {
private static boolean isTablet( Context context )
{
if ( null == s_isTablet ) {
int screenLayout =
int screenLayout =
context.getResources().getConfiguration().screenLayout;
int size = screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
s_isTablet =
s_isTablet =
new Boolean(Configuration.SCREENLAYOUT_SIZE_LARGE <= size);
}
return s_isTablet;
}
}
}

View file

@ -95,8 +95,8 @@ class XWService extends Service {
// Meant to be overridden
protected MultiMsgSink getSink( long rowid ) { Assert.fail(); return null; }
protected ReceiveResult receiveMessage( Context context, int gameID,
MultiMsgSink sink, byte[] msg,
protected ReceiveResult receiveMessage( Context context, int gameID,
MultiMsgSink sink, byte[] msg,
CommsAddrRec addr )
{
ReceiveResult result;
@ -114,8 +114,8 @@ class XWService extends Service {
return result;
}
protected boolean receiveMessage( Context context, long rowid,
MultiMsgSink sink, byte[] msg,
protected boolean receiveMessage( Context context, long rowid,
MultiMsgSink sink, byte[] msg,
CommsAddrRec addr )
{
boolean allConsumed = true;
@ -126,12 +126,12 @@ class XWService extends Service {
consumed = true;
jniThread.receive( msg, addr ).release();
} else {
GameUtils.BackMoveResult bmr =
GameUtils.BackMoveResult bmr =
new GameUtils.BackMoveResult();
if ( null == sink ) {
sink = getSink( rowid );
}
if ( GameUtils.feedMessage( context, rowid, msg, addr,
if ( GameUtils.feedMessage( context, rowid, msg, addr,
sink, bmr, isLocalP ) ) {
consumed = true;
GameUtils.postMoveNotification( context, rowid, bmr,

View file

@ -68,9 +68,9 @@ public class XWSumListPreference extends XWListPreference {
if ( !done ) {
newEntries = new CharSequence[entries.length + addRows.length];
System.arraycopy( entries, 0, newEntries, 0,
System.arraycopy( entries, 0, newEntries, 0,
entries.length );
System.arraycopy( addRows, 0, newEntries, entries.length,
System.arraycopy( addRows, 0, newEntries, entries.length,
addRows.length );
setEntries( newEntries );

View file

@ -31,7 +31,7 @@ public class BoardDims {
public int cellSize, maxCellSize;
public int timerWidth;
// public String toString()
// public String toString()
// {
// return "width: " + width
// + " height: " + height

View file

@ -25,7 +25,7 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
public interface BoardHandler {
void startHandling( Activity parent, JNIThread thread,
void startHandling( Activity parent, JNIThread thread,
CommsConnTypeSet connTypes );
void stopHandling();
}

View file

@ -47,7 +47,7 @@ public class CommonPrefs extends XWPrefs {
public boolean showBoardArrow;
public boolean showRobotScores;
public boolean hideTileValues;
public boolean hideTileValues;
public boolean skipCommitConfirm;
public boolean showColors;
public boolean sortNewTiles;
@ -72,13 +72,13 @@ public class CommonPrefs extends XWPrefs {
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences( context );
showBoardArrow = getBoolean( context, sp, R.string.key_show_arrow,
showBoardArrow = getBoolean( context, sp, R.string.key_show_arrow,
true );
showRobotScores = getBoolean( context, sp, R.string.key_explain_robot,
showRobotScores = getBoolean( context, sp, R.string.key_explain_robot,
false );
hideTileValues = getBoolean( context, sp, R.string.key_hide_values,
hideTileValues = getBoolean( context, sp, R.string.key_hide_values,
false );
skipCommitConfirm = getBoolean( context, sp,
skipCommitConfirm = getBoolean( context, sp,
R.string.key_skip_confirm, false );
showColors = getBoolean( context, sp, R.string.key_color_tiles, true );
sortNewTiles = getBoolean( context, sp, R.string.key_sort_tiles, true );
@ -117,7 +117,7 @@ public class CommonPrefs extends XWPrefs {
return this;
}
private boolean getBoolean( Context context, SharedPreferences sp,
private boolean getBoolean( Context context, SharedPreferences sp,
int id, boolean dflt )
{
String key = LocUtils.getString( context, id );
@ -149,7 +149,7 @@ public class CommonPrefs extends XWPrefs {
result = Integer.parseInt( value.substring( 0, 2 ) );
} catch ( Exception ex ) {
result = 15;
}
}
return result;
}
@ -170,7 +170,7 @@ public class CommonPrefs extends XWPrefs {
}
return value;
}
public static String getDefaultOriginalPlayerName( Context context,
int num )
{
@ -205,12 +205,12 @@ public class CommonPrefs extends XWPrefs {
setPrefsString( context, R.string.key_player1_name, value );
}
public static CurGameInfo.XWPhoniesChoice
public static CurGameInfo.XWPhoniesChoice
getDefaultPhonies( Context context )
{
String value = getPrefsString( context, R.string.key_default_phonies );
CurGameInfo.XWPhoniesChoice result =
CurGameInfo.XWPhoniesChoice result =
CurGameInfo.XWPhoniesChoice.PHONIES_IGNORE;
Resources res = context.getResources();
String[] names = res.getStringArray( R.array.phony_names );
@ -223,14 +223,14 @@ public class CommonPrefs extends XWPrefs {
}
return result;
}
public static boolean getDefaultTimerEnabled( Context context )
{
return getPrefsBoolean( context, R.string.key_default_timerenabled,
return getPrefsBoolean( context, R.string.key_default_timerenabled,
false );
}
public static boolean getDefaultHintsAllowed( Context context,
public static boolean getDefaultHintsAllowed( Context context,
boolean networked )
{
int key = networked ?
@ -246,7 +246,7 @@ public class CommonPrefs extends XWPrefs {
public static boolean getHideTitleBar( Context context )
{
boolean hideByDefault = 11 > Integer.valueOf( Build.VERSION.SDK );
return getPrefsBoolean( context, R.string.key_hide_title,
return getPrefsBoolean( context, R.string.key_hide_title,
hideByDefault );
}

View file

@ -47,7 +47,7 @@ public class CommsAddrRec {
COMMS_CONN_BT,
COMMS_CONN_SMS;
public String longName( Context context )
public String longName( Context context )
{
int id = 0;
switch( this ) {
@ -69,13 +69,13 @@ public class CommsAddrRec {
public CommsConnTypeSet() { this(BIT_VECTOR_MASK); }
public CommsConnTypeSet( int bits, boolean isVector )
public CommsConnTypeSet( int bits, boolean isVector )
{
this( bits | BIT_VECTOR_MASK );
Assert.assertTrue( isVector );
}
public CommsConnTypeSet( int bits )
public CommsConnTypeSet( int bits )
{
boolean isVector = 0 != (BIT_VECTOR_MASK & bits);
bits &= ~BIT_VECTOR_MASK;
@ -118,7 +118,7 @@ public class CommsAddrRec {
return s_supported;
}
public static void removeUnsupported( Context context,
public static void removeUnsupported( Context context,
CommsConnTypeSet set )
{
// Remove anything no longer supported. This probably only
@ -188,47 +188,47 @@ public class CommsAddrRec {
public String sms_phone;
public int sms_port; // SMS port, if they still use those
public CommsAddrRec( CommsConnType cTyp )
public CommsAddrRec( CommsConnType cTyp )
{
this();
conTypes.add( cTyp );
}
public CommsAddrRec()
public CommsAddrRec()
{
conTypes = new CommsConnTypeSet();
}
public CommsAddrRec( CommsConnTypeSet types )
public CommsAddrRec( CommsConnTypeSet types )
{
conTypes = types;
}
public CommsAddrRec( String host, int port )
public CommsAddrRec( String host, int port )
{
this( CommsConnType.COMMS_CONN_RELAY );
setRelayParams( host, port );
}
public CommsAddrRec( String btName, String btAddr )
public CommsAddrRec( String btName, String btAddr )
{
this( CommsConnType.COMMS_CONN_BT );
setBTParams( btAddr, btName );
}
public CommsAddrRec( String phone )
public CommsAddrRec( String phone )
{
this( CommsConnType.COMMS_CONN_SMS );
sms_phone = phone;
sms_port = 2; // something other that 0 (need to fix comms)
}
public CommsAddrRec( final CommsAddrRec src )
public CommsAddrRec( final CommsAddrRec src )
{
this.copyFrom( src );
}
public boolean contains( CommsConnType typ )
public boolean contains( CommsConnType typ )
{
return null != conTypes && conTypes.contains( typ );
}
@ -295,7 +295,7 @@ public class CommsAddrRec {
|| ip_relay_port != other.ip_relay_port;
break;
default:
DbgUtils.logf( "changesMatter: not handling case: %s",
DbgUtils.logf( "changesMatter: not handling case: %s",
conType.toString() );
break;
}

View file

@ -85,7 +85,7 @@ public class CurGameInfo {
players = new LocalPlayer[MAX_NUM_PLAYERS];
serverRole = isNetworked ? DeviceRole.SERVER_ISCLIENT
: DeviceRole.SERVER_STANDALONE;
hintsNotAllowed = !CommonPrefs.getDefaultHintsAllowed( context,
hintsNotAllowed = !CommonPrefs.getDefaultHintsAllowed( context,
isNetworked );
phoniesAction = CommonPrefs.getDefaultPhonies( context );
timerEnabled = CommonPrefs.getDefaultTimerEnabled( context );
@ -143,7 +143,7 @@ public class CurGameInfo {
timerEnabled = src.timerEnabled;
allowPickTiles = src.allowPickTiles;
allowHintRect = src.allowHintRect;
int ii;
for ( ii = 0; ii < MAX_NUM_PLAYERS; ++ii ) {
players[ii] = new LocalPlayer( src.players[ii] );
@ -348,9 +348,9 @@ public class CurGameInfo {
}
// Replace any dict that doesn't exist with newDict
public void replaceDicts( String newDict )
public void replaceDicts( String newDict )
{
String[] dicts =
String[] dicts =
DictLangCache.getHaveLang( m_context, dictLang );
HashSet<String> installed = new HashSet<String>( Arrays.asList(dicts) );
@ -391,24 +391,24 @@ public class CurGameInfo {
return dname;
}
public String getName()
public String getName()
{
// Assert.assertNotNull( m_name );
return m_name;
}
public void setName( String name )
public void setName( String name )
{
m_name = name;
}
public boolean addPlayer()
public boolean addPlayer()
{
boolean added = nPlayers < MAX_NUM_PLAYERS;
// We can add either by adding a player, if nPlayers <
// MAX_NUM_PLAYERS, or by making an unusable player usable.
if ( added ) {
players[nPlayers].isLocal =
players[nPlayers].isLocal =
serverRole == DeviceRole.SERVER_STANDALONE;
++nPlayers;
}
@ -468,7 +468,7 @@ public class CurGameInfo {
for ( int ii = nPlayers - 1; ii > 0; --ii ) {
// Contrary to docs, nextInt() comes back negative!
int rand = Math.abs(rgen.nextInt());
int rand = Math.abs(rgen.nextInt());
int indx = rand % (ii+1);
if ( indx != ii ) {
LocalPlayer tmp = players[ii];
@ -487,14 +487,14 @@ public class CurGameInfo {
// matches langauge. Otherwise pick an arbitrary dict in the
// right language.
String humanDict =
String humanDict =
DictLangCache.getBestDefault( m_context, dictLang, true );
String robotDict =
String robotDict =
DictLangCache.getBestDefault( m_context, dictLang, false );
if ( null == dictName
|| ! DictUtils.dictExists( m_context, dictName )
|| dictLang != DictLangCache.getDictLangCode( m_context,
if ( null == dictName
|| ! DictUtils.dictExists( m_context, dictName )
|| dictLang != DictLangCache.getDictLangCode( m_context,
dictName ) ) {
dictName = humanDict;
}
@ -503,7 +503,7 @@ public class CurGameInfo {
LocalPlayer lp = players[ii];
if ( null != lp.dictName &&
dictLang != DictLangCache.getDictLangCode( m_context,
dictLang != DictLangCache.getDictLangCode( m_context,
lp.dictName ) ) {
lp.dictName = null;
}

View file

@ -47,12 +47,12 @@ public interface DrawCtx {
boolean measureRemText( Rect r, int nTilesLeft, int[] width, int[] height );
void measureScoreText( Rect r, DrawScoreInfo dsi, int[] width, int[] height );
void drawRemText( Rect rInner, Rect rOuter, int nTilesLeft, boolean focussed );
void score_drawPlayer( Rect rInner, Rect rOuter, int gotPct,
void score_drawPlayer( Rect rInner, Rect rOuter, int gotPct,
DrawScoreInfo dsi );
// New way of drawing
// boolean drawRemText( int nTilesLeft, boolean focussed, Rect rect );
// void score_drawPlayers( Rect scoreRect, DrawScoreInfo[] playerData,
// void score_drawPlayers( Rect scoreRect, DrawScoreInfo[] playerData,
// Rect[] playerRects );
void drawTimer( Rect rect, int player, int secondsLeft );
@ -64,11 +64,11 @@ public interface DrawCtx {
int flags );
boolean trayBegin ( Rect rect, int owner, int score );
boolean drawTile( Rect rect, String text, int val, int flags );
boolean drawTileMidDrag ( Rect rect, String text, int val, int owner,
boolean drawTileMidDrag ( Rect rect, String text, int val, int owner,
int flags );
boolean drawTileBack( Rect rect, int flags );
void drawTrayDivider( Rect rect, int flags );
void score_pendingScore( Rect rect, int score, int playerNum, int curTurn,
void score_pendingScore( Rect rect, int score, int playerNum, int curTurn,
int flags );
public static final int BONUS_NONE = 0;

View file

@ -99,7 +99,7 @@ public class GameSummary {
public Context getContext()
{
Assert.assertNotNull( m_context );
return m_context;
return m_context;
}
public boolean inRelayGame()
@ -134,7 +134,7 @@ public class GameSummary {
public String getRematchName()
{
return LocUtils.getString( m_context, R.string.rematch_name_fmt,
return LocUtils.getString( m_context, R.string.rematch_name_fmt,
playerNames() );
}
@ -145,13 +145,13 @@ public class GameSummary {
m_remotePhones = new String[remoteDevs.length];
for ( int ii = 0; ii < remoteDevs.length; ++ii ) {
m_remotePhones[ii] =
m_remotePhones[ii] =
Utils.phoneToContact( context, remoteDevs[ii], true );
}
}
}
public void readPlayers( String playersStr )
public void readPlayers( String playersStr )
{
if ( null != playersStr ) {
m_players = new String[nPlayers];
@ -167,7 +167,7 @@ public class GameSummary {
int prev = nxt;
nxt = playersStr.indexOf( sep, nxt );
String name = -1 == nxt ?
playersStr.substring( prev ) :
playersStr.substring( prev ) :
playersStr.substring( prev, nxt );
m_players[ii] = name;
if ( -1 == nxt ) {
@ -178,7 +178,7 @@ public class GameSummary {
}
}
public void setPlayerSummary( String summary )
public void setPlayerSummary( String summary )
{
m_playersSummary = summary;
}
@ -212,7 +212,7 @@ public class GameSummary {
R.string.summary_invites_out );
}
}
// If we're using relay to connect, get status from that
if ( null == result
&& conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
@ -229,7 +229,7 @@ public class GameSummary {
}
result = LocUtils.getString( m_context, fmtID, roomName );
}
// Otherwise, use BT or SMS
if ( null == result ) {
if ( conTypes.contains( CommsConnType.COMMS_CONN_BT )
@ -242,9 +242,9 @@ public class GameSummary {
}
} else if ( gameOver ) {
fmtID = R.string.summary_gameover;
} else if ( null != remoteDevs
} else if ( null != remoteDevs
&& conTypes.contains( CommsConnType.COMMS_CONN_SMS)){
result =
result =
LocUtils.getString( m_context, R.string.summary_conn_sms_fmt,
TextUtils.join(", ", m_remotePhones) );
} else {
@ -268,7 +268,7 @@ public class GameSummary {
// anyway, e.g. via BT.
result = 0 > turn && !gameOver;
}
// DbgUtils.logf( "relayConnectPending()=>%b (turn=%d)", result,
// DbgUtils.logf( "relayConnectPending()=>%b (turn=%d)", result,
// turn );
return result;
}
@ -299,7 +299,7 @@ public class GameSummary {
}
return result;
}
public boolean anyMissing()
{
return 0 < countMissing();
@ -323,12 +323,12 @@ public class GameSummary {
return result;
}
public void setGiFlags( int flags )
public void setGiFlags( int flags )
{
m_giFlags = new Integer( flags );
}
public String summarizePlayer( int indx )
public String summarizePlayer( int indx )
{
String player = m_players[indx];
int formatID = 0;
@ -367,7 +367,7 @@ public class GameSummary {
return result;
}
public boolean isNextToPlay( int indx, boolean[] isLocal )
public boolean isNextToPlay( int indx, boolean[] isLocal )
{
boolean isNext = indx == turn;
if ( isNext ) {
@ -392,7 +392,7 @@ public class GameSummary {
return m_players[prevTurn];
}
public String dictNames( String separator )
public String dictNames( String separator )
{
String list = null;
if ( null != m_gi ) {

View file

@ -60,7 +60,7 @@ public class JNIThread extends Thread {
public static JNIThread getCurrent() {
JNIThread result = null;
synchronized( s_curThreads ) {
// DbgUtils.logf( "JNIThread.getCurrent(): have %d threads",
// DbgUtils.logf( "JNIThread.getCurrent(): have %d threads",
// s_curThreads.size() );
if ( 1 == s_curThreads.size() ) {
result = s_curThreads.iterator().next();
@ -186,9 +186,9 @@ public class JNIThread extends Thread {
m_rowid = rowid;
m_queue = new LinkedBlockingQueue<QueueElem>();
}
public JNIThread configure( Context context, SyncedDraw drawer,
UtilCtxtImpl utils,
UtilCtxtImpl utils,
TransportProcs.TPMsgHandler xportHandler,
Handler handler )
{
@ -219,7 +219,7 @@ public class JNIThread extends Thread {
XwJNI.gi_from_stream( m_gi, stream );
m_summary = DBUtils.getSummary( context, m_lock );
if ( m_gi.serverRole != DeviceRole.SERVER_STANDALONE ) {
m_xport = new CommsTransport( context, xportHandler, m_rowid,
m_gi.serverRole );
@ -229,16 +229,16 @@ public class JNIThread extends Thread {
CommonPrefs cp = CommonPrefs.get( context );
JNIUtils jniUtils = JNIUtilsImpl.get( context );
if ( null == stream ||
! XwJNI.game_makeFromStream( m_jniGamePtr, stream,
m_gi, dictNames,
pairs.m_bytes,
pairs.m_paths,
m_gi.langName(),
! XwJNI.game_makeFromStream( m_jniGamePtr, stream,
m_gi, dictNames,
pairs.m_bytes,
pairs.m_paths,
m_gi.langName(),
utils, jniUtils,
null, cp, m_xport ) ) {
XwJNI.game_makeNewGame( m_jniGamePtr, m_gi, dictNames,
pairs.m_bytes, pairs.m_paths,
m_gi.langName(), utils, jniUtils,
XwJNI.game_makeNewGame( m_jniGamePtr, m_gi, dictNames,
pairs.m_bytes, pairs.m_paths,
m_gi.langName(), utils, jniUtils,
null, cp, m_xport );
}
@ -322,8 +322,8 @@ public class JNIThread extends Thread {
boolean squareTiles = XWPrefs.getSquareTiles( m_context );
XwJNI.board_figureLayout( m_jniGamePtr, m_gi, 0, 0, width, height,
150 /*scorePct*/, 200 /*trayPct*/,
width, fontWidth, fontHeight, squareTiles,
150 /*scorePct*/, 200 /*trayPct*/,
width, fontWidth, fontHeight, squareTiles,
dims /* out param */ );
// Make space for net status icon if appropriate
@ -331,7 +331,7 @@ public class JNIThread extends Thread {
int statusWidth = dims.boardWidth / 15;
dims.scoreWidth -= statusWidth;
int left = dims.scoreLeft + dims.scoreWidth + dims.timerWidth;
ConnStatusHandler.setRect( left, dims.top, left + statusWidth,
ConnStatusHandler.setRect( left, dims.top, left + statusWidth,
dims.top + dims.scoreHt );
} else {
ConnStatusHandler.clearRect();
@ -342,7 +342,7 @@ public class JNIThread extends Thread {
m_drawer.dimsChanged( dims );
}
private boolean nextSame( JNICmd cmd )
private boolean nextSame( JNICmd cmd )
{
QueueElem nextElem = m_queue.peek();
return null != nextElem && nextElem.m_cmd == cmd;
@ -417,7 +417,7 @@ public class JNIThread extends Thread {
}
@SuppressWarnings("fallthrough")
public void run()
public void run()
{
boolean[] barr = new boolean[2]; // scratch boolean
for ( ; ; ) {
@ -470,7 +470,7 @@ public class JNIThread extends Thread {
dims = (BoardDims)args0;
XwJNI.board_applyLayout( m_jniGamePtr, dims );
} else {
doLayout( (Integer)args0, (Integer)args[1],
doLayout( (Integer)args0, (Integer)args[1],
(Integer)args[2], (Integer)args[3] );
}
draw = true;
@ -501,7 +501,7 @@ public class JNIThread extends Thread {
case CMD_RECEIVE:
CommsAddrRec ret = (CommsAddrRec)args[1];
Assert.assertNotNull( ret );
draw = XwJNI.game_receiveMessage( m_jniGamePtr,
draw = XwJNI.game_receiveMessage( m_jniGamePtr,
(byte[])args[0], ret );
handle( JNICmd.CMD_DO );
if ( draw ) {
@ -519,13 +519,13 @@ public class JNIThread extends Thread {
// e.g. colors, aren't known by common code so
// board_prefsChanged's return value isn't enough.
XwJNI.board_invalAll( m_jniGamePtr );
XwJNI.board_server_prefsChanged( m_jniGamePtr,
XwJNI.board_server_prefsChanged( m_jniGamePtr,
CommonPrefs.get( m_context ) );
draw = true;
break;
case CMD_PEN_DOWN:
draw = XwJNI.board_handlePenDown( m_jniGamePtr,
draw = XwJNI.board_handlePenDown( m_jniGamePtr,
((Integer)args[0]).intValue(),
((Integer)args[1]).intValue(),
barr );
@ -534,12 +534,12 @@ public class JNIThread extends Thread {
if ( nextSame( JNICmd.CMD_PEN_MOVE ) ) {
continue;
}
draw = XwJNI.board_handlePenMove( m_jniGamePtr,
draw = XwJNI.board_handlePenMove( m_jniGamePtr,
((Integer)args[0]).intValue(),
((Integer)args[1]).intValue() );
break;
case CMD_PEN_UP:
draw = XwJNI.board_handlePenUp( m_jniGamePtr,
draw = XwJNI.board_handlePenUp( m_jniGamePtr,
((Integer)args[0]).intValue(),
((Integer)args[1]).intValue() );
break;
@ -582,7 +582,7 @@ public class JNIThread extends Thread {
if ( nextSame( elem.m_cmd ) ) {
continue;
}
draw = XwJNI.board_requestHint( m_jniGamePtr, false,
draw = XwJNI.board_requestHint( m_jniGamePtr, false,
JNICmd.CMD_PREV_HINT==elem.m_cmd,
barr );
if ( barr[0] ) {
@ -602,7 +602,7 @@ public class JNIThread extends Thread {
draw = XwJNI.board_zoom( m_jniGamePtr, zoomBy, barr );
break;
case CMD_ZOOM:
draw = XwJNI.board_zoom( m_jniGamePtr,
draw = XwJNI.board_zoom( m_jniGamePtr,
((Integer)args[0]).intValue(),
barr );
break;
@ -623,9 +623,9 @@ public class JNIThread extends Thread {
break;
case CMD_RESEND:
int nSent =
XwJNI.comms_resendAll( m_jniGamePtr,
((Boolean)args[0]).booleanValue(),
int nSent =
XwJNI.comms_resendAll( m_jniGamePtr,
((Boolean)args[0]).booleanValue(),
((Boolean)args[1]).booleanValue() );
if ( ((Boolean)args[2]).booleanValue() ) {
Message.obtain(m_handler, MSGS_SENT, nSent).sendToTarget();
@ -638,7 +638,7 @@ public class JNIThread extends Thread {
case CMD_HISTORY:
boolean gameOver = XwJNI.server_getGameIsOver( m_jniGamePtr );
sendForDialog( ((Integer)args[0]).intValue(),
XwJNI.model_writeGameHistory( m_jniGamePtr,
XwJNI.model_writeGameHistory( m_jniGamePtr,
gameOver ) );
break;
@ -661,7 +661,7 @@ public class JNIThread extends Thread {
((Boolean)args[0]).booleanValue();
int titleID = auto? R.string.summary_gameover
: R.string.finalscores_title;
String text = XwJNI.server_writeFinalScores( m_jniGamePtr );
Message.obtain( m_handler, GAME_OVER, titleID, 0, text )
.sendToTarget();
@ -679,7 +679,7 @@ public class JNIThread extends Thread {
break;
case CMD_TIMER_FIRED:
draw = XwJNI.timerFired( m_jniGamePtr,
draw = XwJNI.timerFired( m_jniGamePtr,
((Integer)args[0]).intValue(),
((Integer)args[1]).intValue(),
((Integer)args[2]).intValue() );
@ -728,12 +728,12 @@ public class JNIThread extends Thread {
{
handle( JNICmd.CMD_SENDCHAT, chat );
}
public void handle( JNICmd cmd, Object... args )
{
m_queue.add( new QueueElem( cmd, true, args ) );
if ( m_stopped && ! JNICmd.CMD_NONE.equals(cmd) ) {
DbgUtils.logf( "WARNING: adding %s to stopped thread!!!",
DbgUtils.logf( "WARNING: adding %s to stopped thread!!!",
cmd.toString() );
DbgUtils.printStack();
}
@ -752,10 +752,10 @@ public class JNIThread extends Thread {
private void retain_sync()
{
++m_refCount;
DbgUtils.logf( "JNIThread.retain_sync(rowid=%d): m_refCount: %d",
DbgUtils.logf( "JNIThread.retain_sync(rowid=%d): m_refCount: %d",
m_rowid, m_refCount );
}
public JNIThread retain()
{
synchronized( s_instances ) {
@ -773,7 +773,7 @@ public class JNIThread extends Thread {
stop = true;
}
}
DbgUtils.logf( "JNIThread.release(rowid=%d): m_refCount: %d",
DbgUtils.logf( "JNIThread.release(rowid=%d): m_refCount: %d",
m_rowid, m_refCount );
if ( stop ) {

View file

@ -72,7 +72,7 @@ public class JNIUtilsImpl implements JNIUtils {
DbgUtils.logf( "splitFaces: %s", uee.toString() );
isr = new InputStreamReader( bais );
}
int[] codePoints = new int[1];
// "A aB bC c"
@ -119,7 +119,7 @@ public class JNIUtilsImpl implements JNIUtils {
face.add( letter );
}
}
String[][] result = faces.toArray( new String[faces.size()][] );
return result;
}

View file

@ -40,7 +40,7 @@ public class LastMoveInfo {
public int nTiles;
public String word;
public String format( Context context )
public String format( Context context )
{
String result = null;
if ( isValid ) {
@ -50,20 +50,20 @@ public class LastMoveInfo {
break;
case MOVE_TYPE:
if ( 0 == nTiles ) {
result = LocUtils.getString( context, R.string.lmi_pass_fmt,
result = LocUtils.getString( context, R.string.lmi_pass_fmt,
name );
} else {
result = LocUtils.getQuantityString( context, R.plurals.lmi_move_fmt,
result = LocUtils.getQuantityString( context, R.plurals.lmi_move_fmt,
score, name, word, score );
}
break;
case TRADE_TYPE:
result = LocUtils
.getQuantityString( context, R.plurals.lmi_trade_fmt,
.getQuantityString( context, R.plurals.lmi_trade_fmt,
nTiles, name, nTiles );
break;
case PHONY_TYPE:
result = LocUtils.getString( context, R.string.lmi_phony_fmt,
result = LocUtils.getString( context, R.string.lmi_phony_fmt,
name );
break;
}

View file

@ -51,7 +51,7 @@ public class LocalPlayer {
secondsUsed = src.secondsUsed;
}
public boolean isRobot()
public boolean isRobot()
{
return robotIQ > 0;
}

View file

@ -28,7 +28,7 @@ public interface TransportProcs {
public static final int COMMS_XPORT_FLAGS_HASNOCONN = 1;
int getFlags();
int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
CommsConnType conType, int gameID );
enum CommsRelayState { COMMS_RELAYSTATE_UNCONNECTED
@ -43,11 +43,11 @@ public interface TransportProcs {
void relayConnd( String room, int devOrder, boolean allHere, int nMissing );
public static enum XWRELAY_ERROR { NONE
,OLDFLAGS
,OLDFLAGS
,BADPROTO
,RELAYBUSY
,SHUTDOWN
,TIMEOUT
,TIMEOUT
,HEART_YOU
,HEART_OTHER
,LOST_OTHER
@ -64,7 +64,7 @@ public interface TransportProcs {
boolean relayNoConnProc( byte[] buf, String msgNo, String relayID );
public interface TPMsgHandler {
public void tpmRelayConnd( String room, int devOrder, boolean allHere,
public void tpmRelayConnd( String room, int devOrder, boolean allHere,
int nMissing );
public void tpmRelayErrorProc( XWRELAY_ERROR relayErr );
}

View file

@ -38,7 +38,7 @@ public interface UtilCtxt {
public static final int PICKER_BACKUP = -2;
int userPickTileBlank( int playerNum, String[] texts );
int userPickTileTray( int playerNum, String[] tiles,
int userPickTileTray( int playerNum, String[] tiles,
String[] curTiles, int nPicked );
String askPassword( String name );
@ -133,7 +133,7 @@ public interface UtilCtxt {
void informMove( int turn, String expl, String words );
void informUndo();
void informNetDict( int lang, String oldName, String newName,
void informNetDict( int lang, String oldName, String newName,
String newSum, CurGameInfo.XWPhoniesChoice phonies );
void informMissing( boolean isServer, CommsConnTypeSet connTypes,
@ -143,7 +143,7 @@ public interface UtilCtxt {
// Don't need this unless we have a scroll thumb to indicate position
//void yOffsetChange( int maxOffset, int oldOffset, int newOffset );
boolean warnIllegalWord( String dict, String[] words, int turn,
boolean warnIllegalWord( String dict, String[] words, int turn,
boolean turnLost );
void showChat( String msg, int fromIndx, String fromName );

View file

@ -53,7 +53,7 @@ public class UtilCtxtImpl implements UtilCtxt {
return 0;
}
public int userPickTileTray( int playerNum, String[] texts,
public int userPickTileTray( int playerNum, String[] texts,
String[] curTiles, int nPicked )
{
subclassOverride( "userPickTileTray" );
@ -264,14 +264,14 @@ public class UtilCtxtImpl implements UtilCtxt {
subclassOverride( "informUndo" );
}
public void informNetDict( int lang, String oldName,
String newName, String newSum,
public void informNetDict( int lang, String oldName,
String newName, String newSum,
CurGameInfo.XWPhoniesChoice phonies )
{
subclassOverride( "informNetDict" );
}
public void informMissing( boolean isServer,
public void informMissing( boolean isServer,
CommsConnTypeSet connTypes,
int nDevices, int nMissingPlayers )
{
@ -285,7 +285,7 @@ public class UtilCtxtImpl implements UtilCtxt {
subclassOverride( "notifyGameOver" );
}
public boolean warnIllegalWord( String dict, String[] words, int turn,
public boolean warnIllegalWord( String dict, String[] words, int turn,
boolean turnLost )
{
subclassOverride( "warnIllegalWord" );

Some files were not shown because too many files have changed in this diff Show more