|
|
|
@ -4692,78 +4692,72 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
if (ex.getCause() instanceof CertificateException)
|
|
|
|
|
v.getContext().startActivity(new Intent(v.getContext(), ActivitySetup.class)
|
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
|
|
|
|
.putExtra("tab", "encryption"));
|
|
|
|
|
else {
|
|
|
|
|
EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem();
|
|
|
|
|
|
|
|
|
|
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), vwAnchor);
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_send_dialog, 1, R.string.title_send_dialog);
|
|
|
|
|
if (identity != null)
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_reset_sign_key, 2, R.string.title_reset_sign_key);
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_advanced_manage_certificates, 3, R.string.title_advanced_manage_certificates);
|
|
|
|
|
EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem();
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
|
int itemId = item.getItemId();
|
|
|
|
|
if (itemId == R.string.title_send_dialog) {
|
|
|
|
|
Helper.hideKeyboard(view);
|
|
|
|
|
|
|
|
|
|
FragmentDialogSend fragment = new FragmentDialogSend();
|
|
|
|
|
fragment.setArguments(args);
|
|
|
|
|
fragment.setTargetFragment(FragmentCompose.this, REQUEST_SEND);
|
|
|
|
|
fragment.show(getParentFragmentManager(), "compose:send");
|
|
|
|
|
return true;
|
|
|
|
|
} else if (itemId == R.string.title_reset_sign_key) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", identity.id);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPostExecute(Bundle args) {
|
|
|
|
|
ToastEx.makeText(getContext(), R.string.title_completed, Toast.LENGTH_LONG).show();
|
|
|
|
|
}
|
|
|
|
|
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), vwAnchor);
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_send_dialog, 1, R.string.title_send_dialog);
|
|
|
|
|
if (identity != null)
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_reset_sign_key, 2, R.string.title_reset_sign_key);
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_advanced_manage_certificates, 3, R.string.title_advanced_manage_certificates);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
|
int itemId = item.getItemId();
|
|
|
|
|
if (itemId == R.string.title_send_dialog) {
|
|
|
|
|
Helper.hideKeyboard(view);
|
|
|
|
|
|
|
|
|
|
FragmentDialogSend fragment = new FragmentDialogSend();
|
|
|
|
|
fragment.setArguments(args);
|
|
|
|
|
fragment.setTargetFragment(FragmentCompose.this, REQUEST_SEND);
|
|
|
|
|
fragment.show(getParentFragmentManager(), "compose:send");
|
|
|
|
|
return true;
|
|
|
|
|
} else if (itemId == R.string.title_reset_sign_key) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", identity.id);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPostExecute(Bundle args) {
|
|
|
|
|
ToastEx.makeText(getContext(), R.string.title_completed, Toast.LENGTH_LONG).show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
try {
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
db.identity().setIdentitySignKey(id, null);
|
|
|
|
|
db.identity().setIdentitySignKeyAlias(id, null);
|
|
|
|
|
db.identity().setIdentityEncrypt(id, 0);
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
try {
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
} finally {
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
}
|
|
|
|
|
db.identity().setIdentitySignKey(id, null);
|
|
|
|
|
db.identity().setIdentitySignKeyAlias(id, null);
|
|
|
|
|
db.identity().setIdentityEncrypt(id, 0);
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
} finally {
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(FragmentCompose.this, args, "identity:reset");
|
|
|
|
|
} else if (itemId == R.string.title_advanced_manage_certificates) {
|
|
|
|
|
startActivity(new Intent(getContext(), ActivitySetup.class)
|
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
|
|
|
|
.putExtra("tab", "encryption"));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(FragmentCompose.this, args, "identity:reset");
|
|
|
|
|
} else if (itemId == R.string.title_advanced_manage_certificates) {
|
|
|
|
|
startActivity(new Intent(getContext(), ActivitySetup.class)
|
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
|
|
|
|
.putExtra("tab", "encryption"));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
popupMenu.show();
|
|
|
|
|
}
|
|
|
|
|
popupMenu.show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
snackbar.show();
|
|
|
|
|