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;
import java.util.ArrayList;
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.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Context;
import android.content.IntentSender.SendIntentException;
@ -31,9 +18,30 @@ import android.widget.LinearLayout;
import android.widget.TextView;
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 static final String ACTION_VIEW_MUC = "view_muc";
private Conversation conversation;
private OnClickListener inviteListener = new OnClickListener() {
@Override
public void onClick(View v) {
inviteToConversation(conversation);
}
};
private TextView mYourNick;
private ImageView mYourPhoto;
private ImageButton mEditNickButton;
@ -44,14 +52,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
private LinearLayout mMoreDetails;
private Button mInviteButton;
private String uuid = null;
private OnClickListener inviteListener = new OnClickListener() {
@Override
public void onClick(View v) {
inviteToConversation(conversation);
}
};
private List<User> users = new ArrayList<>();
@Override
public void onRename(final boolean success) {
@ -74,8 +75,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
});
}
private List<User> users = new ArrayList<>();
@Override
public void onConversationUpdate() {
runOnUiThread(new Runnable() {
@ -220,6 +219,13 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
for (final User user : conversation.getMucOptions().getUsers()) {
View view = inflater.inflate(R.layout.contact, membersView,
false);
this.setListItemBackgroundOnView(view);
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
highlightInMuc(conversation, user.getName());
}
});
TextView name = (TextView) view
.findViewById(R.id.contact_display_name);
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) {
PgpEngine pgp = xmppConnectionService.getPgpEngine();
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 CONVERSATION = "conversationUuid";
public static final String TEXT = "text";
public static final String NICK = "nick";
public static final String PRESENCE = "eu.siacs.conversations.presence";
public static final int REQUEST_SEND_MESSAGE = 0x0201;
@ -701,9 +702,14 @@ public class ConversationActivity extends XmppActivity implements
private void handleViewConversationIntent(Intent intent) {
String uuid = (String) intent.getExtras().get(CONVERSATION);
String text = intent.getExtras().getString(TEXT, "");
String nick = intent.getExtras().getString(NICK,null);
selectConversationByUuid(uuid);
this.mConversationFragment.reInit(getSelectedConversation());
if (nick!=null) {
this.mConversationFragment.highlightInConference(nick);
} else {
this.mConversationFragment.appendText(text);
}
hideConversationsOverview();
if (mContentView instanceof SlidingPaneLayout) {
openConversation();

View file

@ -301,6 +301,14 @@ public abstract class XmppActivity extends Activity {
public void switchToConversation(Conversation conversation, String text,
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,
ConversationActivity.class);
viewConversationIntent.setAction(Intent.ACTION_VIEW);
@ -309,6 +317,9 @@ public abstract class XmppActivity extends Activity {
if (text != null) {
viewConversationIntent.putExtra(ConversationActivity.TEXT, text);
}
if (nick != null) {
viewConversationIntent.putExtra(ConversationActivity.NICK, nick);
}
viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
if (newTask) {
viewConversationIntent.setFlags(viewConversationIntent.getFlags()

View file

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