Split name field on the info screen

This commit is contained in:
xynngh 2020-05-13 16:27:45 +04:00
parent b44d4a78ac
commit 7f1ed07262
2 changed files with 37 additions and 17 deletions

View File

@ -23,40 +23,38 @@ public class InfoDialogHelper {
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
View view = LayoutInflater.from(context).inflate(R.layout.info_dialog, null); View view = LayoutInflater.from(context).inflate(R.layout.info_dialog, null);
String name = ""; TextView categoryView = view.findViewById(R.id.category);
NumberCategory category = numberInfo.communityDatabaseItem != null NumberCategory category = numberInfo.communityDatabaseItem != null
? NumberCategory.getById(numberInfo.communityDatabaseItem.getCategory()) ? NumberCategory.getById(numberInfo.communityDatabaseItem.getCategory())
: null; : null;
if (category != null && category != NumberCategory.NONE) { if (category != null && category != NumberCategory.NONE) {
name += NumberCategory.getString(context, category); categoryView.setText(NumberCategory.getString(context, category));
} else {
categoryView.setVisibility(View.GONE);
} }
TextView nameView = view.findViewById(R.id.name);
String contactName = numberInfo.contactItem != null String contactName = numberInfo.contactItem != null
? numberInfo.contactItem.displayName : null; ? numberInfo.contactItem.displayName : null;
if (!TextUtils.isEmpty(contactName)) { if (!TextUtils.isEmpty(contactName)) {
if (!TextUtils.isEmpty(name)) name += "\n"; nameView.setText(contactName);
name += contactName; } else {
nameView.setVisibility(View.GONE);
} }
TextView featuredNameView = view.findViewById(R.id.featured_name);
String featuredName = numberInfo.featuredDatabaseItem != null String featuredName = numberInfo.featuredDatabaseItem != null
? numberInfo.featuredDatabaseItem.getName() : null; ? numberInfo.featuredDatabaseItem.getName() : null;
if (!TextUtils.isEmpty(featuredName)) { if (!TextUtils.isEmpty(featuredName)) {
if (name.isEmpty()) { featuredNameView.setText(featuredName);
name = featuredName;
} else { } else {
name += "\n(" + featuredName + ")"; featuredNameView.setVisibility(View.GONE);
}
}
TextView nameView = view.findViewById(R.id.name);
if (!TextUtils.isEmpty(name)) {
nameView.setText(name);
} else {
nameView.setVisibility(View.GONE);
} }
ReviewsSummaryHelper.populateSummary(view.findViewById(R.id.reviews_summary), ReviewsSummaryHelper.populateSummary(view.findViewById(R.id.reviews_summary),

View File

@ -7,16 +7,38 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp"> android:padding="16dp">
<TextView
android:id="@+id/category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_horizontal"
android:maxLines="1"
android:textAlignment="center"
android:textSize="20sp"
tools:text="Category" />
<TextView <TextView
android:id="@+id/name" android:id="@+id/name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:maxLines="3" android:maxLines="2"
android:textAlignment="center" android:textAlignment="center"
android:textSize="20sp" android:textSize="20sp"
tools:text="Featured company or contact name" /> tools:text="Contact name" />
<TextView
android:id="@+id/featured_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_horizontal"
android:maxLines="1"
android:textAlignment="center"
android:textSize="20sp"
tools:text="Featured company name" />
<include <include
layout="@layout/reviews_summary" layout="@layout/reviews_summary"