Added setting to automatically show images for known contacts

This commit is contained in:
M66B 2019-01-27 17:30:15 +00:00
parent 0a84a6c6f8
commit 8c5d26643e
5 changed files with 48 additions and 24 deletions

3
FAQ.md
View File

@ -226,6 +226,7 @@ In the display section of the advanced settings you can enable or disable:
* *Show message preview*: to show two lines of the message text
* *Show address details by default*: to collapse the addresses section by default
* *Conversation action bar*: to disable the bottom navigation bar
* *Automatically show images for known contacts*: to automatically show images for contacts on your device, please read [this FAQ](#user-content-faq35)
Note that messages can be previewed only when the message text was downloaded.
Larger message texts are not downloaded by default on metered (generally mobile) networks.
@ -641,6 +642,8 @@ but will also leak your IP address.
Opening attachments or viewing an original message might execute scripts,
that might not only cause privacy sensitive information to leak, but can also be a security risk.
Note that your contacts could unknowingly send malicious messages if they got infected with malware.
<br />
<a name="faq36"></a>

View File

@ -133,6 +133,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean avatars;
private boolean preview;
private boolean confirm;
private boolean autoimages;
private boolean debug;
private float textSize;
@ -499,9 +500,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<ContactInfo>() {
@Override
protected void onPreExecute(Bundle args) {
ivAvatar.setTag(message.id);
tvFrom.setTag(message.id);
itemView.setTag(message.id);
ivAvatar.setVisibility(avatars ? View.INVISIBLE : View.GONE);
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
}
@ -515,17 +514,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected void onExecuted(Bundle args, ContactInfo info) {
Long id = args.getLong("id");
if (id.equals(ivAvatar.getTag())) {
if (info.hasPhoto())
ivAvatar.setImageBitmap(info.getPhotoBitmap());
else
ivAvatar.setImageResource(R.drawable.baseline_person_24);
ivAvatar.setVisibility(avatars ? View.VISIBLE : View.GONE);
}
if (id.equals(tvFrom.getTag()))
tvFrom.setText(info.getDisplayName(compact));
if (id != null && id.equals(itemView.getTag()))
showContactInfo(info, message);
}
@Override
@ -533,14 +523,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Helper.unexpectedError(context, owner, ex);
}
}.execute(context, owner, aargs, "message:avatar");
} else {
if (info.hasPhoto())
ivAvatar.setImageBitmap(info.getPhotoBitmap());
else
ivAvatar.setImageResource(R.drawable.baseline_person_24);
ivAvatar.setVisibility(avatars ? View.VISIBLE : View.GONE);
tvFrom.setText(info.getDisplayName(compact));
}
} else
showContactInfo(info, message);
vwColor.setBackgroundColor(message.accountColor == null ? Color.TRANSPARENT : message.accountColor);
vwColor.setVisibility(View.VISIBLE);
@ -864,6 +848,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
itemView.setActivated(selectionTracker != null && selectionTracker.isSelected(message.id));
}
private void showContactInfo(ContactInfo info, TupleMessageEx message) {
if (info.hasPhoto())
ivAvatar.setImageBitmap(info.getPhotoBitmap());
else
ivAvatar.setImageResource(R.drawable.baseline_person_24);
ivAvatar.setVisibility(avatars ? View.VISIBLE : View.GONE);
tvFrom.setText(info.getDisplayName(compact));
if (info.hasLookupUri() && autoimages &&
!properties.getValue("images", message.id))
onShowImagesConfirmed(message);
}
void unbind() {
if (liveAttachments != null) {
liveAttachments.removeObserver(observerAttachments);
@ -2218,6 +2215,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
prefs.getBoolean("identicons", false));
this.preview = prefs.getBoolean("preview", false);
this.confirm = prefs.getBoolean("confirm", false);
this.autoimages = prefs.getBoolean("autoimages", false);
this.debug = prefs.getBoolean("debug", false);
this.textSize = Helper.getTextSize(context, zoom);

View File

@ -69,6 +69,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private SwitchCompat swIdenticons;
private SwitchCompat swPreview;
private SwitchCompat swAddresses;
private SwitchCompat swImages;
private SwitchCompat swPull;
private SwitchCompat swActionbar;
@ -90,7 +91,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private Group grpNotification;
static String[] OPTIONS_RESTART = new String[]{
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses",
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages",
"pull", "actionbar", "autoclose", "autonext", "confirm", "debug"
};
@ -129,6 +130,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swIdenticons = view.findViewById(R.id.swIdenticons);
swPreview = view.findViewById(R.id.swPreview);
swAddresses = view.findViewById(R.id.swAddresses);
swImages = view.findViewById(R.id.swImages);
swPull = view.findViewById(R.id.swPull);
swActionbar = view.findViewById(R.id.swActionbar);
@ -266,6 +268,13 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
}
});
swImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("autoimages", checked).apply();
}
});
swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -454,6 +463,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
swPreview.setChecked(prefs.getBoolean("preview", false));
swAddresses.setChecked(prefs.getBoolean("addresses", true));
swImages.setChecked(prefs.getBoolean("autoimages", false));
swPull.setChecked(prefs.getBoolean("pull", true));
swActionbar.setChecked(prefs.getBoolean("actionbar", true));

View File

@ -305,6 +305,18 @@
app:layout_constraintTop_toBottomOf="@id/tvPreviewHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swImages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_images"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAddresses"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swActionbar"
android:layout_width="match_parent"
@ -314,7 +326,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_actionbar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAddresses"
app:layout_constraintTop_toBottomOf="@id/swImages"
app:switchPadding="12dp" />
<TextView

View File

@ -144,6 +144,7 @@
<string name="title_advanced_identicons">Show identicons</string>
<string name="title_advanced_preview">Show message preview</string>
<string name="title_advanced_addresses">Show address details by default</string>
<string name="title_advanced_images">Automatically show images for known contacts</string>
<string name="title_advanced_actionbar">Conversation action bar</string>
<string name="title_advanced_light">Use notification light</string>