1package eu.siacs.conversations.ui;
2
3import android.app.AlertDialog.Builder;
4import android.app.PendingIntent;
5import android.content.DialogInterface;
6import android.content.Intent;
7import android.os.Bundle;
8import android.text.Editable;
9import android.text.TextWatcher;
10import android.view.Menu;
11import android.view.MenuItem;
12import android.view.View;
13import android.view.View.OnClickListener;
14import android.widget.AutoCompleteTextView;
15import android.widget.Button;
16import android.widget.CheckBox;
17import android.widget.CompoundButton;
18import android.widget.CompoundButton.OnCheckedChangeListener;
19import android.widget.EditText;
20import android.widget.ImageButton;
21import android.widget.ImageView;
22import android.widget.LinearLayout;
23import android.widget.RelativeLayout;
24import android.widget.TableLayout;
25import android.widget.TextView;
26import android.widget.Toast;
27
28import org.whispersystems.libaxolotl.IdentityKey;
29
30import java.util.Set;
31
32import eu.siacs.conversations.R;
33import eu.siacs.conversations.entities.Account;
34import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
35import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
36import eu.siacs.conversations.utils.CryptoHelper;
37import eu.siacs.conversations.utils.UIHelper;
38import eu.siacs.conversations.xmpp.XmppConnection.Features;
39import eu.siacs.conversations.xmpp.jid.InvalidJidException;
40import eu.siacs.conversations.xmpp.jid.Jid;
41import eu.siacs.conversations.xmpp.pep.Avatar;
42
43public class EditAccountActivity extends XmppActivity implements OnAccountUpdate{
44
45 private AutoCompleteTextView mAccountJid;
46 private EditText mPassword;
47 private EditText mPasswordConfirm;
48 private CheckBox mRegisterNew;
49 private Button mCancelButton;
50 private Button mSaveButton;
51 private TableLayout mMoreTable;
52
53 private LinearLayout mStats;
54 private TextView mServerInfoSm;
55 private TextView mServerInfoRosterVersion;
56 private TextView mServerInfoCarbons;
57 private TextView mServerInfoMam;
58 private TextView mServerInfoCSI;
59 private TextView mServerInfoBlocking;
60 private TextView mServerInfoPep;
61 private TextView mSessionEst;
62 private TextView mOtrFingerprint;
63 private TextView mAxolotlFingerprint;
64 private ImageView mAvatar;
65 private RelativeLayout mOtrFingerprintBox;
66 private RelativeLayout mAxolotlFingerprintBox;
67 private ImageButton mOtrFingerprintToClipboardButton;
68 private ImageButton mAxolotlFingerprintToClipboardButton;
69 private ImageButton mRegenerateAxolotlKeyButton;
70 private LinearLayout keys;
71 private LinearLayout keysCard;
72
73 private Jid jidToEdit;
74 private Account mAccount;
75
76 private boolean mFetchingAvatar = false;
77
78 private final OnClickListener mSaveButtonClickListener = new OnClickListener() {
79
80 @Override
81 public void onClick(final View v) {
82 if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED && !accountInfoEdited()) {
83 mAccount.setOption(Account.OPTION_DISABLED, false);
84 xmppConnectionService.updateAccount(mAccount);
85 return;
86 }
87 final boolean registerNewAccount = mRegisterNew.isChecked();
88 final Jid jid;
89 try {
90 jid = Jid.fromString(mAccountJid.getText().toString());
91 } catch (final InvalidJidException e) {
92 mAccountJid.setError(getString(R.string.invalid_jid));
93 mAccountJid.requestFocus();
94 return;
95 }
96 if (jid.isDomainJid()) {
97 mAccountJid.setError(getString(R.string.invalid_jid));
98 mAccountJid.requestFocus();
99 return;
100 }
101 final String password = mPassword.getText().toString();
102 final String passwordConfirm = mPasswordConfirm.getText().toString();
103 if (registerNewAccount) {
104 if (!password.equals(passwordConfirm)) {
105 mPasswordConfirm.setError(getString(R.string.passwords_do_not_match));
106 mPasswordConfirm.requestFocus();
107 return;
108 }
109 }
110 if (mAccount != null) {
111 try {
112 mAccount.setUsername(jid.hasLocalpart() ? jid.getLocalpart() : "");
113 mAccount.setServer(jid.getDomainpart());
114 } catch (final InvalidJidException ignored) {
115 return;
116 }
117 mAccountJid.setError(null);
118 mPasswordConfirm.setError(null);
119 mAccount.setPassword(password);
120 mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount);
121 xmppConnectionService.updateAccount(mAccount);
122 } else {
123 try {
124 if (xmppConnectionService.findAccountByJid(Jid.fromString(mAccountJid.getText().toString())) != null) {
125 mAccountJid.setError(getString(R.string.account_already_exists));
126 mAccountJid.requestFocus();
127 return;
128 }
129 } catch (final InvalidJidException e) {
130 return;
131 }
132 mAccount = new Account(jid.toBareJid(), password);
133 mAccount.setOption(Account.OPTION_USETLS, true);
134 mAccount.setOption(Account.OPTION_USECOMPRESSION, true);
135 mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount);
136 xmppConnectionService.createAccount(mAccount);
137 }
138 if (jidToEdit != null && !mAccount.isOptionSet(Account.OPTION_DISABLED)) {
139 finish();
140 } else {
141 updateSaveButton();
142 updateAccountInformation(true);
143 }
144
145 }
146 };
147 private final OnClickListener mCancelButtonClickListener = new OnClickListener() {
148
149 @Override
150 public void onClick(final View v) {
151 finish();
152 }
153 };
154 @Override
155 public void onAccountUpdate() {
156 runOnUiThread(new Runnable() {
157
158 @Override
159 public void run() {
160 invalidateOptionsMenu();
161 if (mAccount != null
162 && mAccount.getStatus() != Account.State.ONLINE
163 && mFetchingAvatar) {
164 startActivity(new Intent(getApplicationContext(),
165 ManageAccountActivity.class));
166 finish();
167 } else if (jidToEdit == null && mAccount != null
168 && mAccount.getStatus() == Account.State.ONLINE) {
169 if (!mFetchingAvatar) {
170 mFetchingAvatar = true;
171 xmppConnectionService.checkForAvatar(mAccount,
172 mAvatarFetchCallback);
173 }
174 } else {
175 updateSaveButton();
176 }
177 if (mAccount != null) {
178 updateAccountInformation(false);
179 }
180 }
181 });
182 }
183 private final UiCallback<Avatar> mAvatarFetchCallback = new UiCallback<Avatar>() {
184
185 @Override
186 public void userInputRequried(final PendingIntent pi, final Avatar avatar) {
187 finishInitialSetup(avatar);
188 }
189
190 @Override
191 public void success(final Avatar avatar) {
192 finishInitialSetup(avatar);
193 }
194
195 @Override
196 public void error(final int errorCode, final Avatar avatar) {
197 finishInitialSetup(avatar);
198 }
199 };
200 private final TextWatcher mTextWatcher = new TextWatcher() {
201
202 @Override
203 public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
204 updateSaveButton();
205 }
206
207 @Override
208 public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
209 }
210
211 @Override
212 public void afterTextChanged(final Editable s) {
213
214 }
215 };
216
217 private final OnClickListener mAvatarClickListener = new OnClickListener() {
218 @Override
219 public void onClick(final View view) {
220 if (mAccount != null) {
221 final Intent intent = new Intent(getApplicationContext(),
222 PublishProfilePictureActivity.class);
223 intent.putExtra("account", mAccount.getJid().toBareJid().toString());
224 startActivity(intent);
225 }
226 }
227 };
228
229 protected void finishInitialSetup(final Avatar avatar) {
230 runOnUiThread(new Runnable() {
231
232 @Override
233 public void run() {
234 final Intent intent;
235 if (avatar != null) {
236 intent = new Intent(getApplicationContext(),
237 StartConversationActivity.class);
238 if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
239 intent.putExtra("init", true);
240 }
241 } else {
242 intent = new Intent(getApplicationContext(),
243 PublishProfilePictureActivity.class);
244 intent.putExtra("account", mAccount.getJid().toBareJid().toString());
245 intent.putExtra("setup", true);
246 }
247 startActivity(intent);
248 finish();
249 }
250 });
251 }
252
253 protected void updateSaveButton() {
254 if (accountInfoEdited() && jidToEdit != null) {
255 this.mSaveButton.setText(R.string.save);
256 this.mSaveButton.setEnabled(true);
257 this.mSaveButton.setTextColor(getPrimaryTextColor());
258 } else if (mAccount != null && (mAccount.getStatus() == Account.State.CONNECTING || mFetchingAvatar)) {
259 this.mSaveButton.setEnabled(false);
260 this.mSaveButton.setTextColor(getSecondaryTextColor());
261 this.mSaveButton.setText(R.string.account_status_connecting);
262 } else if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED) {
263 this.mSaveButton.setEnabled(true);
264 this.mSaveButton.setTextColor(getPrimaryTextColor());
265 this.mSaveButton.setText(R.string.enable);
266 } else {
267 this.mSaveButton.setEnabled(true);
268 this.mSaveButton.setTextColor(getPrimaryTextColor());
269 if (jidToEdit != null) {
270 if (mAccount != null && mAccount.isOnlineAndConnected()) {
271 this.mSaveButton.setText(R.string.save);
272 if (!accountInfoEdited()) {
273 this.mSaveButton.setEnabled(false);
274 this.mSaveButton.setTextColor(getSecondaryTextColor());
275 }
276 } else {
277 this.mSaveButton.setText(R.string.connect);
278 }
279 } else {
280 this.mSaveButton.setText(R.string.next);
281 }
282 }
283 }
284
285 protected boolean accountInfoEdited() {
286 return this.mAccount != null && (!this.mAccount.getJid().toBareJid().toString().equals(
287 this.mAccountJid.getText().toString())
288 || !this.mAccount.getPassword().equals(
289 this.mPassword.getText().toString()));
290 }
291
292 @Override
293 protected String getShareableUri() {
294 if (mAccount!=null) {
295 return mAccount.getShareableUri();
296 } else {
297 return "";
298 }
299 }
300
301 @Override
302 protected void onCreate(final Bundle savedInstanceState) {
303 super.onCreate(savedInstanceState);
304 setContentView(R.layout.activity_edit_account);
305 this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
306 this.mAccountJid.addTextChangedListener(this.mTextWatcher);
307 this.mPassword = (EditText) findViewById(R.id.account_password);
308 this.mPassword.addTextChangedListener(this.mTextWatcher);
309 this.mPasswordConfirm = (EditText) findViewById(R.id.account_password_confirm);
310 this.mAvatar = (ImageView) findViewById(R.id.avater);
311 this.mAvatar.setOnClickListener(this.mAvatarClickListener);
312 this.mRegisterNew = (CheckBox) findViewById(R.id.account_register_new);
313 this.mStats = (LinearLayout) findViewById(R.id.stats);
314 this.mSessionEst = (TextView) findViewById(R.id.session_est);
315 this.mServerInfoRosterVersion = (TextView) findViewById(R.id.server_info_roster_version);
316 this.mServerInfoCarbons = (TextView) findViewById(R.id.server_info_carbons);
317 this.mServerInfoMam = (TextView) findViewById(R.id.server_info_mam);
318 this.mServerInfoCSI = (TextView) findViewById(R.id.server_info_csi);
319 this.mServerInfoBlocking = (TextView) findViewById(R.id.server_info_blocking);
320 this.mServerInfoSm = (TextView) findViewById(R.id.server_info_sm);
321 this.mServerInfoPep = (TextView) findViewById(R.id.server_info_pep);
322 this.mOtrFingerprint = (TextView) findViewById(R.id.otr_fingerprint);
323 this.mOtrFingerprintBox = (RelativeLayout) findViewById(R.id.otr_fingerprint_box);
324 this.mOtrFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_to_clipboard);
325 this.mAxolotlFingerprint = (TextView) findViewById(R.id.axolotl_fingerprint);
326 this.mAxolotlFingerprintBox = (RelativeLayout) findViewById(R.id.axolotl_fingerprint_box);
327 this.mAxolotlFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_axolotl_to_clipboard);
328 this.mRegenerateAxolotlKeyButton = (ImageButton) findViewById(R.id.action_regenerate_axolotl_key);
329 this.keysCard = (LinearLayout) findViewById(R.id.other_device_keys_card);
330 this.keys = (LinearLayout) findViewById(R.id.other_device_keys);
331 this.mSaveButton = (Button) findViewById(R.id.save_button);
332 this.mCancelButton = (Button) findViewById(R.id.cancel_button);
333 this.mSaveButton.setOnClickListener(this.mSaveButtonClickListener);
334 this.mCancelButton.setOnClickListener(this.mCancelButtonClickListener);
335 this.mMoreTable = (TableLayout) findViewById(R.id.server_info_more);
336 final OnCheckedChangeListener OnCheckedShowConfirmPassword = new OnCheckedChangeListener() {
337 @Override
338 public void onCheckedChanged(final CompoundButton buttonView,
339 final boolean isChecked) {
340 if (isChecked) {
341 mPasswordConfirm.setVisibility(View.VISIBLE);
342 } else {
343 mPasswordConfirm.setVisibility(View.GONE);
344 }
345 updateSaveButton();
346 }
347 };
348 this.mRegisterNew.setOnCheckedChangeListener(OnCheckedShowConfirmPassword);
349 }
350
351 @Override
352 public boolean onCreateOptionsMenu(final Menu menu) {
353 super.onCreateOptionsMenu(menu);
354 getMenuInflater().inflate(R.menu.editaccount, menu);
355 final MenuItem showQrCode = menu.findItem(R.id.action_show_qr_code);
356 final MenuItem showBlocklist = menu.findItem(R.id.action_show_block_list);
357 final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more);
358 final MenuItem changePassword = menu.findItem(R.id.action_change_password_on_server);
359 final MenuItem clearDevices = menu.findItem(R.id.action_clear_devices);
360 if (mAccount != null && mAccount.isOnlineAndConnected()) {
361 if (!mAccount.getXmppConnection().getFeatures().blocking()) {
362 showBlocklist.setVisible(false);
363 }
364 if (!mAccount.getXmppConnection().getFeatures().register()) {
365 changePassword.setVisible(false);
366 }
367 Set<Integer> otherDevices = mAccount.getAxolotlService().getOwnDeviceIds();
368 if (otherDevices == null || otherDevices.isEmpty()) {
369 clearDevices.setVisible(false);
370 }
371 } else {
372 showQrCode.setVisible(false);
373 showBlocklist.setVisible(false);
374 showMoreInfo.setVisible(false);
375 changePassword.setVisible(false);
376 }
377 return true;
378 }
379
380 @Override
381 protected void onStart() {
382 super.onStart();
383 if (getIntent() != null) {
384 try {
385 this.jidToEdit = Jid.fromString(getIntent().getStringExtra("jid"));
386 } catch (final InvalidJidException | NullPointerException ignored) {
387 this.jidToEdit = null;
388 }
389 if (this.jidToEdit != null) {
390 this.mRegisterNew.setVisibility(View.GONE);
391 if (getActionBar() != null) {
392 getActionBar().setTitle(getString(R.string.account_details));
393 }
394 } else {
395 this.mAvatar.setVisibility(View.GONE);
396 if (getActionBar() != null) {
397 getActionBar().setTitle(R.string.action_add_account);
398 }
399 }
400 }
401 }
402
403 @Override
404 protected void onBackendConnected() {
405 final KnownHostsAdapter mKnownHostsAdapter = new KnownHostsAdapter(this,
406 android.R.layout.simple_list_item_1,
407 xmppConnectionService.getKnownHosts());
408 if (this.jidToEdit != null) {
409 this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit);
410 updateAccountInformation(true);
411 } else if (this.xmppConnectionService.getAccounts().size() == 0) {
412 if (getActionBar() != null) {
413 getActionBar().setDisplayHomeAsUpEnabled(false);
414 getActionBar().setDisplayShowHomeEnabled(false);
415 getActionBar().setHomeButtonEnabled(false);
416 }
417 this.mCancelButton.setEnabled(false);
418 this.mCancelButton.setTextColor(getSecondaryTextColor());
419 }
420 this.mAccountJid.setAdapter(mKnownHostsAdapter);
421 updateSaveButton();
422 }
423
424 @Override
425 public boolean onOptionsItemSelected(final MenuItem item) {
426 switch (item.getItemId()) {
427 case R.id.action_show_block_list:
428 final Intent showBlocklistIntent = new Intent(this, BlocklistActivity.class);
429 showBlocklistIntent.putExtra("account", mAccount.getJid().toString());
430 startActivity(showBlocklistIntent);
431 break;
432 case R.id.action_server_info_show_more:
433 mMoreTable.setVisibility(item.isChecked() ? View.GONE : View.VISIBLE);
434 item.setChecked(!item.isChecked());
435 break;
436 case R.id.action_change_password_on_server:
437 final Intent changePasswordIntent = new Intent(this, ChangePasswordActivity.class);
438 changePasswordIntent.putExtra("account", mAccount.getJid().toString());
439 startActivity(changePasswordIntent);
440 break;
441 case R.id.action_clear_devices:
442 showWipePepDialog();
443 break;
444 }
445 return super.onOptionsItemSelected(item);
446 }
447
448 private void updateAccountInformation(boolean init) {
449 if (init) {
450 this.mAccountJid.setText(this.mAccount.getJid().toBareJid().toString());
451 this.mPassword.setText(this.mAccount.getPassword());
452 }
453 if (this.jidToEdit != null) {
454 this.mAvatar.setVisibility(View.VISIBLE);
455 this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72)));
456 }
457 if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) {
458 this.mRegisterNew.setVisibility(View.VISIBLE);
459 this.mRegisterNew.setChecked(true);
460 this.mPasswordConfirm.setText(this.mAccount.getPassword());
461 } else {
462 this.mRegisterNew.setVisibility(View.GONE);
463 this.mRegisterNew.setChecked(false);
464 }
465 if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) {
466 this.mStats.setVisibility(View.VISIBLE);
467 this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection()
468 .getLastSessionEstablished()));
469 Features features = this.mAccount.getXmppConnection().getFeatures();
470 if (features.rosterVersioning()) {
471 this.mServerInfoRosterVersion.setText(R.string.server_info_available);
472 } else {
473 this.mServerInfoRosterVersion.setText(R.string.server_info_unavailable);
474 }
475 if (features.carbons()) {
476 this.mServerInfoCarbons.setText(R.string.server_info_available);
477 } else {
478 this.mServerInfoCarbons
479 .setText(R.string.server_info_unavailable);
480 }
481 if (features.mam()) {
482 this.mServerInfoMam.setText(R.string.server_info_available);
483 } else {
484 this.mServerInfoMam.setText(R.string.server_info_unavailable);
485 }
486 if (features.csi()) {
487 this.mServerInfoCSI.setText(R.string.server_info_available);
488 } else {
489 this.mServerInfoCSI.setText(R.string.server_info_unavailable);
490 }
491 if (features.blocking()) {
492 this.mServerInfoBlocking.setText(R.string.server_info_available);
493 } else {
494 this.mServerInfoBlocking.setText(R.string.server_info_unavailable);
495 }
496 if (features.sm()) {
497 this.mServerInfoSm.setText(R.string.server_info_available);
498 } else {
499 this.mServerInfoSm.setText(R.string.server_info_unavailable);
500 }
501 if (features.pep()) {
502 this.mServerInfoPep.setText(R.string.server_info_available);
503 } else {
504 this.mServerInfoPep.setText(R.string.server_info_unavailable);
505 }
506 final String otrFingerprint = this.mAccount.getOtrFingerprint();
507 if (otrFingerprint != null) {
508 this.mOtrFingerprintBox.setVisibility(View.VISIBLE);
509 this.mOtrFingerprint.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
510 this.mOtrFingerprintToClipboardButton
511 .setVisibility(View.VISIBLE);
512 this.mOtrFingerprintToClipboardButton
513 .setOnClickListener(new View.OnClickListener() {
514
515 @Override
516 public void onClick(final View v) {
517
518 if (copyTextToClipboard(otrFingerprint, R.string.otr_fingerprint)) {
519 Toast.makeText(
520 EditAccountActivity.this,
521 R.string.toast_message_otr_fingerprint,
522 Toast.LENGTH_SHORT).show();
523 }
524 }
525 });
526 } else {
527 this.mOtrFingerprintBox.setVisibility(View.GONE);
528 }
529 final String axolotlFingerprint = this.mAccount.getAxolotlService().getOwnPublicKey().getFingerprint();
530 if (axolotlFingerprint != null) {
531 this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE);
532 this.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(axolotlFingerprint));
533 this.mAxolotlFingerprintToClipboardButton
534 .setVisibility(View.VISIBLE);
535 this.mAxolotlFingerprintToClipboardButton
536 .setOnClickListener(new View.OnClickListener() {
537
538 @Override
539 public void onClick(final View v) {
540
541 if (copyTextToClipboard(axolotlFingerprint, R.string.axolotl_fingerprint)) {
542 Toast.makeText(
543 EditAccountActivity.this,
544 R.string.toast_message_axolotl_fingerprint,
545 Toast.LENGTH_SHORT).show();
546 }
547 }
548 });
549 this.mRegenerateAxolotlKeyButton
550 .setVisibility(View.VISIBLE);
551 this.mRegenerateAxolotlKeyButton
552 .setOnClickListener(new View.OnClickListener() {
553
554 @Override
555 public void onClick(final View v) {
556 showRegenerateAxolotlKeyDialog();
557 }
558 });
559 } else {
560 this.mAxolotlFingerprintBox.setVisibility(View.GONE);
561 }
562 final IdentityKey ownKey = mAccount.getAxolotlService().getOwnPublicKey();
563 boolean hasKeys = false;
564 keys.removeAllViews();
565 for(final IdentityKey identityKey : xmppConnectionService.databaseBackend.loadIdentityKeys(
566 mAccount, mAccount.getJid().toBareJid().toString())) {
567 if(ownKey.equals(identityKey)) {
568 continue;
569 }
570 hasKeys = true;
571 addFingerprintRow(keys, mAccount, identityKey);
572 }
573 if (hasKeys) {
574 keysCard.setVisibility(View.VISIBLE);
575 } else {
576 keysCard.setVisibility(View.GONE);
577 }
578 } else {
579 if (this.mAccount.errorStatus()) {
580 this.mAccountJid.setError(getString(this.mAccount.getStatus().getReadableId()));
581 if (init || !accountInfoEdited()) {
582 this.mAccountJid.requestFocus();
583 }
584 } else {
585 this.mAccountJid.setError(null);
586 }
587 this.mStats.setVisibility(View.GONE);
588 }
589 }
590
591 public void showRegenerateAxolotlKeyDialog() {
592 Builder builder = new Builder(this);
593 builder.setTitle("Regenerate Key");
594 builder.setIconAttribute(android.R.attr.alertDialogIcon);
595 builder.setMessage("Are you sure you want to regenerate your Identity Key? (This will also wipe all established sessions and contact Identity Keys)");
596 builder.setNegativeButton(getString(R.string.cancel), null);
597 builder.setPositiveButton("Yes",
598 new DialogInterface.OnClickListener() {
599 @Override
600 public void onClick(DialogInterface dialog, int which) {
601 mAccount.getAxolotlService().regenerateKeys();
602 }
603 });
604 builder.create().show();
605 }
606
607 public void showWipePepDialog() {
608 Builder builder = new Builder(this);
609 builder.setTitle(getString(R.string.clear_other_devices));
610 builder.setIconAttribute(android.R.attr.alertDialogIcon);
611 builder.setMessage(getString(R.string.clear_other_devices_desc));
612 builder.setNegativeButton(getString(R.string.cancel), null);
613 builder.setPositiveButton(getString(R.string.accept),
614 new DialogInterface.OnClickListener() {
615 @Override
616 public void onClick(DialogInterface dialog, int which) {
617 mAccount.getAxolotlService().wipeOtherPepDevices();
618 }
619 });
620 builder.create().show();
621 }
622}