mirror of https://github.com/M66B/FairEmail.git
Improved logging
This commit is contained in:
parent
7912dcd09f
commit
b056801967
|
@ -201,6 +201,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
Log.i("Result class=" + this.getClass().getSimpleName() +
|
||||
" action=" + data.getAction() +
|
||||
" request=" + requestCode + " result=" + resultCode);
|
||||
Log.logExtras(data);
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
|
|
@ -193,6 +193,7 @@ public class FragmentBase extends Fragment {
|
|||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
Log.i("Result class=" + this.getClass().getSimpleName() +
|
||||
" action=" + data.getAction() +
|
||||
" request=" + requestCode + " result=" + resultCode);
|
||||
Log.logExtras(data);
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
|
|
@ -1248,11 +1248,8 @@ public class FragmentCompose extends FragmentBase {
|
|||
onAddMedia(data);
|
||||
break;
|
||||
case REQUEST_ENCRYPT:
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
if (BuildConfig.DEBUG || BuildConfig.BETA_RELEASE)
|
||||
Log.logExtras(data);
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
onPgp(data);
|
||||
}
|
||||
break;
|
||||
case REQUEST_REF_DELETE:
|
||||
if (resultCode == RESULT_OK)
|
||||
|
@ -1489,21 +1486,13 @@ public class FragmentCompose extends FragmentBase {
|
|||
OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction()))
|
||||
encrypted = new ByteArrayOutputStream();
|
||||
|
||||
if (BuildConfig.DEBUG || BuildConfig.BETA_RELEASE) {
|
||||
Log.i("Execute " + data);
|
||||
Log.logExtras(data);
|
||||
}
|
||||
|
||||
// Encrypt message
|
||||
Log.i("Executing " + data.getAction());
|
||||
OpenPgpApi api = new OpenPgpApi(context, pgpService.getService());
|
||||
Intent result = api.executeApi(data, decrypted, encrypted);
|
||||
|
||||
if (BuildConfig.DEBUG || BuildConfig.BETA_RELEASE) {
|
||||
Log.i("Result " + result);
|
||||
Log.logExtras(result);
|
||||
}
|
||||
|
||||
int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
|
||||
Log.i("Result action=" + data.getAction() + " code=" + resultCode);
|
||||
switch (resultCode) {
|
||||
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
||||
// Attach encrypted data / signature
|
||||
|
@ -1543,8 +1532,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
bytes = encrypted.toByteArray();
|
||||
|
||||
File file = attachment.getFile(context);
|
||||
if (BuildConfig.DEBUG || BuildConfig.BETA_RELEASE)
|
||||
Log.i("Writing " + file + " size=" + bytes.length);
|
||||
Log.i("Writing " + file + " size=" + bytes.length);
|
||||
try (OutputStream out = new FileOutputStream(file)) {
|
||||
out.write(bytes);
|
||||
}
|
||||
|
@ -1557,8 +1545,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
if (OpenPgpApi.ACTION_GET_KEY_IDS.equals(data.getAction())) {
|
||||
pgpKeyIds = result.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS);
|
||||
if (BuildConfig.DEBUG || BuildConfig.BETA_RELEASE)
|
||||
Log.i("Keys=" + pgpKeyIds.length);
|
||||
Log.i("Keys=" + pgpKeyIds.length);
|
||||
|
||||
// Send without encryption
|
||||
if (pgpKeyIds.length == 0)
|
||||
|
@ -1570,7 +1557,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||
return intent;
|
||||
} else if (OpenPgpApi.ACTION_GET_KEY.equals(data.getAction())) {
|
||||
if (identity != null && identity.sign_key != null) {
|
||||
if (identity.sign_key != null) {
|
||||
// Encrypt message
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, pgpKeyIds);
|
||||
|
@ -1583,8 +1570,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
} else if (OpenPgpApi.ACTION_GET_SIGN_KEY_ID.equals(data.getAction())) {
|
||||
pgpSignKeyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, -1);
|
||||
if (identity != null)
|
||||
db.identity().setIdentitySignKey(identity.id, pgpSignKeyId);
|
||||
db.identity().setIdentitySignKey(identity.id, pgpSignKeyId);
|
||||
|
||||
// Encrypt message
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT);
|
||||
|
@ -1606,8 +1592,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
return result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
||||
|
||||
case OpenPgpApi.RESULT_CODE_ERROR:
|
||||
if (identity != null)
|
||||
db.identity().setIdentitySignKey(identity.id, null);
|
||||
db.identity().setIdentitySignKey(identity.id, null);
|
||||
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
|
||||
if (error == null)
|
||||
throw new IllegalArgumentException("Unknown error");
|
||||
|
@ -1621,6 +1606,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Object result) {
|
||||
Log.i("Result= " + result);
|
||||
if (result == null)
|
||||
onAction(R.id.action_send);
|
||||
else if (result instanceof Intent) {
|
||||
|
|
|
@ -81,6 +81,7 @@ public class FragmentDialogBase extends DialogFragment {
|
|||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
Log.i("Result class=" + this.getClass().getSimpleName() +
|
||||
" action=" + data.getAction() +
|
||||
" request=" + requestCode + " result=" + resultCode);
|
||||
Log.logExtras(data);
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
|
Loading…
Reference in New Issue