diff --git a/app/src/main/java/eu/faircode/email/AdapterMedia.java b/app/src/main/java/eu/faircode/email/AdapterMedia.java index f0ae5606e8..93395a3a6e 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMedia.java +++ b/app/src/main/java/eu/faircode/email/AdapterMedia.java @@ -81,6 +81,8 @@ public class AdapterMedia extends RecyclerView.Adapter private final Context context; private final LayoutInflater inflater; private final LifecycleOwner owner; + private final int textColorTertiary; + private final int textColorLink; private List items = new ArrayList<>(); @@ -318,26 +320,27 @@ public class AdapterMedia extends RecyclerView.Adapter String barcode = args.getString("barcode"); if (!TextUtils.isEmpty(barcode)) { - boolean link; Uri uri; try { uri = UriHelper.guessScheme(Uri.parse(barcode)); - link = UriHelper.isHyperLink(uri) || UriHelper.isMail(uri); } catch (Throwable ex) { - Log.e(ex); + Log.w(ex); uri = null; - link = false; } - tvContent.setTypeface(null, link ? Typeface.NORMAL : Typeface.BOLD); + boolean openable = (uri != null && + !TextUtils.isEmpty(uri.getScheme()) && + !"tel".equals(uri.getScheme())); + + tvContent.setTypeface(null, openable ? Typeface.NORMAL : Typeface.BOLD); int flags = tvContent.getPaintFlags(); - if (link) + if (openable) flags |= Paint.UNDERLINE_TEXT_FLAG; else flags &= ~Paint.UNDERLINE_TEXT_FLAG; tvContent.setPaintFlags(flags); - - tvContent.setTag(link ? uri.toString() : null); + tvContent.setTextColor(openable ? textColorLink : textColorTertiary); + tvContent.setTag(openable ? uri.toString() : null); tvContent.setText(barcode); tvContent.setVisibility(View.VISIBLE); } @@ -500,6 +503,9 @@ public class AdapterMedia extends RecyclerView.Adapter this.owner = parentFragment.getViewLifecycleOwner(); this.inflater = LayoutInflater.from(context); + this.textColorTertiary = Helper.resolveColor(context, android.R.attr.textColorTertiary); + this.textColorLink = Helper.resolveColor(context, android.R.attr.textColorLink); + setHasStableIds(true); owner.getLifecycle().addObserver(new LifecycleObserver() { diff --git a/app/src/main/res/layout/item_media.xml b/app/src/main/res/layout/item_media.xml index d3654cc442..d497baa02b 100644 --- a/app/src/main/res/layout/item_media.xml +++ b/app/src/main/res/layout/item_media.xml @@ -54,6 +54,7 @@ android:gravity="center_horizontal" android:text="1234567890" android:textAppearance="@style/TextAppearance.AppCompat.Small" + android:textIsSelectable="true" android:textSize="12sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"