|
|
@ -25,6 +25,7 @@ import android.graphics.Bitmap;
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
|
|
|
import android.graphics.Paint;
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
@ -90,6 +91,7 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|
|
|
private final ImageView ivImage;
|
|
|
|
private final ImageView ivImage;
|
|
|
|
private final TextView tvCaption;
|
|
|
|
private final TextView tvCaption;
|
|
|
|
private final TextView tvProperties;
|
|
|
|
private final TextView tvProperties;
|
|
|
|
|
|
|
|
private final TextView tvContent;
|
|
|
|
|
|
|
|
|
|
|
|
ViewHolder(View itemView) {
|
|
|
|
ViewHolder(View itemView) {
|
|
|
|
super(itemView);
|
|
|
|
super(itemView);
|
|
|
@ -98,17 +100,19 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|
|
|
ivImage = itemView.findViewById(R.id.ivImage);
|
|
|
|
ivImage = itemView.findViewById(R.id.ivImage);
|
|
|
|
tvCaption = itemView.findViewById(R.id.tvCaption);
|
|
|
|
tvCaption = itemView.findViewById(R.id.tvCaption);
|
|
|
|
tvProperties = itemView.findViewById(R.id.tvProperties);
|
|
|
|
tvProperties = itemView.findViewById(R.id.tvProperties);
|
|
|
|
tvProperties.setMovementMethod(LinkMovementMethodCompat.getInstance());
|
|
|
|
tvContent = itemView.findViewById(R.id.tvContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void wire() {
|
|
|
|
private void wire() {
|
|
|
|
view.setOnClickListener(this);
|
|
|
|
view.setOnClickListener(this);
|
|
|
|
view.setOnLongClickListener(this);
|
|
|
|
view.setOnLongClickListener(this);
|
|
|
|
|
|
|
|
tvContent.setOnClickListener(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void unwire() {
|
|
|
|
private void unwire() {
|
|
|
|
view.setOnClickListener(null);
|
|
|
|
view.setOnClickListener(null);
|
|
|
|
view.setOnLongClickListener(null);
|
|
|
|
view.setOnLongClickListener(null);
|
|
|
|
|
|
|
|
tvContent.setOnClickListener(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void showPlayerState(Uri uri) {
|
|
|
|
private void showPlayerState(Uri uri) {
|
|
|
@ -124,6 +128,7 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|
|
|
tvCaption.setText(attachment.name);
|
|
|
|
tvCaption.setText(attachment.name);
|
|
|
|
tvCaption.setVisibility(TextUtils.isEmpty(attachment.name) ? View.GONE : View.VISIBLE);
|
|
|
|
tvCaption.setVisibility(TextUtils.isEmpty(attachment.name) ? View.GONE : View.VISIBLE);
|
|
|
|
tvProperties.setVisibility(View.GONE);
|
|
|
|
tvProperties.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
tvContent.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
if (attachment.available) {
|
|
|
|
if (attachment.available) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
@ -267,66 +272,74 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|
|
|
ImageHelper.animate(context, image);
|
|
|
|
ImageHelper.animate(context, image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SpannableStringBuilder ssb = new SpannableStringBuilderEx();
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
int width = args.getInt("width");
|
|
|
|
int width = args.getInt("width");
|
|
|
|
int height = args.getInt("height");
|
|
|
|
int height = args.getInt("height");
|
|
|
|
if (width > 0 && height > 0)
|
|
|
|
if (width > 0 && height > 0)
|
|
|
|
ssb.append(Integer.toString(width))
|
|
|
|
sb.append(width)
|
|
|
|
.append("\u00d7") // ×
|
|
|
|
.append("\u00d7") // ×
|
|
|
|
.append(Integer.toString(height));
|
|
|
|
.append(height);
|
|
|
|
|
|
|
|
|
|
|
|
if (BuildConfig.DEBUG) {
|
|
|
|
if (BuildConfig.DEBUG) {
|
|
|
|
String color = args.getString("color");
|
|
|
|
String color = args.getString("color");
|
|
|
|
if (color != null) {
|
|
|
|
if (color != null) {
|
|
|
|
if (ssb.length() > 0)
|
|
|
|
if (sb.length() > 0)
|
|
|
|
ssb.append(' ');
|
|
|
|
sb.append(' ');
|
|
|
|
ssb.append(color);
|
|
|
|
sb.append(color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String config = args.getString("config");
|
|
|
|
String config = args.getString("config");
|
|
|
|
if (config != null) {
|
|
|
|
if (config != null) {
|
|
|
|
if (ssb.length() > 0)
|
|
|
|
if (sb.length() > 0)
|
|
|
|
ssb.append(' ');
|
|
|
|
sb.append(' ');
|
|
|
|
ssb.append(config);
|
|
|
|
sb.append(config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long size = args.getLong("size");
|
|
|
|
long size = args.getLong("size");
|
|
|
|
if (size > 0) {
|
|
|
|
if (size > 0) {
|
|
|
|
if (ssb.length() > 0)
|
|
|
|
if (sb.length() > 0)
|
|
|
|
ssb.append(' ');
|
|
|
|
sb.append(' ');
|
|
|
|
ssb.append(Helper.humanReadableByteCount(size));
|
|
|
|
sb.append(Helper.humanReadableByteCount(size));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int duration = args.getInt("duration");
|
|
|
|
int duration = args.getInt("duration");
|
|
|
|
if (duration > 0) {
|
|
|
|
if (duration > 0) {
|
|
|
|
if (ssb.length() > 0)
|
|
|
|
if (sb.length() > 0)
|
|
|
|
ssb.append(' ');
|
|
|
|
sb.append(' ');
|
|
|
|
ssb.append(Helper.formatDuration(duration));
|
|
|
|
sb.append(Helper.formatDuration(duration));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sb.length() > 0) {
|
|
|
|
|
|
|
|
tvProperties.setText(sb);
|
|
|
|
|
|
|
|
tvProperties.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String barcode = args.getString("barcode");
|
|
|
|
String barcode = args.getString("barcode");
|
|
|
|
if (!TextUtils.isEmpty(barcode)) {
|
|
|
|
if (!TextUtils.isEmpty(barcode)) {
|
|
|
|
if (ssb.length() > 0)
|
|
|
|
boolean link;
|
|
|
|
ssb.append('\n');
|
|
|
|
Uri uri;
|
|
|
|
int start = ssb.length();
|
|
|
|
|
|
|
|
ssb.append(barcode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Uri uri = UriHelper.guessScheme(Uri.parse(barcode));
|
|
|
|
uri = UriHelper.guessScheme(Uri.parse(barcode));
|
|
|
|
if (UriHelper.isHyperLink(uri) || UriHelper.isMail(uri))
|
|
|
|
link = UriHelper.isHyperLink(uri) || UriHelper.isMail(uri);
|
|
|
|
ssb.setSpan(new URLSpan(uri.toString()), start, ssb.length(), 0);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0);
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
uri = null;
|
|
|
|
|
|
|
|
link = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ssb.length() > 0) {
|
|
|
|
tvContent.setTypeface(null, link ? Typeface.NORMAL : Typeface.BOLD);
|
|
|
|
tvProperties.setText(ssb);
|
|
|
|
int flags = tvContent.getPaintFlags();
|
|
|
|
tvProperties.setVisibility(View.VISIBLE);
|
|
|
|
if (link)
|
|
|
|
|
|
|
|
flags |= Paint.UNDERLINE_TEXT_FLAG;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
flags &= ~Paint.UNDERLINE_TEXT_FLAG;
|
|
|
|
|
|
|
|
tvContent.setPaintFlags(flags);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvContent.setTag(link ? uri.toString() : null);
|
|
|
|
|
|
|
|
tvContent.setText(barcode);
|
|
|
|
|
|
|
|
tvContent.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -348,6 +361,18 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|
|
|
if (pos == RecyclerView.NO_POSITION)
|
|
|
|
if (pos == RecyclerView.NO_POSITION)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (view.getId() == R.id.tvContent && view.getTag() instanceof String) {
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putParcelable("uri", Uri.parse((String) view.getTag()));
|
|
|
|
|
|
|
|
args.putString("title", ((TextView) view).getText().toString());
|
|
|
|
|
|
|
|
args.putBoolean("always_confirm", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentDialogOpenLink fragment = new FragmentDialogOpenLink();
|
|
|
|
|
|
|
|
fragment.setArguments(args);
|
|
|
|
|
|
|
|
fragment.show(parentFragment.getParentFragmentManager(), "open:barcode");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EntityAttachment attachment = items.get(pos);
|
|
|
|
EntityAttachment attachment = items.get(pos);
|
|
|
|
if (attachment.available) {
|
|
|
|
if (attachment.available) {
|
|
|
|
if (attachment.isAudio()) {
|
|
|
|
if (attachment.isAudio()) {
|
|
|
|