mirror of
https://gitlab.com/xynngh/YetAnotherCallBlocker.git
synced 2025-06-05 22:19:12 +02:00
Allow to paste non-plain text content on Lookup screen
Thanks to an anonymous contributor
This commit is contained in:
@@ -25,6 +25,11 @@ import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabaseItem
|
|||||||
|
|
||||||
public class LookupNumberActivity extends AppCompatActivity {
|
public class LookupNumberActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private static final String[] MIME_TYPES = new String[]{
|
||||||
|
ClipDescription.MIMETYPE_TEXT_PLAIN,
|
||||||
|
"vnd.android.cursor.item/phone_v2" // ContactsContract.Phone.CONTENT_ITEM_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
|
|
||||||
private ClipboardManager clipboardManager;
|
private ClipboardManager clipboardManager;
|
||||||
@@ -127,8 +132,7 @@ public class LookupNumberActivity extends AppCompatActivity {
|
|||||||
public void onPasteNumberButtonClick(View view) {
|
public void onPasteNumberButtonClick(View view) {
|
||||||
if (clipboardManager.hasPrimaryClip()) {
|
if (clipboardManager.hasPrimaryClip()) {
|
||||||
ClipDescription clipDescription = clipboardManager.getPrimaryClipDescription();
|
ClipDescription clipDescription = clipboardManager.getPrimaryClipDescription();
|
||||||
if (clipDescription != null && clipDescription
|
if (clipDescription != null && hasMimeType(clipDescription, MIME_TYPES)) {
|
||||||
.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
|
|
||||||
ClipData primaryClip = clipboardManager.getPrimaryClip();
|
ClipData primaryClip = clipboardManager.getPrimaryClip();
|
||||||
if (primaryClip != null) {
|
if (primaryClip != null) {
|
||||||
ClipData.Item item = primaryClip.getItemAt(0);
|
ClipData.Item item = primaryClip.getItemAt(0);
|
||||||
@@ -212,4 +216,13 @@ public class LookupNumberActivity extends AppCompatActivity {
|
|||||||
setReviewsNumberAndDetails(number, details);
|
setReviewsNumberAndDetails(number, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hasMimeType(ClipDescription cd, String... mimeTypes) {
|
||||||
|
for (String mimeType : mimeTypes) {
|
||||||
|
if (cd.hasMimeType(mimeType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user