Replaced message zoom by seekbar

pull/203/head
M66B 3 years ago
parent 54e60c7b41
commit e72c3dbef5

@ -27,8 +27,6 @@ import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -39,7 +37,6 @@ import android.view.Window;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.SeekBar; import android.widget.SeekBar;
@ -127,7 +124,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private TextView tvPreviewLinesHint; private TextView tvPreviewLinesHint;
private SwitchCompat swAddresses; private SwitchCompat swAddresses;
private EditText etMessageZoom; private TextView tvMessageZoom;
private SeekBar sbMessageZoom;
private SwitchCompat swOverviewMode; private SwitchCompat swOverviewMode;
private SwitchCompat swContrast; private SwitchCompat swContrast;
@ -247,7 +245,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
spPreviewLines = view.findViewById(R.id.spPreviewLines); spPreviewLines = view.findViewById(R.id.spPreviewLines);
tvPreviewLinesHint = view.findViewById(R.id.tvPreviewLinesHint); tvPreviewLinesHint = view.findViewById(R.id.tvPreviewLinesHint);
swAddresses = view.findViewById(R.id.swAddresses); swAddresses = view.findViewById(R.id.swAddresses);
etMessageZoom = view.findViewById(R.id.etMessageZoom); tvMessageZoom = view.findViewById(R.id.tvMessageZoom);
sbMessageZoom = view.findViewById(R.id.sbMessageZoom);
swOverviewMode = view.findViewById(R.id.swOverviewMode); swOverviewMode = view.findViewById(R.id.swOverviewMode);
swContrast = view.findViewById(R.id.swContrast); swContrast = view.findViewById(R.id.swContrast);
swMonospaced = view.findViewById(R.id.swMonospaced); swMonospaced = view.findViewById(R.id.swMonospaced);
@ -792,27 +791,24 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
} }
}); });
etMessageZoom.addTextChangedListener(new TextWatcher() { sbMessageZoom.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// Do nothing int message_zoom = progress + 50;
} if (message_zoom == 100)
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
try {
int zoom = (s.length() > 0 ? Integer.parseInt(s.toString()) : 0);
if (zoom == 0)
prefs.edit().remove("message_zoom").apply(); prefs.edit().remove("message_zoom").apply();
else else
prefs.edit().putInt("message_zoom", zoom).apply(); prefs.edit().putInt("message_zoom", message_zoom).apply();
} catch (NumberFormatException ex) { tvMessageZoom.setText(getString(R.string.title_advanced_message_text_zoom2, NF.format(message_zoom)));
Log.e(ex);
} }
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing
} }
@Override @Override
public void afterTextChanged(Editable s) { public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing // Do nothing
} }
}); });
@ -1120,8 +1116,11 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swAddresses.setChecked(prefs.getBoolean("addresses", false)); swAddresses.setChecked(prefs.getBoolean("addresses", false));
int message_zoom = prefs.getInt("message_zoom", 0); int message_zoom = prefs.getInt("message_zoom", 100);
etMessageZoom.setText(message_zoom == 0 ? null : Integer.toString(message_zoom)); tvMessageZoom.setText(getString(R.string.title_advanced_message_text_zoom2, NF.format(message_zoom)));
if (message_zoom >= 50 && message_zoom <= 250)
sbMessageZoom.setProgress(message_zoom - 50);
swOverviewMode.setChecked(prefs.getBoolean("overview_mode", false)); swOverviewMode.setChecked(prefs.getBoolean("overview_mode", false));
swContrast.setChecked(prefs.getBoolean("contrast", false)); swContrast.setChecked(prefs.getBoolean("contrast", false));

@ -1121,35 +1121,23 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginEnd="48dp" android:layout_marginEnd="48dp"
android:text="@string/title_advanced_message_text_zoom" android:text="@string/title_advanced_message_text_zoom2"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAddresses" /> app:layout_constraintTop_toBottomOf="@id/swAddresses" />
<eu.faircode.email.EditTextPlain <SeekBar
android:id="@+id/etMessageZoom" android:id="@+id/sbMessageZoom"
android:layout_width="100dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="100" android:max="200"
android:inputType="number" android:min="0"
android:maxLength="3" android:progress="50"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessageZoom" /> app:layout_constraintTop_toBottomOf="@id/tvMessageZoom" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvMessageZoomPercentage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="%"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintBottom_toBottomOf="@id/etMessageZoom"
app:layout_constraintStart_toEndOf="@id/etMessageZoom"
app:layout_constraintTop_toTopOf="@id/etMessageZoom" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swOverviewMode" android:id="@+id/swOverviewMode"
android:layout_width="0dp" android:layout_width="0dp"
@ -1158,7 +1146,7 @@
android:text="@string/title_advanced_overview_mode" android:text="@string/title_advanced_overview_mode"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etMessageZoom" app:layout_constraintTop_toBottomOf="@id/sbMessageZoom"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView

@ -444,7 +444,7 @@
<string name="title_advanced_addresses">Expand address details by default</string> <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_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_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_message_text_zoom2">Default message text zoom: %1$s %%</string>
<string name="title_advanced_overview_mode">Zoom original messages to fit the screen</string> <string name="title_advanced_overview_mode">Zoom original messages to fit the screen</string>
<string name="title_advanced_contrast">Use high contrast for message text</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_monospaced">Use monospaced font for message text by default</string>

Loading…
Cancel
Save