mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +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_REMATCHEXTRAS = "SAVE_REMATCHEXTRAS";
|
||||
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 ROWID_EXTRA = "rowid";
|
||||
|
@ -965,10 +966,11 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private Dialog mkNewWithKnowns()
|
||||
{
|
||||
String[] names = XwJNI.kplr_getPlayers();
|
||||
final String[] nameRef = {null};
|
||||
final String[] nameRef
|
||||
= { DBUtils.getStringFor( m_activity, KP_NAME_KEY, null ) };
|
||||
final NewWithKnowns view = (NewWithKnowns)
|
||||
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()
|
||||
.setView( view )
|
||||
.setTitle( R.string.new_game_networked )
|
||||
|
@ -977,6 +979,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
@Override
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
Assert.assertTrueNR( null != nameRef[0] );
|
||||
DBUtils.setStringFor( m_activity, KP_NAME_KEY, nameRef[0] );
|
||||
CommsAddrRec addr = XwJNI.kplr_getAddr( nameRef[0] );
|
||||
if ( null != addr ) {
|
||||
launchLikeRematch( addr, view.gameName() );
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
|
@ -49,7 +50,7 @@ public class NewWithKnowns extends LinearLayout implements OnItemSelectedListene
|
|||
mListener = listener;
|
||||
}
|
||||
|
||||
void setNames( String[] knowns, String gameName )
|
||||
void setNames( String[] knowns, String dflt, String gameName )
|
||||
{
|
||||
ArrayAdapter<String> adapter = new
|
||||
ArrayAdapter<String>( getContext(),
|
||||
|
@ -60,6 +61,14 @@ public class NewWithKnowns extends LinearLayout implements OnItemSelectedListene
|
|||
Spinner spinner = (Spinner)findViewById( R.id.names );
|
||||
spinner.setAdapter( adapter );
|
||||
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 );
|
||||
et.setText( gameName );
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<TextView android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Choose your opponent"
|
||||
android:text="@string/choose_opponent"
|
||||
/>
|
||||
|
||||
<Spinner android:id="@+id/names"
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
<TextView android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Name your game"
|
||||
android:text="@string/name_game"
|
||||
/>
|
||||
|
||||
<EditText android:id="@+id/name_edit"
|
||||
|
|
|
@ -2667,4 +2667,9 @@
|
|||
<string name="knowns_dup_name_fmt">Unable to change name from
|
||||
“%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>
|
||||
|
|
Loading…
Reference in a new issue