highlight muc members by touching their name in muc details. fixed #503

This commit is contained in:
iNPUTmice 2014-11-17 01:54:01 +01:00
parent 2036c58cd7
commit 967cd922e1
4 changed files with 106 additions and 73 deletions

View File

@ -1,19 +1,6 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import java.util.ArrayList; import android.annotation.SuppressLint;
import java.util.List;
import org.openintents.openpgp.util.OpenPgpUtils;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.MucOptions.OnRenameListener;
import eu.siacs.conversations.entities.MucOptions.User;
import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.IntentSender.SendIntentException; import android.content.IntentSender.SendIntentException;
@ -31,9 +18,30 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.openintents.openpgp.util.OpenPgpUtils;
import java.util.ArrayList;
import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.MucOptions.OnRenameListener;
import eu.siacs.conversations.entities.MucOptions.User;
import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnRenameListener { public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnRenameListener {
public static final String ACTION_VIEW_MUC = "view_muc"; public static final String ACTION_VIEW_MUC = "view_muc";
private Conversation conversation; private Conversation conversation;
private OnClickListener inviteListener = new OnClickListener() {
@Override
public void onClick(View v) {
inviteToConversation(conversation);
}
};
private TextView mYourNick; private TextView mYourNick;
private ImageView mYourPhoto; private ImageView mYourPhoto;
private ImageButton mEditNickButton; private ImageButton mEditNickButton;
@ -44,14 +52,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
private LinearLayout mMoreDetails; private LinearLayout mMoreDetails;
private Button mInviteButton; private Button mInviteButton;
private String uuid = null; private String uuid = null;
private List<User> users = new ArrayList<>();
private OnClickListener inviteListener = new OnClickListener() {
@Override
public void onClick(View v) {
inviteToConversation(conversation);
}
};
@Override @Override
public void onRename(final boolean success) { public void onRename(final boolean success) {
@ -74,8 +75,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}); });
} }
private List<User> users = new ArrayList<>();
@Override @Override
public void onConversationUpdate() { public void onConversationUpdate() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@ -160,8 +159,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override @Override
protected String getShareableUri() { protected String getShareableUri() {
if (conversation!=null) { if (conversation != null) {
return "xmpp:"+conversation.getContactJid().toBareJid().toString()+"?join"; return "xmpp:" + conversation.getContactJid().toBareJid().toString() + "?join";
} else { } else {
return ""; return "";
} }
@ -220,6 +219,13 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
for (final User user : conversation.getMucOptions().getUsers()) { for (final User user : conversation.getMucOptions().getUsers()) {
View view = inflater.inflate(R.layout.contact, membersView, View view = inflater.inflate(R.layout.contact, membersView,
false); false);
this.setListItemBackgroundOnView(view);
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
highlightInMuc(conversation, user.getName());
}
});
TextView name = (TextView) view TextView name = (TextView) view
.findViewById(R.id.contact_display_name); .findViewById(R.id.contact_display_name);
TextView key = (TextView) view.findViewById(R.id.key); TextView key = (TextView) view.findViewById(R.id.key);
@ -253,6 +259,16 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
} }
} }
@SuppressLint("JELLY_BEAN")
private void setListItemBackgroundOnView(View view) {
int sdk = android.os.Build.VERSION.SDK_INT;
if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
view.setBackgroundDrawable(getResources().getDrawable(R.drawable.greybackground));
} else {
view.setBackground(getResources().getDrawable(R.drawable.greybackground));
}
}
private void viewPgpKey(User user) { private void viewPgpKey(User user) {
PgpEngine pgp = xmppConnectionService.getPgpEngine(); PgpEngine pgp = xmppConnectionService.getPgpEngine();
if (pgp != null) { if (pgp != null) {

View File

@ -47,6 +47,7 @@ public class ConversationActivity extends XmppActivity implements
public static final String VIEW_CONVERSATION = "viewConversation"; public static final String VIEW_CONVERSATION = "viewConversation";
public static final String CONVERSATION = "conversationUuid"; public static final String CONVERSATION = "conversationUuid";
public static final String TEXT = "text"; public static final String TEXT = "text";
public static final String NICK = "nick";
public static final String PRESENCE = "eu.siacs.conversations.presence"; public static final String PRESENCE = "eu.siacs.conversations.presence";
public static final int REQUEST_SEND_MESSAGE = 0x0201; public static final int REQUEST_SEND_MESSAGE = 0x0201;
@ -701,9 +702,14 @@ public class ConversationActivity extends XmppActivity implements
private void handleViewConversationIntent(Intent intent) { private void handleViewConversationIntent(Intent intent) {
String uuid = (String) intent.getExtras().get(CONVERSATION); String uuid = (String) intent.getExtras().get(CONVERSATION);
String text = intent.getExtras().getString(TEXT, ""); String text = intent.getExtras().getString(TEXT, "");
String nick = intent.getExtras().getString(NICK,null);
selectConversationByUuid(uuid); selectConversationByUuid(uuid);
this.mConversationFragment.reInit(getSelectedConversation()); this.mConversationFragment.reInit(getSelectedConversation());
if (nick!=null) {
this.mConversationFragment.highlightInConference(nick);
} else {
this.mConversationFragment.appendText(text); this.mConversationFragment.appendText(text);
}
hideConversationsOverview(); hideConversationsOverview();
if (mContentView instanceof SlidingPaneLayout) { if (mContentView instanceof SlidingPaneLayout) {
openConversation(); openConversation();

View File

@ -301,6 +301,14 @@ public abstract class XmppActivity extends Activity {
public void switchToConversation(Conversation conversation, String text, public void switchToConversation(Conversation conversation, String text,
boolean newTask) { boolean newTask) {
switchToConversation(conversation,text,null,newTask);
}
public void highlightInMuc(Conversation conversation, String nick) {
switchToConversation(conversation,null,nick,false);
}
private void switchToConversation(Conversation conversation, String text, String nick, boolean newTask) {
Intent viewConversationIntent = new Intent(this, Intent viewConversationIntent = new Intent(this,
ConversationActivity.class); ConversationActivity.class);
viewConversationIntent.setAction(Intent.ACTION_VIEW); viewConversationIntent.setAction(Intent.ACTION_VIEW);
@ -309,6 +317,9 @@ public abstract class XmppActivity extends Activity {
if (text != null) { if (text != null) {
viewConversationIntent.putExtra(ConversationActivity.TEXT, text); viewConversationIntent.putExtra(ConversationActivity.TEXT, text);
} }
if (nick != null) {
viewConversationIntent.putExtra(ConversationActivity.NICK, nick);
}
viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION); viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
if (newTask) { if (newTask) {
viewConversationIntent.setFlags(viewConversationIntent.getFlags() viewConversationIntent.setFlags(viewConversationIntent.getFlags()

View File

@ -2,6 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" > android:shape="rectangle" >
<solid android:color="#ffdddddd" /> <solid android:color="@color/divider" />
</shape> </shape>