Check identity email address, small fixes

pull/147/head
M66B 6 years ago
parent cbbcad98cb
commit ea177d5a61

@ -47,9 +47,9 @@ public class EntityIdentity {
public Long id; public Long id;
@NonNull @NonNull
public String name; public String name;
public String display;
@NonNull @NonNull
public String email; public String email;
public String display;
public String replyto; public String replyto;
public String bcc; public String bcc;
@NonNull @NonNull

@ -451,13 +451,13 @@ public class FragmentAccount extends FragmentEx {
int auth_type = args.getInt("auth_type"); int auth_type = args.getInt("auth_type");
if (TextUtils.isEmpty(host)) if (TextUtils.isEmpty(host))
throw new Throwable(getContext().getString(R.string.title_no_host)); throw new Throwable(context.getString(R.string.title_no_host));
if (TextUtils.isEmpty(port)) if (TextUtils.isEmpty(port))
port = (starttls ? "143" : "993"); port = (starttls ? "143" : "993");
if (TextUtils.isEmpty(user)) if (TextUtils.isEmpty(user))
throw new Throwable(getContext().getString(R.string.title_no_user)); throw new Throwable(context.getString(R.string.title_no_user));
if (TextUtils.isEmpty(password) && !insecure) if (TextUtils.isEmpty(password) && !insecure)
throw new Throwable(getContext().getString(R.string.title_no_password)); throw new Throwable(context.getString(R.string.title_no_password));
CheckResult result = new CheckResult(); CheckResult result = new CheckResult();
result.folders = new ArrayList<>(); result.folders = new ArrayList<>();
@ -647,17 +647,17 @@ public class FragmentAccount extends FragmentEx {
EntityFolder junk = (EntityFolder) args.getSerializable("junk"); EntityFolder junk = (EntityFolder) args.getSerializable("junk");
if (TextUtils.isEmpty(host)) if (TextUtils.isEmpty(host))
throw new Throwable(getContext().getString(R.string.title_no_host)); throw new Throwable(context.getString(R.string.title_no_host));
if (TextUtils.isEmpty(port)) if (TextUtils.isEmpty(port))
port = (starttls ? "143" : "993"); port = (starttls ? "143" : "993");
if (TextUtils.isEmpty(user)) if (TextUtils.isEmpty(user))
throw new Throwable(getContext().getString(R.string.title_no_user)); throw new Throwable(context.getString(R.string.title_no_user));
if (synchronize && TextUtils.isEmpty(password) && !insecure) if (synchronize && TextUtils.isEmpty(password) && !insecure)
throw new Throwable(getContext().getString(R.string.title_no_password)); throw new Throwable(context.getString(R.string.title_no_password));
if (TextUtils.isEmpty(interval)) if (TextUtils.isEmpty(interval))
interval = "19"; interval = "19";
if (synchronize && drafts == null) if (synchronize && drafts == null)
throw new Throwable(getContext().getString(R.string.title_no_drafts)); throw new Throwable(context.getString(R.string.title_no_drafts));
if (TextUtils.isEmpty(prefix)) if (TextUtils.isEmpty(prefix))
prefix = null; prefix = null;
@ -816,10 +816,10 @@ public class FragmentAccount extends FragmentEx {
} }
if (reload) if (reload)
ServiceSynchronize.reload(getContext(), "save account"); ServiceSynchronize.reload(context, "save account");
if (!synchronize) { if (!synchronize) {
NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel("receive", account.id.intValue()); nm.cancel("receive", account.id.intValue());
} }
@ -1070,7 +1070,7 @@ public class FragmentAccount extends FragmentEx {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
db.account().setAccountTbd(id); db.account().setAccountTbd(id);
ServiceSynchronize.reload(getContext(), "delete account"); ServiceSynchronize.reload(context, "delete account");
return null; return null;
} }

@ -171,7 +171,7 @@ public class FragmentFolder extends FragmentEx {
keep_days = sync_days; keep_days = sync_days;
boolean reload; boolean reload;
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
@ -233,7 +233,7 @@ public class FragmentFolder extends FragmentEx {
} }
if (reload) if (reload)
ServiceSynchronize.reload(getContext(), "save folder"); ServiceSynchronize.reload(context, "save folder");
return null; return null;
} }
@ -308,7 +308,7 @@ public class FragmentFolder extends FragmentEx {
protected Void onLoad(Context context, Bundle args) { protected Void onLoad(Context context, Bundle args) {
long id = args.getLong("id"); long id = args.getLong("id");
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(context);
int count = db.operation().getOperationCount(id, null); int count = db.operation().getOperationCount(id, null);
if (count > 0) if (count > 0)
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -316,7 +316,7 @@ public class FragmentFolder extends FragmentEx {
R.plurals.title_notification_operations, count, count)); R.plurals.title_notification_operations, count, count));
db.folder().setFolderTbd(id); db.folder().setFolderTbd(id);
ServiceSynchronize.reload(getContext(), "delete folder"); ServiceSynchronize.reload(context, "delete folder");
return null; return null;
} }

@ -29,6 +29,7 @@ import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Html; import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Patterns;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -46,7 +47,6 @@ import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView;
import com.android.colorpicker.ColorPickerDialog; import com.android.colorpicker.ColorPickerDialog;
import com.android.colorpicker.ColorPickerSwatch; import com.android.colorpicker.ColorPickerSwatch;
@ -74,11 +74,10 @@ import androidx.fragment.app.FragmentTransaction;
public class FragmentIdentity extends FragmentEx { public class FragmentIdentity extends FragmentEx {
private ViewGroup view; private ViewGroup view;
private EditText etName; private EditText etName;
private EditText etEmail;
private EditText etDisplay; private EditText etDisplay;
private Spinner spAccount; private Spinner spAccount;
private Button btnAdvanced; private Button btnAdvanced;
private TextView tvEmail;
private EditText etEmail;
private EditText etReplyTo; private EditText etReplyTo;
private EditText etBcc; private EditText etBcc;
private CheckBox cbDeliveryReceipt; private CheckBox cbDeliveryReceipt;
@ -134,12 +133,11 @@ public class FragmentIdentity extends FragmentEx {
// Get controls // Get controls
etName = view.findViewById(R.id.etName); etName = view.findViewById(R.id.etName);
etEmail = view.findViewById(R.id.etEmail);
spAccount = view.findViewById(R.id.spAccount); spAccount = view.findViewById(R.id.spAccount);
btnAdvanced = view.findViewById(R.id.btnAdvanced); btnAdvanced = view.findViewById(R.id.btnAdvanced);
etDisplay = view.findViewById(R.id.etDisplay); etDisplay = view.findViewById(R.id.etDisplay);
tvEmail = view.findViewById(R.id.tvEmail);
etEmail = view.findViewById(R.id.etEmail);
etReplyTo = view.findViewById(R.id.etReplyTo); etReplyTo = view.findViewById(R.id.etReplyTo);
etBcc = view.findViewById(R.id.etBcc); etBcc = view.findViewById(R.id.etBcc);
cbDeliveryReceipt = view.findViewById(R.id.cbDeliveryReceipt); cbDeliveryReceipt = view.findViewById(R.id.cbDeliveryReceipt);
@ -383,8 +381,8 @@ public class FragmentIdentity extends FragmentEx {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", id); args.putLong("id", id);
args.putString("name", etName.getText().toString()); args.putString("name", etName.getText().toString());
args.putString("display", etDisplay.getText().toString());
args.putString("email", etEmail.getText().toString()); args.putString("email", etEmail.getText().toString());
args.putString("display", etDisplay.getText().toString());
args.putString("replyto", etReplyTo.getText().toString()); args.putString("replyto", etReplyTo.getText().toString());
args.putString("bcc", etBcc.getText().toString()); args.putString("bcc", etBcc.getText().toString());
args.putBoolean("delivery_receipt", cbDeliveryReceipt.isChecked()); args.putBoolean("delivery_receipt", cbDeliveryReceipt.isChecked());
@ -429,17 +427,19 @@ public class FragmentIdentity extends FragmentEx {
EntityFolder sent = (EntityFolder) args.getSerializable("sent"); EntityFolder sent = (EntityFolder) args.getSerializable("sent");
if (TextUtils.isEmpty(name)) if (TextUtils.isEmpty(name))
throw new IllegalArgumentException(getContext().getString(R.string.title_no_name)); throw new IllegalArgumentException(context.getString(R.string.title_no_name));
if (TextUtils.isEmpty(email)) if (TextUtils.isEmpty(email))
throw new IllegalArgumentException(getContext().getString(R.string.title_no_email)); throw new IllegalArgumentException(context.getString(R.string.title_no_email));
if (!Patterns.EMAIL_ADDRESS.matcher(email).matches())
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid));
if (TextUtils.isEmpty(host)) if (TextUtils.isEmpty(host))
throw new IllegalArgumentException(getContext().getString(R.string.title_no_host)); throw new IllegalArgumentException(context.getString(R.string.title_no_host));
if (TextUtils.isEmpty(port)) if (TextUtils.isEmpty(port))
port = (starttls ? "587" : "465"); port = (starttls ? "587" : "465");
if (TextUtils.isEmpty(user)) if (TextUtils.isEmpty(user))
throw new IllegalArgumentException(getContext().getString(R.string.title_no_user)); throw new IllegalArgumentException(context.getString(R.string.title_no_user));
if (synchronize && TextUtils.isEmpty(password) && !insecure) if (synchronize && TextUtils.isEmpty(password) && !insecure)
throw new IllegalArgumentException(getContext().getString(R.string.title_no_password)); throw new IllegalArgumentException(context.getString(R.string.title_no_password));
email = email.toLowerCase(); email = email.toLowerCase();
@ -531,7 +531,7 @@ public class FragmentIdentity extends FragmentEx {
} }
if (reload) if (reload)
ServiceSynchronize.reload(getContext(), "save identity"); ServiceSynchronize.reload(context, "save identity");
return null; return null;
} }
@ -601,8 +601,8 @@ public class FragmentIdentity extends FragmentEx {
protected void onLoaded(Bundle args, final EntityIdentity identity) { protected void onLoaded(Bundle args, final EntityIdentity identity) {
if (savedInstanceState == null) { if (savedInstanceState == null) {
etName.setText(identity == null ? null : identity.name); etName.setText(identity == null ? null : identity.name);
etDisplay.setText(identity == null ? null : identity.display);
etEmail.setText(identity == null ? null : identity.email); etEmail.setText(identity == null ? null : identity.email);
etDisplay.setText(identity == null ? null : identity.display);
etReplyTo.setText(identity == null ? null : identity.replyto); etReplyTo.setText(identity == null ? null : identity.replyto);
etBcc.setText(identity == null ? null : identity.bcc); etBcc.setText(identity == null ? null : identity.bcc);
cbDeliveryReceipt.setChecked(identity == null ? false : identity.delivery_receipt); cbDeliveryReceipt.setChecked(identity == null ? false : identity.delivery_receipt);
@ -787,7 +787,7 @@ public class FragmentIdentity extends FragmentEx {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
db.identity().setIdentityTbd(id); db.identity().setIdentityTbd(id);
ServiceSynchronize.reload(getContext(), "delete identity"); ServiceSynchronize.reload(context, "delete identity");
return null; return null;
} }

@ -33,6 +33,26 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvName" /> app:layout_constraintTop_toBottomOf="@id/tvName" />
<TextView
android:id="@+id/tvEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_email"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etName" />
<EditText
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="emailAddress"
android:inputType="textEmailAddress"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvEmail" />
<!--- linked account --> <!--- linked account -->
<TextView <TextView
@ -43,7 +63,7 @@
android:text="@string/title_account_linked" android:text="@string/title_account_linked"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etName" /> app:layout_constraintTop_toBottomOf="@id/etEmail" />
<Spinner <Spinner
android:id="@+id/spAccount" android:id="@+id/spAccount"
@ -87,26 +107,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDisplay" /> app:layout_constraintTop_toBottomOf="@id/tvDisplay" />
<TextView
android:id="@+id/tvEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_email"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etDisplay" />
<EditText
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="emailAddress"
android:inputType="textEmailAddress"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvEmail" />
<!-- reply to --> <!-- reply to -->
<TextView <TextView
@ -117,7 +117,7 @@
android:text="@string/title_identity_reply_to" android:text="@string/title_identity_reply_to"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etEmail" /> app:layout_constraintTop_toBottomOf="@id/etDisplay" />
<EditText <EditText
android:id="@+id/etReplyTo" android:id="@+id/etReplyTo"
@ -506,6 +506,6 @@
android:id="@+id/grpAdvanced" android:id="@+id/grpAdvanced"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="tvDisplay,etDisplay,tvEmail,etEmail,tvReplyTo,etReplyTo,tvBcc,etBcc,cbDeliveryReceipt,cbReadReceipt,tvReceipt,tvProvider,spProvider,tvDomain,etDomain,btnAutoConfig,tvSmtp,tvHost,etHost,cbStartTls,tvPort,etPort,tvUser,etUser,tvPassword,tilPassword,btnColor,vwColor,ibColorDefault,tvSignature,etSignature,ibPro,cbSynchronize,cbPrimary,tvSent,spSent,tvSentHint" /> app:constraint_referenced_ids="tvDisplay,etDisplay,tvReplyTo,etReplyTo,tvBcc,etBcc,cbDeliveryReceipt,cbReadReceipt,tvReceipt,tvProvider,spProvider,tvDomain,etDomain,btnAutoConfig,tvSmtp,tvHost,etHost,cbStartTls,tvPort,etPort,tvUser,etUser,tvPassword,tilPassword,btnColor,vwColor,ibColorDefault,tvSignature,etSignature,ibPro,cbSynchronize,cbPrimary,tvSent,spSent,tvSentHint" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

@ -187,6 +187,7 @@
<string name="title_check">Check</string> <string name="title_check">Check</string>
<string name="title_no_name">Name missing</string> <string name="title_no_name">Name missing</string>
<string name="title_no_email">Email address missing</string> <string name="title_no_email">Email address missing</string>
<string name="title_email_invalid">Email address invalid</string>
<string name="title_no_account">Account missing</string> <string name="title_no_account">Account missing</string>
<string name="title_no_host">Host name missing</string> <string name="title_no_host">Host name missing</string>
<string name="title_no_user">User name missing</string> <string name="title_no_user">User name missing</string>

Loading…
Cancel
Save