aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-03-09 19:31:40 +0100
committerChristian Schneppe <christian@pix-art.de>2017-03-09 19:31:40 +0100
commite1ff6b02f53ef6fcd3732b78607beedd88da916a (patch)
tree1b79a32ede95add24e3f1800eb8e8ae70899fc78 /src/main/java/de/pixart/messenger/ui
parente20e7893a546b700e5a4ca00d523cf078bb28747 (diff)
added an option to directly add a jid to block list from blocklist activity
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/BlocklistActivity.java43
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java2
2 files changed, 42 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/BlocklistActivity.java b/src/main/java/de/pixart/messenger/ui/BlocklistActivity.java
index cb5a0112b..c1d388231 100644
--- a/src/main/java/de/pixart/messenger/ui/BlocklistActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/BlocklistActivity.java
@@ -2,18 +2,23 @@ package de.pixart.messenger.ui;
import android.os.Bundle;
import android.text.Editable;
+import android.view.Menu;
+import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
+import de.pixart.messenger.R;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.xmpp.OnUpdateBlocklist;
import de.pixart.messenger.xmpp.jid.Jid;
public class BlocklistActivity extends AbstractSearchableListItemActivity implements OnUpdateBlocklist {
-
+ private List<String> mKnownHosts = new ArrayList<String>();
private Account account = null;
@Override
@@ -41,6 +46,7 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
}
}
filterContacts();
+ this.mKnownHosts = xmppConnectionService.getKnownHosts();
}
@Override
@@ -58,6 +64,41 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
getListItemAdapter().notifyDataSetChanged();
}
+ @Override
+ public boolean onCreateOptionsMenu(final Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ menu.findItem(R.id.action_add_contact).setVisible(true);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_add_contact:
+ showEnterJidDialog();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ protected void showEnterJidDialog() {
+ EnterJidDialog dialog = new EnterJidDialog(
+ this, mKnownHosts, null,
+ getString(R.string.block_jabber_id), getString(R.string.block),
+ null, account.getJid().toBareJid().toString(), true
+ );
+
+ dialog.setOnEnterJidDialogPositiveListener(new EnterJidDialog.OnEnterJidDialogPositiveListener() {
+ @Override
+ public boolean onEnterJidDialogPositive(Jid accountJid, Jid contactJid) throws EnterJidDialog.JidError {
+ Contact contact = account.getRoster().getContact(contactJid);
+ xmppConnectionService.sendBlockRequest(contact, false);
+ return true;
+ }
+ });
+ dialog.show();
+ }
+
protected void refreshUiReal() {
final Editable editable = getSearchEditText().getText();
if (editable != null) {
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index c578a5931..fd18df172 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -575,8 +575,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
if (mAccount != null && mAccount.isOnlineAndConnected()) {
if (!mAccount.getXmppConnection().getFeatures().blocking()) {
showBlocklist.setVisible(false);
- } else {
- showBlocklist.setEnabled(mAccount.getBlocklist().size() > 0);
}
if (!mAccount.getXmppConnection().getFeatures().register()) {
changePassword.setVisible(false);