use data binder for inflating muc items
This commit is contained in:
parent
fb383c7881
commit
595757fe00
|
@ -1,5 +1,6 @@
|
||||||
package eu.siacs.conversations.ui;
|
package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
|
import android.databinding.DataBindingUtil;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -38,6 +39,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.crypto.PgpEngine;
|
import eu.siacs.conversations.crypto.PgpEngine;
|
||||||
|
import eu.siacs.conversations.databinding.ContactBinding;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Bookmark;
|
import eu.siacs.conversations.entities.Bookmark;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
|
@ -604,54 +606,42 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
mNotifyStatusText.setText(R.string.notify_only_when_highlighted);
|
mNotifyStatusText.setText(R.string.notify_only_when_highlighted);
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
membersView.removeAllViews();
|
membersView.removeAllViews();
|
||||||
|
if (inflater == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final ArrayList<User> users = mucOptions.getUsers();
|
final ArrayList<User> users = mucOptions.getUsers();
|
||||||
Collections.sort(users);
|
Collections.sort(users);
|
||||||
for (final User user : users) {
|
for (final User user : users) {
|
||||||
View view = inflater.inflate(R.layout.contact, membersView,false);
|
ContactBinding binding = DataBindingUtil.inflate(inflater,R.layout.contact,membersView,false);
|
||||||
this.setListItemBackgroundOnView(view);
|
this.setListItemBackgroundOnView(binding.getRoot());
|
||||||
view.setOnClickListener(new OnClickListener() {
|
binding.getRoot().setOnClickListener(view1 -> highlightInMuc(mConversation, user.getName()));
|
||||||
@Override
|
registerForContextMenu(binding.getRoot());
|
||||||
public void onClick(View view) {
|
binding.getRoot().setTag(user);
|
||||||
highlightInMuc(mConversation, user.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
registerForContextMenu(view);
|
|
||||||
view.setTag(user);
|
|
||||||
TextView tvDisplayName = (TextView) view.findViewById(R.id.contact_display_name);
|
|
||||||
TextView tvKey = (TextView) view.findViewById(R.id.key);
|
|
||||||
TextView tvStatus = (TextView) view.findViewById(R.id.contact_jid);
|
|
||||||
if (mAdvancedMode && user.getPgpKeyId() != 0) {
|
if (mAdvancedMode && user.getPgpKeyId() != 0) {
|
||||||
tvKey.setVisibility(View.VISIBLE);
|
binding.key.setVisibility(View.VISIBLE);
|
||||||
tvKey.setOnClickListener(new OnClickListener() {
|
binding.key.setOnClickListener(v -> viewPgpKey(user));
|
||||||
|
binding.key.setText(OpenPgpUtils.convertKeyIdToHex(user.getPgpKeyId()));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
viewPgpKey(user);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tvKey.setText(OpenPgpUtils.convertKeyIdToHex(user.getPgpKeyId()));
|
|
||||||
}
|
}
|
||||||
Contact contact = user.getContact();
|
Contact contact = user.getContact();
|
||||||
String name = user.getName();
|
String name = user.getName();
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
tvDisplayName.setText(contact.getDisplayName());
|
binding.contactDisplayName.setText(contact.getDisplayName());
|
||||||
tvStatus.setText((name != null ? name+ " \u2022 " : "") + getStatus(user));
|
binding.contactJid.setText((name != null ? name+ " \u2022 " : "") + getStatus(user));
|
||||||
} else {
|
} else {
|
||||||
tvDisplayName.setText(name == null ? "" : name);
|
binding.contactDisplayName.setText(name == null ? "" : name);
|
||||||
tvStatus.setText(getStatus(user));
|
binding.contactJid.setText(getStatus(user));
|
||||||
|
|
||||||
}
|
}
|
||||||
ImageView iv = (ImageView) view.findViewById(R.id.contact_photo);
|
loadAvatar(user,binding.contactPhoto);
|
||||||
loadAvatar(user,iv);
|
|
||||||
if (user.getRole() == MucOptions.Role.NONE) {
|
if (user.getRole() == MucOptions.Role.NONE) {
|
||||||
tvDisplayName.setAlpha(INACTIVE_ALPHA);
|
binding.contactJid.setAlpha(INACTIVE_ALPHA);
|
||||||
tvKey.setAlpha(INACTIVE_ALPHA);
|
binding.key.setAlpha(INACTIVE_ALPHA);
|
||||||
tvStatus.setAlpha(INACTIVE_ALPHA);
|
binding.contactDisplayName.setAlpha(INACTIVE_ALPHA);
|
||||||
iv.setAlpha(INACTIVE_ALPHA);
|
binding.contactPhoto.setAlpha(INACTIVE_ALPHA);
|
||||||
}
|
}
|
||||||
membersView.addView(view);
|
membersView.addView(binding.getRoot());
|
||||||
if (mConversation.getMucOptions().canInvite()) {
|
if (mConversation.getMucOptions().canInvite()) {
|
||||||
mInviteButton.setVisibility(View.VISIBLE);
|
mInviteButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/activatedBackgroundIndicator"
|
android:background="?android:attr/activatedBackgroundIndicator"
|
||||||
|
@ -12,7 +14,7 @@
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:riv_corner_radius="2dp" />
|
app:riv_corner_radius="2dp"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -20,14 +22,14 @@
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_toRightOf="@+id/contact_photo"
|
android:layout_toRightOf="@+id/contact_photo"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="@dimen/avatar_item_distance" >
|
android:paddingLeft="@dimen/avatar_item_distance">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/contact_display_name"
|
android:id="@+id/contact_display_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/contact_jid"
|
android:id="@+id/contact_jid"
|
||||||
|
@ -35,6 +37,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="@style/TextAppearance.Conversations.Body1.Secondary"/>
|
android:textAppearance="@style/TextAppearance.Conversations.Body1.Secondary"/>
|
||||||
|
|
||||||
<com.wefika.flowlayout.FlowLayout
|
<com.wefika.flowlayout.FlowLayout
|
||||||
android:id="@+id/tags"
|
android:id="@+id/tags"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -42,15 +45,17 @@
|
||||||
android:layout_marginLeft="-2dp"
|
android:layout_marginLeft="-2dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
</com.wefika.flowlayout.FlowLayout>
|
</com.wefika.flowlayout.FlowLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/key"
|
android:id="@+id/key"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="monospace"
|
||||||
android:textColor="?attr/color_text_primary"
|
android:textColor="?attr/color_text_primary"
|
||||||
android:textSize="?attr/TextSizeBody"
|
android:textSize="?attr/TextSizeBody"
|
||||||
android:typeface="monospace"
|
android:typeface="monospace"
|
||||||
android:fontFamily="monospace"
|
android:visibility="gone"/>
|
||||||
android:visibility="gone" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
</layout>
|
Loading…
Reference in New Issue