Added option to use email addresses only

This commit is contained in:
M66B 2021-03-02 09:06:18 +01:00
parent 40ae07fbdf
commit c2b68ad8f0
4 changed files with 44 additions and 4 deletions

View File

@ -793,6 +793,7 @@ public class FragmentCompose extends FragmentBase {
final DB db = DB.getInstance(getContext());
final boolean suggest_names = prefs.getBoolean("suggest_names", true);
final boolean suggest_sent = prefs.getBoolean("suggest_sent", true);
final boolean suggest_received = prefs.getBoolean("suggest_received", false);
final boolean suggest_frequently = prefs.getBoolean("suggest_frequently", false);
@ -870,7 +871,7 @@ public class FragmentCompose extends FragmentBase {
String name = cursor.getString(colName);
String email = MessageHelper.sanitizeEmail(cursor.getString(colEmail));
StringBuilder sb = new StringBuilder();
if (name == null)
if (name == null || !suggest_names)
sb.append(email);
else {
sb.append("\"").append(name).append("\" ");
@ -2052,6 +2053,9 @@ public class FragmentCompose extends FragmentBase {
int requestCode = args.getInt("requestCode");
Uri uri = args.getParcelable("uri");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean suggest_names = prefs.getBoolean("suggest_names", true);
EntityMessage draft = null;
DB db = DB.getInstance(context);
@ -2092,7 +2096,7 @@ public class FragmentCompose extends FragmentBase {
if (address != null)
list.addAll(Arrays.asList(address));
list.add(new InternetAddress(email, name, StandardCharsets.UTF_8.name()));
list.add(new InternetAddress(email, suggest_names ? name : null, StandardCharsets.UTF_8.name()));
if (requestCode == REQUEST_CONTACT_TO)
draft.to = list.toArray(new Address[0]);

View File

@ -44,6 +44,7 @@ import androidx.preference.PreferenceManager;
public class FragmentOptionsSend extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swKeyboard;
private SwitchCompat swKeyboardNoFullscreen;
private SwitchCompat swSuggestNames;
private SwitchCompat swSuggestSent;
private SwitchCompat swSuggestReceived;
private SwitchCompat swSuggestFrequently;
@ -74,7 +75,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swLookupMx;
private final static String[] RESET_OPTIONS = new String[]{
"keyboard", "keyboard_no_fullscreen", "suggest_sent", "suggested_received", "suggest_frequently",
"keyboard", "keyboard_no_fullscreen",
"suggest_names", "suggest_sent", "suggested_received", "suggest_frequently",
"send_reminders", "send_delayed",
"compose_font", "prefix_once", "separate_reply", "extended_reply", "write_below", "quote_reply", "quote_limit", "resize_reply",
"signature_location", "signature_reply", "signature_forward",
@ -95,6 +97,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swKeyboard = view.findViewById(R.id.swKeyboard);
swKeyboardNoFullscreen = view.findViewById(R.id.swKeyboardNoFullscreen);
swSuggestNames = view.findViewById(R.id.swSuggestNames);
swSuggestSent = view.findViewById(R.id.swSuggestSent);
swSuggestReceived = view.findViewById(R.id.swSuggestReceived);
swSuggestFrequently = view.findViewById(R.id.swSuggestFrequently);
@ -144,6 +147,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
swSuggestNames.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("suggest_names", checked).apply();
}
});
swSuggestSent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -410,6 +420,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swKeyboard.setChecked(prefs.getBoolean("keyboard", true));
swKeyboardNoFullscreen.setChecked(prefs.getBoolean("keyboard_no_fullscreen", false));
swSuggestNames.setChecked(prefs.getBoolean("suggest_names", true));
swSuggestSent.setChecked(prefs.getBoolean("suggest_sent", true));
swSuggestReceived.setChecked(prefs.getBoolean("suggest_received", false));
swSuggestFrequently.setChecked(prefs.getBoolean("suggest_frequently", false));

View File

@ -67,6 +67,29 @@
app:layout_constraintTop_toBottomOf="@id/swKeyboard"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSuggestNames"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_suggest_names"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swKeyboardNoFullscreen"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSuggestNames"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_suggest_names_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSuggestNames" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSuggestLocal"
android:layout_width="wrap_content"
@ -76,7 +99,7 @@
android:text="@string/title_advanced_suggest_local"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swKeyboardNoFullscreen" />
app:layout_constraintTop_toBottomOf="@id/tvSuggestNames" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSuggestLocalHint"

View File

@ -308,6 +308,7 @@
<string name="title_advanced_keyboard">Show keyboard by default</string>
<string name="title_advanced_keyboard_no_fullscreen">Prevent fullscreen keyboard</string>
<string name="title_advanced_suggest_names">Use names and email addresses</string>
<string name="title_advanced_suggest_local">Suggest locally stored contacts</string>
<string name="title_advanced_suggest_sent">Suggest addresses found in sent messages</string>
<string name="title_advanced_suggest_received">Suggest addresses found in received messages</string>
@ -567,6 +568,7 @@
<string name="title_advanced_lookup_mx_hint">This will check if DNS MX records exist</string>
<string name="title_advanced_sync_delay_hint">This will slow down synchronizing messages</string>
<string name="title_advanced_suggest_names_hint">If disabled, only email addresses will be used</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_usenet_hint">Insert \'-- \' between the text and the signature</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>