Refactoring

pull/147/head
M66B 6 years ago
parent 66c9a86f2c
commit 351ae13234

@ -26,7 +26,6 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View; import android.view.View;
import java.util.ArrayList; import java.util.ArrayList;
@ -48,7 +47,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.i(Helper.TAG, "Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME); Log.i("Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME);
this.contacts = (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) this.contacts = (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS)
== PackageManager.PERMISSION_GRANTED); == PackageManager.PERMISSION_GRANTED);
@ -69,13 +68,13 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
@Override @Override
protected void onResume() { protected void onResume() {
Log.i(Helper.TAG, "Resume " + this.getClass().getName()); Log.i("Resume " + this.getClass().getName());
boolean contacts = (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) boolean contacts = (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS)
== PackageManager.PERMISSION_GRANTED); == PackageManager.PERMISSION_GRANTED);
if (!this.getClass().equals(ActivitySetup.class) && this.contacts != contacts) { if (!this.getClass().equals(ActivitySetup.class) && this.contacts != contacts) {
Log.i(Helper.TAG, "Contacts permission=" + contacts); Log.i("Contacts permission=" + contacts);
finish(); finish();
startActivity(getIntent()); startActivity(getIntent());
} }
@ -85,33 +84,33 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
@Override @Override
protected void onPause() { protected void onPause() {
Log.i(Helper.TAG, "Pause " + this.getClass().getName()); Log.i("Pause " + this.getClass().getName());
super.onPause(); super.onPause();
} }
@Override @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
Log.i(Helper.TAG, "Config " + this.getClass().getName()); Log.i("Config " + this.getClass().getName());
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Log.i(Helper.TAG, "Destroy " + this.getClass().getName()); Log.i("Destroy " + this.getClass().getName());
PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this); PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
super.onDestroy(); super.onDestroy();
} }
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
Log.i(Helper.TAG, "Result class=" + this.getClass().getSimpleName() + Log.i("Result class=" + this.getClass().getSimpleName() +
" request=" + requestCode + " result=" + resultCode + " data=" + data); " request=" + requestCode + " result=" + resultCode + " data=" + data);
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
} }
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
Log.i(Helper.TAG, "Preference " + key + "=" + prefs.getAll().get(key)); Log.i("Preference " + key + "=" + prefs.getAll().get(key));
if ("theme".equals(key)) { if ("theme".equals(key)) {
finish(); finish();
if (this.getClass().equals(ActivitySetup.class)) if (this.getClass().equals(ActivitySetup.class))
@ -123,11 +122,11 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
protected View getVisibleView() { protected View getVisibleView() {
for (Fragment fragment : getSupportFragmentManager().getFragments()) for (Fragment fragment : getSupportFragmentManager().getFragments())
if (fragment.getUserVisibleHint()) { if (fragment.getUserVisibleHint()) {
Log.i(Helper.TAG, "Visible fragment=" + fragment.getClass().getName()); Log.i("Visible fragment=" + fragment.getClass().getName());
return fragment.getView(); return fragment.getView();
} }
Log.i(Helper.TAG, "Visible activity=" + this.getClass().getName()); Log.i("Visible activity=" + this.getClass().getName());
return findViewById(android.R.id.content); return findViewById(android.R.id.content);
} }

@ -30,7 +30,6 @@ import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import com.android.billingclient.api.BillingClient; import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingClientStateListener; import com.android.billingclient.api.BillingClientStateListener;
@ -103,7 +102,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
intent.setData(Uri.parse("https://email.faircode.eu/pro/?challenge=" + getChallenge())); intent.setData(Uri.parse("https://email.faircode.eu/pro/?challenge=" + getChallenge()));
return intent; return intent;
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
return null; return null;
} }
} }
@ -135,7 +134,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
.build(); .build();
int responseCode = billingClient.launchBillingFlow(this, flowParams); int responseCode = billingClient.launchBillingFlow(this, flowParams);
String text = Helper.getBillingResponseText(responseCode); String text = Helper.getBillingResponseText(responseCode);
Log.i(Helper.TAG, "IAB launch billing flow response=" + text); Log.i("IAB launch billing flow response=" + text);
if (responseCode != BillingClient.BillingResponse.OK) if (responseCode != BillingClient.BillingResponse.OK)
Snackbar.make(getVisibleView(), text, Snackbar.LENGTH_LONG).show(); Snackbar.make(getVisibleView(), text, Snackbar.LENGTH_LONG).show();
} else } else
@ -147,20 +146,20 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
Uri data = intent.getParcelableExtra("uri"); Uri data = intent.getParcelableExtra("uri");
String challenge = getChallenge(); String challenge = getChallenge();
String response = data.getQueryParameter("response"); String response = data.getQueryParameter("response");
Log.i(Helper.TAG, "Challenge=" + challenge); Log.i("Challenge=" + challenge);
Log.i(Helper.TAG, "Response=" + response); Log.i("Response=" + response);
String expected = getResponse(); String expected = getResponse();
if (expected.equals(response)) { if (expected.equals(response)) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.edit().putBoolean("pro", true).apply(); prefs.edit().putBoolean("pro", true).apply();
Log.i(Helper.TAG, "Response valid"); Log.i("Response valid");
Snackbar.make(getVisibleView(), R.string.title_pro_valid, Snackbar.LENGTH_LONG).show(); Snackbar.make(getVisibleView(), R.string.title_pro_valid, Snackbar.LENGTH_LONG).show();
} else { } else {
Log.i(Helper.TAG, "Response invalid"); Log.i("Response invalid");
Snackbar.make(getVisibleView(), R.string.title_pro_invalid, Snackbar.LENGTH_LONG).show(); Snackbar.make(getVisibleView(), R.string.title_pro_invalid, Snackbar.LENGTH_LONG).show();
} }
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
Log.e(Helper.TAG, Log.getStackTraceString(ex)); Log.e(ex);
Helper.unexpectedError(this, this, ex); Helper.unexpectedError(this, this, ex);
} }
} }
@ -171,7 +170,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
@Override @Override
public void onBillingSetupFinished(@BillingClient.BillingResponse int responseCode) { public void onBillingSetupFinished(@BillingClient.BillingResponse int responseCode) {
String text = Helper.getBillingResponseText(responseCode); String text = Helper.getBillingResponseText(responseCode);
Log.i(Helper.TAG, "IAB connected response=" + text); Log.i("IAB connected response=" + text);
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
return; return;
@ -186,7 +185,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
@Override @Override
public void onBillingServiceDisconnected() { public void onBillingServiceDisconnected() {
backoff *= 2; backoff *= 2;
Log.i(Helper.TAG, "IAB disconnected retry in " + backoff + " s"); Log.i("IAB disconnected retry in " + backoff + " s");
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -200,7 +199,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
@Override @Override
public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) { public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) {
String text = Helper.getBillingResponseText(responseCode); String text = Helper.getBillingResponseText(responseCode);
Log.i(Helper.TAG, "IAB purchases updated response=" + text); Log.i("IAB purchases updated response=" + text);
if (responseCode == BillingClient.BillingResponse.OK) if (responseCode == BillingClient.BillingResponse.OK)
checkPurchases(purchases); checkPurchases(purchases);
else else
@ -210,7 +209,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
private void queryPurchases() { private void queryPurchases() {
Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP); Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP);
String text = Helper.getBillingResponseText(result.getResponseCode()); String text = Helper.getBillingResponseText(result.getResponseCode());
Log.i(Helper.TAG, "IAB query purchases response=" + text); Log.i("IAB query purchases response=" + text);
if (result.getResponseCode() == BillingClient.BillingResponse.OK) if (result.getResponseCode() == BillingClient.BillingResponse.OK)
checkPurchases(result.getPurchasesList()); checkPurchases(result.getPurchasesList());
else else
@ -227,7 +226,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
for (Purchase purchase : purchases) for (Purchase purchase : purchases)
try { try {
Log.i(Helper.TAG, "IAB SKU=" + purchase.getSku()); Log.i("IAB SKU=" + purchase.getSku());
byte[] decodedKey = Base64.decode(getString(R.string.public_key), Base64.DEFAULT); byte[] decodedKey = Base64.decode(getString(R.string.public_key), Base64.DEFAULT);
KeyFactory keyFactory = KeyFactory.getInstance("RSA"); KeyFactory keyFactory = KeyFactory.getInstance("RSA");
@ -238,14 +237,14 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
if (sig.verify(Base64.decode(purchase.getSignature(), Base64.DEFAULT))) { if (sig.verify(Base64.decode(purchase.getSignature(), Base64.DEFAULT))) {
if ((BuildConfig.APPLICATION_ID + ".pro").equals(purchase.getSku())) { if ((BuildConfig.APPLICATION_ID + ".pro").equals(purchase.getSku())) {
editor.putBoolean("pro", true); editor.putBoolean("pro", true);
Log.i(Helper.TAG, "IAB pro features activated"); Log.i("IAB pro features activated");
} }
} else { } else {
Log.w(Helper.TAG, "Invalid signature"); Log.w("Invalid signature");
Snackbar.make(getVisibleView(), R.string.title_pro_invalid, Snackbar.LENGTH_LONG).show(); Snackbar.make(getVisibleView(), R.string.title_pro_invalid, Snackbar.LENGTH_LONG).show();
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
Snackbar.make(getVisibleView(), ex.getMessage(), Snackbar.LENGTH_LONG).show(); Snackbar.make(getVisibleView(), ex.getMessage(), Snackbar.LENGTH_LONG).show();
} }

@ -23,7 +23,6 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
@ -74,7 +73,7 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
InternetAddress.parse(to); InternetAddress.parse(to);
args.putString("to", to); args.putString("to", to);
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
} }
@ -85,7 +84,7 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
InternetAddress.parse(TextUtils.join(", ", to)); InternetAddress.parse(TextUtils.join(", ", to));
args.putString("to", TextUtils.join(", ", to)); args.putString("to", TextUtils.join(", ", to));
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
} }
@ -96,7 +95,7 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
InternetAddress.parse(TextUtils.join(", ", cc)); InternetAddress.parse(TextUtils.join(", ", cc));
args.putString("cc", TextUtils.join(", ", cc)); args.putString("cc", TextUtils.join(", ", cc));
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
} }
@ -107,7 +106,7 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
InternetAddress.parse(TextUtils.join(", ", bcc)); InternetAddress.parse(TextUtils.join(", ", bcc));
args.putString("bcc", TextUtils.join(", ", bcc)); args.putString("bcc", TextUtils.join(", ", bcc));
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
} }

@ -23,7 +23,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import java.util.List; import java.util.List;
@ -42,7 +41,7 @@ public class ActivityMain extends AppCompatActivity implements FragmentManager.O
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
if (!Helper.isPlayStoreInstall(this)) { if (!Helper.isPlayStoreInstall(this)) {
Log.i(Helper.TAG, "Third party install"); Log.i("Third party install");
prefs.edit().putBoolean("play_store", false).apply(); prefs.edit().putBoolean("play_store", false).apply();
} }

@ -44,7 +44,6 @@ import android.os.ParcelFileDescriptor;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -351,7 +350,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Intent intent = getIntent(); Intent intent = getIntent();
String action = intent.getAction(); String action = intent.getAction();
Log.i(Helper.TAG, "View intent=" + intent + " action=" + action); Log.i("View intent=" + intent + " action=" + action);
if (action != null) { if (action != null) {
intent.setAction(null); intent.setAction(null);
setIntent(intent); setIntent(intent);
@ -635,7 +634,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (TextUtils.isEmpty(info.tag_name)) if (TextUtils.isEmpty(info.tag_name))
info.tag_name = name; info.tag_name = name;
Log.i(Helper.TAG, "Latest version=" + info.tag_name); Log.i("Latest version=" + info.tag_name);
if (BuildConfig.VERSION_NAME.equals(info.tag_name)) if (BuildConfig.VERSION_NAME.equals(info.tag_name))
break; break;
else else
@ -717,7 +716,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
long last = cursor.getLong(cursor.getColumnIndex(ContactsContract.Contacts.LAST_TIME_CONTACTED)); long last = cursor.getLong(cursor.getColumnIndex(ContactsContract.Contacts.LAST_TIME_CONTACTED));
InternetAddress address = new InternetAddress(email, name); InternetAddress address = new InternetAddress(email, name);
Log.i(Helper.TAG, "Shortcut id=" + id + " address=" + address + Log.i("Shortcut id=" + id + " address=" + address +
" starred=" + starred + " times=" + times + " last=" + last); " starred=" + starred + " times=" + times + " last=" + last);
if (starred == 0 && times == 0 && last == 0) if (starred == 0 && times == 0 && last == 0)
@ -748,7 +747,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (sm.getManifestShortcuts().size() + shortcuts.size() >= sm.getMaxShortcutCountPerActivity()) if (sm.getManifestShortcuts().size() + shortcuts.size() >= sm.getMaxShortcutCountPerActivity())
break; break;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} finally { } finally {
if (cursor != null) if (cursor != null)
@ -1220,7 +1219,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
OpenPgpApi api = new OpenPgpApi(context, pgpService.getService()); OpenPgpApi api = new OpenPgpApi(context, pgpService.getService());
Intent result = api.executeApi(data, encrypted, decrypted); Intent result = api.executeApi(data, encrypted, decrypted);
Log.i(Helper.TAG, "PGP result=" + result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)); Log.i("PGP result=" + result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR));
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: case OpenPgpApi.RESULT_CODE_SUCCESS:
if (inline) { if (inline) {
@ -1292,7 +1291,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
protected void onLoaded(Bundle args, PendingIntent pi) { protected void onLoaded(Bundle args, PendingIntent pi) {
if (pi != null) if (pi != null)
try { try {
Log.i(Helper.TAG, "PGP executing pi=" + pi); Log.i("PGP executing pi=" + pi);
startIntentSenderForResult( startIntentSenderForResult(
pi.getIntentSender(), pi.getIntentSender(),
ActivityView.REQUEST_DECRYPT, ActivityView.REQUEST_DECRYPT,
@ -1349,19 +1348,19 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (pfd != null) if (pfd != null)
pfd.close(); pfd.close();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
try { try {
if (fos != null) if (fos != null)
fos.close(); fos.close();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
try { try {
if (fis != null) if (fis != null)
fis.close(); fis.close();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
} }

@ -24,7 +24,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color; import android.graphics.Color;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -137,7 +136,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
} }
public void set(@NonNull List<EntityAccount> accounts) { public void set(@NonNull List<EntityAccount> accounts) {
Log.i(Helper.TAG, "Set accounts=" + accounts.size()); Log.i("Set accounts=" + accounts.size());
final Collator collator = Collator.getInstance(Locale.getDefault()); final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
@ -159,22 +158,22 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
diff.dispatchUpdatesTo(new ListUpdateCallback() { diff.dispatchUpdatesTo(new ListUpdateCallback() {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
Log.i(Helper.TAG, "Inserted @" + position + " #" + count); Log.i("Inserted @" + position + " #" + count);
} }
@Override @Override
public void onRemoved(int position, int count) { public void onRemoved(int position, int count) {
Log.i(Helper.TAG, "Removed @" + position + " #" + count); Log.i("Removed @" + position + " #" + count);
} }
@Override @Override
public void onMoved(int fromPosition, int toPosition) { public void onMoved(int fromPosition, int toPosition) {
Log.i(Helper.TAG, "Moved " + fromPosition + ">" + toPosition); Log.i("Moved " + fromPosition + ">" + toPosition);
} }
@Override @Override
public void onChanged(int position, int count, Object payload) { public void onChanged(int position, int count, Object payload) {
Log.i(Helper.TAG, "Changed @" + position + " #" + count); Log.i("Changed @" + position + " #" + count);
} }
}); });
diff.dispatchUpdatesTo(this); diff.dispatchUpdatesTo(this);

@ -21,7 +21,6 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -90,7 +89,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
} }
public void set(@NonNull List<EntityAnswer> answers) { public void set(@NonNull List<EntityAnswer> answers) {
Log.i(Helper.TAG, "Set answers=" + answers.size()); Log.i("Set answers=" + answers.size());
final Collator collator = Collator.getInstance(Locale.getDefault()); final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
@ -112,22 +111,22 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
diff.dispatchUpdatesTo(new ListUpdateCallback() { diff.dispatchUpdatesTo(new ListUpdateCallback() {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
Log.i(Helper.TAG, "Inserted @" + position + " #" + count); Log.i("Inserted @" + position + " #" + count);
} }
@Override @Override
public void onRemoved(int position, int count) { public void onRemoved(int position, int count) {
Log.i(Helper.TAG, "Removed @" + position + " #" + count); Log.i("Removed @" + position + " #" + count);
} }
@Override @Override
public void onMoved(int fromPosition, int toPosition) { public void onMoved(int fromPosition, int toPosition) {
Log.i(Helper.TAG, "Moved " + fromPosition + ">" + toPosition); Log.i("Moved " + fromPosition + ">" + toPosition);
} }
@Override @Override
public void onChanged(int position, int count, Object payload) { public void onChanged(int position, int count, Object payload) {
Log.i(Helper.TAG, "Changed @" + position + " #" + count); Log.i("Changed @" + position + " #" + count);
} }
}); });
diff.dispatchUpdatesTo(this); diff.dispatchUpdatesTo(this);

@ -29,7 +29,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -171,7 +170,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
// https://developer.android.com/reference/android/support/v4/content/FileProvider // https://developer.android.com/reference/android/support/v4/content/FileProvider
final Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file); final Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
Log.i(Helper.TAG, "uri=" + uri); Log.i("uri=" + uri);
// Build intent // Build intent
final Intent intent = new Intent(Intent.ACTION_VIEW); final Intent intent = new Intent(Intent.ACTION_VIEW);
@ -179,15 +178,15 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (!TextUtils.isEmpty(attachment.name)) if (!TextUtils.isEmpty(attachment.name))
intent.putExtra(Intent.EXTRA_TITLE, attachment.name); intent.putExtra(Intent.EXTRA_TITLE, attachment.name);
Log.i(Helper.TAG, "Sharing " + file + " type=" + attachment.type); Log.i("Sharing " + file + " type=" + attachment.type);
Log.i(Helper.TAG, "Intent=" + intent); Log.i("Intent=" + intent);
// Get targets // Get targets
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
List<NameResolveInfo> targets = new ArrayList<>(); List<NameResolveInfo> targets = new ArrayList<>();
List<ResolveInfo> ris = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); List<ResolveInfo> ris = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo ri : ris) { for (ResolveInfo ri : ris) {
Log.i(Helper.TAG, "Target=" + ri); Log.i("Target=" + ri);
context.grantUriPermission(ri.activityInfo.packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); context.grantUriPermission(ri.activityInfo.packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
targets.add(new NameResolveInfo( targets.add(new NameResolveInfo(
pm.getApplicationIcon(ri.activityInfo.applicationInfo), pm.getApplicationIcon(ri.activityInfo.applicationInfo),
@ -316,7 +315,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
} }
public void set(@NonNull List<EntityAttachment> attachments) { public void set(@NonNull List<EntityAttachment> attachments) {
Log.i(Helper.TAG, "Set attachments=" + attachments.size()); Log.i("Set attachments=" + attachments.size());
Collections.sort(attachments, new Comparator<EntityAttachment>() { Collections.sort(attachments, new Comparator<EntityAttachment>() {
@Override @Override
@ -335,22 +334,22 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
diff.dispatchUpdatesTo(new ListUpdateCallback() { diff.dispatchUpdatesTo(new ListUpdateCallback() {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
Log.i(Helper.TAG, "Inserted @" + position + " #" + count); Log.i("Inserted @" + position + " #" + count);
} }
@Override @Override
public void onRemoved(int position, int count) { public void onRemoved(int position, int count) {
Log.i(Helper.TAG, "Removed @" + position + " #" + count); Log.i("Removed @" + position + " #" + count);
} }
@Override @Override
public void onMoved(int fromPosition, int toPosition) { public void onMoved(int fromPosition, int toPosition) {
Log.i(Helper.TAG, "Moved " + fromPosition + ">" + toPosition); Log.i("Moved " + fromPosition + ">" + toPosition);
} }
@Override @Override
public void onChanged(int position, int count, Object payload) { public void onChanged(int position, int count, Object payload) {
Log.i(Helper.TAG, "Changed @" + position + " #" + count); Log.i("Changed @" + position + " #" + count);
} }
}); });
diff.dispatchUpdatesTo(this); diff.dispatchUpdatesTo(this);

@ -29,7 +29,6 @@ import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -297,7 +296,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
protected Void onLoad(Context context, Bundle args) { protected Void onLoad(Context context, Bundle args) {
long id = args.getLong("id"); long id = args.getLong("id");
boolean outbox = args.getBoolean("outbox"); boolean outbox = args.getBoolean("outbox");
Log.i(Helper.TAG, "Delete local messages outbox=" + outbox); Log.i("Delete local messages outbox=" + outbox);
if (outbox) if (outbox)
DB.getInstance(context).message().deleteSeenMessages(id); DB.getInstance(context).message().deleteSeenMessages(id);
else else
@ -389,7 +388,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
} }
public void set(long account, @NonNull List<TupleFolderEx> _folders) { public void set(long account, @NonNull List<TupleFolderEx> _folders) {
Log.i(Helper.TAG, "Set account=" + account + " folders=" + _folders.size()); Log.i("Set account=" + account + " folders=" + _folders.size());
this.account = account; this.account = account;
@ -414,22 +413,22 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
diff.dispatchUpdatesTo(new ListUpdateCallback() { diff.dispatchUpdatesTo(new ListUpdateCallback() {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
Log.i(Helper.TAG, "Inserted @" + position + " #" + count); Log.i("Inserted @" + position + " #" + count);
} }
@Override @Override
public void onRemoved(int position, int count) { public void onRemoved(int position, int count) {
Log.i(Helper.TAG, "Removed @" + position + " #" + count); Log.i("Removed @" + position + " #" + count);
} }
@Override @Override
public void onMoved(int fromPosition, int toPosition) { public void onMoved(int fromPosition, int toPosition) {
Log.i(Helper.TAG, "Moved " + fromPosition + ">" + toPosition); Log.i("Moved " + fromPosition + ">" + toPosition);
} }
@Override @Override
public void onChanged(int position, int count, Object payload) { public void onChanged(int position, int count, Object payload) {
Log.i(Helper.TAG, "Changed @" + position + " #" + count); Log.i("Changed @" + position + " #" + count);
} }
}); });
diff.dispatchUpdatesTo(this); diff.dispatchUpdatesTo(this);

@ -22,7 +22,6 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -125,7 +124,7 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
} }
public void set(@NonNull List<TupleIdentityEx> identities) { public void set(@NonNull List<TupleIdentityEx> identities) {
Log.i(Helper.TAG, "Set identities=" + identities.size()); Log.i("Set identities=" + identities.size());
final Collator collator = Collator.getInstance(Locale.getDefault()); final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
@ -147,22 +146,22 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
diff.dispatchUpdatesTo(new ListUpdateCallback() { diff.dispatchUpdatesTo(new ListUpdateCallback() {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
Log.i(Helper.TAG, "Inserted @" + position + " #" + count); Log.i("Inserted @" + position + " #" + count);
} }
@Override @Override
public void onRemoved(int position, int count) { public void onRemoved(int position, int count) {
Log.i(Helper.TAG, "Removed @" + position + " #" + count); Log.i("Removed @" + position + " #" + count);
} }
@Override @Override
public void onMoved(int fromPosition, int toPosition) { public void onMoved(int fromPosition, int toPosition) {
Log.i(Helper.TAG, "Moved " + fromPosition + ">" + toPosition); Log.i("Moved " + fromPosition + ">" + toPosition);
} }
@Override @Override
public void onChanged(int position, int count, Object payload) { public void onChanged(int position, int count, Object payload) {
Log.i(Helper.TAG, "Changed @" + position + " #" + count); Log.i("Changed @" + position + " #" + count);
} }
}); });
diff.dispatchUpdatesTo(this); diff.dispatchUpdatesTo(this);

@ -20,7 +20,6 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -70,7 +69,7 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
} }
public void set(@NonNull List<EntityLog> logs) { public void set(@NonNull List<EntityLog> logs) {
Log.i(Helper.TAG, "Set logs=" + logs.size()); Log.i("Set logs=" + logs.size());
all = logs; all = logs;
@ -82,22 +81,22 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
diff.dispatchUpdatesTo(new ListUpdateCallback() { diff.dispatchUpdatesTo(new ListUpdateCallback() {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
Log.i(Helper.TAG, "Inserted @" + position + " #" + count); Log.i("Inserted @" + position + " #" + count);
} }
@Override @Override
public void onRemoved(int position, int count) { public void onRemoved(int position, int count) {
Log.i(Helper.TAG, "Removed @" + position + " #" + count); Log.i("Removed @" + position + " #" + count);
} }
@Override @Override
public void onMoved(int fromPosition, int toPosition) { public void onMoved(int fromPosition, int toPosition) {
Log.i(Helper.TAG, "Moved " + fromPosition + ">" + toPosition); Log.i("Moved " + fromPosition + ">" + toPosition);
} }
@Override @Override
public void onChanged(int position, int count, Object payload) { public void onChanged(int position, int count, Object payload) {
Log.i(Helper.TAG, "Changed @" + position + " #" + count); Log.i("Changed @" + position + " #" + count);
} }
}); });
diff.dispatchUpdatesTo(this); diff.dispatchUpdatesTo(this);

@ -51,7 +51,6 @@ import android.text.method.LinkMovementMethod;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;
import android.text.style.QuoteSpan; import android.text.style.QuoteSpan;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -342,7 +341,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivAvatar.setImageDrawable(Drawable.createFromStream(is, "avatar")); ivAvatar.setImageDrawable(Drawable.createFromStream(is, "avatar"));
} }
} catch (SecurityException ex) { } catch (SecurityException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }
if (!photo && identicons && !outgoing) { if (!photo && identicons && !outgoing) {
@ -793,7 +792,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
try { try {
body = message.read(context); body = message.read(context);
} catch (IOException ex) { } catch (IOException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
body = ex.toString(); body = ex.toString();
DB.getInstance(context).message().setMessageContent(message.id, false, null); DB.getInstance(context).message().setMessageContent(message.id, false, null);
} }
@ -877,7 +876,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override @Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG)
Log.i(Helper.TAG, "HTML tag=" + tag + " opening=" + opening); Log.i("HTML tag=" + tag + " opening=" + opening);
} }
}); });
} }
@ -1167,7 +1166,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
args.putLong("id", message.id); args.putLong("id", message.id);
args.putBoolean("flagged", !message.ui_flagged); args.putBoolean("flagged", !message.ui_flagged);
args.putBoolean("thread", viewType != ViewType.THREAD); args.putBoolean("thread", viewType != ViewType.THREAD);
Log.i(Helper.TAG, "Set message id=" + message.id + " flagged=" + !message.ui_flagged); Log.i("Set message id=" + message.id + " flagged=" + !message.ui_flagged);
new SimpleTask<Void>() { new SimpleTask<Void>() {
@Override @Override
@ -1710,11 +1709,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
for (int i = 0; i < messages.size(); i++) { for (int i = 0; i < messages.size(); i++) {
TupleMessageEx message = messages.get(i); TupleMessageEx message = messages.get(i);
if (message != null && message.id.equals(key)) { if (message != null && message.id.equals(key)) {
Log.i(Helper.TAG, "Position=" + i + " @Key=" + key); Log.i("Position=" + i + " @Key=" + key);
return i; return i;
} }
} }
Log.i(Helper.TAG, "Position=" + RecyclerView.NO_POSITION + " @Key=" + key); Log.i("Position=" + RecyclerView.NO_POSITION + " @Key=" + key);
return RecyclerView.NO_POSITION; return RecyclerView.NO_POSITION;
} }
@ -1723,10 +1722,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (list != null && pos < list.size()) { if (list != null && pos < list.size()) {
TupleMessageEx message = list.get(pos); TupleMessageEx message = list.get(pos);
Long key = (message == null ? null : message.id); Long key = (message == null ? null : message.id);
Log.i(Helper.TAG, "Item=" + key + " @Position=" + pos); Log.i("Item=" + key + " @Position=" + pos);
return message; return message;
} else { } else {
Log.i(Helper.TAG, "Item=" + null + " @Position=" + pos); Log.i("Item=" + null + " @Position=" + pos);
return null; return null;
} }
} }
@ -1737,18 +1736,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
for (int i = 0; i < messages.size(); i++) { for (int i = 0; i < messages.size(); i++) {
TupleMessageEx message = messages.get(i); TupleMessageEx message = messages.get(i);
if (message != null && message.id.equals(key)) { if (message != null && message.id.equals(key)) {
Log.i(Helper.TAG, "Item=" + message.id + " @Key=" + key); Log.i("Item=" + message.id + " @Key=" + key);
return message; return message;
} }
} }
Log.i(Helper.TAG, "Item=" + null + " @Key" + key); Log.i("Item=" + null + " @Key" + key);
return null; return null;
} }
Long getKeyAtPosition(int pos) { Long getKeyAtPosition(int pos) {
TupleMessageEx message = getItemAtPosition(pos); TupleMessageEx message = getItemAtPosition(pos);
Long key = (message == null ? null : message.id); Long key = (message == null ? null : message.id);
Log.i(Helper.TAG, "Key=" + key + " @Position=" + pos); Log.i("Key=" + key + " @Position=" + pos);
return key; return key;
} }

@ -23,7 +23,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -166,7 +165,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
} }
public void set(@NonNull List<TupleOperationEx> operations) { public void set(@NonNull List<TupleOperationEx> operations) {
Log.i(Helper.TAG, "Set operations=" + operations.size()); Log.i("Set operations=" + operations.size());
all = operations; all = operations;
@ -178,22 +177,22 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
diff.dispatchUpdatesTo(new ListUpdateCallback() { diff.dispatchUpdatesTo(new ListUpdateCallback() {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
Log.i(Helper.TAG, "Inserted @" + position + " #" + count); Log.i("Inserted @" + position + " #" + count);
} }
@Override @Override
public void onRemoved(int position, int count) { public void onRemoved(int position, int count) {
Log.i(Helper.TAG, "Removed @" + position + " #" + count); Log.i("Removed @" + position + " #" + count);
} }
@Override @Override
public void onMoved(int fromPosition, int toPosition) { public void onMoved(int fromPosition, int toPosition) {
Log.i(Helper.TAG, "Moved " + fromPosition + ">" + toPosition); Log.i("Moved " + fromPosition + ">" + toPosition);
} }
@Override @Override
public void onChanged(int position, int count, Object payload) { public void onChanged(int position, int count, Object payload) {
Log.i(Helper.TAG, "Changed @" + position + " #" + count); Log.i("Changed @" + position + " #" + count);
} }
}); });
diff.dispatchUpdatesTo(this); diff.dispatchUpdatesTo(this);

@ -27,7 +27,6 @@ import android.content.Context;
import android.os.Build; import android.os.Build;
import android.os.DeadSystemException; import android.os.DeadSystemException;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
@ -47,7 +46,7 @@ public class ApplicationEx extends Application {
@Override @Override
public void uncaughtException(Thread thread, Throwable ex) { public void uncaughtException(Thread thread, Throwable ex) {
if (ownFault(ex)) { if (ownFault(ex)) {
Log.e(Helper.TAG, ex + "\r\n" + Log.getStackTraceString(ex)); Log.e(ex);
if (!Helper.isPlayStoreInstall(ApplicationEx.this)) if (!Helper.isPlayStoreInstall(ApplicationEx.this))
writeCrashLog(ApplicationEx.this, ex); writeCrashLog(ApplicationEx.this, ex);
@ -55,7 +54,7 @@ public class ApplicationEx extends Application {
if (prev != null) if (prev != null)
prev.uncaughtException(thread, ex); prev.uncaughtException(thread, ex);
} else { } else {
Log.w(Helper.TAG, ex + "\r\n" + Log.getStackTraceString(ex)); Log.w(ex);
System.exit(1); System.exit(1);
} }
} }
@ -116,21 +115,21 @@ public class ApplicationEx extends Application {
static void writeCrashLog(Context context, Throwable ex) { static void writeCrashLog(Context context, Throwable ex) {
File file = new File(context.getCacheDir(), "crash.log"); File file = new File(context.getCacheDir(), "crash.log");
Log.w(Helper.TAG, "Writing exception to " + file); Log.w("Writing exception to " + file);
FileWriter out = null; FileWriter out = null;
try { try {
out = new FileWriter(file, true); out = new FileWriter(file, true);
out.write(BuildConfig.VERSION_NAME + " " + new Date() + "\r\n"); out.write(BuildConfig.VERSION_NAME + " " + new Date() + "\r\n");
out.write(ex + "\r\n" + Log.getStackTraceString(ex) + "\r\n"); out.write(ex + "\r\n" + android.util.Log.getStackTraceString(ex) + "\r\n");
} catch (IOException e) { } catch (IOException e) {
Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e)); Log.e(e);
} finally { } finally {
if (out != null) { if (out != null) {
try { try {
out.close(); out.close();
} catch (IOException e) { } catch (IOException e) {
Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e)); Log.e(e);
} }
} }
} }

@ -20,7 +20,6 @@ package eu.faircode.email;
*/ */
import android.os.Handler; import android.os.Handler;
import android.util.Log;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -72,13 +71,13 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
@Override @Override
public void onZeroItemsLoaded() { public void onZeroItemsLoaded() {
Log.i(Helper.TAG, "onZeroItemsLoaded"); Log.i("onZeroItemsLoaded");
load(); load();
} }
@Override @Override
public void onItemAtEndLoaded(final TupleMessageEx itemAtEnd) { public void onItemAtEndLoaded(final TupleMessageEx itemAtEnd) {
Log.i(Helper.TAG, "onItemAtEndLoaded"); Log.i("onItemAtEndLoaded");
load(); load();
} }
@ -97,7 +96,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
}); });
model.load(); model.load();
} catch (final Throwable ex) { } catch (final Throwable ex) {
Log.e(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex)); Log.e("Boundary", ex);
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {

@ -5,7 +5,6 @@ import android.content.SharedPreferences;
import android.database.Cursor; import android.database.Cursor;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -90,9 +89,9 @@ public abstract class DB extends RoomDatabase {
.openHelperFactory(new RequerySQLiteOpenHelperFactory()) .openHelperFactory(new RequerySQLiteOpenHelperFactory())
.setJournalMode(JournalMode.WRITE_AHEAD_LOGGING)); .setJournalMode(JournalMode.WRITE_AHEAD_LOGGING));
Log.i(Helper.TAG, "sqlite version=" + exec(sInstance, "SELECT sqlite_version() AS sqlite_version")); Log.i("sqlite version=" + exec(sInstance, "SELECT sqlite_version() AS sqlite_version"));
Log.i(Helper.TAG, "sqlite sync=" + exec(sInstance, "PRAGMA synchronous")); Log.i("sqlite sync=" + exec(sInstance, "PRAGMA synchronous"));
Log.i(Helper.TAG, "sqlite journal=" + exec(sInstance, "PRAGMA journal_mode")); Log.i("sqlite journal=" + exec(sInstance, "PRAGMA journal_mode"));
} }
return sInstance; return sInstance;
@ -118,14 +117,14 @@ public abstract class DB extends RoomDatabase {
.addCallback(new Callback() { .addCallback(new Callback() {
@Override @Override
public void onOpen(SupportSQLiteDatabase db) { public void onOpen(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "Database version=" + db.getVersion()); Log.i("Database version=" + db.getVersion());
super.onOpen(db); super.onOpen(db);
} }
}) })
.addMigrations(new Migration(1, 2) { .addMigrations(new Migration(1, 2) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` RENAME COLUMN `after` TO `sync_days`"); db.execSQL("ALTER TABLE `folder` RENAME COLUMN `after` TO `sync_days`");
db.execSQL("ALTER TABLE `folder` ADD COLUMN `keep_days` INTEGER NOT NULL DEFAULT 30"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `keep_days` INTEGER NOT NULL DEFAULT 30");
db.execSQL("UPDATE `folder` SET keep_days = sync_days"); db.execSQL("UPDATE `folder` SET keep_days = sync_days");
@ -134,7 +133,7 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(2, 3) { .addMigrations(new Migration(2, 3) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `signature` TEXT"); db.execSQL("ALTER TABLE `identity` ADD COLUMN `signature` TEXT");
db.execSQL("UPDATE `identity` SET signature =" + db.execSQL("UPDATE `identity` SET signature =" +
" (SELECT account.signature FROM account WHERE account.id = identity.account)"); " (SELECT account.signature FROM account WHERE account.id = identity.account)");
@ -143,7 +142,7 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(3, 4) { .addMigrations(new Migration(3, 4) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `forwarding` INTEGER" + db.execSQL("ALTER TABLE `message` ADD COLUMN `forwarding` INTEGER" +
" REFERENCES `message`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL"); " REFERENCES `message`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL");
db.execSQL("CREATE INDEX `index_message_forwarding` ON `message` (`forwarding`)"); db.execSQL("CREATE INDEX `index_message_forwarding` ON `message` (`forwarding`)");
@ -152,7 +151,7 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(4, 5) { .addMigrations(new Migration(4, 5) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `last_connected` INTEGER"); db.execSQL("ALTER TABLE `account` ADD COLUMN `last_connected` INTEGER");
db.execSQL("ALTER TABLE `message` ADD COLUMN `last_attempt` INTEGER"); db.execSQL("ALTER TABLE `message` ADD COLUMN `last_attempt` INTEGER");
} }
@ -160,14 +159,14 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(5, 6) { .addMigrations(new Migration(5, 6) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `notify` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `account` ADD COLUMN `notify` INTEGER NOT NULL DEFAULT 0");
} }
}) })
.addMigrations(new Migration(6, 7) { .addMigrations(new Migration(6, 7) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `answered` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `message` ADD COLUMN `answered` INTEGER NOT NULL DEFAULT 0");
db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_answered` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_answered` INTEGER NOT NULL DEFAULT 0");
} }
@ -175,21 +174,21 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(7, 8) { .addMigrations(new Migration(7, 8) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `keywords` TEXT"); db.execSQL("ALTER TABLE `message` ADD COLUMN `keywords` TEXT");
} }
}) })
.addMigrations(new Migration(8, 9) { .addMigrations(new Migration(8, 9) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `keywords` TEXT"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `keywords` TEXT");
} }
}) })
.addMigrations(new Migration(9, 10) { .addMigrations(new Migration(9, 10) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_browsed` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_browsed` INTEGER NOT NULL DEFAULT 0");
db.execSQL("CREATE INDEX `index_message_ui_browsed` ON `message` (`ui_browsed`)"); db.execSQL("CREATE INDEX `index_message_ui_browsed` ON `message` (`ui_browsed`)");
} }
@ -197,14 +196,14 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(10, 11) { .addMigrations(new Migration(10, 11) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `operation` ADD COLUMN `error` TEXT"); db.execSQL("ALTER TABLE `operation` ADD COLUMN `error` TEXT");
} }
}) })
.addMigrations(new Migration(11, 12) { .addMigrations(new Migration(11, 12) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("DROP INDEX `index_operation_folder`"); db.execSQL("DROP INDEX `index_operation_folder`");
db.execSQL("DROP INDEX `index_operation_message`"); db.execSQL("DROP INDEX `index_operation_message`");
db.execSQL("DROP TABLE `operation`"); db.execSQL("DROP TABLE `operation`");
@ -225,35 +224,35 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(12, 13) { .addMigrations(new Migration(12, 13) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("CREATE INDEX `index_message_ui_flagged` ON `message` (`ui_flagged`)"); db.execSQL("CREATE INDEX `index_message_ui_flagged` ON `message` (`ui_flagged`)");
} }
}) })
.addMigrations(new Migration(13, 14) { .addMigrations(new Migration(13, 14) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `level` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `level` INTEGER NOT NULL DEFAULT 0");
} }
}) })
.addMigrations(new Migration(14, 15) { .addMigrations(new Migration(14, 15) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `sync_state` TEXT"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `sync_state` TEXT");
} }
}) })
.addMigrations(new Migration(15, 16) { .addMigrations(new Migration(15, 16) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `poll` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `poll` INTEGER NOT NULL DEFAULT 0");
} }
}) })
.addMigrations(new Migration(16, 17) { .addMigrations(new Migration(16, 17) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("DELETE FROM `message` WHERE ui_found"); db.execSQL("DELETE FROM `message` WHERE ui_found");
db.execSQL("DROP INDEX `index_message_folder_uid_ui_found`"); db.execSQL("DROP INDEX `index_message_folder_uid_ui_found`");
db.execSQL("DROP INDEX `index_message_msgid_folder_ui_found`"); db.execSQL("DROP INDEX `index_message_msgid_folder_ui_found`");
@ -264,7 +263,7 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(17, 18) { .addMigrations(new Migration(17, 18) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `tbd` INTEGER"); db.execSQL("ALTER TABLE `account` ADD COLUMN `tbd` INTEGER");
db.execSQL("ALTER TABLE `identity` ADD COLUMN `tbd` INTEGER"); db.execSQL("ALTER TABLE `identity` ADD COLUMN `tbd` INTEGER");
db.execSQL("ALTER TABLE `folder` ADD COLUMN `tbd` INTEGER"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `tbd` INTEGER");
@ -273,7 +272,7 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(18, 19) { .addMigrations(new Migration(18, 19) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `delivery_receipt` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `identity` ADD COLUMN `delivery_receipt` INTEGER NOT NULL DEFAULT 0");
db.execSQL("ALTER TABLE `identity` ADD COLUMN `read_receipt` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `identity` ADD COLUMN `read_receipt` INTEGER NOT NULL DEFAULT 0");
} }
@ -281,7 +280,7 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(19, 20) { .addMigrations(new Migration(19, 20) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `notify` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `notify` INTEGER NOT NULL DEFAULT 0");
db.execSQL("UPDATE `folder` SET notify = unified"); db.execSQL("UPDATE `folder` SET notify = unified");
} }
@ -289,7 +288,7 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(20, 21) { .addMigrations(new Migration(20, 21) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `display` TEXT"); db.execSQL("ALTER TABLE `identity` ADD COLUMN `display` TEXT");
db.execSQL("ALTER TABLE `identity` ADD COLUMN `bcc` TEXT"); db.execSQL("ALTER TABLE `identity` ADD COLUMN `bcc` TEXT");
} }
@ -297,7 +296,7 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(21, 22) { .addMigrations(new Migration(21, 22) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `initialize` INTEGER NOT NULL DEFAULT 1"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `initialize` INTEGER NOT NULL DEFAULT 1");
db.execSQL("UPDATE `folder` SET sync_days = 1"); db.execSQL("UPDATE `folder` SET sync_days = 1");
} }
@ -305,28 +304,28 @@ public abstract class DB extends RoomDatabase {
.addMigrations(new Migration(22, 23) { .addMigrations(new Migration(22, 23) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `download` INTEGER NOT NULL DEFAULT 1"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `download` INTEGER NOT NULL DEFAULT 1");
} }
}) })
.addMigrations(new Migration(23, 24) { .addMigrations(new Migration(23, 24) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `tbc` INTEGER"); db.execSQL("ALTER TABLE `folder` ADD COLUMN `tbc` INTEGER");
} }
}) })
.addMigrations(new Migration(24, 25) { .addMigrations(new Migration(24, 25) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `prefix` TEXT"); db.execSQL("ALTER TABLE `account` ADD COLUMN `prefix` TEXT");
} }
}) })
.addMigrations(new Migration(25, 26) { .addMigrations(new Migration(25, 26) {
@Override @Override
public void migrate(SupportSQLiteDatabase db) { public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int browse = (prefs.getBoolean("browse", true) ? 1 : 0); int browse = (prefs.getBoolean("browse", true) ? 1 : 0);
db.execSQL("ALTER TABLE `account` ADD COLUMN `browse` INTEGER NOT NULL DEFAULT " + browse); db.execSQL("ALTER TABLE `account` ADD COLUMN `browse` INTEGER NOT NULL DEFAULT " + browse);
@ -374,7 +373,7 @@ public abstract class DB extends RoomDatabase {
jaddresses.put(jaddress); jaddresses.put(jaddress);
} }
} catch (JSONException ex) { } catch (JSONException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
return jaddresses.toString(); return jaddresses.toString();
} }
@ -398,7 +397,7 @@ public abstract class DB extends RoomDatabase {
} }
} catch (Throwable ex) { } catch (Throwable ex) {
// Compose can store invalid addresses // Compose can store invalid addresses
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
return result.toArray(new Address[0]); return result.toArray(new Address[0]);
} }

@ -20,7 +20,6 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.util.Log;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -127,7 +126,7 @@ public class EntityAttachment {
this.available = true; this.available = true;
db.attachment().updateAttachment(this); db.attachment().updateAttachment(this);
Log.i(Helper.TAG, "Downloaded attachment size=" + this.size); Log.i("Downloaded attachment size=" + this.size);
} catch (IOException ex) { } catch (IOException ex) {
// Reset progress on failure // Reset progress on failure
this.progress = null; this.progress = null;

@ -20,7 +20,6 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.util.Log;
import java.util.Date; import java.util.Date;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@ -52,7 +51,7 @@ public class EntityLog {
private static ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); private static ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
static void log(Context context, String data) { static void log(Context context, String data) {
Log.i(Helper.TAG, data); Log.i(data);
final EntityLog entry = new EntityLog(); final EntityLog entry = new EntityLog();
entry.time = new Date().getTime(); entry.time = new Date().getTime();

@ -26,7 +26,6 @@ import android.content.pm.PackageManager;
import android.database.Cursor; import android.database.Cursor;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -233,7 +232,7 @@ public class EntityMessage implements Serializable {
} }
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }

@ -19,8 +19,6 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B) Copyright 2018 by Marcel Bokhorst (M66B)
*/ */
import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -109,7 +107,7 @@ public class EntityOperation {
db.folder().setFolderSyncState(fid, "requested"); db.folder().setFolderSyncState(fid, "requested");
Log.i(Helper.TAG, "Queued sync folder=" + folder); Log.i("Queued sync folder=" + folder);
} }
} }
@ -137,7 +135,7 @@ public class EntityOperation {
} else if (DELETE.equals(name)) } else if (DELETE.equals(name))
db.message().setMessageUiHide(message.id, true); db.message().setMessageUiHide(message.id, true);
} catch (JSONException ex) { } catch (JSONException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
EntityOperation operation = new EntityOperation(); EntityOperation operation = new EntityOperation();
@ -148,7 +146,7 @@ public class EntityOperation {
operation.created = new Date().getTime(); operation.created = new Date().getTime();
operation.id = db.operation().insertOperation(operation); operation.id = db.operation().insertOperation(operation);
Log.i(Helper.TAG, "Queued op=" + operation.id + "/" + operation.name + Log.i("Queued op=" + operation.id + "/" + operation.name +
" msg=" + operation.folder + "/" + operation.message + " msg=" + operation.folder + "/" + operation.message +
" args=" + operation.args); " args=" + operation.args);
} }

@ -40,7 +40,6 @@ import android.preference.PreferenceManager;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -277,7 +276,7 @@ public class FragmentAccount extends FragmentEx {
if (records != null) if (records != null)
for (int i = 0; i < records.length; i++) { for (int i = 0; i < records.length; i++) {
SRVRecord srv = (SRVRecord) records[i]; SRVRecord srv = (SRVRecord) records[i];
Log.i(Helper.TAG, "SRV=" + srv); Log.i("SRV=" + srv);
return srv; return srv;
} }
@ -335,13 +334,13 @@ public class FragmentAccount extends FragmentEx {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Provider provider = (Provider) spProvider.getSelectedItem(); Provider provider = (Provider) spProvider.getSelectedItem();
Log.i(Helper.TAG, "Authorize " + provider); Log.i("Authorize " + provider);
if ("com.google".equals(provider.type)) { if ("com.google".equals(provider.type)) {
String permission = Manifest.permission.GET_ACCOUNTS; String permission = Manifest.permission.GET_ACCOUNTS;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O && if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O &&
ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED) { ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED) {
Log.i(Helper.TAG, "Requesting " + permission); Log.i("Requesting " + permission);
requestPermissions(new String[]{permission}, ActivitySetup.REQUEST_PERMISSION); requestPermissions(new String[]{permission}, ActivitySetup.REQUEST_PERMISSION);
} else } else
selectAccount(); selectAccount();
@ -487,7 +486,7 @@ public class FragmentAccount extends FragmentEx {
String type = null; String type = null;
boolean selectable = true; boolean selectable = true;
String[] attrs = ((IMAPFolder) ifolder).getAttributes(); String[] attrs = ((IMAPFolder) ifolder).getAttributes();
Log.i(Helper.TAG, ifolder.getFullName() + " attrs=" + TextUtils.join(" ", attrs)); Log.i(ifolder.getFullName() + " attrs=" + TextUtils.join(" ", attrs));
for (String attr : attrs) { for (String attr : attrs) {
if ("\\Noselect".equals(attr) || "\\NonExistent".equals(attr)) if ("\\Noselect".equals(attr) || "\\NonExistent".equals(attr))
selectable = false; selectable = false;
@ -514,7 +513,7 @@ public class FragmentAccount extends FragmentEx {
} }
result.folders.add(folder); result.folders.add(folder);
Log.i(Helper.TAG, folder.name + " id=" + folder.id + Log.i(folder.name + " id=" + folder.id +
" type=" + folder.type + " attr=" + TextUtils.join(",", attrs)); " type=" + folder.type + " attr=" + TextUtils.join(",", attrs));
} }
} }
@ -803,7 +802,7 @@ public class FragmentAccount extends FragmentEx {
EntityFolder existing = db.folder().getFolderByName(account.id, folder.name); EntityFolder existing = db.folder().getFolderByName(account.id, folder.name);
if (existing == null) { if (existing == null) {
folder.account = account.id; folder.account = account.id;
Log.i(Helper.TAG, "Creating folder=" + folder.name + " (" + folder.type + ")"); Log.i("Creating folder=" + folder.name + " (" + folder.type + ")");
folder.id = db.folder().insertFolder(folder); folder.id = db.folder().insertFolder(folder);
} else { } else {
db.folder().setFolderType(existing.id, folder.type); db.folder().setFolderType(existing.id, folder.type);
@ -1108,7 +1107,7 @@ public class FragmentAccount extends FragmentEx {
AccountManager am = AccountManager.get(getContext()); AccountManager am = AccountManager.get(getContext());
Account[] accounts = am.getAccountsByType(type); Account[] accounts = am.getAccountsByType(type);
Log.i(Helper.TAG, "Accounts=" + accounts.length); Log.i("Accounts=" + accounts.length);
for (final Account account : accounts) for (final Account account : accounts)
if (name.equals(account.name)) { if (name.equals(account.name)) {
final Snackbar snackbar = Snackbar.make(view, R.string.title_authorizing, Snackbar.LENGTH_SHORT); final Snackbar snackbar = Snackbar.make(view, R.string.title_authorizing, Snackbar.LENGTH_SHORT);
@ -1125,7 +1124,7 @@ public class FragmentAccount extends FragmentEx {
try { try {
Bundle bundle = future.getResult(); Bundle bundle = future.getResult();
String token = bundle.getString(AccountManager.KEY_AUTHTOKEN); String token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
Log.i(Helper.TAG, "Got token"); Log.i("Got token");
authorized = token; authorized = token;
etUser.setText(account.name); etUser.setText(account.name);
@ -1137,7 +1136,7 @@ public class FragmentAccount extends FragmentEx {
} }
}, 1000); }, 1000);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
snackbar.setText(Helper.formatThrowable(ex)); snackbar.setText(Helper.formatThrowable(ex));
} }
} }
@ -1149,7 +1148,7 @@ public class FragmentAccount extends FragmentEx {
} }
private void selectAccount() { private void selectAccount() {
Log.i(Helper.TAG, "Select account"); Log.i("Select account");
Provider provider = (Provider) spProvider.getSelectedItem(); Provider provider = (Provider) spProvider.getSelectedItem();
if (provider.type != null) if (provider.type != null)
startActivityForResult( startActivityForResult(

@ -47,7 +47,6 @@ import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan; import android.text.style.TypefaceSpan;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.text.style.UnderlineSpan; import android.text.style.UnderlineSpan;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -838,7 +837,7 @@ public class FragmentCompose extends FragmentEx {
etBcc.setText(sb.toString()); etBcc.setText(sb.toString());
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex); Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
} finally { } finally {
if (cursor != null) if (cursor != null)
@ -946,7 +945,7 @@ public class FragmentCompose extends FragmentEx {
args.putString("body", Html.toHtml(spannable)); args.putString("body", Html.toHtml(spannable));
Log.i(Helper.TAG, "Run load id=" + working); Log.i("Run load id=" + working);
actionLoader.load(this, args); actionLoader.load(this, args);
} }
@ -996,7 +995,7 @@ public class FragmentCompose extends FragmentEx {
db.beginTransaction(); db.beginTransaction();
EntityMessage draft = db.message().getMessage(id); EntityMessage draft = db.message().getMessage(id);
Log.i(Helper.TAG, "Attaching to id=" + id); Log.i("Attaching to id=" + id);
attachment.message = draft.id; attachment.message = draft.id;
attachment.sequence = db.attachment().getAttachmentSequence(draft.id) + 1; attachment.sequence = db.attachment().getAttachmentSequence(draft.id) + 1;
@ -1012,7 +1011,7 @@ public class FragmentCompose extends FragmentEx {
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
Log.i(Helper.TAG, "Created attachment=" + attachment.name + ":" + attachment.sequence + " type=" + attachment.type); Log.i("Created attachment=" + attachment.name + ":" + attachment.sequence + " type=" + attachment.type);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
@ -1074,7 +1073,7 @@ public class FragmentCompose extends FragmentEx {
boolean raw = args.getBoolean("raw", false); boolean raw = args.getBoolean("raw", false);
long answer = args.getLong("answer", -1); long answer = args.getLong("answer", -1);
Log.i(Helper.TAG, "Load draft action=" + action + " id=" + id + " reference=" + reference); Log.i("Load draft action=" + action + " id=" + id + " reference=" + reference);
DraftAccount result = new DraftAccount(); DraftAccount result = new DraftAccount();
@ -1116,20 +1115,20 @@ public class FragmentCompose extends FragmentEx {
if (ref.deliveredto != null && (ref.to == null || ref.to.length == 0)) { if (ref.deliveredto != null && (ref.to == null || ref.to.length == 0)) {
try { try {
Log.i(Helper.TAG, "Setting delivered to=" + ref.deliveredto); Log.i("Setting delivered to=" + ref.deliveredto);
ref.to = InternetAddress.parse(ref.deliveredto); ref.to = InternetAddress.parse(ref.deliveredto);
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
} }
if (ref.from != null && ref.from.length > 0) { if (ref.from != null && ref.from.length > 0) {
String from = Helper.canonicalAddress(((InternetAddress) ref.from[0]).getAddress()); String from = Helper.canonicalAddress(((InternetAddress) ref.from[0]).getAddress());
Log.i(Helper.TAG, "From=" + from + " to=" + MessageHelper.getFormattedAddresses(ref.to, false)); Log.i("From=" + from + " to=" + MessageHelper.getFormattedAddresses(ref.to, false));
for (EntityIdentity identity : identities) { for (EntityIdentity identity : identities) {
String email = Helper.canonicalAddress(identity.email); String email = Helper.canonicalAddress(identity.email);
if (from.equals(email)) { if (from.equals(email)) {
Log.i(Helper.TAG, "Swapping from/to"); Log.i("Swapping from/to");
Address[] tmp = ref.to; Address[] tmp = ref.to;
ref.to = ref.from; ref.to = ref.from;
ref.from = tmp; ref.from = tmp;
@ -1160,21 +1159,21 @@ public class FragmentCompose extends FragmentEx {
String to = args.getString("to"); String to = args.getString("to");
result.draft.to = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to)); result.draft.to = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to));
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
try { try {
String cc = args.getString("cc"); String cc = args.getString("cc");
result.draft.cc = (TextUtils.isEmpty(cc) ? null : InternetAddress.parse(cc)); result.draft.cc = (TextUtils.isEmpty(cc) ? null : InternetAddress.parse(cc));
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
try { try {
String bcc = args.getString("bcc"); String bcc = args.getString("bcc");
result.draft.bcc = (TextUtils.isEmpty(bcc) ? null : InternetAddress.parse(bcc)); result.draft.bcc = (TextUtils.isEmpty(bcc) ? null : InternetAddress.parse(bcc));
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
result.draft.subject = args.getString("subject"); result.draft.subject = args.getString("subject");
@ -1321,7 +1320,7 @@ public class FragmentCompose extends FragmentEx {
working = result.draft.id; working = result.draft.id;
final String action = getArguments().getString("action"); final String action = getArguments().getString("action");
Log.i(Helper.TAG, "Loaded draft id=" + result.draft.id + " action=" + action); Log.i("Loaded draft id=" + result.draft.id + " action=" + action);
etExtra.setText(result.draft.extra); etExtra.setText(result.draft.extra);
etTo.setText(MessageHelper.getFormattedAddresses(result.draft.to, true)); etTo.setText(MessageHelper.getFormattedAddresses(result.draft.to, true));
@ -1347,7 +1346,7 @@ public class FragmentCompose extends FragmentEx {
if (accounts == null) if (accounts == null)
accounts = new ArrayList<>(); accounts = new ArrayList<>();
Log.i(Helper.TAG, "Set accounts=" + accounts.size()); Log.i("Set accounts=" + accounts.size());
// Sort accounts // Sort accounts
Collections.sort(accounts, new Comparator<EntityAccount>() { Collections.sort(accounts, new Comparator<EntityAccount>() {
@ -1377,7 +1376,7 @@ public class FragmentCompose extends FragmentEx {
if (identities == null) if (identities == null)
identities = new ArrayList<>(); identities = new ArrayList<>();
Log.i(Helper.TAG, "Set identities=" + identities.size()); Log.i("Set identities=" + identities.size());
// Sort identities // Sort identities
Collections.sort(identities, new Comparator<EntityIdentity>() { Collections.sort(identities, new Comparator<EntityIdentity>() {
@ -1571,7 +1570,7 @@ public class FragmentCompose extends FragmentEx {
if (draft == null) if (draft == null)
throw new MessageRemovedException("Draft for action was deleted"); throw new MessageRemovedException("Draft for action was deleted");
Log.i(Helper.TAG, "Load action id=" + draft.id + " action=" + action); Log.i("Load action id=" + draft.id + " action=" + action);
// Move draft to new account // Move draft to new account
if (draft.account != aid && aid >= 0) { if (draft.account != aid && aid >= 0) {
@ -1731,7 +1730,7 @@ public class FragmentCompose extends FragmentEx {
@Override @Override
protected void onLoaded(Bundle args, EntityMessage draft) { protected void onLoaded(Bundle args, EntityMessage draft) {
int action = args.getInt("action"); int action = args.getInt("action");
Log.i(Helper.TAG, "Loaded action id=" + (draft == null ? null : draft.id) + " action=" + action); Log.i("Loaded action id=" + (draft == null ? null : draft.id) + " action=" + action);
busy = false; busy = false;
Helper.setViewsEnabled(view, true); Helper.setViewsEnabled(view, true);
@ -1804,7 +1803,7 @@ public class FragmentCompose extends FragmentEx {
} }
private void processTt(boolean opening, Editable output) { private void processTt(boolean opening, Editable output) {
Log.i(Helper.TAG, "Handling tt"); Log.i("Handling tt");
int len = output.length(); int len = output.length();
if (opening) if (opening)
output.setSpan(new TypefaceSpan("monospace"), len, len, Spannable.SPAN_MARK_MARK); output.setSpan(new TypefaceSpan("monospace"), len, len, Spannable.SPAN_MARK_MARK);

@ -22,7 +22,6 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -55,14 +54,14 @@ public class FragmentEx extends Fragment {
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
Log.i(Helper.TAG, "Save instance " + this); Log.i("Save instance " + this);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putString("subtitle", subtitle); outState.putString("subtitle", subtitle);
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
Log.i(Helper.TAG, "Create " + this + " saved=" + (savedInstanceState != null)); Log.i("Create " + this + " saved=" + (savedInstanceState != null));
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState != null) if (savedInstanceState != null)
subtitle = savedInstanceState.getString("subtitle"); subtitle = savedInstanceState.getString("subtitle");
@ -70,19 +69,19 @@ public class FragmentEx extends Fragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.i(Helper.TAG, "Create view " + this); Log.i("Create view " + this);
return super.onCreateView(inflater, container, savedInstanceState); return super.onCreateView(inflater, container, savedInstanceState);
} }
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
Log.i(Helper.TAG, "Activity " + this + " saved=" + (savedInstanceState != null)); Log.i("Activity " + this + " saved=" + (savedInstanceState != null));
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
} }
@Override @Override
public void onResume() { public void onResume() {
Log.i(Helper.TAG, "Resume " + this); Log.i("Resume " + this);
super.onResume(); super.onResume();
updateSubtitle(); updateSubtitle();
if (finish) { if (finish) {
@ -93,7 +92,7 @@ public class FragmentEx extends Fragment {
@Override @Override
public void onPause() { public void onPause() {
Log.i(Helper.TAG, "Pause " + this); Log.i("Pause " + this);
super.onPause(); super.onPause();
} }
@ -109,13 +108,13 @@ public class FragmentEx extends Fragment {
@Override @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
Log.i(Helper.TAG, "Config " + this); Log.i("Config " + this);
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
} }
@Override @Override
public void onDestroy() { public void onDestroy() {
Log.i(Helper.TAG, "Destroy " + this); Log.i("Destroy " + this);
super.onDestroy(); super.onDestroy();
} }

@ -24,7 +24,6 @@ import android.content.DialogInterface;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -180,7 +179,7 @@ public class FragmentFolder extends FragmentEx {
if (folder == null) { if (folder == null) {
reload = true; reload = true;
Log.i(Helper.TAG, "Creating folder=" + name); Log.i("Creating folder=" + name);
if (TextUtils.isEmpty(name)) if (TextUtils.isEmpty(name))
throw new IllegalArgumentException(getString(R.string.title_folder_name_missing)); throw new IllegalArgumentException(getString(R.string.title_folder_name_missing));
@ -217,7 +216,7 @@ public class FragmentFolder extends FragmentEx {
if (keep_time < 0) if (keep_time < 0)
keep_time = 0; keep_time = 0;
Log.i(Helper.TAG, "Updating folder=" + name); Log.i("Updating folder=" + name);
db.folder().setFolderProperties(id, db.folder().setFolderProperties(id,
display, unified, notify, hide, display, unified, notify, hide,
synchronize, poll, download, synchronize, poll, download,

@ -29,7 +29,6 @@ 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.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -270,7 +269,7 @@ public class FragmentIdentity extends FragmentEx {
if (records != null) if (records != null)
for (int i = 0; i < records.length; i++) { for (int i = 0; i < records.length; i++) {
SRVRecord srv = (SRVRecord) records[i]; SRVRecord srv = (SRVRecord) records[i];
Log.i(Helper.TAG, "SRV=" + srv); Log.i("SRV=" + srv);
return srv; return srv;
} }

@ -31,7 +31,6 @@ import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -435,7 +434,7 @@ public class FragmentMessages extends FragmentEx {
if (getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) if (getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
loadMessages(); loadMessages();
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
swipeRefresh.setEnabled(true); swipeRefresh.setEnabled(true);
} }
@ -528,7 +527,7 @@ public class FragmentMessages extends FragmentEx {
TupleMessageEx message = ((AdapterMessage) rvMessage.getAdapter()).getCurrentList().get(pos); TupleMessageEx message = ((AdapterMessage) rvMessage.getAdapter()).getCurrentList().get(pos);
if (message == null) if (message == null)
return; return;
Log.i(Helper.TAG, "Swiped dir=" + direction + " message=" + message.id); Log.i("Swiped dir=" + direction + " message=" + message.id);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", message.id); args.putLong("id", message.id);
@ -1596,7 +1595,7 @@ public class FragmentMessages extends FragmentEx {
message.folder = sent.id; message.folder = sent.id;
message.uid = null; message.uid = null;
db.message().updateMessage(message); db.message().updateMessage(message);
Log.i(Helper.TAG, "Appending sent msgid=" + message.msgid); Log.i("Appending sent msgid=" + message.msgid);
EntityOperation.queue(db, message, EntityOperation.ADD); // Could already exist EntityOperation.queue(db, message, EntityOperation.ADD); // Could already exist
} }
} }
@ -1792,7 +1791,7 @@ public class FragmentMessages extends FragmentEx {
!EntityFolder.JUNK.equals(message.folderType)) !EntityFolder.JUNK.equals(message.folderType))
count++; count++;
} }
Log.i(Helper.TAG, "Auto close=" + count); Log.i("Auto close=" + count);
// Auto close when: // Auto close when:
// - no more non archived/trashed/sent messages // - no more non archived/trashed/sent messages
@ -1808,7 +1807,7 @@ public class FragmentMessages extends FragmentEx {
model.setMessages(messages); model.setMessages(messages);
} }
Log.i(Helper.TAG, "Submit messages=" + messages.size()); Log.i("Submit messages=" + messages.size());
adapter.submitList(messages); adapter.submitList(messages);
boolean searching = (searchCallback != null && searchCallback.isSearching()); boolean searching = (searchCallback != null && searchCallback.isSearching());
@ -1906,7 +1905,7 @@ public class FragmentMessages extends FragmentEx {
for (long id : result.ids) { for (long id : result.ids) {
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message != null) { if (message != null) {
Log.i(Helper.TAG, "Move id=" + id + " target=" + result.target.name); Log.i("Move id=" + id + " target=" + result.target.name);
EntityFolder folder = db.folder().getFolderByName(message.account, result.target.name); EntityFolder folder = db.folder().getFolderByName(message.account, result.target.name);
EntityOperation.queue(db, message, EntityOperation.MOVE, folder.id); EntityOperation.queue(db, message, EntityOperation.MOVE, folder.id);
} }
@ -1950,7 +1949,7 @@ public class FragmentMessages extends FragmentEx {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
MessageTarget result = (MessageTarget) args.getSerializable("result"); MessageTarget result = (MessageTarget) args.getSerializable("result");
for (long id : result.ids) { for (long id : result.ids) {
Log.i(Helper.TAG, "Move undo id=" + id); Log.i("Move undo id=" + id);
db.message().setMessageUiHide(id, false); db.message().setMessageUiHide(id, false);
} }
return null; return null;
@ -1969,7 +1968,7 @@ public class FragmentMessages extends FragmentEx {
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
Log.i(Helper.TAG, "Move timeout"); Log.i("Move timeout");
// Remove snackbar // Remove snackbar
if (snackbar.isShown()) if (snackbar.isShown())
@ -1986,7 +1985,7 @@ public class FragmentMessages extends FragmentEx {
for (long id : result.ids) { for (long id : result.ids) {
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message != null && message.ui_hide) { if (message != null && message.ui_hide) {
Log.i(Helper.TAG, "Move id=" + id + " target=" + result.target.name); Log.i("Move id=" + id + " target=" + result.target.name);
EntityFolder folder = db.folder().getFolderByName(message.account, result.target.name); EntityFolder folder = db.folder().getFolderByName(message.account, result.target.name);
EntityOperation.queue(db, message, EntityOperation.MOVE, folder.id); EntityOperation.queue(db, message, EntityOperation.MOVE, folder.id);
} }

@ -25,7 +25,6 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -142,9 +141,9 @@ public class FragmentOperations extends FragmentEx {
protected Void onLoad(Context context, Bundle args) { protected Void onLoad(Context context, Bundle args) {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
List<EntityOperation> ops = db.operation().getOperationsError(); List<EntityOperation> ops = db.operation().getOperationsError();
Log.i(Helper.TAG, "Operations with error count=" + ops.size()); Log.i("Operations with error count=" + ops.size());
for (EntityOperation op : ops) { for (EntityOperation op : ops) {
Log.w(Helper.TAG, "Deleting operation=" + op.id + " error=" + op.error); Log.w("Deleting operation=" + op.id + " error=" + op.error);
if (op.message != null) if (op.message != null)
db.message().setMessageUiHide(op.message, false); db.message().setMessageUiHide(op.message, false);
db.operation().deleteOperation(op.id); db.operation().deleteOperation(op.id);

@ -31,7 +31,6 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -229,13 +228,13 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
for (Long id : db.message().getMessageWithoutPreview()) { for (Long id : db.message().getMessageWithoutPreview()) {
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
try { try {
Log.i(Helper.TAG, "Building preview id=" + id); Log.i("Building preview id=" + id);
String html = message.read(context); String html = message.read(context);
String text = (html == null ? null : Jsoup.parse(html).text()); String text = (html == null ? null : Jsoup.parse(html).text());
String preview = (text == null ? null : text.substring(0, Math.min(text.length(), 250))); String preview = (text == null ? null : text.substring(0, Math.min(text.length(), 250)));
db.message().setMessageContent(message.id, true, preview); db.message().setMessageContent(message.id, true, preview);
} catch (IOException ex) { } catch (IOException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
db.message().setMessageContent(message.id, false, null); db.message().setMessageContent(message.id, false, null);
if (!metered) if (!metered)
EntityOperation.queue(db, message, EntityOperation.BODY); EntityOperation.queue(db, message, EntityOperation.BODY);
@ -419,13 +418,13 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i(Helper.TAG, "Result class=" + this.getClass().getSimpleName() + Log.i("Result class=" + this.getClass().getSimpleName() +
" request=" + requestCode + " result=" + resultCode + " data=" + data); " request=" + requestCode + " result=" + resultCode + " data=" + data);
if (requestCode == ActivitySetup.REQUEST_SOUND) if (requestCode == ActivitySetup.REQUEST_SOUND)
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
Log.i(Helper.TAG, "Selected ringtone=" + uri); Log.i("Selected ringtone=" + uri);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (uri == null) if (uri == null)

@ -37,7 +37,6 @@ import android.os.PowerManager;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -204,7 +203,7 @@ public class FragmentSetup extends FragmentEx {
try { try {
startActivity(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)); startActivity(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS));
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }
}) })
@ -221,7 +220,7 @@ public class FragmentSetup extends FragmentEx {
startActivity(new Intent(Settings.ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS, startActivity(new Intent(Settings.ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS,
Uri.parse("package:" + BuildConfig.APPLICATION_ID))); Uri.parse("package:" + BuildConfig.APPLICATION_ID)));
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }
}); });
@ -614,7 +613,7 @@ public class FragmentSetup extends FragmentEx {
OutputStream out = null; OutputStream out = null;
try { try {
Log.i(Helper.TAG, "Writing URI=" + uri); Log.i("Writing URI=" + uri);
byte[] salt = new byte[16]; byte[] salt = new byte[16];
SecureRandom random = new SecureRandom(); SecureRandom random = new SecureRandom();
@ -678,7 +677,7 @@ public class FragmentSetup extends FragmentEx {
out.write(jexport.toString(2).getBytes()); out.write(jexport.toString(2).getBytes());
Log.i(Helper.TAG, "Exported data"); Log.i("Exported data");
} finally { } finally {
if (out != null) if (out != null)
out.close(); out.close();
@ -718,7 +717,7 @@ public class FragmentSetup extends FragmentEx {
InputStream in = null; InputStream in = null;
try { try {
Log.i(Helper.TAG, "Reading URI=" + uri); Log.i("Reading URI=" + uri);
ContentResolver resolver = getContext().getContentResolver(); ContentResolver resolver = getContext().getContentResolver();
AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(uri, "*/*", null); AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(uri, "*/*", null);
InputStream raw = descriptor.createInputStream(); InputStream raw = descriptor.createInputStream();
@ -744,7 +743,7 @@ public class FragmentSetup extends FragmentEx {
String line; String line;
while ((line = reader.readLine()) != null) while ((line = reader.readLine()) != null)
response.append(line); response.append(line);
Log.i(Helper.TAG, "Importing " + resolver.toString()); Log.i("Importing " + resolver.toString());
JSONObject jimport = new JSONObject(response.toString()); JSONObject jimport = new JSONObject(response.toString());
@ -758,7 +757,7 @@ public class FragmentSetup extends FragmentEx {
EntityAccount account = EntityAccount.fromJSON(jaccount); EntityAccount account = EntityAccount.fromJSON(jaccount);
account.created = new Date().getTime(); account.created = new Date().getTime();
account.id = db.account().insertAccount(account); account.id = db.account().insertAccount(account);
Log.i(Helper.TAG, "Imported account=" + account.name); Log.i("Imported account=" + account.name);
JSONArray jidentities = (JSONArray) jaccount.get("identities"); JSONArray jidentities = (JSONArray) jaccount.get("identities");
for (int i = 0; i < jidentities.length(); i++) { for (int i = 0; i < jidentities.length(); i++) {
@ -766,7 +765,7 @@ public class FragmentSetup extends FragmentEx {
EntityIdentity identity = EntityIdentity.fromJSON(jidentity); EntityIdentity identity = EntityIdentity.fromJSON(jidentity);
identity.account = account.id; identity.account = account.id;
identity.id = db.identity().insertIdentity(identity); identity.id = db.identity().insertIdentity(identity);
Log.i(Helper.TAG, "Imported identity=" + identity.email); Log.i("Imported identity=" + identity.email);
} }
JSONArray jfolders = (JSONArray) jaccount.get("folders"); JSONArray jfolders = (JSONArray) jaccount.get("folders");
@ -775,7 +774,7 @@ public class FragmentSetup extends FragmentEx {
EntityFolder folder = EntityFolder.fromJSON(jfolder); EntityFolder folder = EntityFolder.fromJSON(jfolder);
folder.account = account.id; folder.account = account.id;
folder.id = db.folder().insertFolder(folder); folder.id = db.folder().insertFolder(folder);
Log.i(Helper.TAG, "Imported folder=" + folder.name); Log.i("Imported folder=" + folder.name);
} }
} }
@ -784,7 +783,7 @@ public class FragmentSetup extends FragmentEx {
JSONObject janswer = (JSONObject) janswers.get(a); JSONObject janswer = (JSONObject) janswers.get(a);
EntityAnswer answer = EntityAnswer.fromJSON(janswer); EntityAnswer answer = EntityAnswer.fromJSON(janswer);
answer.id = db.answer().insertAnswer(answer); answer.id = db.answer().insertAnswer(answer);
Log.i(Helper.TAG, "Imported answer=" + answer.name); Log.i("Imported answer=" + answer.name);
} }
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -805,7 +804,7 @@ public class FragmentSetup extends FragmentEx {
editor.putString(key, (String) value); editor.putString(key, (String) value);
else else
throw new IllegalArgumentException("Unknown settings type key=" + key); throw new IllegalArgumentException("Unknown settings type key=" + key);
Log.i(Helper.TAG, "Imported setting=" + key); Log.i("Imported setting=" + key);
} }
} }
editor.apply(); editor.apply();
@ -815,7 +814,7 @@ public class FragmentSetup extends FragmentEx {
db.endTransaction(); db.endTransaction();
} }
Log.i(Helper.TAG, "Imported data"); Log.i("Imported data");
ServiceSynchronize.reload(context, "import"); ServiceSynchronize.reload(context, "import");
} finally { } finally {
if (in != null) if (in != null)

@ -27,7 +27,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -104,7 +103,7 @@ public class FragmentWebView extends FragmentEx {
webview.setDownloadListener(new DownloadListener() { webview.setDownloadListener(new DownloadListener() {
public void onDownloadStart( public void onDownloadStart(
String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Log.i(Helper.TAG, "Download url=" + url + " mime type=" + mimetype); Log.i("Download url=" + url + " mime type=" + mimetype);
Uri uri = Uri.parse(url); Uri uri = Uri.parse(url);
@ -168,7 +167,7 @@ public class FragmentWebView extends FragmentEx {
} }
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
return doc.html(); return doc.html();
@ -207,7 +206,7 @@ public class FragmentWebView extends FragmentEx {
final WebView.HitTestResult result = ((WebView) view).getHitTestResult(); final WebView.HitTestResult result = ((WebView) view).getHitTestResult();
if (result.getType() == WebView.HitTestResult.IMAGE_TYPE || if (result.getType() == WebView.HitTestResult.IMAGE_TYPE ||
result.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) { result.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
Log.i(Helper.TAG, "Context menu url=" + result.getExtra()); Log.i("Context menu url=" + result.getExtra());
menu.add(Menu.NONE, 1, 0, R.string.title_view) menu.add(Menu.NONE, 1, 0, R.string.title_view)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

@ -41,7 +41,6 @@ import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -90,8 +89,6 @@ import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
import static androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION; import static androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION;
public class Helper { public class Helper {
static final String TAG = "fairemail";
static final int JOB_DAILY = 1001; static final int JOB_DAILY = 1001;
static final int AUTH_TYPE_PASSWORD = 1; static final int AUTH_TYPE_PASSWORD = 1;
@ -115,7 +112,7 @@ public class Helper {
} }
static void view(Context context, LifecycleOwner owner, Uri uri, boolean browse) { static void view(Context context, LifecycleOwner owner, Uri uri, boolean browse) {
Log.i(Helper.TAG, "View=" + uri); Log.i("View=" + uri);
if (!hasCustomTabs(context, uri)) if (!hasCustomTabs(context, uri))
browse = true; browse = true;
@ -267,7 +264,7 @@ public class Helper {
sb.append(context.getString(title)).append("\n\n\n\n"); sb.append(context.getString(title)).append("\n\n\n\n");
sb.append(Helper.getAppInfo(context)); sb.append(Helper.getAppInfo(context));
if (ex != null) if (ex != null)
sb.append(ex.toString()).append("\n").append(Log.getStackTraceString(ex)); sb.append(ex.toString()).append("\n").append(android.util.Log.getStackTraceString(ex));
if (log != null) if (log != null)
sb.append(log); sb.append(log);
String body = "<pre>" + sb.toString().replaceAll("\\r?\\n", "<br />") + "</pre>"; String body = "<pre>" + sb.toString().replaceAll("\\r?\\n", "<br />") + "</pre>";
@ -526,7 +523,7 @@ public class Helper {
"-d", "-d",
"-v", "threadtime", "-v", "threadtime",
//"-t", "1000", //"-t", "1000",
Helper.TAG + ":I"}; Log.TAG + ":I"};
proc = Runtime.getRuntime().exec(cmd); proc = Runtime.getRuntime().exec(cmd);
br = new BufferedReader(new InputStreamReader(proc.getInputStream())); br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
@ -615,7 +612,7 @@ public class Helper {
} }
if (log) if (log)
Log.i(Helper.TAG, "isMetered: active info=" + cm.getNetworkInfo(active)); Log.i("isMetered: active info=" + cm.getNetworkInfo(active));
NetworkCapabilities caps = cm.getNetworkCapabilities(active); NetworkCapabilities caps = cm.getNetworkCapabilities(active);
if (caps == null) { if (caps == null) {
@ -625,7 +622,7 @@ public class Helper {
} }
if (log) if (log)
Log.i(Helper.TAG, "isMetered: active caps=" + caps); Log.i("isMetered: active caps=" + caps);
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) { if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
boolean unmetered = caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); boolean unmetered = caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
@ -642,7 +639,7 @@ public class Helper {
for (Network network : networks) { for (Network network : networks) {
NetworkInfo ni = cm.getNetworkInfo(network); NetworkInfo ni = cm.getNetworkInfo(network);
if (log) if (log)
Log.i(Helper.TAG, "isMetered: underlying info=" + ni); Log.i("isMetered: underlying info=" + ni);
caps = cm.getNetworkCapabilities(network); caps = cm.getNetworkCapabilities(network);
if (caps == null) { if (caps == null) {
@ -652,17 +649,17 @@ public class Helper {
} }
if (log) if (log)
Log.i(Helper.TAG, "isMetered: underlying caps=" + caps); Log.i("isMetered: underlying caps=" + caps);
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) { if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
underlying = true; underlying = true;
if (log) if (log)
Log.i(Helper.TAG, "isMetered: underlying caps=" + caps); Log.i("isMetered: underlying caps=" + caps);
if (ni != null && ni.isConnected()) { if (ni != null && ni.isConnected()) {
if (log) if (log)
Log.i(Helper.TAG, "isMetered: underlying is connected"); Log.i("isMetered: underlying is connected");
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)) { if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)) {
if (log) if (log)
@ -671,7 +668,7 @@ public class Helper {
} }
} else { } else {
if (log) if (log)
Log.i(Helper.TAG, "isMetered: underlying is disconnected"); Log.i("isMetered: underlying is disconnected");
} }
} }
} }
@ -707,14 +704,14 @@ public class Helper {
Account[] accounts = am.getAccountsByType(type); Account[] accounts = am.getAccountsByType(type);
for (Account account : accounts) for (Account account : accounts)
if (name.equals(account.name)) { if (name.equals(account.name)) {
Log.i(Helper.TAG, "Refreshing token"); Log.i("Refreshing token");
am.invalidateAuthToken(type, current); am.invalidateAuthToken(type, current);
String refreshed = am.blockingGetAuthToken(account, getAuthTokenType(type), true); String refreshed = am.blockingGetAuthToken(account, getAuthTokenType(type), true);
Log.i(Helper.TAG, "Refreshed token"); Log.i("Refreshed token");
return refreshed; return refreshed;
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
return current; return current;
} }
@ -733,7 +730,7 @@ public class Helper {
try { try {
return "com.android.vending".equals(context.getPackageManager().getInstallerPackageName(context.getPackageName())); return "com.android.vending".equals(context.getPackageManager().getInstallerPackageName(context.getPackageName()));
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(TAG, Log.getStackTraceString(ex)); Log.e(ex);
return false; return false;
} }
} }
@ -814,7 +811,7 @@ public class Helper {
sb.append(Integer.toString(b & 0xff, 16).toUpperCase()); sb.append(Integer.toString(b & 0xff, 16).toUpperCase());
return sb.toString(); return sb.toString();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
return null; return null;
} }
} }

@ -27,7 +27,6 @@ import android.graphics.drawable.Drawable;
import android.text.Html; import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
@ -121,7 +120,7 @@ public class HtmlHelper {
boolean embedded = source.startsWith("cid:"); boolean embedded = source.startsWith("cid:");
boolean data = source.startsWith("data:"); boolean data = source.startsWith("data:");
Log.i(Helper.TAG, "Image embedded=" + embedded + " data=" + data + " source=" + source); Log.i("Image embedded=" + embedded + " data=" + data + " source=" + source);
if (show) { if (show) {
// Embedded images // Embedded images
@ -167,7 +166,7 @@ public class HtmlHelper {
d.setBounds(0, 0, bm.getWidth(), bm.getHeight()); d.setBounds(0, 0, bm.getWidth(), bm.getHeight());
return d; return d;
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
Drawable d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme()); Drawable d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme());
d.setBounds(0, 0, px / 2, px / 2); d.setBounds(0, 0, px / 2, px / 2);
return d; return d;
@ -186,10 +185,10 @@ public class HtmlHelper {
// Get input stream // Get input stream
if (file.exists()) { if (file.exists()) {
Log.i(Helper.TAG, "Using cached " + file); Log.i("Using cached " + file);
is = new FileInputStream(file); is = new FileInputStream(file);
} else { } else {
Log.i(Helper.TAG, "Downloading " + source); Log.i("Downloading " + source);
is = new URL(source).openStream(); is = new URL(source).openStream();
} }
@ -210,7 +209,7 @@ public class HtmlHelper {
return d; return d;
} catch (Throwable ex) { } catch (Throwable ex) {
// Show warning icon // Show warning icon
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
Drawable d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme()); Drawable d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme());
d.setBounds(0, 0, px / 2, px / 2); d.setBounds(0, 0, px / 2, px / 2);
return d; return d;
@ -220,14 +219,14 @@ public class HtmlHelper {
try { try {
is.close(); is.close();
} catch (IOException e) { } catch (IOException e) {
Log.w(Helper.TAG, e + "\n" + Log.getStackTraceString(e)); Log.w(e);
} }
} }
if (os != null) { if (os != null) {
try { try {
os.close(); os.close();
} catch (IOException e) { } catch (IOException e) {
Log.w(Helper.TAG, e + "\n" + Log.getStackTraceString(e)); Log.w(e);
} }
} }
} }

@ -19,8 +19,6 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B) Copyright 2018 by Marcel Bokhorst (M66B)
*/ */
import android.util.Log;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.selection.ItemDetailsLookup; import androidx.recyclerview.selection.ItemDetailsLookup;
@ -34,7 +32,7 @@ public class ItemDetailsMessage extends ItemDetailsLookup.ItemDetails<Long> {
@Override @Override
public int getPosition() { public int getPosition() {
int pos = viewHolder.getAdapterPosition(); int pos = viewHolder.getAdapterPosition();
Log.i(Helper.TAG, "ItemDetails pos=" + pos); Log.i("ItemDetails pos=" + pos);
return pos; return pos;
} }
@ -43,7 +41,7 @@ public class ItemDetailsMessage extends ItemDetailsLookup.ItemDetails<Long> {
public Long getSelectionKey() { public Long getSelectionKey() {
int pos = viewHolder.getAdapterPosition(); int pos = viewHolder.getAdapterPosition();
Long key = viewHolder.getKey(); Long key = viewHolder.getKey();
Log.i(Helper.TAG, "ItemDetails pos=" + pos + " key=" + key); Log.i("ItemDetails pos=" + pos + " key=" + key);
return key; return key;
} }
} }

@ -25,7 +25,6 @@ import android.app.job.JobScheduler;
import android.app.job.JobService; import android.app.job.JobService;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.util.Log;
import java.io.File; import java.io.File;
import java.util.Calendar; import java.util.Calendar;
@ -42,7 +41,7 @@ public class JobDaily extends JobService {
private static final long KEEP_LOG_DURATION = 24 * 3600 * 1000L; // milliseconds private static final long KEEP_LOG_DURATION = 24 * 3600 * 1000L; // milliseconds
public static void schedule(Context context) { public static void schedule(Context context) {
Log.i(Helper.TAG, "Scheduling daily job"); Log.i("Scheduling daily job");
JobInfo.Builder job = new JobInfo.Builder(Helper.JOB_DAILY, new ComponentName(context, JobDaily.class)) JobInfo.Builder job = new JobInfo.Builder(Helper.JOB_DAILY, new ComponentName(context, JobDaily.class))
.setPeriodic(CLEANUP_INTERVAL) .setPeriodic(CLEANUP_INTERVAL)
@ -51,9 +50,9 @@ public class JobDaily extends JobService {
JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.cancel(Helper.JOB_DAILY); scheduler.cancel(Helper.JOB_DAILY);
if (scheduler.schedule(job.build()) == JobScheduler.RESULT_SUCCESS) if (scheduler.schedule(job.build()) == JobScheduler.RESULT_SUCCESS)
Log.i(Helper.TAG, "Scheduled daily job"); Log.i("Scheduled daily job");
else else
Log.e(Helper.TAG, "Scheduling daily job failed"); Log.e("Scheduling daily job failed");
} }
@Override @Override
@ -75,10 +74,10 @@ public class JobDaily extends JobService {
try { try {
db.beginTransaction(); db.beginTransaction();
Log.i(Helper.TAG, "Start daily job"); Log.i("Start daily job");
// Cleanup folders // Cleanup folders
Log.i(Helper.TAG, "Cleanup folders"); Log.i("Cleanup folders");
for (EntityFolder folder : db.folder().getFolders()) { for (EntityFolder folder : db.folder().getFolders()) {
Calendar cal_keep = Calendar.getInstance(); Calendar cal_keep = Calendar.getInstance();
cal_keep.add(Calendar.DAY_OF_MONTH, -folder.keep_days); cal_keep.add(Calendar.DAY_OF_MONTH, -folder.keep_days);
@ -93,62 +92,62 @@ public class JobDaily extends JobService {
int messages = db.message().deleteMessagesBefore(folder.id, keep_time, false); int messages = db.message().deleteMessagesBefore(folder.id, keep_time, false);
if (messages > 0) if (messages > 0)
Log.i(Helper.TAG, "Cleanup folder=" + folder.account + "/" + folder.name + Log.i("Cleanup folder=" + folder.account + "/" + folder.name +
" before=" + new Date(keep_time) + " deleted=" + messages); " before=" + new Date(keep_time) + " deleted=" + messages);
} }
long now = new Date().getTime(); long now = new Date().getTime();
// Cleanup message files // Cleanup message files
Log.i(Helper.TAG, "Cleanup message files"); Log.i("Cleanup message files");
File[] messages = new File(context.getFilesDir(), "messages").listFiles(); File[] messages = new File(context.getFilesDir(), "messages").listFiles();
if (messages != null) if (messages != null)
for (File file : messages) for (File file : messages)
if (file.isFile() && (now - file.lastModified()) > FILE_DELETE_THRESHOLD) { if (file.isFile() && (now - file.lastModified()) > FILE_DELETE_THRESHOLD) {
long id = Long.parseLong(file.getName()); long id = Long.parseLong(file.getName());
if (db.message().countMessage(id) == 0) { if (db.message().countMessage(id) == 0) {
Log.i(Helper.TAG, "Cleanup message id=" + id); Log.i("Cleanup message id=" + id);
if (!file.delete()) if (!file.delete())
Log.w(Helper.TAG, "Error deleting " + file); Log.w("Error deleting " + file);
} }
} }
// Cleanup attachment files // Cleanup attachment files
Log.i(Helper.TAG, "Cleanup attachment files"); Log.i("Cleanup attachment files");
File[] attachments = new File(context.getFilesDir(), "attachments").listFiles(); File[] attachments = new File(context.getFilesDir(), "attachments").listFiles();
if (attachments != null) if (attachments != null)
for (File file : attachments) for (File file : attachments)
if (file.isFile() && (now - file.lastModified()) > FILE_DELETE_THRESHOLD) { if (file.isFile() && (now - file.lastModified()) > FILE_DELETE_THRESHOLD) {
long id = Long.parseLong(file.getName()); long id = Long.parseLong(file.getName());
if (db.attachment().countAttachment(id) == 0) { if (db.attachment().countAttachment(id) == 0) {
Log.i(Helper.TAG, "Cleanup attachment id=" + id); Log.i("Cleanup attachment id=" + id);
if (!file.delete()) if (!file.delete())
Log.w(Helper.TAG, "Error deleting " + file); Log.w("Error deleting " + file);
} }
} }
// Cleanup cached images // Cleanup cached images
Log.i(Helper.TAG, "Cleanup cached image files"); Log.i("Cleanup cached image files");
File[] images = new File(context.getCacheDir(), "images").listFiles(); File[] images = new File(context.getCacheDir(), "images").listFiles();
if (images != null) if (images != null)
for (File file : images) for (File file : images)
if (file.isFile() && (now - file.lastModified()) > CACHE_IMAGE_DURATION) { if (file.isFile() && (now - file.lastModified()) > CACHE_IMAGE_DURATION) {
Log.i(Helper.TAG, "Deleting cached image=" + file.getName()); Log.i("Deleting cached image=" + file.getName());
if (!file.delete()) if (!file.delete())
Log.w(Helper.TAG, "Error deleting " + file); Log.w("Error deleting " + file);
} }
Log.i(Helper.TAG, "Cleanup log"); Log.i("Cleanup log");
long before = now - KEEP_LOG_DURATION; long before = now - KEEP_LOG_DURATION;
int logs = db.log().deleteLogs(before); int logs = db.log().deleteLogs(before);
Log.i(Helper.TAG, "Deleted logs=" + logs); Log.i("Deleted logs=" + logs);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} finally { } finally {
db.endTransaction(); db.endTransaction();
Log.i(Helper.TAG, "End daily job"); Log.i("End daily job");
} }
} }

@ -0,0 +1,33 @@
package eu.faircode.email;
public class Log {
static final String TAG = "fairemail";
public static int i(String msg) {
return android.util.Log.i(TAG, msg);
}
public static int w(String msg) {
return android.util.Log.w(TAG, msg);
}
public static int e(String msg) {
return android.util.Log.e(TAG, msg);
}
public static int w(Throwable ex) {
return android.util.Log.w(TAG, ex + "\n" + android.util.Log.getStackTraceString(ex));
}
public static int e(Throwable ex) {
return android.util.Log.e(TAG, ex + "\n" + android.util.Log.getStackTraceString(ex));
}
public static int w(String prefix, Throwable ex) {
return android.util.Log.w(TAG, prefix + " " + ex + "\n" + android.util.Log.getStackTraceString(ex));
}
public static int e(String prefix, Throwable ex) {
return android.util.Log.e(TAG, prefix + " " + ex + "\n" + android.util.Log.getStackTraceString(ex));
}
}

@ -22,7 +22,6 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
@ -159,12 +158,12 @@ public class MessageHelper {
System.setProperty("mail.mime.multipart.ignoreexistingboundaryparameter", "true"); System.setProperty("mail.mime.multipart.ignoreexistingboundaryparameter", "true");
if (false) { if (false) {
Log.i(Helper.TAG, "Prefering IPv4"); Log.i("Prefering IPv4");
System.setProperty("java.net.preferIPv4Stack", "true"); System.setProperty("java.net.preferIPv4Stack", "true");
} }
// https://javaee.github.io/javamail/OAuth2 // https://javaee.github.io/javamail/OAuth2
Log.i(Helper.TAG, "Auth type=" + auth_type); Log.i("Auth type=" + auth_type);
if (auth_type == Helper.AUTH_TYPE_GMAIL) { if (auth_type == Helper.AUTH_TYPE_GMAIL) {
props.put("mail.imaps.auth.mechanisms", "XOAUTH2"); props.put("mail.imaps.auth.mechanisms", "XOAUTH2");
props.put("mail.imap.auth.mechanisms", "XOAUTH2"); props.put("mail.imap.auth.mechanisms", "XOAUTH2");
@ -201,7 +200,7 @@ public class MessageHelper {
if (email != null && !TextUtils.isEmpty(message.extra)) { if (email != null && !TextUtils.isEmpty(message.extra)) {
int at = email.indexOf('@'); int at = email.indexOf('@');
email = email.substring(0, at) + message.extra + email.substring(at); email = email.substring(0, at) + message.extra + email.substring(at);
Log.i(Helper.TAG, "extra=" + email); Log.i("extra=" + email);
} }
imessage.setFrom(new InternetAddress(email, name)); imessage.setFrom(new InternetAddress(email, name));
} }
@ -502,13 +501,13 @@ public class MessageHelper {
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
// x-binaryenc // x-binaryenc
// https://javaee.github.io/javamail/FAQ#unsupen // https://javaee.github.io/javamail/FAQ#unsupen
Log.w(Helper.TAG, "Unsupported encoding: " + part.getContentType()); Log.w("Unsupported encoding: " + part.getContentType());
return readStream(part.getInputStream(), "US-ASCII"); return readStream(part.getInputStream(), "US-ASCII");
} }
} catch (IOException ex) { } catch (IOException ex) {
// IOException; Unknown encoding: none // IOException; Unknown encoding: none
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
return "<pre>" + ex + "<br />" + Log.getStackTraceString(ex) + "</pre>"; return "<pre>" + ex + "<br />" + android.util.Log.getStackTraceString(ex) + "</pre>";
} }
if (part.isMimeType("text/plain")) if (part.isMimeType("text/plain"))
@ -535,8 +534,8 @@ public class MessageHelper {
} }
} catch (ParseException ex) { } catch (ParseException ex) {
// ParseException: In parameter list boundary="...">, expected parameter name, got ";" // ParseException: In parameter list boundary="...">, expected parameter name, got ";"
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
text = "<pre>" + ex + "<br />" + Log.getStackTraceString(ex) + "</pre>"; text = "<pre>" + ex + "<br />" + android.util.Log.getStackTraceString(ex) + "</pre>";
} }
return text; return text;
} }
@ -550,8 +549,8 @@ public class MessageHelper {
return s; return s;
} }
} catch (ParseException ex) { } catch (ParseException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
return "<pre>" + ex + "<br />" + Log.getStackTraceString(ex) + "</pre>"; return "<pre>" + ex + "<br />" + android.util.Log.getStackTraceString(ex) + "</pre>";
} }
return null; return null;
@ -572,11 +571,11 @@ public class MessageHelper {
} }
} catch (IOException ex) { } catch (IOException ex) {
if (ex.getCause() instanceof MessagingException) if (ex.getCause() instanceof MessagingException)
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
else else
throw ex; throw ex;
} catch (ParseException ex) { } catch (ParseException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
return result; return result;
@ -590,10 +589,10 @@ public class MessageHelper {
try { try {
content = part.getContent(); content = part.getContent();
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
Log.w(Helper.TAG, "attachment content type=" + part.getContentType()); Log.w("attachment content type=" + part.getContentType());
content = part.getInputStream(); content = part.getInputStream();
} catch (ParseException ex) { } catch (ParseException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
content = null; content = null;
} }
@ -602,7 +601,7 @@ public class MessageHelper {
try { try {
disposition = part.getDisposition(); disposition = part.getDisposition();
} catch (MessagingException ex) { } catch (MessagingException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
disposition = null; disposition = null;
} }
@ -610,7 +609,7 @@ public class MessageHelper {
try { try {
filename = part.getFileName(); filename = part.getFileName();
} catch (MessagingException ex) { } catch (MessagingException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
filename = null; filename = null;
} }
@ -635,7 +634,7 @@ public class MessageHelper {
if (extension != null) { if (extension != null) {
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase()); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
if (type != null) { if (type != null) {
Log.w(Helper.TAG, "Guessing file=" + attachment.name + " type=" + type); Log.w("Guessing file=" + attachment.name + " type=" + type);
attachment.type = type; attachment.type = type;
} }
} }

@ -19,8 +19,6 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B) Copyright 2018 by Marcel Bokhorst (M66B)
*/ */
import android.util.Log;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.mail.Session; import javax.mail.Session;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
@ -39,7 +37,7 @@ public class MimeMessageEx extends MimeMessage {
super.updateMessageID(); super.updateMessageID();
else { else {
setHeader("Message-ID", msgid); setHeader("Message-ID", msgid);
Log.v(Helper.TAG, "Override Message-ID=" + msgid); Log.i("Override Message-ID=" + msgid);
} }
} }
} }

@ -21,7 +21,6 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.res.XmlResourceParser; import android.content.res.XmlResourceParser;
import android.util.Log;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -89,7 +88,7 @@ public class Provider {
eventType = xml.next(); eventType = xml.next();
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
final Collator collator = Collator.getInstance(Locale.getDefault()); final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc

@ -50,7 +50,6 @@ import android.preference.PreferenceManager;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.Html; import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.LongSparseArray; import android.util.LongSparseArray;
import com.sun.mail.iap.ConnectionException; import com.sun.mail.iap.ConnectionException;
@ -158,7 +157,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void onCreate() { public void onCreate() {
Log.i(Helper.TAG, "Service create version=" + BuildConfig.VERSION_NAME); Log.i("Service create version=" + BuildConfig.VERSION_NAME);
super.onCreate(); super.onCreate();
// Listen for network changes // Listen for network changes
@ -188,7 +187,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void run() { public void run() {
try { try {
Log.i(Helper.TAG, "Notification messages=" + messages.size()); Log.i("Notification messages=" + messages.size());
Widget.update(ServiceSynchronize.this, messages.size()); Widget.update(ServiceSynchronize.this, messages.size());
@ -222,11 +221,11 @@ public class ServiceSynchronize extends LifecycleService {
all.add(id); all.add(id);
if (removed.contains(id)) { if (removed.contains(id)) {
removed.remove(id); removed.remove(id);
Log.i(Helper.TAG, "Notification removing=" + id); Log.i("Notification removing=" + id);
} else { } else {
removed.remove(Integer.valueOf(-id)); removed.remove(Integer.valueOf(-id));
added.add(id); added.add(id);
Log.i(Helper.TAG, "Notification adding=" + id); Log.i("Notification adding=" + id);
} }
} }
} }
@ -236,7 +235,7 @@ public class ServiceSynchronize extends LifecycleService {
if (id < 0) if (id < 0)
headers++; headers++;
Log.i(Helper.TAG, "Notification account=" + account + Log.i("Notification account=" + account +
" notifications=" + notifications.size() + " all=" + all.size() + " notifications=" + notifications.size() + " all=" + all.size() +
" added=" + added.size() + " removed=" + removed.size() + " headers=" + headers); " added=" + added.size() + " removed=" + removed.size() + " headers=" + headers);
@ -258,7 +257,7 @@ public class ServiceSynchronize extends LifecycleService {
notifying.put(account, all); notifying.put(account, all);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }
}); });
@ -268,7 +267,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void onDestroy() { public void onDestroy() {
Log.i(Helper.TAG, "Service destroy"); Log.i("Service destroy");
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cm.unregisterNetworkCallback(serviceManager); cm.unregisterNetworkCallback(serviceManager);
@ -288,7 +287,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
String action = (intent == null ? null : intent.getAction()); String action = (intent == null ? null : intent.getAction());
Log.i(Helper.TAG, "Service command intent=" + intent + " action=" + action); Log.i("Service command intent=" + intent + " action=" + action);
startForeground(NOTIFICATION_SYNCHRONIZE, getNotificationService(null).build()); startForeground(NOTIFICATION_SYNCHRONIZE, getNotificationService(null).build());
@ -370,7 +369,7 @@ public class ServiceSynchronize extends LifecycleService {
break; break;
default: default:
Log.w(Helper.TAG, "Unknown action: " + parts[0]); Log.w("Unknown action: " + parts[0]);
} }
db.setTransactionSuccessful(); db.setTransactionSuccessful();
@ -382,7 +381,7 @@ public class ServiceSynchronize extends LifecycleService {
break; break;
default: default:
Log.w(Helper.TAG, "Unknown action: " + action); Log.w("Unknown action: " + action);
} }
} }
@ -627,7 +626,7 @@ public class ServiceSynchronize extends LifecycleService {
sb.append(Jsoup.parse(html).text()); sb.append(Jsoup.parse(html).text());
mbuilder.setStyle(new Notification.BigTextStyle().bigText(Html.fromHtml(sb.toString()))); mbuilder.setStyle(new Notification.BigTextStyle().bigText(Html.fromHtml(sb.toString())));
} catch (IOException ex) { } catch (IOException ex) {
Log.e(Helper.TAG, ex + "/n" + Log.getStackTraceString(ex)); Log.e(ex);
mbuilder.setStyle(new Notification.BigTextStyle().bigText(ex.toString())); mbuilder.setStyle(new Notification.BigTextStyle().bigText(ex.toString()));
} }
@ -659,7 +658,7 @@ public class ServiceSynchronize extends LifecycleService {
} }
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} finally { } finally {
if (cursor != null) if (cursor != null)
cursor.close(); cursor.close();
@ -794,7 +793,7 @@ public class ServiceSynchronize extends LifecycleService {
int backoff = CONNECT_BACKOFF_START; int backoff = CONNECT_BACKOFF_START;
while (state.running()) { while (state.running()) {
Log.i(Helper.TAG, account.name + " run"); Log.i(account.name + " run");
// Debug // Debug
boolean debug = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("debug", false); boolean debug = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("debug", false);
@ -825,7 +824,7 @@ public class ServiceSynchronize extends LifecycleService {
reportError(account, null, new AlertException(e.getMessage())); reportError(account, null, new AlertException(e.getMessage()));
state.error(); state.error();
} else } else
Log.i(Helper.TAG, account.name + " " + type + ": " + e.getMessage()); Log.i(account.name + " " + type + ": " + e.getMessage());
} finally { } finally {
wlAccount.release(); wlAccount.release();
} }
@ -838,7 +837,7 @@ public class ServiceSynchronize extends LifecycleService {
public void folderCreated(FolderEvent e) { public void folderCreated(FolderEvent e) {
try { try {
wlAccount.acquire(); wlAccount.acquire();
Log.i(Helper.TAG, "Folder created=" + e.getFolder().getFullName()); Log.i("Folder created=" + e.getFolder().getFullName());
reload(ServiceSynchronize.this, "folder created"); reload(ServiceSynchronize.this, "folder created");
} finally { } finally {
wlAccount.release(); wlAccount.release();
@ -849,12 +848,12 @@ public class ServiceSynchronize extends LifecycleService {
public void folderRenamed(FolderEvent e) { public void folderRenamed(FolderEvent e) {
try { try {
wlAccount.acquire(); wlAccount.acquire();
Log.i(Helper.TAG, "Folder renamed=" + e.getFolder().getFullName()); Log.i("Folder renamed=" + e.getFolder().getFullName());
String old = e.getFolder().getFullName(); String old = e.getFolder().getFullName();
String name = e.getNewFolder().getFullName(); String name = e.getNewFolder().getFullName();
int count = db.folder().renameFolder(account.id, old, name); int count = db.folder().renameFolder(account.id, old, name);
Log.i(Helper.TAG, "Renamed to " + name + " count=" + count); Log.i("Renamed to " + name + " count=" + count);
reload(ServiceSynchronize.this, "folder renamed"); reload(ServiceSynchronize.this, "folder renamed");
} finally { } finally {
@ -866,7 +865,7 @@ public class ServiceSynchronize extends LifecycleService {
public void folderDeleted(FolderEvent e) { public void folderDeleted(FolderEvent e) {
try { try {
wlAccount.acquire(); wlAccount.acquire();
Log.i(Helper.TAG, "Folder deleted=" + e.getFolder().getFullName()); Log.i("Folder deleted=" + e.getFolder().getFullName());
reload(ServiceSynchronize.this, "folder deleted"); reload(ServiceSynchronize.this, "folder deleted");
} finally { } finally {
wlAccount.release(); wlAccount.release();
@ -878,17 +877,17 @@ public class ServiceSynchronize extends LifecycleService {
istore.addConnectionListener(new ConnectionAdapter() { istore.addConnectionListener(new ConnectionAdapter() {
@Override @Override
public void opened(ConnectionEvent e) { public void opened(ConnectionEvent e) {
Log.i(Helper.TAG, account.name + " opened event"); Log.i(account.name + " opened event");
} }
@Override @Override
public void disconnected(ConnectionEvent e) { public void disconnected(ConnectionEvent e) {
Log.e(Helper.TAG, account.name + " disconnected event"); Log.e(account.name + " disconnected event");
} }
@Override @Override
public void closed(ConnectionEvent e) { public void closed(ConnectionEvent e) {
Log.e(Helper.TAG, account.name + " closed event"); Log.e(account.name + " closed event");
} }
}); });
@ -907,7 +906,7 @@ public class ServiceSynchronize extends LifecycleService {
long now = new Date().getTime(); long now = new Date().getTime();
long delayed = now - account.last_connected; long delayed = now - account.last_connected;
if (delayed > ACCOUNT_ERROR_AFTER * 60 * 1000L) { if (delayed > ACCOUNT_ERROR_AFTER * 60 * 1000L) {
Log.i(Helper.TAG, "Reporting sync error after=" + delayed); Log.i("Reporting sync error after=" + delayed);
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify("receive", account.id.intValue(), nm.notify("receive", account.id.intValue(),
getNotificationError(account.name, account.last_connected, ex, false).build()); getNotificationError(account.name, account.last_connected, ex, false).build());
@ -918,7 +917,7 @@ public class ServiceSynchronize extends LifecycleService {
} }
final boolean capIdle = istore.hasCapability("IDLE"); final boolean capIdle = istore.hasCapability("IDLE");
Log.i(Helper.TAG, account.name + " idle=" + capIdle); Log.i(account.name + " idle=" + capIdle);
db.account().setAccountState(account.id, "connected"); db.account().setAccountState(account.id, "connected");
@ -934,7 +933,7 @@ public class ServiceSynchronize extends LifecycleService {
final ExecutorService pollExecutor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); final ExecutorService pollExecutor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
for (final EntityFolder folder : db.folder().getFolders(account.id)) { for (final EntityFolder folder : db.folder().getFolders(account.id)) {
if (folder.synchronize && !folder.poll && capIdle) { if (folder.synchronize && !folder.poll && capIdle) {
Log.i(Helper.TAG, account.name + " sync folder " + folder.name); Log.i(account.name + " sync folder " + folder.name);
db.folder().setFolderState(folder.id, "connecting"); db.folder().setFolderState(folder.id, "connecting");
@ -950,7 +949,7 @@ public class ServiceSynchronize extends LifecycleService {
db.folder().setFolderState(folder.id, "connected"); db.folder().setFolderState(folder.id, "connected");
db.folder().setFolderError(folder.id, null); db.folder().setFolderError(folder.id, null);
Log.i(Helper.TAG, account.name + " folder " + folder.name + " flags=" + ifolder.getPermanentFlags()); Log.i(account.name + " folder " + folder.name + " flags=" + ifolder.getPermanentFlags());
// Listen for new and deleted messages // Listen for new and deleted messages
ifolder.addMessageCountListener(new MessageCountAdapter() { ifolder.addMessageCountListener(new MessageCountAdapter() {
@ -958,7 +957,7 @@ public class ServiceSynchronize extends LifecycleService {
public void messagesAdded(MessageCountEvent e) { public void messagesAdded(MessageCountEvent e) {
try { try {
wlAccount.acquire(); wlAccount.acquire();
Log.i(Helper.TAG, folder.name + " messages added"); Log.i(folder.name + " messages added");
FetchProfile fp = new FetchProfile(); FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.ENVELOPE);
@ -993,22 +992,22 @@ public class ServiceSynchronize extends LifecycleService {
db.endTransaction(); db.endTransaction();
} }
} catch (MessageRemovedException ex) { } catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
} catch (FolderClosedException ex) { } catch (FolderClosedException ex) {
throw ex; throw ex;
} catch (IOException ex) { } catch (IOException ex) {
if (ex.getCause() instanceof MessagingException) { if (ex.getCause() instanceof MessagingException) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
if (!(ex.getCause() instanceof MessageRemovedException)) if (!(ex.getCause() instanceof MessageRemovedException))
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} else } else
throw ex; throw ex;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
reportError(account, folder, ex); reportError(account, folder, ex);
state.error(); state.error();
} finally { } finally {
@ -1020,7 +1019,7 @@ public class ServiceSynchronize extends LifecycleService {
public void messagesRemoved(MessageCountEvent e) { public void messagesRemoved(MessageCountEvent e) {
try { try {
wlAccount.acquire(); wlAccount.acquire();
Log.i(Helper.TAG, folder.name + " messages removed"); Log.i(folder.name + " messages removed");
for (Message imessage : e.getMessages()) for (Message imessage : e.getMessages())
try { try {
long uid = ifolder.getUID(imessage); long uid = ifolder.getUID(imessage);
@ -1028,12 +1027,12 @@ public class ServiceSynchronize extends LifecycleService {
DB db = DB.getInstance(ServiceSynchronize.this); DB db = DB.getInstance(ServiceSynchronize.this);
int count = db.message().deleteMessage(folder.id, uid); int count = db.message().deleteMessage(folder.id, uid);
Log.i(Helper.TAG, "Deleted uid=" + uid + " count=" + count); Log.i("Deleted uid=" + uid + " count=" + count);
} catch (MessageRemovedException ex) { } catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
reportError(account, folder, ex); reportError(account, folder, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
state.error(); state.error();
@ -1052,7 +1051,7 @@ public class ServiceSynchronize extends LifecycleService {
try { try {
wlAccount.acquire(); wlAccount.acquire();
try { try {
Log.i(Helper.TAG, folder.name + " message changed"); Log.i(folder.name + " message changed");
FetchProfile fp = new FetchProfile(); FetchProfile fp = new FetchProfile();
fp.add(UIDFolder.FetchProfileItem.UID); fp.add(UIDFolder.FetchProfileItem.UID);
@ -1079,22 +1078,22 @@ public class ServiceSynchronize extends LifecycleService {
db.endTransaction(); db.endTransaction();
} }
} catch (MessageRemovedException ex) { } catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
} catch (FolderClosedException ex) { } catch (FolderClosedException ex) {
throw ex; throw ex;
} catch (IOException ex) { } catch (IOException ex) {
if (ex.getCause() instanceof MessagingException) { if (ex.getCause() instanceof MessagingException) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
if (!(ex.getCause() instanceof MessageRemovedException)) if (!(ex.getCause() instanceof MessageRemovedException))
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} else } else
throw ex; throw ex;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
reportError(account, folder, ex); reportError(account, folder, ex);
state.error(); state.error();
} finally { } finally {
@ -1108,18 +1107,18 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void run() { public void run() {
try { try {
Log.i(Helper.TAG, folder.name + " start idle"); Log.i(folder.name + " start idle");
while (state.running()) { while (state.running()) {
Log.v(Helper.TAG, folder.name + " do idle"); Log.i(folder.name + " do idle");
ifolder.idle(false); ifolder.idle(false);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
reportError(account, folder, ex); reportError(account, folder, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
state.error(); state.error();
} finally { } finally {
Log.i(Helper.TAG, folder.name + " end idle"); Log.i(folder.name + " end idle");
} }
} }
}, "idler." + folder.id); }, "idler." + folder.id);
@ -1136,7 +1135,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void handleMessage(android.os.Message msg) { public void handleMessage(android.os.Message msg) {
Log.i(Helper.TAG, account.name + "/" + folder.name + " observe=" + msg.what); Log.i(account.name + "/" + folder.name + " observe=" + msg.what);
try { try {
if (msg.what == 0) if (msg.what == 0)
liveOperations.removeObserver(observer); liveOperations.removeObserver(observer);
@ -1145,7 +1144,7 @@ public class ServiceSynchronize extends LifecycleService {
liveOperations.observe(ServiceSynchronize.this, observer); liveOperations.observe(ServiceSynchronize.this, observer);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }
@ -1167,20 +1166,20 @@ public class ServiceSynchronize extends LifecycleService {
handling = current; handling = current;
if (handling.size() > 0 && process) { if (handling.size() > 0 && process) {
Log.i(Helper.TAG, folder.name + " operations=" + operations.size()); Log.i(folder.name + " operations=" + operations.size());
(folder.poll ? pollExecutor : folderExecutor).submit(new Runnable() { (folder.poll ? pollExecutor : folderExecutor).submit(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
wlFolder.acquire(); wlFolder.acquire();
Log.i(Helper.TAG, folder.name + " process"); Log.i(folder.name + " process");
// Get folder // Get folder
IMAPFolder ifolder = folders.get(folder); // null when polling IMAPFolder ifolder = folders.get(folder); // null when polling
final boolean shouldClose = (ifolder == null); final boolean shouldClose = (ifolder == null);
try { try {
Log.i(Helper.TAG, folder.name + " run " + (shouldClose ? "offline" : "online")); Log.i(folder.name + " run " + (shouldClose ? "offline" : "online"));
if (ifolder == null) { if (ifolder == null) {
// Prevent unnecessary folder connections // Prevent unnecessary folder connections
@ -1199,7 +1198,7 @@ public class ServiceSynchronize extends LifecycleService {
processOperations(account, folder, isession, istore, ifolder, state); processOperations(account, folder, isession, istore, ifolder, state);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
reportError(account, folder, ex); reportError(account, folder, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
state.error(); state.error();
@ -1210,7 +1209,7 @@ public class ServiceSynchronize extends LifecycleService {
try { try {
ifolder.close(false); ifolder.close(false);
} catch (MessagingException ex) { } catch (MessagingException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
} }
} }
db.folder().setFolderState(folder.id, null); db.folder().setFolderState(folder.id, null);
@ -1227,7 +1226,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
boolean eq = super.equals(obj); boolean eq = super.equals(obj);
Log.i(Helper.TAG, account.name + "/" + folder.name + " equal=" + eq + " observer=" + observer + " other=" + obj); Log.i(account.name + "/" + folder.name + " equal=" + eq + " observer=" + observer + " other=" + obj);
return eq; return eq;
} }
}; };
@ -1303,9 +1302,9 @@ public class ServiceSynchronize extends LifecycleService {
unregisterReceiver(alarm); unregisterReceiver(alarm);
} }
Log.i(Helper.TAG, account.name + " done state=" + state); Log.i(account.name + " done state=" + state);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, account.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(account.name, ex);
reportError(account, null, ex); reportError(account, null, ex);
EntityLog.log(ServiceSynchronize.this, account.name + " " + Helper.formatThrowable(ex)); EntityLog.log(ServiceSynchronize.this, account.name + " " + Helper.formatThrowable(ex));
@ -1328,7 +1327,7 @@ public class ServiceSynchronize extends LifecycleService {
istore.close(); istore.close();
EntityLog.log(ServiceSynchronize.this, account.name + " store closed"); EntityLog.log(ServiceSynchronize.this, account.name + " store closed");
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(Helper.TAG, account.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(account.name, ex);
} finally { } finally {
EntityLog.log(this, account.name + " closed"); EntityLog.log(this, account.name + " closed");
db.account().setAccountState(account.id, null); db.account().setAccountState(account.id, null);
@ -1394,7 +1393,7 @@ public class ServiceSynchronize extends LifecycleService {
if (backoff <= CONNECT_BACKOFF_MAX) if (backoff <= CONNECT_BACKOFF_MAX)
backoff *= 2; backoff *= 2;
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.w(Helper.TAG, account.name + " backoff " + ex.toString()); Log.w(account.name + " backoff " + ex.toString());
} }
} }
} finally { } finally {
@ -1405,16 +1404,16 @@ public class ServiceSynchronize extends LifecycleService {
private void processOperations(EntityAccount account, EntityFolder folder, Session isession, IMAPStore istore, IMAPFolder ifolder, ServiceState state) throws MessagingException, JSONException, IOException { private void processOperations(EntityAccount account, EntityFolder folder, Session isession, IMAPStore istore, IMAPFolder ifolder, ServiceState state) throws MessagingException, JSONException, IOException {
try { try {
Log.i(Helper.TAG, folder.name + " start process"); Log.i(folder.name + " start process");
DB db = DB.getInstance(this); DB db = DB.getInstance(this);
List<EntityOperation> ops = db.operation().getOperationsByFolder( List<EntityOperation> ops = db.operation().getOperationsByFolder(
folder.id, EntityFolder.OUTBOX.equals(folder.type)); folder.id, EntityFolder.OUTBOX.equals(folder.type));
Log.i(Helper.TAG, folder.name + " pending operations=" + ops.size()); Log.i(folder.name + " pending operations=" + ops.size());
for (int i = 0; i < ops.size() && state.running(); i++) { for (int i = 0; i < ops.size() && state.running(); i++) {
EntityOperation op = ops.get(i); EntityOperation op = ops.get(i);
try { try {
Log.i(Helper.TAG, folder.name + Log.i(folder.name +
" start op=" + op.id + "/" + op.name + " start op=" + op.id + "/" + op.name +
" msg=" + op.message + " msg=" + op.message +
" args=" + op.args); " args=" + op.args);
@ -1502,7 +1501,7 @@ public class ServiceSynchronize extends LifecycleService {
if (ex instanceof MessageRemovedException || if (ex instanceof MessageRemovedException ||
ex instanceof FolderNotFoundException || ex instanceof FolderNotFoundException ||
ex instanceof SendFailedException) { ex instanceof SendFailedException) {
Log.w(Helper.TAG, "Unrecoverable " + ex + "\n" + Log.getStackTraceString(ex)); Log.w("Unrecoverable", ex);
// There is no use in repeating // There is no use in repeating
db.operation().deleteOperation(op.id); db.operation().deleteOperation(op.id);
@ -1510,7 +1509,7 @@ public class ServiceSynchronize extends LifecycleService {
} else if (ex instanceof MessagingException) { } else if (ex instanceof MessagingException) {
// Socket timeout is a recoverable condition (send message) // Socket timeout is a recoverable condition (send message)
if (ex.getCause() instanceof SocketTimeoutException) { if (ex.getCause() instanceof SocketTimeoutException) {
Log.w(Helper.TAG, "Recoverable " + ex + "\n" + Log.getStackTraceString(ex)); Log.w("Recoverable", ex);
// No need to inform user // No need to inform user
return; return;
} }
@ -1519,11 +1518,11 @@ public class ServiceSynchronize extends LifecycleService {
throw ex; throw ex;
} }
} finally { } finally {
Log.i(Helper.TAG, folder.name + " end op=" + op.id + "/" + op.name); Log.i(folder.name + " end op=" + op.id + "/" + op.name);
} }
} }
} finally { } finally {
Log.i(Helper.TAG, folder.name + " end process state=" + state); Log.i(folder.name + " end process state=" + state);
} }
} }
@ -1659,7 +1658,7 @@ public class ServiceSynchronize extends LifecycleService {
Folder itarget = istore.getFolder(target.name); Folder itarget = istore.getFolder(target.name);
ifolder.moveMessages(new Message[]{imessage}, itarget); ifolder.moveMessages(new Message[]{imessage}, itarget);
} else { } else {
Log.w(Helper.TAG, "MOVE by DELETE/APPEND"); Log.w("MOVE by DELETE/APPEND");
// Delete source // Delete source
imessage.setFlag(Flags.Flag.DELETED, true); imessage.setFlag(Flags.Flag.DELETED, true);
@ -1680,7 +1679,7 @@ public class ServiceSynchronize extends LifecycleService {
if (message.msgid != null) { if (message.msgid != null) {
Message[] imessages = ifolder.search(new MessageIDTerm(message.msgid)); Message[] imessages = ifolder.search(new MessageIDTerm(message.msgid));
for (Message imessage : imessages) { for (Message imessage : imessages) {
Log.i(Helper.TAG, "Deleting uid=" + message.uid + " msgid=" + message.msgid); Log.i("Deleting uid=" + message.uid + " msgid=" + message.msgid);
imessage.setFlag(Flags.Flag.DELETED, true); imessage.setFlag(Flags.Flag.DELETED, true);
} }
ifolder.expunge(); ifolder.expunge();
@ -1759,7 +1758,7 @@ public class ServiceSynchronize extends LifecycleService {
// Send message // Send message
Address[] to = imessage.getAllRecipients(); Address[] to = imessage.getAllRecipients();
itransport.sendMessage(imessage, to); itransport.sendMessage(imessage, to);
Log.i(Helper.TAG, "Sent via " + ident.host + "/" + ident.user + Log.i("Sent via " + ident.host + "/" + ident.user +
" to " + TextUtils.join(", ", to)); " to " + TextUtils.join(", ", to));
try { try {
@ -1786,7 +1785,7 @@ public class ServiceSynchronize extends LifecycleService {
message.folder = sent.id; message.folder = sent.id;
message.uid = null; message.uid = null;
db.message().updateMessage(message); db.message().updateMessage(message);
Log.i(Helper.TAG, "Appending sent msgid=" + message.msgid); Log.i("Appending sent msgid=" + message.msgid);
EntityOperation.queue(db, message, EntityOperation.ADD); // Could already exist EntityOperation.queue(db, message, EntityOperation.ADD); // Could already exist
} }
} }
@ -1827,7 +1826,7 @@ public class ServiceSynchronize extends LifecycleService {
long now = new Date().getTime(); long now = new Date().getTime();
long delayed = now - message.last_attempt; long delayed = now - message.last_attempt;
if (delayed > IDENTITY_ERROR_AFTER * 60 * 1000L) { if (delayed > IDENTITY_ERROR_AFTER * 60 * 1000L) {
Log.i(Helper.TAG, "Reporting send error after=" + delayed); Log.i("Reporting send error after=" + delayed);
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify("send", message.identity.intValue(), getNotificationError(ident.name, ex).build()); nm.notify("send", message.identity.intValue(), getNotificationError(ident.name, ex).build());
} }
@ -1904,7 +1903,7 @@ public class ServiceSynchronize extends LifecycleService {
try { try {
db.beginTransaction(); db.beginTransaction();
Log.v(Helper.TAG, "Start sync folders account=" + account.name); Log.i("Start sync folders account=" + account.name);
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
for (EntityFolder folder : db.folder().getFolders(account.id)) { for (EntityFolder folder : db.folder().getFolders(account.id)) {
@ -1923,12 +1922,12 @@ public class ServiceSynchronize extends LifecycleService {
db.folder().deleteFolder(folder.id); db.folder().deleteFolder(folder.id);
} }
} }
Log.i(Helper.TAG, "Local folder count=" + names.size()); Log.i("Local folder count=" + names.size());
Folder defaultFolder = istore.getDefaultFolder(); Folder defaultFolder = istore.getDefaultFolder();
char separator = defaultFolder.getSeparator(); char separator = defaultFolder.getSeparator();
Folder[] ifolders = defaultFolder.list("*"); Folder[] ifolders = defaultFolder.list("*");
Log.i(Helper.TAG, "Remote folder count=" + ifolders.length + " separator=" + separator); Log.i("Remote folder count=" + ifolders.length + " separator=" + separator);
for (Folder ifolder : ifolders) { for (Folder ifolder : ifolders) {
String fullName = ifolder.getFullName(); String fullName = ifolder.getFullName();
@ -1936,7 +1935,7 @@ public class ServiceSynchronize extends LifecycleService {
String type = null; String type = null;
boolean selectable = true; boolean selectable = true;
String[] attrs = ((IMAPFolder) ifolder).getAttributes(); String[] attrs = ((IMAPFolder) ifolder).getAttributes();
Log.i(Helper.TAG, account.name + ":" + fullName + Log.i(account.name + ":" + fullName +
" attrs=" + TextUtils.join(" ", attrs)); " attrs=" + TextUtils.join(" ", attrs));
for (String attr : attrs) { for (String attr : attrs) {
if ("\\Noselect".equals(attr) || "\\NonExistent".equals(attr)) if ("\\Noselect".equals(attr) || "\\NonExistent".equals(attr))
@ -1976,9 +1975,9 @@ public class ServiceSynchronize extends LifecycleService {
folder.sync_days = EntityFolder.DEFAULT_SYNC; folder.sync_days = EntityFolder.DEFAULT_SYNC;
folder.keep_days = EntityFolder.DEFAULT_KEEP; folder.keep_days = EntityFolder.DEFAULT_KEEP;
db.folder().insertFolder(folder); db.folder().insertFolder(folder);
Log.i(Helper.TAG, folder.name + " added"); Log.i(folder.name + " added");
} else { } else {
Log.i(Helper.TAG, folder.name + " exists"); Log.i(folder.name + " exists");
if (folder.display == null) { if (folder.display == null) {
if (display != null) if (display != null)
@ -1999,16 +1998,16 @@ public class ServiceSynchronize extends LifecycleService {
} }
} }
Log.i(Helper.TAG, "Delete local count=" + names.size()); Log.i("Delete local count=" + names.size());
for (String name : names) { for (String name : names) {
Log.i(Helper.TAG, name + " delete"); Log.i(name + " delete");
db.folder().deleteFolder(account.id, name); db.folder().deleteFolder(account.id, name);
} }
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();
Log.v(Helper.TAG, "End sync folder"); Log.i("End sync folder");
} }
} }
@ -2018,7 +2017,7 @@ public class ServiceSynchronize extends LifecycleService {
int sync_days = jargs.getInt(0); int sync_days = jargs.getInt(0);
int keep_days = jargs.getInt(1); int keep_days = jargs.getInt(1);
Log.v(Helper.TAG, folder.name + " start sync after=" + sync_days + "/" + keep_days); Log.i(folder.name + " start sync after=" + sync_days + "/" + keep_days);
db.folder().setFolderSyncState(folder.id, "syncing"); db.folder().setFolderSyncState(folder.id, "syncing");
@ -2045,15 +2044,15 @@ public class ServiceSynchronize extends LifecycleService {
if (keep_time < 0) if (keep_time < 0)
keep_time = 0; keep_time = 0;
Log.i(Helper.TAG, folder.name + " sync=" + new Date(sync_time) + " keep=" + new Date(keep_time)); Log.i(folder.name + " sync=" + new Date(sync_time) + " keep=" + new Date(keep_time));
// Delete old local messages // Delete old local messages
int old = db.message().deleteMessagesBefore(folder.id, keep_time, false); int old = db.message().deleteMessagesBefore(folder.id, keep_time, false);
Log.i(Helper.TAG, folder.name + " local old=" + old); Log.i(folder.name + " local old=" + old);
// Get list of local uids // Get list of local uids
List<Long> uids = db.message().getUids(folder.id, sync_time); List<Long> uids = db.message().getUids(folder.id, sync_time);
Log.i(Helper.TAG, folder.name + " local count=" + uids.size()); Log.i(folder.name + " local count=" + uids.size());
// Reduce list of local uids // Reduce list of local uids
long search = SystemClock.elapsedRealtime(); long search = SystemClock.elapsedRealtime();
@ -2063,7 +2062,7 @@ public class ServiceSynchronize extends LifecycleService {
new FlagTerm(new Flags(Flags.Flag.FLAGGED), true) new FlagTerm(new Flags(Flags.Flag.FLAGGED), true)
) )
); );
Log.i(Helper.TAG, folder.name + " remote count=" + imessages.length + Log.i(folder.name + " remote count=" + imessages.length +
" search=" + (SystemClock.elapsedRealtime() - search) + " ms"); " search=" + (SystemClock.elapsedRealtime() - search) + " ms");
FetchProfile fp = new FetchProfile(); FetchProfile fp = new FetchProfile();
@ -2072,24 +2071,24 @@ public class ServiceSynchronize extends LifecycleService {
ifolder.fetch(imessages, fp); ifolder.fetch(imessages, fp);
long fetch = SystemClock.elapsedRealtime(); long fetch = SystemClock.elapsedRealtime();
Log.i(Helper.TAG, folder.name + " remote fetched=" + (SystemClock.elapsedRealtime() - fetch) + " ms"); Log.i(folder.name + " remote fetched=" + (SystemClock.elapsedRealtime() - fetch) + " ms");
for (int i = 0; i < imessages.length && state.running(); i++) for (int i = 0; i < imessages.length && state.running(); i++)
try { try {
uids.remove(ifolder.getUID(imessages[i])); uids.remove(ifolder.getUID(imessages[i]));
} catch (MessageRemovedException ex) { } catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
reportError(account, folder, ex); reportError(account, folder, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} }
// Delete local messages not at remote // Delete local messages not at remote
Log.i(Helper.TAG, folder.name + " delete=" + uids.size()); Log.i(folder.name + " delete=" + uids.size());
for (Long uid : uids) { for (Long uid : uids) {
int count = db.message().deleteMessage(folder.id, uid); int count = db.message().deleteMessage(folder.id, uid);
Log.i(Helper.TAG, folder.name + " delete local uid=" + uid + " count=" + count); Log.i(folder.name + " delete local uid=" + uid + " count=" + count);
} }
fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.ENVELOPE);
@ -2103,7 +2102,7 @@ public class ServiceSynchronize extends LifecycleService {
// Add/update local messages // Add/update local messages
Long[] ids = new Long[imessages.length]; Long[] ids = new Long[imessages.length];
Log.i(Helper.TAG, folder.name + " add=" + imessages.length); Log.i(folder.name + " add=" + imessages.length);
for (int i = imessages.length - 1; i >= 0 && state.running(); i -= SYNC_BATCH_SIZE) { for (int i = imessages.length - 1; i >= 0 && state.running(); i -= SYNC_BATCH_SIZE) {
int from = Math.max(0, i - SYNC_BATCH_SIZE + 1); int from = Math.max(0, i - SYNC_BATCH_SIZE + 1);
Message[] isub = Arrays.copyOfRange(imessages, from, i + 1); Message[] isub = Arrays.copyOfRange(imessages, from, i + 1);
@ -2119,7 +2118,7 @@ public class ServiceSynchronize extends LifecycleService {
if (full.size() > 0) { if (full.size() > 0) {
long headers = SystemClock.elapsedRealtime(); long headers = SystemClock.elapsedRealtime();
ifolder.fetch(full.toArray(new Message[0]), fp); ifolder.fetch(full.toArray(new Message[0]), fp);
Log.i(Helper.TAG, folder.name + " fetched headers=" + full.size() + Log.i(folder.name + " fetched headers=" + full.size() +
" " + (SystemClock.elapsedRealtime() - headers) + " ms"); " " + (SystemClock.elapsedRealtime() - headers) + " ms");
} }
@ -2132,18 +2131,18 @@ public class ServiceSynchronize extends LifecycleService {
ids[from + j] = message.id; ids[from + j] = message.id;
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} catch (MessageRemovedException ex) { } catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
} catch (FolderClosedException ex) { } catch (FolderClosedException ex) {
throw ex; throw ex;
} catch (IOException ex) { } catch (IOException ex) {
if (ex.getCause() instanceof MessagingException) { if (ex.getCause() instanceof MessagingException) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name, ex);
if (!(ex.getCause() instanceof MessageRemovedException)) if (!(ex.getCause() instanceof MessageRemovedException))
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} else } else
throw ex; throw ex;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} finally { } finally {
db.endTransaction(); db.endTransaction();
@ -2163,7 +2162,7 @@ public class ServiceSynchronize extends LifecycleService {
//fp.add(IMAPFolder.FetchProfileItem.MESSAGE); //fp.add(IMAPFolder.FetchProfileItem.MESSAGE);
// Download messages/attachments // Download messages/attachments
Log.i(Helper.TAG, folder.name + " download=" + imessages.length); Log.i(folder.name + " download=" + imessages.length);
for (int i = imessages.length - 1; i >= 0 && state.running(); i -= DOWNLOAD_BATCH_SIZE) { for (int i = imessages.length - 1; i >= 0 && state.running(); i -= DOWNLOAD_BATCH_SIZE) {
int from = Math.max(0, i - DOWNLOAD_BATCH_SIZE + 1); int from = Math.max(0, i - DOWNLOAD_BATCH_SIZE + 1);
@ -2181,7 +2180,7 @@ public class ServiceSynchronize extends LifecycleService {
} catch (FolderClosedIOException ex) { } catch (FolderClosedIOException ex) {
throw ex; throw ex;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name, ex);
} finally { } finally {
db.endTransaction(); db.endTransaction();
// Free memory // Free memory
@ -2200,7 +2199,7 @@ public class ServiceSynchronize extends LifecycleService {
db.folder().setFolderError(folder.id, null); db.folder().setFolderError(folder.id, null);
} finally { } finally {
Log.v(Helper.TAG, folder.name + " end sync state=" + state); Log.i(folder.name + " end sync state=" + state);
db.folder().setFolderSyncState(folder.id, null); db.folder().setFolderSyncState(folder.id, null);
} }
} }
@ -2212,11 +2211,11 @@ public class ServiceSynchronize extends LifecycleService {
long uid = ifolder.getUID(imessage); long uid = ifolder.getUID(imessage);
if (imessage.isExpunged()) { if (imessage.isExpunged()) {
Log.i(Helper.TAG, folder.name + " expunged uid=" + uid); Log.i(folder.name + " expunged uid=" + uid);
throw new MessageRemovedException(); throw new MessageRemovedException();
} }
if (imessage.isSet(Flags.Flag.DELETED)) { if (imessage.isSet(Flags.Flag.DELETED)) {
Log.i(Helper.TAG, folder.name + " deleted uid=" + uid); Log.i(folder.name + " deleted uid=" + uid);
throw new MessageRemovedException(); throw new MessageRemovedException();
} }
@ -2237,17 +2236,17 @@ public class ServiceSynchronize extends LifecycleService {
if (message == null) { if (message == null) {
// Will fetch headers within database transaction // Will fetch headers within database transaction
String msgid = helper.getMessageID(); String msgid = helper.getMessageID();
Log.i(Helper.TAG, "Searching for " + msgid); Log.i("Searching for " + msgid);
for (EntityMessage dup : db.message().getMessageByMsgId(folder.account, msgid)) { for (EntityMessage dup : db.message().getMessageByMsgId(folder.account, msgid)) {
EntityFolder dfolder = db.folder().getFolder(dup.folder); EntityFolder dfolder = db.folder().getFolder(dup.folder);
Log.i(Helper.TAG, folder.name + " found as id=" + dup.id + "/" + dup.uid + Log.i(folder.name + " found as id=" + dup.id + "/" + dup.uid +
" folder=" + dfolder.type + ":" + dup.folder + "/" + folder.type + ":" + folder.id + " folder=" + dfolder.type + ":" + dup.folder + "/" + folder.type + ":" + folder.id +
" msgid=" + dup.msgid + " thread=" + dup.thread); " msgid=" + dup.msgid + " thread=" + dup.thread);
if (dup.folder.equals(folder.id) || if (dup.folder.equals(folder.id) ||
(EntityFolder.OUTBOX.equals(dfolder.type) && EntityFolder.SENT.equals(folder.type))) { (EntityFolder.OUTBOX.equals(dfolder.type) && EntityFolder.SENT.equals(folder.type))) {
String thread = helper.getThreadId(uid); String thread = helper.getThreadId(uid);
Log.i(Helper.TAG, folder.name + " found as id=" + dup.id + "/" + Log.i(folder.name + " found as id=" + dup.id + "/" +
" uid=" + dup.uid + "/" + uid + " uid=" + dup.uid + "/" + uid +
" msgid=" + msgid + " thread=" + thread); " msgid=" + msgid + " thread=" + thread);
dup.folder = folder.id; // outbox to sent dup.folder = folder.id; // outbox to sent
@ -2256,16 +2255,16 @@ public class ServiceSynchronize extends LifecycleService {
dup.uid = uid; dup.uid = uid;
else if (dup.uid != uid) { else if (dup.uid != uid) {
if (EntityFolder.DRAFTS.equals(folder.type)) { if (EntityFolder.DRAFTS.equals(folder.type)) {
Log.i(Helper.TAG, "Deleting previous uid=" + dup.uid); Log.i("Deleting previous uid=" + dup.uid);
Message iprev = ifolder.getMessageByUID(dup.uid); Message iprev = ifolder.getMessageByUID(dup.uid);
if (iprev == null) if (iprev == null)
Log.w(Helper.TAG, "Previous not found uid=" + dup.uid); Log.w("Previous not found uid=" + dup.uid);
else { else {
iprev.setFlag(Flags.Flag.DELETED, true); iprev.setFlag(Flags.Flag.DELETED, true);
ifolder.expunge(); ifolder.expunge();
} }
} else // Draft in Gmail archive } else // Draft in Gmail archive
Log.e(Helper.TAG, "Changed uid=" + dup.uid + "/" + uid); Log.e("Changed uid=" + dup.uid + "/" + uid);
dup.uid = uid; dup.uid = uid;
} }
@ -2325,7 +2324,7 @@ public class ServiceSynchronize extends LifecycleService {
message.msgid = helper.getMessageID(); message.msgid = helper.getMessageID();
if (TextUtils.isEmpty(message.msgid)) if (TextUtils.isEmpty(message.msgid))
Log.w(Helper.TAG, "No Message-ID id=" + message.id + " uid=" + message.uid); Log.w("No Message-ID id=" + message.id + " uid=" + message.uid);
message.references = TextUtils.join(" ", helper.getReferences()); message.references = TextUtils.join(" ", helper.getReferences());
message.inreplyto = helper.getInReplyTo(); message.inreplyto = helper.getInReplyTo();
@ -2355,15 +2354,15 @@ public class ServiceSynchronize extends LifecycleService {
message.id = db.message().insertMessage(message); message.id = db.message().insertMessage(message);
Log.i(Helper.TAG, folder.name + " added id=" + message.id + " uid=" + message.uid); Log.i(folder.name + " added id=" + message.id + " uid=" + message.uid);
int sequence = 1; int sequence = 1;
for (EntityAttachment attachment : helper.getAttachments()) { for (EntityAttachment attachment : helper.getAttachments()) {
Log.i(Helper.TAG, folder.name + " attachment seq=" + sequence + Log.i(folder.name + " attachment seq=" + sequence +
" name=" + attachment.name + " type=" + attachment.type + " cid=" + attachment.cid); " name=" + attachment.name + " type=" + attachment.type + " cid=" + attachment.cid);
if (!TextUtils.isEmpty(attachment.cid) && if (!TextUtils.isEmpty(attachment.cid) &&
db.attachment().getAttachment(message.id, attachment.cid) != null) { db.attachment().getAttachment(message.id, attachment.cid) != null) {
Log.i(Helper.TAG, "Skipping duplicated CID"); Log.i("Skipping duplicated CID");
continue; continue;
} }
attachment.message = message.id; attachment.message = message.id;
@ -2377,34 +2376,34 @@ public class ServiceSynchronize extends LifecycleService {
update = true; update = true;
message.seen = seen; message.seen = seen;
message.ui_seen = seen; message.ui_seen = seen;
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " seen=" + seen); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " seen=" + seen);
} }
if (!message.answered.equals(answered) || !message.answered.equals(message.ui_answered)) { if (!message.answered.equals(answered) || !message.answered.equals(message.ui_answered)) {
update = true; update = true;
message.answered = answered; message.answered = answered;
message.ui_answered = answered; message.ui_answered = answered;
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " answered=" + answered); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " answered=" + answered);
} }
if (!message.flagged.equals(flagged) || !message.flagged.equals(message.ui_flagged)) { if (!message.flagged.equals(flagged) || !message.flagged.equals(message.ui_flagged)) {
update = true; update = true;
message.flagged = flagged; message.flagged = flagged;
message.ui_flagged = flagged; message.ui_flagged = flagged;
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " flagged=" + flagged); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " flagged=" + flagged);
} }
if (!Helper.equal(message.keywords, keywords)) { if (!Helper.equal(message.keywords, keywords)) {
update = true; update = true;
message.keywords = keywords; message.keywords = keywords;
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid +
" keywords=" + TextUtils.join(" ", keywords)); " keywords=" + TextUtils.join(" ", keywords));
} }
if (message.ui_hide && full) { if (message.ui_hide && full) {
update = true; update = true;
message.ui_hide = false; message.ui_hide = false;
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide"); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide");
} }
if (update) if (update)
@ -2415,7 +2414,7 @@ public class ServiceSynchronize extends LifecycleService {
for (String keyword : keywords) for (String keyword : keywords)
if (!fkeywords.contains(keyword)) { if (!fkeywords.contains(keyword)) {
Log.i(Helper.TAG, folder.name + " adding keyword=" + keyword); Log.i(folder.name + " adding keyword=" + keyword);
fkeywords.add(keyword); fkeywords.add(keyword);
} }
@ -2461,7 +2460,7 @@ public class ServiceSynchronize extends LifecycleService {
} }
if (fetch) { if (fetch) {
Log.i(Helper.TAG, folder.name + " fetching message id=" + message.id); Log.i(folder.name + " fetching message id=" + message.id);
FetchProfile fp = new FetchProfile(); FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.FLAGS); fp.add(FetchProfile.Item.FLAGS);
@ -2481,7 +2480,7 @@ public class ServiceSynchronize extends LifecycleService {
String preview = (text == null ? null : text.substring(0, Math.min(text.length(), PREVIEW_SIZE))); String preview = (text == null ? null : text.substring(0, Math.min(text.length(), PREVIEW_SIZE)));
message.write(context, html); message.write(context, html);
db.message().setMessageContent(message.id, true, preview); db.message().setMessageContent(message.id, true, preview);
Log.i(Helper.TAG, folder.name + " downloaded message id=" + message.id + " size=" + message.size); Log.i(folder.name + " downloaded message id=" + message.id + " size=" + message.size);
} }
List<EntityAttachment> iattachments = null; List<EntityAttachment> iattachments = null;
@ -2495,7 +2494,7 @@ public class ServiceSynchronize extends LifecycleService {
if (i < iattachments.size()) { if (i < iattachments.size()) {
attachment.part = iattachments.get(i).part; attachment.part = iattachments.get(i).part;
attachment.download(context, db); attachment.download(context, db);
Log.i(Helper.TAG, folder.name + " downloaded message id=" + message.id + " attachment=" + attachment.name + " size=" + message.size); Log.i(folder.name + " downloaded message id=" + message.id + " attachment=" + attachment.name + " size=" + message.size);
} }
} }
} }
@ -2518,7 +2517,7 @@ public class ServiceSynchronize extends LifecycleService {
queue_reload(true, "connect " + network); queue_reload(true, "connect " + network);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }
@ -2531,7 +2530,7 @@ public class ServiceSynchronize extends LifecycleService {
if (!started && suitableNetwork()) if (!started && suitableNetwork())
queue_reload(true, "connect " + network); queue_reload(true, "connect " + network);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }
@ -2545,7 +2544,7 @@ public class ServiceSynchronize extends LifecycleService {
queue_reload(false, "disconnect " + network); queue_reload(false, "disconnect " + network);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
} }
@ -2603,7 +2602,7 @@ public class ServiceSynchronize extends LifecycleService {
if (state.acquire(backoff)) if (state.acquire(backoff))
return; return;
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.w(Helper.TAG, "main backoff " + ex.toString()); Log.w("main backoff " + ex.toString());
} }
// Start monitoring outbox // Start monitoring outbox
@ -2617,7 +2616,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void handleMessage(android.os.Message msg) { public void handleMessage(android.os.Message msg) {
Log.i(Helper.TAG, outbox.name + " observe=" + msg.what); Log.i(outbox.name + " observe=" + msg.what);
if (msg.what == 0) if (msg.what == 0)
liveOperations.removeObserver(observer); liveOperations.removeObserver(observer);
else { else {
@ -2645,19 +2644,19 @@ public class ServiceSynchronize extends LifecycleService {
handling = current; handling = current;
if (handling.size() > 0 && process) { if (handling.size() > 0 && process) {
Log.i(Helper.TAG, outbox.name + " operations=" + operations.size()); Log.i(outbox.name + " operations=" + operations.size());
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
wl.acquire(); wl.acquire();
Log.i(Helper.TAG, outbox.name + " process"); Log.i(outbox.name + " process");
db.folder().setFolderSyncState(outbox.id, "syncing"); db.folder().setFolderSyncState(outbox.id, "syncing");
processOperations(null, outbox, null, null, null, state); processOperations(null, outbox, null, null, null, state);
db.folder().setFolderError(outbox.id, null); db.folder().setFolderError(outbox.id, null);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, outbox.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(outbox.name, ex);
reportError(null, outbox, ex); reportError(null, outbox, ex);
db.folder().setFolderError(outbox.id, Helper.formatThrowable(ex)); db.folder().setFolderError(outbox.id, Helper.formatThrowable(ex));
} finally { } finally {
@ -2684,7 +2683,7 @@ public class ServiceSynchronize extends LifecycleService {
else else
account.deleteNotificationChannel(ServiceSynchronize.this); account.deleteNotificationChannel(ServiceSynchronize.this);
Log.i(Helper.TAG, account.host + "/" + account.user + " run"); Log.i(account.host + "/" + account.user + " run");
final ServiceState astate = new ServiceState(); final ServiceState astate = new ServiceState();
astate.runnable(new Runnable() { astate.runnable(new Runnable() {
@Override @Override
@ -2692,7 +2691,7 @@ public class ServiceSynchronize extends LifecycleService {
try { try {
monitorAccount(account, astate); monitorAccount(account, astate);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
EntityLog.log(ServiceSynchronize.this, account.name + " " + Helper.formatThrowable(ex)); EntityLog.log(ServiceSynchronize.this, account.name + " " + Helper.formatThrowable(ex));
db.account().setAccountError(account.id, Helper.formatThrowable(ex)); db.account().setAccountError(account.id, Helper.formatThrowable(ex));
} }
@ -2708,7 +2707,7 @@ public class ServiceSynchronize extends LifecycleService {
wl.release(); wl.release();
state.acquire(); state.acquire();
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.w(Helper.TAG, "main wait " + ex.toString()); Log.w("main wait " + ex.toString());
} finally { } finally {
wl.acquire(); wl.acquire();
} }
@ -2722,7 +2721,7 @@ public class ServiceSynchronize extends LifecycleService {
// Stop monitoring outbox // Stop monitoring outbox
if (outbox != null) { if (outbox != null) {
Log.i(Helper.TAG, outbox.name + " unlisten operations"); Log.i(outbox.name + " unlisten operations");
handler.sendEmptyMessage(0); handler.sendEmptyMessage(0);
db.folder().setFolderState(outbox.id, null); db.folder().setFolderState(outbox.id, null);
} }
@ -2730,7 +2729,7 @@ public class ServiceSynchronize extends LifecycleService {
EntityLog.log(ServiceSynchronize.this, "Main exited"); EntityLog.log(ServiceSynchronize.this, "Main exited");
} catch (Throwable ex) { } catch (Throwable ex) {
// Fail-safe // Fail-safe
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} finally { } finally {
wl.release(); wl.release();
EntityLog.log(ServiceSynchronize.this, "Start wake lock=" + wl.isHeld()); EntityLog.log(ServiceSynchronize.this, "Start wake lock=" + wl.isHeld());
@ -2786,13 +2785,13 @@ public class ServiceSynchronize extends LifecycleService {
int accounts = db.account().deleteAccountsTbd(); int accounts = db.account().deleteAccountsTbd();
int identities = db.identity().deleteIdentitiesTbd(); int identities = db.identity().deleteIdentitiesTbd();
if (accounts > 0 || identities > 0) if (accounts > 0 || identities > 0)
Log.i(Helper.TAG, "Deleted accounts=" + accounts + " identities=" + identities); Log.i("Deleted accounts=" + accounts + " identities=" + identities);
if (doStart) if (doStart)
start(); start();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} finally { } finally {
queued--; queued--;
EntityLog.log(ServiceSynchronize.this, "Reload done queued=" + queued); EntityLog.log(ServiceSynchronize.this, "Reload done queued=" + queued);
@ -2892,12 +2891,12 @@ public class ServiceSynchronize extends LifecycleService {
boolean joined = false; boolean joined = false;
while (!joined) while (!joined)
try { try {
Log.i(Helper.TAG, "Joining " + thread.getName()); Log.i("Joining " + thread.getName());
thread.join(); thread.join();
joined = true; joined = true;
Log.i(Helper.TAG, "Joined " + thread.getName()); Log.i("Joined " + thread.getName());
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.w(Helper.TAG, thread.getName() + " join " + ex.toString()); Log.w(thread.getName() + " join " + ex.toString());
} }
} }

@ -26,12 +26,11 @@ import android.os.Build;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.service.quicksettings.Tile; import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService; import android.service.quicksettings.TileService;
import android.util.Log;
@TargetApi(Build.VERSION_CODES.N) @TargetApi(Build.VERSION_CODES.N)
public class ServiceTileSynchronize extends TileService implements SharedPreferences.OnSharedPreferenceChangeListener { public class ServiceTileSynchronize extends TileService implements SharedPreferences.OnSharedPreferenceChangeListener {
public void onStartListening() { public void onStartListening() {
Log.i(Helper.TAG, "Start tile synchronize"); Log.i("Start tile synchronize");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
update(); update();
@ -46,7 +45,7 @@ public class ServiceTileSynchronize extends TileService implements SharedPrefere
private void update() { private void update() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean enabled = prefs.getBoolean("enabled", false); boolean enabled = prefs.getBoolean("enabled", false);
Log.i(Helper.TAG, "Update tile synchronize=" + enabled); Log.i("Update tile synchronize=" + enabled);
Tile tile = getQsTile(); Tile tile = getQsTile();
if (tile != null) { if (tile != null) {
@ -58,13 +57,13 @@ public class ServiceTileSynchronize extends TileService implements SharedPrefere
} }
public void onStopListening() { public void onStopListening() {
Log.i(Helper.TAG, "Stop tile synchronize"); Log.i("Stop tile synchronize");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.unregisterOnSharedPreferenceChangeListener(this); prefs.unregisterOnSharedPreferenceChangeListener(this);
} }
public void onClick() { public void onClick() {
Log.i(Helper.TAG, "Click tile synchronize"); Log.i("Click tile synchronize");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean enabled = !prefs.getBoolean("enabled", false); boolean enabled = !prefs.getBoolean("enabled", false);

@ -26,7 +26,6 @@ import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.service.quicksettings.Tile; import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService; import android.service.quicksettings.TileService;
import android.util.Log;
import java.util.List; import java.util.List;
@ -64,12 +63,12 @@ public class ServiceTileUnseen extends TileService {
} }
public void onStartListening() { public void onStartListening() {
Log.i(Helper.TAG, "Start tile unseen"); Log.i("Start tile unseen");
liveMessages = DB.getInstance(this).message().liveUnseenNotify(); liveMessages = DB.getInstance(this).message().liveUnseenNotify();
liveMessages.observe(owner, new Observer<List<TupleMessageEx>>() { liveMessages.observe(owner, new Observer<List<TupleMessageEx>>() {
@Override @Override
public void onChanged(List<TupleMessageEx> messages) { public void onChanged(List<TupleMessageEx> messages) {
Log.i(Helper.TAG, "Update tile unseen=" + messages.size()); Log.i("Update tile unseen=" + messages.size());
Tile tile = getQsTile(); Tile tile = getQsTile();
if (tile != null) { if (tile != null) {
@ -85,7 +84,7 @@ public class ServiceTileUnseen extends TileService {
} }
public void onStopListening() { public void onStopListening() {
Log.i(Helper.TAG, "Stop tile unseen"); Log.i("Stop tile unseen");
if (liveMessages != null) { if (liveMessages != null) {
liveMessages.removeObservers(owner); liveMessages.removeObservers(owner);
liveMessages = null; liveMessages = null;
@ -93,7 +92,7 @@ public class ServiceTileUnseen extends TileService {
} }
public void onClick() { public void onClick() {
Log.i(Helper.TAG, "Click tile unseen"); Log.i("Click tile unseen");
Intent clear = new Intent(this, ServiceSynchronize.class); Intent clear = new Intent(this, ServiceSynchronize.class);
clear.setAction("clear"); clear.setAction("clear");

@ -22,7 +22,6 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.util.Log;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -65,26 +64,26 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
try { try {
run(fragment.getContext(), fragment.getViewLifecycleOwner(), args); run(fragment.getContext(), fragment.getViewLifecycleOwner(), args);
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.w(ex);
} }
} }
@OnLifecycleEvent(Lifecycle.Event.ON_START) @OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() { public void onStart() {
Log.i(Helper.TAG, "Start task " + this); Log.i("Start task " + this);
} }
@OnLifecycleEvent(Lifecycle.Event.ON_STOP) @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onStop() { public void onStop() {
Log.i(Helper.TAG, "Stop task " + this); Log.i("Stop task " + this);
} }
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() { public void onResume() {
Log.i(Helper.TAG, "Resume task " + this); Log.i("Resume task " + this);
paused = false; paused = false;
if (stored != null) { if (stored != null) {
Log.i(Helper.TAG, "Deferred delivery task " + this); Log.i("Deferred delivery task " + this);
deliver(args, stored); deliver(args, stored);
stored = null; stored = null;
} }
@ -92,18 +91,18 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
public void onPause() { public void onPause() {
Log.i(Helper.TAG, "Pause task " + this); Log.i("Pause task " + this);
paused = true; paused = true;
} }
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE) @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
public void onCreated() { public void onCreated() {
Log.i(Helper.TAG, "Created task " + this); Log.i("Created task " + this);
} }
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() { public void onDestroyed() {
Log.i(Helper.TAG, "Destroy task " + this); Log.i("Destroy task " + this);
owner.getLifecycle().removeObserver(this); owner.getLifecycle().removeObserver(this);
owner = null; owner = null;
paused = true; paused = true;
@ -120,7 +119,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
try { try {
onInit(args); onInit(args);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
owner.getLifecycle().addObserver(this); owner.getLifecycle().addObserver(this);
@ -136,7 +135,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
try { try {
result.data = onLoad(context, args); result.data = onLoad(context, args);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
result.ex = ex; result.ex = ex;
} }
@ -153,23 +152,23 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
private void deliver(Bundle args, Result result) { private void deliver(Bundle args, Result result) {
if (paused) { if (paused) {
Log.i(Helper.TAG, "Deferring delivery task " + this); Log.i("Deferring delivery task " + this);
this.args = args; this.args = args;
this.stored = result; this.stored = result;
} else { } else {
Log.i(Helper.TAG, "Delivery task " + this); Log.i("Delivery task " + this);
try { try {
if (result.ex == null) if (result.ex == null)
onLoaded(args, (T) result.data); onLoaded(args, (T) result.data);
else else
onException(args, result.ex); onException(args, result.ex);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} finally { } finally {
try { try {
onCleanup(args); onCleanup(args);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
onDestroyed(); onDestroyed();
} }

@ -20,7 +20,6 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.util.Log;
import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.IMAPMessage; import com.sun.mail.imap.IMAPMessage;
@ -111,7 +110,7 @@ public class ViewModelBrowse extends ViewModel {
try { try {
body = message.read(state.context); body = message.read(state.context);
} catch (IOException ex) { } catch (IOException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(ex);
} }
if (message.from != null) if (message.from != null)
@ -151,15 +150,15 @@ public class ViewModelBrowse extends ViewModel {
props.setProperty("mail.imap.throwsearchexception", "true"); props.setProperty("mail.imap.throwsearchexception", "true");
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
Log.i(Helper.TAG, "Boundary connecting account=" + account.name); Log.i("Boundary connecting account=" + account.name);
state.istore = (IMAPStore) isession.getStore(account.starttls ? "imap" : "imaps"); state.istore = (IMAPStore) isession.getStore(account.starttls ? "imap" : "imaps");
Helper.connect(state.context, state.istore, account); Helper.connect(state.context, state.istore, account);
Log.i(Helper.TAG, "Boundary opening folder=" + folder.name); Log.i("Boundary opening folder=" + folder.name);
state.ifolder = (IMAPFolder) state.istore.getFolder(folder.name); state.ifolder = (IMAPFolder) state.istore.getFolder(folder.name);
state.ifolder.open(Folder.READ_WRITE); state.ifolder.open(Folder.READ_WRITE);
Log.i(Helper.TAG, "Boundary searching=" + state.search); Log.i("Boundary searching=" + state.search);
if (state.search == null) if (state.search == null)
state.imessages = state.ifolder.getMessages(); state.imessages = state.ifolder.getMessages();
else else
@ -178,14 +177,14 @@ public class ViewModelBrowse extends ViewModel {
new FlagTerm(new Flags(Helper.sanitizeKeyword(state.search)), true) new FlagTerm(new Flags(Helper.sanitizeKeyword(state.search)), true)
) )
); );
Log.i(Helper.TAG, "Boundary found messages=" + state.imessages.length); Log.i("Boundary found messages=" + state.imessages.length);
state.index = state.imessages.length - 1; state.index = state.imessages.length - 1;
} catch (Throwable ex) { } catch (Throwable ex) {
if (ex instanceof FolderClosedException) if (ex instanceof FolderClosedException)
Log.w(Helper.TAG, "Search " + ex + "\n" + Log.getStackTraceString(ex)); Log.w("Search", ex);
else { else {
Log.e(Helper.TAG, "Search " + ex + "\n" + Log.getStackTraceString(ex)); Log.e("Search", ex);
throw ex; throw ex;
} }
} }
@ -193,7 +192,7 @@ public class ViewModelBrowse extends ViewModel {
int count = 0; int count = 0;
while (state.index >= 0 && count < state.pageSize && currentState != null) { while (state.index >= 0 && count < state.pageSize && currentState != null) {
Log.i(Helper.TAG, "Boundary index=" + state.index); Log.i("Boundary index=" + state.index);
int from = Math.max(0, state.index - (state.pageSize - count) + 1); int from = Math.max(0, state.index - (state.pageSize - count) + 1);
Message[] isub = Arrays.copyOfRange(state.imessages, from, state.index + 1); Message[] isub = Arrays.copyOfRange(state.imessages, from, state.index + 1);
state.index -= (state.pageSize - count); state.index -= (state.pageSize - count);
@ -214,7 +213,7 @@ public class ViewModelBrowse extends ViewModel {
for (int j = isub.length - 1; j >= 0; j--) for (int j = isub.length - 1; j >= 0; j--)
try { try {
long uid = state.ifolder.getUID(isub[j]); long uid = state.ifolder.getUID(isub[j]);
Log.i(Helper.TAG, "Boundary sync uid=" + uid); Log.i("Boundary sync uid=" + uid);
EntityMessage message = db.message().getMessageByUid(state.fid, uid); EntityMessage message = db.message().getMessageByUid(state.fid, uid);
if (message == null) { if (message == null) {
message = ServiceSynchronize.synchronizeMessage( message = ServiceSynchronize.synchronizeMessage(
@ -224,18 +223,18 @@ public class ViewModelBrowse extends ViewModel {
} }
db.message().setMessageFound(message.account, message.thread); db.message().setMessageFound(message.account, message.thread);
} catch (MessageRemovedException ex) { } catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " boundary " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name + " boundary", ex);
} catch (FolderClosedException ex) { } catch (FolderClosedException ex) {
throw ex; throw ex;
} catch (IOException ex) { } catch (IOException ex) {
if (ex.getCause() instanceof MessagingException) { if (ex.getCause() instanceof MessagingException) {
Log.w(Helper.TAG, folder.name + " boundary " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(folder.name + " boundary", ex);
if (!(ex.getCause() instanceof MessageRemovedException)) if (!(ex.getCause() instanceof MessageRemovedException))
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} else } else
throw ex; throw ex;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " boundary " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(folder.name + " boundary", ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} finally { } finally {
((IMAPMessage) isub[j]).invalidateHeaders(); ((IMAPMessage) isub[j]).invalidateHeaders();
@ -247,7 +246,7 @@ public class ViewModelBrowse extends ViewModel {
} }
} }
Log.i(Helper.TAG, "Boundary done"); Log.i("Boundary done");
} }
void clear() { void clear() {
@ -256,12 +255,12 @@ public class ViewModelBrowse extends ViewModel {
return; return;
currentState = null; currentState = null;
Log.i(Helper.TAG, "Boundary clear"); Log.i("Boundary clear");
try { try {
if (state.istore != null) if (state.istore != null)
state.istore.close(); state.istore.close();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex)); Log.e("Boundary", ex);
} finally { } finally {
state.context = null; state.context = null;
state.messages = null; state.messages = null;

Loading…
Cancel
Save