mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-29 05:15:13 +02:00
Added settings to suggest local sent/received addresses
This commit is contained in:
@@ -144,6 +144,12 @@ public class ApplicationEx extends Application {
|
||||
editor.putBoolean("ascending_list", prefs.getBoolean("ascending", false));
|
||||
editor.remove("ascending");
|
||||
}
|
||||
|
||||
} else if (version < 701) {
|
||||
if (prefs.getBoolean("suggest_local", false)) {
|
||||
editor.putBoolean("suggest_sent", true);
|
||||
editor.remove("suggest_local");
|
||||
}
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG && false) {
|
||||
|
||||
@@ -528,16 +528,18 @@ public class FragmentCompose extends FragmentBase {
|
||||
});
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean suggest_local = prefs.getBoolean("suggest_local", false);
|
||||
boolean suggest_sent = prefs.getBoolean("suggest_sent", false);
|
||||
boolean suggest_received = prefs.getBoolean("suggest_received", false);
|
||||
|
||||
cadapter.setFilterQueryProvider(new FilterQueryProvider() {
|
||||
public Cursor runQuery(CharSequence typed) {
|
||||
Log.i("Searching provided contact=" + typed);
|
||||
Log.i("Suggest contact=" + typed);
|
||||
|
||||
String wildcard = "%" + typed + "%";
|
||||
boolean contacts = Helper.hasPermission(getContext(), Manifest.permission.READ_CONTACTS);
|
||||
MatrixCursor provided = new MatrixCursor(new String[]{"_id", "name", "email"});
|
||||
List<Cursor> cursors = new ArrayList<>();
|
||||
|
||||
MatrixCursor provided = new MatrixCursor(new String[]{"_id", "name", "email"});
|
||||
boolean contacts = Helper.hasPermission(getContext(), Manifest.permission.READ_CONTACTS);
|
||||
if (contacts) {
|
||||
Cursor cursor = resolver.query(
|
||||
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
||||
@@ -553,18 +555,25 @@ public class FragmentCompose extends FragmentBase {
|
||||
"CASE WHEN " + ContactsContract.Contacts.DISPLAY_NAME + " NOT LIKE '%@%' THEN 0 ELSE 1 END" +
|
||||
", " + ContactsContract.Contacts.DISPLAY_NAME + " COLLATE NOCASE" +
|
||||
", " + ContactsContract.CommonDataKinds.Email.DATA + " COLLATE NOCASE");
|
||||
|
||||
while (cursor != null && cursor.moveToNext())
|
||||
provided.newRow()
|
||||
.add(cursor.getLong(0))
|
||||
.add(cursor.getString(1))
|
||||
.add(cursor.getString(2));
|
||||
|
||||
if (!suggest_local)
|
||||
return provided;
|
||||
}
|
||||
cursors.add(provided);
|
||||
|
||||
Cursor local = db.contact().searchContacts(null, null, wildcard);
|
||||
return new MergeCursor(new Cursor[]{provided, local});
|
||||
if (suggest_sent)
|
||||
cursors.add(db.contact().searchContacts(null, EntityContact.TYPE_TO, wildcard));
|
||||
|
||||
if (suggest_received)
|
||||
cursors.add(db.contact().searchContacts(null, EntityContact.TYPE_FROM, wildcard));
|
||||
|
||||
if (cursors.size() == 1)
|
||||
return cursors.get(0);
|
||||
else
|
||||
return new MergeCursor(cursors.toArray(new Cursor[0]));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ import androidx.preference.PreferenceManager;
|
||||
|
||||
public class FragmentOptionsSend extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private SwitchCompat swKeyboard;
|
||||
private SwitchCompat swSuggestLocal;
|
||||
private SwitchCompat swSuggestSent;
|
||||
private SwitchCompat swSuggestReceived;
|
||||
private SwitchCompat swPrefixOnce;
|
||||
private SwitchCompat swPlainOnly;
|
||||
private SwitchCompat swUsenetSignature;
|
||||
@@ -52,7 +53,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
private Spinner spSendDelayed;
|
||||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"keyboard", "suggest_local", "prefix_once", "plain_only", "usenet_signature", "autoresize", "resize", "lookup_mx", "send_delayed"
|
||||
"keyboard", "suggest_sent", "suggested_received", "prefix_once", "plain_only", "usenet_signature",
|
||||
"autoresize", "resize", "lookup_mx", "send_delayed"
|
||||
};
|
||||
|
||||
@Override
|
||||
@@ -66,7 +68,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
// Get controls
|
||||
|
||||
swKeyboard = view.findViewById(R.id.swKeyboard);
|
||||
swSuggestLocal = view.findViewById(R.id.swSuggestLocal);
|
||||
swSuggestSent = view.findViewById(R.id.swSuggestSent);
|
||||
swSuggestReceived = view.findViewById(R.id.swSuggestReceived);
|
||||
swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
|
||||
swPlainOnly = view.findViewById(R.id.swPlainOnly);
|
||||
swUsenetSignature = view.findViewById(R.id.swUsenetSignature);
|
||||
@@ -89,10 +92,17 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
}
|
||||
});
|
||||
|
||||
swSuggestLocal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
swSuggestSent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("suggest_local", checked).apply();
|
||||
prefs.edit().putBoolean("suggest_sent", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swSuggestReceived.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("suggest_received", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -206,7 +216,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
swKeyboard.setChecked(prefs.getBoolean("keyboard", true));
|
||||
swSuggestLocal.setChecked(prefs.getBoolean("suggest_local", false));
|
||||
swSuggestSent.setChecked(prefs.getBoolean("suggest_sent", false));
|
||||
swSuggestReceived.setChecked(prefs.getBoolean("suggest_received", false));
|
||||
swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", true));
|
||||
swPlainOnly.setChecked(prefs.getBoolean("plain_only", false));
|
||||
swUsenetSignature.setChecked(prefs.getBoolean("usenet_signature", false));
|
||||
|
||||
@@ -31,16 +31,16 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swSuggestLocal"
|
||||
android:layout_width="0dp"
|
||||
<TextView
|
||||
android:id="@+id/tvSuggestLocal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_suggest_local"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swKeyboard"
|
||||
app:switchPadding="12dp" />
|
||||
app:layout_constraintTop_toBottomOf="@id/swKeyboard" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSuggestLocalHint"
|
||||
@@ -52,7 +52,31 @@
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSuggestLocal" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSuggestLocal" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swSuggestSent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_suggest_sent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSuggestLocalHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swSuggestReceived"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_suggest_received"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSuggestSent"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swPrefixOnce"
|
||||
@@ -63,7 +87,7 @@
|
||||
android:text="@string/title_advanced_prefix_once"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSuggestLocalHint"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSuggestReceived"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
||||
@@ -215,6 +215,8 @@
|
||||
|
||||
<string name="title_advanced_keyboard">Show keyboard by default</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>
|
||||
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
|
||||
<string name="title_advanced_plain_only">Send plain text only by default</string>
|
||||
<string name="title_advanced_usenet_signature">Usenet signature convention</string>
|
||||
|
||||
Reference in New Issue
Block a user