aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-07-10 19:42:37 +0200
committeriNPUTmice <daniel@gultsch.de>2014-07-10 19:42:37 +0200
commita523127a805db12a82701ccf7cf6a21d979607d2 (patch)
tree3a0abf186f80123c9070a7b5e7d107bc0e7b6960 /src/eu/siacs/conversations/ui
parente97b5244552c8da06b3311bccb831be30c9a641a (diff)
fixed #38
Diffstat (limited to 'src/eu/siacs/conversations/ui')
-rw-r--r--src/eu/siacs/conversations/ui/EditAccount.java23
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java2
-rw-r--r--src/eu/siacs/conversations/ui/StartConversation.java11
3 files changed, 29 insertions, 7 deletions
diff --git a/src/eu/siacs/conversations/ui/EditAccount.java b/src/eu/siacs/conversations/ui/EditAccount.java
index e1bcaeb5..9a0b8d84 100644
--- a/src/eu/siacs/conversations/ui/EditAccount.java
+++ b/src/eu/siacs/conversations/ui/EditAccount.java
@@ -1,14 +1,19 @@
package eu.siacs.conversations.ui;
+import java.util.List;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.utils.KnownHostsAdapter;
import eu.siacs.conversations.utils.Validator;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
+import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
@@ -19,6 +24,8 @@ import android.widget.TextView;
public class EditAccount extends DialogFragment {
protected Account account;
+
+ protected AutoCompleteTextView mAccountJid;
public void setAccount(Account account) {
this.account = account;
@@ -30,16 +37,28 @@ public class EditAccount extends DialogFragment {
protected EditAccountListener listener = null;
+ private KnownHostsAdapter mKnownHostsAdapter;
+
public void setEditAccountListener(EditAccountListener listener) {
this.listener = listener;
}
+
+ public void setKnownHosts(List<String> hosts, Context context) {
+ this.mKnownHostsAdapter = new KnownHostsAdapter(context, android.R.layout.simple_list_item_1, hosts);
+ if (this.mAccountJid != null) {
+ this.mAccountJid.setAdapter(this.mKnownHostsAdapter);
+ }
+ }
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.edit_account_dialog, null);
- final EditText jidText = (EditText) view.findViewById(R.id.account_jid);
+ mAccountJid = (AutoCompleteTextView) view.findViewById(R.id.account_jid);
+ if (this.mKnownHostsAdapter!=null) {
+ mAccountJid.setAdapter(this.mKnownHostsAdapter);
+ }
final TextView confirmPwDesc = (TextView) view
.findViewById(R.id.account_confirm_password_desc);
@@ -51,7 +70,7 @@ public class EditAccount extends DialogFragment {
.findViewById(R.id.edit_account_register_new);
if (account != null) {
- jidText.setText(account.getJid());
+ mAccountJid.setText(account.getJid());
password.setText(account.getPassword());
if (account.isOptionSet(Account.OPTION_REGISTER)) {
registerAccount.setChecked(true);
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index c52916a2..f72e3d93 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -433,6 +433,7 @@ public class ManageAccountActivity extends XmppActivity {
}
});
dialog.show(getFragmentManager(), "edit_account");
+ dialog.setKnownHosts(xmppConnectionService.getKnownHosts(),this);
}
@@ -449,6 +450,7 @@ public class ManageAccountActivity extends XmppActivity {
}
});
dialog.show(getFragmentManager(), "add_account");
+ dialog.setKnownHosts(xmppConnectionService.getKnownHosts(),this);
}
diff --git a/src/eu/siacs/conversations/ui/StartConversation.java b/src/eu/siacs/conversations/ui/StartConversation.java
index 880b4a9b..3986929f 100644
--- a/src/eu/siacs/conversations/ui/StartConversation.java
+++ b/src/eu/siacs/conversations/ui/StartConversation.java
@@ -12,8 +12,6 @@ import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ListFragment;
import android.content.Context;
-import android.content.DialogInterface;
-import android.database.DataSetObserver;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v13.app.FragmentPagerAdapter;
@@ -29,11 +27,10 @@ import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
-import android.widget.EditText;
+import android.widget.AutoCompleteTextView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SearchView;
-import android.widget.SpinnerAdapter;
import android.widget.SearchView.OnQueryTextListener;
import android.widget.Spinner;
import android.widget.TextView;
@@ -42,6 +39,7 @@ import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.ListItem;
+import eu.siacs.conversations.utils.KnownHostsAdapter;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.utils.Validator;
@@ -61,6 +59,7 @@ public class StartConversation extends XmppActivity {
private ArrayAdapter<ListItem> mConferenceAdapter;
private List<String> mActivatedAccounts = new ArrayList<String>();
+ private List<String> mKnownHosts;
private TabListener mTabListener = new TabListener() {
@@ -176,7 +175,8 @@ public class StartConversation extends XmppActivity {
builder.setTitle(R.string.create_contact);
View dialogView = getLayoutInflater().inflate(R.layout.create_contact_dialog, null);
final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
- final EditText jid = (EditText) dialogView.findViewById(R.id.jid);
+ final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
+ jid.setAdapter(new KnownHostsAdapter(this, android.R.layout.simple_list_item_1, mKnownHosts));
populateAccountSpinner(spinner);
builder.setView(dialogView);
builder.setNegativeButton(R.string.cancel, null);
@@ -259,6 +259,7 @@ public class StartConversation extends XmppActivity {
this.mActivatedAccounts.add(account.getJid());
}
}
+ this.mKnownHosts = xmppConnectionService.getKnownHosts();
}
protected void filterContacts(String needle) {