diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java | 12 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java | 22 |
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 cab6e90e6..209c0a7b1 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 0865d1aaf..91fb021cc 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); + } + } |