mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
Merge branch 'android_branch' into send_in_background
This commit is contained in:
commit
e592ea8559
8 changed files with 201 additions and 142 deletions
|
@ -74,10 +74,12 @@ public class BoardActivity extends XWActivity
|
||||||
private static final int SCREEN_ON_TIME = 10 * 60 * 1000; // 10 mins
|
private static final int SCREEN_ON_TIME = 10 * 60 * 1000; // 10 mins
|
||||||
|
|
||||||
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 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 BoardView m_view;
|
private BoardView m_view;
|
||||||
private int m_jniGamePtr;
|
private int m_jniGamePtr;
|
||||||
|
@ -268,10 +270,7 @@ public class BoardActivity extends XWActivity
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dialog,
|
public void onClick( DialogInterface dialog,
|
||||||
int item ) {
|
int item ) {
|
||||||
GameUtils.launchInviteActivity( BoardActivity.this,
|
showTextOrHtmlThen( LAUNCH_INVITE_ACTION );
|
||||||
m_room,
|
|
||||||
m_gi.dictLang,
|
|
||||||
m_gi.nPlayers );
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
dialog = new AlertDialog.Builder( this )
|
dialog = new AlertDialog.Builder( this )
|
||||||
|
@ -364,6 +363,7 @@ public class BoardActivity extends XWActivity
|
||||||
outState.putInt( DLG_TITLESTR, m_dlgTitle );
|
outState.putInt( DLG_TITLESTR, m_dlgTitle );
|
||||||
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getBundledData( Bundle bundle )
|
private void getBundledData( Bundle bundle )
|
||||||
|
@ -372,6 +372,7 @@ public class BoardActivity extends XWActivity
|
||||||
m_dlgTitleStr = bundle.getString( DLG_TITLESTR );
|
m_dlgTitleStr = bundle.getString( DLG_TITLESTR );
|
||||||
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,15 +567,24 @@ public class BoardActivity extends XWActivity
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
@Override
|
||||||
public void buttonClicked( int id, boolean cancelled )
|
public void dlgButtonClicked( int id, int which )
|
||||||
{
|
{
|
||||||
switch ( id ) {
|
switch ( id ) {
|
||||||
case UNDO_LAST_ACTION:
|
case UNDO_LAST_ACTION:
|
||||||
if ( !cancelled ) {
|
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||||
m_jniThread.handle( JNIThread.JNICmd.CMD_UNDO_LAST );
|
m_jniThread.handle( JNIThread.JNICmd.CMD_UNDO_LAST );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case LAUNCH_INVITE_ACTION:
|
||||||
|
if ( DlgDelegate.DISMISS_BUTTON != which ) {
|
||||||
|
GameUtils.launchInviteActivity( BoardActivity.this,
|
||||||
|
DlgDelegate.TEXT_BTN == which,
|
||||||
|
m_room,
|
||||||
|
m_gi.dictLang,
|
||||||
|
m_gi.nPlayers );
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,11 +551,11 @@ public class DictsActivity extends ExpandableListActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
public void dlgButtonClicked( int id, boolean cancelled )
|
public void dlgButtonClicked( int id, int which )
|
||||||
{
|
{
|
||||||
switch( id ) {
|
switch( id ) {
|
||||||
case DELETE_DICT_ACTION:
|
case DELETE_DICT_ACTION:
|
||||||
if ( !cancelled ) {
|
if ( DialogInterface.BUTTON_POSITIVE == which ) {
|
||||||
deleteDict( m_deleteDict );
|
deleteDict( m_deleteDict );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -45,16 +45,21 @@ public class DlgDelegate {
|
||||||
public static final int DLG_DICTGONE = 6;
|
public static final int DLG_DICTGONE = 6;
|
||||||
public static final int DIALOG_LAST = DLG_DICTGONE;
|
public static final int DIALOG_LAST = DLG_DICTGONE;
|
||||||
|
|
||||||
public static final String MSG = "msg";
|
public static final int TEXT_BTN = AlertDialog.BUTTON_POSITIVE;
|
||||||
public static final String CALLBACK = "callback";
|
public static final int HTML_BTN = AlertDialog.BUTTON_NEGATIVE;
|
||||||
public static final String MSGID = "msgid";
|
public static final int DISMISS_BUTTON = 0;
|
||||||
|
|
||||||
|
private static final String MSG = "msg";
|
||||||
|
private static final String CALLBACK = "callback";
|
||||||
|
private static final String MSGID = "msgid";
|
||||||
|
|
||||||
public interface DlgClickNotify {
|
public interface DlgClickNotify {
|
||||||
void dlgButtonClicked( int id, boolean cancelled );
|
void dlgButtonClicked( int id, int button );
|
||||||
}
|
}
|
||||||
|
|
||||||
private int m_msgID;
|
private int m_msgID;
|
||||||
private int m_cbckID;
|
private int m_cbckID = 0; // if this can be set twice I have a
|
||||||
|
// problem. See asserts below.
|
||||||
private String m_msg;
|
private String m_msg;
|
||||||
private Runnable m_proc = null;
|
private Runnable m_proc = null;
|
||||||
private int m_prefsKey;
|
private int m_prefsKey;
|
||||||
|
@ -126,17 +131,6 @@ public class DlgDelegate {
|
||||||
break;
|
break;
|
||||||
case CONFIRM_THEN:
|
case CONFIRM_THEN:
|
||||||
ad.setMessage( m_msg );
|
ad.setMessage( m_msg );
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick( DialogInterface dlg, int button ) {
|
|
||||||
boolean cancelled =
|
|
||||||
button == DialogInterface.BUTTON_NEGATIVE;
|
|
||||||
m_clickCallback.dlgButtonClicked( m_cbckID, cancelled );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ad.setButton( AlertDialog.BUTTON_POSITIVE,
|
|
||||||
m_activity.getString( R.string.button_ok ), lstnr );
|
|
||||||
ad.setButton( AlertDialog.BUTTON_NEGATIVE,
|
|
||||||
m_activity.getString( R.string.button_ok ), lstnr );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,12 +170,16 @@ public class DlgDelegate {
|
||||||
public void showConfirmThen( String msg, int callbackID )
|
public void showConfirmThen( String msg, int callbackID )
|
||||||
{
|
{
|
||||||
m_msg = msg;
|
m_msg = msg;
|
||||||
|
Assert.assertTrue( 0 != callbackID );
|
||||||
|
Assert.assertTrue( 0 == m_cbckID );
|
||||||
m_cbckID = callbackID;
|
m_cbckID = callbackID;
|
||||||
m_activity.showDialog( CONFIRM_THEN );
|
m_activity.showDialog( CONFIRM_THEN );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showTextOrHtmlThen( int callbackID )
|
public void showTextOrHtmlThen( int callbackID )
|
||||||
{
|
{
|
||||||
|
Assert.assertTrue( 0 != callbackID );
|
||||||
|
Assert.assertTrue( 0 == m_cbckID );
|
||||||
m_cbckID = callbackID;
|
m_cbckID = callbackID;
|
||||||
m_activity.showDialog( TEXT_OR_HTML_THEN );
|
m_activity.showDialog( TEXT_OR_HTML_THEN );
|
||||||
}
|
}
|
||||||
|
@ -275,31 +273,29 @@ public class DlgDelegate {
|
||||||
|
|
||||||
private Dialog createConfirmThenDialog()
|
private Dialog createConfirmThenDialog()
|
||||||
{
|
{
|
||||||
|
DialogInterface.OnClickListener lstnr = mkCallbackClickListener();
|
||||||
|
|
||||||
Dialog dialog = new AlertDialog.Builder( m_activity )
|
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||||
.setTitle( R.string.query_title )
|
.setTitle( R.string.query_title )
|
||||||
.setMessage( "" )
|
.setMessage( "" )
|
||||||
.setPositiveButton( R.string.button_ok, null ) // will change
|
.setPositiveButton( R.string.button_ok, lstnr )
|
||||||
.setNegativeButton( R.string.button_cancel, null )
|
.setNegativeButton( R.string.button_cancel, lstnr )
|
||||||
.create();
|
.create();
|
||||||
return dialog;
|
|
||||||
|
return setCallbackDismissListener( dialog );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dialog createHtmlThenDialog()
|
private Dialog createHtmlThenDialog()
|
||||||
{
|
{
|
||||||
DialogInterface.OnClickListener lstnr =
|
DialogInterface.OnClickListener lstnr = mkCallbackClickListener();
|
||||||
new DialogInterface.OnClickListener() {
|
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||||
public void onClick( DialogInterface dlg, int button ) {
|
|
||||||
boolean cancelled =
|
|
||||||
button == DialogInterface.BUTTON_NEGATIVE;
|
|
||||||
m_clickCallback.dlgButtonClicked( m_cbckID, cancelled );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return new AlertDialog.Builder( m_activity )
|
|
||||||
.setTitle( R.string.query_title )
|
.setTitle( R.string.query_title )
|
||||||
.setMessage( R.string.text_or_html )
|
.setMessage( R.string.text_or_html )
|
||||||
.setPositiveButton( R.string.button_text, lstnr )
|
.setPositiveButton( R.string.button_text, lstnr )
|
||||||
.setNegativeButton( R.string.button_html, lstnr )
|
.setNegativeButton( R.string.button_html, lstnr )
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
|
return setCallbackDismissListener( dialog );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dialog createDictGoneDialog()
|
private Dialog createDictGoneDialog()
|
||||||
|
@ -319,4 +315,31 @@ public class DlgDelegate {
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DialogInterface.OnClickListener mkCallbackClickListener()
|
||||||
|
{
|
||||||
|
DialogInterface.OnClickListener lstnr =
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick( DialogInterface dlg, int button ) {
|
||||||
|
Assert.assertTrue( 0 != m_cbckID );
|
||||||
|
m_clickCallback.dlgButtonClicked( m_cbckID, button );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return lstnr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dialog setCallbackDismissListener( Dialog dialog )
|
||||||
|
{
|
||||||
|
DialogInterface.OnDismissListener lstnr =
|
||||||
|
new DialogInterface.OnDismissListener() {
|
||||||
|
public void onDismiss( DialogInterface di ) {
|
||||||
|
Assert.assertTrue( 0 != m_cbckID );
|
||||||
|
m_clickCallback.dlgButtonClicked( m_cbckID,
|
||||||
|
DISMISS_BUTTON );
|
||||||
|
m_cbckID = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
dialog.setOnDismissListener( lstnr );
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ public class GameConfig extends XWActivity
|
||||||
private static final int CONFIRM_CHANGE_PLAY = PLAYER_EDIT + 3;
|
private static final int CONFIRM_CHANGE_PLAY = PLAYER_EDIT + 3;
|
||||||
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 CheckBox m_joinPublicCheck;
|
private CheckBox m_joinPublicCheck;
|
||||||
private CheckBox m_gameLockedCheck;
|
private CheckBox m_gameLockedCheck;
|
||||||
private boolean m_isLocked;
|
private boolean m_isLocked;
|
||||||
|
@ -358,6 +360,7 @@ public class GameConfig extends XWActivity
|
||||||
public void onCreate( Bundle savedInstanceState )
|
public void onCreate( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
getBundledData( savedInstanceState );
|
||||||
|
|
||||||
// 1.5 doesn't have SDK_INT. So parse the string version.
|
// 1.5 doesn't have SDK_INT. So parse the string version.
|
||||||
// int sdk_int = 0;
|
// int sdk_int = 0;
|
||||||
|
@ -391,12 +394,43 @@ public class GameConfig extends XWActivity
|
||||||
setTitle();
|
setTitle();
|
||||||
} // onCreate
|
} // onCreate
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
super.onStart();
|
||||||
|
loadGame();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
loadGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause()
|
||||||
|
{
|
||||||
|
if ( null != m_gameLock ) {
|
||||||
|
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 );
|
m_giOrig = new CurGameInfo( this );
|
||||||
|
|
||||||
// Lock in case we're going to config. We *could* re-get the
|
// Lock in case we're going to config. We *could* re-get the
|
||||||
// lock once the user decides to make changes. PENDING.
|
// lock once the user decides to make changes. PENDING.
|
||||||
m_gameLock = new GameUtils.GameLock( m_rowid, true ).lock();
|
m_gameLock = new GameUtils.GameLock( m_rowid, true ).lock();
|
||||||
|
@ -481,16 +515,14 @@ public class GameConfig extends XWActivity
|
||||||
check.setOnCheckedChangeListener( lstnr );
|
check.setOnCheckedChangeListener( lstnr );
|
||||||
Utils.setChecked( this, R.id.use_timer, m_gi.timerEnabled );
|
Utils.setChecked( this, R.id.use_timer, m_gi.timerEnabled );
|
||||||
}
|
}
|
||||||
} // onResume
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause()
|
|
||||||
{
|
|
||||||
if ( null != m_gameLock ) {
|
|
||||||
m_gameLock.unlock();
|
|
||||||
m_gameLock = null;
|
|
||||||
}
|
}
|
||||||
super.onPause();
|
} // loadGame
|
||||||
|
|
||||||
|
private void getBundledData( Bundle bundle )
|
||||||
|
{
|
||||||
|
if ( null != bundle ) {
|
||||||
|
m_whichPlayer = bundle.getInt( WHICH_PLAYER );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteCallback interface
|
// DeleteCallback interface
|
||||||
|
|
|
@ -404,9 +404,10 @@ public class GamesList extends XWListActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
public void dlgButtonClicked( int id, boolean cancelled )
|
@Override
|
||||||
|
public void dlgButtonClicked( int id, int which )
|
||||||
{
|
{
|
||||||
if ( !cancelled ) {
|
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||||
switch( id ) {
|
switch( id ) {
|
||||||
case NEW_NET_GAME_ACTION:
|
case NEW_NET_GAME_ACTION:
|
||||||
long rowid = GameUtils.makeNewNetGame( this, m_netLaunchInfo );
|
long rowid = GameUtils.makeNewNetGame( this, m_netLaunchInfo );
|
||||||
|
|
|
@ -87,11 +87,15 @@ public class NewGameActivity extends XWActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dlgButtonClicked( int id, boolean cancelled )
|
// DlgDelegate.DlgClickNotify interface
|
||||||
|
@Override
|
||||||
|
public void dlgButtonClicked( int id, int which )
|
||||||
{
|
{
|
||||||
switch( id ) {
|
switch( id ) {
|
||||||
case NEW_GAME_ACTION:
|
case NEW_GAME_ACTION:
|
||||||
makeNewGame( true, true, !cancelled );
|
if ( DlgDelegate.DISMISS_BUTTON != which ) {
|
||||||
|
makeNewGame( true, true, DlgDelegate.TEXT_BTN == which );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class XWActivity extends Activity
|
||||||
}
|
}
|
||||||
|
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
public void dlgButtonClicked( int id, boolean cancelled )
|
public void dlgButtonClicked( int id, int which )
|
||||||
{
|
{
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,17 +95,6 @@ public class XWListActivity extends ListActivity
|
||||||
if ( null == dialog ) {
|
if ( null == dialog ) {
|
||||||
dialog = super.onCreateDialog( id );
|
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;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +143,7 @@ public class XWListActivity extends ListActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
public void dlgButtonClicked( int id, boolean cancelled )
|
public void dlgButtonClicked( int id, int which )
|
||||||
{
|
{
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue