mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
show Known Player name in button
Got tired of it not being clear what the button was going to do
This commit is contained in:
parent
71d5127782
commit
57d93273c9
4 changed files with 60 additions and 19 deletions
|
@ -458,9 +458,6 @@ public class BTUtils {
|
|||
PacketAccumulator pa = pas.get( dev );
|
||||
try {
|
||||
pa.join();
|
||||
if ( 0 < pa.getResponseCount() ) {
|
||||
callListeners( dev );
|
||||
}
|
||||
} catch ( InterruptedException ex ) {
|
||||
Assert.failDbg();
|
||||
}
|
||||
|
@ -560,9 +557,11 @@ public class BTUtils {
|
|||
private volatile boolean mExitWhenEmpty = false;
|
||||
private BluetoothAdapter mAdapter;
|
||||
private BTHelper mHelper;
|
||||
private boolean mPostOnResponse;
|
||||
|
||||
PacketAccumulator( String addr ) { this(addr, 20000); }
|
||||
|
||||
// Ping case -- used only once
|
||||
PacketAccumulator( String addr, int timeoutMS )
|
||||
{
|
||||
Assert.assertTrue( !TextUtils.isEmpty(addr) );
|
||||
|
@ -575,6 +574,7 @@ public class BTUtils {
|
|||
mAdapter = getAdapterIf();
|
||||
Assert.assertTrueNR( null != mAdapter );
|
||||
mHelper = new BTHelper( mName, mAddr );
|
||||
mPostOnResponse = true;
|
||||
start();
|
||||
}
|
||||
|
||||
|
@ -614,11 +614,6 @@ public class BTUtils {
|
|||
return this;
|
||||
}
|
||||
|
||||
int getResponseCount()
|
||||
{
|
||||
return mResponseCount;
|
||||
}
|
||||
|
||||
void addInvite( NetLaunchInfo nli )
|
||||
{
|
||||
try {
|
||||
|
@ -825,6 +820,9 @@ public class BTUtils {
|
|||
mName, dos );
|
||||
nDone += writeAndCheck( socket, dos );
|
||||
updateStatusOut( true );
|
||||
if ( mPostOnResponse ) {
|
||||
callListeners( socket.getRemoteDevice() );
|
||||
}
|
||||
}
|
||||
} catch ( IOException ioe ) {
|
||||
Log.e( TAG, "PacketAccumulator.run(): ioe: %s",
|
||||
|
|
|
@ -965,6 +965,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private Dialog mkNewWithKnowns()
|
||||
{
|
||||
String[] names = XwJNI.kplr_getPlayers();
|
||||
final String[] nameRef = {null};
|
||||
final NewWithKnowns view = (NewWithKnowns)
|
||||
LocUtils.inflate( m_activity, R.layout.new_game_with_knowns );
|
||||
view.setNames( names, GameUtils.makeDefaultName( m_activity ) );
|
||||
|
@ -972,11 +973,11 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
.setView( view )
|
||||
.setTitle( R.string.new_game_networked )
|
||||
.setIcon( R.drawable.ic_multigame )
|
||||
.setPositiveButton( R.string.play, new OnClickListener() {
|
||||
.setPositiveButton( "…" /* can't be empty*/, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
String player = view.getSelPlayer();
|
||||
CommsAddrRec addr = XwJNI.kplr_getAddr( player );
|
||||
Assert.assertTrueNR( null != nameRef[0] );
|
||||
CommsAddrRec addr = XwJNI.kplr_getAddr( nameRef[0] );
|
||||
if ( null != addr ) {
|
||||
launchLikeRematch( addr, view.gameName() );
|
||||
}
|
||||
|
@ -991,7 +992,22 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
} )
|
||||
;
|
||||
|
||||
return ab.create();
|
||||
final AlertDialog dialog = ab.create();
|
||||
view.setOnNameChangeListener( new NewWithKnowns.OnNameChangeListener() {
|
||||
@Override
|
||||
public void onNewName( String name ) {
|
||||
nameRef[0] = name;
|
||||
Button button = dialog.getButton( DialogInterface.BUTTON_POSITIVE );
|
||||
if ( null != button ) {
|
||||
String msg = getString( R.string.invite_player_fmt, name );
|
||||
button.setText( msg );
|
||||
} else {
|
||||
Log.e( TAG, "Button still null" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private void enableMoveGroupButton( DialogInterface dlgi )
|
||||
|
|
|
@ -21,18 +21,34 @@ package org.eehouse.android.xw4;
|
|||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class NewWithKnowns extends LinearLayout {
|
||||
public class NewWithKnowns extends LinearLayout implements OnItemSelectedListener
|
||||
{
|
||||
public interface OnNameChangeListener {
|
||||
void onNewName( String name );
|
||||
}
|
||||
|
||||
private OnNameChangeListener mListener;
|
||||
|
||||
public NewWithKnowns( Context cx, AttributeSet as )
|
||||
{
|
||||
super( cx, as );
|
||||
}
|
||||
|
||||
void setOnNameChangeListener( OnNameChangeListener listener )
|
||||
{
|
||||
Assert.assertTrueNR( null == mListener );
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
void setNames( String[] knowns, String gameName )
|
||||
{
|
||||
ArrayAdapter<String> adapter = new
|
||||
|
@ -43,20 +59,29 @@ public class NewWithKnowns extends LinearLayout {
|
|||
.simple_spinner_dropdown_item );
|
||||
Spinner spinner = (Spinner)findViewById( R.id.names );
|
||||
spinner.setAdapter( adapter );
|
||||
spinner.setOnItemSelectedListener( this );
|
||||
|
||||
EditText et = (EditText)findViewById( R.id.name_edit );
|
||||
et.setText( gameName );
|
||||
}
|
||||
|
||||
String getSelPlayer()
|
||||
{
|
||||
Spinner spinner = (Spinner)findViewById( R.id.names );
|
||||
return spinner.getSelectedItem().toString();
|
||||
}
|
||||
|
||||
String gameName()
|
||||
{
|
||||
EditText et = (EditText)findViewById( R.id.name_edit );
|
||||
return et.getText().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected( AdapterView<?> parent, View view,
|
||||
int pos, long id )
|
||||
{
|
||||
OnNameChangeListener listener = mListener;
|
||||
if ( null != listener && view instanceof TextView ) {
|
||||
TextView tv = (TextView)view;
|
||||
listener.onNewName( tv.getText().toString() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected( AdapterView<?> parent ) {}
|
||||
}
|
||||
|
|
|
@ -1007,6 +1007,8 @@
|
|||
it immediately because an email or messaging app will be
|
||||
launched to send your invitation. -->
|
||||
<string name="newgame_invite">Invite now</string>
|
||||
<!-- Button offering to invite Known Player to a new game -->
|
||||
<string name="invite_player_fmt">Invite %1$s</string>
|
||||
<string name="newgame_invite_more">More info</string>
|
||||
<string name="newgame_drop_relay">Drop Relay</string>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue