mirror of https://github.com/M66B/FairEmail.git
Added option for default message text zoom
This commit is contained in:
parent
0b6cc4eadc
commit
aa05caf488
|
@ -248,6 +248,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private boolean preview;
|
||||
private boolean preview_italic;
|
||||
private int preview_lines;
|
||||
private int message_zoom;
|
||||
private boolean attachments_alt;
|
||||
private boolean thumbnails;
|
||||
private boolean contrast;
|
||||
|
@ -1796,7 +1797,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
properties.setValue("images", message.id, true);
|
||||
}
|
||||
|
||||
float size = properties.getSize(message.id, show_full ? 0 : textSize);
|
||||
float size = properties.getSize(message.id, show_full ? 0 : textSize * message_zoom / 100f);
|
||||
int height = properties.getHeight(message.id, 0);
|
||||
Pair<Integer, Integer> position = properties.getPosition(message.id);
|
||||
Log.i("Bind size=" + size + " height=" + height);
|
||||
|
@ -4996,6 +4997,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.preview = prefs.getBoolean("preview", false);
|
||||
this.preview_italic = prefs.getBoolean("preview_italic", true);
|
||||
this.preview_lines = prefs.getInt("preview_lines", 2);
|
||||
this.message_zoom = prefs.getInt("message_zoom", 100);
|
||||
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
|
||||
this.thumbnails = prefs.getBoolean("thumbnails", true);
|
||||
this.contrast = prefs.getBoolean("contrast", false);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class FragmentOptions extends FragmentBase {
|
|||
"name_email", "prefer_contact", "distinguish_contacts", "show_recipients", "authentication",
|
||||
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
|
||||
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
|
||||
"addresses", "attachments_alt", "thumbnails",
|
||||
"message_zoom", "addresses", "attachments_alt", "thumbnails",
|
||||
"contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
|
||||
"inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize",
|
||||
"autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",
|
||||
|
|
|
@ -28,6 +28,8 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -38,6 +40,7 @@ import android.view.Window;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
|
@ -105,6 +108,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
private Spinner spPreviewLines;
|
||||
|
||||
private SwitchCompat swAddresses;
|
||||
private EditText etMessageZoom;
|
||||
|
||||
private SwitchCompat swContrast;
|
||||
private SwitchCompat swMonospaced;
|
||||
|
@ -130,7 +134,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
"keywords_header", "labels_header", "flags", "flags_background",
|
||||
"preview", "preview_italic", "preview_lines",
|
||||
"addresses",
|
||||
"contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
|
||||
"message_zoom", "contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
|
||||
"inline_images", "collapse_quotes", "attachments_alt", "thumbnails",
|
||||
"parse_classes", "authentication"
|
||||
};
|
||||
|
@ -194,6 +198,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swPreviewItalic = view.findViewById(R.id.swPreviewItalic);
|
||||
spPreviewLines = view.findViewById(R.id.spPreviewLines);
|
||||
swAddresses = view.findViewById(R.id.swAddresses);
|
||||
etMessageZoom = view.findViewById(R.id.etMessageZoom);
|
||||
swContrast = view.findViewById(R.id.swContrast);
|
||||
swMonospaced = view.findViewById(R.id.swMonospaced);
|
||||
swTextColor = view.findViewById(R.id.swTextColor);
|
||||
|
@ -610,6 +615,31 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
etMessageZoom.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
try {
|
||||
int timeout = (s.length() > 0 ? Integer.parseInt(s.toString()) : 0);
|
||||
if (timeout == 0)
|
||||
prefs.edit().remove("message_zoom").apply();
|
||||
else
|
||||
prefs.edit().putInt("message_zoom", timeout).apply();
|
||||
} catch (NumberFormatException ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
|
||||
swContrast.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -707,6 +737,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||
if ("message_zoom".equals(key))
|
||||
return;
|
||||
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
setOptions();
|
||||
}
|
||||
|
@ -832,7 +865,12 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swPreviewItalic.setEnabled(swPreview.isChecked());
|
||||
spPreviewLines.setSelection(prefs.getInt("preview_lines", 2) - 1);
|
||||
spPreviewLines.setEnabled(swPreview.isChecked());
|
||||
|
||||
swAddresses.setChecked(prefs.getBoolean("addresses", false));
|
||||
|
||||
int message_zoom = prefs.getInt("message_zoom", 0);
|
||||
etMessageZoom.setText(message_zoom == 0 ? null : Integer.toString(message_zoom));
|
||||
|
||||
swContrast.setChecked(prefs.getBoolean("contrast", false));
|
||||
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
||||
swTextColor.setChecked(prefs.getBoolean("text_color", true));
|
||||
|
|
|
@ -822,6 +822,30 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/tvCaptionBody"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvMessageZoom"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_message_text_zoom"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAddresses" />
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
android:id="@+id/etMessageZoom"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="100"
|
||||
android:inputType="number"
|
||||
android:maxLength="3"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvMessageZoom" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swContrast"
|
||||
android:layout_width="0dp"
|
||||
|
@ -830,7 +854,7 @@
|
|||
android:text="@string/title_advanced_contrast"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAddresses"
|
||||
app:layout_constraintTop_toBottomOf="@id/etMessageZoom"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -358,6 +358,7 @@
|
|||
<string name="title_advanced_addresses">Expand address details by default</string>
|
||||
<string name="title_advanced_attachments_alt">Show attachments after the message text</string>
|
||||
<string name="title_advanced_thumbnails">Show image thumbnails after the message text</string>
|
||||
<string name="title_advanced_message_text_zoom">Default message text zoom (%)</string>
|
||||
<string name="title_advanced_contrast">Use high contrast for message text</string>
|
||||
<string name="title_advanced_monospaced">Use monospaced font for message text by default</string>
|
||||
<string name="title_advanced_text_color">Use text colors</string>
|
||||
|
|
Loading…
Reference in New Issue