Blacklist from the info dialog

This commit is contained in:
xynngh 2020-08-04 18:53:48 +04:00
parent 636d56bdc2
commit 5cf1d77860
4 changed files with 35 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
import dummydomain.yetanothercallblocker.data.NumberInfo;
import dummydomain.yetanothercallblocker.data.SiaNumberCategoryUtils;
import dummydomain.yetanothercallblocker.sia.model.NumberCategory;
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabaseItem;
import static dummydomain.yetanothercallblocker.IntentHelper.clearTop;
@ -65,6 +66,14 @@ public class InfoDialogHelper {
featuredNameView.setVisibility(View.GONE);
}
TextView inBlacklistView = view.findViewById(R.id.in_blacklist);
if (numberInfo.blacklistItem != null) {
inBlacklistView.setVisibility(View.VISIBLE);
if (numberInfo.contactItem != null) {
inBlacklistView.setText(R.string.info_in_blacklist_contact);
}
}
ReviewsSummaryHelper.populateSummary(view.findViewById(R.id.reviews_summary),
numberInfo.communityDatabaseItem);
@ -86,8 +95,17 @@ public class InfoDialogHelper {
IntentHelper.startActivity(context, new Intent(Intent.ACTION_VIEW, uri));
};
Runnable addToBlacklistAction = () -> {
FeaturedDatabaseItem featuredDatabaseItem = numberInfo.featuredDatabaseItem;
String name = featuredDatabaseItem != null ? featuredDatabaseItem.getName() : null;
context.startActivity(EditBlacklistItemActivity
.getIntent(context, name, numberInfo.number));
};
builder.setPositiveButton(R.string.add_web_review, null)
.setNeutralButton(R.string.online_reviews, null);
.setNeutralButton(R.string.online_reviews, null)
.setNegativeButton(R.string.add_to_blacklist, (dialog, which)
-> addToBlacklistAction.run());
AlertDialog dialog = builder.create();

View File

@ -46,4 +46,14 @@
android:layout_height="wrap_content"
android:layout_marginTop="6dp" />
<TextView
android:id="@+id/in_blacklist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:gravity="center_horizontal"
android:text="@string/info_in_blacklist"
android:textAlignment="center"
android:visibility="gone" />
</LinearLayout>

View File

@ -139,4 +139,7 @@
<string name="number_pattern_incorrect">Некорректный шаблон</string>
<string name="number_pattern_empty">Пустой шаблон</string>
<string name="number_pattern_hint">Введите номер в формате +СТРАНА-НОМЕР (как Android показал бы в списке вызовов). Используйте \"*\" как подстановку для нуля и более цифр и \"#\" для одной цифры.</string>
<string name="info_in_blacklist">В чёрном списке</string>
<string name="info_in_blacklist_contact">В чёрном списке (контакты не блокируются)</string>
<string name="add_to_blacklist">Добавить в чёрный список</string>
</resources>

View File

@ -150,6 +150,9 @@
<string name="number_pattern_incorrect">Incorrect pattern</string>
<string name="number_pattern_empty">Empty pattern</string>
<string name="number_pattern_hint">Enter the number in +COUNTRY-NUMBER format (as Android would show in your dialer). Use \"*\" as a wildcard for zero or more digits, and \"#\" for exactly one digit.</string>
<string name="info_in_blacklist">In blacklist</string>
<string name="info_in_blacklist_contact">In blacklist (contacts are not blocked)</string>
<string name="add_to_blacklist">Add to blacklist</string>
<string name="open_debug_activity">Open debug screen</string>
<string name="debug_activity_label">Debug</string>