Added option for auto identity

pull/207/head
M66B 3 years ago
parent bb33dd9330
commit 189e568bdb

@ -1293,10 +1293,14 @@ public class FragmentCompose extends FragmentBase {
protected Long onExecute(Context context, Bundle args) throws Throwable { protected Long onExecute(Context context, Bundle args) throws Throwable {
String email = args.getString("email"); String email = args.getString("email");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean auto_identity = prefs.getBoolean("auto_identity", true);
boolean suggest_sent = prefs.getBoolean("suggest_sent", true); boolean suggest_sent = prefs.getBoolean("suggest_sent", true);
boolean suggest_received = prefs.getBoolean("suggest_received", false); boolean suggest_received = prefs.getBoolean("suggest_received", false);
if (!auto_identity)
return null;
List<Integer> types = new ArrayList<>(); List<Integer> types = new ArrayList<>();
if (suggest_sent) if (suggest_sent)
types.add(EntityContact.TYPE_TO); types.add(EntityContact.TYPE_TO);

@ -62,6 +62,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swSuggestFrequently; private SwitchCompat swSuggestFrequently;
private Button btnLocalContacts; private Button btnLocalContacts;
private Button btnBlockedSenders; private Button btnBlockedSenders;
private SwitchCompat swAutoIdentity;
private SwitchCompat swPrefixOnce; private SwitchCompat swPrefixOnce;
private SwitchCompat swPrefixCount; private SwitchCompat swPrefixCount;
private RadioGroup rgRe; private RadioGroup rgRe;
@ -102,7 +103,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"keyboard", "keyboard_no_fullscreen", "keyboard", "keyboard_no_fullscreen",
"suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "auto_identity",
"alt_re", "alt_fwd", "alt_re", "alt_fwd",
"send_reminders", "send_chips", "send_delayed", "send_reminders", "send_chips", "send_delayed",
"attach_new", "answer_action", "send_pending", "sound_sent", "attach_new", "answer_action", "send_pending", "sound_sent",
@ -131,6 +132,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swSuggestFrequently = view.findViewById(R.id.swSuggestFrequently); swSuggestFrequently = view.findViewById(R.id.swSuggestFrequently);
btnLocalContacts = view.findViewById(R.id.btnLocalContacts); btnLocalContacts = view.findViewById(R.id.btnLocalContacts);
btnBlockedSenders = view.findViewById(R.id.btnBlockedSenders); btnBlockedSenders = view.findViewById(R.id.btnBlockedSenders);
swAutoIdentity = view.findViewById(R.id.swAutoIdentity);
swPrefixOnce = view.findViewById(R.id.swPrefixOnce); swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swPrefixCount = view.findViewById(R.id.swPrefixCount); swPrefixCount = view.findViewById(R.id.swPrefixCount);
rgRe = view.findViewById(R.id.rgRe); rgRe = view.findViewById(R.id.rgRe);
@ -252,6 +254,14 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
} }
}); });
swAutoIdentity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("auto_identity", checked).apply();
swPrefixCount.setEnabled(checked);
}
});
swPrefixOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swPrefixOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -607,6 +617,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swSuggestReceived.setChecked(prefs.getBoolean("suggest_received", false)); swSuggestReceived.setChecked(prefs.getBoolean("suggest_received", false));
swSuggestFrequently.setChecked(prefs.getBoolean("suggest_frequently", false)); swSuggestFrequently.setChecked(prefs.getBoolean("suggest_frequently", false));
swSuggestFrequently.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked()); swSuggestFrequently.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
swAutoIdentity.setChecked(prefs.getBoolean("auto_identity", true));
swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", true)); swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", true));
swPrefixCount.setChecked(prefs.getBoolean("prefix_count", false)); swPrefixCount.setChecked(prefs.getBoolean("prefix_count", false));

@ -196,6 +196,30 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnLocalContacts" /> app:layout_constraintTop_toBottomOf="@id/btnLocalContacts" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoIdentity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_auto_identity"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnBlockedSenders"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvAutoIdentity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_auto_identity_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoIdentity" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPrefixOnce" android:id="@+id/swPrefixOnce"
android:layout_width="0dp" android:layout_width="0dp"
@ -205,7 +229,7 @@
android:text="@string/title_advanced_prefix_once" android:text="@string/title_advanced_prefix_once"
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/btnBlockedSenders" app:layout_constraintTop_toBottomOf="@id/tvAutoIdentity"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -395,6 +395,7 @@
<string name="title_advanced_send_pending">Show non-obtrusive send delayed icon</string> <string name="title_advanced_send_pending">Show non-obtrusive send delayed icon</string>
<string name="title_advanced_compose_font">Default font</string> <string name="title_advanced_compose_font">Default font</string>
<string name="title_advanced_auto_identity">Automatically select identities for new messages</string>
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string> <string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
<string name="title_advanced_prefix_count">Add count to reply prefix</string> <string name="title_advanced_prefix_count">Add count to reply prefix</string>
<string name="title_advanced_separate_reply">Insert a horizontal line before a reply/forward header</string> <string name="title_advanced_separate_reply">Insert a horizontal line before a reply/forward header</string>
@ -787,6 +788,7 @@
<string name="title_advanced_suggest_names_hint">If disabled, only email addresses will be used when selecting contacts</string> <string name="title_advanced_suggest_names_hint">If disabled, only email addresses will be used when selecting contacts</string>
<string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string> <string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string>
<string name="title_advanced_auto_identity_hint">This will select the last identity used for the first recipient of new messages</string>
<string name="title_advanced_send_reminders_hint">Show a warning when the message text or the subject is empty or when an attachment might be missing</string> <string name="title_advanced_send_reminders_hint">Show a warning when the message text or the subject is empty or when an attachment might be missing</string>
<string name="title_advanced_reply_move_hint">The email server could still add the messages to the sent message folder</string> <string name="title_advanced_reply_move_hint">The email server could still add the messages to the sent message folder</string>
<string name="title_advanced_usenet_hint">Insert \'-- \' between the text and the signature</string> <string name="title_advanced_usenet_hint">Insert \'-- \' between the text and the signature</string>

Loading…
Cancel
Save