Moved resize option to send section

pull/156/head
M66B 5 years ago
parent fed309423b
commit 151d13c152

@ -27,10 +27,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -47,13 +44,10 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swCollapse;
private SwitchCompat swAutoRead;
private SwitchCompat swAutoMove;
private SwitchCompat swAutoResize;
private Spinner spAutoResize;
private TextView tvAutoResize;
private final static String[] RESET_OPTIONS = new String[]{
"pull", "autoscroll", "swipenav", "autoexpand", "autoclose", "autonext",
"collapse", "autoread", "automove", "autoresize", "resize"
"collapse", "autoread", "automove"
};
@Override
@ -75,9 +69,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swCollapse = view.findViewById(R.id.swCollapse);
swAutoRead = view.findViewById(R.id.swAutoRead);
swAutoMove = view.findViewById(R.id.swAutoMove);
swAutoResize = view.findViewById(R.id.swAutoResize);
spAutoResize = view.findViewById(R.id.spAutoResize);
tvAutoResize = view.findViewById(R.id.tvAutoResize);
setOptions();
@ -149,28 +140,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swAutoResize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("autoresize", checked).apply();
spAutoResize.setEnabled(checked);
}
});
spAutoResize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.resizeValues);
prefs.edit().putInt("resize", values[position]).apply();
tvAutoResize.setText(getString(R.string.title_advanced_resize_pixels, values[position]));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("resize").apply();
}
});
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;
@ -225,16 +194,5 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swCollapse.setChecked(prefs.getBoolean("collapse", false));
swAutoRead.setChecked(prefs.getBoolean("autoread", false));
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
swAutoResize.setChecked(prefs.getBoolean("autoresize", true));
int resize = prefs.getInt("resize", FragmentCompose.REDUCED_IMAGE_SIZE);
int[] resizeValues = getResources().getIntArray(R.array.resizeValues);
for (int pos = 0; pos < resizeValues.length; pos++)
if (resizeValues[pos] == resize) {
spAutoResize.setSelection(pos);
tvAutoResize.setText(getString(R.string.title_advanced_resize_pixels, resizeValues[pos]));
break;
}
spAutoResize.setEnabled(swAutoResize.isChecked());
}
}

@ -30,6 +30,7 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -38,11 +39,14 @@ import androidx.preference.PreferenceManager;
public class FragmentOptionsSend extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swPrefixOnce;
private SwitchCompat swAutoResize;
private Spinner spAutoResize;
private TextView tvAutoResize;
private SwitchCompat swAutoSend;
private Spinner spSendDelayed;
private final static String[] RESET_OPTIONS = new String[]{
"prefix_once", "autosend", "send_delayed"
"prefix_once", "autoresize", "resize", "autosend", "send_delayed"
};
@Override
@ -56,6 +60,9 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
// Get controls
swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swAutoResize = view.findViewById(R.id.swAutoResize);
spAutoResize = view.findViewById(R.id.spAutoResize);
tvAutoResize = view.findViewById(R.id.tvAutoResize);
swAutoSend = view.findViewById(R.id.swAutoSend);
spSendDelayed = view.findViewById(R.id.spSendDelayed);
@ -72,6 +79,28 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
swAutoResize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("autoresize", checked).apply();
spAutoResize.setEnabled(checked);
}
});
spAutoResize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.resizeValues);
prefs.edit().putInt("resize", values[position]).apply();
tvAutoResize.setText(getString(R.string.title_advanced_resize_pixels, values[position]));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("resize").apply();
}
});
swAutoSend.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -137,6 +166,19 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", false));
swAutoResize.setChecked(prefs.getBoolean("autoresize", true));
int resize = prefs.getInt("resize", FragmentCompose.REDUCED_IMAGE_SIZE);
int[] resizeValues = getResources().getIntArray(R.array.resizeValues);
for (int pos = 0; pos < resizeValues.length; pos++)
if (resizeValues[pos] == resize) {
spAutoResize.setSelection(pos);
tvAutoResize.setText(getString(R.string.title_advanced_resize_pixels, resizeValues[pos]));
break;
}
spAutoResize.setEnabled(swAutoResize.isChecked());
swAutoSend.setChecked(!prefs.getBoolean("autosend", false));
int send_delayed = prefs.getInt("send_delayed", 0);

@ -144,34 +144,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoRead"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoResize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_autoresize"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoMove"
app:switchPadding="12dp" />
<Spinner
android:id="@+id/spAutoResize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/resizeNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoResize" />
<TextView
android:id="@+id/tvAutoResize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_advanced_resize_pixels"
app:layout_constraintBottom_toBottomOf="@id/spAutoResize"
app:layout_constraintStart_toEndOf="@id/spAutoResize"
app:layout_constraintTop_toTopOf="@id/spAutoResize" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -28,6 +28,34 @@
app:layout_constraintTop_toTopOf="parent"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoResize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_autoresize"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPrefixOnce"
app:switchPadding="12dp" />
<Spinner
android:id="@+id/spAutoResize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/resizeNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoResize" />
<TextView
android:id="@+id/tvAutoResize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_advanced_resize_pixels"
app:layout_constraintBottom_toBottomOf="@id/spAutoResize"
app:layout_constraintStart_toEndOf="@id/spAutoResize"
app:layout_constraintTop_toTopOf="@id/spAutoResize" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoSend"
android:layout_width="match_parent"
@ -35,7 +63,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_advanced_autosend"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPrefixOnce"
app:layout_constraintTop_toBottomOf="@id/spAutoResize"
app:switchPadding="12dp" />
<TextView

@ -167,6 +167,12 @@
<string name="title_advanced_unseen">All unread messages</string>
<string name="title_advanced_flagged">All starred messages</string>
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
<string name="title_advanced_autoresize">Automatically resize attached and embedded images</string>
<string name="title_advanced_resize_pixels">&lt; %1$d pixels</string>
<string name="title_advanced_autosend">Confirm sending messages</string>
<string name="title_advanced_send_delayed">Delay sending messages</string>
<string name="title_advanced_metered">Use metered connections</string>
<string name="title_advanced_download">Automatically download messages and attachments on a metered connection up to</string>
<string name="title_advanced_roaming">Download messages and attachments while roaming</string>
@ -197,13 +203,6 @@
<string name="title_advanced_autonext">Automatically go to next conversation on close conversation</string>
<string name="title_advanced_autoread">Automatically mark messages read on moving messages</string>
<string name="title_advanced_automove">Confirm moving messages</string>
<string name="title_advanced_autoresize">Automatically resize attached and embedded images</string>
<string name="title_advanced_resize_pixels">&lt; %1$d pixels</string>
<string name="title_advanced_sender">Allow editing sender address</string>
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
<string name="title_advanced_autosend">Confirm sending messages</string>
<string name="title_advanced_send_delayed">Delay sending messages</string>
<string name="title_advanced_notify_group">Group new message notifications</string>
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
@ -253,6 +252,7 @@
<string name="title_select">Select &#8230;</string>
<string name="title_identity_name">Your name</string>
<string name="title_identity_email">Your email address</string>
<string name="title_advanced_sender">Allow editing sender address</string>
<string name="title_identity_reply_to">Reply to address</string>
<string name="title_identity_encrypt">Encrypt by default</string>
<string name="title_identity_use_ip_hint">In case of \'invalid greeting\', \'requires valid address\' or a similar error, try to change this setting</string>

Loading…
Cancel
Save