From 22c65f2ab823b275f498b8b2cb4b6732f628fe37 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 20 Jan 2018 02:12:43 +0100 Subject: [PATCH] Use Timber instead of Android.Log --- OpenKeychain/build.gradle | 2 + .../v4/widget/FlingNestedScrollView.java | 13 +- .../keychain/KeychainApplication.java | 9 +- .../compatibility/ClipboardReflection.java | 6 +- .../keychain/keyimport/CloudSearch.java | 5 +- .../keyimport/FacebookKeyserverClient.java | 18 +- .../keyimport/HkpKeyserverClient.java | 29 ++-- .../keyimport/KeybaseKeyserverClient.java | 5 +- .../processing/ImportKeysListCloudLoader.java | 9 +- .../processing/ImportKeysListLoader.java | 7 +- .../keychain/linked/LinkedTokenResource.java | 19 +-- .../keychain/linked/UriAttribute.java | 5 +- .../linked/resources/GithubResource.java | 9 +- .../linked/resources/TwitterResource.java | 7 +- .../network/KeyTransferInteractor.java | 17 +- .../keychain/network/NetworkReceiver.java | 8 +- .../keychain/network/SktUri.java | 5 +- .../network/TlsCertificatePinning.java | 9 +- .../keychain/network/orbot/OrbotHelper.java | 14 +- .../network/orbot/OrbotStatusReceiver.java | 10 +- .../keychain/operations/BackupOperation.java | 5 +- .../operations/BenchmarkOperation.java | 4 +- .../keychain/operations/ImportOperation.java | 18 +- .../keychain/operations/RevokeOperation.java | 6 +- .../keychain/operations/UploadOperation.java | 9 +- .../operations/results/OperationResult.java | 9 +- .../keychain/pgp/CanonicalizedPublicKey.java | 21 ++- .../keychain/pgp/CanonicalizedSecretKey.java | 15 +- .../pgp/CanonicalizedSecretKeyRing.java | 16 +- .../pgp/OpenPgpDecryptionResultBuilder.java | 10 +- .../pgp/OpenPgpSignatureResultBuilder.java | 22 +-- .../keychain/pgp/PgpCertifyOperation.java | 7 +- .../pgp/PgpDecryptVerifyOperation.java | 33 ++-- .../keychain/pgp/PgpHelper.java | 14 +- .../keychain/pgp/PgpKeyOperation.java | 15 +- .../keychain/pgp/PgpSignEncryptOperation.java | 13 +- .../keychain/pgp/PgpSignatureChecker.java | 6 +- .../keychain/pgp/UncachedKeyRing.java | 8 +- .../keychain/pgp/UncachedPublicKey.java | 19 ++- .../keychain/pgp/WrappedSignature.java | 8 +- .../provider/CachedPublicKeyRing.java | 6 +- .../keychain/provider/KeyRepository.java | 5 +- .../provider/KeyWritableRepository.java | 16 +- .../keychain/provider/KeychainDatabase.java | 6 +- .../keychain/provider/KeychainProvider.java | 30 ++-- .../provider/TemporaryFileProvider.java | 10 +- .../keychain/remote/ApiPermissionHelper.java | 23 ++- .../remote/CryptoInputParcelCacheService.java | 14 +- .../remote/KeychainExternalProvider.java | 8 +- .../keychain/remote/OpenPgpService.java | 29 ++-- .../keychain/remote/OpenPgpService2.java | 5 +- .../remote/OpenPgpServiceKeyIdExtractor.java | 5 +- .../remote/SshAuthenticationService.java | 3 +- .../remote/ui/AppSettingsActivity.java | 14 +- .../AppSettingsAllowedKeysListFragment.java | 6 +- .../remote/ui/AppSettingsHeaderFragment.java | 5 +- .../keychain/remote/ui/AppsListFragment.java | 8 +- .../remote/ui/RemoteRegisterPresenter.java | 5 +- .../ui/RequestKeyPermissionPresenter.java | 5 +- .../remote/ui/SelectSignKeyIdActivity.java | 12 +- .../ui/SelectSignKeyIdListFragment.java | 8 +- .../ui/dialog/RemoteDeduplicatePresenter.java | 9 +- ...emoteSelectAuthenticationKeyPresenter.java | 9 +- .../securitytoken/CardCapabilities.java | 3 - .../keychain/securitytoken/NfcTransport.java | 8 +- .../SecurityTokenConnection.java | 7 +- .../UsbConnectionDispatcher.java | 6 +- .../SecurityTokenPsoSignTokenOp.java | 6 +- .../securitytoken/usb/CcidTransceiver.java | 21 ++- .../securitytoken/usb/UsbTransport.java | 15 +- .../usb/tpdu/T1TpduProtocol.java | 10 +- .../service/ContactSyncAdapterService.java | 5 +- .../keychain/service/DummyAccountService.java | 18 +- .../keychain/service/KeychainService.java | 10 +- .../service/KeyserverSyncAdapterService.java | 23 +-- .../service/PassphraseCacheService.java | 50 +++--- .../service/ServiceProgressHandler.java | 6 +- .../keychain/ssh/AuthenticationOperation.java | 9 +- .../ui/CertifyFingerprintActivity.java | 8 +- .../ui/CertifyFingerprintFragment.java | 12 +- .../keychain/ui/CertifyKeyFragment.java | 5 +- .../keychain/ui/CreateKeyFinalFragment.java | 4 +- .../keychain/ui/CreateKeyStartFragment.java | 6 +- .../keychain/ui/DecryptFragment.java | 4 +- .../keychain/ui/DecryptListFragment.java | 8 +- .../keychain/ui/DeleteKeyDialogActivity.java | 8 +- .../keychain/ui/EditIdentitiesActivity.java | 6 +- .../keychain/ui/EditIdentitiesFragment.java | 7 +- .../keychain/ui/EditKeyActivity.java | 6 +- .../keychain/ui/EditKeyFragment.java | 8 +- .../keychain/ui/EncryptFilesFragment.java | 5 +- .../ui/EncryptModeAsymmetricFragment.java | 7 +- .../keychain/ui/EncryptTextActivity.java | 6 +- .../keychain/ui/HelpAboutFragment.java | 7 +- .../keychain/ui/HelpMarkdownFragment.java | 5 +- .../keychain/ui/ImportKeysActivity.java | 14 +- .../keychain/ui/ImportKeysFileFragment.java | 5 +- .../keychain/ui/ImportKeysProxyActivity.java | 10 +- .../keychain/ui/KeyListFragment.java | 9 +- .../keychain/ui/MultiUserIdsFragment.java | 9 +- .../ui/OrbotRequiredDialogActivity.java | 6 +- .../keychain/ui/PassphraseDialogActivity.java | 13 +- .../keychain/ui/QrCodeViewActivity.java | 9 +- .../keychain/ui/SafeSlingerActivity.java | 9 +- ...curityTokenChangePinOperationActivity.java | 5 +- .../ui/SecurityTokenOperationActivity.java | 6 +- .../keychain/ui/SettingsActivity.java | 4 +- .../keychain/ui/UploadKeyActivity.java | 5 +- .../keychain/ui/UsbEventReceiverActivity.java | 6 +- .../keychain/ui/ViewCertActivity.java | 8 +- .../keychain/ui/ViewKeyAdvActivity.java | 8 +- .../keychain/ui/ViewKeyAdvCertsFragment.java | 6 +- .../keychain/ui/ViewKeyAdvShareFragment.java | 16 +- .../keychain/ui/ViewKeyAdvStartFragment.java | 5 +- .../ui/ViewKeyAdvSubkeysFragment.java | 6 +- .../ui/ViewKeyAdvUserIdsFragment.java | 8 +- .../keychain/ui/ViewKeyKeybaseFragment.java | 5 +- .../ui/adapter/ImportKeysAdapter.java | 10 +- .../ui/adapter/KeySectionedListAdapter.java | 7 +- .../ui/adapter/KeySelectableAdapter.java | 2 - .../ui/base/BaseSecurityTokenActivity.java | 13 +- .../ui/base/CryptoOperationHelper.java | 10 +- .../keychain/ui/base/RecyclerFragment.java | 8 +- .../AddEditKeyserverDialogFragment.java | 14 +- ...ddEditSmartPGPAuthorityDialogFragment.java | 7 +- .../ui/dialog/AddEmailDialogFragment.java | 12 +- .../ui/dialog/AddUserIdDialogFragment.java | 12 +- .../ui/dialog/DeleteFileDialogFragment.java | 7 +- .../ui/dialog/EditSubkeyDialogFragment.java | 8 +- .../EditSubkeyExpiryDialogFragment.java | 8 +- .../ui/dialog/EditUserIdDialogFragment.java | 8 +- .../ui/dialog/FidesmoPgpInstallDialog.java | 6 +- .../ui/dialog/OrbotStartDialogFragment.java | 16 +- .../dialog/SetPassphraseDialogFragment.java | 9 +- .../ui/keyview/LinkedIdViewFragment.java | 6 +- .../keychain/ui/keyview/ViewKeyActivity.java | 12 +- .../ui/keyview/loader/IdentityLoader.java | 9 +- .../keyview/loader/KeyserverStatusLoader.java | 3 +- .../ui/keyview/loader/SubkeyStatusLoader.java | 3 +- .../loader/SystemContactInfoLoader.java | 3 +- .../presenter/IdentitiesPresenter.java | 7 +- .../presenter/SystemContactPresenter.java | 5 +- .../linked/LinkedIdCreateGithubFragment.java | 10 +- .../keychain/ui/linked/LinkedIdWizard.java | 8 +- .../ui/token/PublicKeyRetrievalLoader.java | 7 +- .../ui/transfer/loader/SecretKeyLoader.java | 3 +- .../transfer/presenter/TransferPresenter.java | 11 +- .../ui/util/InstallDialogFragmentHelper.java | 17 +- .../keychain/ui/util/QrCodeUtils.java | 5 +- .../ui/util/adapter/CursorAdapter.java | 9 +- .../ui/util/adapter/SectionCursorAdapter.java | 6 +- .../ui/widget/EncryptKeyCompletionView.java | 6 +- .../ui/widget/PasswordStrengthView.java | 3 +- .../util/CloseDatabaseCursorFactory.java | 7 +- .../keychain/util/ContactHelper.java | 44 ++--- .../keychain/util/FileHelper.java | 4 +- .../keychain/util/FileHelperLollipop.java | 8 +- .../sufficientlysecure/keychain/util/Log.java | 161 ------------------ .../keychain/util/PRNGFixes.java | 6 +- .../keychain/util/ParcelableFileCache.java | 17 +- .../keychain/util/Preferences.java | 6 +- 161 files changed, 782 insertions(+), 947 deletions(-) delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Log.java diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index 9dbca8941..4ab516c31 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -88,6 +88,8 @@ dependencies { exclude module: 'recyclerview-v7' } + compile "com.jakewharton.timber:timber:4.5.1" + compile 'org.glassfish:javax.annotation:10.0-b28' provided "com.google.auto.value:auto-value:1.4.1" apt "com.google.auto.value:auto-value:1.4.1" diff --git a/OpenKeychain/src/main/java/android/support/v4/widget/FlingNestedScrollView.java b/OpenKeychain/src/main/java/android/support/v4/widget/FlingNestedScrollView.java index 2f4bd8ba8..5e10b3f02 100644 --- a/OpenKeychain/src/main/java/android/support/v4/widget/FlingNestedScrollView.java +++ b/OpenKeychain/src/main/java/android/support/v4/widget/FlingNestedScrollView.java @@ -16,12 +16,14 @@ package android.support.v4.widget; + +import java.util.ArrayList; + import android.annotation.SuppressLint; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; -import android.os.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; @@ -37,7 +39,6 @@ import android.support.v4.view.accessibility.AccessibilityEventCompat; import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; import android.support.v4.view.accessibility.AccessibilityRecordCompat; import android.util.AttributeSet; -import android.util.Log; import android.util.TypedValue; import android.view.FocusFinder; import android.view.KeyEvent; @@ -49,11 +50,11 @@ import android.view.ViewGroup; import android.view.ViewParent; import android.view.accessibility.AccessibilityEvent; import android.view.animation.AnimationUtils; -import android.view.animation.Interpolator; import android.widget.FrameLayout; import android.widget.ScrollView; -import java.util.ArrayList; +import timber.log.Timber; + /** * Workaround for bug in support lib. From https://code.google.com/p/android/issues/detail?id=177729 @@ -444,7 +445,7 @@ public class FlingNestedScrollView extends FrameLayout implements NestedScrollin if(y != -1) { int pointerIndex = MotionEventCompat.findPointerIndex(ev, y); if(pointerIndex == -1) { - Log.e("FlingNestedScrollView", "Invalid pointerId=" + y + " in onInterceptTouchEvent"); + Timber.e("Invalid pointerId=" + y + " in onInterceptTouchEvent"); } else { int y1 = (int)MotionEventCompat.getY(ev, pointerIndex); int yDiff = Math.abs(y1 - this.mLastMotionY); @@ -521,7 +522,7 @@ public class FlingNestedScrollView extends FrameLayout implements NestedScrollin case 2: int activePointerIndex = MotionEventCompat.findPointerIndex(ev, this.mActivePointerId); if(activePointerIndex == -1) { - Log.e("FlingNestedScrollView", "Invalid pointerId=" + this.mActivePointerId + " in onTouchEvent"); + Timber.e("Invalid pointerId=" + this.mActivePointerId + " in onTouchEvent"); } else { int y = (int)MotionEventCompat.getY(ev, activePointerIndex); int deltaY = this.mLastMotionY - y; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java index 37cdc8f50..8ded1f795 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java @@ -29,7 +29,6 @@ import android.graphics.Bitmap; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; -import android.os.Environment; import android.support.annotation.Nullable; import android.widget.Toast; @@ -39,9 +38,9 @@ import org.sufficientlysecure.keychain.provider.TemporaryFileProvider; import org.sufficientlysecure.keychain.service.ContactSyncAdapterService; import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService; import org.sufficientlysecure.keychain.ui.util.FormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.PRNGFixes; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; public class KeychainApplication extends Application { @@ -72,7 +71,7 @@ public class KeychainApplication extends Application { * LinuxPRNGSecureRandomProvider(), 1) for Android <= SDK 17 */ PRNGFixes.apply(); - Log.d(Constants.TAG, "Bouncy Castle set and PRNG Fixes applied!"); + Timber.d("Bouncy Castle set and PRNG Fixes applied!"); /* if (Constants.DEBUG) { @@ -127,7 +126,7 @@ public class KeychainApplication extends Application { Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE); if (accounts.length == 0) { if (!manager.addAccountExplicitly(account, null, null)) { - Log.d(Constants.TAG, "error when adding account via addAccountExplicitly"); + Timber.d("error when adding account via addAccountExplicitly"); return null; } else { return account; @@ -136,7 +135,7 @@ public class KeychainApplication extends Application { return accounts[0]; } } catch (SecurityException e) { - Log.e(Constants.TAG, "SecurityException when adding the account", e); + Timber.e(e, "SecurityException when adding the account"); Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show(); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java index d26ca1ce8..0911068c5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java @@ -23,8 +23,8 @@ import android.content.ClipboardManager; import android.content.Context; import android.support.annotation.Nullable; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class ClipboardReflection { @@ -37,7 +37,7 @@ public class ClipboardReflection { ClipData clip = clipboard.getPrimaryClip(); if (clip == null || clip.getItemCount() == 0) { - Log.e(Constants.TAG, "No clipboard data!"); + Timber.e("No clipboard data!"); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java index 843dcd6a1..b48ade564 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java @@ -19,10 +19,9 @@ package org.sufficientlysecure.keychain.keyimport; import android.support.annotation.NonNull; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; import java.net.Proxy; import java.util.ArrayList; @@ -98,7 +97,7 @@ public class CloudSearch { if (!problems.isEmpty()) { for (KeyserverClient.CloudSearchFailureException e : problems) { - Log.d(Constants.TAG, "Cloud search exception: " + e.getLocalizedMessage()); + Timber.d("Cloud search exception: " + e.getLocalizedMessage()); } // only throw exception if we didn’t get any results diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/FacebookKeyserverClient.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/FacebookKeyserverClient.java index 2d7ccd868..1ed579685 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/FacebookKeyserverClient.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/FacebookKeyserverClient.java @@ -32,15 +32,15 @@ import android.support.annotation.Nullable; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.network.OkHttpClientFactory; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; import org.sufficientlysecure.keychain.pgp.UncachedPublicKey; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; +import timber.log.Timber; + public class FacebookKeyserverClient implements KeyserverClient { private static final String FB_KEY_URL_FORMAT @@ -69,10 +69,10 @@ public class FacebookKeyserverClient implements KeyserverClient { try { entry.add(getEntry(keyRing, fbUsername)); } catch (UnsupportedOperationException e) { - Log.e(Constants.TAG, "Parsing retrieved Facebook key failed!"); + Timber.e("Parsing retrieved Facebook key failed!"); } } catch (PgpGeneralException | IOException e) { - Log.e(Constants.TAG, "Failed parsing key from Facebook during search", e); + Timber.e(e, "Failed parsing key from Facebook during search"); throw new QueryFailedException("No valid key found on Facebook"); } return entry; @@ -80,7 +80,7 @@ public class FacebookKeyserverClient implements KeyserverClient { @Override public String get(String fbUsername, ParcelableProxy proxy) throws QueryFailedException { - Log.d(Constants.TAG, "FacebookKeyserver get: " + fbUsername + " using Proxy: " + proxy.getProxy()); + Timber.d("FacebookKeyserver get: " + fbUsername + " using Proxy: " + proxy.getProxy()); String data = query(fbUsername, proxy); @@ -98,7 +98,7 @@ public class FacebookKeyserverClient implements KeyserverClient { private String query(String fbUsername, ParcelableProxy proxy) throws QueryFailedException { try { URL url = new URL(String.format(FB_KEY_URL_FORMAT, fbUsername)); - Log.d(Constants.TAG, "fetching from Facebook with: " + url + " proxy: " + proxy.getProxy()); + Timber.d("fetching from Facebook with: " + url + " proxy: " + proxy.getProxy()); /* * For some URLs such as https://www.facebook.com/adithya.abraham/publickey/download @@ -125,7 +125,7 @@ public class FacebookKeyserverClient implements KeyserverClient { } } catch (IOException e) { - Log.e(Constants.TAG, "IOException at Facebook key download", e); + Timber.e(e, "IOException at Facebook key download"); throw new QueryFailedException("Cannot connect to Facebook. " + "Check your Internet connection!" + (proxy.getProxy() == Proxy.NO_PROXY ? "" : " Using proxy " + proxy.getProxy())); @@ -163,7 +163,7 @@ public class FacebookKeyserverClient implements KeyserverClient { try { if (key.isEC()) { // unsupported key format (ECDH or ECDSA) - Log.e(Constants.TAG, "ECDH/ECDSA key - not supported."); + Timber.e("ECDH/ECDSA key - not supported."); throw new UnsupportedOperationException( "ECDH/ECDSA keys not supported yet"); } @@ -172,7 +172,7 @@ public class FacebookKeyserverClient implements KeyserverClient { entry.setAlgorithm(KeyFormattingUtils.getAlgorithmInfo(algorithm, key.getBitStrength(), key.getCurveOid())); } catch (NumberFormatException | NullPointerException e) { - Log.e(Constants.TAG, "Conversion for bit size, algorithm, or creation date failed.", e); + Timber.e(e, "Conversion for bit size, algorithm, or creation date failed."); // can't use this key throw new UnsupportedOperationException( "Conversion for bit size, algorithm, or creation date failed."); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserverClient.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserverClient.java index 4943b28ed..78e63825b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserverClient.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserverClient.java @@ -41,12 +41,13 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.network.OkHttpClientFactory; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; +import timber.log.Timber; + +import static java.util.Locale.ENGLISH; public class HkpKeyserverClient implements KeyserverClient { @@ -148,14 +149,14 @@ public class HkpKeyserverClient implements KeyserverClient { .addQueryParameter("search", query) .build(); - Log.d(Constants.TAG, "Keyserver search: " + url + " using Proxy: " + proxy.getProxy()); + Timber.d("Keyserver search: " + url + " using Proxy: " + proxy.getProxy()); data = query(url, proxy); } catch (URISyntaxException e) { throw new IllegalStateException("Unsupported keyserver URI"); } catch (HttpError e) { if (e.getData() != null) { - Log.d(Constants.TAG, "returned error data: " + e.getData().toLowerCase(Locale.ENGLISH)); + Timber.d("returned error data: " + e.getData().toLowerCase(ENGLISH)); if (e.getData().toLowerCase(Locale.ENGLISH).contains("no keys found")) { // NOTE: This is also a 404 error for some keyservers! @@ -193,7 +194,7 @@ public class HkpKeyserverClient implements KeyserverClient { // set key id only entry.setKeyIdHex("0x" + fingerprintOrKeyId); } else { - Log.e(Constants.TAG, "Wrong length for fingerprint/long key id."); + Timber.e("Wrong length for fingerprint/long key id."); // skip this key continue; } @@ -209,7 +210,7 @@ public class HkpKeyserverClient implements KeyserverClient { calendar.setTimeInMillis(creationDate * 1000); entry.setDate(calendar.getTime()); } catch (NumberFormatException e) { - Log.e(Constants.TAG, "Conversation for bit size, algorithm, or creation date failed.", e); + Timber.e(e, "Conversation for bit size, algorithm, or creation date failed."); // skip this key continue; } @@ -229,7 +230,7 @@ public class HkpKeyserverClient implements KeyserverClient { } entry.setExpired(expired); } catch (NullPointerException e) { - Log.e(Constants.TAG, "Check for revocation or expiry failed.", e); + Timber.e(e, "Check for revocation or expiry failed."); // skip this key continue; } @@ -251,7 +252,7 @@ public class HkpKeyserverClient implements KeyserverClient { } catch (UnsupportedEncodingException ignored) { // will never happen, because "UTF8" is supported } catch (IllegalArgumentException e) { - Log.e(Constants.TAG, "User ID encoding broken", e); + Timber.e(e, "User ID encoding broken"); // skip this user id continue; } @@ -278,13 +279,13 @@ public class HkpKeyserverClient implements KeyserverClient { .addQueryParameter("search", keyIdHex) .build(); - Log.d(Constants.TAG, "Keyserver get: " + url + " using Proxy: " + proxy.getProxy()); + Timber.d("Keyserver get: " + url + " using Proxy: " + proxy.getProxy()); data = query(url, proxy); } catch (URISyntaxException e) { throw new IllegalStateException("Unsupported keyserver URI"); } catch (HttpError httpError) { - Log.d(Constants.TAG, "Failed to get key at HkpKeyserver", httpError); + Timber.d(httpError, "Failed to get key at HkpKeyserver"); if (httpError.getCode() == 404) { throw new KeyserverClient.QueryNotFoundException("not found"); } @@ -324,7 +325,7 @@ public class HkpKeyserverClient implements KeyserverClient { String responseBody = getResponseBodyAsUtf8(response); - Log.d(Constants.TAG, "Adding key with URL: " + url + Timber.d("Adding key with URL: " + url + ", response code: " + response.code() + ", body: " + responseBody); @@ -333,10 +334,10 @@ public class HkpKeyserverClient implements KeyserverClient { } } catch (IOException e) { - Log.e(Constants.TAG, "IOException", e); + Timber.e(e, "IOException"); throw new KeyserverClient.AddKeyException(); } catch (URISyntaxException e) { - Log.e(Constants.TAG, "Unsupported keyserver URI", e); + Timber.e(e, "Unsupported keyserver URI"); throw new KeyserverClient.AddKeyException(); } } @@ -373,7 +374,7 @@ public class HkpKeyserverClient implements KeyserverClient { throw new HttpError(response.code(), responseBody); } } catch (IOException e) { - Log.e(Constants.TAG, "IOException at HkpKeyserver", e); + Timber.e(e, "IOException at HkpKeyserver"); String proxyInfo = proxy.getProxy() == Proxy.NO_PROXY ? "" : " Using proxy " + proxy.getProxy(); Throwable cause = e.getCause(); String causeName = cause != null ? cause.getClass().getSimpleName() : "generic"; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserverClient.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserverClient.java index db8ced393..e0b20b55e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserverClient.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserverClient.java @@ -22,11 +22,10 @@ import com.textuality.keybase.lib.KeybaseQuery; import com.textuality.keybase.lib.Match; import com.textuality.keybase.lib.User; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.network.OkHttpKeybaseClient; import org.sufficientlysecure.keychain.util.ParcelableProxy; +import timber.log.Timber; import java.util.ArrayList; import java.util.List; @@ -60,7 +59,7 @@ public class KeybaseKeyserverClient implements KeyserverClient { results.add(makeEntry(match, query)); } } catch (KeybaseException e) { - Log.e(Constants.TAG, "keybase result parsing error", e); + Timber.e(e, "keybase result parsing error"); throw new QueryFailedException("Unexpected structure in keybase search result: " + e.getMessage()); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/processing/ImportKeysListCloudLoader.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/processing/ImportKeysListCloudLoader.java index 3b18e4d99..25a08ddb8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/processing/ImportKeysListCloudLoader.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/processing/ImportKeysListCloudLoader.java @@ -21,7 +21,6 @@ import android.content.Context; import android.support.annotation.Nullable; import android.support.v4.content.AsyncTaskLoader; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.keyimport.CloudSearch; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.keyimport.KeyserverClient; @@ -31,10 +30,10 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.service.input.RequiredInputParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.network.orbot.OrbotHelper; +import timber.log.Timber; import java.util.ArrayList; @@ -71,12 +70,12 @@ public class ImportKeysListCloudLoader mEntryListWrapper = new AsyncTaskResultWrapper<>(mEntryList, null); if (mState.mServerQuery == null) { - Log.e(Constants.TAG, "mServerQuery is null!"); + Timber.e("mServerQuery is null!"); return mEntryListWrapper; } if (mState.mServerQuery.startsWith("0x") && mState.mServerQuery.length() == 42) { - Log.d(Constants.TAG, "This search is based on a unique fingerprint. Enforce a fingerprint check!"); + Timber.d("This search is based on a unique fingerprint. Enforce a fingerprint check!"); queryServer(true); } else { queryServer(false); @@ -148,7 +147,7 @@ public class ImportKeysListCloudLoader // add result to data if (enforceFingerprint) { String fingerprintHex = mState.mServerQuery.substring(2); - Log.d(Constants.TAG, "fingerprint: " + fingerprintHex); + Timber.d("fingerprint: " + fingerprintHex); // query must return only one result! if (searchResult.size() == 1) { if (fingerprintHex.length() != 40) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/processing/ImportKeysListLoader.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/processing/ImportKeysListLoader.java index 13d91b9f9..0e5b50168 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/processing/ImportKeysListLoader.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/processing/ImportKeysListLoader.java @@ -22,7 +22,6 @@ import android.content.Context; import android.support.annotation.NonNull; import android.support.v4.content.AsyncTaskLoader; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.operations.results.GetKeyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; @@ -32,8 +31,8 @@ import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow; import org.sufficientlysecure.keychain.util.FileHelper; import org.sufficientlysecure.keychain.util.InputData; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.PositionAwareInputStream; +import timber.log.Timber; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; @@ -70,7 +69,7 @@ public class ImportKeysListLoader } if (mState == null) { - Log.e(Constants.TAG, "Input data is null!"); + Timber.e("Input data is null!"); return mEntryListWrapper; } @@ -123,7 +122,7 @@ public class ImportKeysListLoader mData.add(new ImportKeysListEntry(mContext, it.next())); } } catch (IOException e) { - Log.e(Constants.TAG, "IOException on parsing key file! Return NoValidKeysException!", e); + Timber.e(e, "IOException on parsing key file! Return NoValidKeysException!"); OperationResult.OperationLog log = new OperationResult.OperationLog(); log.add(OperationResult.LogType.MSG_GET_NO_VALID_KEYS, 0); GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_ERROR_NO_VALID_KEYS, log); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/LinkedTokenResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/LinkedTokenResource.java index 3d67148c3..b7ce26072 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/LinkedTokenResource.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/LinkedTokenResource.java @@ -24,7 +24,6 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.json.JSONException; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.linked.resources.GenericHttpsResource; import org.sufficientlysecure.keychain.linked.resources.GithubResource; import org.sufficientlysecure.keychain.linked.resources.TwitterResource; @@ -32,8 +31,8 @@ import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.network.OkHttpClientFactory; +import timber.log.Timber; import java.io.IOException; import java.net.MalformedURLException; @@ -83,18 +82,18 @@ public abstract class LinkedTokenResource extends LinkedResource { if (!"openpgpid+token".equals(uri.getScheme()) && !"openpgpid+cookie".equals(uri.getScheme())) { - Log.e(Constants.TAG, "unknown uri scheme in (suspected) linked id packet"); + Timber.e("unknown uri scheme in (suspected) linked id packet"); return null; } if (!uri.isOpaque()) { - Log.e(Constants.TAG, "non-opaque uri in (suspected) linked id packet"); + Timber.e("non-opaque uri in (suspected) linked id packet"); return null; } String specific = uri.getSchemeSpecificPart(); if (!specific.contains("@")) { - Log.e(Constants.TAG, "unknown uri scheme in linked id packet"); + Timber.e("unknown uri scheme in linked id packet"); return null; } @@ -192,15 +191,15 @@ public abstract class LinkedTokenResource extends LinkedResource { res = fetchResource(context, log, 1); } catch (HttpStatusException e) { // log verbose output to logcat - Log.e(Constants.TAG, "http error (" + e.getStatus() + "): " + e.getReason()); + Timber.e("http error (" + e.getStatus() + "): " + e.getReason()); log.add(LogType.MSG_LV_FETCH_ERROR, 2, Integer.toString(e.getStatus())); } catch (MalformedURLException e) { log.add(LogType.MSG_LV_FETCH_ERROR_URL, 2); } catch (IOException e) { - Log.e(Constants.TAG, "io error", e); + Timber.e(e, "io error"); log.add(LogType.MSG_LV_FETCH_ERROR_IO, 2); } catch (JSONException e) { - Log.e(Constants.TAG, "json error", e); + Timber.e(e, "json error"); log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, 2); } @@ -209,7 +208,7 @@ public abstract class LinkedTokenResource extends LinkedResource { return new LinkedVerifyResult(LinkedVerifyResult.RESULT_ERROR, log); } - Log.d(Constants.TAG, "Resource data: '" + res + "'"); + Timber.d("Resource data: '" + res + "'"); return verifyString(log, 1, res, fingerprint); @@ -258,7 +257,7 @@ public abstract class LinkedTokenResource extends LinkedResource { public static String getResponseBody(Request request, String... pins) throws IOException, HttpStatusException { - Log.d("Connection to: " + request.url().url().getHost(), ""); + Timber.d(""); OkHttpClient client; if (pins != null) { client = OkHttpClientFactory.getSimpleClientPinned(getCertificatePinner(request.url().url().getHost(), pins)); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/UriAttribute.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/UriAttribute.java index ceef211de..6187d8ff7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/UriAttribute.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/UriAttribute.java @@ -18,10 +18,9 @@ package org.sufficientlysecure.keychain.linked; import org.bouncycastle.util.Strings; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.IOException; import java.net.URI; @@ -67,7 +66,7 @@ public class UriAttribute { return new LinkedAttribute(uri, res); } catch (IllegalArgumentException e) { - Log.e(Constants.TAG, "error parsing uri in (suspected) linked id packet"); + Timber.e("error parsing uri in (suspected) linked id packet"); return null; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/resources/GithubResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/resources/GithubResource.java index c4c737abc..5b32c9c4e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/resources/GithubResource.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/resources/GithubResource.java @@ -27,12 +27,11 @@ import okhttp3.Request; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.linked.LinkedTokenResource; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.IOException; import java.net.MalformedURLException; @@ -166,15 +165,15 @@ public class GithubResource extends LinkedTokenResource { } catch (HttpStatusException e) { // log verbose output to logcat - Log.e(Constants.TAG, "http error (" + e.getStatus() + "): " + e.getReason()); + Timber.e("http error (" + e.getStatus() + "): " + e.getReason()); log.add(LogType.MSG_LV_FETCH_ERROR, 2, Integer.toString(e.getStatus())); } catch (MalformedURLException e) { log.add(LogType.MSG_LV_FETCH_ERROR_URL, 2); } catch (IOException e) { - Log.e(Constants.TAG, "io error", e); + Timber.e(e, "io error"); log.add(LogType.MSG_LV_FETCH_ERROR_IO, 2); } catch (JSONException e) { - Log.e(Constants.TAG, "json error", e); + Timber.e(e, "json error"); log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, 2); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/resources/TwitterResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/resources/TwitterResource.java index b31afaaf9..48e6b4163 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/resources/TwitterResource.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/linked/resources/TwitterResource.java @@ -37,6 +37,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.linked.LinkedTokenResource; +import timber.log.Timber; import java.io.IOException; import java.net.MalformedURLException; @@ -207,15 +208,15 @@ public class TwitterResource extends LinkedTokenResource { } catch (HttpStatusException e) { // log verbose output to logcat - Log.e(Constants.TAG, "http error (" + e.getStatus() + "): " + e.getReason()); + Timber.e("http error (" + e.getStatus() + "): " + e.getReason()); log.add(LogType.MSG_LV_FETCH_ERROR, 1, Integer.toString(e.getStatus())); } catch (MalformedURLException e) { log.add(LogType.MSG_LV_FETCH_ERROR_URL, 1); } catch (IOException e) { - Log.e(Constants.TAG, "io error", e); + Timber.e(e, "io error"); log.add(LogType.MSG_LV_FETCH_ERROR_IO, 1); } catch (JSONException e) { - Log.e(Constants.TAG, "json error", e); + Timber.e(e, "json error"); log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, 1); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/KeyTransferInteractor.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/KeyTransferInteractor.java index b7cf5d334..c7f565970 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/KeyTransferInteractor.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/KeyTransferInteractor.java @@ -56,8 +56,7 @@ import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLSocket; import javax.net.ssl.TrustManager; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; @RequiresApi(api = VERSION_CODES.LOLLIPOP) @@ -171,12 +170,12 @@ public class KeyTransferInteractor { try { handleOpenConnection(socket); - Log.d(Constants.TAG, "connection closed ok!"); + Timber.d("connection closed ok!"); } catch (SSLHandshakeException e) { - Log.d(Constants.TAG, "ssl handshake error!", e); + Timber.d(e, "ssl handshake error!"); invokeListener(CONNECTION_ERROR_CONNECT, null); } catch (IOException e) { - Log.e(Constants.TAG, "communication error!", e); + Timber.e(e, "communication error!"); invokeListener(CONNECTION_ERROR_WHILE_CONNECTED, e.getLocalizedMessage()); } } finally { @@ -200,7 +199,7 @@ public class KeyTransferInteractor { socket = serverSocket.accept(); } catch (IOException e) { - Log.e(Constants.TAG, "error while listening!", e); + Timber.e(e, "error while listening!"); invokeListener(CONNECTION_ERROR_LISTEN, null); return null; } @@ -214,7 +213,7 @@ public class KeyTransferInteractor { socket = sslSocket; socket.connect(new InetSocketAddress(InetAddress.getByName(clientHost), clientPort), TIMEOUT_CONNECTING); } catch (IOException e) { - Log.e(Constants.TAG, "error while connecting!", e); + Timber.e(e, "error while connecting!"); if (e instanceof NoRouteToHostException) { invokeListener(CONNECTION_ERROR_NO_ROUTE_TO_HOST, wifiSsid); } else { @@ -252,7 +251,7 @@ public class KeyTransferInteractor { break; } } - Log.d(Constants.TAG, "disconnected"); + Timber.d("disconnected"); invokeListener(CONNECTION_LOST, null); } @@ -270,7 +269,7 @@ public class KeyTransferInteractor { boolean lineIsDelimiter = delimiterStart.equals(firstLine); if (!lineIsDelimiter) { - Log.d(Constants.TAG, "bad beginning of key block?"); + Timber.d("bad beginning of key block?"); return false; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/NetworkReceiver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/NetworkReceiver.java index bfbc57ce5..ec3cebf0f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/NetworkReceiver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/NetworkReceiver.java @@ -25,9 +25,9 @@ import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class NetworkReceiver extends BroadcastReceiver { @@ -60,11 +60,11 @@ public class NetworkReceiver extends BroadcastReceiver { if (isEnabled) { pm.setComponentEnabledSetting(compName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); - Log.d(Constants.TAG, "Wifi Receiver is enabled!"); + Timber.d("Wifi Receiver is enabled!"); } else { pm.setComponentEnabledSetting(compName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); - Log.d(Constants.TAG, "Wifi Receiver is disabled!"); + Timber.d("Wifi Receiver is disabled!"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/SktUri.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/SktUri.java index 8b2ec9a48..46c4297b1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/SktUri.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/SktUri.java @@ -28,7 +28,8 @@ import com.google.auto.value.AutoValue; import org.bouncycastle.util.encoders.DecoderException; import org.bouncycastle.util.encoders.Hex; import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + @AutoValue abstract class SktUri { @@ -75,7 +76,7 @@ abstract class SktUri { try { wifiSsid = new String(Hex.decode(optarg[1])); } catch (DecoderException e) { - Log.d(Constants.TAG, "error parsing ssid in skt uri, ignoring: " + input); + Timber.d("error parsing ssid in skt uri, ignoring: " + input); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/TlsCertificatePinning.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/TlsCertificatePinning.java index a284b3b27..5431ce9bf 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/TlsCertificatePinning.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/TlsCertificatePinning.java @@ -19,9 +19,6 @@ package org.sufficientlysecure.keychain.network; import android.content.res.AssetManager; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -45,6 +42,8 @@ import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; import okhttp3.OkHttpClient; +import timber.log.Timber; + public class TlsCertificatePinning { @@ -68,7 +67,7 @@ public class TlsCertificatePinning { sCertificatePins.put(host, baos.toByteArray()); } catch (IOException e) { - Log.w(Constants.TAG, e); + Timber.w(e); } } @@ -89,7 +88,7 @@ public class TlsCertificatePinning { * to URLs with passed certificate. */ void pinCertificate(OkHttpClient.Builder builder) { - Log.d(Constants.TAG, "Pinning certificate for " + url); + Timber.d("Pinning certificate for " + url); // We don't use OkHttp's CertificatePinner since it can not be used to pin self-signed // certificate if such certificate is not accepted by TrustManager. diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/orbot/OrbotHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/orbot/OrbotHelper.java index 0491046f3..5bb3b0e44 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/orbot/OrbotHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/orbot/OrbotHelper.java @@ -65,18 +65,18 @@ import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.text.TextUtils; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.dialog.SupportInstallDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.OrbotStartDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.PreferenceInstallDialogFragment; import org.sufficientlysecure.keychain.ui.util.ThemeChanger; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; import java.util.List; + /** * This class is taken from the NetCipher library: https://github.com/guardianproject/NetCipher/ * All calls that use a shell have been removed. @@ -221,7 +221,7 @@ public class OrbotHelper { */ public static boolean requestStartTor(Context context) { if (OrbotHelper.isOrbotInstalled(context)) { - Log.i("OrbotHelper", "requestStartTor " + context.getPackageName()); + Timber.i("requestStartTor " + context.getPackageName()); Intent intent = getOrbotStartIntent(); intent.putExtra(EXTRA_PACKAGE_NAME, context.getPackageName()); context.sendBroadcast(intent); @@ -245,7 +245,7 @@ public class OrbotHelper { String foundPackageName = null; for (ResolveInfo r : resInfos) { - Log.i("OrbotHelper", "market: " + r.activityInfo.packageName); + Timber.i("market: " + r.activityInfo.packageName); if (TextUtils.equals(r.activityInfo.packageName, FDROID_PACKAGE_NAME) || TextUtils.equals(r.activityInfo.packageName, PLAY_PACKAGE_NAME)) { foundPackageName = r.activityInfo.packageName; @@ -416,7 +416,7 @@ public class OrbotHelper { private ProgressDialog mProgressDialog; public void startOrbotAndListen(final Context context, final boolean showProgress) { - Log.d(Constants.TAG, "starting orbot listener"); + Timber.d("starting orbot listener"); if (showProgress) { showProgressDialog(context); } @@ -447,8 +447,8 @@ public class OrbotHelper { break; } - Log.d(Constants.TAG, "Orbot silent start broadcast: " + - intent.getStringExtra(OrbotHelper.EXTRA_STATUS)); + Timber.d("Orbot silent start broadcast: " + + intent.getStringExtra(EXTRA_STATUS)); } }; context.registerReceiver(receiver, new IntentFilter(OrbotHelper.ACTION_STATUS)); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/orbot/OrbotStatusReceiver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/orbot/OrbotStatusReceiver.java index 8e20b4dc0..af9650a4e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/orbot/OrbotStatusReceiver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/network/orbot/OrbotStatusReceiver.java @@ -22,8 +22,8 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + /** * BroadcastReceiver that receives Orbots status @@ -58,18 +58,18 @@ public class OrbotStatusReceiver extends BroadcastReceiver { String status = intent.getStringExtra(OrbotHelper.EXTRA_STATUS); this.torRunning = (intent.getStringExtra(OrbotHelper.EXTRA_STATUS).equals(OrbotHelper.STATUS_ON)); - Log.d(Constants.TAG, "Receiver: Orbot status: " + status); + Timber.d("Receiver: Orbot status: " + status); if (torRunning) { Bundle extras = intent.getExtras(); if (extras.containsKey(EXTRA_PROXY_PORT_HTTP)) { this.proxyPortHttp = extras.getInt(EXTRA_PROXY_PORT_HTTP, -1); - Log.i(Constants.TAG, "Receiver: Orbot Http proxy at " + proxyPortHttp); + Timber.i("Receiver: Orbot Http proxy at " + proxyPortHttp); } if (extras.containsKey(EXTRA_PROXY_PORT_SOCKS)) { this.proxyPortSocks = extras.getInt(EXTRA_PROXY_PORT_SOCKS, -1); - Log.i(Constants.TAG, "Receiver: Orbot Socks proxy at " + proxyPortSocks); + Timber.i("Receiver: Orbot Socks proxy at " + proxyPortSocks); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java index dfac723c5..a31f7e4e1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java @@ -46,7 +46,6 @@ import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing; import org.sufficientlysecure.keychain.pgp.PgpSignEncryptData; -import org.sufficientlysecure.keychain.pgp.PgpSignEncryptInputParcel; import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation; import org.sufficientlysecure.keychain.pgp.Progressable; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; @@ -61,7 +60,7 @@ import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.util.CountingOutputStream; import org.sufficientlysecure.keychain.util.InputData; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; /** @@ -259,7 +258,7 @@ public class BackupOperation extends BaseOperation { if (outStream != null) try { outStream.close(); } catch (Exception e) { - Log.e(Constants.TAG, "error closing stream", e); + Timber.e(e, "error closing stream"); } cursor.close(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java index 224db4890..65edf45cd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java @@ -45,9 +45,9 @@ import org.sufficientlysecure.keychain.pgp.SignEncryptParcel; import org.sufficientlysecure.keychain.provider.KeyWritableRepository; import org.sufficientlysecure.keychain.service.BenchmarkInputParcel; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; import org.sufficientlysecure.keychain.util.ProgressScaler; +import timber.log.Timber; public class BenchmarkOperation extends BaseOperation { @@ -139,7 +139,7 @@ public class BenchmarkOperation extends BaseOperation { iterationsFor100ms = iterations; } catch (PGPException e) { - Log.e(Constants.TAG, "internal error during benchmark", e); + Timber.e(e, "internal error during benchmark"); log.add(LogType.MSG_INTERNAL_ERROR, 0); return new BenchmarkResult(BenchmarkResult.RESULT_ERROR, log); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java index 7512c641f..e57e4a3bf 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java @@ -35,7 +35,6 @@ import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.keyimport.FacebookKeyserverClient; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; @@ -62,11 +61,12 @@ import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.service.input.RequiredInputParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.util.IteratorWithSize; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableFileCache; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.util.ProgressScaler; +import timber.log.Timber; + /** * An operation class which implements high level import @@ -248,7 +248,7 @@ public class ImportOperation extends BaseReadWriteOperation log.add(result, 2); } catch (IOException | PgpGeneralException e) { - Log.e(Constants.TAG, "Encountered bad key on import!", e); + Timber.e(e, "Encountered bad key on import!"); ++badKeys; } @@ -400,7 +400,7 @@ public class ImportOperation extends BaseReadWriteOperation } catch (KeyserverClient.QueryNotFoundException e) { throw e; } catch (KeyserverClient.QueryFailedException e) { - Log.d(Constants.TAG, "query failed", e); + Timber.d(e, "query failed"); log.add(LogType.MSG_IMPORT_FETCH_ERROR_KEYSERVER, 3, e.getMessage()); return null; } @@ -426,7 +426,7 @@ public class ImportOperation extends BaseReadWriteOperation return keybaseKey; } catch (KeyserverClient.QueryFailedException e) { // download failed, too bad. just proceed - Log.e(Constants.TAG, "query failed", e); + Timber.e(e, "query failed"); log.add(LogType.MSG_IMPORT_FETCH_ERROR_KEYSERVER, 3, e.getMessage()); return null; } @@ -452,7 +452,7 @@ public class ImportOperation extends BaseReadWriteOperation return facebookKey; } catch (KeyserverClient.QueryFailedException e) { // download failed, too bad. just proceed - Log.e(Constants.TAG, "query failed", e); + Timber.e(e, "query failed"); log.add(LogType.MSG_IMPORT_FETCH_ERROR_KEYSERVER, 3, e.getMessage()); return null; } @@ -515,7 +515,7 @@ public class ImportOperation extends BaseReadWriteOperation private ImportKeyResult multiThreadedKeyImport(List keyList, final HkpKeyserverAddress keyServer, final ParcelableProxy proxy, final boolean skipSave) { - Log.d(Constants.TAG, "Multi-threaded key import starting"); + Timber.d("Multi-threaded key import starting"); final Iterator keyListIterator = keyList.iterator(); final int totKeys = keyList.size(); @@ -555,8 +555,8 @@ public class ImportOperation extends BaseReadWriteOperation try { accumulator.accumulateKeyImport(importCompletionService.take().get()); } catch (InterruptedException | ExecutionException e) { - Log.e(Constants.TAG, "A key could not be imported during multi-threaded " + - "import", e); + Timber.e(e, "A key could not be imported during multi-threaded " + + "import"); // do nothing? if (e instanceof ExecutionException) { // Since serialKeyRingImport does not throw any exceptions, this is what diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java index 12de8d9b7..23b3380a2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java @@ -22,7 +22,6 @@ import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.operations.results.EditKeyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.operations.results.RevokeResult; @@ -35,7 +34,8 @@ import org.sufficientlysecure.keychain.service.RevokeKeyringParcel; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class RevokeOperation extends BaseReadWriteOperation { @@ -97,7 +97,7 @@ public class RevokeOperation extends BaseReadWriteOperation } } catch (PgpKeyNotFoundException | KeyWritableRepository.NotFoundException e) { - Log.e(Constants.TAG, "could not find key to revoke", e); + Timber.e(e, "could not find key to revoke"); log.add(OperationResult.LogType.MSG_REVOKE_ERROR_KEY_FAIL, 1); return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java index 417c83165..f9a428008 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java @@ -23,7 +23,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import org.bouncycastle.bcpg.ArmoredOutputStream; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverClient; import org.sufficientlysecure.keychain.keyimport.KeyserverClient.AddKeyException; @@ -42,10 +41,10 @@ import org.sufficientlysecure.keychain.service.UploadKeyringParcel; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.service.input.RequiredInputParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.network.orbot.OrbotHelper; +import timber.log.Timber; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -130,7 +129,7 @@ public class UploadOperation extends BaseOperation { return null; } catch (IOException | PgpGeneralException e) { log.add(LogType.MSG_UPLOAD_ERROR_IO, 1); - Log.e(Constants.TAG, "error uploading key", e); + Timber.e(e, "error uploading key"); return null; } @@ -159,12 +158,12 @@ public class UploadOperation extends BaseOperation { log.add(LogType.MSG_UPLOAD_SUCCESS, 1); return new UploadResult(UploadResult.RESULT_OK, log); } catch (IOException e) { - Log.e(Constants.TAG, "IOException", e); + Timber.e(e, "IOException"); log.add(LogType.MSG_UPLOAD_ERROR_IO, 1); return new UploadResult(UploadResult.RESULT_ERROR, log); } catch (AddKeyException e) { - Log.e(Constants.TAG, "AddKeyException", e); + Timber.e(e, "AddKeyException"); log.add(LogType.MSG_UPLOAD_ERROR_UPLOAD, 1); return new UploadResult(UploadResult.RESULT_ERROR, log); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java index c9f0a3273..327561d1d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java @@ -24,7 +24,6 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.LogDisplayActivity; import org.sufficientlysecure.keychain.ui.LogDisplayFragment; @@ -33,8 +32,8 @@ import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener; import org.sufficientlysecure.keychain.ui.util.Notify.Showable; import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.util.IterableIterator; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableCache; +import timber.log.Timber; import java.util.ArrayList; import java.util.Arrays; @@ -122,7 +121,7 @@ public abstract class OperationResult implements Parcelable { mType = type; mParameters = parameters; mIndent = indent; - Log.v(Constants.TAG, "log: " + this); + Timber.v("log: " + this); } /** Clones this LogEntryParcel, adding extra indent. Note that the parameter array is NOT cloned! */ @@ -206,7 +205,7 @@ public abstract class OperationResult implements Parcelable { super(type, indent, parameters); mSubResult = subResult; - Log.v(Constants.TAG, "log: " + this); + Timber.v("log: " + this); } public SubLogEntryParcel(Parcel source) { @@ -264,7 +263,7 @@ public abstract class OperationResult implements Parcelable { LogEntryParcel entryParcel = mLog.getLast(); if (entryParcel == null) { - Log.e(Constants.TAG, "Tried to show empty log!"); + Timber.e("Tried to show empty log!"); return Notify.create(activity, R.string.error_empty_log, Style.ERROR); } // special case: first parameter may be a quantity diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedPublicKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedPublicKey.java index 94a3df478..2ee4ab42d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedPublicKey.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedPublicKey.java @@ -18,6 +18,14 @@ package org.sufficientlysecure.keychain.pgp; +import java.io.IOException; +import java.security.PublicKey; +import java.security.interfaces.ECPublicKey; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Iterator; + import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; import org.bouncycastle.bcpg.ECDHPublicBCPGKey; @@ -31,18 +39,9 @@ import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator; import org.bouncycastle.openpgp.operator.RFC6637Utils; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter; import org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.util.IterableIterator; -import org.sufficientlysecure.keychain.util.Log; - -import java.io.IOException; -import java.security.PublicKey; -import java.security.interfaces.ECPublicKey; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Iterator; +import timber.log.Timber; /** Wrapper for a PGPPublicKey. * @@ -185,7 +184,7 @@ public class CanonicalizedPublicKey extends UncachedPublicKey { long seconds = getValidSeconds(); if (seconds > Integer.MAX_VALUE) { - Log.e(Constants.TAG, "error, expiry time too large"); + Timber.e("error, expiry time too large"); return null; } if (seconds == 0) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java index 3533f82b8..b37b572f4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java @@ -37,14 +37,21 @@ import org.bouncycastle.openpgp.PGPSignatureGenerator; import org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder; -import org.bouncycastle.openpgp.operator.jcajce.*; +import org.bouncycastle.openpgp.operator.jcajce.CachingDataDecryptorFactory; +import org.bouncycastle.openpgp.operator.jcajce.EdDsaAuthenticationContentSignerBuilder; +import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder; +import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter; +import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; +import org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyDataDecryptorFactoryBuilder; +import org.bouncycastle.openpgp.operator.jcajce.NfcSyncPGPContentSignerBuilder; +import org.bouncycastle.openpgp.operator.jcajce.SessionKeySecretKeyDecryptorBuilder; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.provider.KeyWritableRepository; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; +import timber.log.Timber; /** @@ -204,7 +211,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey { mPrivateKey = mSecretKey.extractPrivateKey(keyDecryptor); mPrivateKeyState = PRIVATE_KEY_STATE_UNLOCKED; } catch (PGPException e) { - Log.e(Constants.TAG, "Error extracting private key!", e); + Timber.e(e, "Error extracting private key!"); return false; } if (mPrivateKey == null) { @@ -241,7 +248,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey { signatureGenerator.init(PGPSignature.DEFAULT_CERTIFICATION, mPrivateKey); return signatureGenerator; } catch (PGPException e) { - Log.e(Constants.TAG, "signing error", e); + Timber.e(e, "signing error"); return null; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKeyRing.java index 4b6eaa609..b59ee917a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKeyRing.java @@ -17,19 +17,19 @@ package org.sufficientlysecure.keychain.pgp; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; + import org.bouncycastle.openpgp.PGPKeyRing; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.util.IterableIterator; -import org.sufficientlysecure.keychain.util.Log; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; +import timber.log.Timber; public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing { @@ -47,10 +47,10 @@ public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing { PGPKeyRing keyRing = null; try { if ((keyRing = (PGPKeyRing) factory.nextObject()) == null) { - Log.e(Constants.TAG, "No keys given!"); + Timber.e("No keys given!"); } } catch (IOException e) { - Log.e(Constants.TAG, "Error while converting to PGPKeyRing!", e); + Timber.e(e, "Error while converting to PGPKeyRing!"); } mRing = (PGPSecretKeyRing) keyRing; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpDecryptionResultBuilder.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpDecryptionResultBuilder.java index fc0a81010..7b879b386 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpDecryptionResultBuilder.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpDecryptionResultBuilder.java @@ -18,8 +18,8 @@ package org.sufficientlysecure.keychain.pgp; import org.openintents.openpgp.OpenPgpDecryptionResult; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + class OpenPgpDecryptionResultBuilder { @@ -39,16 +39,16 @@ class OpenPgpDecryptionResultBuilder { public OpenPgpDecryptionResult build() { if (isInsecure) { - Log.d(Constants.TAG, "RESULT_INSECURE"); + Timber.d("RESULT_INSECURE"); return new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_INSECURE, sessionKey, decryptedSessionKey); } if (isEncrypted) { - Log.d(Constants.TAG, "RESULT_ENCRYPTED"); + Timber.d("RESULT_ENCRYPTED"); return new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_ENCRYPTED, sessionKey, decryptedSessionKey); } - Log.d(Constants.TAG, "RESULT_NOT_ENCRYPTED"); + Timber.d("RESULT_NOT_ENCRYPTED"); return new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java index 4cea3e207..f7034800b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java @@ -25,11 +25,11 @@ import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.OpenPgpSignatureResult.SenderStatusResult; import org.openintents.openpgp.util.OpenPgpUtils; import org.openintents.openpgp.util.OpenPgpUtils.UserId; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.provider.KeyRepository; import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + /** * This class can be used to build OpenPgpSignatureResult objects based on several checks. @@ -121,7 +121,7 @@ public class OpenPgpSignatureResultBuilder { try { setPrimaryUserId(signingRing.getPrimaryUserIdWithFallback()); } catch (PgpKeyNotFoundException e) { - Log.d(Constants.TAG, "No primary user id in keyring with master key id " + signingRing.getMasterKeyId()); + Timber.d("No primary user id in keyring with master key id " + signingRing.getMasterKeyId()); } setSignatureKeyCertified(signingRing.getVerified() > 0); @@ -168,35 +168,35 @@ public class OpenPgpSignatureResultBuilder { public OpenPgpSignatureResult build() { if (!mSignatureAvailable) { - Log.d(Constants.TAG, "RESULT_NO_SIGNATURE"); + Timber.d("RESULT_NO_SIGNATURE"); return OpenPgpSignatureResult.createWithNoSignature(); } if (!mKnownKey) { - Log.d(Constants.TAG, "RESULT_KEY_MISSING"); + Timber.d("RESULT_KEY_MISSING"); return OpenPgpSignatureResult.createWithKeyMissing(mKeyId, mSignatureTimestamp); } if (!mValidSignature) { - Log.d(Constants.TAG, "RESULT_INVALID_SIGNATURE"); + Timber.d("RESULT_INVALID_SIGNATURE"); return OpenPgpSignatureResult.createWithInvalidSignature(); } int signatureStatus; if (mIsKeyRevoked) { - Log.d(Constants.TAG, "RESULT_INVALID_KEY_REVOKED"); + Timber.d("RESULT_INVALID_KEY_REVOKED"); signatureStatus = OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED; } else if (mIsKeyExpired) { - Log.d(Constants.TAG, "RESULT_INVALID_KEY_EXPIRED"); + Timber.d("RESULT_INVALID_KEY_EXPIRED"); signatureStatus = OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED; } else if (mInsecure) { - Log.d(Constants.TAG, "RESULT_INVALID_INSECURE"); + Timber.d("RESULT_INVALID_INSECURE"); signatureStatus = OpenPgpSignatureResult.RESULT_INVALID_KEY_INSECURE; } else if (mIsSignatureKeyCertified) { - Log.d(Constants.TAG, "RESULT_VALID_CONFIRMED"); + Timber.d("RESULT_VALID_CONFIRMED"); signatureStatus = OpenPgpSignatureResult.RESULT_VALID_KEY_CONFIRMED; } else { - Log.d(Constants.TAG, "RESULT_VALID_UNCONFIRMED"); + Timber.d("RESULT_VALID_UNCONFIRMED"); signatureStatus = OpenPgpSignatureResult.RESULT_VALID_KEY_UNCONFIRMED; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java index a63611b52..9229a0f9f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java @@ -32,14 +32,13 @@ import org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator; import org.bouncycastle.openpgp.PGPSignatureSubpacketVector; import org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector; import org.bouncycastle.openpgp.operator.jcajce.NfcSyncPGPContentSignerBuilder.NfcInteractionNeeded; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction; import org.sufficientlysecure.keychain.service.input.RequiredInputParcel; import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.SecurityTokenSignOperationsBuilder; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; public class PgpCertifyOperation { @@ -67,7 +66,7 @@ public class PgpCertifyOperation { PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator(); if (creationTimestamp != null) { spGen.setSignatureCreationTime(false, creationTimestamp); - Log.d(Constants.TAG, "For NFC: set sig creation time to " + creationTimestamp); + Timber.d("For NFC: set sig creation time to " + creationTimestamp); } PGPSignatureSubpacketVector packetVector = spGen.generate(); signatureGenerator.setHashedSubpackets(packetVector); @@ -115,7 +114,7 @@ public class PgpCertifyOperation { } } catch (PGPException e) { - Log.e(Constants.TAG, "signing error", e); + Timber.e(e, "signing error"); return new PgpCertifyResult(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java index c642c2197..6f079495d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java @@ -83,9 +83,12 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.util.CharsetVerifier; import org.sufficientlysecure.keychain.util.FileHelper; import org.sufficientlysecure.keychain.util.InputData; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; import org.sufficientlysecure.keychain.util.ProgressScaler; +import timber.log.Timber; + +import static java.lang.String.format; + public class PgpDecryptVerifyOperation extends BaseOperation { @@ -112,7 +115,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation Integer.MAX_VALUE) { - Log.e(Constants.TAG, "error, expiry time too large"); + Timber.e("error, expiry time too large"); return null; } if (valid == 0) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java index e5fe9daeb..44414c0ee 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java @@ -33,7 +33,7 @@ import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.IOException; import java.util.ArrayList; @@ -103,7 +103,7 @@ public class WrappedSignature { } } catch (PGPException e) { // no matter - Log.e(Constants.TAG, "exception reading embedded signatures", e); + Timber.e(e, "exception reading embedded signatures"); } return sigs; } @@ -229,11 +229,11 @@ public class WrappedSignature { PGPSignatureList signatures = null; try { if ((signatures = (PGPSignatureList) factory.nextObject()) == null || signatures.isEmpty()) { - Log.e(Constants.TAG, "No signatures given!"); + Timber.e("No signatures given!"); return null; } } catch (IOException e) { - Log.e(Constants.TAG, "Error while converting to PGPSignature!", e); + Timber.e(e, "Error while converting to PGPSignature!"); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java index 4e3bc23c0..56f879589 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java @@ -20,14 +20,14 @@ package org.sufficientlysecure.keychain.provider; import android.net.Uri; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + /** This implementation of KeyRing provides a cached view of PublicKeyRing * objects based on database queries exclusively. @@ -77,7 +77,7 @@ public class CachedPublicKeyRing extends KeyRing { return Long.parseLong(firstSegment); } catch (NumberFormatException e) { // didn't work? oh well. - Log.d(Constants.TAG, "Couldn't get masterKeyId from URI, querying..."); + Timber.d("Couldn't get masterKeyId from URI, querying..."); } return getMasterKeyId(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyRepository.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyRepository.java index c94d60c53..fbe765ac9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyRepository.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyRepository.java @@ -28,10 +28,8 @@ import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.support.annotation.Nullable; -import android.util.Log; import org.bouncycastle.bcpg.ArmoredOutputStream; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; @@ -43,6 +41,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.UpdatedKeys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; +import timber.log.Timber; public class KeyRepository { @@ -339,7 +338,7 @@ public class KeyRepository { try { data = mLocalPublicKeyStorage.readPublicKey(masterKeyId); } catch (IOException e) { - Log.e(Constants.TAG, "Error reading public key from storage!", e); + Timber.e(e, "Error reading public key from storage!"); throw new NotFoundException(); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java index 58c80028c..42ea211e8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java @@ -38,7 +38,6 @@ import android.support.annotation.VisibleForTesting; import android.support.v4.util.LongSparseArray; import org.openintents.openpgp.util.OpenPgpUtils; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; @@ -67,9 +66,10 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.UpdatedKeys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.util.IterableIterator; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.util.Utf8Util; +import timber.log.Timber; + /** * This class contains high level methods for database access. Despite its @@ -514,7 +514,7 @@ public class KeyWritableRepository extends KeyRepository { } catch (IOException e) { log(LogType.MSG_IP_ERROR_IO_EXC); - Log.e(Constants.TAG, "IOException during import", e); + Timber.e(e, "IOException during import"); return SaveKeyringResult.RESULT_ERROR; } finally { mIndent -= 1; @@ -544,11 +544,11 @@ public class KeyWritableRepository extends KeyRepository { } catch (RemoteException e) { log(LogType.MSG_IP_ERROR_REMOTE_EX); - Log.e(Constants.TAG, "RemoteException during import", e); + Timber.e(e, "RemoteException during import"); return SaveKeyringResult.RESULT_ERROR; } catch (OperationApplicationException e) { log(LogType.MSG_IP_ERROR_OP_EXC); - Log.e(Constants.TAG, "OperationApplicationException during import", e); + Timber.e(e, "OperationApplicationException during import"); return SaveKeyringResult.RESULT_ERROR; } @@ -602,7 +602,7 @@ public class KeyWritableRepository extends KeyRepository { try { mLocalPublicKeyStorage.deletePublicKey(masterKeyId); } catch (IOException e) { - android.util.Log.e(Constants.TAG, "Could not delete file!", e); + Timber.e(e, "Could not delete file!"); return false; } mContentResolver.delete(ApiAutocryptPeer.buildByMasterKeyId(masterKeyId),null, null); @@ -671,7 +671,7 @@ public class KeyWritableRepository extends KeyRepository { return SaveKeyringResult.RESULT_ERROR; } } catch (IOException e) { - Log.e(Constants.TAG, "Failed to encode key!", e); + Timber.e(e, "Failed to encode key!"); log(LogType.MSG_IS_ERROR_IO_EXC); return SaveKeyringResult.RESULT_ERROR; } @@ -1068,7 +1068,7 @@ public class KeyWritableRepository extends KeyRepository { log.add(result, 1); progress.setProgress(processedKeys++, totalKeys); } catch (NotFoundException | PgpGeneralException | IOException e) { - Log.e(Constants.TAG, "Error updating trust database", e); + Timber.e(e, "Error updating trust database"); return new UpdateTrustResult(UpdateTrustResult.RESULT_ERROR, log); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index a59c8fd7c..c838b69a2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -40,8 +40,8 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.OverriddenWarnings; import org.sufficientlysecure.keychain.provider.KeychainContract.UpdatedKeysColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPacketsColumns; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; /** @@ -215,7 +215,7 @@ public class KeychainDatabase extends SQLiteOpenHelper { @Override public void onCreate(SQLiteDatabase db) { - Log.w(Constants.TAG, "Creating database..."); + Timber.w("Creating database..."); db.execSQL(CREATE_KEYRINGS_PUBLIC); db.execSQL(CREATE_KEYRINGS_SECRET); @@ -249,7 +249,7 @@ public class KeychainDatabase extends SQLiteOpenHelper { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - Log.d(Constants.TAG, "Upgrading db from " + oldVersion + " to " + newVersion); + Timber.d("Upgrading db from " + oldVersion + " to " + newVersion); switch (oldVersion) { case 1: diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 93a7fb8ef..f0b045081 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -50,7 +50,10 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.UpdatedKeys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPacketsColumns; import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + +import static android.database.DatabaseUtils.dumpCursorToString; + public class KeychainProvider extends ContentProvider { @@ -296,7 +299,7 @@ public class KeychainProvider extends ContentProvider { @Override public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { - Log.v(Constants.TAG, "query(uri=" + uri + ", proj=" + Arrays.toString(projection) + ")"); + Timber.v("query(uri=" + uri + ", proj=" + Arrays.toString(projection) + ")"); SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); @@ -457,7 +460,7 @@ public class KeychainProvider extends ContentProvider { + " AND tmp." + Keys.KEY_ID + " = " + subkey + "" + ")"); } catch(NumberFormatException e) { - Log.e(Constants.TAG, "Malformed find by subkey query!", e); + Timber.e(e, "Malformed find by subkey query!"); qb.appendWhere(" AND 0"); } break; @@ -510,7 +513,7 @@ public class KeychainProvider extends ContentProvider { + ")"); } else { // TODO better way to do this? - Log.e(Constants.TAG, "Malformed find by email query!"); + Timber.e("Malformed find by email query!"); qb.appendWhere(" AND 0"); } break; @@ -795,11 +798,10 @@ public class KeychainProvider extends ContentProvider { cursor.setNotificationUri(getContext().getContentResolver(), uri); } - Log.d(Constants.TAG, - "Query: " + qb.buildQuery(projection, selection, null, null, orderBy, null)); + Timber.d("Query: " + qb.buildQuery(projection, selection, null, null, orderBy, null)); if (Constants.DEBUG && Constants.DEBUG_LOG_DB_QUERIES) { - Log.d(Constants.TAG, "Cursor: " + DatabaseUtils.dumpCursorToString(cursor)); + Timber.d("Cursor: " + dumpCursorToString(cursor)); } if (Constants.DEBUG && Constants.DEBUG_EXPLAIN_QUERIES) { @@ -813,14 +815,14 @@ public class KeychainProvider extends ContentProvider { for (int i = 0; i < explainCursor.getColumnCount(); i++) { line.append(explainCursor.getColumnName(i)).append(", "); } - Log.d(Constants.TAG, line.toString()); + Timber.d(line.toString()); while (!explainCursor.isAfterLast()) { line = new StringBuilder(); for (int i = 0; i < explainCursor.getColumnCount(); i++) { line.append(explainCursor.getString(i)).append(", "); } - Log.d(Constants.TAG, line.toString()); + Timber.d(line.toString()); explainCursor.moveToNext(); } @@ -835,7 +837,7 @@ public class KeychainProvider extends ContentProvider { */ @Override public Uri insert(Uri uri, ContentValues values) { - Log.d(Constants.TAG, "insert(uri=" + uri + ", values=" + values.toString() + ")"); + Timber.d("insert(uri=" + uri + ", values=" + values.toString() + ")"); final SQLiteDatabase db = getDb().getWritableDatabase(); @@ -925,7 +927,7 @@ public class KeychainProvider extends ContentProvider { getContext().getContentResolver().notifyChange(uri, null); } catch (SQLiteConstraintException e) { - Log.d(Constants.TAG, "Constraint exception on insert! Entry already existing?", e); + Timber.d(e, "Constraint exception on insert! Entry already existing?"); } return rowUri; @@ -936,7 +938,7 @@ public class KeychainProvider extends ContentProvider { */ @Override public int delete(Uri uri, String additionalSelection, String[] selectionArgs) { - Log.v(Constants.TAG, "delete(uri=" + uri + ")"); + Timber.v("delete(uri=" + uri + ")"); final SQLiteDatabase db = getDb().getWritableDatabase(); @@ -1028,7 +1030,7 @@ public class KeychainProvider extends ContentProvider { */ @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { - Log.v(Constants.TAG, "update(uri=" + uri + ", values=" + values.toString() + ")"); + Timber.v("update(uri=" + uri + ", values=" + values.toString() + ")"); final SQLiteDatabase db = getDb().getWritableDatabase(); ContentResolver contentResolver = getContext().getContentResolver(); @@ -1109,7 +1111,7 @@ public class KeychainProvider extends ContentProvider { contentResolver.notifyChange(uri, null); } catch (SQLiteConstraintException e) { - Log.d(Constants.TAG, "Constraint exception on update! Entry already existing?", e); + Timber.d(e, "Constraint exception on update! Entry already existing?"); } return count; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryFileProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryFileProvider.java index 5f643504c..e164ac989 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryFileProvider.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryFileProvider.java @@ -32,7 +32,7 @@ import android.provider.MediaStore; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.util.DatabaseUtil; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.File; import java.io.FileNotFoundException; @@ -136,7 +136,7 @@ public class TemporaryFileProvider extends ContentProvider { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - Log.d(Constants.TAG, "Upgrading files db from " + oldVersion + " to " + newVersion); + Timber.d("Upgrading files db from %s to %s", oldVersion, newVersion); switch (oldVersion) { case 1: @@ -188,7 +188,7 @@ public class TemporaryFileProvider extends ContentProvider { try { file = getFile(uri); } catch (FileNotFoundException e) { - Log.e(Constants.TAG, "file not found!"); + Timber.e("file not found!"); return null; } @@ -253,13 +253,13 @@ public class TemporaryFileProvider extends ContentProvider { values.put(TemporaryFileColumns.COLUMN_UUID, uuid); int insert = (int) db.getWritableDatabase().insert(TABLE_FILES, null, values); if (insert == -1) { - Log.e(Constants.TAG, "Insert failed!"); + Timber.e("Insert failed!"); return null; } try { getFile(uuid).createNewFile(); } catch (IOException e) { - Log.e(Constants.TAG, "File creation failed!"); + Timber.e("File creation failed!"); return null; } return Uri.withAppendedPath(CONTENT_URI, uuid); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPermissionHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPermissionHelper.java index c82062963..97aa7035e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPermissionHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPermissionHelper.java @@ -34,10 +34,9 @@ import android.os.Binder; import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.util.OpenPgpApi; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.ApiDataAccessObject; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; /** @@ -86,13 +85,13 @@ public class ApiPermissionHelper { return null; } else { String packageName = getCurrentCallingPackage(); - Log.d(Constants.TAG, "isAllowed packageName: " + packageName); + Timber.d("isAllowed packageName: " + packageName); byte[] packageCertificate; try { packageCertificate = getPackageCertificate(packageName); } catch (NameNotFoundException e) { - Log.e(Constants.TAG, "Should not happen, returning!", e); + Timber.e(e, "Should not happen, returning!"); // return error Intent result = new Intent(); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); @@ -100,7 +99,7 @@ public class ApiPermissionHelper { new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); return result; } - Log.e(Constants.TAG, "Not allowed to use service! return PendingIntent for registration!"); + Timber.e("Not allowed to use service! return PendingIntent for registration!"); PendingIntent pi = piFactory.createRegisterPendingIntent(data, packageName, packageCertificate); @@ -112,7 +111,7 @@ public class ApiPermissionHelper { return result; } } catch (WrongPackageCertificateException e) { - Log.e(Constants.TAG, "wrong signature!", e); + Timber.e(e, "wrong signature!"); PendingIntent pi = piFactory.createErrorPendingIntent(data, mContext.getString(R.string.api_error_wrong_signature)); @@ -159,7 +158,7 @@ public class ApiPermissionHelper { // No plans to support sharedUserIds due to many bugs connected to them: // http://java-hamster.blogspot.de/2010/05/androids-shareduserid.html String currentPkg = callingPackages[0]; - Log.d(Constants.TAG, "currentPkg: " + currentPkg); + Timber.d("currentPkg: " + currentPkg); return currentPkg; } @@ -187,7 +186,7 @@ public class ApiPermissionHelper { } } - Log.e(Constants.TAG, "Uid is NOT allowed!"); + Timber.e("Uid is NOT allowed!"); return false; } @@ -197,16 +196,16 @@ public class ApiPermissionHelper { * @throws WrongPackageCertificateException */ public boolean isPackageAllowed(String packageName) throws WrongPackageCertificateException { - Log.d(Constants.TAG, "isPackageAllowed packageName: " + packageName); + Timber.d("isPackageAllowed packageName: " + packageName); byte[] storedPackageCert = mApiDao.getApiAppCertificate(packageName); boolean isKnownPackage = storedPackageCert != null; if (!isKnownPackage) { - Log.d(Constants.TAG, "Package is NOT allowed! packageName: " + packageName); + Timber.d("Package is NOT allowed! packageName: " + packageName); return false; } - Log.d(Constants.TAG, "Package is allowed! packageName: " + packageName); + Timber.d("Package is allowed! packageName: " + packageName); byte[] currentPackageCert; try { @@ -217,7 +216,7 @@ public class ApiPermissionHelper { boolean packageCertMatchesStored = Arrays.equals(currentPackageCert, storedPackageCert); if (packageCertMatchesStored) { - Log.d(Constants.TAG,"Package certificate matches expected."); + Timber.d("Package certificate matches expected."); return true; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/CryptoInputParcelCacheService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/CryptoInputParcelCacheService.java index ca2f68460..af0229820 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/CryptoInputParcelCacheService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/CryptoInputParcelCacheService.java @@ -32,7 +32,7 @@ import android.os.RemoteException; import org.openintents.openpgp.util.OpenPgpApi; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -158,7 +158,7 @@ public class CryptoInputParcelCacheService extends Service { case MSG_GET_NOT_FOUND: throw new InputParcelNotFound(); default: - Log.e(Constants.TAG, "timeout!"); + Timber.e("timeout!"); throw new InputParcelNotFound("should not happen!"); } } @@ -206,19 +206,19 @@ public class CryptoInputParcelCacheService extends Service { try { messenger.send(msg); } catch (RemoteException e) { - Log.e(Constants.TAG, "CryptoInputParcelCacheService: Sending message failed", e); + Timber.e(e, "CryptoInputParcelCacheService: Sending message failed"); } break; } default: { - Log.e(Constants.TAG, "CryptoInputParcelCacheService: Intent or Intent Action not supported!"); + Timber.e("CryptoInputParcelCacheService: Intent or Intent Action not supported!"); break; } } if (mCache.size() <= 0) { // stop whole service if cache is empty - Log.d(Constants.TAG, "CryptoInputParcelCacheService: No passphrases remaining in memory, stopping service!"); + Timber.d("CryptoInputParcelCacheService: No passphrases remaining in memory, stopping service!"); stopSelf(); } @@ -229,13 +229,13 @@ public class CryptoInputParcelCacheService extends Service { public void onCreate() { super.onCreate(); mContext = this; - Log.d(Constants.TAG, "CryptoInputParcelCacheService, onCreate()"); + Timber.d("CryptoInputParcelCacheService, onCreate()"); } @Override public void onDestroy() { super.onDestroy(); - Log.d(Constants.TAG, "CryptoInputParcelCacheService, onDestroy()"); + Timber.d("CryptoInputParcelCacheService, onDestroy()"); } @Override diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/KeychainExternalProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/KeychainExternalProvider.java index 72788decd..c7581929e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/KeychainExternalProvider.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/KeychainExternalProvider.java @@ -54,7 +54,8 @@ import org.sufficientlysecure.keychain.provider.KeychainExternalContract.Autocry import org.sufficientlysecure.keychain.provider.KeychainExternalContract.EmailStatus; import org.sufficientlysecure.keychain.provider.SimpleContentResolverInterface; import org.sufficientlysecure.keychain.util.CloseDatabaseCursorFactory; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class KeychainExternalProvider extends ContentProvider implements SimpleContentResolverInterface { private static final int EMAIL_STATUS = 101; @@ -135,7 +136,7 @@ public class KeychainExternalProvider extends ContentProvider implements SimpleC @Override public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { - Log.v(Constants.TAG, "query(uri=" + uri + ", proj=" + Arrays.toString(projection) + ")"); + Timber.v("query(uri=" + uri + ", proj=" + Arrays.toString(projection) + ")"); SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); @@ -349,8 +350,7 @@ public class KeychainExternalProvider extends ContentProvider implements SimpleC } } - Log.d(Constants.TAG, - "Query: " + qb.buildQuery(projection, selection, groupBy, null, orderBy, null)); + Timber.d("Query: " + qb.buildQuery(projection, selection, groupBy, null, orderBy, null)); return cursor; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 7e06c136b..4f889807f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -81,8 +81,9 @@ import org.sufficientlysecure.keychain.service.BackupKeyringParcel; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.service.input.RequiredInputParcel; import org.sufficientlysecure.keychain.util.InputData; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; +import timber.log.Timber; + public class OpenPgpService extends Service { public static final int API_VERSION_WITH_KEY_INVALID_INSECURE = 8; @@ -193,7 +194,7 @@ public class OpenPgpService extends Service { throw new Exception(getString(errorMsg.mType.getMsgId())); } } catch (Exception e) { - Log.d(Constants.TAG, "signImpl", e); + Timber.d(e, "signImpl"); return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, e.getMessage()); } } @@ -296,7 +297,7 @@ public class OpenPgpService extends Service { throw new Exception(getString(errorMsg.mType.getMsgId())); } } catch (Exception e) { - Log.d(Constants.TAG, "encryptAndSignImpl", e); + Timber.d(e, "encryptAndSignImpl"); return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, e.getMessage()); } } @@ -446,7 +447,7 @@ public class OpenPgpService extends Service { } } catch (Exception e) { - Log.e(Constants.TAG, "decryptAndVerifyImpl", e); + Timber.e(e, "decryptAndVerifyImpl"); return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, e.getMessage()); } } @@ -486,7 +487,7 @@ public class OpenPgpService extends Service { if (autocryptPeerUpdate.hasKeyData()) { UncachedKeyRing uncachedKeyRing = UncachedKeyRing.decodeFromData(autocryptPeerUpdate.getKeyData()); if (uncachedKeyRing.isSecret()) { - Log.e(Constants.TAG, "Found secret key in autocrypt id! - Ignoring"); + Timber.e("Found secret key in autocrypt id! - Ignoring"); return null; } // this will merge if the key already exists - no worries! @@ -669,7 +670,7 @@ public class OpenPgpService extends Service { try { outputStream.close(); } catch (IOException e) { - Log.e(Constants.TAG, "IOException when closing OutputStream", e); + Timber.e(e, "IOException when closing OutputStream"); } } } @@ -689,7 +690,7 @@ public class OpenPgpService extends Service { return result; } } catch (Exception e) { - Log.d(Constants.TAG, "getKeyImpl", e); + Timber.d(e, "getKeyImpl"); return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, e.getMessage()); } } @@ -776,7 +777,7 @@ public class OpenPgpService extends Service { return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, errorMsg); } } catch (Exception e) { - Log.d(Constants.TAG, "backupImpl", e); + Timber.d(e, "backupImpl"); return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, e.getMessage()); } } @@ -797,7 +798,7 @@ public class OpenPgpService extends Service { result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); return result; } catch (Exception e) { - Log.d(Constants.TAG, "exception in updateAutocryptPeerImpl", e); + Timber.d(e, "exception in updateAutocryptPeerImpl"); return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, e.getMessage()); } } @@ -870,7 +871,8 @@ public class OpenPgpService extends Service { private final IOpenPgpService.Stub mBinder = new IOpenPgpService.Stub() { @Override public Intent execute(Intent data, ParcelFileDescriptor input, ParcelFileDescriptor output) { - Log.w(Constants.TAG, "You are using a deprecated service which may lead to truncated data on return, please use IOpenPgpService2!"); + Timber.w( + "You are using a deprecated service which may lead to truncated data on return, please use IOpenPgpService2!"); return executeInternal(data, input, output); } @@ -900,14 +902,14 @@ public class OpenPgpService extends Service { try { inputStream.close(); } catch (IOException e) { - Log.e(Constants.TAG, "IOException when closing input ParcelFileDescriptor", e); + Timber.e(e, "IOException when closing input ParcelFileDescriptor"); } } if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { - Log.e(Constants.TAG, "IOException when closing output ParcelFileDescriptor", e); + Timber.e(e, "IOException when closing output ParcelFileDescriptor"); } } } @@ -943,7 +945,8 @@ public class OpenPgpService extends Service { } case OpenPgpApi.ACTION_SIGN: { // DEPRECATED: same as ACTION_CLEARTEXT_SIGN - Log.w(Constants.TAG, "You are using a deprecated API call, please use ACTION_CLEARTEXT_SIGN instead of ACTION_SIGN!"); + Timber.w( + "You are using a deprecated API call, please use ACTION_CLEARTEXT_SIGN instead of ACTION_SIGN!"); return signImpl(data, inputStream, outputStream, true); } case OpenPgpApi.ACTION_DETACHED_SIGN: { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService2.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService2.java index 58d7b9dd1..81a1b0070 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService2.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService2.java @@ -23,8 +23,7 @@ import android.os.IBinder; import android.os.ParcelFileDescriptor; import org.openintents.openpgp.IOpenPgpService2; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.IOException; import java.util.HashMap; @@ -48,7 +47,7 @@ public class OpenPgpService2 extends OpenPgpService { mOutputPipeMap.put(createKey(outputPipeId), pipe[1]); return pipe[0]; } catch (IOException e) { - Log.e(Constants.TAG, "IOException in OpenPgpService2", e); + Timber.e(e, "IOException in OpenPgpService2"); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpServiceKeyIdExtractor.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpServiceKeyIdExtractor.java index 84fcf2e61..7f38c555e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpServiceKeyIdExtractor.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpServiceKeyIdExtractor.java @@ -31,12 +31,11 @@ import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; import org.openintents.openpgp.util.OpenPgpApi; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAutocryptPeer; import org.sufficientlysecure.keychain.provider.KeychainExternalContract; import org.sufficientlysecure.keychain.provider.KeychainExternalContract.AutocryptStatus; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; class OpenPgpServiceKeyIdExtractor { @@ -158,7 +157,7 @@ class OpenPgpServiceKeyIdExtractor { } if (userIdEntries.size() != encryptionAddresses.length) { - Log.e(Constants.TAG, "Number of rows doesn't match number of retrieved rows! Probably a bug?"); + Timber.e("Number of rows doesn't match number of retrieved rows! Probably a bug?"); } allKeysConfirmed = !anyKeyNotVerified; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/SshAuthenticationService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/SshAuthenticationService.java index 0aca6e657..df287d6d9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/SshAuthenticationService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/SshAuthenticationService.java @@ -48,6 +48,7 @@ import org.sufficientlysecure.keychain.ssh.AuthenticationOperation; import org.sufficientlysecure.keychain.ssh.AuthenticationParcel; import org.sufficientlysecure.keychain.ssh.AuthenticationResult; import org.sufficientlysecure.keychain.ssh.signature.SshSignatureConverter; +import timber.log.Timber; import java.security.NoSuchAlgorithmException; import java.security.PublicKey; @@ -412,7 +413,7 @@ public class SshAuthenticationService extends Service { } private Intent createErrorResult(int errorCode, String errorMessage) { - Log.e(TAG, errorMessage); + Timber.e(errorMessage); Intent result = new Intent(); result.putExtra(SshAuthenticationApi.EXTRA_ERROR, new SshAuthenticationApiError(errorCode, errorMessage)); result.putExtra(SshAuthenticationApi.EXTRA_RESULT_CODE, SshAuthenticationApi.RESULT_CODE_ERROR); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java index b499374b5..c89a4495d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java @@ -35,7 +35,6 @@ import android.widget.ImageView; import android.widget.TextView; import org.bouncycastle.util.encoders.Hex; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.provider.ApiDataAccessObject; @@ -43,7 +42,8 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.remote.AppSettings; import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.dialog.AdvancedAppSettingsDialogFragment; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class AppSettingsActivity extends BaseActivity { private Uri mAppUri; @@ -82,12 +82,12 @@ public class AppSettingsActivity extends BaseActivity { Intent intent = getIntent(); mAppUri = intent.getData(); if (mAppUri == null) { - Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!"); + Timber.e("Intent data missing. Should be Uri of app!"); finish(); return; } - Log.d(Constants.TAG, "uri: " + mAppUri); + Timber.d("uri: %s", mAppUri); loadData(savedInstanceState, mAppUri); } @@ -142,7 +142,7 @@ public class AppSettingsActivity extends BaseActivity { byte[] digest = md.digest(); certificate = new String(Hex.encode(digest)); } catch (NoSuchAlgorithmException e) { - Log.e(Constants.TAG, "Should not happen!", e); + Timber.e(e, "Should not happen!"); } AdvancedAppSettingsDialogFragment dialogFragment = @@ -163,7 +163,7 @@ public class AppSettingsActivity extends BaseActivity { i.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(i); } catch (PackageManager.NameNotFoundException e) { - Log.e(Constants.TAG, "startApp", e); + Timber.e(e, "startApp"); } } @@ -187,7 +187,7 @@ public class AppSettingsActivity extends BaseActivity { mAppIconView.setImageDrawable(appIcon); Uri allowedKeysUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ALLOWED_KEYS).build(); - Log.d(Constants.TAG, "allowedKeysUri: " + allowedKeysUri); + Timber.d("allowedKeysUri: " + allowedKeysUri); startListFragments(savedInstanceState, allowedKeysUri); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java index ab0f95236..9f5556516 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java @@ -33,7 +33,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ListView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.ListFragmentWorkaround; import org.sufficientlysecure.keychain.provider.ApiDataAccessObject; @@ -41,7 +40,8 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter; import org.sufficientlysecure.keychain.ui.adapter.KeySelectableAdapter; import org.sufficientlysecure.keychain.ui.widget.FixedListView; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class AppSettingsAllowedKeysListFragment extends ListFragmentWorkaround implements LoaderManager.LoaderCallbacks { private static final String ARG_DATA_URI = "uri"; @@ -143,7 +143,7 @@ public class AppSettingsAllowedKeysListFragment extends ListFragmentWorkaround i try { mApiDao.saveAllowedKeyIdsForApp(mDataUri, getSelectedMasterKeyIds()); } catch (RemoteException | OperationApplicationException e) { - Log.e(Constants.TAG, "Problem saving allowed key ids!", e); + Timber.e(e, "Problem saving allowed key ids!"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsHeaderFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsHeaderFragment.java index 80ce63a49..6420211a8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsHeaderFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsHeaderFragment.java @@ -30,10 +30,9 @@ import android.widget.ImageView; import android.widget.TextView; import org.bouncycastle.util.encoders.Hex; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.remote.AppSettings; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -100,7 +99,7 @@ public class AppSettingsHeaderFragment extends Fragment { mPackageCertificate.setText(signature); } catch (NoSuchAlgorithmException e) { - Log.e(Constants.TAG, "Should not happen!", e); + Timber.e(e, "Should not happen!"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java index a4ee04ea8..f1e125c43 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java @@ -41,11 +41,11 @@ import android.widget.AdapterView.OnItemClickListener; import android.widget.ImageView; import android.widget.TextView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class AppsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks, OnItemClickListener { @@ -106,7 +106,7 @@ public class AppsListFragment extends ListFragment implements i.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(i); } catch (PackageManager.NameNotFoundException e) { - Log.e(Constants.TAG, "startApp", e); + Timber.e(e, "startApp"); } } } else { @@ -326,7 +326,7 @@ public class AppsListFragment extends ListFragment implements ImageView installIcon = (ImageView) view.findViewById(R.id.api_apps_adapter_install_icon); String packageName = cursor.getString(INDEX_PACKAGE_NAME); - Log.d(Constants.TAG, "packageName: " + packageName); + Timber.d("packageName: " + packageName); int installed = cursor.getInt(INDEX_INSTALLED); String name = cursor.getString(INDEX_NAME); int iconResName = cursor.getInt(INDEX_ICON_RES_ID); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteRegisterPresenter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteRegisterPresenter.java index f99786a2a..e753654ab 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteRegisterPresenter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteRegisterPresenter.java @@ -25,11 +25,10 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.drawable.Drawable; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.ApiDataAccessObject; import org.sufficientlysecure.keychain.remote.AppSettings; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; class RemoteRegisterPresenter { @@ -61,7 +60,7 @@ class RemoteRegisterPresenter { try { setPackageInfo(packageName); } catch (NameNotFoundException e) { - Log.e(Constants.TAG, "Unable to find info of calling app!"); + Timber.e("Unable to find info of calling app!"); view.finishAsCancelled(); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RequestKeyPermissionPresenter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RequestKeyPermissionPresenter.java index efd138786..a3c4e1bad 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RequestKeyPermissionPresenter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RequestKeyPermissionPresenter.java @@ -26,7 +26,6 @@ import android.graphics.drawable.Drawable; import android.support.annotation.Nullable; import org.openintents.openpgp.util.OpenPgpUtils.UserId; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; @@ -37,7 +36,7 @@ import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.remote.ApiPermissionHelper; import org.sufficientlysecure.keychain.remote.ApiPermissionHelper.WrongPackageCertificateException; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; class RequestKeyPermissionPresenter { @@ -83,7 +82,7 @@ class RequestKeyPermissionPresenter { try { setPackageInfo(packageName); } catch (NameNotFoundException e) { - Log.e(Constants.TAG, "Unable to find info of calling app!"); + Timber.e("Unable to find info of calling app!"); view.finishAsCancelled(); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdActivity.java index 95ad8af1a..cff81bf01 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdActivity.java @@ -25,14 +25,12 @@ import android.view.View; import android.widget.TextView; import org.openintents.openpgp.util.OpenPgpApi; -import org.openintents.openpgp.util.OpenPgpUtils; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult; -import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.ui.base.BaseActivity; -import org.sufficientlysecure.keychain.ui.CreateKeyActivity; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class SelectSignKeyIdActivity extends BaseActivity { @@ -74,10 +72,10 @@ public class SelectSignKeyIdActivity extends BaseActivity { mPreferredUserId = intent.getStringExtra(EXTRA_USER_ID); mData = intent.getParcelableExtra(EXTRA_DATA); if (appUri == null) { - Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!"); + Timber.e("Intent data missing. Should be Uri of app!"); finish(); } else { - Log.d(Constants.TAG, "uri: " + appUri); + Timber.d("uri: " + appUri); startListFragments(savedInstanceState, appUri, mData, mPreferredUserId); } } @@ -123,7 +121,7 @@ public class SelectSignKeyIdActivity extends BaseActivity { // EditKeyResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT); // mSelectKeySpinner.setSelectedKeyId(result.mMasterKeyId); } else { - Log.e(Constants.TAG, "missing result!"); + Timber.e("missing result!"); } } break; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdListFragment.java index 1cd9f6cb0..7ddbdd82e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdListFragment.java @@ -30,7 +30,6 @@ import android.support.v7.widget.LinearLayoutManager; import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpUtils; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.provider.ApiDataAccessObject; @@ -40,7 +39,8 @@ import org.sufficientlysecure.keychain.remote.ui.adapter.SelectSignKeyAdapter; import org.sufficientlysecure.keychain.ui.CreateKeyActivity; import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter; import org.sufficientlysecure.keychain.ui.base.RecyclerFragment; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class SelectSignKeyIdListFragment extends RecyclerFragment implements SelectSignKeyAdapter.SelectSignKeyListener, LoaderManager.LoaderCallbacks { @@ -182,8 +182,8 @@ public class SelectSignKeyIdListFragment extends RecyclerFragment> { @@ -68,7 +67,7 @@ class RemoteDeduplicatePresenter implements LoaderCallbacks> { try { setPackageInfo(packageName); } catch (NameNotFoundException e) { - Log.e(Constants.TAG, "Unable to find info of calling app!"); + Timber.e("Unable to find info of calling app!"); view.finishAsCancelled(); return; } @@ -113,11 +112,11 @@ class RemoteDeduplicatePresenter implements LoaderCallbacks> { void onClickSelect() { if (keyInfoData == null) { - Log.e(Constants.TAG, "got click on select with no data…?"); + Timber.e("got click on select with no data…?"); return; } if (selectedItem == null) { - Log.e(Constants.TAG, "got click on select with no selection…?"); + Timber.e("got click on select with no selection…?"); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/dialog/RemoteSelectAuthenticationKeyPresenter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/dialog/RemoteSelectAuthenticationKeyPresenter.java index 2b202fb25..98d4fe857 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/dialog/RemoteSelectAuthenticationKeyPresenter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/dialog/RemoteSelectAuthenticationKeyPresenter.java @@ -28,11 +28,10 @@ import android.support.v4.app.LoaderManager; import android.support.v4.app.LoaderManager.LoaderCallbacks; import android.support.v4.content.Loader; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.remote.ui.dialog.KeyLoader.KeyInfo; import org.sufficientlysecure.keychain.remote.ui.dialog.KeyLoader.KeySelector; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.util.List; @@ -64,7 +63,7 @@ class RemoteSelectAuthenticationKeyPresenter implements LoaderCallbacks 0) { - Log.e(Constants.TAG, - "Skipped " + ignoredBytes + " bytes: " + Hex.toHexString(inputBuffer, 0, ignoredBytes)); + Timber.e("Skipped " + ignoredBytes + " bytes: " + toHexString(inputBuffer, 0, ignoredBytes)); } } while (ignoredBytes > 0); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/usb/UsbTransport.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/usb/UsbTransport.java index 2b27d1fef..917459a3b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/usb/UsbTransport.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/usb/UsbTransport.java @@ -31,7 +31,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Pair; -import org.bouncycastle.util.encoders.Hex; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.securitytoken.CommandApdu; import org.sufficientlysecure.keychain.securitytoken.ResponseApdu; @@ -39,8 +38,10 @@ import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo; import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo.TokenType; import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo.TransportType; import org.sufficientlysecure.keychain.securitytoken.Transport; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + +import static org.bouncycastle.util.encoders.Hex.toHexString; /** @@ -98,7 +99,7 @@ public class UsbTransport implements Transport { usbConnection = null; } - Log.d(Constants.TAG, "Usb transport disconnected"); + Timber.d("Usb transport disconnected"); } /** @@ -158,7 +159,7 @@ public class UsbTransport implements Transport { } CcidDescription ccidDescription = CcidDescription.fromRawDescriptors(usbConnection.getRawDescriptors()); - Log.d(Constants.TAG, "CCID Description: " + ccidDescription); + Timber.d("CCID Description: " + ccidDescription); CcidTransceiver transceiver = new CcidTransceiver(usbConnection, usbBulkIn, usbBulkOut, ccidDescription); ccidTransportProtocol = ccidDescription.getSuitableTransportProtocol(); @@ -175,12 +176,12 @@ public class UsbTransport implements Transport { public ResponseApdu transceive(CommandApdu data) throws UsbTransportException { byte[] rawCommand = data.toBytes(); if (Constants.DEBUG) { - Log.d(Constants.TAG, "USB >> " + Hex.toHexString(rawCommand)); + Timber.d("USB >> " + toHexString(rawCommand)); } byte[] rawResponse = ccidTransportProtocol.transceive(rawCommand); if (Constants.DEBUG) { - Log.d(Constants.TAG, "USB << " + Hex.toHexString(rawResponse)); + Timber.d("USB << " + toHexString(rawResponse)); } return ResponseApdu.fromBytes(rawResponse); @@ -252,7 +253,7 @@ public class UsbTransport implements Transport { } } - Log.d(Constants.TAG, "Unknown USB token. Vendor ID: " + usbDevice.getVendorId() + ", Product ID: " + + Timber.d("Unknown USB token. Vendor ID: " + usbDevice.getVendorId() + ", Product ID: " + usbDevice.getProductId()); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/usb/tpdu/T1TpduProtocol.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/usb/tpdu/T1TpduProtocol.java index f159f5f24..4fa786715 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/usb/tpdu/T1TpduProtocol.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/usb/tpdu/T1TpduProtocol.java @@ -21,12 +21,12 @@ package org.sufficientlysecure.keychain.securitytoken.usb.tpdu; import android.support.annotation.NonNull; import org.bouncycastle.util.Arrays; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.securitytoken.usb.CcidTransceiver; import org.sufficientlysecure.keychain.securitytoken.usb.CcidTransceiver.CcidDataBlock; import org.sufficientlysecure.keychain.securitytoken.usb.CcidTransportProtocol; import org.sufficientlysecure.keychain.securitytoken.usb.UsbTransportException; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + /* T=1 Protocol, see http://www.icedev.se/proxmark3/docs/ISO-7816.pdf, Part 11 */ public class T1TpduProtocol implements CcidTransportProtocol { @@ -94,10 +94,10 @@ public class T1TpduProtocol implements CcidTransportProtocol { sentLength += len; if (responseBlock instanceof SBlock) { - Log.d(Constants.TAG, "S-Block received " + responseBlock); + Timber.d("S-Block received " + responseBlock); // just ignore } else if (responseBlock instanceof RBlock) { - Log.d(Constants.TAG, "R-Block received " + responseBlock); + Timber.d("R-Block received " + responseBlock); if (((RBlock) responseBlock).getError() != RBlock.RError.NO_ERROR) { throw new UsbTransportException("R-Block reports error " + ((RBlock) responseBlock).getError()); } @@ -123,7 +123,7 @@ public class T1TpduProtocol implements CcidTransportProtocol { Block responseBlock = blockFactory.fromBytes(response.getData()); if (!(responseBlock instanceof IBlock)) { - Log.e(Constants.TAG, "Invalid response block received " + responseBlock); + Timber.e("Invalid response block received " + responseBlock); throw new UsbTransportException("Response: invalid state - invalid block received"); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java index 6a7a04947..6c81d8fb8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java @@ -41,7 +41,8 @@ import org.sufficientlysecure.keychain.KeychainApplication; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.SettingsActivity; import org.sufficientlysecure.keychain.util.ContactHelper; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class ContactSyncAdapterService extends Service { @@ -58,7 +59,7 @@ public class ContactSyncAdapterService extends Service { @Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, final SyncResult syncResult) { - Log.d(Constants.TAG, "Performing a contact sync!"); + Timber.d("Performing a contact sync!"); new ContactHelper(ContactSyncAdapterService.this).writeKeysToContacts(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/DummyAccountService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/DummyAccountService.java index 54ff61a44..14b0db553 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/DummyAccountService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/DummyAccountService.java @@ -30,9 +30,9 @@ import android.os.IBinder; import android.os.Message; import android.widget.Toast; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + /** * This service actually does nothing, it's sole task is to show a Toast if the use tries to create an account. @@ -75,7 +75,7 @@ public class DummyAccountService extends Service { @Override public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) { - Log.d(Constants.TAG, "DummyAccountService.editProperties"); + Timber.d("DummyAccountService.editProperties"); return null; } @@ -84,41 +84,41 @@ public class DummyAccountService extends Service { String[] requiredFeatures, Bundle options) throws NetworkErrorException { response.onResult(new Bundle()); toaster.toast(R.string.account_no_manual_account_creation); - Log.d(Constants.TAG, "DummyAccountService.addAccount"); + Timber.d("DummyAccountService.addAccount"); return null; } @Override public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) throws NetworkErrorException { - Log.d(Constants.TAG, "DummyAccountService.confirmCredentials"); + Timber.d("DummyAccountService.confirmCredentials"); return null; } @Override public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException { - Log.d(Constants.TAG, "DummyAccountService.getAuthToken"); + Timber.d("DummyAccountService.getAuthToken"); return null; } @Override public String getAuthTokenLabel(String authTokenType) { - Log.d(Constants.TAG, "DummyAccountService.getAuthTokenLabel"); + Timber.d("DummyAccountService.getAuthTokenLabel"); return null; } @Override public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException { - Log.d(Constants.TAG, "DummyAccountService.updateCredentials"); + Timber.d("DummyAccountService.updateCredentials"); return null; } @Override public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) throws NetworkErrorException { - Log.d(Constants.TAG, "DummyAccountService.hasFeatures"); + Timber.d("DummyAccountService.hasFeatures"); return null; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainService.java index 8f7dede98..2c82f1c71 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainService.java @@ -29,7 +29,6 @@ import android.os.Messenger; import android.os.Parcelable; import android.os.RemoteException; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.operations.BackupOperation; import org.sufficientlysecure.keychain.operations.BaseOperation; import org.sufficientlysecure.keychain.operations.BenchmarkOperation; @@ -52,7 +51,8 @@ import org.sufficientlysecure.keychain.pgp.SignEncryptParcel; import org.sufficientlysecure.keychain.provider.KeyWritableRepository; import org.sufficientlysecure.keychain.service.ServiceProgressHandler.MessageStatus; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + /** * This Service contains all important long lasting operations for OpenKeychain. It receives Intents with @@ -172,9 +172,9 @@ public class KeychainService extends Service implements Progressable { try { mMessenger.get().send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } @@ -193,7 +193,7 @@ public class KeychainService extends Service implements Progressable { */ @Override public void setProgress(String message, int progress, int max) { - Log.d(Constants.TAG, "Send message by setProgress with progress=" + progress + ", max=" + Timber.d("Send message by setProgress with progress=" + progress + ", max=" + max); Bundle data = new Bundle(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java index 0a306876e..2a763c105 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java @@ -66,9 +66,10 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.ui.OrbotRequiredDialogActivity; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + public class KeyserverSyncAdapterService extends Service { @@ -215,7 +216,7 @@ public class KeyserverSyncAdapterService extends Service { return; } } - Log.d(Constants.TAG, "Performing a keyserver sync!"); + Timber.d("Performing a keyserver sync!"); PowerManager pm = (PowerManager) KeyserverSyncAdapterService.this .getSystemService(Context.POWER_SERVICE); @SuppressWarnings("deprecation") // our min is API 15, deprecated only in 20 @@ -249,7 +250,7 @@ public class KeyserverSyncAdapterService extends Service { */ private void handleUpdateResult(ImportKeyResult result, final int startId) { if (result.isPending()) { - Log.d(Constants.TAG, "Orbot required for sync but not running, attempting to start"); + Timber.d("Orbot required for sync but not running, attempting to start"); // result is pending due to Orbot not being started // try to start it silently, if disabled show notifications new OrbotHelper.SilentStartManager() { @@ -275,13 +276,13 @@ public class KeyserverSyncAdapterService extends Service { // if we're killed before we get a response from Orbot, we need the intent to be // redelivered, so no stopSelf(int) here } else if (isUpdateCancelled()) { - Log.d(Constants.TAG, "Keyserver sync cancelled, postponing by" + SYNC_POSTPONE_TIME + Timber.d("Keyserver sync cancelled, postponing by" + SYNC_POSTPONE_TIME + "ms"); postponeSync(); // postponeSync creates a new intent, so we don't need this to be redelivered stopSelf(startId); } else { - Log.d(Constants.TAG, "Keyserver sync completed: Updated: " + result.mUpdatedKeys + Timber.d("Keyserver sync completed: Updated: " + result.mUpdatedKeys + " Failed: " + result.mBadKeys); // key sync completed successfully, we can stop stopSelf(startId); @@ -337,7 +338,7 @@ public class KeyserverSyncAdapterService extends Service { private ImportKeyResult directUpdate(Context context, ArrayList keyList, CryptoInputParcel cryptoInputParcel) { - Log.d(Constants.TAG, "Starting normal update"); + Timber.d("Starting normal update"); ImportOperation importOp = new ImportOperation(context, KeyWritableRepository.create(context), null); return importOp.execute( @@ -356,7 +357,7 @@ public class KeyserverSyncAdapterService extends Service { */ private ImportKeyResult staggeredUpdate(Context context, ArrayList keyList, CryptoInputParcel cryptoInputParcel) { - Log.d(Constants.TAG, "Starting staggered update"); + Timber.d("Starting staggered update"); // final int WEEK_IN_SECONDS = (int) TimeUnit.DAYS.toSeconds(7); // we are limiting our randomness to ORBOT_CIRCUIT_TIMEOUT_SECONDS for now final int WEEK_IN_SECONDS = 0; @@ -383,11 +384,11 @@ public class KeyserverSyncAdapterService extends Service { first = false; } - Log.d(Constants.TAG, "Updating key with a wait time of " + waitTime + "s"); + Timber.d("Updating key with a wait time of " + waitTime + "s"); try { Thread.sleep(waitTime * 1000); } catch (InterruptedException e) { - Log.e(Constants.TAG, "Exception during sleep between key updates", e); + Timber.e(e, "Exception during sleep between key updates"); // skip this one continue; } @@ -445,7 +446,7 @@ public class KeyserverSyncAdapterService extends Service { ArrayList ignoreMasterKeyIds = new ArrayList<>(); while (updatedKeysCursor != null && updatedKeysCursor.moveToNext()) { long masterKeyId = updatedKeysCursor.getLong(INDEX_UPDATED_KEYS_MASTER_KEY_ID); - Log.d(Constants.TAG, "Keyserver sync: Ignoring {" + masterKeyId + "} last updated at {" + Timber.d("Keyserver sync: Ignoring {" + masterKeyId + "} last updated at {" + updatedKeysCursor.getLong(INDEX_LAST_UPDATED) + "}s"); ignoreMasterKeyIds.add(masterKeyId); } @@ -477,7 +478,7 @@ public class KeyserverSyncAdapterService extends Service { if (ignoreMasterKeyIds.contains(keyId)) { continue; } - Log.d(Constants.TAG, "Keyserver sync: Updating {" + keyId + "}"); + Timber.d("Keyserver sync: Updating {" + keyId + "}"); byte[] fingerprint = keyCursor.getBlob(INDEX_FINGERPRINT); String hexKeyId = KeyFormattingUtils.convertKeyIdToHex(keyId); // we aren't updating from keybase as of now diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index a0c24adee..8945a3652 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -42,9 +42,9 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing; import org.sufficientlysecure.keychain.provider.KeyRepository; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; import java.util.Date; @@ -122,7 +122,7 @@ public class PassphraseCacheService extends Service { Passphrase passphrase, String primaryUserId, int timeToLiveSeconds) { - Log.d(Constants.TAG, "PassphraseCacheService.addCachedPassphrase() for " + masterKeyId); + Timber.d("PassphraseCacheService.addCachedPassphrase() for " + masterKeyId); Intent intent = new Intent(context, PassphraseCacheService.class); intent.setAction(ACTION_PASSPHRASE_CACHE_ADD); @@ -137,7 +137,7 @@ public class PassphraseCacheService extends Service { } public static void clearCachedPassphrase(Context context, long masterKeyId, long subKeyId) { - Log.d(Constants.TAG, "PassphraseCacheService.clearCachedPassphrase() for " + masterKeyId); + Timber.d("PassphraseCacheService.clearCachedPassphrase() for " + masterKeyId); Intent intent = new Intent(context, PassphraseCacheService.class); intent.setAction(ACTION_PASSPHRASE_CACHE_CLEAR); @@ -149,7 +149,7 @@ public class PassphraseCacheService extends Service { } public static void clearCachedPassphrases(Context context) { - Log.d(Constants.TAG, "PassphraseCacheService.clearCachedPassphrase()"); + Timber.d("PassphraseCacheService.clearCachedPassphrase()"); Intent intent = new Intent(context, PassphraseCacheService.class); intent.setAction(ACTION_PASSPHRASE_CACHE_CLEAR); @@ -164,7 +164,7 @@ public class PassphraseCacheService extends Service { * @return passphrase or null (if no passphrase is cached for this keyId) */ public static Passphrase getCachedPassphrase(Context context, long masterKeyId, long subKeyId) throws KeyNotFoundException { - Log.d(Constants.TAG, "PassphraseCacheService.getCachedPassphrase() for masterKeyId " + Timber.d("PassphraseCacheService.getCachedPassphrase() for masterKeyId " + masterKeyId + ", subKeyId " + subKeyId); Intent intent = new Intent(context, PassphraseCacheService.class); @@ -216,7 +216,7 @@ public class PassphraseCacheService extends Service { case MSG_PASSPHRASE_CACHE_GET_KEY_NOT_FOUND: throw new KeyNotFoundException(); default: - Log.e(Constants.TAG, "timeout case!"); + Timber.e("timeout case!"); throw new KeyNotFoundException("should not happen!"); } } @@ -232,7 +232,7 @@ public class PassphraseCacheService extends Service { // passphrase for symmetric encryption? if (masterKeyId == Constants.key.symmetric) { - Log.d(Constants.TAG, "PassphraseCacheService.getCachedPassphraseImpl() for symmetric encryption"); + Timber.d("PassphraseCacheService.getCachedPassphraseImpl() for symmetric encryption"); CachedPassphrase cachedPassphrase = mPassphraseCache.get(Constants.key.symmetric); if (cachedPassphrase == null) { return null; @@ -241,7 +241,7 @@ public class PassphraseCacheService extends Service { } // try to get master key id which is used as an identifier for cached passphrases - Log.d(Constants.TAG, "PassphraseCacheService.getCachedPassphraseImpl() for masterKeyId " + Timber.d("PassphraseCacheService.getCachedPassphraseImpl() for masterKeyId " + masterKeyId + ", subKeyId " + subKeyId); // get the type of key (from the database) @@ -263,13 +263,13 @@ public class PassphraseCacheService extends Service { // If we cache strictly by subkey, exit early if (Preferences.getPreferences(mContext).getPassphraseCacheSubs()) { - Log.d(Constants.TAG, "PassphraseCacheService: specific subkey passphrase not (yet) cached, returning null"); + Timber.d("PassphraseCacheService: specific subkey passphrase not (yet) cached, returning null"); // not really an error, just means the passphrase is not cached but not empty either return null; } if (subKeyId == masterKeyId) { - Log.d(Constants.TAG, "PassphraseCacheService: masterkey passphrase not (yet) cached, returning null"); + Timber.d("PassphraseCacheService: masterkey passphrase not (yet) cached, returning null"); // not really an error, just means the passphrase is not cached but not empty either return null; } @@ -277,7 +277,7 @@ public class PassphraseCacheService extends Service { cachedPassphrase = mPassphraseCache.get(masterKeyId); // If we cache strictly by subkey, exit early if (cachedPassphrase == null) { - Log.d(Constants.TAG, "PassphraseCacheService: keyring passphrase not (yet) cached, returning null"); + Timber.d("PassphraseCacheService: keyring passphrase not (yet) cached, returning null"); // not really an error, just means the passphrase is not cached but not empty either return null; } @@ -299,7 +299,7 @@ public class PassphraseCacheService extends Service { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); - Log.d(Constants.TAG, "PassphraseCacheService: Received broadcast..."); + Timber.d("PassphraseCacheService: Received broadcast..."); if (action.equals(BROADCAST_ACTION_PASSPHRASE_CACHE_SERVICE)) { long keyId = intent.getLongExtra(EXTRA_KEY_ID, -1); @@ -335,7 +335,7 @@ public class PassphraseCacheService extends Service { */ @Override public int onStartCommand(Intent intent, int flags, int startId) { - Log.d(Constants.TAG, "PassphraseCacheService.onStartCommand()"); + Timber.d("PassphraseCacheService.onStartCommand()"); if (intent == null || intent.getAction() == null) { updateService(); @@ -352,10 +352,10 @@ public class PassphraseCacheService extends Service { Passphrase passphrase = intent.getParcelableExtra(EXTRA_PASSPHRASE); String primaryUserID = intent.getStringExtra(EXTRA_USER_ID); - Log.d(Constants.TAG, + Timber.d( "PassphraseCacheService: Received ACTION_PASSPHRASE_CACHE_ADD intent in onStartCommand() with masterkeyId: " - + masterKeyId + ", subKeyId: " + subKeyId + ", ttl: " + timeoutTtl + ", usrId: " + primaryUserID - ); + + masterKeyId + ", subKeyId: " + subKeyId + ", ttl: " + timeoutTtl + ", usrId: " + + primaryUserID); // if we don't cache by specific subkey id, or the requested subkey is the master key, // just add master key id to the cache, otherwise, add this specific subkey to the cache @@ -389,7 +389,7 @@ public class PassphraseCacheService extends Service { try { // If only one of these is symmetric, error out! if (masterKeyId == Constants.key.symmetric ^ subKeyId == Constants.key.symmetric) { - Log.e(Constants.TAG, "PassphraseCacheService: Bad request, missing masterKeyId or subKeyId!"); + Timber.e("PassphraseCacheService: Bad request, missing masterKeyId or subKeyId!"); msg.what = MSG_PASSPHRASE_CACHE_GET_KEY_NOT_FOUND; } else { Passphrase passphrase = getCachedPassphraseImpl(masterKeyId, subKeyId); @@ -399,14 +399,14 @@ public class PassphraseCacheService extends Service { msg.setData(bundle); } } catch (KeyRepository.NotFoundException e) { - Log.e(Constants.TAG, "PassphraseCacheService: Passphrase for unknown key was requested!"); + Timber.e("PassphraseCacheService: Passphrase for unknown key was requested!"); msg.what = MSG_PASSPHRASE_CACHE_GET_KEY_NOT_FOUND; } try { messenger.send(msg); } catch (RemoteException e) { - Log.e(Constants.TAG, "PassphraseCacheService: Sending message failed", e); + Timber.e(e, "PassphraseCacheService: Sending message failed"); } break; } @@ -440,7 +440,7 @@ public class PassphraseCacheService extends Service { break; } default: { - Log.e(Constants.TAG, "PassphraseCacheService: Intent or Intent Action not supported!"); + Timber.e("PassphraseCacheService: Intent or Intent Action not supported!"); break; } } @@ -463,7 +463,7 @@ public class PassphraseCacheService extends Service { mPassphraseCache.remove(keyId); } - Log.d(Constants.TAG, "PassphraseCacheService Timeout of keyId " + keyId + ", removed from memory!"); + Timber.d("PassphraseCacheService Timeout of keyId " + keyId + ", removed from memory!"); updateService(); } @@ -481,7 +481,7 @@ public class PassphraseCacheService extends Service { i += 1; } - Log.d(Constants.TAG, "PassphraseCacheService Removing all cached-until-lock passphrases from memory!"); + Timber.d("PassphraseCacheService Removing all cached-until-lock passphrases from memory!"); updateService(); } @@ -491,7 +491,7 @@ public class PassphraseCacheService extends Service { startForeground(Constants.Notification.PASSPHRASE_CACHE, getNotification()); } else { // stop whole service if no cached passphrases remaining - Log.d(Constants.TAG, "PassphraseCacheService: No passphrases remaining in memory, stopping service!"); + Timber.d("PassphraseCacheService: No passphrases remaining in memory, stopping service!"); stopForeground(true); stopSelf(); } @@ -544,7 +544,7 @@ public class PassphraseCacheService extends Service { public void onCreate() { super.onCreate(); mContext = this; - Log.d(Constants.TAG, "PassphraseCacheService, onCreate()"); + Timber.d("PassphraseCacheService, onCreate()"); registerReceiver(); } @@ -552,7 +552,7 @@ public class PassphraseCacheService extends Service { @Override public void onDestroy() { super.onDestroy(); - Log.d(Constants.TAG, "PassphraseCacheService, onDestroy()"); + Timber.d("PassphraseCacheService, onDestroy()"); unregisterReceiver(mIntentReceiver); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java index 4212e328a..544d2e77c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java @@ -25,11 +25,11 @@ import android.os.Message; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment; import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class ServiceProgressHandler extends Handler { @@ -144,7 +144,7 @@ public class ServiceProgressHandler extends Handler { break; default: - Log.e(Constants.TAG, "unknown handler message!"); + Timber.e("unknown handler message!"); break; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ssh/AuthenticationOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ssh/AuthenticationOperation.java index 2a37913a4..3df7f8724 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ssh/AuthenticationOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ssh/AuthenticationOperation.java @@ -33,11 +33,14 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.provider.KeyRepository; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.service.input.RequiredInputParcel; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; +import timber.log.Timber; import java.util.Collection; +import static java.lang.String.format; + + /** * This class supports a single, low-level, authentication operation. *

@@ -83,7 +86,7 @@ public class AuthenticationOperation extends BaseOperation log.add(LogType.MSG_AUTH, indent); indent += 1; - Log.d(TAG, data.toString()); + Timber.d(data.toString()); long opTime; long startTime = System.currentTimeMillis(); @@ -231,7 +234,7 @@ public class AuthenticationOperation extends BaseOperation } opTime = System.currentTimeMillis() - startTime; - Log.d(TAG, "Authentication operation duration : " + String.format("%.2f", opTime / 1000.0) + "s"); + Timber.d("Authentication operation duration : " + format("%.2f", opTime / 1000.0) + "s"); log.add(LogType.MSG_AUTH_OK, indent); AuthenticationResult result = new AuthenticationResult(AuthenticationResult.RESULT_OK, log); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java index 69a5766da..a80174343 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java @@ -21,10 +21,10 @@ import android.net.Uri; import android.os.Bundle; import android.view.View; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.base.BaseActivity; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class CertifyFingerprintActivity extends BaseActivity { @@ -36,7 +36,7 @@ public class CertifyFingerprintActivity extends BaseActivity { mDataUri = getIntent().getData(); if (mDataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be uri of key!"); + Timber.e("Data missing. Should be uri of key!"); finish(); return; } @@ -48,7 +48,7 @@ public class CertifyFingerprintActivity extends BaseActivity { } }); - Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + Timber.i("mDataUri: " + mDataUri.toString()); startFragment(savedInstanceState, mDataUri); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java index fbf1c9faf..cec6e2749 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java @@ -18,11 +18,8 @@ package org.sufficientlysecure.keychain.ui; -import java.io.IOException; - import android.content.Intent; import android.database.Cursor; -import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.LoaderManager; @@ -33,14 +30,13 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.provider.KeyRepository; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.ui.base.LoaderFragment; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; public class CertifyFingerprintFragment extends LoaderFragment implements @@ -106,7 +102,7 @@ public class CertifyFingerprintFragment extends LoaderFragment implements Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + Timber.e("Data missing. Should be Uri of key!"); getActivity().finish(); return; } @@ -117,7 +113,7 @@ public class CertifyFingerprintFragment extends LoaderFragment implements private void loadData(Uri dataUri) { mDataUri = dataUri; - Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + Timber.i("mDataUri: " + mDataUri.toString()); // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. @@ -187,7 +183,7 @@ public class CertifyFingerprintFragment extends LoaderFragment implements .getCachedPublicKeyRing(dataUri) .extractOrGetMasterKeyId(); } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); + Timber.e(e, "key not found!"); } Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class); certifyIntent.putExtras(getActivity().getIntent()); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java index f0964ce31..ded50c64a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java @@ -46,8 +46,9 @@ import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment; import org.sufficientlysecure.keychain.ui.util.FormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + public class CertifyKeyFragment extends CachingCryptoOperationFragment { @@ -75,7 +76,7 @@ public class CertifyKeyFragment mCertifyKeySpinner.setPreSelectedKeyId(certifyKeyId); } } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "certify certify check failed", e); + Timber.e(e, "certify certify check failed"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java index 08d0d5be1..63c1ee7d9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java @@ -52,10 +52,10 @@ import org.sufficientlysecure.keychain.service.UploadKeyringParcel; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction; import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; import org.sufficientlysecure.keychain.util.Passphrase; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; import java.util.Date; import java.util.Iterator; @@ -435,7 +435,7 @@ public class CreateKeyFinalFragment extends Fragment { try { builder = SaveKeyringParcel.buildChangeKeyringParcel(key.getMasterKeyId(), key.getFingerprint()); } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "Key that should be moved to Security Token not found in database!"); + Timber.e("Key that should be moved to Security Token not found in database!"); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyStartFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyStartFragment.java index f439df53d..944c1f0cc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyStartFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyStartFragment.java @@ -32,12 +32,12 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.TextView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction; import org.sufficientlysecure.keychain.ui.transfer.view.TransferFragment; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + public class CreateKeyStartFragment extends Fragment { public static final int REQUEST_CODE_IMPORT_KEY = 0x00007012; @@ -149,7 +149,7 @@ public class CreateKeyStartFragment extends Fragment { } } } else { - Log.e(Constants.TAG, "No valid request code!"); + Timber.e("No valid request code!"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java index 497c572ee..6c7366821 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java @@ -60,6 +60,8 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + public abstract class DecryptFragment extends Fragment implements LoaderManager.LoaderCallbacks { @@ -424,7 +426,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager. int result = mSignatureResult.getResult(); if (result != OpenPgpSignatureResult.RESULT_KEY_MISSING && result != OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE) { - Log.e(Constants.TAG, "got missing status for non-missing key, shouldn't happen!"); + Timber.e("got missing status for non-missing key, shouldn't happen!"); } String userId = mSignatureResult.getPrimaryUserId(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java index 1e99a6d2f..62f9cd693 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java @@ -95,9 +95,9 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.util.FileHelper; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableHashMap; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; /** @@ -321,7 +321,7 @@ public class DecryptListFragment FileHelper.copyUriData(activity, decryptedFileUri, saveUri); Notify.create(activity, R.string.file_saved, Style.OK).show(); } catch (IOException e) { - Log.e(Constants.TAG, "error saving file", e); + Timber.e(e, "error saving file"); Notify.create(activity, R.string.error_saving_file, Style.ERROR).show(); } } @@ -631,7 +631,7 @@ public class DecryptListFragment mCurrentInputUri = mPendingInputUris.remove(0); } - Log.d(Constants.TAG, "mCurrentInputUri=" + mCurrentInputUri); + Timber.d("mCurrentInputUri=" + mCurrentInputUri); if (!checkAndRequestReadPermission(activity, mCurrentInputUri)) { return null; @@ -825,7 +825,7 @@ public class DecryptListFragment Notify.create(activity, R.string.file_delete_none, Style.WARN).show(); } } catch (Exception e) { - Log.e(Constants.TAG, "exception deleting file", e); + Timber.e(e, "exception deleting file"); Notify.create(activity, R.string.file_delete_exception, Style.ERROR).show(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DeleteKeyDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DeleteKeyDialogActivity.java index 944ca50c3..3de2bc495 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DeleteKeyDialogActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DeleteKeyDialogActivity.java @@ -33,7 +33,6 @@ import android.widget.AdapterView; import android.widget.Spinner; import android.widget.TextView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; import org.sufficientlysecure.keychain.operations.results.DeleteResult; @@ -47,7 +46,7 @@ import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder; import org.sufficientlysecure.keychain.ui.util.ThemeChanger; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.util.Date; import java.util.HashMap; @@ -111,9 +110,8 @@ public class DeleteKeyDialogActivity extends FragmentActivity { showRevokeDeleteDialog(name); } } catch (KeyRepository.NotFoundException e) { - Log.e(Constants.TAG, - "Secret key to delete not found at DeleteKeyDialogActivity for " - + mMasterKeyIds[0], e); + Timber.e(e, "Secret key to delete not found at DeleteKeyDialogActivity for " + + mMasterKeyIds[0]); finish(); } } else { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesActivity.java index e0b9ef674..811543990 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesActivity.java @@ -20,10 +20,10 @@ package org.sufficientlysecure.keychain.ui; import android.net.Uri; import android.os.Bundle; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.base.BaseActivity; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class EditIdentitiesActivity extends BaseActivity { @@ -33,7 +33,7 @@ public class EditIdentitiesActivity extends BaseActivity { Uri dataUri = getIntent().getData(); if (dataUri == null) { - Log.e(Constants.TAG, "Either a key Uri or EXTRA_SAVE_KEYRING_PARCEL is required!"); + Timber.e("Either a key Uri or EXTRA_SAVE_KEYRING_PARCEL is required!"); finish(); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesFragment.java index 14a23e2ed..17792a539 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesFragment.java @@ -62,8 +62,9 @@ import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + public class EditIdentitiesFragment extends Fragment implements LoaderManager.LoaderCallbacks { @@ -140,7 +141,7 @@ public class EditIdentitiesFragment extends Fragment Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); if (dataUri == null) { - Log.e(Constants.TAG, "Either a key Uri is required!"); + Timber.e("Either a key Uri is required!"); getActivity().finish(); return; } @@ -164,7 +165,7 @@ public class EditIdentitiesFragment extends Fragment private void loadData(Uri dataUri) { mDataUri = dataUri; - Log.i(Constants.TAG, "mDataUri: " + mDataUri); + Timber.i("mDataUri: " + mDataUri); // load the secret key ring. we do verify here that the passphrase is correct, so cached won't do try { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 21f5c7cf4..7e5995a80 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -20,11 +20,11 @@ package org.sufficientlysecure.keychain.ui; import android.net.Uri; import android.os.Bundle; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.ui.base.BaseActivity; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class EditKeyActivity extends BaseActivity { @@ -39,7 +39,7 @@ public class EditKeyActivity extends BaseActivity { Uri dataUri = getIntent().getData(); SaveKeyringParcel saveKeyringParcel = getIntent().getParcelableExtra(EXTRA_SAVE_KEYRING_PARCEL); if (dataUri == null && saveKeyringParcel == null) { - Log.e(Constants.TAG, "Either a key Uri or EXTRA_SAVE_KEYRING_PARCEL is required!"); + Timber.e("Either a key Uri or EXTRA_SAVE_KEYRING_PARCEL is required!"); finish(); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java index 419d9d422..6b0723544 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java @@ -38,7 +38,6 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ListView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; import org.sufficientlysecure.keychain.operations.results.OperationResult; @@ -68,8 +67,9 @@ import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; +import timber.log.Timber; + public class EditKeyFragment extends QueueingCryptoOperationFragment implements LoaderManager.LoaderCallbacks { @@ -168,7 +168,7 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment { @@ -901,7 +902,7 @@ public class EncryptFilesFragment for (Uri inputUri : inputUris) { ViewModel newModel = new ViewModel(mActivity, inputUri); if (mDataset.contains(newModel)) { - Log.e(Constants.TAG, "Skipped duplicate " + inputUri); + Timber.e("Skipped duplicate " + inputUri); } else { mDataset.add(newModel); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java index 3c5e49616..43154ce1d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java @@ -44,8 +44,9 @@ import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.widget.EncryptKeyCompletionView; import org.sufficientlysecure.keychain.ui.widget.KeySpinner; import org.sufficientlysecure.keychain.ui.widget.KeySpinner.OnKeyChangedListener; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; +import timber.log.Timber; + public class EncryptModeAsymmetricFragment extends EncryptModeFragment { @@ -144,7 +145,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment { mSignKeySpinner.setPreSelectedKeyId(signatureKeyId); } } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found for signing!", e); + Timber.e(e, "key not found for signing!"); Notify.create(getActivity(), getString(R.string.error_preselect_sign_key, KeyFormattingUtils.beautifyKeyId(signatureKeyId)), Style.ERROR).show(); @@ -158,7 +159,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment { mKeyRepository.getCanonicalizedPublicKeyRing(preselectedId); mEncryptKeyView.addObject(new KeyItem(ring)); } catch (NotFoundException e) { - Log.e(Constants.TAG, "key not found for encryption!", e); + Timber.e(e, "key not found for encryption!"); Notify.create(getActivity(), getString(R.string.error_preselect_encrypt_key, KeyFormattingUtils.beautifyKeyId(preselectedId)), Style.ERROR).show(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java index 67effcd7f..2529b343c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java @@ -25,6 +25,7 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; +import android.util.Log; import android.widget.Toast; import org.apache.james.mime4j.util.MimeUtil; @@ -33,7 +34,8 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.util.FileHelper; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class EncryptTextActivity extends EncryptActivity { @@ -63,8 +65,6 @@ public class EncryptTextActivity extends EncryptActivity { // When sending to OpenKeychain Encrypt via share menu if (Intent.ACTION_SEND.equals(action) && type != null) { - Log.logDebugBundle(extras, "extras"); - // When sending to OpenKeychain Encrypt via share menu if ( ! MimeUtil.isSameMimeType("text/plain", type)) { Toast.makeText(this, R.string.toast_wrong_mimetype, Toast.LENGTH_LONG).show(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java index 7f9e02c0e..70d6b98d4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java @@ -30,9 +30,8 @@ import android.widget.TextView; import org.markdown4j.Markdown4jProcessor; import org.sufficientlysecure.htmltextview.HtmlResImageGetter; import org.sufficientlysecure.htmltextview.HtmlTextView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.IOException; @@ -54,7 +53,7 @@ public class HelpAboutFragment extends Fragment { getActivity().getResources().openRawResource(R.raw.help_about)); aboutTextView.setHtml(html, new HtmlResImageGetter(aboutTextView)); } catch (IOException e) { - Log.e(Constants.TAG, "IOException", e); + Timber.e(e, "IOException"); } return view; @@ -73,7 +72,7 @@ public class HelpAboutFragment extends Fragment { result = String.format("%s (%s)", info.versionName, info.versionCode); } catch (NameNotFoundException e) { - Log.w(Constants.TAG, "Unable to get application version: " + e.getMessage()); + Timber.w("Unable to get application version: " + e.getMessage()); result = "Unable to get application version."; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpMarkdownFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpMarkdownFragment.java index f7eb109fa..6adb9b906 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpMarkdownFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpMarkdownFragment.java @@ -28,8 +28,7 @@ import android.widget.ScrollView; import org.markdown4j.Markdown4jProcessor; import org.sufficientlysecure.htmltextview.HtmlResImageGetter; import org.sufficientlysecure.htmltextview.HtmlTextView; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.IOException; @@ -71,7 +70,7 @@ public class HelpMarkdownFragment extends Fragment { getActivity().getResources().openRawResource(mHtmlFile)); text.setHtml(html, new HtmlResImageGetter(text)); } catch (IOException e) { - Log.e(Constants.TAG, "IOException", e); + Timber.e(e, "IOException"); } return scroller; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index 1fd0a0581..f59f5a74e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -42,9 +42,9 @@ import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableFileCache; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; import java.io.IOException; import java.util.ArrayList; @@ -176,7 +176,7 @@ public class ImportKeysActivity extends BaseActivity implements ImportKeysListen // action: search immediately startListFragment(null, null, query, null); } else { - Log.e(Constants.TAG, "Query is empty!"); + Timber.e("Query is empty!"); return; } } else if (extras.containsKey(EXTRA_FINGERPRINT)) { @@ -193,10 +193,8 @@ public class ImportKeysActivity extends BaseActivity implements ImportKeysListen startListFragment(null, null, query, null); } } else { - Log.e(Constants.TAG, - "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " + - "'fingerprint' extra!" - ); + Timber.e("IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " + + "'fingerprint' extra!"); return; } break; @@ -216,7 +214,7 @@ public class ImportKeysActivity extends BaseActivity implements ImportKeysListen dataUri.getScheme() + "://" + dataUri.getAuthority()); Preferences.CloudSearchPrefs cloudSearchPrefs = new Preferences.CloudSearchPrefs( true, false, false, keyserver); - Log.d(Constants.TAG, "Using keyserver: " + keyserver); + Timber.d("Using keyserver: " + keyserver); // process URL to get operation and query String operation = dataUri.getQueryParameter("op"); @@ -352,7 +350,7 @@ public class ImportKeysActivity extends BaseActivity implements ImportKeysListen new ParcelableFileCache<>(this, ImportOperation.CACHE_FILE_NAME); cache.writeCache(entries.size(), keyRings.iterator()); } catch (IOException e) { - Log.e(Constants.TAG, "Problem writing cache file", e); + Timber.e(e, "Problem writing cache file"); Notify.create(this, "Problem writing cache file!", Notify.Style.ERROR).show(); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java index ed3e13b0d..a1165f217 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java @@ -32,7 +32,6 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.keyimport.processing.BytesLoaderState; @@ -42,7 +41,7 @@ import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.util.PermissionsUtil; import org.sufficientlysecure.keychain.util.FileHelper; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.IOException; @@ -151,7 +150,7 @@ public class ImportKeysFileFragment extends Fragment { try { isEncrypted = FileHelper.isEncryptedFile(mActivity, mCurrentUri); } catch (IOException e) { - Log.e(Constants.TAG, "Error opening file", e); + Timber.e(e, "Error opening file"); Notify.create(mActivity, R.string.error_bad_data, Style.ERROR).show(); return; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysProxyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysProxyActivity.java index 4c48f5e8e..dabbd3547 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysProxyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysProxyActivity.java @@ -43,9 +43,9 @@ import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; import org.sufficientlysecure.keychain.ui.transfer.view.TransferFragment; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; import java.util.ArrayList; import java.util.Locale; @@ -94,11 +94,11 @@ public class ImportKeysProxyActivity extends FragmentActivity if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { handleActionNdefDiscovered(getIntent()); } else { - Log.e(Constants.TAG, "Android Beam not supported by Android < 4.1"); + Timber.e("Android Beam not supported by Android < 4.1"); finish(); } } else { - Log.e(Constants.TAG, "No valid scheme or action given!"); + Timber.e("No valid scheme or action given!"); finish(); } } @@ -123,7 +123,7 @@ public class ImportKeysProxyActivity extends FragmentActivity resultCode, data); if (scanResult == null || scanResult.getFormatName() == null) { - Log.e(Constants.TAG, "scanResult or formatName null! Should not happen!"); + Timber.e("scanResult or formatName null! Should not happen!"); finish(); return; } @@ -142,7 +142,7 @@ public class ImportKeysProxyActivity extends FragmentActivity private void processScannedContent(Uri uri) { String action = getIntent().getAction(); - Log.d(Constants.TAG, "scanned: " + uri); + Timber.d("scanned: " + uri); // example: pgp+transfer: if (uri != null && uri.getScheme() != null && uri.getScheme().equalsIgnoreCase(Constants.SKT_SCHEME)) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 1e64a31dd..da1d1bf0f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -68,8 +68,9 @@ import org.sufficientlysecure.keychain.ui.base.RecyclerFragment; import org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.util.FabContainer; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + public class KeyListFragment extends RecyclerFragment implements SearchView.OnQueryTextListener, @@ -381,7 +382,7 @@ public class KeyListFragment extends RecyclerFragment Notify.create(getActivity(), "Restored debug_backup.db", Notify.Style.OK).show(); getActivity().getContentResolver().notifyChange(KeychainContract.KeyRings.CONTENT_URI, null); } catch (IOException e) { - Log.e(Constants.TAG, "IO Error", e); + Timber.e(e, "IO Error"); Notify.create(getActivity(), "IO Error " + e.getMessage(), Notify.Style.ERROR).show(); } return true; @@ -391,7 +392,7 @@ public class KeyListFragment extends RecyclerFragment KeychainDatabase.debugBackup(getActivity(), false); Notify.create(getActivity(), "Backup to debug_backup.db completed", Notify.Style.OK).show(); } catch (IOException e) { - Log.e(Constants.TAG, "IO Error", e); + Timber.e(e, "IO Error"); Notify.create(getActivity(), "IO Error: " + e.getMessage(), Notify.Style.ERROR).show(); } return true; @@ -422,7 +423,7 @@ public class KeyListFragment extends RecyclerFragment @Override public boolean onQueryTextChange(String s) { - Log.d(Constants.TAG, "onQueryTextChange s:" + s); + Timber.d("onQueryTextChange s: %s", s); // Called when the action bar search text has changed. Update the // search filter, and restart the loader to do a new query with this // filter. diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiUserIdsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiUserIdsFragment.java index 1b35dfe0a..364528b41 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiUserIdsFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiUserIdsFragment.java @@ -32,15 +32,12 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ListView; -import org.openintents.openpgp.util.OpenPgpUtils; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.service.CertifyActionsParcel; import org.sufficientlysecure.keychain.ui.adapter.MultiUserIdsAdapter; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.util.ArrayList; @@ -90,7 +87,7 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load mPubMasterKeyIds = getActivity().getIntent().getLongArrayExtra(EXTRA_KEY_IDS); if (mPubMasterKeyIds == null) { - Log.e(Constants.TAG, "List of key ids to certify missing!"); + Timber.e("List of key ids to certify missing!"); getActivity().finish(); return; } @@ -184,7 +181,7 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load // Remember for next loop lastName = name; - Log.d(Constants.TAG, Long.toString(masterKeyId, 16) + (grouped ? "grouped" : "not grouped")); + Timber.d(Long.toString(masterKeyId, 16) + (grouped ? "grouped" : "not grouped")); if (!subGrouped) { // 1. This name should NOT be grouped with the previous, so we flush the buffer diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/OrbotRequiredDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/OrbotRequiredDialogActivity.java index d0a66c64e..c1565fc9d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/OrbotRequiredDialogActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/OrbotRequiredDialogActivity.java @@ -27,14 +27,14 @@ import android.os.RemoteException; import android.support.v4.app.FragmentActivity; import android.view.ContextThemeWrapper; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.ui.util.ThemeChanger; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.network.orbot.OrbotHelper; +import timber.log.Timber; + /** * Simply encapsulates a dialog. If orbot is not installed, it shows an install dialog, else a @@ -165,7 +165,7 @@ public class OrbotRequiredDialogActivity extends FragmentActivity try { mMessenger.send(msg); } catch (RemoteException e) { - Log.e(Constants.TAG, "Could not deliver message", e); + Timber.e(e, "Could not deliver message"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java index f7bb40781..921b34179 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java @@ -68,9 +68,10 @@ import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.Require import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder; import org.sufficientlysecure.keychain.ui.util.ThemeChanger; import org.sufficientlysecure.keychain.ui.widget.CacheTTLSpinner; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + /** * We can not directly create a dialog on the application context. @@ -124,7 +125,7 @@ public class PassphraseDialogActivity extends FragmentActivity { finish(); } } catch (NotFoundException e) { - Log.e(Constants.TAG, "Key not found?!", e); + Timber.e(e, "Key not found?!"); setResult(RESULT_CANCELED); finish(); } @@ -523,19 +524,19 @@ public class PassphraseDialogActivity extends FragmentActivity { } // cache the new passphrase as specified in CryptoInputParcel - Log.d(Constants.TAG, "Everything okay!"); + Timber.d("Everything okay!"); if (mRequiredInput.mSkipCaching) { - Log.d(Constants.TAG, "Not caching entered passphrase!"); + Timber.d("Not caching entered passphrase!"); } else { - Log.d(Constants.TAG, "Caching entered passphrase"); + Timber.d("Caching entered passphrase"); try { PassphraseCacheService.addCachedPassphrase(getActivity(), unlockedKey.getRing().getMasterKeyId(), unlockedKey.getKeyId(), passphrase, unlockedKey.getRing().getPrimaryUserIdWithFallback(), timeToLiveSeconds); } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "adding of a passphrase failed", e); + Timber.e(e, "adding of a passphrase failed"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java index e5f0dca95..8a9aabe3a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java @@ -35,7 +35,8 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.util.QrCodeUtils; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class QrCodeViewActivity extends BaseActivity { @@ -59,7 +60,7 @@ public class QrCodeViewActivity extends BaseActivity { Uri dataUri = getIntent().getData(); if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + Timber.e("Data missing. Should be Uri of key!"); ActivityCompat.finishAfterTransition(QrCodeViewActivity.this); return; } @@ -78,7 +79,7 @@ public class QrCodeViewActivity extends BaseActivity { try { byte[] blob = keyRepository.getCachedPublicKeyRing(dataUri).getFingerprint(); if (blob == null) { - Log.e(Constants.TAG, "key not found!"); + Timber.e("key not found!"); Notify.create(this, R.string.error_key_not_found, Style.ERROR).show(); ActivityCompat.finishAfterTransition(QrCodeViewActivity.this); } @@ -101,7 +102,7 @@ public class QrCodeViewActivity extends BaseActivity { } }); } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); + Timber.e(e, "key not found!"); Notify.create(this, R.string.error_key_not_found, Style.ERROR).show(); ActivityCompat.finishAfterTransition(QrCodeViewActivity.this); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SafeSlingerActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SafeSlingerActivity.java index f12bc9075..9206db407 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SafeSlingerActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SafeSlingerActivity.java @@ -48,8 +48,9 @@ import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; import org.sufficientlysecure.keychain.ui.util.FormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableFileCache; +import timber.log.Timber; + @TargetApi(Build.VERSION_CODES.HONEYCOMB) public class SafeSlingerActivity extends BaseActivity @@ -115,7 +116,7 @@ public class SafeSlingerActivity extends BaseActivity slingerIntent.putExtra(ExchangeConfig.extra.HOST_NAME, Constants.SAFESLINGER_SERVER); startActivityForResult(slingerIntent, REQUEST_CODE_SAFE_SLINGER); } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "personal key not found", e); + Timber.e(e, "personal key not found"); } } @@ -131,7 +132,7 @@ public class SafeSlingerActivity extends BaseActivity return; } - Log.d(Constants.TAG, "importKeys started"); + Timber.d("importKeys started"); // instead of giving the entries by Intent extra, cache them into a // file to prevent Java Binder problems on heavy imports @@ -153,7 +154,7 @@ public class SafeSlingerActivity extends BaseActivity mKeyserver = null; mOperationHelper.cryptoOperation(); } catch (IOException e) { - Log.e(Constants.TAG, "Problem writing cache file", e); + Timber.e(e, "Problem writing cache file"); Notify.create(this, "Problem writing cache file!", Notify.Style.ERROR).show(); } } else { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SecurityTokenChangePinOperationActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SecurityTokenChangePinOperationActivity.java index aa6256185..f3234dcb5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SecurityTokenChangePinOperationActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SecurityTokenChangePinOperationActivity.java @@ -30,7 +30,6 @@ import android.widget.TextView; import android.widget.ViewAnimator; import nordpol.android.NfcGuideView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.securitytoken.operations.ModifyPinTokenOp; import org.sufficientlysecure.keychain.securitytoken.SecurityTokenConnection; @@ -38,9 +37,9 @@ import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo; import org.sufficientlysecure.keychain.service.input.SecurityTokenChangePinParcel; import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity; import org.sufficientlysecure.keychain.ui.util.ThemeChanger; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.OrientationUtils; import org.sufficientlysecure.keychain.util.Passphrase; +import timber.log.Timber; /** @@ -74,7 +73,7 @@ public class SecurityTokenChangePinOperationActivity extends BaseSecurityTokenAc @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Log.d(Constants.TAG, "NfcOperationActivity.onCreate"); + Timber.d("NfcOperationActivity.onCreate"); nfcGuideView = (NfcGuideView) findViewById(R.id.nfc_guide_view); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SecurityTokenOperationActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SecurityTokenOperationActivity.java index b41e09865..d4d7a629e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SecurityTokenOperationActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SecurityTokenOperationActivity.java @@ -32,7 +32,6 @@ import android.widget.TextView; import android.widget.ViewAnimator; import nordpol.android.NfcGuideView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey; @@ -52,9 +51,10 @@ import org.sufficientlysecure.keychain.service.input.RequiredInputParcel; import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.ThemeChanger; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.OrientationUtils; import org.sufficientlysecure.keychain.util.Passphrase; +import timber.log.Timber; + /** * This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant @@ -92,7 +92,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Log.d(Constants.TAG, "NfcOperationActivity.onCreate"); + Timber.d("NfcOperationActivity.onCreate"); nfcGuideView = (NfcGuideView) findViewById(R.id.nfc_guide_view); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java index ea4f3abf8..c88b6adb5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java @@ -53,9 +53,9 @@ import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.ThemeChanger; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.network.orbot.OrbotHelper; +import timber.log.Timber; import java.security.KeyStore; import java.security.KeyStoreException; @@ -262,7 +262,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { if ((Boolean) newValue) { boolean installed = OrbotHelper.isOrbotInstalled(activity); if (!installed) { - Log.d(Constants.TAG, "Prompting to install Tor"); + Timber.d("Prompting to install Tor"); OrbotHelper.getPreferenceInstallDialogFragment().show(activity.getFragmentManager(), "installDialog"); // don't let the user check the box until he's installed orbot diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java index d4c8dd917..a2144a194 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java @@ -28,7 +28,6 @@ import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Spinner; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.UploadResult; import org.sufficientlysecure.keychain.provider.KeychainContract; @@ -36,8 +35,8 @@ import org.sufficientlysecure.keychain.service.UploadKeyringParcel; import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; import java.util.ArrayList; @@ -86,7 +85,7 @@ public class UploadKeyActivity extends BaseActivity mDataUri = getIntent().getData(); if (mDataUri == null) { - Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!"); + Timber.e("Intent data missing. Should be Uri of key!"); finish(); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UsbEventReceiverActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UsbEventReceiverActivity.java index e737c50b2..e24c96cac 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UsbEventReceiverActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UsbEventReceiverActivity.java @@ -25,8 +25,8 @@ import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; import android.os.Bundle; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class UsbEventReceiverActivity extends Activity { public static final String ACTION_USB_PERMISSION = @@ -47,7 +47,7 @@ public class UsbEventReceiverActivity extends Activity { if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) { UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); - Log.d(Constants.TAG, "Requesting permission for " + usbDevice.getDeviceName()); + Timber.d("Requesting permission for " + usbDevice.getDeviceName()); usbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0)); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java index 08bba3ba1..f581f5909 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java @@ -34,7 +34,6 @@ import android.view.MenuItem; import android.view.View; import android.widget.TextView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.WrappedSignature; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; @@ -45,7 +44,8 @@ import org.sufficientlysecure.keychain.provider.KeyRepository; import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class ViewCertActivity extends BaseActivity implements LoaderManager.LoaderCallbacks { @@ -100,7 +100,7 @@ public class ViewCertActivity extends BaseActivity mDataUri = getIntent().getData(); if (mDataUri == null) { - Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!"); + Timber.e("Intent data missing. Should be Uri of key!"); finish(); return; } @@ -195,7 +195,7 @@ public class ViewCertActivity extends BaseActivity startActivity(viewIntent); } catch (PgpKeyNotFoundException e) { // TODO notify user of this, maybe offer download? - Log.e(Constants.TAG, "key not found!", e); + Timber.e(e, "key not found!"); } } }); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java index dbc6068ef..8e0f30194 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java @@ -40,7 +40,6 @@ import android.view.animation.OvershootInterpolator; import android.widget.Toast; import com.astuetz.PagerSlidingTabStrip; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.provider.KeyRepository; @@ -50,7 +49,8 @@ import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.util.ContactHelper; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class ViewKeyAdvActivity extends BaseActivity implements LoaderCallbacks, OnPageChangeListener { @@ -95,14 +95,14 @@ public class ViewKeyAdvActivity extends BaseActivity implements mDataUri = getIntent().getData(); if (mDataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be uri of key!"); + Timber.e("Data missing. Should be uri of key!"); finish(); return; } if (mDataUri.getHost().equals(ContactsContract.AUTHORITY)) { mDataUri = new ContactHelper(this).dataUriFromContactUri(mDataUri); if (mDataUri == null) { - Log.e(Constants.TAG, "Contact Data missing. Should be uri of key!"); + Timber.e("Contact Data missing. Should be uri of key!"); Toast.makeText(this, R.string.error_contacts_key_id_missing, Toast.LENGTH_LONG).show(); finish(); return; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java index 7bbeede16..1a11c1bce 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java @@ -30,12 +30,12 @@ import android.view.LayoutInflater; import com.tonicartos.superslim.LayoutManager; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.ui.adapter.CertSectionedListAdapter; import org.sufficientlysecure.keychain.ui.base.RecyclerFragment; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class ViewKeyAdvCertsFragment extends RecyclerFragment implements LoaderManager.LoaderCallbacks, CertSectionedListAdapter.CertListListener { @@ -68,7 +68,7 @@ public class ViewKeyAdvCertsFragment extends RecyclerFragment { @@ -127,7 +127,7 @@ public class ViewKeyAdvSubkeysFragment extends LoaderFragment implements Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + Timber.e("Data missing. Should be Uri of key!"); getActivity().finish(); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java index d0dc5f228..dd12f062c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java @@ -38,7 +38,6 @@ import android.widget.AdapterView; import android.widget.ListView; import android.widget.ViewAnimator; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; import org.sufficientlysecure.keychain.operations.results.EditKeyResult; @@ -53,7 +52,8 @@ import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks { @@ -220,7 +220,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + Timber.e("Data missing. Should be Uri of key!"); getActivity().finish(); return; } @@ -240,7 +240,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements private void loadData(Uri dataUri) { mDataUri = dataUri; - Log.i(Constants.TAG, "mDataUri: " + mDataUri); + Timber.i("mDataUri: " + mDataUri); mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); mUserIds.setAdapter(mUserIdsAdapter); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeybaseFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeybaseFragment.java index f4586afb3..5227472df 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeybaseFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeybaseFragment.java @@ -44,7 +44,6 @@ import com.textuality.keybase.lib.KeybaseQuery; import com.textuality.keybase.lib.Proof; import com.textuality.keybase.lib.User; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.KeybaseVerificationResult; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; @@ -52,11 +51,11 @@ import org.sufficientlysecure.keychain.service.KeybaseVerificationParcel; import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; import org.sufficientlysecure.keychain.ui.base.LoaderFragment; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.network.OkHttpKeybaseClient; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.network.orbot.OrbotHelper; +import timber.log.Timber; import java.util.ArrayList; import java.util.Hashtable; @@ -124,7 +123,7 @@ public class ViewKeyKeybaseFragment extends LoaderFragment implements Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + Timber.e("Data missing. Should be Uri of key!"); getActivity().finish(); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 88cbcd737..9acab30ce 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -32,7 +32,6 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.databinding.ImportKeysListItemBinding; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; @@ -53,8 +52,9 @@ import org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity; import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableFileCache; +import timber.log.Timber; + public class ImportKeysAdapter extends RecyclerView.Adapter implements ImportKeysResultListener { @@ -230,7 +230,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter(mActivity, ImportOperation.CACHE_FILE_NAME); cache.writeCache(keyRing); } catch (IOException e) { - Log.e(Constants.TAG, "Problem writing cache file", e); + Timber.e(e, "Problem writing cache file"); Notify.create(mActivity, "Problem writing cache file!", Notify.Style.ERROR).show(); } @@ -260,12 +260,12 @@ public class ImportKeysAdapter extends RecyclerView.Adapter canKeyRings = result.mCanonicalizedKeyRings; if (canKeyRings.size() == 1) { CanonicalizedKeyRing keyRing = canKeyRings.get(0); - Log.e(Constants.TAG, "Key ID: " + keyRing.getMasterKeyId() + + Timber.e("Key ID: " + keyRing.getMasterKeyId() + "| isRev: " + keyRing.isRevoked() + "| isExp: " + keyRing.isExpired() + "| isSec: " + keyRing.isSecure()); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeySectionedListAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeySectionedListAdapter.java index 6b23d9a68..1b6564707 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeySectionedListAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeySectionedListAdapter.java @@ -37,7 +37,6 @@ import android.widget.TextView; import com.futuremind.recyclerviewfastscroll.SectionTitleProvider; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; @@ -46,7 +45,7 @@ import org.sufficientlysecure.keychain.ui.util.Highlighter; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter; import org.sufficientlysecure.keychain.ui.util.adapter.SectionCursorAdapter; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.util.ArrayList; import java.util.Arrays; @@ -221,7 +220,7 @@ public class KeySectionedListAdapter extends SectionCursorAdapter extends Fragment { private void checkDataSet() { boolean empty = treatAsEmpty(getItemCount()); - Log.d("RecyclerFragment", "Dataset change detected! Count: " + Timber.d("Dataset change detected! Count: " + getItemCount() + ", Empty: " + empty); if (emptyView != null) { @@ -302,7 +302,7 @@ public class RecyclerFragment extends Fragment { if (emptyView instanceof TextView) { ((TextView) emptyView).setText(text); } else { - Log.e(Constants.TAG, "Cannot set empty text on a view that is null" + + Timber.e("Cannot set empty text on a view that is null" + "or not an instance of android.view.View!"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEditKeyserverDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEditKeyserverDialogFragment.java index 07df7e4ec..a794f1624 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEditKeyserverDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEditKeyserverDialogFragment.java @@ -51,15 +51,15 @@ import android.widget.TextView.OnEditorActionListener; import okhttp3.OkHttpClient; import okhttp3.Request; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; import org.sufficientlysecure.keychain.network.OkHttpClientFactory; import org.sufficientlysecure.keychain.network.TlsCertificatePinning; import org.sufficientlysecure.keychain.network.orbot.OrbotHelper; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; + public class AddEditKeyserverDialogFragment extends DialogFragment implements OnEditorActionListener { private static final String ARG_MESSENGER = "arg_messenger"; @@ -369,7 +369,7 @@ public class AddEditKeyserverDialogFragment extends DialogFragment implements On TlsCertificatePinning tlsCertificatePinning = new TlsCertificatePinning(keyserverUriHttp.toURL()); boolean isPinAvailable = tlsCertificatePinning.isPinAvailable(); if (onlyTrustedKeyserver && !isPinAvailable) { - Log.w(Constants.TAG, "No pinned certificate for this host in OpenKeychain's assets."); + Timber.w("No pinned certificate for this host in OpenKeychain's assets."); reason = VerifyReturn.NO_PINNED_CERTIFICATE; return reason; } @@ -387,10 +387,10 @@ public class AddEditKeyserverDialogFragment extends DialogFragment implements On clientTor.newCall(new Request.Builder().url(keyserverUriOnion.toURL()).build()).execute(); } } catch (MalformedURLException | URISyntaxException e) { - Log.w(Constants.TAG, "Invalid keyserver URL entered by user."); + Timber.w("Invalid keyserver URL entered by user."); reason = VerifyReturn.INVALID_URL; } catch (IOException e) { - Log.w(Constants.TAG, "Could not connect to entered keyserver url"); + Timber.w("Could not connect to entered keyserver url"); reason = VerifyReturn.CONNECTION_FAILED; } @@ -450,9 +450,9 @@ public class AddEditKeyserverDialogFragment extends DialogFragment implements On try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEditSmartPGPAuthorityDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEditSmartPGPAuthorityDialogFragment.java index a73e6f840..4b9b44d48 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEditSmartPGPAuthorityDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEditSmartPGPAuthorityDialogFragment.java @@ -42,11 +42,10 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.EncryptFilesFragment; import org.sufficientlysecure.keychain.util.FileHelper; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; public class AddEditSmartPGPAuthorityDialogFragment extends DialogFragment implements OnEditorActionListener { @@ -305,9 +304,9 @@ public class AddEditSmartPGPAuthorityDialogFragment extends DialogFragment imple try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEmailDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEmailDialogFragment.java index 6bcd115c0..84ac4a4bc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEmailDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddEmailDialogFragment.java @@ -37,10 +37,10 @@ import android.widget.Button; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.widget.EmailEditText; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class AddEmailDialogFragment extends DialogFragment implements OnEditorActionListener { private static final String ARG_MESSENGER = "messenger"; @@ -187,9 +187,9 @@ public class AddEmailDialogFragment extends DialogFragment implements OnEditorAc try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } @@ -208,9 +208,9 @@ public class AddEmailDialogFragment extends DialogFragment implements OnEditorAc try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java index 688070018..becc5ff22 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java @@ -38,12 +38,12 @@ import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; import org.openintents.openpgp.util.OpenPgpUtils; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.ui.widget.EmailEditText; import org.sufficientlysecure.keychain.ui.widget.NameEditText; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class AddUserIdDialogFragment extends DialogFragment implements OnEditorActionListener { private static final String ARG_MESSENGER = "messenger"; @@ -193,9 +193,9 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } @@ -214,9 +214,9 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java index 0c12d70d6..6f7435cbc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java @@ -27,10 +27,9 @@ import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.widget.Toast; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.util.FileHelper; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.io.File; import java.util.ArrayList; @@ -107,7 +106,7 @@ public class DeleteFileDialogFragment extends DialogFragment { continue; } } catch (Exception e) { - Log.d(Constants.TAG, "Catched Exception, can happen when delete is not supported!", e); + Timber.d(e, "Catched Exception, can happen when delete is not supported!"); } } @@ -116,7 +115,7 @@ public class DeleteFileDialogFragment extends DialogFragment { continue; } } catch (Exception e) { - Log.d(Constants.TAG, "Catched Exception, can happen when delete is not supported!", e); + Timber.d(e, "Catched Exception, can happen when delete is not supported!"); } // some Uri's a ContentResolver fails to delete is handled by the java.io.File's delete diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditSubkeyDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditSubkeyDialogFragment.java index 25062a85d..603fe0136 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditSubkeyDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditSubkeyDialogFragment.java @@ -25,9 +25,9 @@ import android.os.Messenger; import android.os.RemoteException; import android.support.v4.app.DialogFragment; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class EditSubkeyDialogFragment extends DialogFragment { private static final String ARG_MESSENGER = "messenger"; @@ -128,9 +128,9 @@ public class EditSubkeyDialogFragment extends DialogFragment { try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditSubkeyExpiryDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditSubkeyExpiryDialogFragment.java index a6edddea2..79a6d995a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditSubkeyExpiryDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditSubkeyExpiryDialogFragment.java @@ -35,14 +35,12 @@ import android.widget.DatePicker; import android.widget.LinearLayout; import android.widget.TextView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify.Style; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; import java.util.Calendar; -import java.util.Date; import java.util.TimeZone; public class EditSubkeyExpiryDialogFragment extends DialogFragment { @@ -227,9 +225,9 @@ public class EditSubkeyExpiryDialogFragment extends DialogFragment { try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java index d9d28271f..7123c90b7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java @@ -25,9 +25,9 @@ import android.os.Messenger; import android.os.RemoteException; import android.support.v4.app.DialogFragment; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class EditUserIdDialogFragment extends DialogFragment { private static final String ARG_MESSENGER = "messenger"; @@ -130,9 +130,9 @@ public class EditUserIdDialogFragment extends DialogFragment { try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoPgpInstallDialog.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoPgpInstallDialog.java index a45c080da..dcf2c3b5d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoPgpInstallDialog.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoPgpInstallDialog.java @@ -25,9 +25,9 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class FidesmoPgpInstallDialog extends DialogFragment { @@ -74,7 +74,7 @@ public class FidesmoPgpInstallDialog extends DialogFragment { Uri.parse(mPgpInstallServiceUrl)); startActivity(mPgpServiceIntent); } catch (IllegalArgumentException e) { - Log.e(Constants.TAG, "Error when parsing URI"); + Timber.e("Error when parsing URI"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/OrbotStartDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/OrbotStartDialogFragment.java index 105acb947..e2bff1db5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/OrbotStartDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/OrbotStartDialogFragment.java @@ -32,11 +32,11 @@ import android.view.ContextThemeWrapper; import android.view.View; import android.widget.Button; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.util.ThemeChanger; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.network.orbot.OrbotHelper; +import timber.log.Timber; + /** * displays a dialog asking the user to enable Tor @@ -89,9 +89,9 @@ public class OrbotStartDialogFragment extends DialogFragment { try { messenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } @@ -105,9 +105,9 @@ public class OrbotStartDialogFragment extends DialogFragment { try { messenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } }); @@ -153,9 +153,9 @@ public class OrbotStartDialogFragment extends DialogFragment { try { messenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } dismiss(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java index 014afdd12..a0bda2979 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java @@ -27,7 +27,6 @@ import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import android.support.v4.app.DialogFragment; -import android.text.TextUtils; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; @@ -41,11 +40,11 @@ import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.widget.PassphraseEditText; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; +import timber.log.Timber; + public class SetPassphraseDialogFragment extends DialogFragment implements OnEditorActionListener { private static final String ARG_MESSENGER = "messenger"; @@ -236,9 +235,9 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi try { mMessenger.send(msg); } catch (RemoteException e) { - Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); + Timber.w(e, "Exception sending message, Is handler present?"); } catch (NullPointerException e) { - Log.w(Constants.TAG, "Messenger is null!", e); + Timber.w(e, "Messenger is null!"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/LinkedIdViewFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/LinkedIdViewFragment.java index 135cb9619..f333b126d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/LinkedIdViewFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/LinkedIdViewFragment.java @@ -48,7 +48,6 @@ import android.widget.TextSwitcher; import android.widget.TextView; import android.widget.ViewAnimator; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants.key; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.linked.LinkedAttribute; @@ -75,7 +74,8 @@ import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.util.SubtleAttentionSeeker; import org.sufficientlysecure.keychain.ui.widget.CertListWidget; import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; + public class LinkedIdViewFragment extends CryptoOperationFragment implements LoaderManager.LoaderCallbacks, OnBackStackChangedListener { @@ -170,7 +170,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements loadIdentity(linkedId, certStatus); } catch (IOException e) { - Log.e(Constants.TAG, "error parsing identity", e); + Timber.e(e, "error parsing identity"); Notify.create(getActivity(), "Error parsing identity!", Notify.LENGTH_LONG, Style.ERROR).show(); finishFragment(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyActivity.java index f1c82553c..e9cfbb3f0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyActivity.java @@ -106,9 +106,9 @@ import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.util.QrCodeUtils; import org.sufficientlysecure.keychain.util.ContactHelper; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; public class ViewKeyActivity extends BaseSecurityTokenActivity implements @@ -248,21 +248,21 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements mDataUri = getIntent().getData(); if (mDataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be uri of key!"); + Timber.e("Data missing. Should be uri of key!"); finish(); return; } if (mDataUri.getHost().equals(ContactsContract.AUTHORITY)) { mDataUri = new ContactHelper(this).dataUriFromContactUri(mDataUri); if (mDataUri == null) { - Log.e(Constants.TAG, "Contact Data missing. Should be uri of key!"); + Timber.e("Contact Data missing. Should be uri of key!"); Toast.makeText(this, R.string.error_contacts_key_id_missing, Toast.LENGTH_LONG).show(); finish(); return; } } - Log.i(Constants.TAG, "mDataUri: " + mDataUri); + Timber.i("mDataUri: " + mDataUri); mActionEncryptFile.setOnClickListener(new View.OnClickListener() { @Override @@ -665,7 +665,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements // used instead of startActivity set actionbar based on callingPackage startActivityForResult(intent, 0); } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); + Timber.e(e, "key not found!"); } } @@ -676,7 +676,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements .getCachedPublicKeyRing(dataUri) .extractOrGetMasterKeyId(); } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); + Timber.e(e, "key not found!"); } Intent safeSlingerIntent = new Intent(this, SafeSlingerActivity.class); safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, keyId); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/IdentityLoader.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/IdentityLoader.java index b2e944b07..b2064b903 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/IdentityLoader.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/IdentityLoader.java @@ -45,6 +45,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; import org.sufficientlysecure.keychain.ui.keyview.loader.IdentityLoader.IdentityInfo; import org.sufficientlysecure.keychain.ui.util.PackageIconGetter; +import timber.log.Timber; public class IdentityLoader extends AsyncTaskLoader> { @@ -122,7 +123,7 @@ public class IdentityLoader extends AsyncTaskLoader> { Cursor cursor = contentResolver.query(ApiAutocryptPeer.buildByMasterKeyId(masterKeyId), TRUST_IDS_PROJECTION, null, null, null); if (cursor == null) { - Log.e(Constants.TAG, "Error loading trust ids!"); + Timber.e("Error loading trust ids!"); return; } @@ -180,7 +181,7 @@ public class IdentityLoader extends AsyncTaskLoader> { Cursor cursor = contentResolver.query(UserPackets.buildLinkedIdsUri(masterKeyId), USER_PACKETS_PROJECTION, USER_IDS_WHERE, null, null); if (cursor == null) { - Log.e(Constants.TAG, "Error loading key items!"); + Timber.e("Error loading key items!"); return; } @@ -198,7 +199,7 @@ public class IdentityLoader extends AsyncTaskLoader> { identities.add(identityInfo); } } catch (IOException e) { - Log.e(Constants.TAG, "Failed parsing uri attribute", e); + Timber.e(e, "Failed parsing uri attribute"); } } } finally { @@ -210,7 +211,7 @@ public class IdentityLoader extends AsyncTaskLoader> { Cursor cursor = contentResolver.query(UserPackets.buildUserIdsUri(masterKeyId), USER_PACKETS_PROJECTION, USER_IDS_WHERE, null, null); if (cursor == null) { - Log.e(Constants.TAG, "Error loading key items!"); + Timber.e("Error loading key items!"); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/KeyserverStatusLoader.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/KeyserverStatusLoader.java index 5fce24cf1..5f643ee1c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/KeyserverStatusLoader.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/KeyserverStatusLoader.java @@ -30,6 +30,7 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.UpdatedKeys; import org.sufficientlysecure.keychain.ui.keyview.loader.KeyserverStatusLoader.KeyserverStatus; +import timber.log.Timber; public class KeyserverStatusLoader extends AsyncTaskLoader { @@ -62,7 +63,7 @@ public class KeyserverStatusLoader extends AsyncTaskLoader { Cursor cursor = contentResolver.query(UpdatedKeys.CONTENT_URI, PROJECTION, UpdatedKeys.MASTER_KEY_ID + " = ?", new String[] { Long.toString(masterKeyId) }, null); if (cursor == null) { - Log.e(Constants.TAG, "Error loading key items!"); + Timber.e("Error loading key items!"); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SubkeyStatusLoader.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SubkeyStatusLoader.java index 6b51b614d..82816d05d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SubkeyStatusLoader.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SubkeyStatusLoader.java @@ -37,6 +37,7 @@ import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants; import org.sufficientlysecure.keychain.pgp.SecurityProblem.KeySecurityProblem; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.ui.keyview.loader.SubkeyStatusLoader.KeySubkeyStatus; +import timber.log.Timber; public class SubkeyStatusLoader extends AsyncTaskLoader { @@ -86,7 +87,7 @@ public class SubkeyStatusLoader extends AsyncTaskLoader { public KeySubkeyStatus loadInBackground() { Cursor cursor = contentResolver.query(Keys.buildKeysUri(masterKeyId), PROJECTION, null, null, null); if (cursor == null) { - Log.e(Constants.TAG, "Error loading key items!"); + Timber.e("Error loading key items!"); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SystemContactInfoLoader.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SystemContactInfoLoader.java index 0fae457da..cfbe51f73 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SystemContactInfoLoader.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SystemContactInfoLoader.java @@ -32,6 +32,7 @@ import android.util.Log; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.ui.keyview.loader.SystemContactInfoLoader.SystemContactInfo; import org.sufficientlysecure.keychain.util.ContactHelper; +import timber.log.Timber; public class SystemContactInfoLoader extends AsyncTaskLoader { @@ -72,7 +73,7 @@ public class SystemContactInfoLoader extends AsyncTaskLoader }, null); if (cursor == null) { - Log.e(Constants.TAG, "Error loading key items!"); + Timber.e("Error loading key items!"); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/presenter/IdentitiesPresenter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/presenter/IdentitiesPresenter.java index 98e23a9c5..d606eed4a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/presenter/IdentitiesPresenter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/presenter/IdentitiesPresenter.java @@ -30,7 +30,6 @@ import android.support.v4.app.LoaderManager.LoaderCallbacks; import android.support.v4.content.Loader; import android.view.View; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.provider.AutocryptPeerDataAccessObject; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; @@ -46,8 +45,8 @@ import org.sufficientlysecure.keychain.ui.keyview.loader.IdentityLoader.LinkedId import org.sufficientlysecure.keychain.ui.keyview.loader.IdentityLoader.TrustIdInfo; import org.sufficientlysecure.keychain.ui.keyview.loader.IdentityLoader.UserIdInfo; import org.sufficientlysecure.keychain.ui.linked.LinkedIdWizard; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import timber.log.Timber; public class IdentitiesPresenter implements LoaderCallbacks> { @@ -148,7 +147,7 @@ public class IdentitiesPresenter implements LoaderCallbacks> Uri dataUri = UserPackets.buildLinkedIdsUri(KeyRings.buildGenericKeyRingUri(masterKeyId)); frag = LinkedIdViewFragment.newInstance(dataUri, info.getRank(), isSecret, masterKeyId); } catch (IOException e) { - Log.e(Constants.TAG, "IOException", e); + Timber.e(e, "IOException"); return; } @@ -179,7 +178,7 @@ public class IdentitiesPresenter implements LoaderCallbacks> public void onClickForgetIdentity(int position) { TrustIdInfo info = (TrustIdInfo) identitiesAdapter.getInfo(position); if (info == null) { - Log.e(Constants.TAG, "got a 'forget' click on a bad trust id"); + Timber.e("got a 'forget' click on a bad trust id"); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/presenter/SystemContactPresenter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/presenter/SystemContactPresenter.java index c306b7373..ff658197c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/presenter/SystemContactPresenter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/presenter/SystemContactPresenter.java @@ -31,10 +31,9 @@ import android.support.v4.app.LoaderManager.LoaderCallbacks; import android.support.v4.content.ContextCompat; import android.support.v4.content.Loader; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.ui.keyview.loader.SystemContactInfoLoader; import org.sufficientlysecure.keychain.ui.keyview.loader.SystemContactInfoLoader.SystemContactInfo; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; public class SystemContactPresenter implements LoaderCallbacks { @@ -67,7 +66,7 @@ public class SystemContactPresenter implements LoaderCallbacks { @@ -234,7 +234,7 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment { @@ -204,7 +205,7 @@ public abstract class PublicKeyRetrievalLoader extends AsyncTaskLoader> { @@ -63,7 +64,7 @@ public class SecretKeyLoader extends AsyncTaskLoader> { String where = KeyRings.HAS_ANY_SECRET + " = 1"; Cursor cursor = contentResolver.query(KeyRings.buildUnifiedKeyRingsUri(), PROJECTION, where, null, null); if (cursor == null) { - Log.e(Constants.TAG, "Error loading key items!"); + Timber.e("Error loading key items!"); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/transfer/presenter/TransferPresenter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/transfer/presenter/TransferPresenter.java index d6a702259..a17f636db 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/transfer/presenter/TransferPresenter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/transfer/presenter/TransferPresenter.java @@ -42,7 +42,6 @@ import android.view.LayoutInflater; import org.openintents.openpgp.util.OpenPgpUtils; import org.openintents.openpgp.util.OpenPgpUtils.UserId; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; import org.sufficientlysecure.keychain.network.KeyTransferInteractor; import org.sufficientlysecure.keychain.network.KeyTransferInteractor.KeyTransferCallback; @@ -62,7 +61,7 @@ import org.sufficientlysecure.keychain.ui.transfer.view.ReceivedSecretKeyList.Re import org.sufficientlysecure.keychain.ui.transfer.view.TransferSecretKeyList.OnClickTransferKeyListener; import org.sufficientlysecure.keychain.ui.transfer.view.TransferSecretKeyList.TransferKeyAdapter; import org.sufficientlysecure.keychain.ui.util.QrCodeUtils; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; @RequiresApi(api = VERSION_CODES.LOLLIPOP) @@ -260,16 +259,16 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks= getItemCount() || position < -1) { - Log.w(TAG, "Position: %d is invalid for this data set!"); + Timber.w("Position: %d is invalid for this data set!"); return false; } if (!mDataValid) { - Log.d(TAG, "Attempt to move cursor over invalid data set!"); + Timber.d("Attempt to move cursor over invalid data set!"); } return mCursor.moveToPosition(position); @@ -322,7 +321,7 @@ public abstract class CursorAdapter constructor = type.getConstructor(Cursor.class); return constructor.newInstance(cursor); } catch (Exception e) { - Log.e(Constants.TAG, "Could not create instance of cursor wrapper!", e); + Timber.e(e, "Could not create instance of cursor wrapper!"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/adapter/SectionCursorAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/adapter/SectionCursorAdapter.java index a83e2a737..4af5faf82 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/adapter/SectionCursorAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/adapter/SectionCursorAdapter.java @@ -26,7 +26,7 @@ import android.view.ViewGroup; import com.tonicartos.superslim.LayoutManager; import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter.SimpleCursor; -import org.sufficientlysecure.keychain.util.Log; +import timber.log.Timber; /** @@ -92,8 +92,8 @@ public abstract class SectionCursorAdapter @@ -103,7 +102,8 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView if (getContext() instanceof FragmentActivity) { mLoaderManager = ((FragmentActivity) getContext()).getSupportLoaderManager(); } else { - Log.e(Constants.TAG, "EncryptKeyCompletionView must be attached to a FragmentActivity, this is " + getContext().getClass()); + Timber.e("EncryptKeyCompletionView must be attached to a FragmentActivity, this is " + + getContext().getClass()); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/PasswordStrengthView.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/PasswordStrengthView.java index a7ead8039..c1c0e9efa 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/PasswordStrengthView.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/PasswordStrengthView.java @@ -31,9 +31,8 @@ import android.graphics.Paint; import android.util.AttributeSet; import android.view.View; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; + /** * Created by Matt Allen diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/CloseDatabaseCursorFactory.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/CloseDatabaseCursorFactory.java index f3243d4ce..ac9fb90e3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/CloseDatabaseCursorFactory.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/CloseDatabaseCursorFactory.java @@ -7,9 +7,8 @@ import android.database.sqlite.SQLiteCursorDriver; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteQuery; -import android.util.Log; -import org.sufficientlysecure.keychain.Constants; +import timber.log.Timber; public class CloseDatabaseCursorFactory implements CursorFactory { @@ -23,11 +22,11 @@ public class CloseDatabaseCursorFactory implements CursorFactory { final SQLiteDatabase db = getDatabase(); super.close(); if (db != null) { - Log.d(Constants.TAG, "Closing cursor: " + db.getPath()); + Timber.d("Closing cursor: " + db.getPath()); try { db.close(); } catch (Exception e) { - Log.e(Constants.TAG, "Error closing db", e); + Timber.e(e, "Error closing db"); } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java index c116b27aa..40bc57519 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java @@ -17,6 +17,17 @@ package org.sufficientlysecure.keychain.util; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; + import android.Manifest; import android.accounts.Account; import android.accounts.AccountManager; @@ -40,16 +51,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; +import timber.log.Timber; public class ContactHelper { @@ -490,7 +492,7 @@ public class ContactHelper { return true; } - Log.w(Constants.TAG, "READ_CONTACTS permission denied!"); + Timber.w("READ_CONTACTS permission denied!"); return false; } @@ -515,7 +517,7 @@ public class ContactHelper { boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0; boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 0; - Log.d(Constants.TAG, "masterKeyId: " + masterKeyId); + Timber.d("masterKeyId: " + masterKeyId); deletedKeys.remove(masterKeyId); @@ -524,7 +526,7 @@ public class ContactHelper { // Do not store expired or revoked or unverified keys in contact db - and // remove them if they already exist. Secret keys do not reach this point if (isExpired || isRevoked || !isVerified) { - Log.d(Constants.TAG, "Expired or revoked or unverified: Deleting masterKeyId " + Timber.d("Expired or revoked or unverified: Deleting masterKeyId " + masterKeyId); if (masterKeyId != -1) { deleteRawContactByMasterKeyId(masterKeyId); @@ -533,11 +535,11 @@ public class ContactHelper { // get raw contact to this master key id long rawContactId = findRawContactId(masterKeyId); - Log.d(Constants.TAG, "rawContactId: " + rawContactId); + Timber.d("rawContactId: " + rawContactId); // Create a new rawcontact with corresponding key if it does not exist yet if (rawContactId == -1) { - Log.d(Constants.TAG, "Insert new raw contact with masterKeyId " + masterKeyId); + Timber.d("Insert new raw contact with masterKeyId " + masterKeyId); insertContact(ops, masterKeyId); writeContactKey(ops, rawContactId, masterKeyId, name); @@ -550,7 +552,7 @@ public class ContactHelper { try { mContentResolver.applyBatch(ContactsContract.AUTHORITY, ops); } catch (Exception e) { - Log.w(Constants.TAG, e); + Timber.w(e); } } } @@ -559,7 +561,7 @@ public class ContactHelper { // Delete master key ids that are no longer present in OK for (Long masterKeyId : deletedKeys) { - Log.d(Constants.TAG, "Delete raw contact with masterKeyId " + masterKeyId); + Timber.d("Delete raw contact with masterKeyId " + masterKeyId); deleteRawContactByMasterKeyId(masterKeyId); } } @@ -594,7 +596,7 @@ public class ContactHelper { if (!existsInMainProfile) { long rawContactId = -1;//new raw contact - Log.d(Constants.TAG, "masterKeyId with secret " + masterKeyId); + Timber.d("masterKeyId with secret " + masterKeyId); ArrayList ops = new ArrayList<>(); insertMainProfileRawContact(ops, masterKeyId); @@ -603,7 +605,7 @@ public class ContactHelper { try { mContentResolver.applyBatch(ContactsContract.AUTHORITY, ops); } catch (Exception e) { - Log.w(Constants.TAG, e); + Timber.w(e); } } } @@ -614,7 +616,7 @@ public class ContactHelper { for (long masterKeyId : keysToDelete) { deleteMainProfileRawContactByMasterKeyId(masterKeyId); - Log.d(Constants.TAG, "Delete main profile raw contact with masterKeyId " + masterKeyId); + Timber.d("Delete main profile raw contact with masterKeyId " + masterKeyId); } } @@ -684,7 +686,7 @@ public class ContactHelper { Uri deleteUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon(). appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build(); - Log.d(Constants.TAG, "Deleting all raw contacts associated to OK..."); + Timber.d("Deleting all raw contacts associated to OK..."); int delete = mContentResolver.delete(deleteUri, ContactsContract.RawContacts.ACCOUNT_TYPE + "=?", new String[]{ diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelper.java index 5a8a08f06..9aa6a94ba 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelper.java @@ -54,6 +54,8 @@ import android.widget.Toast; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import timber.log.Timber; + /** This class offers a number of helper functions for saving documents. * @@ -241,7 +243,7 @@ public class FileHelper { if (br != null) br.close(); } catch (IOException e) { - Log.e(Constants.TAG, "Error closing file", e); + Timber.e(e, "Error closing file"); } } return isEncrypted; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelperLollipop.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelperLollipop.java index 849b692bc..85997675a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelperLollipop.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelperLollipop.java @@ -17,6 +17,7 @@ package org.sufficientlysecure.keychain.util; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -32,7 +33,8 @@ import android.system.ErrnoException; import android.system.Os; import android.system.StructStat; -import org.sufficientlysecure.keychain.Constants; +import timber.log.Timber; + /** * FileHelper methods which use Lollipop-exclusive API. @@ -67,11 +69,11 @@ class FileHelperLollipop { try { final StructStat st = Os.fstat(pfd.getFileDescriptor()); if (st.st_uid == android.os.Process.myUid()) { - Log.e(Constants.TAG, "File is owned by the application itself, aborting!"); + Timber.e("File is owned by the application itself, aborting!"); throw new FileNotFoundException("Unable to create stream"); } } catch (ErrnoException e) { - Log.e(Constants.TAG, "fstat() failed: " + e); + Timber.e("fstat() failed: " + e); throw new FileNotFoundException("fstat() failed"); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Log.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Log.java deleted file mode 100644 index df0fa6a35..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Log.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2017 Schürmann & Breitmoser GbR - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.util; - -import android.os.Bundle; - -import org.sufficientlysecure.keychain.Constants; - -import java.util.Iterator; -import java.util.Set; - -/** - * Wraps Android Logging to enable or disable debug output using Constants - */ -public final class Log { - - public static void v(String tag, String msg) { - if (Constants.DEBUG) { - android.util.Log.v(tag, msg); - } - } - - public static void v(String tag, String msg, Throwable tr) { - if (Constants.DEBUG) { - android.util.Log.v(tag, msg, tr); - } - } - - public static void d(String tag, String msg) { - if (Constants.DEBUG) { - android.util.Log.d(tag, msg); - } - } - - public static void d(String tag, String msg, Throwable tr) { - if (Constants.DEBUG) { - android.util.Log.d(tag, msg, tr); - } - } - - public static void dEscaped(String tag, String msg) { - if (Constants.DEBUG) { - android.util.Log.d(tag, removeUnicodeAndEscapeChars(msg)); - } - } - - public static void dEscaped(String tag, String msg, Throwable tr) { - if (Constants.DEBUG) { - android.util.Log.d(tag, removeUnicodeAndEscapeChars(msg), tr); - } - } - - public static void i(String tag, String msg) { - if (Constants.DEBUG) { - android.util.Log.i(tag, msg); - } - } - - public static void i(String tag, String msg, Throwable tr) { - if (Constants.DEBUG) { - android.util.Log.i(tag, msg, tr); - } - } - - public static void w(String tag, String msg) { - android.util.Log.w(tag, msg); - } - - public static void w(String tag, String msg, Throwable tr) { - android.util.Log.w(tag, msg, tr); - } - - public static void w(String tag, Throwable tr) { - android.util.Log.w(tag, tr); - } - - public static void e(String tag, String msg) { - android.util.Log.e(tag, msg); - } - - public static void e(String tag, String msg, Throwable tr) { - android.util.Log.e(tag, msg, tr); - } - - - /** - * Logs bundle content to debug for inspecting the content - * - * @param bundle - * @param bundleName - */ - public static void logDebugBundle(Bundle bundle, String bundleName) { - if (Constants.DEBUG) { - if (bundle != null) { - Set ks = bundle.keySet(); - Iterator iterator = ks.iterator(); - - Log.d(Constants.TAG, "Bundle " + bundleName + ":"); - Log.d(Constants.TAG, "------------------------------"); - while (iterator.hasNext()) { - String key = iterator.next(); - Object value = bundle.get(key); - - if (value != null) { - Log.d(Constants.TAG, key + " : " + value.toString()); - } else { - Log.d(Constants.TAG, key + " : null"); - } - } - Log.d(Constants.TAG, "------------------------------"); - } else { - Log.d(Constants.TAG, "Bundle " + bundleName + ": null"); - } - } - } - - public static String removeUnicodeAndEscapeChars(String input) { - StringBuilder buffer = new StringBuilder(input.length()); - for (int i = 0; i < input.length(); i++) { - if ((int) input.charAt(i) > 256) { - buffer.append("\\u").append(Integer.toHexString((int) input.charAt(i))); - } else { - if (input.charAt(i) == '\n') { - buffer.append("\\n"); - } else if (input.charAt(i) == '\t') { - buffer.append("\\t"); - } else if (input.charAt(i) == '\r') { - buffer.append("\\r"); - } else if (input.charAt(i) == '\b') { - buffer.append("\\b"); - } else if (input.charAt(i) == '\f') { - buffer.append("\\f"); - } else if (input.charAt(i) == '\'') { - buffer.append("\\'"); - } else if (input.charAt(i) == '\"') { - buffer.append("\\"); - } else if (input.charAt(i) == '\\') { - buffer.append("\\\\"); - } else { - buffer.append(input.charAt(i)); - } - } - } - return buffer.toString(); - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/PRNGFixes.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/PRNGFixes.java index 4414f2d71..143d222f0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/PRNGFixes.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/PRNGFixes.java @@ -29,6 +29,9 @@ import java.security.SecureRandom; import java.security.SecureRandomSpi; import java.security.Security; +import timber.log.Timber; + + /** * Fixes for the output of the default PRNG having low entropy. *

@@ -245,8 +248,7 @@ public final class PRNGFixes { } catch (IOException e) { // On a small fraction of devices /dev/urandom is not writable. // Log and ignore. - Log.w(PRNGFixes.class.getSimpleName(), - "Failed to mix seed into " + URANDOM_FILE); + Timber.w("Failed to mix seed into " + URANDOM_FILE); } finally { mSeeded = true; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableFileCache.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableFileCache.java index a5d9365ef..b9e3c2c36 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableFileCache.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableFileCache.java @@ -17,12 +17,6 @@ package org.sufficientlysecure.keychain.util; -import android.content.Context; -import android.os.Parcel; -import android.os.Parcelable; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.KeychainApplication; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -34,6 +28,13 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; +import android.content.Context; +import android.os.Parcel; +import android.os.Parcelable; + +import org.sufficientlysecure.keychain.KeychainApplication; +import timber.log.Timber; + /** * When sending large data (over 1MB) through Androids Binder IPC you get * JavaBinder E !!! FAILED BINDER TRANSACTION !!! @@ -127,7 +128,7 @@ public class ParcelableFileCache { try { ois = new DataInputStream(new FileInputStream(tempFile)); } catch (FileNotFoundException e) { - Log.e(Constants.TAG, "parcel import file not existing", e); + Timber.e(e, "parcel import file not existing"); throw new IOException(e); } @@ -165,7 +166,7 @@ public class ParcelableFileCache { // aight close(); } catch (IOException e) { - Log.e(Constants.TAG, "Encountered IOException during cache read!", e); + Timber.e(e, "Encountered IOException during cache read!"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java index c0a1e80fa..d435864c5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java @@ -37,6 +37,8 @@ import org.sufficientlysecure.keychain.Constants.Pref; import org.sufficientlysecure.keychain.KeychainApplication; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService; +import timber.log.Timber; + /** * Singleton Implementation of a Preference Helper @@ -279,7 +281,7 @@ public class Preferences { case typeSocks: return Proxy.Type.SOCKS; default: // shouldn't happen - Log.e(Constants.TAG, "Invalid Proxy Type in preferences"); + Timber.e("Invalid Proxy Type in preferences"); return null; } } @@ -422,7 +424,7 @@ public class Preferences { } public void upgradePreferences(Context context) { - Log.d(Constants.TAG, "Upgrading preferences…"); + Timber.d("Upgrading preferences…"); int oldVersion = mSharedPreferences.getInt(Constants.Pref.PREF_VERSION, 0); boolean requiresUpgrade = oldVersion < Constants.Defaults.PREF_CURRENT_VERSION;