From 412bf162ceaaa27187981f830a69549313d341ea Mon Sep 17 00:00:00 2001
From: Torsten Grote <t@grobox.de>
Date: Fri, 8 Jul 2016 12:39:26 -0300
Subject: [PATCH] Show contact names under avatars before sending introduction

to make it clearer who will be introduced.
---
 .../res/layout/introduction_message.xml       | 93 +++++++++++++------
 .../IntroductionMessageFragment.java          |  7 ++
 2 files changed, 70 insertions(+), 30 deletions(-)

diff --git a/briar-android/res/layout/introduction_message.xml b/briar-android/res/layout/introduction_message.xml
index 9438479911..b56700fb72 100644
--- a/briar-android/res/layout/introduction_message.xml
+++ b/briar-android/res/layout/introduction_message.xml
@@ -1,38 +1,51 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
 	xmlns:android="http://schemas.android.com/apk/res/android"
-	xmlns:app="http://schemas.android.com/apk/res-auto"
 	xmlns:tools="http://schemas.android.com/tools"
 	android:layout_width="match_parent"
 	android:layout_height="match_parent"
 	android:fillViewport="true">
 
 	<LinearLayout
-		xmlns:android="http://schemas.android.com/apk/res/android"
-		xmlns:app="http://schemas.android.com/apk/res-auto"
-		xmlns:tools="http://schemas.android.com/tools"
 		android:layout_width="match_parent"
 		android:layout_height="match_parent"
-		android:padding="@dimen/margin_activity_horizontal"
-		android:orientation="vertical">
+		android:orientation="vertical"
+		android:padding="@dimen/margin_activity_horizontal">
 
 		<RelativeLayout
-			android:id="@+id/introductionHeader"
 			android:layout_width="match_parent"
-			android:layout_height="wrap_content"
-			android:padding="@dimen/margin_medium">
+			android:layout_height="wrap_content">
 
-			<de.hdodenhof.circleimageview.CircleImageView
-				android:id="@+id/avatarContact1"
-				style="@style/BriarAvatar"
-				android:layout_width="@dimen/listitem_picture_size"
-				android:layout_height="@dimen/listitem_picture_size"
-				android:layout_centerHorizontal="true"
-				android:layout_marginEnd="@dimen/listitem_horizontal_margin"
-				android:layout_marginRight="@dimen/listitem_horizontal_margin"
+			<LinearLayout
+				android:id="@+id/layoutContact1"
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
 				android:layout_toLeftOf="@+id/introductionIcon"
-				android:layout_toStartOf="@+id/introductionIcon"
-				tools:src="@drawable/ic_launcher"/>
+				android:gravity="top|center_horizontal"
+				android:orientation="vertical">
+
+				<de.hdodenhof.circleimageview.CircleImageView
+					android:id="@+id/avatarContact1"
+					style="@style/BriarAvatar"
+					android:layout_width="@dimen/listitem_picture_size"
+					android:layout_height="@dimen/listitem_picture_size"
+					android:layout_marginEnd="@dimen/listitem_horizontal_margin"
+					android:layout_marginLeft="@dimen/listitem_horizontal_margin"
+					android:layout_marginRight="@dimen/listitem_horizontal_margin"
+					android:layout_marginStart="@dimen/listitem_horizontal_margin"
+					tools:src="@drawable/ic_launcher"/>
+
+				<TextView
+					android:id="@+id/nameContact1"
+					android:layout_width="wrap_content"
+					android:layout_height="wrap_content"
+					android:layout_marginTop="@dimen/margin_small"
+					android:gravity="center"
+					android:textColor="@color/briar_text_primary"
+					android:textSize="@dimen/text_size_tiny"
+					tools:text="Contact 1"/>
+
+			</LinearLayout>
 
 			<ImageView
 				android:id="@+id/introductionIcon"
@@ -42,18 +55,38 @@
 				android:src="@drawable/ic_contact_introduction"
 				tools:ignore="ContentDescription"/>
 
-			<de.hdodenhof.circleimageview.CircleImageView
-				android:id="@+id/avatarContact2"
-				style="@style/BriarAvatar"
-				android:layout_width="@dimen/listitem_picture_size"
-				android:layout_height="@dimen/listitem_picture_size"
-				android:layout_centerHorizontal="true"
-				android:layout_marginLeft="@dimen/listitem_horizontal_margin"
-				android:layout_marginStart="@dimen/listitem_horizontal_margin"
+			<LinearLayout
+				android:id="@+id/layoutContact2"
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
 				android:layout_toEndOf="@+id/introductionIcon"
 				android:layout_toRightOf="@+id/introductionIcon"
-				android:transitionName="avatar"
-				tools:src="@drawable/ic_launcher"/>
+				android:gravity="top|center_horizontal"
+				android:orientation="vertical">
+
+				<de.hdodenhof.circleimageview.CircleImageView
+					android:id="@+id/avatarContact2"
+					style="@style/BriarAvatar"
+					android:layout_width="@dimen/listitem_picture_size"
+					android:layout_height="@dimen/listitem_picture_size"
+					android:layout_marginEnd="@dimen/listitem_horizontal_margin"
+					android:layout_marginLeft="@dimen/listitem_horizontal_margin"
+					android:layout_marginRight="@dimen/listitem_horizontal_margin"
+					android:layout_marginStart="@dimen/listitem_horizontal_margin"
+					android:transitionName="avatar"
+					tools:src="@drawable/ic_launcher"/>
+
+				<TextView
+					android:id="@+id/nameContact2"
+					android:layout_width="wrap_content"
+					android:layout_height="wrap_content"
+					android:layout_marginTop="@dimen/margin_small"
+					android:gravity="center"
+					android:textColor="@color/briar_text_primary"
+					android:textSize="@dimen/text_size_tiny"
+					tools:text="Contact 2"/>
+
+			</LinearLayout>
 
 		</RelativeLayout>
 
@@ -72,8 +105,8 @@
 			android:layout_marginTop="@dimen/margin_medium"
 			android:layout_weight="1"
 			android:gravity="top"
-			android:textSize="@dimen/text_size_medium"
 			android:textColor="@color/briar_text_primary"
+			android:textSize="@dimen/text_size_medium"
 			tools:text="@string/introduction_message_text"/>
 
 		<EditText
diff --git a/briar-android/src/org/briarproject/android/introduction/IntroductionMessageFragment.java b/briar-android/src/org/briarproject/android/introduction/IntroductionMessageFragment.java
index 42e0b93d1e..46470ef392 100644
--- a/briar-android/src/org/briarproject/android/introduction/IntroductionMessageFragment.java
+++ b/briar-android/src/org/briarproject/android/introduction/IntroductionMessageFragment.java
@@ -149,6 +149,10 @@ public class IntroductionMessageFragment extends BaseFragment {
 				ui.avatar2.setImageDrawable(new IdenticonDrawable(
 						c2.getAuthor().getId().getBytes()));
 
+				// set contact names
+				ui.contactName1.setText(c1.getAuthor().getName());
+				ui.contactName2.setText(c2.getAuthor().getName());
+
 				// set introduction text
 				ui.text.setText(String.format(
 						getString(R.string.introduction_message_text),
@@ -215,6 +219,7 @@ public class IntroductionMessageFragment extends BaseFragment {
 
 		private final ProgressBar progressBar;
 		private final CircleImageView avatar1, avatar2;
+		private final TextView contactName1, contactName2;
 		private final TextView text;
 		private final EditText message;
 		private final Button button;
@@ -223,6 +228,8 @@ public class IntroductionMessageFragment extends BaseFragment {
 			progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
 			avatar1 = (CircleImageView) v.findViewById(R.id.avatarContact1);
 			avatar2 = (CircleImageView) v.findViewById(R.id.avatarContact2);
+			contactName1 = (TextView) v.findViewById(R.id.nameContact1);
+			contactName2 = (TextView) v.findViewById(R.id.nameContact2);
 			text = (TextView) v.findViewById(R.id.introductionText);
 			message = (EditText) v.findViewById(R.id.introductionMessageView);
 			button = (Button) v.findViewById(R.id.makeIntroductionButton);
-- 
GitLab