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,18 +75,16 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}); });
} }
private List<User> users = new ArrayList<>(); @Override
public void onConversationUpdate() {
runOnUiThread(new Runnable() {
@Override @Override
public void onConversationUpdate() { public void run() {
runOnUiThread(new Runnable() { populateView();
}
@Override });
public void run() { }
populateView();
}
});
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -123,45 +122,45 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override @Override
public boolean onOptionsItemSelected(MenuItem menuItem) { public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case android.R.id.home: case android.R.id.home:
finish(); finish();
break; break;
case R.id.action_edit_subject: case R.id.action_edit_subject:
if (conversation != null) { if (conversation != null) {
quickEdit(conversation.getName(), new OnValueEdited() { quickEdit(conversation.getName(), new OnValueEdited() {
@Override @Override
public void onValueEdited(String value) { public void onValueEdited(String value) {
MessagePacket packet = xmppConnectionService MessagePacket packet = xmppConnectionService
.getMessageGenerator().conferenceSubject( .getMessageGenerator().conferenceSubject(
conversation, value); conversation, value);
xmppConnectionService.sendMessagePacket( xmppConnectionService.sendMessagePacket(
conversation.getAccount(), packet); conversation.getAccount(), packet);
} }
}); });
} }
break; break;
} }
return super.onOptionsItemSelected(menuItem); return super.onOptionsItemSelected(menuItem);
} }
public String getReadableRole(int role) { public String getReadableRole(int role) {
switch (role) { switch (role) {
case User.ROLE_MODERATOR: case User.ROLE_MODERATOR:
return getString(R.string.moderator); return getString(R.string.moderator);
case User.ROLE_PARTICIPANT: case User.ROLE_PARTICIPANT:
return getString(R.string.participant); return getString(R.string.participant);
case User.ROLE_VISITOR: case User.ROLE_VISITOR:
return getString(R.string.visitor); return getString(R.string.visitor);
default: default:
return ""; return "";
} }
} }
@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 "";
} }
@ -200,17 +199,17 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
mMoreDetails.setVisibility(View.VISIBLE); mMoreDetails.setVisibility(View.VISIBLE);
User self = conversation.getMucOptions().getSelf(); User self = conversation.getMucOptions().getSelf();
switch (self.getAffiliation()) { switch (self.getAffiliation()) {
case User.AFFILIATION_ADMIN: case User.AFFILIATION_ADMIN:
mRoleAffiliaton.setText(getReadableRole(self.getRole()) + " (" mRoleAffiliaton.setText(getReadableRole(self.getRole()) + " ("
+ getString(R.string.admin) + ")"); + getString(R.string.admin) + ")");
break; break;
case User.AFFILIATION_OWNER: case User.AFFILIATION_OWNER:
mRoleAffiliaton.setText(getReadableRole(self.getRole()) + " (" mRoleAffiliaton.setText(getReadableRole(self.getRole()) + " ("
+ getString(R.string.owner) + ")"); + getString(R.string.owner) + ")");
break; break;
default: default:
mRoleAffiliaton.setText(getReadableRole(self.getRole())); mRoleAffiliaton.setText(getReadableRole(self.getRole()));
break; break;
} }
} }
this.users.clear(); this.users.clear();
@ -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());
this.mConversationFragment.appendText(text); if (nick!=null) {
this.mConversationFragment.highlightInConference(nick);
} else {
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>