mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
On "configure first" BT newgame button, create the game then launch
the GameConfig activity. If the user exits other than with "play game", delete it so user never sees it. Otherwise launch it. Next step is to detect a BT host that's missing clients and offer to invite them.
This commit is contained in:
parent
606e733b19
commit
d8ee493f1b
7 changed files with 50 additions and 13 deletions
|
@ -58,7 +58,6 @@ import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
|||
public class BoardActivity extends XWActivity
|
||||
implements TransportProcs.TPMsgHandler, View.OnClickListener {
|
||||
|
||||
public static final String INTENT_KEY_ROWID = "rowid";
|
||||
public static final String INTENT_KEY_CHAT = "chat";
|
||||
|
||||
private static final int DLG_OKONLY = DlgDelegate.DIALOG_LAST + 1;
|
||||
|
@ -454,7 +453,7 @@ public class BoardActivity extends XWActivity
|
|||
m_volKeysZoom = CommonPrefs.getVolKeysZoom( this );
|
||||
|
||||
Intent intent = getIntent();
|
||||
m_rowid = intent.getLongExtra( INTENT_KEY_ROWID, -1 );
|
||||
m_rowid = intent.getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
m_haveInvited = intent.getBooleanExtra( GameUtils.INVITED, false );
|
||||
|
||||
setBackgroundColor();
|
||||
|
@ -1596,7 +1595,7 @@ public class BoardActivity extends XWActivity
|
|||
private void startChatActivity()
|
||||
{
|
||||
Intent intent = new Intent( this, ChatActivity.class );
|
||||
intent.putExtra( BoardActivity.INTENT_KEY_ROWID, m_rowid );
|
||||
intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_rowid );
|
||||
startActivityForResult( intent, CHAT_REQUEST );
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ChatActivity extends XWActivity implements View.OnClickListener {
|
|||
|
||||
setContentView( R.layout.chat );
|
||||
|
||||
m_rowid = getIntent().getLongExtra( BoardActivity.INTENT_KEY_ROWID, -1 );
|
||||
m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
|
||||
DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( this, m_rowid );
|
||||
if ( null != pairs ) {
|
||||
|
|
|
@ -644,6 +644,13 @@ public class DBUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static void deleteGame( Context context, long rowid )
|
||||
{
|
||||
GameUtils.GameLock lock = new GameUtils.GameLock( rowid, true ).lock();
|
||||
deleteGame( context, lock );
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
public static void deleteGame( Context context, GameUtils.GameLock lock )
|
||||
{
|
||||
Assert.assertTrue( lock.canWrite() );
|
||||
|
|
|
@ -88,6 +88,7 @@ public class GameConfig extends XWActivity
|
|||
private Spinner m_roomChoose;
|
||||
// private Button m_configureButton;
|
||||
private long m_rowid;
|
||||
private boolean m_forResult;
|
||||
private CurGameInfo m_gi;
|
||||
private CurGameInfo m_giOrig;
|
||||
private GameUtils.GameLock m_gameLock;
|
||||
|
@ -392,7 +393,9 @@ public class GameConfig extends XWActivity
|
|||
m_cp = CommonPrefs.get( this );
|
||||
|
||||
Intent intent = getIntent();
|
||||
m_rowid = intent.getLongExtra( BoardActivity.INTENT_KEY_ROWID, -1 );
|
||||
m_rowid = intent.getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
m_forResult = intent.getBooleanExtra( GameUtils.INTENT_FORRESULT_ROWID,
|
||||
false );
|
||||
|
||||
setContentView(R.layout.game_config);
|
||||
|
||||
|
@ -601,7 +604,11 @@ public class GameConfig extends XWActivity
|
|||
// from here if there's no confirmation needed, or launch
|
||||
// a new dialog whose OK button does the same thing.
|
||||
saveChanges();
|
||||
if ( !m_gameStarted ) { // no confirm needed
|
||||
if ( m_forResult ) {
|
||||
applyChanges( true );
|
||||
setResult( Activity.RESULT_OK, null );
|
||||
finish();
|
||||
} else if ( !m_gameStarted ) { // no confirm needed
|
||||
applyChanges( true );
|
||||
launchGame();
|
||||
} else if ( m_giOrig.changesMatter(m_gi)
|
||||
|
|
|
@ -48,6 +48,8 @@ import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
|||
public class GameUtils {
|
||||
|
||||
public static final String INVITED = "invited";
|
||||
public static final String INTENT_KEY_ROWID = "rowid";
|
||||
public static final String INTENT_FORRESULT_ROWID = "forresult";
|
||||
private static Random s_random = new Random();
|
||||
|
||||
// Implements read-locks and write-locks per game. A read lock is
|
||||
|
@ -575,7 +577,7 @@ public class GameUtils {
|
|||
{
|
||||
Intent intent = new Intent( activity, BoardActivity.class );
|
||||
intent.setAction( Intent.ACTION_EDIT );
|
||||
intent.putExtra( BoardActivity.INTENT_KEY_ROWID, rowid );
|
||||
intent.putExtra( INTENT_KEY_ROWID, rowid );
|
||||
if ( invited ) {
|
||||
intent.putExtra( INVITED, true );
|
||||
}
|
||||
|
@ -785,7 +787,7 @@ public class GameUtils {
|
|||
{
|
||||
Intent intent = new Intent( activity, clazz );
|
||||
intent.setAction( Intent.ACTION_EDIT );
|
||||
intent.putExtra( BoardActivity.INTENT_KEY_ROWID, rowid );
|
||||
intent.putExtra( INTENT_KEY_ROWID, rowid );
|
||||
activity.startActivity( intent );
|
||||
}
|
||||
|
||||
|
|
|
@ -49,12 +49,14 @@ public class NewGameActivity extends XWActivity {
|
|||
private static final int NEW_GAME_ACTION = 1;
|
||||
private static final String SAVE_DEVNAMES = "DEVNAMES";
|
||||
private static final int PICK_BTDEV_DLG = DlgDelegate.DIALOG_LAST + 1;
|
||||
private static final int CONFIG_BT = 1;
|
||||
|
||||
private boolean m_showsOn;
|
||||
private Handler m_handler = null;
|
||||
private int m_chosen;
|
||||
private String[] m_btDevNames;
|
||||
private int m_lang = 0;
|
||||
private long m_btRowID = -1;
|
||||
|
||||
@Override
|
||||
protected void onCreate( Bundle savedInstanceState )
|
||||
|
@ -203,6 +205,22 @@ public class NewGameActivity extends XWActivity {
|
|||
checkEnableBT( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult( int requestCode, int resultCode,
|
||||
Intent data )
|
||||
{
|
||||
if ( CONFIG_BT == requestCode ) {
|
||||
if ( Activity.RESULT_CANCELED == resultCode ) {
|
||||
DBUtils.deleteGame( this, m_btRowID );
|
||||
} else {
|
||||
// We'll leave it up to BoardActivity to detect that
|
||||
// it's not had any remote connections yet.
|
||||
GameUtils.launchGame( this, m_btRowID );
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
|
@ -316,10 +334,14 @@ public class NewGameActivity extends XWActivity {
|
|||
{
|
||||
int gameID = GameUtils.newGameID();
|
||||
if ( !useDefaults ) {
|
||||
DbgUtils.showf( this, "For debugging only..." );
|
||||
GameUtils.makeNewBTGame( NewGameActivity.this, gameID,
|
||||
null, m_lang, 2, 1 );
|
||||
finish();
|
||||
m_btRowID = GameUtils.makeNewBTGame( NewGameActivity.this,
|
||||
gameID, null, m_lang,
|
||||
2, 1 );
|
||||
Intent intent = new Intent( this, GameConfig.class );
|
||||
intent.setAction( Intent.ACTION_EDIT );
|
||||
intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_btRowID );
|
||||
intent.putExtra( GameUtils.INTENT_FORRESULT_ROWID, true );
|
||||
startActivityForResult( intent, CONFIG_BT );
|
||||
} else if ( null == m_btDevNames || 0 == m_btDevNames.length ) {
|
||||
startProgress( R.string.scan_progress );
|
||||
BTService.rescan( this );
|
||||
|
|
|
@ -53,7 +53,7 @@ public class RelayGameActivity extends XWActivity
|
|||
|
||||
setContentView( R.layout.relay_game_config );
|
||||
|
||||
m_rowid = getIntent().getLongExtra( BoardActivity.INTENT_KEY_ROWID, -1 );
|
||||
m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
|
||||
m_playButton = (Button)findViewById( R.id.play_button );
|
||||
m_playButton.setOnClickListener( this );
|
||||
|
|
Loading…
Reference in a new issue