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