Merge branch 'android_branch' into send_in_background

This commit is contained in:
eehouse@eehouse.org 2011-08-28 17:27:46 -07:00 committed by Andy2
commit 867b9118c1
18 changed files with 268 additions and 166 deletions

View file

@ -31,6 +31,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<!-- <uses-permission android:name="android.permission.RECEIVE_SMS" /> -->
<!-- <uses-permission android:name="android.permission.SEND_SMS" /> -->
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" /> <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
@ -122,5 +124,13 @@
<service android:name="RelayService"/> <service android:name="RelayService"/>
<!-- <receiver android:name="NBSReceiver"> -->
<!-- <intent-filter android:priority="10"> -->
<!-- <action android:name="android.intent.action.DATA_SMS_RECEIVED" /> -->
<!-- <data android:scheme="sms" /> -->
<!-- <data android:port="50009" /> -->
<!-- </intent-filter> -->
<!-- </receiver> -->
</application> </application>
</manifest> </manifest>

View file

@ -63,6 +63,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginRight="4dip"
/> <!-- end players column --> /> <!-- end players column -->
<!-- holds right column. Could hold more... --> <!-- holds right column. Could hold more... -->

View file

@ -13,6 +13,9 @@
<li>Use the term "wordlist" instead of "dictionary" to not imply that <li>Use the term "wordlist" instead of "dictionary" to not imply that
there are definitions provided.</li> there are definitions provided.</li>
<li>Add color of bonus hints -- the 2L etc. that appear on the board
-- to set of editable colors</li>
<li>Change how downloaded wordlists are opened to consume much less <li>Change how downloaded wordlists are opened to consume much less
Java memory. Downside: wordlists on external storage are not Java memory. Downside: wordlists on external storage are not
available when that storage is mounted on a computer over USB.</li> available when that storage is mounted on a computer over USB.</li>
@ -34,6 +37,9 @@
from standalone. These are placeholders until I can get an artist from standalone. These are placeholders until I can get an artist
to help out. :-)</li> to help out. :-)</li>
<li>Fix a family of crashes that occurred when dialogs were up and
memory got low: rare, but annoying.</li>
</ul> </ul>
<p>Please remember that this is beta software. Please let me know (at <p>Please remember that this is beta software. Please let me know (at

View file

@ -26,6 +26,7 @@
<string name="key_empty">key_clr_empty</string> <string name="key_empty">key_clr_empty</string>
<string name="key_background">key_clr_background</string> <string name="key_background">key_clr_background</string>
<string name="key_clr_crosshairs">key_clr_crosshairs</string> <string name="key_clr_crosshairs">key_clr_crosshairs</string>
<string name="key_clr_bonushint">key_clr_bonushint</string>
<string name="key_relay_host">key_relay_host</string> <string name="key_relay_host">key_relay_host</string>
<string name="key_redir_host">key_redir_host</string> <string name="key_redir_host">key_redir_host</string>

View file

@ -332,6 +332,7 @@
<string name="empty">Empty cell/background</string> <string name="empty">Empty cell/background</string>
<string name="clr_crosshairs">Crosshairs color</string> <string name="clr_crosshairs">Crosshairs color</string>
<string name="background">Board background</string> <string name="background">Board background</string>
<string name="key_bonushint">In-square bonus hint</string>
<string name="tab_relay">Internet/Relay</string> <string name="tab_relay">Internet/Relay</string>
<string name="tab_sms">SMS (broken)</string> <string name="tab_sms">SMS (broken)</string>

View file

@ -177,6 +177,13 @@
android:title="@string/clr_crosshairs" android:title="@string/clr_crosshairs"
android:defaultValue="0x7070FF" android:defaultValue="0x7070FF"
/> />
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_clr_bonushint"
android:title="@string/key_bonushint"
android:defaultValue="0x7F7F7F"
/>
<org.eehouse.android.xw4.EditColorPreference <org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_tile_back" android:key="@string/key_tile_back"
android:title="@string/tile_back" android:title="@string/tile_back"

View file

@ -75,11 +75,22 @@ public class BoardActivity extends XWActivity
private static final int UNDO_LAST_ACTION = 1; private static final int UNDO_LAST_ACTION = 1;
private static final int LAUNCH_INVITE_ACTION = 2; private static final int LAUNCH_INVITE_ACTION = 2;
private static final int SYNC_ACTION = 3;
private static final int COMMIT_ACTION = 4;
private static final int SHOW_EXPL_ACTION = 5;
private static final int PREV_HINT_ACTION = 6;
private static final int NEXT_HINT_ACTION = 7;
private static final int JUGGLE_ACTION = 8;
private static final int FLIP_ACTION = 9;
private static final int ZOOM_ACTION = 10;
private static final int UNDO_ACTION = 11;
private static final int CHAT_ACTION = 12;
private static final String DLG_TITLE = "DLG_TITLE"; private static final String DLG_TITLE = "DLG_TITLE";
private static final String DLG_TITLESTR = "DLG_TITLESTR"; private static final String DLG_TITLESTR = "DLG_TITLESTR";
private static final String DLG_BYTES = "DLG_BYTES"; private static final String DLG_BYTES = "DLG_BYTES";
private static final String ROOM = "ROOM"; private static final String ROOM = "ROOM";
private static final String TOASTSTR = "TOASTSTR";
private BoardView m_view; private BoardView m_view;
private int m_jniGamePtr; private int m_jniGamePtr;
@ -114,6 +125,7 @@ public class BoardActivity extends XWActivity
private boolean m_blockingDlgPosted = false; private boolean m_blockingDlgPosted = false;
private String m_room; private String m_room;
private String m_toastStr;
private int m_missing; private int m_missing;
private boolean m_haveInvited = false; private boolean m_haveInvited = false;
@ -364,6 +376,7 @@ public class BoardActivity extends XWActivity
outState.putString( DLG_TITLESTR, m_dlgTitleStr ); outState.putString( DLG_TITLESTR, m_dlgTitleStr );
outState.putString( DLG_BYTES, m_dlgBytes ); outState.putString( DLG_BYTES, m_dlgBytes );
outState.putString( ROOM, m_room ); outState.putString( ROOM, m_room );
outState.putString( TOASTSTR, m_toastStr );
} }
private void getBundledData( Bundle bundle ) private void getBundledData( Bundle bundle )
@ -373,6 +386,7 @@ public class BoardActivity extends XWActivity
m_dlgTitle = bundle.getInt( DLG_TITLE ); m_dlgTitle = bundle.getInt( DLG_TITLE );
m_dlgBytes = bundle.getString( DLG_BYTES ); m_dlgBytes = bundle.getString( DLG_BYTES );
m_room = bundle.getString( ROOM ); m_room = bundle.getString( ROOM );
m_toastStr = bundle.getString( TOASTSTR );
} }
} }
@ -481,13 +495,8 @@ public class BoardActivity extends XWActivity
int id = item.getItemId(); int id = item.getItemId();
switch ( id ) { switch ( id ) {
case R.id.board_menu_done: case R.id.board_menu_done:
proc = new Runnable() {
public void run() {
checkAndHandle( JNIThread.JNICmd.CMD_COMMIT );
}
};
showNotAgainDlgThen( R.string.not_again_done, showNotAgainDlgThen( R.string.not_again_done,
R.string.key_notagain_done, proc ); R.string.key_notagain_done, COMMIT_ACTION );
break; break;
// case R.id.board_menu_juggle: // case R.id.board_menu_juggle:
// cmd = JNIThread.JNICmd.CMD_JUGGLE; // cmd = JNIThread.JNICmd.CMD_JUGGLE;
@ -541,7 +550,9 @@ public class BoardActivity extends XWActivity
break; break;
case R.id.gamel_menu_checkmoves: case R.id.gamel_menu_checkmoves:
doSyncMenuitem(); showNotAgainDlgThen( R.string.not_again_sync,
R.string.key_notagain_sync,
SYNC_ACTION );
break; break;
case R.id.board_menu_file_prefs: case R.id.board_menu_file_prefs:
@ -570,13 +581,7 @@ public class BoardActivity extends XWActivity
@Override @Override
public void dlgButtonClicked( int id, int which ) public void dlgButtonClicked( int id, int which )
{ {
switch ( id ) { if ( LAUNCH_INVITE_ACTION == id ) {
case UNDO_LAST_ACTION:
if ( AlertDialog.BUTTON_POSITIVE == which ) {
m_jniThread.handle( JNIThread.JNICmd.CMD_UNDO_LAST );
}
break;
case LAUNCH_INVITE_ACTION:
if ( DlgDelegate.DISMISS_BUTTON != which ) { if ( DlgDelegate.DISMISS_BUTTON != which ) {
GameUtils.launchInviteActivity( BoardActivity.this, GameUtils.launchInviteActivity( BoardActivity.this,
DlgDelegate.TEXT_BTN == which, DlgDelegate.TEXT_BTN == which,
@ -584,9 +589,46 @@ public class BoardActivity extends XWActivity
m_gi.dictLang, m_gi.dictLang,
m_gi.nPlayers ); m_gi.nPlayers );
} }
break; } else if ( AlertDialog.BUTTON_POSITIVE == which ) {
default: switch ( id ) {
Assert.fail(); case UNDO_LAST_ACTION:
m_jniThread.handle( JNIThread.JNICmd.CMD_UNDO_LAST );
break;
case SYNC_ACTION:
doSyncMenuitem();
break;
case COMMIT_ACTION:
checkAndHandle( JNIThread.JNICmd.CMD_COMMIT );
break;
case SHOW_EXPL_ACTION:
Toast.makeText( BoardActivity.this, m_toastStr,
Toast.LENGTH_SHORT).show();
m_toastStr = null;
break;
case PREV_HINT_ACTION:
checkAndHandle( JNIThread.JNICmd.CMD_PREV_HINT );
break;
case NEXT_HINT_ACTION:
checkAndHandle( JNIThread.JNICmd.CMD_NEXT_HINT );
break;
case JUGGLE_ACTION:
checkAndHandle( JNIThread.JNICmd.CMD_JUGGLE );
break;
case FLIP_ACTION:
checkAndHandle( JNIThread.JNICmd.CMD_FLIP );
break;
case ZOOM_ACTION:
checkAndHandle( JNIThread.JNICmd.CMD_TOGGLEZOOM );
break;
case UNDO_ACTION:
checkAndHandle( JNIThread.JNICmd.CMD_UNDO_CUR );
break;
case CHAT_ACTION:
startChatActivity();
break;
default:
Assert.fail();
}
} }
} }
@ -777,17 +819,12 @@ public class BoardActivity extends XWActivity
} }
if ( null != str ) { if ( null != str ) {
final String fstr = str; m_toastStr = str;
Runnable proc = new Runnable() {
public void run() {
Toast.makeText( BoardActivity.this, fstr,
Toast.LENGTH_SHORT).show();
}
};
if ( naMsg == 0 ) { if ( naMsg == 0 ) {
proc.run(); dlgButtonClicked( SHOW_EXPL_ACTION,
AlertDialog.BUTTON_POSITIVE );
} else { } else {
showNotAgainDlgThen( naMsg, naKey, proc ); showNotAgainDlgThen( naMsg, naKey, SHOW_EXPL_ACTION );
} }
} }
} // handleConndMessage } // handleConndMessage
@ -894,8 +931,7 @@ public class BoardActivity extends XWActivity
post( new Runnable() { post( new Runnable() {
public void run() { public void run() {
showNotAgainDlgThen( R.string.not_again_turnchanged, showNotAgainDlgThen( R.string.not_again_turnchanged,
R.string.key_notagain_turnchanged, R.string.key_notagain_turnchanged );
null );
} }
} ); } );
m_jniThread.handle( JNIThread.JNICmd. CMD_ZOOM, -8 ); m_jniThread.handle( JNIThread.JNICmd. CMD_ZOOM, -8 );
@ -1165,71 +1201,31 @@ public class BoardActivity extends XWActivity
m_toolbar.setListener( Toolbar.BUTTON_HINT_PREV, m_toolbar.setListener( Toolbar.BUTTON_HINT_PREV,
R.string.not_again_hintprev, R.string.not_again_hintprev,
R.string.key_notagain_hintprev, R.string.key_notagain_hintprev,
new Runnable() { PREV_HINT_ACTION );
public void run() {
checkAndHandle( JNIThread.JNICmd.
CMD_PREV_HINT );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_HINT_NEXT, m_toolbar.setListener( Toolbar.BUTTON_HINT_NEXT,
R.string.not_again_hintnext, R.string.not_again_hintnext,
R.string.key_notagain_hintnext, R.string.key_notagain_hintnext,
new Runnable() { NEXT_HINT_ACTION );
@Override
public void run() {
checkAndHandle( JNIThread.JNICmd
.CMD_NEXT_HINT );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_JUGGLE, m_toolbar.setListener( Toolbar.BUTTON_JUGGLE,
R.string.not_again_juggle, R.string.not_again_juggle,
R.string.key_notagain_juggle, R.string.key_notagain_juggle,
new Runnable() { JUGGLE_ACTION );
@Override
public void run() {
checkAndHandle( JNIThread.JNICmd
.CMD_JUGGLE );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_FLIP, m_toolbar.setListener( Toolbar.BUTTON_FLIP,
R.string.not_again_flip, R.string.not_again_flip,
R.string.key_notagain_flip, R.string.key_notagain_flip,
new Runnable() { FLIP_ACTION );
@Override
public void run() {
checkAndHandle( JNIThread.JNICmd
.CMD_FLIP );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_ZOOM, m_toolbar.setListener( Toolbar.BUTTON_ZOOM,
R.string.not_again_zoom, R.string.not_again_zoom,
R.string.key_notagain_zoom, R.string.key_notagain_zoom,
new Runnable() { ZOOM_ACTION );
@Override
public void run() {
checkAndHandle( JNIThread.JNICmd
.CMD_TOGGLEZOOM );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_UNDO, m_toolbar.setListener( Toolbar.BUTTON_UNDO,
R.string.not_again_undo, R.string.not_again_undo,
R.string.key_notagain_undo, R.string.key_notagain_undo,
new Runnable() { UNDO_ACTION );
@Override
public void run() {
checkAndHandle( JNIThread.JNICmd
.CMD_UNDO_CUR );
}
});
m_toolbar.setListener( Toolbar.BUTTON_CHAT, m_toolbar.setListener( Toolbar.BUTTON_CHAT,
R.string.not_again_chat, R.string.not_again_chat,
R.string.key_notagain_chat, R.string.key_notagain_chat,
new Runnable() { CHAT_ACTION );
@Override
public void run() {
startChatActivity();
}
});
} // populateToolbar } // populateToolbar
private OnDismissListener makeODLforBlocking( final int id ) private OnDismissListener makeODLforBlocking( final int id )

View file

@ -119,7 +119,6 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
private static final int BLACK = 0xFF000000; private static final int BLACK = 0xFF000000;
private static final int WHITE = 0xFFFFFFFF; private static final int WHITE = 0xFFFFFFFF;
private static final int FRAME_GREY = 0xFF101010; private static final int FRAME_GREY = 0xFF101010;
private static final int GREY = 0xFF7F7F7F;
private int[] m_bonusColors; private int[] m_bonusColors;
private int[] m_playerColors; private int[] m_playerColors;
private int[] m_otherColors; private int[] m_otherColors;
@ -506,7 +505,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_origin.setBounds( rect ); m_origin.setBounds( rect );
m_origin.draw( m_canvas ); m_origin.draw( m_canvas );
} else if ( null != bonusStr ) { } else if ( null != bonusStr ) {
m_fillPaint.setColor( GREY ); m_fillPaint.
setColor( m_otherColors[CommonPrefs.COLOR_BONUSHINT] );
Rect brect = new Rect( rect ); Rect brect = new Rect( rect );
brect.inset( 0, brect.height()/10 ); brect.inset( 0, brect.height()/10 );
drawCentered( bonusStr, brect, m_fontDims ); drawCentered( bonusStr, brect, m_fontDims );
@ -562,8 +562,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
public void run() { public void run() {
m_parent. m_parent.
showNotAgainDlgThen( R.string.not_again_arrow, showNotAgainDlgThen( R.string.not_again_arrow,
R.string.key_notagain_arrow, R.string.key_notagain_arrow );
null );
} }
} ); } );
} }

View file

@ -48,10 +48,16 @@ public class DlgDelegate {
public static final int TEXT_BTN = AlertDialog.BUTTON_POSITIVE; public static final int TEXT_BTN = AlertDialog.BUTTON_POSITIVE;
public static final int HTML_BTN = AlertDialog.BUTTON_NEGATIVE; public static final int HTML_BTN = AlertDialog.BUTTON_NEGATIVE;
public static final int DISMISS_BUTTON = 0; public static final int DISMISS_BUTTON = 0;
public static final int SKIP_CALLBACK = -1;
private static final String MSG = "msg"; private static final String MSG = "msg";
private static final String CALLBACK = "callback"; private static final String CALLBACK = "callback";
private static final String MSGID = "msgid"; private static final String MSGID = "msgid";
private static final String PREFSKEY = "prefskey";
// Cache a couple of callback implementations that never change:
private DialogInterface.OnClickListener m_cbkOnClickLstnr = null;
private DialogInterface.OnDismissListener m_cbkOnDismissLstnr = null;
public interface DlgClickNotify { public interface DlgClickNotify {
void dlgButtonClicked( int id, int button ); void dlgButtonClicked( int id, int button );
@ -61,7 +67,6 @@ public class DlgDelegate {
private int m_cbckID = 0; // if this can be set twice I have a private int m_cbckID = 0; // if this can be set twice I have a
// problem. See asserts below. // problem. See asserts below.
private String m_msg; private String m_msg;
private Runnable m_proc = null;
private int m_prefsKey; private int m_prefsKey;
private Activity m_activity; private Activity m_activity;
private DlgClickNotify m_clickCallback; private DlgClickNotify m_clickCallback;
@ -77,6 +82,7 @@ public class DlgDelegate {
m_msg = bundle.getString( MSG ); m_msg = bundle.getString( MSG );
m_cbckID = bundle.getInt( CALLBACK ); m_cbckID = bundle.getInt( CALLBACK );
m_msgID = bundle.getInt( MSGID ); m_msgID = bundle.getInt( MSGID );
m_prefsKey = bundle.getInt( PREFSKEY );
} }
} }
@ -85,6 +91,7 @@ public class DlgDelegate {
outState.putString( MSG, m_msg ); outState.putString( MSG, m_msg );
outState.putInt( CALLBACK, m_cbckID ); outState.putInt( CALLBACK, m_cbckID );
outState.putInt( MSGID, m_msgID ); outState.putInt( MSGID, m_msgID );
outState.putInt( PREFSKEY, m_prefsKey );
} }
public Dialog onCreateDialog( int id ) public Dialog onCreateDialog( int id )
@ -152,21 +159,31 @@ public class DlgDelegate {
} }
public void showNotAgainDlgThen( int msgID, int prefsKey, public void showNotAgainDlgThen( int msgID, int prefsKey,
Runnable proc ) int callbackID )
{ {
boolean set = CommonPrefs.getPrefsBoolean( m_activity, prefsKey, false ); boolean set = CommonPrefs.getPrefsBoolean( m_activity, prefsKey, false );
if ( set ) { if ( set || 0 != m_cbckID ) {
if ( null != proc ) { // If it's set, do the action without bothering with the
proc.run(); // dialog
} if ( SKIP_CALLBACK != callbackID ) {
m_clickCallback.dlgButtonClicked( callbackID,
AlertDialog.BUTTON_POSITIVE );
}
} else { } else {
m_msgID = msgID; m_msgID = msgID;
m_proc = proc; Assert.assertTrue( 0 != callbackID );
Assert.assertTrue( 0 == m_cbckID ); // fired
m_cbckID = callbackID;
m_prefsKey = prefsKey; m_prefsKey = prefsKey;
m_activity.showDialog( DIALOG_NOTAGAIN ); m_activity.showDialog( DIALOG_NOTAGAIN );
} }
} }
public void showNotAgainDlgThen( int msgID, int prefsKey )
{
showNotAgainDlgThen( msgID, prefsKey, SKIP_CALLBACK );
}
public void showConfirmThen( String msg, int callbackID ) public void showConfirmThen( String msg, int callbackID )
{ {
m_msg = msg; m_msg = msg;
@ -239,36 +256,29 @@ public class DlgDelegate {
private Dialog createNotAgainDialog() private Dialog createNotAgainDialog()
{ {
Dialog dialog = null; DialogInterface.OnClickListener lstnr_p = mkCallbackClickListener();
if ( 0 != m_msgID ) {
DialogInterface.OnClickListener lstnr_p =
new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
if ( null != m_proc ) {
m_proc.run();
}
}
};
DialogInterface.OnClickListener lstnr_n = DialogInterface.OnClickListener lstnr_n =
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int item ) { public void onClick( DialogInterface dlg, int item ) {
CommonPrefs.setPrefsBoolean( m_activity, m_prefsKey, CommonPrefs.setPrefsBoolean( m_activity, m_prefsKey,
true ); true );
if ( null != m_proc ) { if ( SKIP_CALLBACK != m_cbckID ) {
m_proc.run(); m_clickCallback.
} dlgButtonClicked( m_cbckID,
AlertDialog.BUTTON_POSITIVE );
} }
}; }
};
dialog = new AlertDialog.Builder( m_activity ) Dialog dialog = new AlertDialog.Builder( m_activity )
.setTitle( R.string.newbie_title ) .setTitle( R.string.newbie_title )
.setMessage( m_msgID ) .setMessage( m_msgID )
.setPositiveButton( R.string.button_ok, lstnr_p ) .setPositiveButton( R.string.button_ok, lstnr_p )
.setNegativeButton( R.string.button_notagain, lstnr_n ) .setNegativeButton( R.string.button_notagain, lstnr_n )
.create(); .create();
}
return dialog; return setCallbackDismissListener( dialog );
} // createNotAgainDialog } // createNotAgainDialog
private Dialog createConfirmThenDialog() private Dialog createConfirmThenDialog()
@ -317,28 +327,33 @@ public class DlgDelegate {
private DialogInterface.OnClickListener mkCallbackClickListener() private DialogInterface.OnClickListener mkCallbackClickListener()
{ {
DialogInterface.OnClickListener lstnr = if ( null == m_cbkOnClickLstnr ) {
new DialogInterface.OnClickListener() { m_cbkOnClickLstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int button ) { public void onClick( DialogInterface dlg, int button ) {
Assert.assertTrue( 0 != m_cbckID ); if ( SKIP_CALLBACK != m_cbckID ) {
m_clickCallback.dlgButtonClicked( m_cbckID, button ); m_clickCallback.dlgButtonClicked( m_cbckID,
button );
}
} }
}; };
return lstnr; }
return m_cbkOnClickLstnr;
} }
private Dialog setCallbackDismissListener( Dialog dialog ) private Dialog setCallbackDismissListener( Dialog dialog )
{ {
DialogInterface.OnDismissListener lstnr = if ( null == m_cbkOnDismissLstnr ) {
new DialogInterface.OnDismissListener() { m_cbkOnDismissLstnr = new DialogInterface.OnDismissListener() {
public void onDismiss( DialogInterface di ) { public void onDismiss( DialogInterface di ) {
Assert.assertTrue( 0 != m_cbckID ); if ( SKIP_CALLBACK != m_cbckID ) {
m_clickCallback.dlgButtonClicked( m_cbckID, m_clickCallback.dlgButtonClicked( m_cbckID,
DISMISS_BUTTON ); DISMISS_BUTTON );
}
m_cbckID = 0; m_cbckID = 0;
} }
}; };
dialog.setOnDismissListener( lstnr ); }
dialog.setOnDismissListener( m_cbkOnDismissLstnr );
return dialog; return dialog;
} }

View file

@ -69,6 +69,7 @@ public class GameConfig extends XWActivity
private static final int NO_NAME_FOUND = PLAYER_EDIT + 4; private static final int NO_NAME_FOUND = PLAYER_EDIT + 4;
private static final String WHICH_PLAYER = "WHICH_PLAYER"; private static final String WHICH_PLAYER = "WHICH_PLAYER";
private static final int LOCKED_CHANGE_ACTION = 1;
private CheckBox m_joinPublicCheck; private CheckBox m_joinPublicCheck;
private CheckBox m_gameLockedCheck; private CheckBox m_gameLockedCheck;
@ -539,6 +540,20 @@ public class GameConfig extends XWActivity
showDialog( NO_NAME_FOUND ); showDialog( NO_NAME_FOUND );
} }
@Override
public void dlgButtonClicked( int id, int button )
{
switch( id ) {
case LOCKED_CHANGE_ACTION:
if ( AlertDialog.BUTTON_POSITIVE == button ) {
handleLockedChange();
}
break;
default:
Assert.fail();
}
}
public void onClick( View view ) public void onClick( View view )
{ {
if ( m_addPlayerButton == view ) { if ( m_addPlayerButton == view ) {
@ -555,11 +570,7 @@ public class GameConfig extends XWActivity
} else if ( m_gameLockedCheck == view ) { } else if ( m_gameLockedCheck == view ) {
showNotAgainDlgThen( R.string.not_again_unlock, showNotAgainDlgThen( R.string.not_again_unlock,
R.string.key_notagain_unlock, R.string.key_notagain_unlock,
new Runnable() { LOCKED_CHANGE_ACTION );
public void run() {
handleLockedChange();
}
});
} else if ( m_refreshRoomsButton == view ) { } else if ( m_refreshRoomsButton == view ) {
refreshNames(); refreshNames();
} else if ( m_playButton == view ) { } else if ( m_playButton == view ) {

View file

@ -67,6 +67,8 @@ public class GamesList extends XWListActivity
private static final int RESET_GAME_ACTION = 2; private static final int RESET_GAME_ACTION = 2;
private static final int DELETE_GAME_ACTION = 3; private static final int DELETE_GAME_ACTION = 3;
private static final int DELETE_ALL_ACTION = 4; private static final int DELETE_ALL_ACTION = 4;
private static final int SYNC_MENU_ACTION = 5;
private static final int DUPE_GAME_ACTION = 6;
private GameListAdapter m_adapter; private GameListAdapter m_adapter;
private String m_missingDict; private String m_missingDict;
@ -426,6 +428,15 @@ public class GamesList extends XWListActivity
m_adapter.inval( games[ii] ); m_adapter.inval( games[ii] );
} }
break; break;
case SYNC_MENU_ACTION:
doSyncMenuitem();
break;
case DUPE_GAME_ACTION:
long newid = GameUtils.dupeGame( GamesList.this, m_rowid );
if ( null != m_adapter ) {
m_adapter.inval( newid );
}
break;
default: default:
Assert.fail(); Assert.fail();
} }
@ -520,11 +531,7 @@ public class GamesList extends XWListActivity
case R.id.gamel_menu_checkmoves: case R.id.gamel_menu_checkmoves:
showNotAgainDlgThen( R.string.not_again_sync, showNotAgainDlgThen( R.string.not_again_sync,
R.string.key_notagain_sync, R.string.key_notagain_sync,
new Runnable() { SYNC_MENU_ACTION );
public void run() {
doSyncMenuitem();
}
} );
break; break;
case R.id.gamel_menu_prefs: case R.id.gamel_menu_prefs:
@ -551,46 +558,36 @@ public class GamesList extends XWListActivity
boolean handled = true; boolean handled = true;
DialogInterface.OnClickListener lstnr; DialogInterface.OnClickListener lstnr;
final long rowid = DBUtils.gamesList( this )[position]; m_rowid = DBUtils.gamesList( this )[position];
if ( R.id.list_item_delete == menuID ) { if ( R.id.list_item_delete == menuID ) {
m_rowid = rowid;
showConfirmThen( R.string.confirm_delete, DELETE_GAME_ACTION ); showConfirmThen( R.string.confirm_delete, DELETE_GAME_ACTION );
} else { } else {
if ( checkWarnNoDict( rowid ) ) { if ( checkWarnNoDict( m_rowid ) ) {
switch ( menuID ) { switch ( menuID ) {
case R.id.list_item_reset: case R.id.list_item_reset:
m_rowid = rowid;
showConfirmThen( R.string.confirm_reset, RESET_GAME_ACTION ); showConfirmThen( R.string.confirm_reset, RESET_GAME_ACTION );
break; break;
case R.id.list_item_config: case R.id.list_item_config:
GameUtils.doConfig( this, rowid, GameConfig.class ); GameUtils.doConfig( this, m_rowid, GameConfig.class );
break; break;
case R.id.list_item_rename: case R.id.list_item_rename:
m_rowid = rowid;
showDialog( RENAME_GAME ); showDialog( RENAME_GAME );
break; break;
case R.id.list_item_new_from: case R.id.list_item_new_from:
Runnable proc = new Runnable() {
public void run() {
long newid =
GameUtils.dupeGame( GamesList.this, rowid );
if ( null != m_adapter ) {
m_adapter.inval( newid );
}
}
};
showNotAgainDlgThen( R.string.not_again_newfrom, showNotAgainDlgThen( R.string.not_again_newfrom,
R.string.key_notagain_newfrom, proc ); R.string.key_notagain_newfrom,
DUPE_GAME_ACTION );
break; break;
case R.id.list_item_copy: case R.id.list_item_copy:
GameSummary summary = DBUtils.getSummary( this, rowid, true ); GameSummary summary = DBUtils.getSummary( this,
m_rowid, true );
if ( summary.inNetworkGame() ) { if ( summary.inNetworkGame() ) {
showOKOnlyDialog( R.string.no_copy_network ); showOKOnlyDialog( R.string.no_copy_network );
} else { } else {
byte[] stream = GameUtils.savedGame( this, rowid ); byte[] stream = GameUtils.savedGame( this, m_rowid );
GameUtils.GameLock lock = GameUtils.GameLock lock =
GameUtils.saveNewGame( this, stream ); GameUtils.saveNewGame( this, stream );
DBUtils.saveSummary( this, lock, summary ); DBUtils.saveSummary( this, lock, summary );

View file

@ -0,0 +1,54 @@
// /* -*- compile-command: "cd ../../../../../; ant install"; -*- */
// /*
// * Copyright 2010 by Eric House (xwords@eehouse.org). All rights
// * reserved.
// *
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License as
// * published by the Free Software Foundation; either version 2 of the
// * License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful, but
// * WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// * General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// */
// package org.eehouse.android.xw4;
// import android.content.BroadcastReceiver;
// import android.content.Context;
// import android.content.Intent;
// import android.telephony.SmsManager;
// public class NBSReceiver extends BroadcastReceiver {
// @Override
// public void onReceive( Context context, Intent intent )
// {
// Utils.logf( "NBSReceiver::onReceive(intent=%s)!!!!",
// intent.toString() );
// }
// static void tryNBSMessage()
// {
// byte[] data = { 'a', 'b', 'c' };
// SmsManager mgr = SmsManager.getDefault();
// try {
// mgr.sendDataMessage( "123-456-7890", null, (short)50009,
// data, null, null );
// // PendingIntent sentIntent,
// // PendingIntent deliveryIntent );
// Utils.logf( "sendDataMessage finished" );
// } catch ( IllegalArgumentException iae ) {
// Utils.logf( "%s", iae.toString() );
// }
// }
// }

View file

@ -47,8 +47,6 @@ public class NetLaunchInfo {
bundle.putString( ROOM, room ); bundle.putString( ROOM, room );
bundle.putInt( NPLAYERS, nPlayers ); bundle.putInt( NPLAYERS, nPlayers );
bundle.putBoolean( VALID, m_valid ); bundle.putBoolean( VALID, m_valid );
Utils.logf( "bundling NetLaunchInfo: %d, %s, %d, %b",
lang, room, nPlayers, m_valid );
} }
public NetLaunchInfo( Bundle bundle ) public NetLaunchInfo( Bundle bundle )
@ -57,8 +55,6 @@ public class NetLaunchInfo {
room = bundle.getString( ROOM ); room = bundle.getString( ROOM );
nPlayers = bundle.getInt( NPLAYERS ); nPlayers = bundle.getInt( NPLAYERS );
m_valid = bundle.getBoolean( VALID ); m_valid = bundle.getBoolean( VALID );
Utils.logf( "unbundled NetLaunchInfo: %d, %s, %d, %b",
lang, room, nPlayers, m_valid );
} }
public static Uri makeLaunchUri( Context context, String room, public static Uri makeLaunchUri( Context context, String room,

View file

@ -68,6 +68,7 @@ public class PrefsActivity extends PreferenceActivity
R.string.key_clr_crosshairs, R.string.key_clr_crosshairs,
R.string.key_empty, R.string.key_empty,
R.string.key_background, R.string.key_background,
R.string.key_clr_bonushint,
}; };
for ( int colorKey : colorKeys ) { for ( int colorKey : colorKeys ) {
editor.remove( getString(colorKey) ); editor.remove( getString(colorKey) );

View file

@ -85,11 +85,11 @@ public class Toolbar {
} }
public void setListener( int index, final int msgID, final int prefsKey, public void setListener( int index, final int msgID, final int prefsKey,
final Runnable proc ) final int callback )
{ {
View.OnClickListener listener = new View.OnClickListener() { View.OnClickListener listener = new View.OnClickListener() {
public void onClick( View view ) { public void onClick( View view ) {
m_activity.showNotAgainDlgThen( msgID, prefsKey, proc ); m_activity.showNotAgainDlgThen( msgID, prefsKey, callback );
} }
}; };
setListener( index, listener ); setListener( index, listener );

View file

@ -116,9 +116,14 @@ public class XWActivity extends Activity
} }
protected void showNotAgainDlgThen( int msgID, int prefsKey, protected void showNotAgainDlgThen( int msgID, int prefsKey,
Runnable proc ) int action )
{ {
m_delegate.showNotAgainDlgThen( msgID, prefsKey, proc ); m_delegate.showNotAgainDlgThen( msgID, prefsKey, action );
}
protected void showNotAgainDlgThen( int msgID, int prefsKey )
{
m_delegate.showNotAgainDlgThen( msgID, prefsKey );
} }
protected void showOKOnlyDialog( int msgID ) protected void showOKOnlyDialog( int msgID )

View file

@ -112,14 +112,14 @@ public class XWListActivity extends ListActivity
} }
protected void showNotAgainDlgThen( int msgID, int prefsKey, protected void showNotAgainDlgThen( int msgID, int prefsKey,
Runnable proc ) int action )
{ {
m_delegate.showNotAgainDlgThen( msgID, prefsKey, proc ); m_delegate.showNotAgainDlgThen( msgID, prefsKey, action );
} }
protected void showNotAgainDlg( int msgID, int prefsKey ) protected void showNotAgainDlg( int msgID, int prefsKey )
{ {
m_delegate.showNotAgainDlgThen( msgID, prefsKey, null ); m_delegate.showNotAgainDlgThen( msgID, prefsKey );
} }
protected void showOKOnlyDialog( int msgID ) protected void showOKOnlyDialog( int msgID )
@ -134,7 +134,7 @@ public class XWListActivity extends ListActivity
protected void showConfirmThen( int msg, int action ) protected void showConfirmThen( int msg, int action )
{ {
m_delegate.showConfirmThen( getString(msg), action ); showConfirmThen( getString(msg), action );
} }
protected void doSyncMenuitem() protected void doSyncMenuitem()

View file

@ -36,7 +36,8 @@ public class CommonPrefs {
public static final int COLOR_NOTILE = 1; public static final int COLOR_NOTILE = 1;
public static final int COLOR_FOCUS = 2; public static final int COLOR_FOCUS = 2;
public static final int COLOR_BACKGRND = 3; public static final int COLOR_BACKGRND = 3;
public static final int COLOR_LAST = 4; public static final int COLOR_BONUSHINT = 4;
public static final int COLOR_LAST = 5;
private static CommonPrefs s_cp = null; private static CommonPrefs s_cp = null;
@ -101,6 +102,7 @@ public class CommonPrefs {
R.string.key_empty, R.string.key_empty,
R.string.key_clr_crosshairs, R.string.key_clr_crosshairs,
R.string.key_background, R.string.key_background,
R.string.key_clr_bonushint,
}; };
for ( int ii = 0; ii < idsOther.length; ++ii ) { for ( int ii = 0; ii < idsOther.length; ++ii ) {
otherColors[ii] = prefToColor( context, sp, idsOther[ii] ); otherColors[ii] = prefToColor( context, sp, idsOther[ii] );