2014-02-28 17:46:01 +00:00
|
|
|
package eu.siacs.conversations.ui;
|
2014-01-24 01:04:05 +00:00
|
|
|
|
2015-10-20 13:27:33 +00:00
|
|
|
import android.app.ActionBar;
|
2014-02-04 20:44:16 +00:00
|
|
|
import android.app.AlertDialog;
|
2015-10-20 13:27:33 +00:00
|
|
|
import android.content.ActivityNotFoundException;
|
2014-02-04 21:26:46 +00:00
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.DialogInterface.OnClickListener;
|
2014-01-28 18:21:54 +00:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
2015-10-09 11:37:08 +00:00
|
|
|
import android.security.KeyChain;
|
|
|
|
import android.security.KeyChainAliasCallback;
|
2015-12-01 13:18:07 +00:00
|
|
|
import android.util.Pair;
|
2014-08-20 09:32:49 +00:00
|
|
|
import android.view.ContextMenu;
|
2015-07-20 12:26:29 +00:00
|
|
|
import android.view.ContextMenu.ContextMenuInfo;
|
2014-01-28 18:21:54 +00:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.AdapterView;
|
2014-08-20 09:32:49 +00:00
|
|
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
2014-01-28 18:21:54 +00:00
|
|
|
import android.widget.AdapterView.OnItemClickListener;
|
|
|
|
import android.widget.ListView;
|
2015-10-09 11:37:08 +00:00
|
|
|
import android.widget.Toast;
|
2014-01-24 01:04:05 +00:00
|
|
|
|
2015-07-20 12:26:29 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2015-10-20 13:27:33 +00:00
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
2015-07-20 12:26:29 +00:00
|
|
|
|
2015-08-05 16:52:34 +00:00
|
|
|
import eu.siacs.conversations.Config;
|
2015-07-20 12:26:29 +00:00
|
|
|
import eu.siacs.conversations.R;
|
|
|
|
import eu.siacs.conversations.entities.Account;
|
2015-10-09 11:37:08 +00:00
|
|
|
import eu.siacs.conversations.services.XmppConnectionService;
|
2015-07-20 12:26:29 +00:00
|
|
|
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
|
|
|
import eu.siacs.conversations.ui.adapter.AccountAdapter;
|
2017-08-12 20:17:49 +00:00
|
|
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
2015-12-01 13:18:07 +00:00
|
|
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
|
|
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
|
|
|
|
2015-10-29 13:03:41 +00:00
|
|
|
import org.openintents.openpgp.util.OpenPgpApi;
|
2015-07-20 12:26:29 +00:00
|
|
|
|
2015-10-09 11:37:08 +00:00
|
|
|
public class ManageAccountActivity extends XmppActivity implements OnAccountUpdate, KeyChainAliasCallback, XmppConnectionService.OnAccountCreated {
|
2014-07-12 11:42:17 +00:00
|
|
|
|
2015-12-01 13:18:07 +00:00
|
|
|
private final String STATE_SELECTED_ACCOUNT = "selected_account";
|
|
|
|
|
2014-08-20 09:32:49 +00:00
|
|
|
protected Account selectedAccount = null;
|
2015-12-01 13:18:07 +00:00
|
|
|
protected Jid selectedAccountJid = null;
|
2014-07-12 11:42:17 +00:00
|
|
|
|
2015-01-03 12:36:48 +00:00
|
|
|
protected final List<Account> accountList = new ArrayList<>();
|
2014-01-28 18:21:54 +00:00
|
|
|
protected ListView accountListView;
|
2014-07-31 13:09:34 +00:00
|
|
|
protected AccountAdapter mAccountAdapter;
|
2015-10-20 13:27:33 +00:00
|
|
|
protected AtomicBoolean mInvokedAddAccount = new AtomicBoolean(false);
|
2015-01-03 12:36:48 +00:00
|
|
|
|
2015-12-01 13:18:07 +00:00
|
|
|
protected Pair<Integer, Intent> mPostponedActivityResult = null;
|
|
|
|
|
2015-01-03 12:36:48 +00:00
|
|
|
@Override
|
|
|
|
public void onAccountUpdate() {
|
2015-02-17 13:18:35 +00:00
|
|
|
refreshUi();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void refreshUiReal() {
|
2015-01-03 12:36:48 +00:00
|
|
|
synchronized (this.accountList) {
|
2014-02-04 14:09:50 +00:00
|
|
|
accountList.clear();
|
|
|
|
accountList.addAll(xmppConnectionService.getAccounts());
|
|
|
|
}
|
2015-10-20 13:27:33 +00:00
|
|
|
ActionBar actionBar = getActionBar();
|
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.setHomeButtonEnabled(this.accountList.size() > 0);
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0);
|
|
|
|
}
|
2015-02-17 13:18:35 +00:00
|
|
|
invalidateOptionsMenu();
|
|
|
|
mAccountAdapter.notifyDataSetChanged();
|
2015-01-03 12:36:48 +00:00
|
|
|
}
|
2014-07-12 11:42:17 +00:00
|
|
|
|
2014-01-28 18:21:54 +00:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
setContentView(R.layout.manage_accounts);
|
2014-02-04 14:09:50 +00:00
|
|
|
|
2015-12-01 13:18:07 +00:00
|
|
|
if (savedInstanceState != null) {
|
|
|
|
String jid = savedInstanceState.getString(STATE_SELECTED_ACCOUNT);
|
|
|
|
if (jid != null) {
|
|
|
|
try {
|
|
|
|
this.selectedAccountJid = Jid.fromString(jid);
|
|
|
|
} catch (InvalidJidException e) {
|
|
|
|
this.selectedAccountJid = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-28 18:21:54 +00:00
|
|
|
accountListView = (ListView) findViewById(R.id.account_list);
|
2014-07-31 13:09:34 +00:00
|
|
|
this.mAccountAdapter = new AccountAdapter(this, accountList);
|
|
|
|
accountListView.setAdapter(this.mAccountAdapter);
|
2014-01-28 18:21:54 +00:00
|
|
|
accountListView.setOnItemClickListener(new OnItemClickListener() {
|
|
|
|
|
|
|
|
@Override
|
2014-02-04 14:09:50 +00:00
|
|
|
public void onItemClick(AdapterView<?> arg0, View view,
|
2015-10-09 11:37:08 +00:00
|
|
|
int position, long arg3) {
|
2014-09-20 14:02:49 +00:00
|
|
|
switchToAccount(accountList.get(position));
|
2014-02-04 20:44:16 +00:00
|
|
|
}
|
|
|
|
});
|
2014-08-20 09:32:49 +00:00
|
|
|
registerForContextMenu(accountListView);
|
|
|
|
}
|
2014-01-28 18:21:54 +00:00
|
|
|
|
2016-09-18 18:26:47 +00:00
|
|
|
@Override
|
|
|
|
protected void onStart() {
|
|
|
|
super.onStart();
|
|
|
|
final int theme = findTheme();
|
|
|
|
if (this.mTheme != theme) {
|
|
|
|
recreate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-20 09:32:49 +00:00
|
|
|
@Override
|
2015-12-01 13:18:07 +00:00
|
|
|
public void onSaveInstanceState(final Bundle savedInstanceState) {
|
|
|
|
if (selectedAccount != null) {
|
|
|
|
savedInstanceState.putString(STATE_SELECTED_ACCOUNT, selectedAccount.getJid().toBareJid().toString());
|
|
|
|
}
|
|
|
|
super.onSaveInstanceState(savedInstanceState);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
2014-08-20 09:32:49 +00:00
|
|
|
super.onCreateContextMenu(menu, v, menuInfo);
|
2014-10-15 17:32:12 +00:00
|
|
|
ManageAccountActivity.this.getMenuInflater().inflate(
|
|
|
|
R.menu.manageaccounts_context, menu);
|
2015-12-01 13:18:07 +00:00
|
|
|
AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
|
2014-08-20 09:32:49 +00:00
|
|
|
this.selectedAccount = accountList.get(acmi.position);
|
2017-11-06 12:57:25 +00:00
|
|
|
if (this.selectedAccount.isEnabled()) {
|
|
|
|
menu.findItem(R.id.mgmt_account_enable).setVisible(false);
|
|
|
|
menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(Config.supportOpenPgp());
|
|
|
|
menu.findItem(R.id.mgmt_account_change_presence).setVisible(manuallyChangePresence());
|
|
|
|
} else {
|
2014-08-20 09:32:49 +00:00
|
|
|
menu.findItem(R.id.mgmt_account_disable).setVisible(false);
|
|
|
|
menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(false);
|
|
|
|
menu.findItem(R.id.mgmt_account_publish_avatar).setVisible(false);
|
2016-04-23 10:33:56 +00:00
|
|
|
menu.findItem(R.id.mgmt_account_change_presence).setVisible(false);
|
2014-08-20 09:32:49 +00:00
|
|
|
}
|
2014-11-09 15:57:22 +00:00
|
|
|
menu.setHeaderTitle(this.selectedAccount.getJid().toBareJid().toString());
|
2014-01-28 18:21:54 +00:00
|
|
|
}
|
2014-07-12 11:42:17 +00:00
|
|
|
|
2014-01-28 18:21:54 +00:00
|
|
|
@Override
|
|
|
|
void onBackendConnected() {
|
2015-12-01 13:18:07 +00:00
|
|
|
if (selectedAccountJid != null) {
|
|
|
|
this.selectedAccount = xmppConnectionService.findAccountByJid(selectedAccountJid);
|
|
|
|
}
|
2015-10-20 13:27:33 +00:00
|
|
|
refreshUiReal();
|
2015-12-01 13:18:07 +00:00
|
|
|
if (this.mPostponedActivityResult != null) {
|
|
|
|
this.onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second);
|
|
|
|
}
|
2015-10-20 13:27:33 +00:00
|
|
|
if (Config.X509_VERIFICATION && this.accountList.size() == 0) {
|
2015-12-01 13:18:07 +00:00
|
|
|
if (mInvokedAddAccount.compareAndSet(false, true)) {
|
2015-10-20 13:27:33 +00:00
|
|
|
addAccountFromKey();
|
|
|
|
}
|
|
|
|
}
|
2014-01-28 18:21:54 +00:00
|
|
|
}
|
2014-02-04 14:09:50 +00:00
|
|
|
|
2014-01-28 18:21:54 +00:00
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
getMenuInflater().inflate(R.menu.manageaccounts, menu);
|
2015-01-03 12:36:48 +00:00
|
|
|
MenuItem enableAll = menu.findItem(R.id.action_enable_all);
|
2015-10-12 11:18:20 +00:00
|
|
|
MenuItem addAccount = menu.findItem(R.id.action_add_account);
|
|
|
|
MenuItem addAccountWithCertificate = menu.findItem(R.id.action_add_account_with_cert);
|
|
|
|
|
|
|
|
if (Config.X509_VERIFICATION) {
|
|
|
|
addAccount.setVisible(false);
|
|
|
|
addAccountWithCertificate.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
|
|
}
|
|
|
|
|
2015-01-03 12:36:48 +00:00
|
|
|
if (!accountsLeftToEnable()) {
|
|
|
|
enableAll.setVisible(false);
|
|
|
|
}
|
|
|
|
MenuItem disableAll = menu.findItem(R.id.action_disable_all);
|
|
|
|
if (!accountsLeftToDisable()) {
|
|
|
|
disableAll.setVisible(false);
|
|
|
|
}
|
2014-01-28 18:21:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-02-04 14:09:50 +00:00
|
|
|
|
2014-08-20 09:32:49 +00:00
|
|
|
@Override
|
|
|
|
public boolean onContextItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
2015-12-01 13:18:07 +00:00
|
|
|
case R.id.mgmt_account_publish_avatar:
|
|
|
|
publishAvatar(selectedAccount);
|
|
|
|
return true;
|
|
|
|
case R.id.mgmt_account_disable:
|
|
|
|
disableAccount(selectedAccount);
|
|
|
|
return true;
|
|
|
|
case R.id.mgmt_account_enable:
|
|
|
|
enableAccount(selectedAccount);
|
|
|
|
return true;
|
|
|
|
case R.id.mgmt_account_delete:
|
|
|
|
deleteAccount(selectedAccount);
|
|
|
|
return true;
|
|
|
|
case R.id.mgmt_account_announce_pgp:
|
|
|
|
publishOpenPGPPublicKey(selectedAccount);
|
|
|
|
return true;
|
2016-04-23 10:33:56 +00:00
|
|
|
case R.id.mgmt_account_change_presence:
|
|
|
|
changePresence(selectedAccount);
|
|
|
|
return true;
|
2015-12-01 13:18:07 +00:00
|
|
|
default:
|
|
|
|
return super.onContextItemSelected(item);
|
2014-08-20 09:32:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-28 18:21:54 +00:00
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
2015-01-03 12:36:48 +00:00
|
|
|
case R.id.action_add_account:
|
|
|
|
startActivity(new Intent(getApplicationContext(),
|
|
|
|
EditAccountActivity.class));
|
|
|
|
break;
|
|
|
|
case R.id.action_disable_all:
|
|
|
|
disableAllAccounts();
|
|
|
|
break;
|
|
|
|
case R.id.action_enable_all:
|
|
|
|
enableAllAccounts();
|
|
|
|
break;
|
2015-10-12 11:18:20 +00:00
|
|
|
case R.id.action_add_account_with_cert:
|
2015-10-09 11:37:08 +00:00
|
|
|
addAccountFromKey();
|
|
|
|
break;
|
2015-01-03 12:36:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
2014-01-28 18:21:54 +00:00
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
2014-01-28 22:15:30 +00:00
|
|
|
|
2014-05-31 15:50:09 +00:00
|
|
|
@Override
|
|
|
|
public boolean onNavigateUp() {
|
|
|
|
if (xmppConnectionService.getConversations().size() == 0) {
|
2014-07-31 13:09:34 +00:00
|
|
|
Intent contactsIntent = new Intent(this,
|
|
|
|
StartConversationActivity.class);
|
2014-05-31 16:53:23 +00:00
|
|
|
contactsIntent.setFlags(
|
2015-12-01 13:18:07 +00:00
|
|
|
// if activity exists in stack, pop the stack and go back to it
|
2014-05-31 16:53:23 +00:00
|
|
|
Intent.FLAG_ACTIVITY_CLEAR_TOP |
|
2015-12-01 13:18:07 +00:00
|
|
|
// otherwise, make a new task for it
|
2014-07-12 11:42:17 +00:00
|
|
|
Intent.FLAG_ACTIVITY_NEW_TASK |
|
|
|
|
// don't use the new activity animation; finish
|
|
|
|
// animation runs instead
|
|
|
|
Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
2014-05-31 16:53:23 +00:00
|
|
|
startActivity(contactsIntent);
|
2014-05-31 15:50:09 +00:00
|
|
|
finish();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return super.onNavigateUp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-23 10:33:56 +00:00
|
|
|
private void changePresence(Account account) {
|
|
|
|
Intent intent = new Intent(this, SetPresenceActivity.class);
|
|
|
|
intent.putExtra(SetPresenceActivity.EXTRA_ACCOUNT,account.getJid().toBareJid().toString());
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2015-04-13 16:19:40 +00:00
|
|
|
public void onClickTglAccountState(Account account, boolean enable) {
|
|
|
|
if (enable) {
|
2015-04-01 10:14:05 +00:00
|
|
|
enableAccount(account);
|
|
|
|
} else {
|
|
|
|
disableAccount(account);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-09 11:37:08 +00:00
|
|
|
private void addAccountFromKey() {
|
2015-10-20 13:27:33 +00:00
|
|
|
try {
|
|
|
|
KeyChain.choosePrivateKeyAlias(this, this, null, null, null, -1, null);
|
|
|
|
} catch (ActivityNotFoundException e) {
|
2015-12-01 13:18:07 +00:00
|
|
|
Toast.makeText(this, R.string.device_does_not_support_certificates, Toast.LENGTH_LONG).show();
|
2015-10-20 13:27:33 +00:00
|
|
|
}
|
2015-10-09 11:37:08 +00:00
|
|
|
}
|
|
|
|
|
2014-08-20 09:32:49 +00:00
|
|
|
private void publishAvatar(Account account) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(),
|
|
|
|
PublishProfilePictureActivity.class);
|
2016-01-22 19:46:24 +00:00
|
|
|
intent.putExtra(EXTRA_ACCOUNT, account.getJid().toString());
|
2014-08-20 09:32:49 +00:00
|
|
|
startActivity(intent);
|
2014-02-04 20:44:16 +00:00
|
|
|
}
|
2014-07-12 11:42:17 +00:00
|
|
|
|
2015-01-03 12:36:48 +00:00
|
|
|
private void disableAllAccounts() {
|
|
|
|
List<Account> list = new ArrayList<>();
|
|
|
|
synchronized (this.accountList) {
|
|
|
|
for (Account account : this.accountList) {
|
2017-11-06 12:57:25 +00:00
|
|
|
if (account.isEnabled()) {
|
2015-01-03 12:36:48 +00:00
|
|
|
list.add(account);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-12-01 13:18:07 +00:00
|
|
|
for (Account account : list) {
|
2015-01-03 12:36:48 +00:00
|
|
|
disableAccount(account);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean accountsLeftToDisable() {
|
|
|
|
synchronized (this.accountList) {
|
|
|
|
for (Account account : this.accountList) {
|
2017-11-06 12:57:25 +00:00
|
|
|
if (account.isEnabled()) {
|
2015-01-03 12:36:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean accountsLeftToEnable() {
|
|
|
|
synchronized (this.accountList) {
|
|
|
|
for (Account account : this.accountList) {
|
2017-11-06 12:57:25 +00:00
|
|
|
if (!account.isEnabled()) {
|
2015-01-03 12:36:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void enableAllAccounts() {
|
|
|
|
List<Account> list = new ArrayList<>();
|
|
|
|
synchronized (this.accountList) {
|
|
|
|
for (Account account : this.accountList) {
|
2017-11-06 12:57:25 +00:00
|
|
|
if (!account.isEnabled()) {
|
2015-01-03 12:36:48 +00:00
|
|
|
list.add(account);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-12-01 13:18:07 +00:00
|
|
|
for (Account account : list) {
|
2015-01-03 12:36:48 +00:00
|
|
|
enableAccount(account);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-20 09:32:49 +00:00
|
|
|
private void disableAccount(Account account) {
|
|
|
|
account.setOption(Account.OPTION_DISABLED, true);
|
2016-09-07 12:34:58 +00:00
|
|
|
if (!xmppConnectionService.updateAccount(account)) {
|
|
|
|
Toast.makeText(this,R.string.unable_to_update_account,Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
2014-08-20 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void enableAccount(Account account) {
|
|
|
|
account.setOption(Account.OPTION_DISABLED, false);
|
2017-08-12 20:17:49 +00:00
|
|
|
final XmppConnection connection = account.getXmppConnection();
|
|
|
|
if (connection != null) {
|
|
|
|
connection.resetEverything();
|
|
|
|
}
|
2016-09-07 12:34:58 +00:00
|
|
|
if (!xmppConnectionService.updateAccount(account)) {
|
|
|
|
Toast.makeText(this,R.string.unable_to_update_account,Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
2014-08-20 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void publishOpenPGPPublicKey(Account account) {
|
2014-10-08 14:37:43 +00:00
|
|
|
if (ManageAccountActivity.this.hasPgp()) {
|
2016-05-05 11:17:04 +00:00
|
|
|
announcePgp(selectedAccount, null, onOpenPGPKeyPublished);
|
2014-08-20 09:32:49 +00:00
|
|
|
} else {
|
|
|
|
this.showInstallPgpDialog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void deleteAccount(final Account account) {
|
2014-10-15 17:32:12 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
|
|
|
ManageAccountActivity.this);
|
2014-08-20 09:32:49 +00:00
|
|
|
builder.setTitle(getString(R.string.mgmt_account_are_you_sure));
|
|
|
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
|
|
|
builder.setMessage(getString(R.string.mgmt_account_delete_confirm_text));
|
|
|
|
builder.setPositiveButton(getString(R.string.delete),
|
|
|
|
new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
xmppConnectionService.deleteAccount(account);
|
|
|
|
selectedAccount = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
|
|
|
builder.create().show();
|
2014-02-04 20:44:16 +00:00
|
|
|
}
|
2014-07-12 11:42:17 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
if (resultCode == RESULT_OK) {
|
2015-12-01 13:18:07 +00:00
|
|
|
if (xmppConnectionServiceBound) {
|
|
|
|
if (requestCode == REQUEST_CHOOSE_PGP_ID) {
|
|
|
|
if (data.getExtras().containsKey(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
|
|
|
|
selectedAccount.setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID));
|
2016-05-05 11:17:04 +00:00
|
|
|
announcePgp(selectedAccount, null, onOpenPGPKeyPublished);
|
2015-12-01 13:18:07 +00:00
|
|
|
} else {
|
|
|
|
choosePgpSignId(selectedAccount);
|
|
|
|
}
|
|
|
|
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
|
2016-05-05 11:17:04 +00:00
|
|
|
announcePgp(selectedAccount, null, onOpenPGPKeyPublished);
|
2015-10-29 13:03:41 +00:00
|
|
|
}
|
2015-12-01 13:18:07 +00:00
|
|
|
this.mPostponedActivityResult = null;
|
|
|
|
} else {
|
|
|
|
this.mPostponedActivityResult = new Pair<>(requestCode, data);
|
2014-05-08 14:52:19 +00:00
|
|
|
}
|
2014-07-12 11:42:17 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-09 11:37:08 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void alias(String alias) {
|
|
|
|
if (alias != null) {
|
|
|
|
xmppConnectionService.createAccountFromKey(alias, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAccountCreated(Account account) {
|
|
|
|
switchToAccount(account, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void informUser(final int r) {
|
|
|
|
runOnUiThread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2015-12-01 13:18:07 +00:00
|
|
|
Toast.makeText(ManageAccountActivity.this, r, Toast.LENGTH_LONG).show();
|
2015-10-09 11:37:08 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-01-24 01:04:05 +00:00
|
|
|
}
|