|
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
|
|
|
|
|
|
|
|
|
|
|
import android.arch.lifecycle.Observer;
|
|
|
|
import android.arch.lifecycle.Observer;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
@ -28,6 +29,7 @@ import android.support.design.widget.TextInputLayout;
|
|
|
|
import android.support.v4.app.LoaderManager;
|
|
|
|
import android.support.v4.app.LoaderManager;
|
|
|
|
import android.support.v4.content.AsyncTaskLoader;
|
|
|
|
import android.support.v4.content.AsyncTaskLoader;
|
|
|
|
import android.support.v4.content.Loader;
|
|
|
|
import android.support.v4.content.Loader;
|
|
|
|
|
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.TextWatcher;
|
|
|
@ -41,6 +43,7 @@ import android.widget.Button;
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.EditText;
|
|
|
|
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
import android.widget.Spinner;
|
|
|
|
import android.widget.Spinner;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
@ -48,6 +51,8 @@ import android.widget.Toast;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Properties;
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.mail.Session;
|
|
|
|
import javax.mail.Session;
|
|
|
|
import javax.mail.Transport;
|
|
|
|
import javax.mail.Transport;
|
|
|
@ -68,8 +73,11 @@ public class FragmentIdentity extends FragmentEx {
|
|
|
|
private CheckBox cbPrimary;
|
|
|
|
private CheckBox cbPrimary;
|
|
|
|
private Button btnSave;
|
|
|
|
private Button btnSave;
|
|
|
|
private ProgressBar pbCheck;
|
|
|
|
private ProgressBar pbCheck;
|
|
|
|
|
|
|
|
private ImageButton ibDelete;
|
|
|
|
// TODO: loading spinner
|
|
|
|
// TODO: loading spinner
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ExecutorService executor = Executors.newCachedThreadPool();
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Nullable
|
|
|
|
@Nullable
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
@ -99,6 +107,7 @@ public class FragmentIdentity extends FragmentEx {
|
|
|
|
cbPrimary = view.findViewById(R.id.cbPrimary);
|
|
|
|
cbPrimary = view.findViewById(R.id.cbPrimary);
|
|
|
|
btnSave = view.findViewById(R.id.btnSave);
|
|
|
|
btnSave = view.findViewById(R.id.btnSave);
|
|
|
|
pbCheck = view.findViewById(R.id.pbCheck);
|
|
|
|
pbCheck = view.findViewById(R.id.pbCheck);
|
|
|
|
|
|
|
|
ibDelete = view.findViewById(R.id.ibDelete);
|
|
|
|
|
|
|
|
|
|
|
|
// Wire controls
|
|
|
|
// Wire controls
|
|
|
|
|
|
|
|
|
|
|
@ -174,10 +183,38 @@ public class FragmentIdentity extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ibDelete.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
|
|
|
|
|
|
builder
|
|
|
|
|
|
|
|
.setMessage(R.string.title_identity_delete)
|
|
|
|
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
|
|
|
// TODO: spinner
|
|
|
|
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DB.getInstance(getContext()).identity().deleteIdentity(id);
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null).show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
// Initialize
|
|
|
|
etName.requestFocus();
|
|
|
|
etName.requestFocus();
|
|
|
|
tilPassword.setPasswordVisibilityToggleEnabled(id < 0);
|
|
|
|
tilPassword.setPasswordVisibilityToggleEnabled(id < 0);
|
|
|
|
pbCheck.setVisibility(View.GONE);
|
|
|
|
pbCheck.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
ibDelete.setVisibility(id < 0 ? View.GONE : View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
// Observer
|
|
|
|
// Observer
|
|
|
|
DB.getInstance(getContext()).identity().liveIdentity(id).observe(this, new Observer<EntityIdentity>() {
|
|
|
|
DB.getInstance(getContext()).identity().liveIdentity(id).observe(this, new Observer<EntityIdentity>() {
|
|
|
|