From 6de5d307b391bf96d0c767a10bf86c2de211b8f5 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 20 Jun 2017 19:35:38 -0700 Subject: [PATCH] add name field to manual sms contacts entry --- .../android/xw4/SMSInviteDelegate.java | 30 ++++++++----- .../app/src/main/res/layout/get_sms.xml | 45 +++++++++++++++++++ .../app/src/main/res/values/strings.xml | 4 +- 3 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 xwords4/android/app/src/main/res/layout/get_sms.xml diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/SMSInviteDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/SMSInviteDelegate.java index b0545977c..7c1b0b65e 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/SMSInviteDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/SMSInviteDelegate.java @@ -34,6 +34,7 @@ import android.telephony.PhoneNumberUtils; import android.text.method.DialerKeyListener; import android.view.View; import android.widget.Button; +import android.widget.EditText; import junit.framework.Assert; @@ -143,25 +144,30 @@ public class SMSInviteDelegate extends InviteDelegate { DialogInterface.OnClickListener lstnr; switch( alert.getDlgID() ) { case GET_NUMBER: { - final GameNamer namerView = - (GameNamer)inflate( R.layout.rename_game ); - namerView.setLabel( R.string.get_sms_number ); - namerView.setKeyListener(DialerKeyListener.getInstance()); + final View getNumView = inflate( R.layout.get_sms ); + ((EditText)getNumView.findViewById( R.id.num_field )).setKeyListener(DialerKeyListener.getInstance()); lstnr = new DialogInterface.OnClickListener() { public void onClick( DialogInterface dlg, int item ) { - String number = namerView.getName(); - PhoneRec rec = new PhoneRec( number ); - makeConfirmThenBuilder( R.string.warn_unlimited, - Action.POST_WARNING_ACTION ) - .setPosButton( R.string.button_yes ) - .setParams( number, null ) - .show(); + String number + = ((EditText)getNumView.findViewById(R.id.num_field)) + .getText().toString(); + if ( null != number && 0 < number.length() ) { + String name + = ((EditText)getNumView.findViewById(R.id.name_field)) + .getText().toString(); + makeConfirmThenBuilder( R.string.warn_unlimited, + Action.POST_WARNING_ACTION ) + .setPosButton( R.string.button_yes ) + .setParams( number, name ) + .show(); + } } }; dialog = makeAlertBuilder() + .setTitle( R.string.get_sms_title ) + .setView( getNumView ) .setPositiveButton( android.R.string.ok, lstnr ) .setNegativeButton( android.R.string.cancel, null ) - .setView( namerView ) .create(); } break; diff --git a/xwords4/android/app/src/main/res/layout/get_sms.xml b/xwords4/android/app/src/main/res/layout/get_sms.xml new file mode 100644 index 000000000..118fddcf4 --- /dev/null +++ b/xwords4/android/app/src/main/res/layout/get_sms.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index d1d0d36ff..f28cb3295 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -1919,7 +1919,9 @@ empty. Use the \"Scan games\" button to scan your old games for opponents. Use the \"+\" button to enter device IDs directly. - Enter phone number: + Manual entry + Device phone number: + Contact name (optional): Enter device ID: