Fix selection display with account colours

Stephen Paul Weber created

Change summary

src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java | 9 
src/main/res/layout/contact.xml                                      | 7 
2 files changed, 12 insertions(+), 4 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java 🔗

@@ -56,20 +56,23 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
 		LayoutInflater inflater = activity.getLayoutInflater();
 		ListItem item = getItem(position);
 		ViewHolder viewHolder;
+		View innerView;
 		if (view == null) {
 			ContactBinding binding = DataBindingUtil.inflate(inflater,R.layout.contact,parent,false);
 			viewHolder = ViewHolder.get(binding);
 			view = binding.getRoot();
+			innerView = binding.inner;
 		} else {
 			viewHolder = (ViewHolder) view.getTag();
+			innerView = view;
 		}
 
 		if (activity.xmppConnectionService != null && activity.xmppConnectionService.getAccounts().size() > 1) {
-			view.setBackgroundColor(item.getAccount().getColor(activity.isDarkTheme()));
-		} else {
-			view.setBackground(StyledAttributes.getDrawable(view.getContext(),R.attr.list_item_background));
+			innerView.setBackgroundColor(item.getAccount().getColor(activity.isDarkTheme()));
 		}
 
+		view.setBackground(StyledAttributes.getDrawable(view.getContext(),R.attr.list_item_background));
+
 		List<ListItem.Tag> tags = item.getTags(activity);
 		if (tags.size() == 0 || !this.showDynamicTags) {
 			viewHolder.tags.setVisibility(View.GONE);

src/main/res/layout/contact.xml 🔗

@@ -2,10 +2,14 @@
 <layout xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto">
 
+    <FrameLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="?selectableItemBackground">
     <RelativeLayout
+        android:id="@+id/inner"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="?selectableItemBackground"
         android:padding="@dimen/list_padding">
 
         <com.google.android.material.imageview.ShapeableImageView
@@ -56,4 +60,5 @@
         </LinearLayout>
 
     </RelativeLayout>
+    </FrameLayout>
 </layout>