mirror of https://github.com/M66B/FairEmail.git
Openable barcode content
This commit is contained in:
parent
9988d9bb52
commit
cbf8afa636
|
@ -81,6 +81,8 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|||
private final Context context;
|
||||
private final LayoutInflater inflater;
|
||||
private final LifecycleOwner owner;
|
||||
private final int textColorTertiary;
|
||||
private final int textColorLink;
|
||||
|
||||
private List<EntityAttachment> items = new ArrayList<>();
|
||||
|
||||
|
@ -318,26 +320,27 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|||
|
||||
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<AdapterMedia.ViewHolder>
|
|||
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() {
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue