aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDaniel Gultsch <inputmice@siacs.eu>2015-01-02 14:47:08 +0100
committerDaniel Gultsch <inputmice@siacs.eu>2015-01-02 14:47:08 +0100
commitf58f27a1f74ee37092aa24a1187de32fe7e903ae (patch)
tree665d410dc10707350ac0b14148044a90666dd8d5 /src/main
parent093c5275c6edef12084006ad41e23e8bd7fdcfdc (diff)
click on dynamic tag to filter for that tag
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java12
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java22
2 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index cab6e90e..209c0a7b 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -160,6 +160,17 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
};
private MenuItem mMenuSearchView;
private String mInitialJid;
+ private ListItemAdapter.OnTagClickedListener mOnTagClickedListener = new ListItemAdapter.OnTagClickedListener() {
+ @Override
+ public void onTagClicked(String tag) {
+ if (mMenuSearchView != null) {
+ mMenuSearchView.expandActionView();
+ mSearchEditText.setText("");
+ mSearchEditText.append(tag);
+ filter(tag);
+ }
+ }
+ };
@Override
public void onRosterUpdate() {
@@ -221,6 +232,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
});
mContactsAdapter = new ListItemAdapter(this, contacts);
+ ((ListItemAdapter) mContactsAdapter).setOnTagClickedListener(this.mOnTagClickedListener);
mContactsListFragment.setListAdapter(mContactsAdapter);
mContactsListFragment.setContextMenu(R.menu.contact_context);
mContactsListFragment
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
index 0865d1aa..91fb021c 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
@@ -2,6 +2,7 @@ package eu.siacs.conversations.ui.adapter;
import java.util.List;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.ListItem;
import eu.siacs.conversations.ui.XmppActivity;
@@ -10,6 +11,7 @@ import eu.siacs.conversations.xmpp.jid.Jid;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -22,6 +24,17 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
protected XmppActivity activity;
protected boolean showDynamicTags = false;
+ private View.OnClickListener onTagTvClick = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (view instanceof TextView && mOnTagClickedListener != null) {
+ TextView tv = (TextView) view;
+ final String tag = tv.getText().toString();
+ mOnTagClickedListener.onTagClicked(tag);
+ }
+ }
+ };
+ private OnTagClickedListener mOnTagClickedListener = null;
public ListItemAdapter(XmppActivity activity, List<ListItem> objects) {
super(activity, 0, objects);
@@ -53,6 +66,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
TextView tv = (TextView) inflater.inflate(R.layout.list_item_tag,tagLayout,false);
tv.setText(tag.getName());
tv.setBackgroundColor(tag.getColor());
+ tv.setOnClickListener(this.onTagTvClick);
tagLayout.addView(tv);
}
}
@@ -68,4 +82,12 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
return view;
}
+ public void setOnTagClickedListener(OnTagClickedListener listener) {
+ this.mOnTagClickedListener = listener;
+ }
+
+ public interface OnTagClickedListener {
+ public void onTagClicked(String tag);
+ }
+
}