mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
Toward more generic naming/use of Renamer
Not quite done
This commit is contained in:
parent
8406d9e551
commit
ba9164641a
5 changed files with 35 additions and 24 deletions
|
@ -525,7 +525,7 @@ public class DelegateBase implements DlgClickNotify,
|
|||
}
|
||||
}
|
||||
|
||||
protected Dialog buildNamerDlg( GameNamer namer, int titleID,
|
||||
protected Dialog buildNamerDlg( Renamer namer, int titleID,
|
||||
OnClickListener lstnr1, OnClickListener lstnr2,
|
||||
DlgID dlgID )
|
||||
{
|
||||
|
|
|
@ -730,8 +730,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
GameSummary summary = GameUtils.getSummary( m_activity, rowid );
|
||||
int labelID = (summary.isMultiGame() && !summary.anyMissing())
|
||||
? R.string.rename_label_caveat : R.string.rename_label;
|
||||
final GameNamer namer =
|
||||
buildNamer(GameUtils.getName( m_activity, rowid ), labelID );
|
||||
final Renamer namer =
|
||||
buildRenamer( GameUtils.getName( m_activity, rowid ), labelID );
|
||||
lstnr = new OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
String name = namer.getName();
|
||||
|
@ -747,8 +747,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
|
||||
case RENAME_GROUP: {
|
||||
final long groupID = (Long)params[0];
|
||||
final GameNamer namer = buildNamer( m_adapter.groupName(groupID),
|
||||
R.string.rename_group_label );
|
||||
final Renamer namer = buildRenamer( m_adapter.groupName(groupID),
|
||||
R.string.rename_group_label );
|
||||
lstnr = new OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
GamesListDelegate self = curThis();
|
||||
|
@ -766,7 +766,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
break;
|
||||
|
||||
case NEW_GROUP: {
|
||||
final GameNamer namer = buildNamer( "", R.string.newgroup_label );
|
||||
final Renamer namer = buildRenamer( "", R.string.newgroup_label );
|
||||
lstnr = new OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
String name = namer.getName();
|
||||
|
@ -2663,12 +2663,13 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
}
|
||||
}
|
||||
|
||||
private GameNamer buildNamer( String name, int labelID )
|
||||
private Renamer buildRenamer( String name, int labelID )
|
||||
{
|
||||
GameNamer namer = (GameNamer)inflate( R.layout.rename_game );
|
||||
namer.setName( name );
|
||||
namer.setLabel( labelID );
|
||||
return namer;
|
||||
Renamer renamer = ((Renamer)inflate( R.layout.renamer ))
|
||||
.setName( name )
|
||||
.setLabel( labelID )
|
||||
;
|
||||
return renamer;
|
||||
}
|
||||
|
||||
private void showNewGroupIf()
|
||||
|
|
|
@ -87,9 +87,10 @@ public class KnownPlayersDelegate extends DelegateBase {
|
|||
switch ( dlgID ) {
|
||||
case RENAME_PLAYER:
|
||||
final String oldName = (String)params[0];
|
||||
final GameNamer namer = (GameNamer)inflate( R.layout.rename_game );
|
||||
namer.setName( oldName );
|
||||
namer.setLabel( "some label" );
|
||||
final Renamer namer = ((Renamer)inflate( R.layout.renamer ))
|
||||
.setName( oldName )
|
||||
.setLabel( "some label" )
|
||||
;
|
||||
|
||||
OnClickListener lstnr = new OnClickListener() {
|
||||
@Override
|
||||
|
@ -135,6 +136,12 @@ public class KnownPlayersDelegate extends DelegateBase {
|
|||
tv.setText( name );
|
||||
}
|
||||
|
||||
private String getName( ViewGroup item )
|
||||
{
|
||||
TextView tv = (TextView)item.findViewById( R.id.player_name );
|
||||
return tv.getText().toString();
|
||||
}
|
||||
|
||||
private void renameInPlace( String oldName, String newName )
|
||||
{
|
||||
ViewGroup child = mChildren.remove( oldName );
|
||||
|
@ -142,7 +149,7 @@ public class KnownPlayersDelegate extends DelegateBase {
|
|||
mChildren.put( newName, child );
|
||||
}
|
||||
|
||||
private ViewGroup makePlayerElem( final String player )
|
||||
private ViewGroup makePlayerElem( String player )
|
||||
{
|
||||
ViewGroup view = null;
|
||||
CommsAddrRec addr = XwJNI.kplr_getAddr( player );
|
||||
|
@ -173,14 +180,14 @@ public class KnownPlayersDelegate extends DelegateBase {
|
|||
.setOnClickListener( new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick( View view ) {
|
||||
showDialogFragment( DlgID.RENAME_PLAYER, player );
|
||||
showDialogFragment( DlgID.RENAME_PLAYER, getName(item) );
|
||||
}
|
||||
} );
|
||||
item.findViewById( R.id.player_delete )
|
||||
.setOnClickListener( new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick( View view ) {
|
||||
confirmAndDelete( player );
|
||||
confirmAndDelete( getName(item) );
|
||||
}
|
||||
} );
|
||||
|
||||
|
|
|
@ -29,29 +29,32 @@ import android.widget.TextView;
|
|||
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
||||
public class GameNamer extends LinearLayout {
|
||||
public class Renamer extends LinearLayout {
|
||||
|
||||
private Context m_context;
|
||||
|
||||
public GameNamer( Context cx, AttributeSet as ) {
|
||||
public Renamer( Context cx, AttributeSet as ) {
|
||||
super( cx, as );
|
||||
m_context = cx;
|
||||
}
|
||||
|
||||
public void setLabel( String label )
|
||||
public Renamer setLabel( String label )
|
||||
{
|
||||
TextView view = (TextView)findViewById( R.id.name_label );
|
||||
view.setText( label );
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setLabel( int id )
|
||||
public Renamer setLabel( int id )
|
||||
{
|
||||
setLabel( LocUtils.getString( getContext(), id ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setName( String text )
|
||||
public Renamer setName( String text )
|
||||
{
|
||||
getEdit().setText( text );
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName()
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<org.eehouse.android.xw4.GameNamer
|
||||
<org.eehouse.android.xw4.Renamer
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -28,4 +28,4 @@
|
|||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
||||
|
||||
</org.eehouse.android.xw4.GameNamer>
|
||||
</org.eehouse.android.xw4.Renamer>
|
Loading…
Reference in a new issue