mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
add buttons that create new games, bypassing the NewGame activity for
a simpler experience.
This commit is contained in:
parent
d848c17d03
commit
2465017e46
11 changed files with 436 additions and 303 deletions
File diff suppressed because it is too large
Load diff
|
@ -12,4 +12,16 @@
|
|||
android:layout_weight="1"
|
||||
android:drawSelectorOnTop="false"
|
||||
/>
|
||||
|
||||
<Button android:id="@+id/button_newgame_solo"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/new_game"
|
||||
/>
|
||||
<Button android:id="@+id/button_newgame_multi"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/new_game_networked"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -1983,11 +1983,9 @@
|
|||
<!-- -->
|
||||
<string name="connstat_noreceipt">No messages have been received.</string>
|
||||
<!-- -->
|
||||
<string name="connstat_relay">internet/relay</string>
|
||||
<string name="connstat_relay">Internet/relay</string>
|
||||
<!-- -->
|
||||
<string name="connstat_sms">sms/texting</string>
|
||||
<!-- -->
|
||||
<string name="connstat_bt">bluetooth</string>
|
||||
<string name="connstat_sms">SMS/texting</string>
|
||||
<!-- -->
|
||||
<string name="enable_sms">Allow games via SMS</string>
|
||||
<!-- -->
|
||||
|
@ -2288,4 +2286,16 @@
|
|||
<!-- Title of preference in which you select which addressing
|
||||
modes network games will use to communicate -->
|
||||
<string name="title_addrs_pref">Communicate via</string>
|
||||
|
||||
<string name="new_game">New Game</string>
|
||||
<string name="new_game_networked">New Networked Game </string>
|
||||
|
||||
<string name="new_game_message">Would you like to create this game
|
||||
using default settings?\n\nOr would you like to configure it
|
||||
first?</string>
|
||||
<string name="new_game_message_net">(You will have a chance to
|
||||
invite other players after it is created.)</string>
|
||||
|
||||
<string name="use_defaults">Use defaults</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1708,11 +1708,9 @@
|
|||
<!-- -->
|
||||
<string name="connstat_noreceipt">On segassem evah neeb deviecer.</string>
|
||||
<!-- -->
|
||||
<string name="connstat_relay">yaler/tenretni</string>
|
||||
<string name="connstat_relay">Yaler/tenretni</string>
|
||||
<!-- -->
|
||||
<string name="connstat_sms">gnitxet/sms</string>
|
||||
<!-- -->
|
||||
<string name="connstat_bt">htooteulb</string>
|
||||
<string name="connstat_sms">GNItxet/sms</string>
|
||||
<!-- -->
|
||||
<string name="enable_sms">Wolla semag aiv SMS</string>
|
||||
<!-- -->
|
||||
|
@ -1951,4 +1949,12 @@
|
|||
<!-- Title of preference in which you select which addressing
|
||||
modes network games will use to communicate -->
|
||||
<string name="title_addrs_pref">Etacinummoc aiv</string>
|
||||
<string name="new_game">Wen Emag</string>
|
||||
<string name="new_game_networked">Wen Dekrowten Emag </string>
|
||||
<string name="new_game_message">Dluow uoy ekil ot etaerc siht emag
|
||||
gnisu tluafed ?sgnittes\n\nRo dluow uoy ekil ot erugifnoc ti
|
||||
?tsrif</string>
|
||||
<string name="new_game_message_net">uOy( lliw evah a ecnahc ot
|
||||
etivni rehto sreyalp retfa ti si detaerc.)</string>
|
||||
<string name="use_defaults">Esu stluafed</string>
|
||||
</resources>
|
||||
|
|
|
@ -1712,8 +1712,6 @@
|
|||
<!-- -->
|
||||
<string name="connstat_sms">SMS/TEXTING</string>
|
||||
<!-- -->
|
||||
<string name="connstat_bt">BLUETOOTH</string>
|
||||
<!-- -->
|
||||
<string name="enable_sms">ALLOW GAMES VIA SMS</string>
|
||||
<!-- -->
|
||||
<string name="enable_sms_summary">ONLY IF YOU HAVE UNLIMITED TEXTING!</string>
|
||||
|
@ -1951,4 +1949,12 @@
|
|||
<!-- Title of preference in which you select which addressing
|
||||
modes network games will use to communicate -->
|
||||
<string name="title_addrs_pref">COMMUNICATE VIA</string>
|
||||
<string name="new_game">NEW GAME</string>
|
||||
<string name="new_game_networked">NEW NETWORKED GAME </string>
|
||||
<string name="new_game_message">WOULD YOU LIKE TO CREATE THIS GAME
|
||||
USING DEFAULT SETTINGS?\n\nOR WOULD YOU LIKE TO CONFIGURE IT
|
||||
FIRST?</string>
|
||||
<string name="new_game_message_net">(YOU WILL HAVE A CHANCE TO
|
||||
INVITE OTHER PLAYERS AFTER IT IS CREATED.)</string>
|
||||
<string name="use_defaults">USE DEFAULTS</string>
|
||||
</resources>
|
||||
|
|
|
@ -460,7 +460,7 @@ public class ConnStatusHandler {
|
|||
resID = R.string.connstat_sms;
|
||||
break;
|
||||
case COMMS_CONN_BT:
|
||||
resID = R.string.connstat_bt;
|
||||
resID = R.string.invite_choice_bt;
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
|
|
|
@ -68,4 +68,5 @@ public enum DlgID {
|
|||
, PICK_TILE_REQUESTTRAY_BLK
|
||||
, DLG_USEDICT
|
||||
, DLG_GETDICT
|
||||
, GAMES_LIST_NEWGAME
|
||||
}
|
||||
|
|
|
@ -650,7 +650,9 @@ public class GameConfigDelegate extends DelegateBase
|
|||
saveChanges();
|
||||
if ( m_forResult ) {
|
||||
applyChanges( true );
|
||||
setResult( Activity.RESULT_OK, null );
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_rowid );
|
||||
setResult( Activity.RESULT_OK, intent );
|
||||
finish();
|
||||
} else if ( !m_gameStarted ) { // no confirm needed
|
||||
applyChanges( true );
|
||||
|
|
|
@ -463,6 +463,15 @@ public class GameUtils {
|
|||
nli.gameID, false );
|
||||
}
|
||||
|
||||
public static long makeNewMultiGame( Context context, String room, String inviteID )
|
||||
{
|
||||
int[] lang = {0};
|
||||
String[] dict = {null};
|
||||
CommsAddrRec addr = new CommsAddrRec( XWPrefs.getAddrTypes( context ) );
|
||||
return makeNewMultiGame( context, null, DBUtils.GROUPID_UNSPEC, addr,
|
||||
lang, dict, 2, 1, inviteID, 0, true );
|
||||
}
|
||||
|
||||
private static long makeNewMultiGame( Context context, long groupID,
|
||||
CommsAddrRec addr,
|
||||
int[] lang, String[] dict,
|
||||
|
|
|
@ -71,6 +71,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private static final String SAVE_DICTNAMES = "SAVE_DICTNAMES";
|
||||
|
||||
private static final int REQUEST_LANG = 1;
|
||||
private static final int CONFIG_GAME = 2;
|
||||
|
||||
private static final String RELAYIDS_EXTRA = "relayids";
|
||||
private static final String ROWID_EXTRA = "rowid";
|
||||
|
@ -563,6 +564,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private Set<Long> m_selGames;
|
||||
private Set<Long> m_selGroupIDs;
|
||||
private String m_origTitle;
|
||||
private boolean m_nextIsSolo;
|
||||
|
||||
public GamesListDelegate( ListDelegator delegator, Bundle sis )
|
||||
{
|
||||
|
@ -788,6 +790,26 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
});
|
||||
break;
|
||||
|
||||
case GAMES_LIST_NEWGAME:
|
||||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
makeThenLaunchOrConfigure( true );
|
||||
}
|
||||
};
|
||||
lstnr2 = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
makeThenLaunchOrConfigure( false );
|
||||
}
|
||||
};
|
||||
|
||||
dialog = makeAlertBuilder()
|
||||
.setTitle( R.string.new_game )
|
||||
.setMessage( "" ) // must have a message to change it later
|
||||
.setPositiveButton( R.string.newgame_configure_first, lstnr )
|
||||
.setNegativeButton( R.string.use_defaults, lstnr2 )
|
||||
.create();
|
||||
break;
|
||||
|
||||
default:
|
||||
dialog = super.onCreateDialog( id );
|
||||
break;
|
||||
|
@ -795,11 +817,22 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
return dialog;
|
||||
} // onCreateDialog
|
||||
|
||||
@Override
|
||||
protected void prepareDialog( DlgID dlgID, Dialog dialog )
|
||||
{
|
||||
if ( DlgID.CHANGE_GROUP == dlgID ) {
|
||||
DbgUtils.logf( "GamesListDelegate.prepareDialog() called" );
|
||||
switch( dlgID ) {
|
||||
case CHANGE_GROUP:
|
||||
((AlertDialog)dialog).getButton( AlertDialog.BUTTON_POSITIVE )
|
||||
.setEnabled( false );
|
||||
break;
|
||||
case GAMES_LIST_NEWGAME:
|
||||
String msg = getString( R.string.new_game_message );
|
||||
if ( !m_nextIsSolo ) {
|
||||
msg += "\n\n" + getString( R.string.new_game_message_net );
|
||||
}
|
||||
((AlertDialog)dialog).setMessage( msg );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -826,6 +859,21 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
mkListAdapter();
|
||||
getListView().setOnItemLongClickListener( this );
|
||||
|
||||
Button button = (Button)findViewById( R.id.button_newgame_solo );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
public void onClick( View view ) {
|
||||
m_nextIsSolo = true;
|
||||
showDialog( DlgID.GAMES_LIST_NEWGAME );
|
||||
}
|
||||
} );
|
||||
button = (Button)findViewById( R.id.button_newgame_multi );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
public void onClick( View view ) {
|
||||
m_nextIsSolo = false;
|
||||
showDialog( DlgID.GAMES_LIST_NEWGAME );
|
||||
}
|
||||
} );
|
||||
|
||||
NetUtils.informOfDeaths( m_activity );
|
||||
|
||||
tryStartsFromIntent( getIntent() );
|
||||
|
@ -1103,11 +1151,18 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
@Override
|
||||
protected void onActivityResult( int requestCode, int resultCode, Intent data )
|
||||
{
|
||||
if ( Activity.RESULT_CANCELED != resultCode
|
||||
&& REQUEST_LANG == requestCode ) {
|
||||
DbgUtils.logf( "lang need met" );
|
||||
if ( checkWarnNoDict( m_missingDictRowId ) ) {
|
||||
launchGameIf();
|
||||
if ( Activity.RESULT_CANCELED != resultCode ) {
|
||||
switch ( requestCode ) {
|
||||
case REQUEST_LANG:
|
||||
DbgUtils.logf( "lang need met" );
|
||||
if ( checkWarnNoDict( m_missingDictRowId ) ) {
|
||||
launchGameIf();
|
||||
}
|
||||
break;
|
||||
case CONFIG_GAME:
|
||||
long rowID = data.getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
GameUtils.launchGame( m_activity, rowID );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1933,6 +1988,29 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
// return adapter;
|
||||
}
|
||||
|
||||
private void makeThenLaunchOrConfigure( boolean doConfigure )
|
||||
{
|
||||
long rowID;
|
||||
long groupID = DBUtils.GROUPID_UNSPEC;
|
||||
if ( m_nextIsSolo ) {
|
||||
rowID = GameUtils.saveNew( m_activity,
|
||||
new CurGameInfo( m_activity ),
|
||||
groupID );
|
||||
} else {
|
||||
String room = GameUtils.makeRandomID();
|
||||
String inviteID = GameUtils.makeRandomID();
|
||||
rowID = GameUtils.makeNewMultiGame( m_activity, room, inviteID );
|
||||
}
|
||||
|
||||
if ( doConfigure ) {
|
||||
// configure it
|
||||
GameConfigDelegate.editForResult( m_activity, CONFIG_GAME, rowID );
|
||||
} else {
|
||||
// launch it
|
||||
GameUtils.launchGame( m_activity, rowID, !m_nextIsSolo );
|
||||
}
|
||||
}
|
||||
|
||||
public static void boardDestroyed( long rowid )
|
||||
{
|
||||
if ( null != s_self ) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CommsAddrRec {
|
|||
case COMMS_CONN_RELAY:
|
||||
id = R.string.connstat_relay; break;
|
||||
case COMMS_CONN_BT:
|
||||
id = R.string.connstat_bt; break;
|
||||
id = R.string.invite_choice_bt; break;
|
||||
case COMMS_CONN_SMS:
|
||||
id = R.string.connstat_sms; break;
|
||||
}
|
||||
|
@ -123,6 +123,11 @@ public class CommsAddrRec {
|
|||
conTypes = new CommsConnTypeSet();
|
||||
}
|
||||
|
||||
public CommsAddrRec( CommsConnTypeSet types )
|
||||
{
|
||||
conTypes = types;
|
||||
}
|
||||
|
||||
public CommsAddrRec( String host, int port )
|
||||
{
|
||||
this( CommsConnType.COMMS_CONN_RELAY );
|
||||
|
|
Loading…
Reference in a new issue