Ask a friend name when subscribe.

This commit is contained in:
Chteufleur 2019-09-23 10:36:56 +02:00
parent 8a75d0fd4e
commit 4c41b3c41f
1 changed files with 18 additions and 0 deletions

View File

@ -963,12 +963,30 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Demande d'ami");
builder.setMessage("Voulez-vous l'ajouter dans votre liste d'ami ?");
final EditText inputName = new EditText(this);
inputName.setHint("Donner un nom");
inputName.setInputType(InputType.TYPE_CLASS_TEXT);
builder.setView(inputName);
builder.setPositiveButton("Oui", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
serviceTrackingDog.sendAcceptSubscription(_jid);
serviceTrackingDog.sendSubscription(_jid);
final String _name = inputName.getText().toString();
if (!_name.equals("")) {
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
serviceTrackingDog.setJidName(_jid, _name);
}
}).start();
}
} catch (SmackException.NotConnectedException | XmppStringprepException | InterruptedException e) {
e.printStackTrace();
}