|
|
@ -233,14 +233,13 @@ class ImageHelper {
|
|
|
|
boolean inline = prefs.getBoolean("inline_images", false);
|
|
|
|
boolean inline = prefs.getBoolean("inline_images", false);
|
|
|
|
|
|
|
|
|
|
|
|
final int px = Helper.dp2pixels(context, (zoom + 1) * 24);
|
|
|
|
final int px = Helper.dp2pixels(context, (zoom + 1) * 24);
|
|
|
|
final Resources.Theme theme = context.getTheme();
|
|
|
|
|
|
|
|
final Resources res = context.getResources();
|
|
|
|
final Resources res = context.getResources();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
final AnnotatedSource a = new AnnotatedSource(source);
|
|
|
|
final AnnotatedSource a = new AnnotatedSource(source);
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(a.source)) {
|
|
|
|
if (TextUtils.isEmpty(a.source)) {
|
|
|
|
Drawable d = res.getDrawable(R.drawable.twotone_broken_image_24, theme);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -258,12 +257,12 @@ class ImageHelper {
|
|
|
|
EntityAttachment attachment = db.attachment().getAttachment(id, cid);
|
|
|
|
EntityAttachment attachment = db.attachment().getAttachment(id, cid);
|
|
|
|
if (attachment == null) {
|
|
|
|
if (attachment == null) {
|
|
|
|
Log.i("Image not found CID=" + cid);
|
|
|
|
Log.i("Image not found CID=" + cid);
|
|
|
|
Drawable d = res.getDrawable(R.drawable.twotone_broken_image_24, theme);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
} else if (!attachment.available) {
|
|
|
|
} else if (!attachment.available) {
|
|
|
|
Log.i("Image not available CID=" + cid);
|
|
|
|
Log.i("Image not available CID=" + cid);
|
|
|
|
Drawable d = res.getDrawable(R.drawable.twotone_photo_library_24, theme);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_photo_library_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -276,7 +275,7 @@ class ImageHelper {
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
} catch (IOException ex) {
|
|
|
|
} catch (IOException ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
Log.w(ex);
|
|
|
|
Drawable d = res.getDrawable(R.drawable.twotone_broken_image_24, theme);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -284,7 +283,7 @@ class ImageHelper {
|
|
|
|
Bitmap bm = decodeImage(attachment.getFile(context), scaleToPixels);
|
|
|
|
Bitmap bm = decodeImage(attachment.getFile(context), scaleToPixels);
|
|
|
|
if (bm == null) {
|
|
|
|
if (bm == null) {
|
|
|
|
Log.i("Image not decodable CID=" + cid);
|
|
|
|
Log.i("Image not decodable CID=" + cid);
|
|
|
|
Drawable d = res.getDrawable(R.drawable.twotone_broken_image_24, theme);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -316,7 +315,7 @@ class ImageHelper {
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
} catch (IllegalArgumentException ex) {
|
|
|
|
} catch (IllegalArgumentException ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
Log.w(ex);
|
|
|
|
Drawable d = res.getDrawable(R.drawable.twotone_broken_image_24, theme);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -362,7 +361,7 @@ class ImageHelper {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
// FileNotFound, Security
|
|
|
|
// FileNotFound, Security
|
|
|
|
Log.w(ex);
|
|
|
|
Log.w(ex);
|
|
|
|
Drawable d = context.getResources().getDrawable(R.drawable.twotone_broken_image_24);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -370,7 +369,7 @@ class ImageHelper {
|
|
|
|
if (!show) {
|
|
|
|
if (!show) {
|
|
|
|
// Show placeholder icon
|
|
|
|
// Show placeholder icon
|
|
|
|
int resid = (embedded || data ? R.drawable.twotone_photo_library_24 : R.drawable.twotone_image_24);
|
|
|
|
int resid = (embedded || data ? R.drawable.twotone_photo_library_24 : R.drawable.twotone_image_24);
|
|
|
|
Drawable d = res.getDrawable(resid, theme);
|
|
|
|
Drawable d = context.getDrawable(resid);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -380,7 +379,7 @@ class ImageHelper {
|
|
|
|
if (cached != null || view == null) {
|
|
|
|
if (cached != null || view == null) {
|
|
|
|
if (view == null)
|
|
|
|
if (view == null)
|
|
|
|
if (cached == null) {
|
|
|
|
if (cached == null) {
|
|
|
|
Drawable d = res.getDrawable(R.drawable.twotone_hourglass_top_24, theme);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_hourglass_top_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
} else
|
|
|
|
} else
|
|
|
@ -391,7 +390,7 @@ class ImageHelper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final LevelListDrawable lld = new LevelListDrawable();
|
|
|
|
final LevelListDrawable lld = new LevelListDrawable();
|
|
|
|
Drawable wait = res.getDrawable(R.drawable.twotone_hourglass_top_24, theme);
|
|
|
|
Drawable wait = context.getDrawable(R.drawable.twotone_hourglass_top_24);
|
|
|
|
lld.addLevel(1, 1, wait);
|
|
|
|
lld.addLevel(1, 1, wait);
|
|
|
|
lld.setBounds(0, 0, px, px);
|
|
|
|
lld.setBounds(0, 0, px, px);
|
|
|
|
lld.setLevel(1);
|
|
|
|
lld.setLevel(1);
|
|
|
@ -442,7 +441,7 @@ class ImageHelper {
|
|
|
|
int resid = (ex instanceof IOException && !(ex instanceof FileNotFoundException)
|
|
|
|
int resid = (ex instanceof IOException && !(ex instanceof FileNotFoundException)
|
|
|
|
? R.drawable.twotone_cloud_off_24
|
|
|
|
? R.drawable.twotone_cloud_off_24
|
|
|
|
: R.drawable.twotone_broken_image_24);
|
|
|
|
: R.drawable.twotone_broken_image_24);
|
|
|
|
Drawable d = res.getDrawable(resid, theme);
|
|
|
|
Drawable d = context.getDrawable(resid);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
post(d, a.source);
|
|
|
|
post(d, a.source);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -478,7 +477,7 @@ class ImageHelper {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
|
|
|
|
Drawable d = res.getDrawable(R.drawable.twotone_broken_image_24, theme);
|
|
|
|
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
d.setBounds(0, 0, px, px);
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|