Allow switching to text only view again

pull/162/head
M66B 5 years ago
parent 2d917e21ab
commit e912e28d1d

@ -1249,8 +1249,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
properties.setValue("full", message.id, true);
properties.setValue("full_asked", message.id, true);
}
if (prefs.getBoolean(from + ".show_images", false))
if (prefs.getBoolean(from + ".show_images", false)) {
properties.setValue("images", message.id, true);
properties.setValue("images_asked", message.id, true);
}
}
int dp60 = Helper.dp2pixels(context, 60);
@ -1264,6 +1266,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibFull.setEnabled(hasWebView);
ibFull.setImageResource(show_full ? R.drawable.baseline_fullscreen_exit_24 : R.drawable.baseline_fullscreen_24);
ibImages.setImageResource(show_images ? R.drawable.baseline_format_align_justify_24 : R.drawable.baseline_image_24);
if (show_full) {
// Create web view
@ -1421,8 +1424,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
final Bundle args = new Bundle();
args.putSerializable("message", message);
args.putBoolean("show_images", show_images);
args.putBoolean("show_full", show_full);
args.putBoolean("show_images", show_images);
args.putBoolean("show_quotes", show_quotes);
args.putInt("zoom", zoom);
@ -1588,7 +1591,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// Show attachments/images
cowner.start();
ibImages.setVisibility(has_images && !show_images ? View.VISIBLE : View.GONE);
ibImages.setVisibility(has_images ? View.VISIBLE : View.GONE);
}
@Override
@ -2516,24 +2519,22 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onShow(final TupleMessageEx message, boolean full) {
if (full) {
boolean current = properties.getValue("full", message.id);
boolean asked = properties.getValue("full_asked", message.id);
if (current || asked) {
if (current) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
for (Address address : message.from) {
String from = ((InternetAddress) address).getAddress();
editor.remove(from + ".show_full");
}
editor.apply();
boolean current = properties.getValue(full ? "full" : "images", message.id);
boolean asked = properties.getValue(full ? "full_asked" : "images_asked", message.id);
if (current || asked) {
if (current) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
for (Address address : message.from) {
String from = ((InternetAddress) address).getAddress();
editor.remove(from + (full ? ".show_full" : ".show_images"));
}
properties.setValue("full", message.id, !current);
onShowFullConfirmed(message);
return;
editor.apply();
}
properties.setValue(full ? "full" : "images", message.id, !current);
onShowFullConfirmed(message);
return;
}
View dview = LayoutInflater.from(context).inflate(
@ -2589,14 +2590,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (full) {
properties.setValue("full", message.id, true);
properties.setValue("full_asked", message.id, true);
properties.setValue(full ? "full" : "images", message.id, true);
properties.setValue(full ? "full_asked" : "images_asked", message.id, true);
if (full)
onShowFullConfirmed(message);
} else {
properties.setValue("images", message.id, true);
onShowImagesConfirmed(message);
}
onShowImagesConfirmed(message);
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -2623,8 +2621,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onShowImagesConfirmed(final TupleMessageEx message) {
ibImages.setVisibility(View.GONE);
bindBody(message);
// Download inline images

@ -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="M3,21h18v-2L3,19v2zM3,17h18v-2L3,15v2zM3,13h18v-2L3,11v2zM3,9h18L21,7L3,7v2zM3,3v2h18L21,3L3,3z"/>
</vector>
Loading…
Cancel
Save