mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
use same (new) dialog for solo games
This commit is contained in:
parent
4d1e380616
commit
3350ca19b7
4 changed files with 55 additions and 68 deletions
|
@ -867,16 +867,12 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
case GAMES_LIST_NEWGAME:
|
case GAMES_LIST_NEWGAME:
|
||||||
boolean solo = (Boolean)params[0];
|
boolean solo = (Boolean)params[0];
|
||||||
if ( solo ) {
|
dialog = mkNewNetGameDialog( solo );
|
||||||
dialog = mkNewSoloGameDialog();
|
if ( !solo && XwJNI.hasKnownPlayers() ) {
|
||||||
} else {
|
makeNotAgainBuilder( R.string.not_again_quicknetgame,
|
||||||
dialog = mkNewNetGameDialog();
|
R.string.key_na_quicknetgame )
|
||||||
if ( XwJNI.hasKnownPlayers() ) {
|
.setTitle( R.string.new_feature_title )
|
||||||
makeNotAgainBuilder( R.string.not_again_quicknetgame,
|
.show();
|
||||||
R.string.key_na_quicknetgame )
|
|
||||||
.setTitle( R.string.new_feature_title )
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -918,49 +914,16 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
return dialog;
|
return dialog;
|
||||||
} // makeDialog
|
} // makeDialog
|
||||||
|
|
||||||
private Dialog mkNewSoloGameDialog()
|
private Dialog mkNewNetGameDialog( final boolean standalone )
|
||||||
{
|
|
||||||
final LinearLayout view = (LinearLayout)
|
|
||||||
LocUtils.inflate( m_activity, R.layout.msg_label_and_edit );
|
|
||||||
final EditWClear edit = (EditWClear)view.findViewById( R.id.edit );
|
|
||||||
edit.setText( GameUtils.makeDefaultName( m_activity ) );
|
|
||||||
|
|
||||||
String msg = getString( R.string.new_game_message );
|
|
||||||
TextView tmpEdit = (TextView)view.findViewById( R.id.msg );
|
|
||||||
tmpEdit.setText( msg );
|
|
||||||
|
|
||||||
OnClickListener lstnr = new OnClickListener() {
|
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
|
||||||
String name = edit.getText().toString();
|
|
||||||
curThis().makeThenLaunchOrConfigure( name, true, false );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlertDialog.Builder ab = makeAlertBuilder()
|
|
||||||
.setView( view )
|
|
||||||
.setTitle( R.string.new_game )
|
|
||||||
.setIcon( R.drawable.ic_sologame )
|
|
||||||
.setPositiveButton( R.string.newgame_configure_first, lstnr );
|
|
||||||
OnClickListener lstnr2 = new OnClickListener() {
|
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
|
||||||
String name = edit.getText().toString();
|
|
||||||
curThis().makeThenLaunchOrConfigure( name, false, false );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ab.setNegativeButton( R.string.use_defaults, lstnr2 );
|
|
||||||
return ab.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dialog mkNewNetGameDialog()
|
|
||||||
{
|
{
|
||||||
// String[] names = XwJNI.kplr_getPlayers();
|
// String[] names = XwJNI.kplr_getPlayers();
|
||||||
final NewWithKnowns view = (NewWithKnowns)
|
final NewWithKnowns view = (NewWithKnowns)
|
||||||
LocUtils.inflate( m_activity, R.layout.new_game_with_knowns );
|
LocUtils.inflate( m_activity, R.layout.new_game_with_knowns );
|
||||||
view.setGameName( GameUtils.makeDefaultName( m_activity ) );
|
view.configure( standalone, GameUtils.makeDefaultName( m_activity ) );
|
||||||
AlertDialog.Builder ab = makeAlertBuilder()
|
AlertDialog.Builder ab = makeAlertBuilder()
|
||||||
.setView( view )
|
.setView( view )
|
||||||
.setTitle( R.string.new_game_networked )
|
.setTitle( standalone ? R.string.new_game : R.string.new_game_networked )
|
||||||
.setIcon( R.drawable.ic_multigame )
|
.setIcon( standalone ? R.drawable.ic_sologame: R.drawable.ic_multigame )
|
||||||
.setPositiveButton( android.R.string.cancel, new OnClickListener() {
|
.setPositiveButton( android.R.string.cancel, new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
|
@ -968,20 +931,21 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
@Override
|
@Override
|
||||||
public void onUseKnown( String knownName, String gameName )
|
public void onUseKnown( String knownName, String gameName )
|
||||||
{
|
{
|
||||||
|
Assert.assertTrueNR( !standalone );
|
||||||
CommsAddrRec addr = XwJNI.kplr_getAddr( knownName );
|
CommsAddrRec addr = XwJNI.kplr_getAddr( knownName );
|
||||||
if ( null != addr ) {
|
if ( null != addr ) {
|
||||||
launchLikeRematch( addr, gameName );
|
launchLikeRematch( addr, gameName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onInviteLater( String gameName )
|
public void onStartGame( String gameName, boolean solo,
|
||||||
|
boolean configFirst )
|
||||||
{
|
{
|
||||||
curThis().makeThenLaunchOrConfigure( gameName, false, false );
|
Assert.assertTrueNR( solo == standalone );
|
||||||
}
|
Assert.assertTrueNR( solo == m_mySIS.nextIsSolo );
|
||||||
@Override
|
curThis().makeThenLaunchOrConfigure( gameName,
|
||||||
public void onConfigureFirst( String gameName )
|
configFirst,
|
||||||
{
|
false );
|
||||||
curThis().makeThenLaunchOrConfigure( gameName, true, false );
|
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,14 @@ public class NewWithKnowns extends LinearLayout
|
||||||
|
|
||||||
public interface ButtonCallbacks {
|
public interface ButtonCallbacks {
|
||||||
void onUseKnown( String knownName, String gameName );
|
void onUseKnown( String knownName, String gameName );
|
||||||
void onInviteLater( String gameName );
|
void onStartGame( String gameName, boolean solo, boolean configFirst );
|
||||||
void onConfigureFirst( String gameName );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ButtonChangeListener mListener;
|
private ButtonChangeListener mListener;
|
||||||
private String mCurKnown;
|
private String mCurKnown;
|
||||||
private int mCurRadio;
|
private int mCurRadio;
|
||||||
private Spinner mNamesSpinner;
|
private Spinner mNamesSpinner;
|
||||||
|
private boolean mStandalone;
|
||||||
|
|
||||||
public NewWithKnowns( Context cx, AttributeSet as )
|
public NewWithKnowns( Context cx, AttributeSet as )
|
||||||
{
|
{
|
||||||
|
@ -66,9 +66,11 @@ public class NewWithKnowns extends LinearLayout
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGameName( String gameName )
|
void configure( boolean standalone, String gameName )
|
||||||
{
|
{
|
||||||
boolean hasKnowns = XwJNI.hasKnownPlayers();
|
mStandalone = standalone;
|
||||||
|
boolean hasKnowns = !standalone && XwJNI.hasKnownPlayers();
|
||||||
|
int[] toHide;
|
||||||
if ( hasKnowns ) {
|
if ( hasKnowns ) {
|
||||||
String[] knowns = XwJNI.kplr_getPlayers();
|
String[] knowns = XwJNI.kplr_getPlayers();
|
||||||
mCurKnown = DBUtils.getStringFor( getContext(), KP_NAME_KEY,
|
mCurKnown = DBUtils.getStringFor( getContext(), KP_NAME_KEY,
|
||||||
|
@ -89,11 +91,16 @@ public class NewWithKnowns extends LinearLayout
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
toHide = new int[]{ R.id.radio_default, R.id.choose_expl_default,
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
int[] toHide = { R.id.radio_known, R.id.names, R.id.expl_known };
|
toHide = new int[]{ R.id.radio_known, R.id.names, R.id.expl_known,
|
||||||
for ( int resID : toHide ) {
|
R.id.radio_unknown, R.id.choose_expl_new,
|
||||||
findViewById(resID).setVisibility( View.GONE );
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( int resID : toHide ) {
|
||||||
|
findViewById(resID).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditWClear et = (EditWClear)findViewById( R.id.name_edit );
|
EditWClear et = (EditWClear)findViewById( R.id.name_edit );
|
||||||
|
@ -112,12 +119,14 @@ public class NewWithKnowns extends LinearLayout
|
||||||
procs.onUseKnown( mCurKnown, gameName );
|
procs.onUseKnown( mCurKnown, gameName );
|
||||||
break;
|
break;
|
||||||
case R.id.radio_unknown:
|
case R.id.radio_unknown:
|
||||||
procs.onInviteLater( gameName );
|
case R.id.radio_default:
|
||||||
|
procs.onStartGame( gameName, mStandalone, false );
|
||||||
break;
|
break;
|
||||||
case R.id.radio_configure:
|
case R.id.radio_configure:
|
||||||
procs.onConfigureFirst( gameName );
|
procs.onStartGame( gameName, mStandalone, true );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Assert.failDbg();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,11 +174,14 @@ public class NewWithKnowns extends LinearLayout
|
||||||
.getString( context, R.string.newgame_invite_fmt, mCurKnown );
|
.getString( context, R.string.newgame_invite_fmt, mCurKnown );
|
||||||
break;
|
break;
|
||||||
case R.id.radio_unknown:
|
case R.id.radio_unknown:
|
||||||
|
case R.id.radio_default:
|
||||||
resId = R.string.newgame_open_game;
|
resId = R.string.newgame_open_game;
|
||||||
break;
|
break;
|
||||||
case R.id.radio_configure:
|
case R.id.radio_configure:
|
||||||
resId = R.string.newgame_configure_game;
|
resId = R.string.newgame_configure_game;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
Assert.failDbg();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 != resId ) {
|
if ( 0 != resId ) {
|
||||||
|
|
|
@ -15,11 +15,23 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<!-- One of these two pairs gets hidden -->
|
||||||
|
<RadioButton android:id="@+id/radio_default"
|
||||||
|
android:text="@string/use_defaults"
|
||||||
|
style="@style/new_game_radio"
|
||||||
|
/>
|
||||||
|
<TextView android:id="@+id/choose_expl_default"
|
||||||
|
android:text="@string/choose_expl_default"
|
||||||
|
style="@style/new_game_expl"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- pair 2 (networked games case) -->
|
||||||
<RadioButton android:id="@+id/radio_unknown"
|
<RadioButton android:id="@+id/radio_unknown"
|
||||||
android:text="@string/newgame_radio_unknown"
|
android:text="@string/newgame_radio_unknown"
|
||||||
style="@style/new_game_radio"
|
style="@style/new_game_radio"
|
||||||
/>
|
/>
|
||||||
<TextView android:text="@string/choose_expl_new"
|
<TextView android:id="@+id/choose_expl_new"
|
||||||
|
android:text="@string/choose_expl_new"
|
||||||
style="@style/new_game_expl"
|
style="@style/new_game_expl"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -2208,9 +2208,6 @@
|
||||||
<string name="new_game">New one-device game</string>
|
<string name="new_game">New one-device game</string>
|
||||||
<string name="new_game_networked">New networked game</string>
|
<string name="new_game_networked">New networked game</string>
|
||||||
<string name="rematch_name_fmt">%1$s</string>
|
<string name="rematch_name_fmt">%1$s</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_nodflt">This game must be
|
<string name="new_game_message_nodflt">This game must be
|
||||||
configured before it can be opened.</string>
|
configured before it can be opened.</string>
|
||||||
<string name="use_defaults">Use defaults</string>
|
<string name="use_defaults">Use defaults</string>
|
||||||
|
@ -2672,6 +2669,8 @@
|
||||||
“%1$s” to “%2$s”. Is “%2$s” already in use?</string>
|
“%1$s” to “%2$s”. Is “%2$s” already in use?</string>
|
||||||
|
|
||||||
<!-- Quick-start new game explanations and buttons -->
|
<!-- Quick-start new game explanations and buttons -->
|
||||||
|
<string name="choose_expl_default">Start a solo game using the
|
||||||
|
current defaults</string>
|
||||||
<string name="choose_expl_new">Start a game with somebody new,
|
<string name="choose_expl_new">Start a game with somebody new,
|
||||||
sending an invitation via email, SMS, or even a QR code</string>
|
sending an invitation via email, SMS, or even a QR code</string>
|
||||||
<string name="choose_expl_known">OR start a game with somebody you’ve
|
<string name="choose_expl_known">OR start a game with somebody you’ve
|
||||||
|
|
Loading…
Reference in a new issue