mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
Merge branch 'android_branch' into french_xlation
Conflicts: xwords4/android/XWords4/res/values/strings.xml
This commit is contained in:
commit
7f2becfe50
25 changed files with 869 additions and 523 deletions
|
@ -31,6 +31,8 @@
|
|||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<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" />
|
||||
|
||||
|
@ -122,5 +124,13 @@
|
|||
|
||||
<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>
|
||||
</manifest>
|
||||
|
|
|
@ -487,7 +487,7 @@ makeDict( MPFORMAL JNIEnv *env, JNIUtilCtxt* jniutil, jstring jname,
|
|||
anddict->bytes =
|
||||
(*env)->GetByteArrayElements( env, anddict->byteArray, NULL );
|
||||
} else {
|
||||
anddict->byteArray = NULL;
|
||||
XP_ASSERT( NULL == anddict->byteArray );
|
||||
const char* path = (*env)->GetStringUTFChars( env, jpath, NULL );
|
||||
|
||||
struct stat statbuf;
|
||||
|
|
|
@ -58,25 +58,13 @@
|
|||
android:padding="4sp">
|
||||
|
||||
<!-- Player list plus connection status -->
|
||||
<LinearLayout android:orientation="vertical"
|
||||
<LinearLayout android:id="@+id/player_list"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
>
|
||||
|
||||
<!-- Player names container I stick stuff in -->
|
||||
<LinearLayout android:id="@+id/player_list"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/role"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout> <!-- end players column -->
|
||||
android:layout_marginRight="4dip"
|
||||
/> <!-- end players column -->
|
||||
|
||||
<!-- holds right column. Could hold more... -->
|
||||
<LinearLayout android:orientation="vertical"
|
||||
|
@ -97,5 +85,12 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView android:id="@+id/role"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawSelectorOnTop="true"
|
||||
android:prompt="@string/dicts_list_promptf"
|
||||
/>
|
||||
|
||||
<CheckBox android:id="@+id/robot_check"
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<li>Use the term "wordlist" instead of "dictionary" to not imply that
|
||||
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
|
||||
Java memory. Downside: wordlists on external storage are not
|
||||
available when that storage is mounted on a computer over USB.</li>
|
||||
|
@ -24,6 +27,9 @@
|
|||
<li>Make a game's language one of several configurable attributes
|
||||
that can be displayed along with the game</li>
|
||||
|
||||
<li>Display relay connection state as being in one of three phases:
|
||||
configured, connected, and with all players present.</li>
|
||||
|
||||
<li>Fix rename of games to work when keyboard opened while dialog
|
||||
up.</li>
|
||||
|
||||
|
@ -31,6 +37,9 @@
|
|||
from standalone. These are placeholders until I can get an artist
|
||||
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>
|
||||
|
||||
<p>Please remember that this is beta software. Please let me know (at
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<string name="key_empty">key_clr_empty</string>
|
||||
<string name="key_background">key_clr_background</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_redir_host">key_redir_host</string>
|
||||
|
|
|
@ -290,6 +290,7 @@
|
|||
<string name="tile_back">Tile background</string>
|
||||
<string name="empty">Empty cell/background</string>
|
||||
<string name="background">Board background</string>
|
||||
<string name="key_bonushint">In-square bonus hint</string>
|
||||
<string name="explain_robot">Explain other moves</string>
|
||||
<string name="explain_robot_summary">Display score summary after
|
||||
every robot or remote turn</string>
|
||||
|
@ -569,7 +570,11 @@
|
|||
check off-device players.</string>
|
||||
<string name="forced_consistent">Modified first player.</string>
|
||||
|
||||
<string name="summary_fmt_relay">Connecting via Relay, room \"%s\"</string>
|
||||
<string name="summary_relay_conff">Configured for room
|
||||
\"%s\"</string>
|
||||
<string name="summary_relay_waitf">Waiting for players in room
|
||||
\"%s\"</string>
|
||||
<string name="summary_relay_connf">Game in play in room \"%s\"</string>
|
||||
<string name="gameOver">Game over</string>
|
||||
<string name="movesf">%d moves played</string>
|
||||
|
||||
|
|
|
@ -177,6 +177,13 @@
|
|||
android:title="@string/clr_crosshairs"
|
||||
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
|
||||
android:key="@string/key_tile_back"
|
||||
android:title="@string/tile_back"
|
||||
|
|
|
@ -73,9 +73,24 @@ public class BoardActivity extends XWActivity
|
|||
private static final int CHAT_REQUEST = 1;
|
||||
private static final int SCREEN_ON_TIME = 10 * 60 * 1000; // 10 mins
|
||||
|
||||
private static final int UNDO_LAST_ACTION = 1;
|
||||
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_TITLESTR = "DLG_TITLESTR";
|
||||
private static final String DLG_BYTES = "DLG_BYTES";
|
||||
private static final String ROOM = "ROOM";
|
||||
private static final String TOASTSTR = "TOASTSTR";
|
||||
|
||||
private BoardView m_view;
|
||||
private int m_jniGamePtr;
|
||||
|
@ -110,6 +125,7 @@ public class BoardActivity extends XWActivity
|
|||
private boolean m_blockingDlgPosted = false;
|
||||
|
||||
private String m_room;
|
||||
private String m_toastStr;
|
||||
private int m_missing;
|
||||
private boolean m_haveInvited = false;
|
||||
|
||||
|
@ -157,7 +173,7 @@ public class BoardActivity extends XWActivity
|
|||
ab.setNegativeButton( R.string.button_retry, lstnr );
|
||||
}
|
||||
dialog = ab.create();
|
||||
setRemoveOnDismiss( dialog, id );
|
||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
||||
break;
|
||||
|
||||
case DLG_DELETED:
|
||||
|
@ -258,14 +274,7 @@ public class BoardActivity extends XWActivity
|
|||
handle(JNICmd.CMD_ENDGAME);
|
||||
}
|
||||
})
|
||||
.setNegativeButton( R.string.button_no,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void
|
||||
onClick( DialogInterface dlg,
|
||||
int item ) {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
.setNegativeButton( R.string.button_no, null )
|
||||
.create();
|
||||
break;
|
||||
case DLG_INVITE:
|
||||
|
@ -273,10 +282,7 @@ public class BoardActivity extends XWActivity
|
|||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dialog,
|
||||
int item ) {
|
||||
GameUtils.launchInviteActivity( BoardActivity.this,
|
||||
m_room,
|
||||
m_gi.dictLang,
|
||||
m_gi.nPlayers );
|
||||
showTextOrHtmlThen( LAUNCH_INVITE_ACTION );
|
||||
}
|
||||
};
|
||||
dialog = new AlertDialog.Builder( this )
|
||||
|
@ -369,6 +375,8 @@ public class BoardActivity extends XWActivity
|
|||
outState.putInt( DLG_TITLESTR, m_dlgTitle );
|
||||
outState.putString( DLG_TITLESTR, m_dlgTitleStr );
|
||||
outState.putString( DLG_BYTES, m_dlgBytes );
|
||||
outState.putString( ROOM, m_room );
|
||||
outState.putString( TOASTSTR, m_toastStr );
|
||||
}
|
||||
|
||||
private void getBundledData( Bundle bundle )
|
||||
|
@ -377,6 +385,8 @@ public class BoardActivity extends XWActivity
|
|||
m_dlgTitleStr = bundle.getString( DLG_TITLESTR );
|
||||
m_dlgTitle = bundle.getInt( DLG_TITLE );
|
||||
m_dlgBytes = bundle.getString( DLG_BYTES );
|
||||
m_room = bundle.getString( ROOM );
|
||||
m_toastStr = bundle.getString( TOASTSTR );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,13 +495,8 @@ public class BoardActivity extends XWActivity
|
|||
int id = item.getItemId();
|
||||
switch ( id ) {
|
||||
case R.id.board_menu_done:
|
||||
proc = new Runnable() {
|
||||
public void run() {
|
||||
checkAndHandle( JNIThread.JNICmd.CMD_COMMIT );
|
||||
}
|
||||
};
|
||||
showNotAgainDlgThen( R.string.not_again_done,
|
||||
R.string.key_notagain_done, proc );
|
||||
R.string.key_notagain_done, COMMIT_ACTION );
|
||||
break;
|
||||
// case R.id.board_menu_juggle:
|
||||
// cmd = JNIThread.JNICmd.CMD_JUGGLE;
|
||||
|
@ -516,14 +521,7 @@ public class BoardActivity extends XWActivity
|
|||
// cmd = JNIThread.JNICmd.CMD_UNDO_CUR;
|
||||
// break;
|
||||
case R.id.board_menu_undo_last:
|
||||
showConfirmThen( R.string.confirm_undo_last,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg,
|
||||
int whichButton ) {
|
||||
m_jniThread.handle( JNIThread.JNICmd.
|
||||
CMD_UNDO_LAST );
|
||||
}
|
||||
} );
|
||||
showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION );
|
||||
break;
|
||||
case R.id.board_menu_values:
|
||||
cmd = JNIThread.JNICmd.CMD_VALUES;
|
||||
|
@ -552,7 +550,9 @@ public class BoardActivity extends XWActivity
|
|||
break;
|
||||
|
||||
case R.id.gamel_menu_checkmoves:
|
||||
doSyncMenuitem();
|
||||
showNotAgainDlgThen( R.string.not_again_sync,
|
||||
R.string.key_notagain_sync,
|
||||
SYNC_ACTION );
|
||||
break;
|
||||
|
||||
case R.id.board_menu_file_prefs:
|
||||
|
@ -575,6 +575,62 @@ public class BoardActivity extends XWActivity
|
|||
return handled;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
//////////////////////////////////////////////////
|
||||
@Override
|
||||
public void dlgButtonClicked( int id, int which )
|
||||
{
|
||||
if ( LAUNCH_INVITE_ACTION == id ) {
|
||||
if ( DlgDelegate.DISMISS_BUTTON != which ) {
|
||||
GameUtils.launchInviteActivity( BoardActivity.this,
|
||||
DlgDelegate.TEXT_BTN == which,
|
||||
m_room,
|
||||
m_gi.dictLang,
|
||||
m_gi.nPlayers );
|
||||
}
|
||||
} else if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
switch ( id ) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// TransportProcs.TPMsgHandler interface
|
||||
|
@ -763,17 +819,12 @@ public class BoardActivity extends XWActivity
|
|||
}
|
||||
|
||||
if ( null != str ) {
|
||||
final String fstr = str;
|
||||
Runnable proc = new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText( BoardActivity.this, fstr,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
};
|
||||
m_toastStr = str;
|
||||
if ( naMsg == 0 ) {
|
||||
proc.run();
|
||||
dlgButtonClicked( SHOW_EXPL_ACTION,
|
||||
AlertDialog.BUTTON_POSITIVE );
|
||||
} else {
|
||||
showNotAgainDlgThen( naMsg, naKey, proc );
|
||||
showNotAgainDlgThen( naMsg, naKey, SHOW_EXPL_ACTION );
|
||||
}
|
||||
}
|
||||
} // handleConndMessage
|
||||
|
@ -880,8 +931,7 @@ public class BoardActivity extends XWActivity
|
|||
post( new Runnable() {
|
||||
public void run() {
|
||||
showNotAgainDlgThen( R.string.not_again_turnchanged,
|
||||
R.string.key_notagain_turnchanged,
|
||||
null );
|
||||
R.string.key_notagain_turnchanged );
|
||||
}
|
||||
} );
|
||||
m_jniThread.handle( JNIThread.JNICmd. CMD_ZOOM, -8 );
|
||||
|
@ -1079,31 +1129,32 @@ public class BoardActivity extends XWActivity
|
|||
langName );
|
||||
}
|
||||
|
||||
m_jniThread = new
|
||||
JNIThread( m_jniGamePtr, m_gi, m_view, m_gameLock, this,
|
||||
new Handler() {
|
||||
public void handleMessage( Message msg ) {
|
||||
switch( msg.what ) {
|
||||
case JNIThread.DRAW:
|
||||
m_view.invalidate();
|
||||
break;
|
||||
case JNIThread.DIALOG:
|
||||
m_dlgBytes = (String)msg.obj;
|
||||
m_dlgTitle = msg.arg1;
|
||||
showDialog( DLG_OKONLY );
|
||||
break;
|
||||
case JNIThread.QUERY_ENDGAME:
|
||||
showDialog( QUERY_ENDGAME );
|
||||
break;
|
||||
case JNIThread.TOOLBAR_STATES:
|
||||
if ( null != m_jniThread ) {
|
||||
m_gsi = m_jniThread.getGameStateInfo();
|
||||
updateToolbar();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
Handler handler = new Handler() {
|
||||
public void handleMessage( Message msg ) {
|
||||
switch( msg.what ) {
|
||||
case JNIThread.DRAW:
|
||||
m_view.invalidate();
|
||||
break;
|
||||
case JNIThread.DIALOG:
|
||||
m_dlgBytes = (String)msg.obj;
|
||||
m_dlgTitle = msg.arg1;
|
||||
showDialog( DLG_OKONLY );
|
||||
break;
|
||||
case JNIThread.QUERY_ENDGAME:
|
||||
showDialog( QUERY_ENDGAME );
|
||||
break;
|
||||
case JNIThread.TOOLBAR_STATES:
|
||||
if ( null != m_jniThread ) {
|
||||
m_gsi =
|
||||
m_jniThread.getGameStateInfo();
|
||||
updateToolbar();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
m_jniThread = new JNIThread( m_jniGamePtr, m_gi, m_view,
|
||||
m_gameLock, this, handler );
|
||||
// see http://stackoverflow.com/questions/680180/where-to-stop-\
|
||||
// destroy-threads-in-android-service-class
|
||||
m_jniThread.setDaemon( true );
|
||||
|
@ -1150,71 +1201,31 @@ public class BoardActivity extends XWActivity
|
|||
m_toolbar.setListener( Toolbar.BUTTON_HINT_PREV,
|
||||
R.string.not_again_hintprev,
|
||||
R.string.key_notagain_hintprev,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
checkAndHandle( JNIThread.JNICmd.
|
||||
CMD_PREV_HINT );
|
||||
}
|
||||
} );
|
||||
PREV_HINT_ACTION );
|
||||
m_toolbar.setListener( Toolbar.BUTTON_HINT_NEXT,
|
||||
R.string.not_again_hintnext,
|
||||
R.string.key_notagain_hintnext,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkAndHandle( JNIThread.JNICmd
|
||||
.CMD_NEXT_HINT );
|
||||
}
|
||||
} );
|
||||
NEXT_HINT_ACTION );
|
||||
m_toolbar.setListener( Toolbar.BUTTON_JUGGLE,
|
||||
R.string.not_again_juggle,
|
||||
R.string.key_notagain_juggle,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkAndHandle( JNIThread.JNICmd
|
||||
.CMD_JUGGLE );
|
||||
}
|
||||
} );
|
||||
JUGGLE_ACTION );
|
||||
m_toolbar.setListener( Toolbar.BUTTON_FLIP,
|
||||
R.string.not_again_flip,
|
||||
R.string.key_notagain_flip,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkAndHandle( JNIThread.JNICmd
|
||||
.CMD_FLIP );
|
||||
}
|
||||
} );
|
||||
FLIP_ACTION );
|
||||
m_toolbar.setListener( Toolbar.BUTTON_ZOOM,
|
||||
R.string.not_again_zoom,
|
||||
R.string.key_notagain_zoom,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkAndHandle( JNIThread.JNICmd
|
||||
.CMD_TOGGLEZOOM );
|
||||
}
|
||||
} );
|
||||
ZOOM_ACTION );
|
||||
m_toolbar.setListener( Toolbar.BUTTON_UNDO,
|
||||
R.string.not_again_undo,
|
||||
R.string.key_notagain_undo,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkAndHandle( JNIThread.JNICmd
|
||||
.CMD_UNDO_CUR );
|
||||
}
|
||||
});
|
||||
UNDO_ACTION );
|
||||
m_toolbar.setListener( Toolbar.BUTTON_CHAT,
|
||||
R.string.not_again_chat,
|
||||
R.string.key_notagain_chat,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startChatActivity();
|
||||
}
|
||||
});
|
||||
CHAT_ACTION );
|
||||
} // populateToolbar
|
||||
|
||||
private OnDismissListener makeODLforBlocking( final int id )
|
||||
|
|
|
@ -119,7 +119,6 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
private static final int BLACK = 0xFF000000;
|
||||
private static final int WHITE = 0xFFFFFFFF;
|
||||
private static final int FRAME_GREY = 0xFF101010;
|
||||
private static final int GREY = 0xFF7F7F7F;
|
||||
private int[] m_bonusColors;
|
||||
private int[] m_playerColors;
|
||||
private int[] m_otherColors;
|
||||
|
@ -506,7 +505,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
m_origin.setBounds( rect );
|
||||
m_origin.draw( m_canvas );
|
||||
} else if ( null != bonusStr ) {
|
||||
m_fillPaint.setColor( GREY );
|
||||
m_fillPaint.
|
||||
setColor( m_otherColors[CommonPrefs.COLOR_BONUSHINT] );
|
||||
Rect brect = new Rect( rect );
|
||||
brect.inset( 0, brect.height()/10 );
|
||||
drawCentered( bonusStr, brect, m_fontDims );
|
||||
|
@ -562,8 +562,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
public void run() {
|
||||
m_parent.
|
||||
showNotAgainDlgThen( R.string.not_again_arrow,
|
||||
R.string.key_notagain_arrow,
|
||||
null );
|
||||
R.string.key_notagain_arrow );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -56,11 +56,20 @@ import org.eehouse.android.xw4.jni.CommonPrefs;
|
|||
|
||||
public class DictsActivity extends ExpandableListActivity
|
||||
implements View.OnClickListener, XWListItem.DeleteCallback,
|
||||
SDCardWatcher.SDCardNotifiee {
|
||||
SDCardWatcher.SDCardNotifiee, DlgDelegate.DlgClickNotify {
|
||||
|
||||
private static final String DICT_DOLAUNCH = "do_launch";
|
||||
private static final String DICT_LANG_EXTRA = "use_lang";
|
||||
private static final String DICT_NAME_EXTRA = "use_dict";
|
||||
private static final String PACKED_POSITION = "packed_position";
|
||||
private static final String DELETE_DICT = "delete_dict";
|
||||
private static final String NAME = "name";
|
||||
private static final String LANG = "lang";
|
||||
private static final String MOVEFROMLOC = "movefromloc";
|
||||
private static final String MOVETOLOC = "movetoloc";
|
||||
|
||||
// For new callback alternative
|
||||
private static final int DELETE_DICT_ACTION = 1;
|
||||
|
||||
private static final int PICK_STORAGE = DlgDelegate.DIALOG_LAST + 1;
|
||||
private static final int MOVE_DICT = DlgDelegate.DIALOG_LAST + 2;
|
||||
|
@ -68,21 +77,23 @@ public class DictsActivity extends ExpandableListActivity
|
|||
private int m_lang = 0;
|
||||
private String[] m_langs;
|
||||
private String m_name = null;
|
||||
private String m_deleteDict = null;
|
||||
private String m_download;
|
||||
private ExpandableListView m_expView;
|
||||
private DlgDelegate m_delegate;
|
||||
private String[] m_locNames;
|
||||
private DictListAdapter m_adapter;
|
||||
|
||||
private XWListItem m_rowView;
|
||||
GameUtils.DictLoc m_moveFromLoc;
|
||||
GameUtils.DictLoc m_moveToLoc;
|
||||
private long m_packedPosition;
|
||||
private GameUtils.DictLoc m_moveFromLoc;
|
||||
private GameUtils.DictLoc m_moveToLoc;
|
||||
private SDCardWatcher m_cardWatcher;
|
||||
private String m_moveName;
|
||||
|
||||
private LayoutInflater m_factory;
|
||||
|
||||
private class DictListAdapter implements ExpandableListAdapter {
|
||||
private Context m_context;
|
||||
private XWListItem[][] m_cache;
|
||||
|
||||
public DictListAdapter( Context context ) {
|
||||
//super( context, m_dicts.length );
|
||||
|
@ -105,29 +116,41 @@ public class DictsActivity extends ExpandableListActivity
|
|||
boolean isLastChild, View convertView,
|
||||
ViewGroup parent)
|
||||
{
|
||||
int lang = (int)getGroupId( groupPosition );
|
||||
String[] dicts = DictLangCache.getHaveLang( m_context, lang );
|
||||
String text;
|
||||
boolean canDelete = false;
|
||||
if ( null != dicts && childPosition < dicts.length ) {
|
||||
text = dicts[childPosition];
|
||||
canDelete = !GameUtils.dictIsBuiltin( DictsActivity.this,
|
||||
text );
|
||||
} else {
|
||||
text = m_download;
|
||||
}
|
||||
XWListItem view =
|
||||
(XWListItem)m_factory.inflate( R.layout.list_item, null );
|
||||
view.setText( text );
|
||||
if ( canDelete ) {
|
||||
view.setDeleteCallback( DictsActivity.this );
|
||||
return getChildView( groupPosition, childPosition );
|
||||
}
|
||||
|
||||
private View getChildView( int groupPosition, int childPosition )
|
||||
{
|
||||
XWListItem view = null;
|
||||
if ( null != m_cache && null != m_cache[groupPosition] ) {
|
||||
view = m_cache[groupPosition][childPosition];
|
||||
}
|
||||
|
||||
GameUtils.DictLoc loc =
|
||||
GameUtils.getDictLoc( DictsActivity.this, text );
|
||||
view.setComment( m_locNames[loc.ordinal()] );
|
||||
view.cache( loc );
|
||||
if ( null == view ) {
|
||||
int lang = (int)getGroupId( groupPosition );
|
||||
String[] dicts = DictLangCache.getHaveLang( m_context, lang );
|
||||
String text;
|
||||
boolean canDelete = false;
|
||||
if ( null != dicts && childPosition < dicts.length ) {
|
||||
text = dicts[childPosition];
|
||||
canDelete = !GameUtils.dictIsBuiltin( DictsActivity.this,
|
||||
text );
|
||||
} else {
|
||||
text = m_download;
|
||||
}
|
||||
view = (XWListItem)m_factory.inflate( R.layout.list_item, null );
|
||||
view.setText( text );
|
||||
if ( canDelete ) {
|
||||
view.setDeleteCallback( DictsActivity.this );
|
||||
}
|
||||
|
||||
GameUtils.DictLoc loc =
|
||||
GameUtils.getDictLoc( DictsActivity.this, text );
|
||||
view.setComment( m_locNames[loc.ordinal()] );
|
||||
view.cache( loc );
|
||||
|
||||
addToCache( groupPosition, childPosition, view );
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -188,17 +211,40 @@ public class DictsActivity extends ExpandableListActivity
|
|||
public void onGroupExpanded(int groupPosition){}
|
||||
public void registerDataSetObserver( DataSetObserver obs ){}
|
||||
public void unregisterDataSetObserver( DataSetObserver obs ){}
|
||||
|
||||
protected XWListItem getSelChildView()
|
||||
{
|
||||
int groupPosition =
|
||||
ExpandableListView.getPackedPositionGroup( m_packedPosition );
|
||||
int childPosition =
|
||||
ExpandableListView.getPackedPositionChild( m_packedPosition );
|
||||
return (XWListItem)getChildView( groupPosition, childPosition );
|
||||
}
|
||||
|
||||
private void addToCache( int group, int child, XWListItem view )
|
||||
{
|
||||
if ( null == m_cache ) {
|
||||
m_cache = new XWListItem[getGroupCount()][];
|
||||
}
|
||||
if ( null == m_cache[group] ) {
|
||||
m_cache[group] = new XWListItem[getChildrenCount(group)];
|
||||
}
|
||||
Assert.assertTrue( null == m_cache[group][child] );
|
||||
m_cache[group][child] = view;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog( int id )
|
||||
{
|
||||
Dialog dialog;
|
||||
DialogInterface.OnClickListener lstnr;
|
||||
Dialog dialog;
|
||||
String format;
|
||||
String message;
|
||||
boolean doRemove = true;
|
||||
|
||||
switch( id ) {
|
||||
case PICK_STORAGE:
|
||||
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
startDownload( m_lang, m_name, item !=
|
||||
|
@ -216,21 +262,28 @@ public class DictsActivity extends ExpandableListActivity
|
|||
case MOVE_DICT:
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
XWListItem rowView = m_adapter.getSelChildView();
|
||||
if ( GameUtils.moveDict( DictsActivity.this,
|
||||
m_moveName,
|
||||
rowView.getText(),
|
||||
m_moveFromLoc,
|
||||
m_moveToLoc ) ) {
|
||||
m_rowView.
|
||||
rowView.
|
||||
setComment( m_locNames[m_moveToLoc.ordinal()]);
|
||||
m_rowView.cache( m_moveToLoc );
|
||||
m_rowView.invalidate();
|
||||
rowView.cache( m_moveToLoc );
|
||||
rowView.invalidate();
|
||||
} else {
|
||||
Utils.logf( "moveDict failed" );
|
||||
}
|
||||
}
|
||||
};
|
||||
format = getString( R.string.move_dictf );
|
||||
message = String.format( format,
|
||||
m_adapter.getSelChildView().getText(),
|
||||
m_locNames[ m_moveFromLoc.ordinal() ],
|
||||
m_locNames[ m_moveToLoc.ordinal() ] );
|
||||
|
||||
dialog = new AlertDialog.Builder( this )
|
||||
.setMessage( "" ) // will set later
|
||||
.setMessage( message )
|
||||
.setPositiveButton( R.string.button_ok, lstnr )
|
||||
.setNegativeButton( R.string.button_cancel, null )
|
||||
.create();
|
||||
|
@ -240,18 +293,22 @@ public class DictsActivity extends ExpandableListActivity
|
|||
public void onClick( DialogInterface dlg, int item ) {
|
||||
if ( DialogInterface.BUTTON_NEGATIVE == item
|
||||
|| DialogInterface.BUTTON_POSITIVE == item ) {
|
||||
setDefault( R.string.key_default_dict, m_rowView );
|
||||
setDefault( R.string.key_default_dict );
|
||||
}
|
||||
if ( DialogInterface.BUTTON_NEGATIVE == item
|
||||
|| DialogInterface.BUTTON_NEUTRAL == item ) {
|
||||
setDefault( R.string.key_default_robodict,
|
||||
m_rowView );
|
||||
setDefault( R.string.key_default_robodict );
|
||||
}
|
||||
}
|
||||
};
|
||||
XWListItem rowView = m_adapter.getSelChildView();
|
||||
String lang =
|
||||
DictLangCache.getLangName( this, rowView.getText() );
|
||||
format = getString( R.string.set_default_messagef );
|
||||
message = String.format( format, lang );
|
||||
dialog = new AlertDialog.Builder( this )
|
||||
.setTitle( R.string.query_title )
|
||||
.setMessage( "" ) // or can't change it later!
|
||||
.setMessage( message )
|
||||
.setPositiveButton( R.string.button_default_human, lstnr )
|
||||
.setNeutralButton( R.string.button_default_robot, lstnr )
|
||||
.setNegativeButton( R.string.button_default_both, lstnr )
|
||||
|
@ -259,49 +316,34 @@ public class DictsActivity extends ExpandableListActivity
|
|||
break;
|
||||
default:
|
||||
dialog = m_delegate.onCreateDialog( id );
|
||||
doRemove = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( doRemove && null != dialog ) {
|
||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
} // onCreateDialog
|
||||
|
||||
@Override
|
||||
public void onPrepareDialog( int id, Dialog dialog )
|
||||
protected void onPrepareDialog( int id, Dialog dialog )
|
||||
{
|
||||
AlertDialog ad = (AlertDialog)dialog;
|
||||
String format;
|
||||
String message;
|
||||
|
||||
switch( id ) {
|
||||
case PICK_STORAGE:
|
||||
break;
|
||||
case MOVE_DICT:
|
||||
format = getString( R.string.move_dictf );
|
||||
message = String.format( format, m_moveName,
|
||||
m_locNames[ m_moveFromLoc.ordinal() ],
|
||||
m_locNames[ m_moveToLoc.ordinal() ] );
|
||||
ad.setMessage( message );
|
||||
break;
|
||||
case SET_DEFAULT:
|
||||
String lang =
|
||||
DictLangCache.getLangName( this, m_rowView.getText() );
|
||||
format = getString( R.string.set_default_messagef );
|
||||
message = String.format( format, lang );
|
||||
ad.setMessage( message );
|
||||
break;
|
||||
default:
|
||||
m_delegate.onPrepareDialog( id, dialog );
|
||||
}
|
||||
super.onPrepareDialog( id, dialog );
|
||||
m_delegate.onPrepareDialog( id, dialog );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
protected void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
super.onCreate( savedInstanceState );
|
||||
getBundledData( savedInstanceState );
|
||||
|
||||
Resources res = getResources();
|
||||
m_locNames = res.getStringArray( R.array.loc_names );
|
||||
|
||||
m_delegate = new DlgDelegate( this );
|
||||
m_delegate = new DlgDelegate( this, this, savedInstanceState );
|
||||
m_factory = LayoutInflater.from( this );
|
||||
|
||||
m_download = getString( R.string.download_dicts );
|
||||
|
@ -338,6 +380,44 @@ public class DictsActivity extends ExpandableListActivity
|
|||
expandGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
super.onSaveInstanceState( outState );
|
||||
m_delegate.onSaveInstanceState( outState );
|
||||
|
||||
outState.putLong( PACKED_POSITION, m_packedPosition );
|
||||
outState.putString( NAME, m_name );
|
||||
outState.putInt( LANG, m_lang );
|
||||
outState.putString( DELETE_DICT, m_deleteDict );
|
||||
if ( null != m_moveFromLoc ) {
|
||||
outState.putInt( MOVEFROMLOC, m_moveFromLoc.ordinal() );
|
||||
}
|
||||
if ( null != m_moveToLoc ) {
|
||||
outState.putInt( MOVETOLOC, m_moveToLoc.ordinal() );
|
||||
}
|
||||
}
|
||||
|
||||
private void getBundledData( Bundle savedInstanceState )
|
||||
{
|
||||
if ( null != savedInstanceState ) {
|
||||
m_packedPosition = savedInstanceState.getLong( PACKED_POSITION );
|
||||
m_name = savedInstanceState.getString( NAME );
|
||||
m_lang = savedInstanceState.getInt( LANG );
|
||||
m_deleteDict = savedInstanceState.getString( DELETE_DICT );
|
||||
|
||||
int tmp = savedInstanceState.getInt( MOVEFROMLOC, -1 );
|
||||
if ( -1 != tmp ) {
|
||||
m_moveFromLoc = GameUtils.DictLoc.values()[tmp];
|
||||
}
|
||||
tmp = savedInstanceState.getInt( MOVETOLOC, -1 );
|
||||
if ( -1 != tmp ) {
|
||||
m_moveToLoc = GameUtils.DictLoc.values()[tmp];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
m_cardWatcher.close();
|
||||
m_cardWatcher = null;
|
||||
|
@ -395,14 +475,14 @@ public class DictsActivity extends ExpandableListActivity
|
|||
return false;
|
||||
}
|
||||
|
||||
XWListItem row = (XWListItem)info.targetView;
|
||||
m_packedPosition = info.packedPosition;
|
||||
|
||||
int id = item.getItemId();
|
||||
switch( id ) {
|
||||
case R.id.dicts_item_move:
|
||||
askMoveDict( row );
|
||||
askMoveDict( (XWListItem)info.targetView );
|
||||
break;
|
||||
case R.id.dicts_item_select:
|
||||
m_rowView = row;
|
||||
showDialog( SET_DEFAULT );
|
||||
break;
|
||||
case R.id.dicts_item_details:
|
||||
|
@ -413,13 +493,14 @@ public class DictsActivity extends ExpandableListActivity
|
|||
return handled;
|
||||
}
|
||||
|
||||
private void setDefault( int keyId, final XWListItem text )
|
||||
private void setDefault( int keyId )
|
||||
{
|
||||
XWListItem view = m_adapter.getSelChildView();
|
||||
SharedPreferences sp
|
||||
= PreferenceManager.getDefaultSharedPreferences( this );
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
String key = getString( keyId );
|
||||
String name = text.getText();
|
||||
String name = view.getText();
|
||||
editor.putString( key, name );
|
||||
editor.commit();
|
||||
}
|
||||
|
@ -429,32 +510,25 @@ public class DictsActivity extends ExpandableListActivity
|
|||
// options for YY?
|
||||
private void askMoveDict( XWListItem item )
|
||||
{
|
||||
m_rowView = item;
|
||||
m_moveFromLoc = (GameUtils.DictLoc)item.getCached();
|
||||
if ( m_moveFromLoc == GameUtils.DictLoc.INTERNAL ) {
|
||||
m_moveToLoc = GameUtils.DictLoc.EXTERNAL;
|
||||
} else {
|
||||
m_moveToLoc = GameUtils.DictLoc.INTERNAL;
|
||||
}
|
||||
m_moveName = item.getText();
|
||||
|
||||
showDialog( MOVE_DICT );
|
||||
}
|
||||
|
||||
// XWListItem.DeleteCallback interface
|
||||
public void deleteCalled( int myPosition, final String dict )
|
||||
public void deleteCalled( int myPosition, String dict )
|
||||
{
|
||||
int code = DictLangCache.getDictLangCode( this, dict );
|
||||
String lang = DictLangCache.getLangName( this, code );
|
||||
int nGames = DBUtils.countGamesUsing( this, code );
|
||||
String msg = String.format( getString( R.string.confirm_delete_dictf ),
|
||||
dict );
|
||||
DialogInterface.OnClickListener action =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
deleteDict( dict );
|
||||
}
|
||||
};
|
||||
m_deleteDict = dict;
|
||||
|
||||
if ( nGames > 0 ) {
|
||||
int fmt;
|
||||
|
@ -466,7 +540,7 @@ public class DictsActivity extends ExpandableListActivity
|
|||
msg += String.format( getString(fmt), lang );
|
||||
}
|
||||
|
||||
m_delegate.showConfirmThen( msg, action );
|
||||
m_delegate.showConfirmThen( msg, DELETE_DICT_ACTION );
|
||||
}
|
||||
|
||||
// SDCardWatcher.SDCardNotifiee interface
|
||||
|
@ -476,6 +550,20 @@ public class DictsActivity extends ExpandableListActivity
|
|||
expandGroups();
|
||||
}
|
||||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
public void dlgButtonClicked( int id, int which )
|
||||
{
|
||||
switch( id ) {
|
||||
case DELETE_DICT_ACTION:
|
||||
if ( DialogInterface.BUTTON_POSITIVE == which ) {
|
||||
deleteDict( m_deleteDict );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteDict( String dict )
|
||||
{
|
||||
GameUtils.deleteDict( this, dict );
|
||||
|
@ -508,9 +596,8 @@ public class DictsActivity extends ExpandableListActivity
|
|||
private void mkListAdapter()
|
||||
{
|
||||
m_langs = DictLangCache.listLangs( this );
|
||||
//m_langs = DictLangCache.getLangNames( this );
|
||||
ExpandableListAdapter adapter = new DictListAdapter( this );
|
||||
setListAdapter( adapter );
|
||||
m_adapter = new DictListAdapter( this );
|
||||
setListAdapter( m_adapter );
|
||||
}
|
||||
|
||||
private void expandGroups()
|
||||
|
|
|
@ -21,14 +21,16 @@
|
|||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import junit.framework.Assert;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.app.AlertDialog;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
||||
|
@ -43,21 +45,53 @@ public class DlgDelegate {
|
|||
public static final int DLG_DICTGONE = 6;
|
||||
public static final int DIALOG_LAST = DLG_DICTGONE;
|
||||
|
||||
public static final int TEXT_BTN = AlertDialog.BUTTON_POSITIVE;
|
||||
public static final int HTML_BTN = AlertDialog.BUTTON_NEGATIVE;
|
||||
public static final int DISMISS_BUTTON = 0;
|
||||
public static final int SKIP_CALLBACK = -1;
|
||||
|
||||
private static final String MSG = "msg";
|
||||
private static final String CALLBACK = "callback";
|
||||
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 {
|
||||
void dlgButtonClicked( int id, int button );
|
||||
}
|
||||
|
||||
private int m_msgID;
|
||||
private int m_cbckID = 0; // if this can be set twice I have a
|
||||
// problem. See asserts below.
|
||||
private String m_msg;
|
||||
private Runnable m_proc = null;
|
||||
private int m_prefsKey;
|
||||
private Activity m_activity;
|
||||
private DlgClickNotify m_clickCallback;
|
||||
private String m_dictName = null;
|
||||
DialogInterface.OnClickListener m_then;
|
||||
|
||||
public interface TextOrHtmlClicked {
|
||||
public void clicked( boolean choseText );
|
||||
};
|
||||
private TextOrHtmlClicked m_txt_or_html;
|
||||
|
||||
public DlgDelegate( Activity activity ) {
|
||||
public DlgDelegate( Activity activity, DlgClickNotify callback,
|
||||
Bundle bundle )
|
||||
{
|
||||
m_activity = activity;
|
||||
m_clickCallback = callback;
|
||||
|
||||
if ( null != bundle ) {
|
||||
m_msg = bundle.getString( MSG );
|
||||
m_cbckID = bundle.getInt( CALLBACK );
|
||||
m_msgID = bundle.getInt( MSGID );
|
||||
m_prefsKey = bundle.getInt( PREFSKEY );
|
||||
}
|
||||
}
|
||||
|
||||
public void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
outState.putString( MSG, m_msg );
|
||||
outState.putInt( CALLBACK, m_cbckID );
|
||||
outState.putInt( MSGID, m_msgID );
|
||||
outState.putInt( PREFSKEY, m_prefsKey );
|
||||
}
|
||||
|
||||
public Dialog onCreateDialog( int id )
|
||||
|
@ -86,17 +120,6 @@ public class DlgDelegate {
|
|||
return dialog;
|
||||
}
|
||||
|
||||
protected void setRemoveOnDismiss( Dialog dialog, final int id )
|
||||
{
|
||||
dialog.setOnDismissListener( new DialogInterface.OnDismissListener() {
|
||||
public void onDismiss( DialogInterface di ) {
|
||||
Utils.logf( "%s.onDismiss() called",
|
||||
getClass().getName() );
|
||||
m_activity.removeDialog( id );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public void onPrepareDialog( int id, Dialog dialog )
|
||||
{
|
||||
AlertDialog ad = (AlertDialog)dialog;
|
||||
|
@ -114,27 +137,7 @@ public class DlgDelegate {
|
|||
ad.setMessage( m_activity.getString(m_msgID) );
|
||||
break;
|
||||
case CONFIRM_THEN:
|
||||
// I'm getting an occasional 0 here on device only. May
|
||||
// be related to screen orientation changes. Let's be safe
|
||||
ad.setMessage( m_msg );
|
||||
ad.setButton( AlertDialog.BUTTON_POSITIVE,
|
||||
m_activity.getString( R.string.button_ok ), m_then );
|
||||
break;
|
||||
case TEXT_OR_HTML_THEN:
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int button ) {
|
||||
if ( null != m_txt_or_html ) {
|
||||
m_txt_or_html.
|
||||
clicked( button == AlertDialog.BUTTON_POSITIVE );
|
||||
}
|
||||
}
|
||||
};
|
||||
ad.setButton( AlertDialog.BUTTON_POSITIVE,
|
||||
m_activity.getString( R.string.button_text ),
|
||||
lstnr );
|
||||
ad.setButton( AlertDialog.BUTTON_NEGATIVE,
|
||||
m_activity.getString( R.string.button_html ),
|
||||
lstnr );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -156,31 +159,45 @@ public class DlgDelegate {
|
|||
}
|
||||
|
||||
public void showNotAgainDlgThen( int msgID, int prefsKey,
|
||||
Runnable proc )
|
||||
int callbackID )
|
||||
{
|
||||
boolean set = CommonPrefs.getPrefsBoolean( m_activity, prefsKey, false );
|
||||
if ( set ) {
|
||||
if ( null != proc ) {
|
||||
proc.run();
|
||||
}
|
||||
if ( set || 0 != m_cbckID ) {
|
||||
// If it's set, do the action without bothering with the
|
||||
// dialog
|
||||
if ( SKIP_CALLBACK != callbackID ) {
|
||||
m_clickCallback.dlgButtonClicked( callbackID,
|
||||
AlertDialog.BUTTON_POSITIVE );
|
||||
}
|
||||
} else {
|
||||
m_msgID = msgID;
|
||||
m_proc = proc;
|
||||
Assert.assertTrue( 0 != callbackID );
|
||||
Assert.assertTrue( 0 == m_cbckID ); // fired
|
||||
m_cbckID = callbackID;
|
||||
m_prefsKey = prefsKey;
|
||||
m_activity.showDialog( DIALOG_NOTAGAIN );
|
||||
}
|
||||
}
|
||||
|
||||
public void showConfirmThen( String msg, DialogInterface.OnClickListener then )
|
||||
public void showNotAgainDlgThen( int msgID, int prefsKey )
|
||||
{
|
||||
showNotAgainDlgThen( msgID, prefsKey, SKIP_CALLBACK );
|
||||
}
|
||||
|
||||
public void showConfirmThen( String msg, int callbackID )
|
||||
{
|
||||
m_msg = msg;
|
||||
m_then = then;
|
||||
Assert.assertTrue( 0 != callbackID );
|
||||
Assert.assertTrue( 0 == m_cbckID );
|
||||
m_cbckID = callbackID;
|
||||
m_activity.showDialog( CONFIRM_THEN );
|
||||
}
|
||||
|
||||
public void showTextOrHtmlThen( TextOrHtmlClicked txtOrHtml )
|
||||
public void showTextOrHtmlThen( int callbackID )
|
||||
{
|
||||
m_txt_or_html = txtOrHtml;
|
||||
Assert.assertTrue( 0 != callbackID );
|
||||
Assert.assertTrue( 0 == m_cbckID );
|
||||
m_cbckID = callbackID;
|
||||
m_activity.showDialog( TEXT_OR_HTML_THEN );
|
||||
}
|
||||
|
||||
|
@ -239,64 +256,61 @@ public class DlgDelegate {
|
|||
|
||||
private Dialog createNotAgainDialog()
|
||||
{
|
||||
Dialog dialog = null;
|
||||
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_p = mkCallbackClickListener();
|
||||
|
||||
DialogInterface.OnClickListener lstnr_n =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
CommonPrefs.setPrefsBoolean( m_activity, m_prefsKey,
|
||||
true );
|
||||
if ( null != m_proc ) {
|
||||
m_proc.run();
|
||||
}
|
||||
DialogInterface.OnClickListener lstnr_n =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
CommonPrefs.setPrefsBoolean( m_activity, m_prefsKey,
|
||||
true );
|
||||
if ( SKIP_CALLBACK != m_cbckID ) {
|
||||
m_clickCallback.
|
||||
dlgButtonClicked( m_cbckID,
|
||||
AlertDialog.BUTTON_POSITIVE );
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
dialog = new AlertDialog.Builder( m_activity )
|
||||
.setTitle( R.string.newbie_title )
|
||||
.setMessage( m_msgID )
|
||||
.setPositiveButton( R.string.button_ok, lstnr_p )
|
||||
.setNegativeButton( R.string.button_notagain, lstnr_n )
|
||||
.create();
|
||||
}
|
||||
return dialog;
|
||||
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||
.setTitle( R.string.newbie_title )
|
||||
.setMessage( m_msgID )
|
||||
.setPositiveButton( R.string.button_ok, lstnr_p )
|
||||
.setNegativeButton( R.string.button_notagain, lstnr_n )
|
||||
.create();
|
||||
|
||||
return setCallbackDismissListener( dialog );
|
||||
} // createNotAgainDialog
|
||||
|
||||
private Dialog createConfirmThenDialog()
|
||||
{
|
||||
DialogInterface.OnClickListener lstnr = mkCallbackClickListener();
|
||||
|
||||
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||
.setTitle( R.string.query_title )
|
||||
.setMessage( "" )
|
||||
.setPositiveButton( R.string.button_ok, null ) // will change
|
||||
.setNegativeButton( R.string.button_cancel, null )
|
||||
.setPositiveButton( R.string.button_ok, lstnr )
|
||||
.setNegativeButton( R.string.button_cancel, lstnr )
|
||||
.create();
|
||||
return dialog;
|
||||
|
||||
return setCallbackDismissListener( dialog );
|
||||
}
|
||||
|
||||
private Dialog createHtmlThenDialog()
|
||||
{
|
||||
return new AlertDialog.Builder( m_activity )
|
||||
DialogInterface.OnClickListener lstnr = mkCallbackClickListener();
|
||||
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||
.setTitle( R.string.query_title )
|
||||
.setMessage( R.string.text_or_html )
|
||||
.setPositiveButton( R.string.button_text, null ) // will change
|
||||
.setNegativeButton( R.string.button_html, null )
|
||||
.setPositiveButton( R.string.button_text, lstnr )
|
||||
.setNegativeButton( R.string.button_html, lstnr )
|
||||
.create();
|
||||
|
||||
return setCallbackDismissListener( dialog );
|
||||
}
|
||||
|
||||
private Dialog createDictGoneDialog()
|
||||
{
|
||||
Utils.logf( "DlgDelegate.createDictGoneDialog() called" );
|
||||
Dialog dialog;
|
||||
dialog = new AlertDialog.Builder( m_activity )
|
||||
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||
.setTitle( R.string.no_dict_title )
|
||||
.setMessage( R.string.no_dict_finish )
|
||||
.setPositiveButton( R.string.button_close_game, null )
|
||||
|
@ -311,4 +325,36 @@ public class DlgDelegate {
|
|||
return dialog;
|
||||
}
|
||||
|
||||
private DialogInterface.OnClickListener mkCallbackClickListener()
|
||||
{
|
||||
if ( null == m_cbkOnClickLstnr ) {
|
||||
m_cbkOnClickLstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int button ) {
|
||||
if ( SKIP_CALLBACK != m_cbckID ) {
|
||||
m_clickCallback.dlgButtonClicked( m_cbckID,
|
||||
button );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
return m_cbkOnClickLstnr;
|
||||
}
|
||||
|
||||
private Dialog setCallbackDismissListener( Dialog dialog )
|
||||
{
|
||||
if ( null == m_cbkOnDismissLstnr ) {
|
||||
m_cbkOnDismissLstnr = new DialogInterface.OnDismissListener() {
|
||||
public void onDismiss( DialogInterface di ) {
|
||||
if ( SKIP_CALLBACK != m_cbckID ) {
|
||||
m_clickCallback.dlgButtonClicked( m_cbckID,
|
||||
DISMISS_BUTTON );
|
||||
}
|
||||
m_cbckID = 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
dialog.setOnDismissListener( m_cbkOnDismissLstnr );
|
||||
return dialog;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ public class GameConfig extends XWActivity
|
|||
private static final int CONFIRM_CHANGE_PLAY = PLAYER_EDIT + 3;
|
||||
private static final int NO_NAME_FOUND = PLAYER_EDIT + 4;
|
||||
|
||||
private static final String WHICH_PLAYER = "WHICH_PLAYER";
|
||||
private static final int LOCKED_CHANGE_ACTION = 1;
|
||||
|
||||
private CheckBox m_joinPublicCheck;
|
||||
private CheckBox m_gameLockedCheck;
|
||||
private boolean m_isLocked;
|
||||
|
@ -202,7 +205,7 @@ public class GameConfig extends XWActivity
|
|||
.create();
|
||||
dialog.setOnDismissListener( new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss( DialogInterface di )
|
||||
public void onDismiss( DialogInterface di )
|
||||
{
|
||||
if ( m_gi.forceRemoteConsistent() ) {
|
||||
Toast.makeText( GameConfig.this,
|
||||
|
@ -358,6 +361,7 @@ public class GameConfig extends XWActivity
|
|||
public void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
getBundledData( savedInstanceState );
|
||||
|
||||
// 1.5 doesn't have SDK_INT. So parse the string version.
|
||||
// int sdk_int = 0;
|
||||
|
@ -391,97 +395,19 @@ public class GameConfig extends XWActivity
|
|||
setTitle();
|
||||
} // onCreate
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
super.onStart();
|
||||
loadGame();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
m_giOrig = new CurGameInfo( this );
|
||||
// Lock in case we're going to config. We *could* re-get the
|
||||
// lock once the user decides to make changes. PENDING.
|
||||
m_gameLock = new GameUtils.GameLock( m_rowid, true ).lock();
|
||||
int gamePtr = GameUtils.loadMakeGame( this, m_giOrig, m_gameLock );
|
||||
if ( 0 == gamePtr ) {
|
||||
showDictGoneFinish();
|
||||
} else {
|
||||
m_gameStarted = XwJNI.model_getNMoves( gamePtr ) > 0
|
||||
|| XwJNI.comms_isConnected( gamePtr );
|
||||
|
||||
if ( m_gameStarted ) {
|
||||
if ( null == m_gameLockedCheck ) {
|
||||
m_gameLockedCheck =
|
||||
(CheckBox)findViewById( R.id.game_locked_check );
|
||||
m_gameLockedCheck.setVisibility( View.VISIBLE );
|
||||
m_gameLockedCheck.setChecked( true );
|
||||
m_gameLockedCheck.setOnClickListener( this );
|
||||
}
|
||||
handleLockedChange();
|
||||
}
|
||||
|
||||
m_gi = new CurGameInfo( this, m_giOrig );
|
||||
|
||||
m_carOrig = new CommsAddrRec( this );
|
||||
if ( XwJNI.game_hasComms( gamePtr ) ) {
|
||||
XwJNI.comms_getAddr( gamePtr, m_carOrig );
|
||||
} else {
|
||||
String relayName = CommonPrefs.getDefaultRelayHost( this );
|
||||
int relayPort = CommonPrefs.getDefaultRelayPort( this );
|
||||
XwJNI.comms_getInitialAddr( m_carOrig, relayName, relayPort );
|
||||
}
|
||||
XwJNI.game_dispose( gamePtr );
|
||||
|
||||
m_car = new CommsAddrRec( m_carOrig );
|
||||
|
||||
m_notNetworkedGame = DeviceRole.SERVER_STANDALONE == m_gi.serverRole;
|
||||
setTitle();
|
||||
|
||||
if ( !m_notNetworkedGame ) {
|
||||
m_joinPublicCheck =
|
||||
(CheckBox)findViewById(R.id.join_public_room_check);
|
||||
m_joinPublicCheck.setOnClickListener( this );
|
||||
m_joinPublicCheck.setChecked( m_car.ip_relay_seeksPublicRoom );
|
||||
Utils.setChecked( this, R.id.advertise_new_room_check,
|
||||
m_car.ip_relay_advertiseRoom );
|
||||
m_publicRoomsSet =
|
||||
(LinearLayout)findViewById(R.id.public_rooms_set );
|
||||
m_privateRoomsSet =
|
||||
(LinearLayout)findViewById(R.id.private_rooms_set );
|
||||
|
||||
Utils.setText( this, R.id.room_edit, m_car.ip_relay_invite );
|
||||
|
||||
m_roomChoose = (Spinner)findViewById( R.id.room_spinner );
|
||||
|
||||
m_refreshRoomsButton =
|
||||
(ImageButton)findViewById( R.id.refresh_button );
|
||||
m_refreshRoomsButton.setOnClickListener( this );
|
||||
|
||||
adjustConnectStuff();
|
||||
}
|
||||
|
||||
loadPlayers();
|
||||
configLangSpinner();
|
||||
|
||||
m_phoniesSpinner.setSelection( m_gi.phoniesAction.ordinal() );
|
||||
|
||||
setSmartnessSpinner();
|
||||
|
||||
Utils.setChecked( this, R.id.hints_allowed, !m_gi.hintsNotAllowed );
|
||||
Utils.setInt( this, R.id.timer_minutes_edit,
|
||||
m_gi.gameSeconds/60/m_gi.nPlayers );
|
||||
|
||||
CheckBox check = (CheckBox)findViewById( R.id.use_timer );
|
||||
CompoundButton.OnCheckedChangeListener lstnr =
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
public void onCheckedChanged( CompoundButton buttonView,
|
||||
boolean checked ) {
|
||||
View view = findViewById( R.id.timer_set );
|
||||
view.setVisibility( checked ? View.VISIBLE : View.GONE );
|
||||
}
|
||||
};
|
||||
check.setOnCheckedChangeListener( lstnr );
|
||||
Utils.setChecked( this, R.id.use_timer, m_gi.timerEnabled );
|
||||
}
|
||||
} // onResume
|
||||
loadGame();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
|
@ -490,9 +416,116 @@ public class GameConfig extends XWActivity
|
|||
m_gameLock.unlock();
|
||||
m_gameLock = null;
|
||||
}
|
||||
m_giOrig = null; // flag for onStart and onResume
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
super.onSaveInstanceState( outState );
|
||||
outState.putInt( WHICH_PLAYER, m_whichPlayer );
|
||||
}
|
||||
|
||||
private void loadGame()
|
||||
{
|
||||
if ( null == m_giOrig ) {
|
||||
m_giOrig = new CurGameInfo( this );
|
||||
|
||||
// Lock in case we're going to config. We *could* re-get the
|
||||
// lock once the user decides to make changes. PENDING.
|
||||
m_gameLock = new GameUtils.GameLock( m_rowid, true ).lock();
|
||||
int gamePtr = GameUtils.loadMakeGame( this, m_giOrig, m_gameLock );
|
||||
if ( 0 == gamePtr ) {
|
||||
showDictGoneFinish();
|
||||
} else {
|
||||
m_gameStarted = XwJNI.model_getNMoves( gamePtr ) > 0
|
||||
|| XwJNI.comms_isConnected( gamePtr );
|
||||
|
||||
if ( m_gameStarted ) {
|
||||
if ( null == m_gameLockedCheck ) {
|
||||
m_gameLockedCheck =
|
||||
(CheckBox)findViewById( R.id.game_locked_check );
|
||||
m_gameLockedCheck.setVisibility( View.VISIBLE );
|
||||
m_gameLockedCheck.setChecked( true );
|
||||
m_gameLockedCheck.setOnClickListener( this );
|
||||
}
|
||||
handleLockedChange();
|
||||
}
|
||||
|
||||
m_gi = new CurGameInfo( this, m_giOrig );
|
||||
|
||||
m_carOrig = new CommsAddrRec( this );
|
||||
if ( XwJNI.game_hasComms( gamePtr ) ) {
|
||||
XwJNI.comms_getAddr( gamePtr, m_carOrig );
|
||||
} else {
|
||||
String relayName = CommonPrefs.getDefaultRelayHost( this );
|
||||
int relayPort = CommonPrefs.getDefaultRelayPort( this );
|
||||
XwJNI.comms_getInitialAddr( m_carOrig, relayName, relayPort );
|
||||
}
|
||||
XwJNI.game_dispose( gamePtr );
|
||||
|
||||
m_car = new CommsAddrRec( m_carOrig );
|
||||
|
||||
m_notNetworkedGame = DeviceRole.SERVER_STANDALONE == m_gi.serverRole;
|
||||
setTitle();
|
||||
|
||||
if ( !m_notNetworkedGame ) {
|
||||
m_joinPublicCheck =
|
||||
(CheckBox)findViewById(R.id.join_public_room_check);
|
||||
m_joinPublicCheck.setOnClickListener( this );
|
||||
m_joinPublicCheck.setChecked( m_car.ip_relay_seeksPublicRoom );
|
||||
Utils.setChecked( this, R.id.advertise_new_room_check,
|
||||
m_car.ip_relay_advertiseRoom );
|
||||
m_publicRoomsSet =
|
||||
(LinearLayout)findViewById(R.id.public_rooms_set );
|
||||
m_privateRoomsSet =
|
||||
(LinearLayout)findViewById(R.id.private_rooms_set );
|
||||
|
||||
Utils.setText( this, R.id.room_edit, m_car.ip_relay_invite );
|
||||
|
||||
m_roomChoose = (Spinner)findViewById( R.id.room_spinner );
|
||||
|
||||
m_refreshRoomsButton =
|
||||
(ImageButton)findViewById( R.id.refresh_button );
|
||||
m_refreshRoomsButton.setOnClickListener( this );
|
||||
|
||||
adjustConnectStuff();
|
||||
}
|
||||
|
||||
loadPlayers();
|
||||
configLangSpinner();
|
||||
|
||||
m_phoniesSpinner.setSelection( m_gi.phoniesAction.ordinal() );
|
||||
|
||||
setSmartnessSpinner();
|
||||
|
||||
Utils.setChecked( this, R.id.hints_allowed, !m_gi.hintsNotAllowed );
|
||||
Utils.setInt( this, R.id.timer_minutes_edit,
|
||||
m_gi.gameSeconds/60/m_gi.nPlayers );
|
||||
|
||||
CheckBox check = (CheckBox)findViewById( R.id.use_timer );
|
||||
CompoundButton.OnCheckedChangeListener lstnr =
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
public void onCheckedChanged( CompoundButton buttonView,
|
||||
boolean checked ) {
|
||||
View view = findViewById( R.id.timer_set );
|
||||
view.setVisibility( checked ? View.VISIBLE : View.GONE );
|
||||
}
|
||||
};
|
||||
check.setOnCheckedChangeListener( lstnr );
|
||||
Utils.setChecked( this, R.id.use_timer, m_gi.timerEnabled );
|
||||
}
|
||||
}
|
||||
} // loadGame
|
||||
|
||||
private void getBundledData( Bundle bundle )
|
||||
{
|
||||
if ( null != bundle ) {
|
||||
m_whichPlayer = bundle.getInt( WHICH_PLAYER );
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteCallback interface
|
||||
public void deleteCalled( int myPosition, final String name )
|
||||
{
|
||||
|
@ -507,6 +540,20 @@ public class GameConfig extends XWActivity
|
|||
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 )
|
||||
{
|
||||
if ( m_addPlayerButton == view ) {
|
||||
|
@ -523,11 +570,7 @@ public class GameConfig extends XWActivity
|
|||
} else if ( m_gameLockedCheck == view ) {
|
||||
showNotAgainDlgThen( R.string.not_again_unlock,
|
||||
R.string.key_notagain_unlock,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
handleLockedChange();
|
||||
}
|
||||
});
|
||||
LOCKED_CHANGE_ACTION );
|
||||
} else if ( m_refreshRoomsButton == view ) {
|
||||
refreshNames();
|
||||
} else if ( m_playButton == view ) {
|
||||
|
@ -644,6 +687,9 @@ public class GameConfig extends XWActivity
|
|||
{
|
||||
Spinner dictsSpinner =
|
||||
(Spinner)dialog.findViewById( R.id.dict_spinner );
|
||||
String fmt = getString( R.string.dicts_list_promptf );
|
||||
String lang = DictLangCache.getLangName( this, m_gi.dictLang );
|
||||
dictsSpinner.setPrompt(String.format( fmt, lang ) );
|
||||
|
||||
OnItemSelectedListener onSel =
|
||||
new OnItemSelectedListener() {
|
||||
|
|
|
@ -460,21 +460,6 @@ public class GameUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static void launchInviteActivity( final XWActivity activity,
|
||||
final String room,
|
||||
final int lang,
|
||||
final int nPlayers )
|
||||
{
|
||||
DlgDelegate.TextOrHtmlClicked cb =
|
||||
new DlgDelegate.TextOrHtmlClicked() {
|
||||
public void clicked( boolean choseText ) {
|
||||
launchInviteActivity( activity, choseText, room,
|
||||
lang, nPlayers );
|
||||
}
|
||||
};
|
||||
activity.showTextOrHtmlThen( cb );
|
||||
}
|
||||
|
||||
public static boolean gameDictsHere( Context context, long rowid )
|
||||
{
|
||||
return gameDictsHere( context, rowid, null, null );
|
||||
|
|
|
@ -63,6 +63,13 @@ public class GamesList extends XWListActivity
|
|||
|
||||
private static final String SAVE_ROWID = "SAVE_ROWID";
|
||||
|
||||
private static final int NEW_NET_GAME_ACTION = 1;
|
||||
private static final int RESET_GAME_ACTION = 2;
|
||||
private static final int DELETE_GAME_ACTION = 3;
|
||||
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 String m_missingDict;
|
||||
private Handler m_handler;
|
||||
|
@ -72,6 +79,7 @@ public class GamesList extends XWListActivity
|
|||
private int m_missingDictLang;
|
||||
private long m_rowid;
|
||||
private String m_nameField;
|
||||
private NetLaunchInfo m_netLaunchInfo;
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog( int id )
|
||||
|
@ -124,7 +132,7 @@ public class GamesList extends XWListActivity
|
|||
ab.setNeutralButton( R.string.button_substdict, lstnr );
|
||||
}
|
||||
dialog = ab.create();
|
||||
setRemoveOnDismiss( dialog, id );
|
||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
||||
break;
|
||||
case SHOW_SUBST:
|
||||
m_sameLangDicts =
|
||||
|
@ -334,12 +342,16 @@ public class GamesList extends XWListActivity
|
|||
{
|
||||
super.onSaveInstanceState( outState );
|
||||
outState.putLong( SAVE_ROWID, m_rowid );
|
||||
if ( null != m_netLaunchInfo ) {
|
||||
m_netLaunchInfo.putSelf( outState );
|
||||
}
|
||||
}
|
||||
|
||||
private void getBundledData( Bundle bundle )
|
||||
{
|
||||
if ( null != bundle ) {
|
||||
m_rowid = bundle.getLong( SAVE_ROWID );
|
||||
m_netLaunchInfo = new NetLaunchInfo( bundle );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,6 +405,44 @@ public class GamesList extends XWListActivity
|
|||
onContentChanged();
|
||||
}
|
||||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
@Override
|
||||
public void dlgButtonClicked( int id, int which )
|
||||
{
|
||||
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
switch( id ) {
|
||||
case NEW_NET_GAME_ACTION:
|
||||
long rowid = GameUtils.makeNewNetGame( this, m_netLaunchInfo );
|
||||
GameUtils.launchGame( this, rowid, true );
|
||||
break;
|
||||
case RESET_GAME_ACTION:
|
||||
GameUtils.resetGame( this, m_rowid );
|
||||
break;
|
||||
case DELETE_GAME_ACTION:
|
||||
GameUtils.deleteGame( this, m_rowid, true );
|
||||
break;
|
||||
case DELETE_ALL_ACTION:
|
||||
long[] games = DBUtils.gamesList( this );
|
||||
for ( int ii = games.length - 1; ii >= 0; --ii ) {
|
||||
GameUtils.deleteGame( this, games[ii], ii == 0 );
|
||||
m_adapter.inval( games[ii] );
|
||||
}
|
||||
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:
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void itemClicked( long rowid )
|
||||
{
|
||||
// We need a way to let the user get back to the basic-config
|
||||
|
@ -466,19 +516,9 @@ public class GamesList extends XWListActivity
|
|||
break;
|
||||
|
||||
case R.id.gamel_menu_delete_all:
|
||||
final long[] games = DBUtils.gamesList( this );
|
||||
if ( games.length > 0 ) {
|
||||
DialogInterface.OnClickListener lstnr =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
for ( int ii = games.length - 1; ii >= 0; --ii ) {
|
||||
GameUtils.deleteGame( GamesList.this, games[ii],
|
||||
ii == 0 );
|
||||
m_adapter.inval( games[ii] );
|
||||
}
|
||||
}
|
||||
};
|
||||
showConfirmThen( R.string.confirm_delete_all, lstnr );
|
||||
if ( DBUtils.gamesList( this ).length > 0 ) {
|
||||
showConfirmThen( R.string.confirm_delete_all,
|
||||
DELETE_ALL_ACTION );
|
||||
}
|
||||
handled = true;
|
||||
break;
|
||||
|
@ -491,11 +531,7 @@ public class GamesList extends XWListActivity
|
|||
case R.id.gamel_menu_checkmoves:
|
||||
showNotAgainDlgThen( R.string.not_again_sync,
|
||||
R.string.key_notagain_sync,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
doSyncMenuitem();
|
||||
}
|
||||
} );
|
||||
SYNC_MENU_ACTION );
|
||||
break;
|
||||
|
||||
case R.id.gamel_menu_prefs:
|
||||
|
@ -522,54 +558,36 @@ public class GamesList extends XWListActivity
|
|||
boolean handled = true;
|
||||
DialogInterface.OnClickListener lstnr;
|
||||
|
||||
final long rowid = DBUtils.gamesList( this )[position];
|
||||
|
||||
m_rowid = DBUtils.gamesList( this )[position];
|
||||
|
||||
if ( R.id.list_item_delete == menuID ) {
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int ii ) {
|
||||
GameUtils.deleteGame( GamesList.this, rowid, true );
|
||||
}
|
||||
};
|
||||
showConfirmThen( R.string.confirm_delete, lstnr );
|
||||
showConfirmThen( R.string.confirm_delete, DELETE_GAME_ACTION );
|
||||
} else {
|
||||
if ( checkWarnNoDict( rowid ) ) {
|
||||
if ( checkWarnNoDict( m_rowid ) ) {
|
||||
switch ( menuID ) {
|
||||
case R.id.list_item_reset:
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int ii ) {
|
||||
GameUtils.resetGame( GamesList.this, rowid );
|
||||
}
|
||||
};
|
||||
showConfirmThen( R.string.confirm_reset, lstnr );
|
||||
showConfirmThen( R.string.confirm_reset, RESET_GAME_ACTION );
|
||||
break;
|
||||
case R.id.list_item_config:
|
||||
GameUtils.doConfig( this, rowid, GameConfig.class );
|
||||
GameUtils.doConfig( this, m_rowid, GameConfig.class );
|
||||
break;
|
||||
case R.id.list_item_rename:
|
||||
m_rowid = rowid;
|
||||
showDialog( RENAME_GAME );
|
||||
break;
|
||||
|
||||
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,
|
||||
R.string.key_notagain_newfrom, proc );
|
||||
R.string.key_notagain_newfrom,
|
||||
DUPE_GAME_ACTION );
|
||||
break;
|
||||
|
||||
case R.id.list_item_copy:
|
||||
GameSummary summary = DBUtils.getSummary( this, rowid, true );
|
||||
GameSummary summary = DBUtils.getSummary( this,
|
||||
m_rowid, true );
|
||||
if ( summary.inNetworkGame() ) {
|
||||
showOKOnlyDialog( R.string.no_copy_network );
|
||||
} else {
|
||||
byte[] stream = GameUtils.savedGame( this, rowid );
|
||||
byte[] stream = GameUtils.savedGame( this, m_rowid );
|
||||
GameUtils.GameLock lock =
|
||||
GameUtils.saveNewGame( this, stream );
|
||||
DBUtils.saveSummary( this, lock, summary );
|
||||
|
@ -656,7 +674,7 @@ public class GamesList extends XWListActivity
|
|||
startActivity( new Intent( this, NewGameActivity.class ) );
|
||||
}
|
||||
|
||||
private void startNewNetGame( final NetLaunchInfo info )
|
||||
private void startNewNetGame( NetLaunchInfo info )
|
||||
{
|
||||
long rowid = DBUtils.getRowIDForOpen( this, info.room, info.lang,
|
||||
info.nPlayers );
|
||||
|
@ -665,19 +683,10 @@ public class GamesList extends XWListActivity
|
|||
rowid = GameUtils.makeNewNetGame( this, info );
|
||||
GameUtils.launchGame( this, rowid, true );
|
||||
} else {
|
||||
DialogInterface.OnClickListener then =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg,
|
||||
int ii ) {
|
||||
long rowid = GameUtils.
|
||||
makeNewNetGame( GamesList.this, info );
|
||||
GameUtils.launchGame( GamesList.this,
|
||||
rowid, true );
|
||||
}
|
||||
};
|
||||
String fmt = getString( R.string.dup_game_queryf );
|
||||
String msg = String.format( fmt, info.room );
|
||||
showConfirmThen( msg, then );
|
||||
m_netLaunchInfo = info;
|
||||
showConfirmThen( msg, NEW_NET_GAME_ACTION );
|
||||
}
|
||||
} // startNewNetGame
|
||||
|
||||
|
|
|
@ -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() );
|
||||
// }
|
||||
// }
|
||||
// }
|
|
@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
|
|||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.net.Uri.Builder;
|
||||
import android.os.Bundle;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
@ -33,8 +34,29 @@ public class NetLaunchInfo {
|
|||
public int lang;
|
||||
public int nPlayers;
|
||||
|
||||
private static final String LANG = "netlaunchinfo_lang";
|
||||
private static final String ROOM = "netlaunchinfo_room";
|
||||
private static final String NPLAYERS = "netlaunchinfo_nplayers";
|
||||
private static final String VALID = "netlaunchinfo_valid";
|
||||
|
||||
private boolean m_valid;
|
||||
|
||||
public void putSelf( Bundle bundle )
|
||||
{
|
||||
bundle.putInt( LANG, lang );
|
||||
bundle.putString( ROOM, room );
|
||||
bundle.putInt( NPLAYERS, nPlayers );
|
||||
bundle.putBoolean( VALID, m_valid );
|
||||
}
|
||||
|
||||
public NetLaunchInfo( Bundle bundle )
|
||||
{
|
||||
lang = bundle.getInt( LANG );
|
||||
room = bundle.getString( ROOM );
|
||||
nPlayers = bundle.getInt( NPLAYERS );
|
||||
m_valid = bundle.getBoolean( VALID );
|
||||
}
|
||||
|
||||
public static Uri makeLaunchUri( Context context, String room,
|
||||
int lang, int nPlayers )
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.view.View;
|
|||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import java.util.Random;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CurGameInfo;
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
@ -38,6 +39,8 @@ import org.eehouse.android.xw4.jni.XwJNI;
|
|||
|
||||
public class NewGameActivity extends XWActivity {
|
||||
|
||||
private static final int NEW_GAME_ACTION = 1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
|
@ -84,15 +87,26 @@ public class NewGameActivity extends XWActivity {
|
|||
|
||||
}
|
||||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
@Override
|
||||
public void dlgButtonClicked( int id, int which )
|
||||
{
|
||||
switch( id ) {
|
||||
case NEW_GAME_ACTION:
|
||||
if ( DlgDelegate.DISMISS_BUTTON != which ) {
|
||||
makeNewGame( true, true, DlgDelegate.TEXT_BTN == which );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
private void makeNewGame( boolean networked, boolean launch )
|
||||
{
|
||||
if ( launch && networked ) {
|
||||
// Let 'em cancel before we make the game
|
||||
showTextOrHtmlThen( new DlgDelegate.TextOrHtmlClicked() {
|
||||
public void clicked( boolean choseText ) {
|
||||
makeNewGame( true, true, choseText );
|
||||
}
|
||||
} );
|
||||
showTextOrHtmlThen( NEW_GAME_ACTION );
|
||||
} else {
|
||||
makeNewGame( networked, launch, false );
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ public class PrefsActivity extends PreferenceActivity
|
|||
R.string.key_clr_crosshairs,
|
||||
R.string.key_empty,
|
||||
R.string.key_background,
|
||||
R.string.key_clr_bonushint,
|
||||
};
|
||||
for ( int colorKey : colorKeys ) {
|
||||
editor.remove( getString(colorKey) );
|
||||
|
|
|
@ -85,11 +85,11 @@ public class Toolbar {
|
|||
}
|
||||
|
||||
public void setListener( int index, final int msgID, final int prefsKey,
|
||||
final Runnable proc )
|
||||
final int callback )
|
||||
{
|
||||
View.OnClickListener listener = new View.OnClickListener() {
|
||||
public void onClick( View view ) {
|
||||
m_activity.showNotAgainDlgThen( msgID, prefsKey, proc );
|
||||
m_activity.showNotAgainDlgThen( msgID, prefsKey, callback );
|
||||
}
|
||||
};
|
||||
setListener( index, listener );
|
||||
|
|
|
@ -22,14 +22,15 @@ package org.eehouse.android.xw4;
|
|||
|
||||
import android.util.Log;
|
||||
import java.lang.Thread;
|
||||
import android.widget.Toast;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.widget.Toast;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -105,6 +106,16 @@ public class Utils {
|
|||
Toast.makeText( context, text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static void setRemoveOnDismiss( final Activity activity,
|
||||
Dialog dialog, final int id )
|
||||
{
|
||||
dialog.setOnDismissListener( new DialogInterface.OnDismissListener() {
|
||||
public void onDismiss( DialogInterface di ) {
|
||||
activity.removeDialog( id );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public static View inflate( Context context, int layoutId )
|
||||
{
|
||||
LayoutInflater factory = LayoutInflater.from( context );
|
||||
|
|
|
@ -32,7 +32,8 @@ import android.os.Bundle;
|
|||
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
||||
public class XWActivity extends Activity {
|
||||
public class XWActivity extends Activity
|
||||
implements DlgDelegate.DlgClickNotify {
|
||||
|
||||
private DlgDelegate m_delegate;
|
||||
|
||||
|
@ -41,7 +42,7 @@ public class XWActivity extends Activity {
|
|||
{
|
||||
Utils.logf( "%s.onCreate(this=%H)", getClass().getName(), this );
|
||||
super.onCreate( savedInstanceState );
|
||||
m_delegate = new DlgDelegate( this );
|
||||
m_delegate = new DlgDelegate( this, this, savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,6 +83,13 @@ public class XWActivity extends Activity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
super.onSaveInstanceState( outState );
|
||||
m_delegate.onSaveInstanceState( outState );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog( int id )
|
||||
{
|
||||
|
@ -93,11 +101,6 @@ public class XWActivity extends Activity {
|
|||
return dialog;
|
||||
}
|
||||
|
||||
protected void setRemoveOnDismiss( Dialog dialog, int id )
|
||||
{
|
||||
m_delegate.setRemoveOnDismiss( dialog, id );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialog( int id, Dialog dialog )
|
||||
{
|
||||
|
@ -113,9 +116,14 @@ public class XWActivity extends Activity {
|
|||
}
|
||||
|
||||
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 )
|
||||
|
@ -128,19 +136,25 @@ public class XWActivity extends Activity {
|
|||
m_delegate.showDictGoneFinish();
|
||||
}
|
||||
|
||||
protected void showConfirmThen( int msgID,
|
||||
DialogInterface.OnClickListener action )
|
||||
protected void showConfirmThen( int msgID, int action )
|
||||
{
|
||||
m_delegate.showConfirmThen( getString(msgID), action );
|
||||
}
|
||||
|
||||
public void showTextOrHtmlThen( DlgDelegate.TextOrHtmlClicked txtOrHtml )
|
||||
public void showTextOrHtmlThen( int action )
|
||||
{
|
||||
m_delegate.showTextOrHtmlThen( txtOrHtml );
|
||||
m_delegate.showTextOrHtmlThen( action );
|
||||
}
|
||||
|
||||
protected void doSyncMenuitem()
|
||||
{
|
||||
m_delegate.doSyncMenuitem();
|
||||
}
|
||||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
public void dlgButtonClicked( int id, int which )
|
||||
{
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,9 +25,13 @@ import android.app.Dialog;
|
|||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
||||
public class XWListActivity extends ListActivity {
|
||||
public class XWListActivity extends ListActivity
|
||||
implements DlgDelegate.DlgClickNotify {
|
||||
|
||||
private DlgDelegate m_delegate;
|
||||
|
||||
@Override
|
||||
|
@ -35,7 +39,7 @@ public class XWListActivity extends ListActivity {
|
|||
{
|
||||
Utils.logf( "%s.onCreate(this=%H)", getClass().getName(), this );
|
||||
super.onCreate( savedInstanceState );
|
||||
m_delegate = new DlgDelegate( this );
|
||||
m_delegate = new DlgDelegate( this, this, savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +80,13 @@ public class XWListActivity extends ListActivity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
super.onSaveInstanceState( outState );
|
||||
m_delegate.onSaveInstanceState( outState );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog( final int id )
|
||||
{
|
||||
|
@ -84,25 +95,9 @@ public class XWListActivity extends ListActivity {
|
|||
if ( null == dialog ) {
|
||||
dialog = super.onCreateDialog( id );
|
||||
}
|
||||
if ( null != dialog ) {
|
||||
DialogInterface.OnDismissListener lstnr =
|
||||
new DialogInterface.OnDismissListener() {
|
||||
public void onDismiss( DialogInterface di ) {
|
||||
Utils.logf( "%s.onDismiss() called",
|
||||
getClass().getName() );
|
||||
removeDialog( id );
|
||||
}
|
||||
};
|
||||
dialog.setOnDismissListener( lstnr );
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
protected void setRemoveOnDismiss( Dialog dialog, int id )
|
||||
{
|
||||
m_delegate.setRemoveOnDismiss( dialog, id );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialog( int id, Dialog dialog )
|
||||
{
|
||||
|
@ -117,14 +112,14 @@ public class XWListActivity extends ListActivity {
|
|||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey, null );
|
||||
m_delegate.showNotAgainDlgThen( msgID, prefsKey );
|
||||
}
|
||||
|
||||
protected void showOKOnlyDialog( int msgID )
|
||||
|
@ -132,16 +127,14 @@ public class XWListActivity extends ListActivity {
|
|||
m_delegate.showOKOnlyDialog( msgID );
|
||||
}
|
||||
|
||||
protected void showConfirmThen( String msg,
|
||||
DialogInterface.OnClickListener action )
|
||||
protected void showConfirmThen( String msg, int action )
|
||||
{
|
||||
m_delegate.showConfirmThen( msg, action );
|
||||
}
|
||||
|
||||
protected void showConfirmThen( int msgID,
|
||||
DialogInterface.OnClickListener action )
|
||||
protected void showConfirmThen( int msg, int action )
|
||||
{
|
||||
showConfirmThen( getString(msgID), action );
|
||||
showConfirmThen( getString(msg), action );
|
||||
}
|
||||
|
||||
protected void doSyncMenuitem()
|
||||
|
@ -149,4 +142,10 @@ public class XWListActivity extends ListActivity {
|
|||
m_delegate.doSyncMenuitem();
|
||||
}
|
||||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
public void dlgButtonClicked( int id, int which )
|
||||
{
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ public class CommonPrefs {
|
|||
public static final int COLOR_NOTILE = 1;
|
||||
public static final int COLOR_FOCUS = 2;
|
||||
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;
|
||||
|
||||
|
@ -101,6 +102,7 @@ public class CommonPrefs {
|
|||
R.string.key_empty,
|
||||
R.string.key_clr_crosshairs,
|
||||
R.string.key_background,
|
||||
R.string.key_clr_bonushint,
|
||||
};
|
||||
for ( int ii = 0; ii < idsOther.length; ++ii ) {
|
||||
otherColors[ii] = prefToColor( context, sp, idsOther[ii] );
|
||||
|
|
|
@ -118,10 +118,18 @@ public class GameSummary {
|
|||
{
|
||||
String result = null;
|
||||
if ( isRelayGame() ) {
|
||||
|
||||
Assert.assertTrue( CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
|
||||
== conType );
|
||||
String fmt = m_context.getString( R.string.summary_fmt_relay );
|
||||
result = String.format( fmt, roomName );
|
||||
int fmtID;
|
||||
if ( null == relayID || 0 == relayID.length() ) {
|
||||
fmtID = R.string.summary_relay_conff;
|
||||
} else if ( anyMissing() ) {
|
||||
fmtID = R.string.summary_relay_waitf;
|
||||
} else {
|
||||
fmtID = R.string.summary_relay_connf;
|
||||
}
|
||||
result = String.format( m_context.getString(fmtID), roomName );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -144,6 +152,18 @@ public class GameSummary {
|
|||
return result;
|
||||
}
|
||||
|
||||
private boolean anyMissing()
|
||||
{
|
||||
boolean missing = false;
|
||||
for ( int ii = 0; ii < nPlayers; ++ii ) {
|
||||
if ( !isLocal(ii) && (0 != ((1 << ii) & missingPlayers) ) ) {
|
||||
missing = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return missing;
|
||||
}
|
||||
|
||||
public int giflags() {
|
||||
int result;
|
||||
if ( null == m_gi ) {
|
||||
|
|
Loading…
Reference in a new issue