mirror of https://github.com/M66B/FairEmail.git
Added option to suggest contacts of the current account only
This commit is contained in:
parent
1451764b61
commit
37d8194d60
|
@ -299,6 +299,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
private boolean lt_sentence;
|
||||
private boolean lt_auto;
|
||||
|
||||
private Long account = null;
|
||||
private long working = -1;
|
||||
private State state = State.NONE;
|
||||
private boolean show_images = false;
|
||||
|
@ -445,6 +446,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
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);
|
||||
final boolean suggest_account = prefs.getBoolean("suggest_account", false);
|
||||
final boolean cc_bcc = prefs.getBoolean("cc_bcc", false);
|
||||
final boolean circular = prefs.getBoolean("circular", true);
|
||||
|
||||
|
@ -1236,9 +1238,11 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
List<EntityContact> items = new ArrayList<>();
|
||||
if (suggest_sent)
|
||||
items.addAll(db.contact().searchContacts(null, EntityContact.TYPE_TO, wildcard));
|
||||
items.addAll(db.contact().searchContacts(
|
||||
suggest_account ? FragmentCompose.this.account : null, EntityContact.TYPE_TO, wildcard));
|
||||
if (suggest_received)
|
||||
for (EntityContact item : db.contact().searchContacts(null, EntityContact.TYPE_FROM, wildcard))
|
||||
for (EntityContact item : db.contact().searchContacts(
|
||||
suggest_account ? FragmentCompose.this.account : null, EntityContact.TYPE_FROM, wildcard))
|
||||
if (!MessageHelper.isNoReply(item.email))
|
||||
items.add(item);
|
||||
for (EntityContact item : items) {
|
||||
|
@ -7868,6 +7872,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
final Context context = parent.getContext();
|
||||
TupleIdentityEx identity = (TupleIdentityEx) parent.getAdapter().getItem(position);
|
||||
FragmentCompose.this.account = (identity == null ? null : identity.account);
|
||||
|
||||
int at = (identity == null ? -1 : identity.email.indexOf('@'));
|
||||
etExtra.setHint(at < 0 ? null : identity.email.substring(0, at));
|
||||
|
|
|
@ -69,6 +69,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
private SwitchCompat swSuggestSent;
|
||||
private SwitchCompat swSuggestReceived;
|
||||
private SwitchCompat swSuggestFrequently;
|
||||
private SwitchCompat swSuggestAccount;
|
||||
private SwitchCompat swAutoIdentity;
|
||||
private Button btnLocalContacts;
|
||||
private SwitchCompat swSendChips;
|
||||
|
@ -121,7 +122,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"keyboard", "keyboard_no_fullscreen",
|
||||
"suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "auto_identity",
|
||||
"suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "suggest_account", "auto_identity",
|
||||
"send_reminders", "send_chips", "send_nav_color", "send_pending",
|
||||
"auto_save_paragraph", "auto_save_dot", "discard_delete",
|
||||
"send_delayed",
|
||||
|
@ -156,6 +157,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
swSuggestSent = view.findViewById(R.id.swSuggestSent);
|
||||
swSuggestReceived = view.findViewById(R.id.swSuggestReceived);
|
||||
swSuggestFrequently = view.findViewById(R.id.swSuggestFrequently);
|
||||
swSuggestAccount = view.findViewById(R.id.swSuggestAccount);
|
||||
swAutoIdentity = view.findViewById(R.id.swAutoIdentity);
|
||||
btnLocalContacts = view.findViewById(R.id.btnLocalContacts);
|
||||
swSendChips = view.findViewById(R.id.swSendChips);
|
||||
|
@ -261,6 +263,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("suggest_sent", checked).apply();
|
||||
swSuggestFrequently.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
swSuggestAccount.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
swAutoIdentity.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
}
|
||||
});
|
||||
|
@ -270,6 +273,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("suggest_received", checked).apply();
|
||||
swSuggestFrequently.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
swSuggestAccount.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
swAutoIdentity.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
}
|
||||
});
|
||||
|
@ -281,6 +285,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
}
|
||||
});
|
||||
|
||||
swSuggestAccount.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("suggest_account", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swAutoIdentity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -762,6 +773,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
swSuggestReceived.setChecked(prefs.getBoolean("suggest_received", false));
|
||||
swSuggestFrequently.setChecked(prefs.getBoolean("suggest_frequently", false));
|
||||
swSuggestFrequently.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
swSuggestAccount.setChecked(prefs.getBoolean("suggest_account", false));
|
||||
swSuggestAccount.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
swAutoIdentity.setChecked(prefs.getBoolean("auto_identity", false));
|
||||
swAutoIdentity.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked());
|
||||
swSendChips.setChecked(prefs.getBoolean("send_chips", true));
|
||||
|
|
|
@ -182,6 +182,31 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swSuggestReceived"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swSuggestAccount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_suggest_account"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSuggestFrequently"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSuggestAccount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_suggest_account_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/swSuggestAccount" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoIdentity"
|
||||
android:layout_width="0dp"
|
||||
|
@ -191,7 +216,7 @@
|
|||
android:text="@string/title_advanced_auto_identity"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSuggestFrequently"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSuggestAccount"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -448,6 +448,7 @@
|
|||
<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_suggest_frequently">Sort suggested addresses on frequency of use</string>
|
||||
<string name="title_advanced_suggest_account">Limit suggestions to current account</string>
|
||||
<string name="title_advanced_alt_re_fwd">Alternative reply/forward prefix</string>
|
||||
<string name="title_advanced_send_chips">Show address bubbles</string>
|
||||
<string name="title_advanced_send_nav_color">Use the identity color for the bottom action bar</string>
|
||||
|
@ -967,6 +968,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_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_account_hint">This only applies to local contacts because contacts in the Android address book are not linked to specific accounts</string>
|
||||
<string name="title_advanced_auto_identity_hint">This will select the last identity used when selecting a recipient for 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_reply_move_hint">The email server could still add the messages to the sent message folder</string>
|
||||
|
|
Loading…
Reference in New Issue