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