mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 08:29:24 +00:00
Linked contacts
This commit is contained in:
parent
86bcad4910
commit
f4f4b5c939
4 changed files with 69 additions and 15 deletions
|
@ -24,9 +24,12 @@ import static com.google.android.material.textfield.TextInputLayout.END_ICON_PAS
|
|||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_OAUTH;
|
||||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.net.Uri;
|
||||
|
@ -122,7 +125,8 @@ public class FragmentIdentity extends FragmentBase {
|
|||
private EditText etBcc;
|
||||
private EditText etInternal;
|
||||
private Button btnUri;
|
||||
private TextView tvUri;
|
||||
private TextView tvUriInfo;
|
||||
private TextView tvUriPro;
|
||||
private CheckBox cbSignDefault;
|
||||
private CheckBox cbEncryptDefault;
|
||||
private CheckBox cbUnicode;
|
||||
|
@ -225,7 +229,8 @@ public class FragmentIdentity extends FragmentBase {
|
|||
etBcc = view.findViewById(R.id.etBcc);
|
||||
etInternal = view.findViewById(R.id.etInternal);
|
||||
btnUri = view.findViewById(R.id.btnUri);
|
||||
tvUri = view.findViewById(R.id.tvUri);
|
||||
tvUriInfo = view.findViewById(R.id.tvUriInfo);
|
||||
tvUriPro = view.findViewById(R.id.tvUriPro);
|
||||
cbSignDefault = view.findViewById(R.id.cbSignDefault);
|
||||
cbEncryptDefault = view.findViewById(R.id.cbEncryptDefault);
|
||||
cbUnicode = view.findViewById(R.id.cbUnicode);
|
||||
|
@ -496,6 +501,8 @@ public class FragmentIdentity extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
Helper.linkPro(tvUriPro);
|
||||
|
||||
cbEncryptDefault.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
@ -542,10 +549,6 @@ public class FragmentIdentity extends FragmentBase {
|
|||
cbInsecure.setVisibility(View.GONE);
|
||||
|
||||
btnAdvanced.setVisibility(View.GONE);
|
||||
if (!BuildConfig.DEBUG) {
|
||||
Helper.hide(btnUri);
|
||||
Helper.hide(tvUri);
|
||||
}
|
||||
|
||||
etEhlo.setHint(EmailService.getDefaultEhlo());
|
||||
|
||||
|
@ -729,7 +732,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
args.putString("cc", etCc.getText().toString().trim());
|
||||
args.putString("bcc", etBcc.getText().toString().trim());
|
||||
args.putString("internal", etInternal.getText().toString().replaceAll(" ", ""));
|
||||
args.putString("uri", tvUri.getText().toString());
|
||||
args.putString("uri", (String) btnUri.getTag());
|
||||
args.putBoolean("sign_default", cbSignDefault.isChecked());
|
||||
args.putBoolean("encrypt_default", cbEncryptDefault.isChecked());
|
||||
args.putBoolean("unicode", cbUnicode.isChecked());
|
||||
|
@ -1184,6 +1187,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
outState.putInt("fair:auth", auth);
|
||||
outState.putString("fair:authprovider", provider);
|
||||
outState.putString("fair:html", signature);
|
||||
outState.putString("fair:uri", (String) btnUri.getTag());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
|
@ -1265,7 +1269,8 @@ public class FragmentIdentity extends FragmentBase {
|
|||
etCc.setText(identity == null ? null : identity.cc);
|
||||
etBcc.setText(identity == null ? null : identity.bcc);
|
||||
etInternal.setText(identity == null ? null : identity.internal);
|
||||
tvUri.setText(identity == null ? null : identity.uri);
|
||||
btnUri.setTag(identity == null ? null : identity.uri);
|
||||
tvUriInfo.setText(identity == null ? null : getUriInfo(identity.uri));
|
||||
cbSignDefault.setChecked(identity != null && identity.sign_default);
|
||||
cbEncryptDefault.setChecked(identity != null && identity.encrypt_default);
|
||||
cbUnicode.setChecked(identity != null && identity.unicode);
|
||||
|
@ -1301,6 +1306,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
provider = savedInstanceState.getString("fair:authprovider");
|
||||
if (signature == null)
|
||||
signature = savedInstanceState.getString("fair:html");
|
||||
btnUri.setTag(savedInstanceState.getString("fair:uri"));
|
||||
}
|
||||
|
||||
Helper.setViewsEnabled(view, true);
|
||||
|
@ -1522,6 +1528,30 @@ public class FragmentIdentity extends FragmentBase {
|
|||
|
||||
private void onPickUri(Intent intent) {
|
||||
Uri uri = (intent == null ? null : intent.getData());
|
||||
tvUri.setText(uri == null ? null : uri.toString());
|
||||
btnUri.setTag(uri == null ? null : uri.toString());
|
||||
tvUriInfo.setText(uri == null ? null : getUriInfo(uri.toString()));
|
||||
}
|
||||
|
||||
private String getUriInfo(String uri) {
|
||||
if (uri == null)
|
||||
return null;
|
||||
if (!hasPermission(Manifest.permission.READ_CONTACTS))
|
||||
return null;
|
||||
|
||||
try {
|
||||
ContentResolver resolver = getContext().getContentResolver();
|
||||
try (Cursor cursor = resolver.query(Uri.parse(uri),
|
||||
new String[]{
|
||||
ContactsContract.Contacts.DISPLAY_NAME_PRIMARY
|
||||
},
|
||||
null, null, null)) {
|
||||
if (cursor.moveToNext())
|
||||
return cursor.getString(0);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1089,7 +1089,7 @@ public class MessageHelper {
|
|||
db.endTransaction();
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (ActivityBilling.isPro(context)) {
|
||||
VCard vcard = null;
|
||||
|
||||
if (identity.uri != null &&
|
||||
|
|
|
@ -787,14 +787,37 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/tvInternalHint" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvUri"
|
||||
android:id="@+id/tvUriHint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Contact URI"
|
||||
android:text="@string/title_advanced_uri"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnUri" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvUriInfo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="Contact URI"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUriHint" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvUriPro"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/title_pro_feature"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorLink"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUriInfo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvE2Encryption"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -803,7 +826,7 @@
|
|||
android:text="@string/title_advanced_e2e_encryption"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUri" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUriPro" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbSignDefault"
|
||||
|
@ -1007,7 +1030,7 @@
|
|||
cbSenderExtra,cbSenderExtraName,cbReplyExtraName,tvSenderExtra,etSenderExtra,ibSenderExtra,tvSenderExtraHint,
|
||||
tvReplyTo,etReplyTo,tvCc,etCc,tvCcHint,tvBcc,etBcc,tvBccHint,
|
||||
tvInternal,etInternal,tvInternalHint,
|
||||
btnUri,tvUri,
|
||||
btnUri,tvUriHint,tvUriInfo,tvUriPro,
|
||||
tvE2Encryption,cbSignDefault,cbEncryptDefault,
|
||||
cbUnicode,tvUnicodeHint,cbOctetMime,tvMaxSize,etMaxSize" />
|
||||
|
||||
|
|
|
@ -975,6 +975,7 @@
|
|||
<string name="title_advanced_sender_hint">Most providers do not allow modified sender addresses</string>
|
||||
<string name="title_advanced_bcc_hint">The address won\'t be shown, but will be added on sending</string>
|
||||
<string name="title_advanced_internal_hint">There will be a warning when sending to another domain</string>
|
||||
<string name="title_advanced_uri">The info of the selected contact will be used to attach a vCard</string>
|
||||
<string name="title_advanced_e2e_encryption">Options for end-to-end encryption</string>
|
||||
|
||||
<string name="title_advanced_display_harmful_hint">Disabling this option might be harmful to your privacy</string>
|
||||
|
@ -1067,7 +1068,7 @@
|
|||
<string name="title_advanced_sender_regex">Regex to match username of incoming email addresses</string>
|
||||
<string name="title_identity_reply_to">Reply to address</string>
|
||||
<string name="title_identity_internal">Internal domain names (comma separated)</string>
|
||||
<string name="title_identity_uri" translatable="false">Link contact</string>
|
||||
<string name="title_identity_uri">Link contact</string>
|
||||
<string name="title_identity_unicode">Allow UTF-8 in message headers</string>
|
||||
<string name="title_identity_unicode_remark">Most servers do not support this</string>
|
||||
<string name="title_identity_octetmime">Allow 8BITMIME</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue