revised manage account activity. removed contexual action mode
This commit is contained in:
parent
6345217328
commit
06da080371
|
@ -4,6 +4,16 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/primarybackground" >
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/button_bar"
|
||||
android:layout_alignParentTop="true">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/editor"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -72,28 +82,25 @@
|
|||
android:id="@+id/stats"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_above="@+id/button_bar"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/editor"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp"
|
||||
android:visibility="gone">
|
||||
android:visibility="gone" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/secondarytext"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/additional_information"
|
||||
android:gravity="center_horizontal"/>
|
||||
android:textColor="@color/secondarytext"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:stretchColumns="1"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="8dp"
|
||||
android:stretchColumns="1" >
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -127,7 +134,28 @@
|
|||
android:layout_gravity="right" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/otr_fingerprint_headline"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/otr_fingerprint"
|
||||
android:textColor="@color/secondarytext"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/otr_fingerprint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textSize="14sp"
|
||||
android:typeface="monospace" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_bar"
|
||||
|
@ -135,7 +163,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true">
|
||||
android:layout_alignParentRight="true" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/otr_no_fingerprint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/no_otr_fingerprint"
|
||||
android:visibility="visible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/otr_fingerprint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:typeface="monospace"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -2,39 +2,20 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/mgmt_account_edit"
|
||||
android:icon="@drawable/ic_action_edit"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/mgmt_account_edit"/>
|
||||
android:id="@+id/mgmt_account_enable"
|
||||
android:title="@string/mgmt_account_enable"/>
|
||||
<item
|
||||
android:id="@+id/mgmt_account_delete"
|
||||
android:icon="@drawable/ic_action_discard"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/mgmt_account_delete"/>
|
||||
android:id="@+id/mgmt_account_publish_avatar"
|
||||
android:title="@string/mgmt_account_publish_avatar"/>
|
||||
<item
|
||||
android:id="@+id/mgmt_account_announce_pgp"
|
||||
android:title="@string/mgmt_account_publish_pgp"/>
|
||||
<item
|
||||
android:id="@+id/mgmt_account_disable"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/mgmt_account_disable"/>
|
||||
<item
|
||||
android:id="@+id/mgmt_account_enable"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/mgmt_account_enable"
|
||||
android:visible="false"/>
|
||||
<item
|
||||
android:id="@+id/mgmt_account_announce_pgp"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/announce_pgp"/>
|
||||
<item
|
||||
android:id="@+id/mgmt_account_publish_avatar"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/mgmt_account_publish_avatar"/>
|
||||
<item
|
||||
android:id="@+id/mgmt_otr_key"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/show_otr_key"/>
|
||||
<item
|
||||
android:id="@+id/mgmt_account_info"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/account_info"/>
|
||||
android:id="@+id/mgmt_account_delete"
|
||||
android:title="@string/mgmt_account_delete"/>
|
||||
|
||||
</menu>
|
|
@ -184,11 +184,11 @@
|
|||
<string name="encryption_choice_none">Plain text</string>
|
||||
<string name="encryption_choice_otr">OTR</string>
|
||||
<string name="encryption_choice_pgp">OpenPGP</string>
|
||||
<string name="mgmt_account_edit">Edit account</string>
|
||||
<string name="mgmt_account_delete">Delete</string>
|
||||
<string name="mgmt_account_delete">Delete account</string>
|
||||
<string name="mgmt_account_disable">Temporarily disable</string>
|
||||
<string name="mgmt_account_publish_avatar">Publish avatar</string>
|
||||
<string name="mgmt_account_enable">Enable</string>
|
||||
<string name="mgmt_account_publish_pgp">Publish OpenPGP public key</string>
|
||||
<string name="mgmt_account_enable">Enable account</string>
|
||||
<string name="mgmt_account_are_you_sure">Are you sure?</string>
|
||||
<string name="mgmt_account_delete_confirm_text">If you delete your account your entire conversation history will be lost</string>
|
||||
<string name="mgmt_account_account_offline">Account is offline</string>
|
||||
|
|
|
@ -3,8 +3,6 @@ package eu.siacs.conversations.ui;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
|
@ -13,7 +11,6 @@ import android.widget.CheckBox;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.TextView;
|
||||
import eu.siacs.conversations.R;
|
||||
|
@ -36,6 +33,8 @@ public class EditAccountActivity extends XmppActivity {
|
|||
private LinearLayout mStats;
|
||||
private TextView mServerCompat;
|
||||
private TextView mSessionEst;
|
||||
private TextView mOtrFingerprint;
|
||||
private TextView mOtrFingerprintHeadline;
|
||||
|
||||
private String jidToEdit;
|
||||
private Account mAccount;
|
||||
|
@ -46,8 +45,9 @@ public class EditAccountActivity extends XmppActivity {
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mAccount != null && mAccount.errorStatus()) {
|
||||
xmppConnectionService.reconnectAccount(mAccount, true);
|
||||
if (!Validator.isValidJid(mAccountJid.getText().toString())) {
|
||||
mAccountJid.setError(getString(R.string.invalid_jid));
|
||||
mAccountJid.requestFocus();
|
||||
return;
|
||||
}
|
||||
boolean registerNewAccount = mRegisterNew.isChecked();
|
||||
|
@ -65,6 +65,7 @@ public class EditAccountActivity extends XmppActivity {
|
|||
if (!password.equals(passwordConfirm)) {
|
||||
mPasswordConfirm
|
||||
.setError(getString(R.string.passwords_do_not_match));
|
||||
mPasswordConfirm.requestFocus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -72,22 +73,20 @@ public class EditAccountActivity extends XmppActivity {
|
|||
mAccount.setPassword(password);
|
||||
mAccount.setUsername(username);
|
||||
mAccount.setServer(server);
|
||||
mAccount.setOption(Account.OPTION_REGISTER,
|
||||
mRegisterNew.isChecked());
|
||||
mAccount.setOption(Account.OPTION_REGISTER,registerNewAccount);
|
||||
xmppConnectionService.updateAccount(mAccount);
|
||||
} else {
|
||||
if (xmppConnectionService.findAccountByJid(mAccountJid
|
||||
.getText().toString()) != null) {
|
||||
mAccountJid
|
||||
.setError(getString(R.string.account_already_exists));
|
||||
mAccountJid.requestFocus();
|
||||
return;
|
||||
}
|
||||
mAccount = new Account(username, server, password);
|
||||
mAccount.setOption(Account.OPTION_USETLS, true);
|
||||
mAccount.setOption(Account.OPTION_USECOMPRESSION, true);
|
||||
if (registerNewAccount) {
|
||||
mAccount.setOption(Account.OPTION_REGISTER, true);
|
||||
}
|
||||
mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount);
|
||||
xmppConnectionService.createAccount(mAccount);
|
||||
}
|
||||
if (jidToEdit != null) {
|
||||
|
@ -114,9 +113,6 @@ public class EditAccountActivity extends XmppActivity {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAccount != null) {
|
||||
updateAccountInformation();
|
||||
}
|
||||
if (jidToEdit == null && mAccount != null
|
||||
&& mAccount.getStatus() == Account.STATUS_ONLINE) {
|
||||
if (!mFetchingAvatar) {
|
||||
|
@ -127,6 +123,9 @@ public class EditAccountActivity extends XmppActivity {
|
|||
} else {
|
||||
updateSaveButton();
|
||||
}
|
||||
if (mAccount != null) {
|
||||
updateAccountInformation();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -210,6 +209,8 @@ public class EditAccountActivity extends XmppActivity {
|
|||
this.mStats = (LinearLayout) findViewById(R.id.stats);
|
||||
this.mSessionEst = (TextView) findViewById(R.id.session_est);
|
||||
this.mServerCompat = (TextView) findViewById(R.id.server_compat);
|
||||
this.mOtrFingerprint = (TextView) findViewById(R.id.otr_fingerprint);
|
||||
this.mOtrFingerprintHeadline = (TextView) findViewById(R.id.otr_fingerprint_headline);
|
||||
this.mSaveButton = (Button) findViewById(R.id.save_button);
|
||||
this.mCancelButton = (Button) findViewById(R.id.cancel_button);
|
||||
this.mSaveButton.setOnClickListener(this.mSaveButtonClickListener);
|
||||
|
@ -274,7 +275,7 @@ public class EditAccountActivity extends XmppActivity {
|
|||
this.mRegisterNew.setVisibility(View.GONE);
|
||||
this.mRegisterNew.setChecked(false);
|
||||
}
|
||||
if (this.mAccount.getStatus() == Account.STATUS_ONLINE) {
|
||||
if (this.mAccount.getStatus() == Account.STATUS_ONLINE && !this.mFetchingAvatar) {
|
||||
this.mStats.setVisibility(View.VISIBLE);
|
||||
this.mSessionEst.setText(UIHelper.readableTimeDifference(
|
||||
getApplicationContext(), this.mAccount.getXmppConnection()
|
||||
|
@ -282,6 +283,15 @@ public class EditAccountActivity extends XmppActivity {
|
|||
this.mServerCompat.setText(this.mAccount.getXmppConnection()
|
||||
.getFeatures().getCompatibility()
|
||||
+ "%");
|
||||
String fingerprint = this.mAccount.getOtrFingerprint(getApplicationContext());
|
||||
if (fingerprint!=null) {
|
||||
this.mOtrFingerprintHeadline.setVisibility(View.VISIBLE);
|
||||
this.mOtrFingerprint.setVisibility(View.VISIBLE);
|
||||
this.mOtrFingerprint.setText(fingerprint);
|
||||
} else {
|
||||
this.mOtrFingerprint.setVisibility(View.GONE);
|
||||
this.mOtrFingerprintHeadline.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
if (this.mAccount.errorStatus()) {
|
||||
this.mAccountJid.setError(getString(this.mAccount
|
||||
|
|
|
@ -7,32 +7,26 @@ import eu.siacs.conversations.R;
|
|||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
||||
import eu.siacs.conversations.ui.adapter.AccountAdapter;
|
||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.view.ActionMode;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ManageAccountActivity extends XmppActivity {
|
||||
|
||||
protected boolean isActionMode = false;
|
||||
protected ActionMode actionMode;
|
||||
protected Account selectedAccountForActionMode = null;
|
||||
protected ManageAccountActivity activity = this;
|
||||
|
||||
protected boolean firstrun = true;
|
||||
protected Account selectedAccount = null;
|
||||
|
||||
protected List<Account> accountList = new ArrayList<Account>();
|
||||
protected ListView accountListView;
|
||||
|
@ -53,105 +47,6 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
}
|
||||
};
|
||||
|
||||
protected ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
if (selectedAccountForActionMode
|
||||
.isOptionSet(Account.OPTION_DISABLED)) {
|
||||
menu.findItem(R.id.mgmt_account_enable).setVisible(true);
|
||||
menu.findItem(R.id.mgmt_account_disable).setVisible(false);
|
||||
} else {
|
||||
menu.findItem(R.id.mgmt_account_disable).setVisible(true);
|
||||
menu.findItem(R.id.mgmt_account_enable).setVisible(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.manageaccounts_context, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(final ActionMode mode, MenuItem item) {
|
||||
if (item.getItemId() == R.id.mgmt_account_edit) {
|
||||
editAccount(selectedAccountForActionMode);
|
||||
} else if (item.getItemId() == R.id.mgmt_account_disable) {
|
||||
selectedAccountForActionMode.setOption(Account.OPTION_DISABLED,
|
||||
true);
|
||||
xmppConnectionService
|
||||
.updateAccount(selectedAccountForActionMode);
|
||||
mode.finish();
|
||||
} else if (item.getItemId() == R.id.mgmt_account_enable) {
|
||||
selectedAccountForActionMode.setOption(Account.OPTION_DISABLED,
|
||||
false);
|
||||
xmppConnectionService
|
||||
.updateAccount(selectedAccountForActionMode);
|
||||
mode.finish();
|
||||
} else if (item.getItemId() == R.id.mgmt_account_publish_avatar) {
|
||||
Intent intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class);
|
||||
intent.putExtra("account", selectedAccountForActionMode.getJid());
|
||||
startActivity(intent);
|
||||
} else if (item.getItemId() == R.id.mgmt_account_delete) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
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(selectedAccountForActionMode);
|
||||
selectedAccountForActionMode = null;
|
||||
mode.finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||
builder.create().show();
|
||||
} else if (item.getItemId() == R.id.mgmt_account_announce_pgp) {
|
||||
if (activity.hasPgp()) {
|
||||
mode.finish();
|
||||
announcePgp(selectedAccountForActionMode, null);
|
||||
} else {
|
||||
activity.showInstallPgpDialog();
|
||||
}
|
||||
} else if (item.getItemId() == R.id.mgmt_otr_key) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("OTR Fingerprint");
|
||||
String fingerprintTxt = selectedAccountForActionMode
|
||||
.getOtrFingerprint(getApplicationContext());
|
||||
View view = (View) getLayoutInflater().inflate(
|
||||
R.layout.otr_fingerprint, null);
|
||||
if (fingerprintTxt != null) {
|
||||
TextView fingerprint = (TextView) view
|
||||
.findViewById(R.id.otr_fingerprint);
|
||||
TextView noFingerprintView = (TextView) view
|
||||
.findViewById(R.id.otr_no_fingerprint);
|
||||
fingerprint.setText(fingerprintTxt);
|
||||
fingerprint.setVisibility(View.VISIBLE);
|
||||
noFingerprintView.setVisibility(View.GONE);
|
||||
}
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(getString(R.string.done), null);
|
||||
builder.create().show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
@ -160,7 +55,6 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
setContentView(R.layout.manage_accounts);
|
||||
|
||||
accountListView = (ListView) findViewById(R.id.account_list);
|
||||
final XmppActivity activity = this;
|
||||
this.mAccountAdapter = new AccountAdapter(this, accountList);
|
||||
accountListView.setAdapter(this.mAccountAdapter);
|
||||
accountListView.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
@ -168,34 +62,27 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View view,
|
||||
int position, long arg3) {
|
||||
if (!isActionMode) {
|
||||
editAccount(accountList.get(position));
|
||||
} else {
|
||||
selectedAccountForActionMode = accountList.get(position);
|
||||
actionMode.invalidate();
|
||||
}
|
||||
}
|
||||
});
|
||||
accountListView
|
||||
.setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
registerForContextMenu(accountListView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0,
|
||||
View view, int position, long arg3) {
|
||||
if (!isActionMode) {
|
||||
accountListView
|
||||
.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
accountListView.setItemChecked(position, true);
|
||||
selectedAccountForActionMode = accountList
|
||||
.get(position);
|
||||
actionMode = activity
|
||||
.startActionMode(mActionModeCallback);
|
||||
return true;
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
activity.getMenuInflater().inflate(R.menu.manageaccounts_context, menu);
|
||||
AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
|
||||
this.selectedAccount = accountList.get(acmi.position);
|
||||
if (this.selectedAccount.isOptionSet(Account.OPTION_DISABLED)) {
|
||||
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);
|
||||
} else {
|
||||
return false;
|
||||
menu.findItem(R.id.mgmt_account_enable).setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
menu.setHeaderTitle(this.selectedAccount.getJid());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -212,11 +99,6 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
this.accountList.clear();
|
||||
this.accountList.addAll(xmppConnectionService.getAccounts());
|
||||
mAccountAdapter.notifyDataSetChanged();
|
||||
if ((this.accountList.size() == 0) && (this.firstrun)) {
|
||||
getActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
getActionBar().setHomeButtonEnabled(false);
|
||||
this.firstrun = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -225,11 +107,34 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
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);
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_add_account:
|
||||
startActivity(new Intent(getApplicationContext(), EditAccountActivity.class));
|
||||
startActivity(new Intent(getApplicationContext(),
|
||||
EditAccountActivity.class));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -264,24 +169,46 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionModeStarted(ActionMode mode) {
|
||||
super.onActionModeStarted(mode);
|
||||
this.isActionMode = true;
|
||||
private void publishAvatar(Account account) {
|
||||
Intent intent = new Intent(getApplicationContext(),
|
||||
PublishProfilePictureActivity.class);
|
||||
intent.putExtra("account", account.getJid());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void disableAccount(Account account) {
|
||||
account.setOption(Account.OPTION_DISABLED, true);
|
||||
xmppConnectionService.updateAccount(account);
|
||||
}
|
||||
|
||||
private void enableAccount(Account account) {
|
||||
account.setOption(Account.OPTION_DISABLED, false);
|
||||
xmppConnectionService.updateAccount(account);
|
||||
}
|
||||
|
||||
private void publishOpenPGPPublicKey(Account account) {
|
||||
if (activity.hasPgp()) {
|
||||
announcePgp(account, null);
|
||||
} else {
|
||||
this.showInstallPgpDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteAccount(final Account account) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
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 onActionModeFinished(ActionMode mode) {
|
||||
super.onActionModeFinished(mode);
|
||||
this.isActionMode = false;
|
||||
accountListView.clearChoices();
|
||||
accountListView.requestLayout();
|
||||
accountListView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
accountListView.setChoiceMode(ListView.CHOICE_MODE_NONE);
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
xmppConnectionService.deleteAccount(account);
|
||||
selectedAccount = null;
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -289,7 +216,7 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == REQUEST_ANNOUNCE_PGP) {
|
||||
announcePgp(selectedAccountForActionMode, null);
|
||||
announcePgp(selectedAccount, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue