mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-27 19:22:15 -05:00
Merge branch 'issue_#2336' of https://github.com/vikiCoder/Conversations into vikiCoder-issue_#2336
This commit is contained in:
commit
bb7780eae6
@ -2,17 +2,23 @@ package eu.siacs.conversations.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 eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||
|
||||
public class BlocklistActivity extends AbstractSearchableListItemActivity implements OnUpdateBlocklist {
|
||||
private List<String> mKnownHosts = new ArrayList<String>();
|
||||
|
||||
private Account account = null;
|
||||
|
||||
@ -41,6 +47,7 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
|
||||
}
|
||||
}
|
||||
filterContacts();
|
||||
this.mKnownHosts = xmppConnectionService.getKnownHosts();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,6 +65,42 @@ 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) {
|
||||
|
@ -571,9 +571,8 @@ 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);
|
||||
}
|
||||
|
@ -14,4 +14,11 @@
|
||||
android:showAsAction="always"
|
||||
android:title="@string/create_contact"
|
||||
android:visible="false"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_contact"
|
||||
android:icon="?attr/icon_add_person"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/block_jabber_id"
|
||||
android:visible="false"/>
|
||||
</menu>
|
||||
|
@ -177,6 +177,7 @@
|
||||
<string name="mgmt_account_delete_confirm_text">If you delete your account your entire conversation history will be lost</string>
|
||||
<string name="attach_record_voice">Record voice</string>
|
||||
<string name="account_settings_jabber_id">Jabber ID</string>
|
||||
<string name="block_jabber_id">Block Jabber ID</string>
|
||||
<string name="account_settings_password">Password</string>
|
||||
<string name="account_settings_example_jabber_id">username@example.com</string>
|
||||
<string name="account_settings_confirm_password">Confirm password</string>
|
||||
|
Loading…
Reference in New Issue
Block a user