Display blacklist name in call log and info dialog

This commit is contained in:
xynngh 2020-10-18 15:23:12 +04:00
parent 69dbdbc2fd
commit e545365c66
3 changed files with 40 additions and 6 deletions

View File

@ -84,9 +84,7 @@ public class CallLogItemRecyclerViewAdapter extends GenericRecyclerViewAdapter
NumberInfo numberInfo = item.numberInfo;
label.setText(numberInfo.noNumber
? context.getString(R.string.no_number)
: numberInfo.name != null ? numberInfo.name : item.number);
label.setText(getLabel(context, item));
IconAndColor iconAndColor = IconAndColor.forNumberRating(
numberInfo.rating, numberInfo.contactItem != null);
@ -126,6 +124,21 @@ public class CallLogItemRecyclerViewAdapter extends GenericRecyclerViewAdapter
time.setText(timeString);
}
private String getLabel(Context context, CallLogItem item) {
NumberInfo numberInfo = item.numberInfo;
if (numberInfo.noNumber) return context.getString(R.string.no_number);
if (numberInfo.name != null) return numberInfo.name;
if (numberInfo.blacklistItem != null
&& !TextUtils.isEmpty(numberInfo.blacklistItem.getName())) {
return numberInfo.blacklistItem.getName();
}
return item.number;
}
private void bindTypeIcons(CallLogItemGroup group) {
List<CallLogItem> items = group.getItems();

View File

@ -64,12 +64,23 @@ public class InfoDialogHelper {
featuredNameView.setVisibility(View.GONE);
}
String blacklistName = null;
TextView inBlacklistView = view.findViewById(R.id.in_blacklist);
if (numberInfo.blacklistItem != null) {
inBlacklistView.setVisibility(View.VISIBLE);
blacklistName = numberInfo.blacklistItem.getName();
if (numberInfo.contactItem != null) {
inBlacklistView.setText(R.string.info_in_blacklist_contact);
}
} else {
inBlacklistView.setVisibility(View.GONE);
}
TextView blacklistNameView = view.findViewById(R.id.blacklist_name);
if (!TextUtils.isEmpty(blacklistName)) {
blacklistNameView.setText(blacklistName);
} else {
blacklistNameView.setVisibility(View.GONE);
}
ReviewsSummaryHelper.populateSummary(view.findViewById(R.id.reviews_summary),

View File

@ -40,6 +40,17 @@
android:textSize="20sp"
tools:text="Featured company name" />
<TextView
android:id="@+id/blacklist_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="Blacklist name" />
<include
layout="@layout/reviews_summary"
android:layout_width="wrap_content"
@ -53,7 +64,6 @@
android:layout_marginTop="6dp"
android:gravity="center_horizontal"
android:text="@string/info_in_blacklist"
android:textAlignment="center"
android:visibility="gone" />
android:textAlignment="center" />
</LinearLayout>