mirror of https://github.com/M66B/FairEmail.git
Split view/compose zoom
This commit is contained in:
parent
fe9ca75d9a
commit
266959ece8
|
@ -709,7 +709,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
|
||||
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
|
||||
if (zoom == 0)
|
||||
zoom = 1;
|
||||
|
||||
|
|
|
@ -1392,10 +1392,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
@Override
|
||||
protected Object onExecute(final Context context, final Bundle args) throws IOException {
|
||||
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");
|
||||
boolean show_full = args.getBoolean("show_full");
|
||||
boolean show_images = args.getBoolean("show_images");
|
||||
boolean show_quotes = args.getBoolean("show_quotes");
|
||||
int zoom = args.getInt("zoom");
|
||||
final boolean show_full = args.getBoolean("show_full");
|
||||
final boolean show_images = args.getBoolean("show_images");
|
||||
final boolean show_quotes = args.getBoolean("show_quotes");
|
||||
final int zoom = args.getInt("zoom");
|
||||
|
||||
if (message == null || !message.content)
|
||||
return null;
|
||||
|
@ -1473,7 +1473,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Spanned spanned = HtmlHelper.fromHtml(html, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
Drawable drawable = ImageHelper.decodeImage(context, message.id, source, show_images, tvBody);
|
||||
Drawable drawable = ImageHelper.decodeImage(context, message.id, source, show_images, zoom, tvBody);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
if (drawable instanceof AnimatedImageDrawable)
|
||||
|
@ -3155,6 +3155,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
args.putString("source", source);
|
||||
args.putInt("zoom", zoom);
|
||||
|
||||
FragmentDialogImage fragment = new FragmentDialogImage();
|
||||
fragment.setArguments(args);
|
||||
|
@ -4391,7 +4392,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
protected Drawable onExecute(Context context, Bundle args) throws Throwable {
|
||||
long id = args.getLong("id");
|
||||
String source = args.getString("source");
|
||||
return ImageHelper.decodeImage(context, id, source, true, null);
|
||||
int zoom = args.getInt("zoom");
|
||||
return ImageHelper.decodeImage(context, id, source, true, zoom, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -179,6 +179,13 @@ public class ApplicationEx extends Application {
|
|||
editor.putBoolean("secure", prefs.getBoolean("no_history", false));
|
||||
editor.remove("no_history");
|
||||
}
|
||||
|
||||
if (prefs.contains("zoom")) {
|
||||
int zoom = prefs.getInt("zoom", 1);
|
||||
editor.putInt("view_zoom", zoom);
|
||||
editor.putInt("compose_zoom", zoom);
|
||||
editor.remove("zoom");
|
||||
}
|
||||
}
|
||||
|
||||
if (version < BuildConfig.VERSION_CODE)
|
||||
|
|
|
@ -191,6 +191,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
private boolean encrypt = false;
|
||||
private boolean media = true;
|
||||
private boolean compact = false;
|
||||
private int zoom = 0;
|
||||
|
||||
private long working = -1;
|
||||
private State state = State.NONE;
|
||||
|
@ -235,6 +236,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
monospaced = prefs.getBoolean("monospaced", false);
|
||||
media = prefs.getBoolean("compose_media", true);
|
||||
compact = prefs.getBoolean("compose_compact", false);
|
||||
zoom = prefs.getInt("compose_zoom", compact ? 0 : 1);
|
||||
|
||||
setTitle(R.string.page_compose);
|
||||
setSubtitle(getResources().getQuantityString(R.plurals.page_message, 1));
|
||||
|
@ -1071,22 +1073,13 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
private void onMenuZoom() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
|
||||
zoom = ++zoom % 3;
|
||||
prefs.edit().putInt("zoom", zoom).apply();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putInt("compose_zoom", zoom).apply();
|
||||
setZoom();
|
||||
}
|
||||
|
||||
private void setZoom() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
|
||||
setZoom(zoom);
|
||||
}
|
||||
|
||||
private void setZoom(int zoom) {
|
||||
float textSize = Helper.getTextSize(getContext(), zoom);
|
||||
if (textSize != 0) {
|
||||
etBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
||||
|
@ -1484,7 +1477,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
return HtmlHelper.fromHtml(HtmlHelper.toHtml(s), new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(context, id, source, true, etBody);
|
||||
return ImageHelper.decodeImage(context, id, source, true, zoom, etBody);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
@ -3296,7 +3289,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
Spanned spannedBody = HtmlHelper.fromHtml(body, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(context, id, source, true, etBody);
|
||||
return ImageHelper.decodeImage(context, id, source, true, zoom, etBody);
|
||||
}
|
||||
}, null);
|
||||
|
||||
|
@ -3321,7 +3314,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(context, id, source, show_images, tvReference);
|
||||
return ImageHelper.decodeImage(context, id, source, show_images, zoom, tvReference);
|
||||
}
|
||||
},
|
||||
null);
|
||||
|
|
|
@ -577,7 +577,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
rvMessage.addItemDecoration(dateDecorator);
|
||||
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
|
||||
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
|
||||
String sort = prefs.getString("sort", "time");
|
||||
boolean ascending = prefs.getBoolean(
|
||||
viewType == AdapterMessage.ViewType.THREAD ? "ascending_thread" : "ascending_list", false);
|
||||
|
@ -2553,7 +2553,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
|
||||
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
|
||||
adapter.setCompact(compact);
|
||||
adapter.setZoom(zoom);
|
||||
|
||||
|
@ -2943,9 +2943,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
private void onMenuZoom() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
|
||||
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
|
||||
zoom = ++zoom % 3;
|
||||
prefs.edit().putInt("zoom", zoom).apply();
|
||||
prefs.edit().putInt("view_zoom", zoom).apply();
|
||||
adapter.setZoom(zoom);
|
||||
}
|
||||
|
||||
|
@ -2955,7 +2955,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
prefs.edit().putBoolean("compact", compact).apply();
|
||||
|
||||
int zoom = (compact ? 0 : 1);
|
||||
prefs.edit().putInt("zoom", zoom).apply();
|
||||
prefs.edit().putInt("view_zoom", zoom).apply();
|
||||
|
||||
adapter.setCompact(compact);
|
||||
adapter.setZoom(zoom);
|
||||
|
|
|
@ -197,10 +197,8 @@ class ImageHelper {
|
|||
return round;
|
||||
}
|
||||
|
||||
static Drawable decodeImage(final Context context, final long id, String source, boolean show, final TextView view) {
|
||||
static Drawable decodeImage(final Context context, final long id, String source, boolean show, int zoom, final TextView view) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
|
||||
boolean inline = prefs.getBoolean("inline_images", false);
|
||||
|
||||
final int px = Helper.dp2pixels(context, (zoom + 1) * 24);
|
||||
|
|
Loading…
Reference in New Issue