mirror of https://github.com/M66B/FairEmail.git
Differentiate between external and embedded images
This commit is contained in:
parent
c6beb1b902
commit
fe77429da5
18
FAQ.md
18
FAQ.md
|
@ -353,15 +353,21 @@ Yes, you can translate the texts of FairEmail in your own language [here](https:
|
||||||
Registration is free.
|
Registration is free.
|
||||||
|
|
||||||
<a name="faq27"></a>
|
<a name="faq27"></a>
|
||||||
**(27) ~~Why are images shown without tapping 'Show images' ?~~**
|
**(27) How can I differentiate external and embedded images?**
|
||||||
|
|
||||||
~~There are two types of images:~~
|
External image:
|
||||||
|
|
||||||
* ~~Images embedded into a message~~
|
![External image](https://raw.githubusercontent.com/google/material-design-icons/master/image/1x_web/ic_image_black_48dp.png)
|
||||||
* ~~Images stored on a remote server~~
|
|
||||||
|
|
||||||
~~Embedded images, also visible as an attachment, are always shown, but images stored on a remote server need to be downloaded by tapping *Show images*.~~
|
Embedded image:
|
||||||
~~Note that downloading images from a remote server can be used to record you did see a message, which you likely don't want if the message is spam or malicious.~~
|
|
||||||
|
![Embedded image](https://raw.githubusercontent.com/google/material-design-icons/master/image/1x_web/ic_photo_library_black_48dp.png)
|
||||||
|
|
||||||
|
Broken image:
|
||||||
|
|
||||||
|
![Broken image](https://raw.githubusercontent.com/google/material-design-icons/master/image/1x_web/ic_broken_image_black_48dp.png)
|
||||||
|
|
||||||
|
Note that downloading external images from a remote server can be used to record you did see a message, which you likely don't want if the message is spam or malicious.
|
||||||
|
|
||||||
<a name="faq28"></a>
|
<a name="faq28"></a>
|
||||||
**(28) How can I manage status bar notifications?**
|
**(28) How can I manage status bar notifications?**
|
||||||
|
|
|
@ -724,29 +724,34 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||||
@Override
|
@Override
|
||||||
public Drawable getDrawable(String source) {
|
public Drawable getDrawable(String source) {
|
||||||
float scale = context.getResources().getDisplayMetrics().density;
|
float scale = context.getResources().getDisplayMetrics().density;
|
||||||
int px = (int) (48 * scale + 0.5f);
|
int px = Math.round(48 * scale);
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(source)) {
|
||||||
|
Drawable d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme());
|
||||||
|
d.setBounds(0, 0, px / 2, px / 2);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean embedded = (source.startsWith("cid") && source.split(":").length > 1);
|
||||||
|
|
||||||
if (properties.showImages(message.id)) {
|
if (properties.showImages(message.id)) {
|
||||||
// Embedded images
|
// Embedded images
|
||||||
if (source != null && source.startsWith("cid")) {
|
if (embedded) {
|
||||||
String[] cids = source.split(":");
|
String cid = "<" + source.split(":")[1] + ">";
|
||||||
if (cids.length > 1) {
|
EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid);
|
||||||
String cid = "<" + cids[1] + ">";
|
if (attachment == null || !attachment.available) {
|
||||||
EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid);
|
Drawable d = context.getResources().getDrawable(R.drawable.baseline_photo_library_24, context.getTheme());
|
||||||
if (attachment == null || !attachment.available) {
|
d.setBounds(0, 0, px, px);
|
||||||
Drawable d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme());
|
return d;
|
||||||
d.setBounds(0, 0, px, px);
|
} else {
|
||||||
return d;
|
File file = EntityAttachment.getFile(context, attachment.id);
|
||||||
} else {
|
Drawable d = Drawable.createFromPath(file.getAbsolutePath());
|
||||||
File file = EntityAttachment.getFile(context, attachment.id);
|
if (d == null) {
|
||||||
Drawable d = Drawable.createFromPath(file.getAbsolutePath());
|
d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme());
|
||||||
if (d == null) {
|
d.setBounds(0, 0, px / 2, px / 2);
|
||||||
d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme());
|
} else
|
||||||
d.setBounds(0, 0, px, px);
|
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
|
||||||
} else
|
return d;
|
||||||
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -767,9 +772,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
FileOutputStream os = null;
|
FileOutputStream os = null;
|
||||||
try {
|
try {
|
||||||
if (source == null)
|
|
||||||
throw new IllegalArgumentException("Html.ImageGetter.getDrawable(source == null)");
|
|
||||||
|
|
||||||
// Create unique file name
|
// Create unique file name
|
||||||
File file = new File(dir, message.id + "_" + source.hashCode());
|
File file = new File(dir, message.id + "_" + source.hashCode());
|
||||||
|
|
||||||
|
@ -800,8 +802,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// Show warning icon
|
// Show warning icon
|
||||||
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
||||||
Drawable d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme());
|
Drawable d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme());
|
||||||
d.setBounds(0, 0, px, px);
|
d.setBounds(0, 0, px / 2, px / 2);
|
||||||
return d;
|
return d;
|
||||||
} finally {
|
} finally {
|
||||||
// Close streams
|
// Close streams
|
||||||
|
@ -822,7 +824,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Show placeholder icon
|
// Show placeholder icon
|
||||||
Drawable d = context.getResources().getDrawable(R.drawable.baseline_image_24, context.getTheme());
|
int resid = (embedded ? R.drawable.baseline_photo_library_24 : R.drawable.baseline_image_24);
|
||||||
|
Drawable d = context.getResources().getDrawable(resid, context.getTheme());
|
||||||
d.setBounds(0, 0, px, px);
|
d.setBounds(0, 0, px, px);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1705,8 +1705,8 @@ public class FragmentCompose extends FragmentEx {
|
||||||
}
|
}
|
||||||
|
|
||||||
float scale = getContext().getResources().getDisplayMetrics().density;
|
float scale = getContext().getResources().getDisplayMetrics().density;
|
||||||
int px = (int) (24 * scale + 0.5f);
|
int px = Math.round(12 * scale);
|
||||||
Drawable d = getContext().getResources().getDrawable(R.drawable.baseline_warning_24, getContext().getTheme());
|
Drawable d = getContext().getResources().getDrawable(R.drawable.baseline_broken_image_24, getContext().getTheme());
|
||||||
d.setBounds(0, 0, px, px);
|
d.setBounds(0, 0, px, px);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M21,5v6.59l-3,-3.01 -4,4.01 -4,-4 -4,4 -3,-3.01L3,5c0,-1.1 0.9,-2 2,-2h14c1.1,0 2,0.9 2,2zM18,11.42l3,3.01L21,19c0,1.1 -0.9,2 -2,2L5,21c-1.1,0 -2,-0.9 -2,-2v-6.58l3,2.99 4,-4 4,4 4,-3.99z"/>
|
||||||
|
</vector>
|
2
app/src/main/res/drawable/baseline_warning_24.xml → app/src/main/res/drawable/baseline_photo_library_24.xml
Normal file → Executable file
2
app/src/main/res/drawable/baseline_warning_24.xml → app/src/main/res/drawable/baseline_photo_library_24.xml
Normal file → Executable file
|
@ -6,5 +6,5 @@
|
||||||
android:tint="?attr/colorControlNormal">
|
android:tint="?attr/colorControlNormal">
|
||||||
<path
|
<path
|
||||||
android:fillColor="@android:color/white"
|
android:fillColor="@android:color/white"
|
||||||
android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z"/>
|
android:pathData="M22,16L22,4c0,-1.1 -0.9,-2 -2,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zM11,12l2.03,2.71L16,11l4,5L8,16l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z"/>
|
||||||
</vector>
|
</vector>
|
Loading…
Reference in New Issue