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")
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.getById(numberInfo.communityDatabaseItem.getCategory())
: null;
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
? numberInfo.contactItem.displayName : null;
if (!TextUtils.isEmpty(contactName)) {
if (!TextUtils.isEmpty(name)) name += "\n";
name += contactName;
nameView.setText(contactName);
} else {
nameView.setVisibility(View.GONE);
}
TextView featuredNameView = view.findViewById(R.id.featured_name);
String featuredName = numberInfo.featuredDatabaseItem != null
? numberInfo.featuredDatabaseItem.getName() : null;
if (!TextUtils.isEmpty(featuredName)) {
if (name.isEmpty()) {
name = featuredName;
featuredNameView.setText(featuredName);
} else {
name += "\n(" + featuredName + ")";
}
}
TextView nameView = view.findViewById(R.id.name);
if (!TextUtils.isEmpty(name)) {
nameView.setText(name);
} else {
nameView.setVisibility(View.GONE);
featuredNameView.setVisibility(View.GONE);
}
ReviewsSummaryHelper.populateSummary(view.findViewById(R.id.reviews_summary),

View File

@ -7,16 +7,38 @@
android:orientation="vertical"
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
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_horizontal"
android:maxLines="3"
android:maxLines="2"
android:textAlignment="center"
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
layout="@layout/reviews_summary"