mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
remember last invitee and make default next time
This commit is contained in:
parent
712661a6e9
commit
f1eea13c5e
4 changed files with 22 additions and 5 deletions
|
@ -86,6 +86,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
private static final String SAVE_NEXTSOLO = "SAVE_NEXTSOLO";
|
private static final String SAVE_NEXTSOLO = "SAVE_NEXTSOLO";
|
||||||
private static final String SAVE_REMATCHEXTRAS = "SAVE_REMATCHEXTRAS";
|
private static final String SAVE_REMATCHEXTRAS = "SAVE_REMATCHEXTRAS";
|
||||||
private static final String SAVE_MYSIS = TAG + "/MYSIS";
|
private static final String SAVE_MYSIS = TAG + "/MYSIS";
|
||||||
|
private static final String KP_NAME_KEY = TAG + "/kp_last_name";
|
||||||
|
|
||||||
private static final String RELAYIDS_EXTRA = "relayids";
|
private static final String RELAYIDS_EXTRA = "relayids";
|
||||||
private static final String ROWID_EXTRA = "rowid";
|
private static final String ROWID_EXTRA = "rowid";
|
||||||
|
@ -965,10 +966,11 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
private Dialog mkNewWithKnowns()
|
private Dialog mkNewWithKnowns()
|
||||||
{
|
{
|
||||||
String[] names = XwJNI.kplr_getPlayers();
|
String[] names = XwJNI.kplr_getPlayers();
|
||||||
final String[] nameRef = {null};
|
final String[] nameRef
|
||||||
|
= { DBUtils.getStringFor( m_activity, KP_NAME_KEY, null ) };
|
||||||
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.setNames( names, GameUtils.makeDefaultName( m_activity ) );
|
view.setNames( names, nameRef[0], GameUtils.makeDefaultName( m_activity ) );
|
||||||
AlertDialog.Builder ab = makeAlertBuilder()
|
AlertDialog.Builder ab = makeAlertBuilder()
|
||||||
.setView( view )
|
.setView( view )
|
||||||
.setTitle( R.string.new_game_networked )
|
.setTitle( R.string.new_game_networked )
|
||||||
|
@ -977,6 +979,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
@Override
|
@Override
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
Assert.assertTrueNR( null != nameRef[0] );
|
Assert.assertTrueNR( null != nameRef[0] );
|
||||||
|
DBUtils.setStringFor( m_activity, KP_NAME_KEY, nameRef[0] );
|
||||||
CommsAddrRec addr = XwJNI.kplr_getAddr( nameRef[0] );
|
CommsAddrRec addr = XwJNI.kplr_getAddr( nameRef[0] );
|
||||||
if ( null != addr ) {
|
if ( null != addr ) {
|
||||||
launchLikeRematch( addr, view.gameName() );
|
launchLikeRematch( addr, view.gameName() );
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.eehouse.android.xw4;
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
@ -49,7 +50,7 @@ public class NewWithKnowns extends LinearLayout implements OnItemSelectedListene
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNames( String[] knowns, String gameName )
|
void setNames( String[] knowns, String dflt, String gameName )
|
||||||
{
|
{
|
||||||
ArrayAdapter<String> adapter = new
|
ArrayAdapter<String> adapter = new
|
||||||
ArrayAdapter<String>( getContext(),
|
ArrayAdapter<String>( getContext(),
|
||||||
|
@ -60,6 +61,14 @@ public class NewWithKnowns extends LinearLayout implements OnItemSelectedListene
|
||||||
Spinner spinner = (Spinner)findViewById( R.id.names );
|
Spinner spinner = (Spinner)findViewById( R.id.names );
|
||||||
spinner.setAdapter( adapter );
|
spinner.setAdapter( adapter );
|
||||||
spinner.setOnItemSelectedListener( this );
|
spinner.setOnItemSelectedListener( this );
|
||||||
|
if ( !TextUtils.isEmpty( dflt ) ) {
|
||||||
|
for ( int ii = 0; ii < knowns.length; ++ii ) {
|
||||||
|
if ( knowns[ii].equals( dflt ) ) {
|
||||||
|
spinner.setSelection( ii );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EditText et = (EditText)findViewById( R.id.name_edit );
|
EditText et = (EditText)findViewById( R.id.name_edit );
|
||||||
et.setText( gameName );
|
et.setText( gameName );
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<TextView android:layout_width="fill_parent"
|
<TextView android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Choose your opponent"
|
android:text="@string/choose_opponent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spinner android:id="@+id/names"
|
<Spinner android:id="@+id/names"
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<TextView android:layout_width="fill_parent"
|
<TextView android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Name your game"
|
android:text="@string/name_game"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<EditText android:id="@+id/name_edit"
|
<EditText android:id="@+id/name_edit"
|
||||||
|
|
|
@ -2667,4 +2667,9 @@
|
||||||
<string name="knowns_dup_name_fmt">Unable to change name from
|
<string name="knowns_dup_name_fmt">Unable to change name from
|
||||||
“%1$s” to “%2$s”. Is “%2$s” already in use?</string>
|
“%1$s” to “%2$s”. Is “%2$s” already in use?</string>
|
||||||
|
|
||||||
|
<!-- Title of known-player spinner in quick-invite new game dialog -->
|
||||||
|
<string name="name_game">Name your game</string>
|
||||||
|
<!-- Title of the game name field in quick-invite new game dialog -->
|
||||||
|
<string name="choose_opponent">Choose your opponent</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue