mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-13 20:48:02 +01:00
make relay invite record editable
This commit is contained in:
parent
32c6a5e114
commit
c6a72b63ee
2 changed files with 35 additions and 12 deletions
|
@ -64,6 +64,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
R.id.button_relay_add,
|
R.id.button_relay_add,
|
||||||
R.id.manual_add_button,
|
R.id.manual_add_button,
|
||||||
R.id.button_clear,
|
R.id.button_clear,
|
||||||
|
R.id.button_edit,
|
||||||
};
|
};
|
||||||
|
|
||||||
// private static final int GET_CONTACT = 1;
|
// private static final int GET_CONTACT = 1;
|
||||||
|
@ -141,6 +142,9 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
count, count );
|
count, count );
|
||||||
makeConfirmThenBuilder( msg, Action.CLEAR_ACTION ).show();
|
makeConfirmThenBuilder( msg, Action.CLEAR_ACTION ).show();
|
||||||
break;
|
break;
|
||||||
|
case R.id.button_edit:
|
||||||
|
showDialogFragment( DlgID.GET_NUMBER, getChecked().iterator().next() );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,22 +182,33 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
DialogInterface.OnClickListener lstnr;
|
DialogInterface.OnClickListener lstnr;
|
||||||
switch( alert.getDlgID() ) {
|
switch( alert.getDlgID() ) {
|
||||||
case GET_NUMBER: {
|
case GET_NUMBER: {
|
||||||
|
final DevIDRec curRec =
|
||||||
|
1 <= params.length && params[0] instanceof DevIDRec
|
||||||
|
? (DevIDRec)params[0] : null;
|
||||||
final View getNumView = inflate( R.layout.get_relay );
|
final View getNumView = inflate( R.layout.get_relay );
|
||||||
((EditText)getNumView.findViewById( R.id.num_field ))
|
final EditText numField = (EditText)
|
||||||
.setKeyListener(DigitsKeyListener.getInstance());
|
getNumView.findViewById( R.id.num_field );
|
||||||
|
numField.setKeyListener(DigitsKeyListener.getInstance());
|
||||||
|
final EditText nameField = (EditText)
|
||||||
|
getNumView.findViewById( R.id.name_field );
|
||||||
|
if ( null != curRec ) {
|
||||||
|
numField.setText( curRec.m_devID );
|
||||||
|
nameField.setText( curRec.m_opponent );
|
||||||
|
}
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
String number
|
String number = numField.getText().toString();
|
||||||
= ((EditText)getNumView.findViewById(R.id.num_field))
|
|
||||||
.getText().toString();
|
|
||||||
if ( null != number && 0 < number.length() ) {
|
if ( null != number && 0 < number.length() ) {
|
||||||
String name
|
String name = nameField.getText().toString();
|
||||||
= ((EditText)getNumView.findViewById(R.id.name_field))
|
if ( curRec != null ) {
|
||||||
.getText().toString();
|
curRec.m_opponent = name;
|
||||||
DevIDRec rec = new DevIDRec( name, number );
|
curRec.m_devID = number;
|
||||||
m_devIDRecs.add( rec );
|
} else {
|
||||||
clearChecked();
|
DevIDRec rec = new DevIDRec( name, number );
|
||||||
onItemChecked( rec, true );
|
m_devIDRecs.add( rec );
|
||||||
|
clearChecked();
|
||||||
|
onItemChecked( rec, true );
|
||||||
|
}
|
||||||
saveAndRebuild();
|
saveAndRebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,6 +328,10 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
if ( null != button ) { // may not be there yet
|
if ( null != button ) { // may not be there yet
|
||||||
button.setEnabled( 0 < getChecked().size() );
|
button.setEnabled( 0 < getChecked().size() );
|
||||||
}
|
}
|
||||||
|
button = (Button)findViewById( R.id.button_edit );
|
||||||
|
if ( null != button ) {
|
||||||
|
button.setEnabled( 1 == getChecked().size() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
|
|
|
@ -21,4 +21,8 @@
|
||||||
android:text="@string/bt_pick_clear_button"
|
android:text="@string/bt_pick_clear_button"
|
||||||
style="@style/evenly_spaced_horizontal"
|
style="@style/evenly_spaced_horizontal"
|
||||||
/>
|
/>
|
||||||
|
<Button android:id="@+id/button_edit"
|
||||||
|
android:text="@string/button_edit"
|
||||||
|
style="@style/evenly_spaced_horizontal"
|
||||||
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Loading…
Add table
Reference in a new issue