diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 49f6562971268fd1858d69780d93a6b398b124d2..e13d85130850157de35fde64c871be6e24983a8c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -166,6 +166,7 @@ dependencies { implementation(libs.greenrobot.eventbus) implementation(libs.circleindicator) implementation(libs.restriction.bypass) + implementation(libs.tools.timber) debugImplementation(libs.debug.db) coreLibraryDesugaring(libs.tools.desugar) implementation(libs.androidx.profileinstaller) diff --git a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java index b6440b930c7433726fe9ac3626e7a252c114b731..729eb28ce7a94e99cce3118c0bd363e7b64a7c1c 100755 --- a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +++ b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java @@ -8,6 +8,10 @@ import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; import android.provider.Settings; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import foundation.e.blisslauncher.core.DeviceProfile; import foundation.e.blisslauncher.core.IconsHandler; @@ -16,6 +20,7 @@ import foundation.e.blisslauncher.core.customviews.WidgetHost; import foundation.e.blisslauncher.features.launcher.AppProvider; import foundation.e.blisslauncher.features.notification.NotificationService; import foundation.e.lib.telemetry.Telemetry; +import timber.log.Timber; public class BlissLauncher extends Application { public static final Uri NOTIFICATION_BADGING_URI = Settings.Secure.getUriFor("notification_badging"); @@ -46,7 +51,18 @@ public class BlissLauncher extends Application { }; getContentResolver().registerContentObserver(NOTIFICATION_BADGING_URI, false, notificationSettingsObserver); - Telemetry.INSTANCE.init(BuildConfig.SENTRY_DSN, this); + if (!BuildConfig.DEBUG) { + Telemetry.INSTANCE.init(BuildConfig.SENTRY_DSN, this); + Timber.plant(new Timber.Tree() { + @Override + protected void log(int priority, @Nullable String tag, @NonNull String message, @Nullable Throwable t) { + Telemetry.INSTANCE.reportMessage(tag + ": " + message); + Log.println(priority, tag, message); + } + }); + } else { + Timber.plant(new Timber.DebugTree()); + } } private void onNotificationSettingsChanged() { diff --git a/app/src/main/java/foundation/e/blisslauncher/core/AdaptiveIconGenerator.java b/app/src/main/java/foundation/e/blisslauncher/core/AdaptiveIconGenerator.java index 6ad413fdd5206054cb538dbbdf0043577c377e4f..91d71d88a3db23ba07b8f26f39c01b8212bd52dc 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/AdaptiveIconGenerator.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/AdaptiveIconGenerator.java @@ -10,12 +10,12 @@ import android.graphics.Color; import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.util.Log; import android.util.SparseIntArray; import androidx.annotation.NonNull; import androidx.core.graphics.ColorUtils; import foundation.e.blisslauncher.FixedScaleDrawable; import foundation.e.blisslauncher.core.customviews.AdaptiveIconDrawableCompat; +import timber.log.Timber; public class AdaptiveIconGenerator { @@ -60,7 +60,7 @@ public class AdaptiveIconGenerator { Drawable extractee = icon; if (extractee == null) { - Log.e("AdaptiveIconGenerator", "extractee is null, skipping."); + Timber.tag("AdaptiveIconGenerator").e("extractee is null, skipping."); onExitLoop(); return; } diff --git a/app/src/main/java/foundation/e/blisslauncher/core/AdaptiveIconProvider.java b/app/src/main/java/foundation/e/blisslauncher/core/AdaptiveIconProvider.java index 1c1a549e7f268cfca66b364b635378599614d64b..534171c4e9f1d4049d9b341196b39ce07977f872 100755 --- a/app/src/main/java/foundation/e/blisslauncher/core/AdaptiveIconProvider.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/AdaptiveIconProvider.java @@ -6,7 +6,6 @@ import android.content.res.AssetManager; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; -import android.util.Log; import androidx.core.content.res.ResourcesCompat; @@ -14,6 +13,7 @@ import org.xmlpull.v1.XmlPullParser; import foundation.e.blisslauncher.core.customviews.AdaptiveIconDrawableCompat; import foundation.e.blisslauncher.core.utils.ResourceUtils; +import timber.log.Timber; /** * Created by falcon on 19/4/18. @@ -51,19 +51,19 @@ public class AdaptiveIconProvider { String matcher = "application"; while ((eventType = manifestParser.nextToken()) != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && manifestParser.getName().equals(matcher)) { - Log.d(TAG, "Manifest Parser Count: " + manifestParser.getAttributeCount()); + Timber.tag(TAG).d("Manifest Parser Count: %s", manifestParser.getAttributeCount()); for (int i = 0; i < manifestParser.getAttributeCount(); i++) { - Log.d(TAG, "Icon parser: " + manifestParser.getAttributeName(i)); + Timber.tag(TAG).d("Icon parser: %s", manifestParser.getAttributeName(i)); if (manifestParser.getAttributeName(i).equalsIgnoreCase("icon")) { iconId = Integer.parseInt(manifestParser.getAttributeValue(i).substring(1)); - Log.d(TAG, "Iconid:" + iconId); + Timber.tag(TAG).d("Iconid:%s", iconId); break; } } if (iconId != 0) { iconName = resources.getResourceName(iconId); - Log.d("AdaptiveIcon", "Iconname: " + iconName); + Timber.tag("AdaptiveIcon").d("Iconname: %s", iconName); if (iconName.contains("/")) { iconName = iconName.split("/")[1]; } @@ -104,7 +104,8 @@ public class AdaptiveIconProvider { if (parser != null) { int event; while ((event = parser.getEventType()) != XmlPullParser.END_DOCUMENT) { - Log.i(TAG, packageName + ":parserName: " + parser.getName() + " " + parser.getAttributeCount()); + Timber.tag(TAG) + .i(packageName + ":parserName: " + parser.getName() + " " + parser.getAttributeCount()); if (event == XmlPullParser.START_TAG) { switch (parser.getName()) { case "background" : @@ -140,8 +141,8 @@ public class AdaptiveIconProvider { } if (backgroundRes != -1) { - Log.d(TAG, "BackgroundRes: " + backgroundRes); - Log.d(TAG, "BackgroundResName: " + resources.getResourceName(backgroundRes)); + Timber.tag(TAG).d("BackgroundRes: %s", backgroundRes); + Timber.tag(TAG).d("BackgroundResName: %s", resources.getResourceName(backgroundRes)); try { background = ResourcesCompat.getDrawable(resources, backgroundRes, theme); } catch (Resources.NotFoundException e) { diff --git a/app/src/main/java/foundation/e/blisslauncher/core/Utilities.java b/app/src/main/java/foundation/e/blisslauncher/core/Utilities.java index f8518544d7ef00adc54f5706a8af782ac6e1b173..cca8f1647bd334da3c44bff9a8c7197effafde07 100755 --- a/app/src/main/java/foundation/e/blisslauncher/core/Utilities.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/Utilities.java @@ -9,7 +9,6 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.text.TextUtils; import android.util.DisplayMetrics; -import android.util.Log; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; @@ -27,6 +26,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; +import timber.log.Timber; + public class Utilities { private static final String TAG = "Utilities"; @@ -69,7 +70,7 @@ public class Utilities { out.close(); return out.toByteArray(); } catch (IOException e) { - Log.w(TAG, "Could not write bitmap"); + Timber.tag(TAG).w("Could not write bitmap"); return null; } } @@ -191,7 +192,7 @@ public class Utilities { return value; } } catch (Exception e) { - Log.d(TAG, "Unable to read system properties"); + Timber.tag(TAG).d("Unable to read system properties"); } return defaultValue; } diff --git a/app/src/main/java/foundation/e/blisslauncher/core/blur/BlurWallpaperProvider.kt b/app/src/main/java/foundation/e/blisslauncher/core/blur/BlurWallpaperProvider.kt index 23a27e432d7575f837331d2a5871a954ef3d08e3..13844a859098e08570ce95a7266ba9f4f903c00d 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/blur/BlurWallpaperProvider.kt +++ b/app/src/main/java/foundation/e/blisslauncher/core/blur/BlurWallpaperProvider.kt @@ -10,7 +10,6 @@ import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter import android.graphics.Paint import android.util.DisplayMetrics -import android.util.Log import android.view.WindowManager import android.widget.Toast import androidx.core.app.ActivityCompat @@ -23,6 +22,7 @@ import foundation.e.blisslauncher.core.utils.ensureOnMainThread import foundation.e.blisslauncher.core.utils.useApplicationContext import java.util.ArrayList import kotlin.math.max +import timber.log.Timber class BlurWallpaperProvider(val context: Context) { @@ -87,7 +87,7 @@ class BlurWallpaperProvider(val context: Context) { Manifest.permission.READ_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED ) { - Log.d("BWP", "NO permission granted") + Timber.tag("BWP").d("NO permission granted") return } diff --git a/app/src/main/java/foundation/e/blisslauncher/core/broadcast/ManagedProfileBroadcastReceiver.java b/app/src/main/java/foundation/e/blisslauncher/core/broadcast/ManagedProfileBroadcastReceiver.java index ddd9356205c27d6a1929776bf8c69dd0aca06807..63d95c4ab91c41e5a917f1d67982c9cf66114d51 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/broadcast/ManagedProfileBroadcastReceiver.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/broadcast/ManagedProfileBroadcastReceiver.java @@ -5,15 +5,15 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.UserHandle; -import android.util.Log; import foundation.e.blisslauncher.core.events.EventRelay; import foundation.e.blisslauncher.core.events.ForceReloadEvent; +import timber.log.Timber; public class ManagedProfileBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - Log.i("PROFILE", "onReceive: " + intent.getAction()); + Timber.tag("PROFILE").i("onReceive: " + intent.getAction()); final String action = intent.getAction(); if (Intent.ACTION_MANAGED_PROFILE_ADDED.equals(action) || Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) { diff --git a/app/src/main/java/foundation/e/blisslauncher/core/broadcast/PackageAddedRemovedHandler.java b/app/src/main/java/foundation/e/blisslauncher/core/broadcast/PackageAddedRemovedHandler.java index 93dc3af1c2c119c51098c6c8df3d5129e764c957..4a2fd200106b33afa45790ba1dee9fc4ce91b757 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/broadcast/PackageAddedRemovedHandler.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/broadcast/PackageAddedRemovedHandler.java @@ -4,13 +4,13 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Process; -import android.util.Log; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.core.events.AppAddEvent; import foundation.e.blisslauncher.core.events.AppChangeEvent; import foundation.e.blisslauncher.core.events.AppRemoveEvent; import foundation.e.blisslauncher.core.events.EventRelay; import foundation.e.blisslauncher.core.utils.UserHandle; +import timber.log.Timber; public class PackageAddedRemovedHandler extends BroadcastReceiver { @@ -21,7 +21,7 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver { if (!Process.myUserHandle().equals(user.getRealHandle())) { return; } - Log.d(TAG, "handleEvent() called with: ctx = [" + ctx + "], action = [" + action + "], packageName = [" + Timber.tag(TAG).d("handleEvent() called with: ctx = [" + ctx + "], action = [" + action + "], packageName = [" + packageName + "], user = [" + user + "], replacing = [" + replacing + "]"); // Insert into history new packages (not updated ones) if ("android.intent.action.PACKAGE_ADDED".equals(action) && !replacing) { diff --git a/app/src/main/java/foundation/e/blisslauncher/core/customviews/BlissDragShadowBuilder.java b/app/src/main/java/foundation/e/blisslauncher/core/customviews/BlissDragShadowBuilder.java index 372be64e1c269be16c9ab59a80c43440f61afe62..b1592bd9f9f43d95b4a964f46610831b6d2d4353 100755 --- a/app/src/main/java/foundation/e/blisslauncher/core/customviews/BlissDragShadowBuilder.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/customviews/BlissDragShadowBuilder.java @@ -2,9 +2,10 @@ package foundation.e.blisslauncher.core.customviews; import android.graphics.Canvas; import android.graphics.Point; -import android.util.Log; import android.view.View; +import timber.log.Timber; + /** Created by falcon on 15/2/18. */ public class BlissDragShadowBuilder extends View.DragShadowBuilder { @@ -26,12 +27,12 @@ public class BlissDragShadowBuilder extends View.DragShadowBuilder { mX = (int) x; mY = (int) y; - Log.i(TAG, "Touchpoint: " + mX + " " + mY); + Timber.tag(TAG).i("Touchpoint: " + mX + " " + mY); xOffset = mX - v.getWidth() / 2; yOffset = (mY - v.getHeight() / 2); - Log.i(TAG, "Offset: " + xOffset + " " + yOffset); + Timber.tag(TAG).i("Offset: " + xOffset + " " + yOffset); } // Defines a callback that sends the drag shadow dimensions and touch point back diff --git a/app/src/main/java/foundation/e/blisslauncher/core/customviews/HorizontalPager.java b/app/src/main/java/foundation/e/blisslauncher/core/customviews/HorizontalPager.java index 843e2404cdbd2cadfcf5ffdb1dda8d50012355de..853bf5148f125186cf51c0730c94961b31c50b22 100755 --- a/app/src/main/java/foundation/e/blisslauncher/core/customviews/HorizontalPager.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/customviews/HorizontalPager.java @@ -8,7 +8,6 @@ import android.graphics.Rect; import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; -import android.util.Log; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; @@ -28,6 +27,7 @@ import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.features.launcher.DetectSwipeGestureListener; import foundation.e.blisslauncher.features.launcher.LauncherActivity; import foundation.e.blisslauncher.features.launcher.OnSwipeDownListener; +import timber.log.Timber; public class HorizontalPager extends ViewGroup implements Insettable { private static final String TAG = "HorizontalPager"; @@ -283,7 +283,7 @@ public class HorizontalPager extends ViewGroup implements Insettable { */ final int action = ev.getAction(); if ((action == MotionEvent.ACTION_MOVE) && (mTouchState != TOUCH_STATE_REST)) { - Log.d(TAG, "onInterceptTouchEvent::shortcut=true"); + Timber.tag(TAG).d("onInterceptTouchEvent::shortcut=true"); return true; } @@ -561,7 +561,7 @@ public class HorizontalPager extends ViewGroup implements Insettable { for (int index = 0; index < childCount; ++index) { View child = getChildAt(index); if (child instanceof Insettable) { - Log.d(TAG, "child is instance of insettable"); + Timber.tag(TAG).d("child is instance of insettable"); ((Insettable) child).setInsets(insets); } } @@ -570,9 +570,9 @@ public class HorizontalPager extends ViewGroup implements Insettable { @Override public void onViewAdded(View child) { super.onViewAdded(child); - Log.d(TAG, "onViewAdded() called with: child = [" + child + "]"); + Timber.tag(TAG).d("onViewAdded() called with: child = [" + child + "]"); if (child instanceof Insettable) { - Log.d(TAG, "child is instance of insettable"); + Timber.tag(TAG).d("child is instance of insettable"); ((Insettable) child).setInsets(insets); } } diff --git a/app/src/main/java/foundation/e/blisslauncher/core/customviews/PagedView.java b/app/src/main/java/foundation/e/blisslauncher/core/customviews/PagedView.java index 5ef838c892a128ffa61799b29f7b149f6ce05f2e..8aa5d43aa43fcd72499f58857ff25c9819bdd12e 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/customviews/PagedView.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/customviews/PagedView.java @@ -24,7 +24,6 @@ import android.content.res.TypedArray; import android.graphics.Rect; import android.os.Bundle; import android.util.AttributeSet; -import android.util.Log; import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; @@ -43,6 +42,8 @@ import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.Utilities; import foundation.e.blisslauncher.core.customviews.pageindicators.PageIndicator; import foundation.e.blisslauncher.core.touch.OverScroll; +import timber.log.Timber; + import java.util.ArrayList; /** @@ -496,7 +497,7 @@ public abstract class PagedView extends ViewGrou // The children are given the same width and height as the workspace // unless they were set to WRAP_CONTENT if (DEBUG) - Log.d(TAG, "PagedView.onMeasure(): " + widthSize + ", " + heightSize); + Timber.tag(TAG).d("PagedView.onMeasure(): " + widthSize + ", " + heightSize); int myWidthSpec = MeasureSpec.makeMeasureSpec(widthSize - mInsets.left - mInsets.right, MeasureSpec.EXACTLY); int myHeightSpec = MeasureSpec.makeMeasureSpec(heightSize - mInsets.top - mInsets.bottom, MeasureSpec.EXACTLY); @@ -524,7 +525,7 @@ public abstract class PagedView extends ViewGrou } if (DEBUG) - Log.d(TAG, "PagedView.onLayout()"); + Timber.tag(TAG).d("PagedView.onLayout()"); if (getPageScrolls(mPageScrolls, true, SIMPLE_SCROLL_LOGIC)) { pageScrollChanged = true; diff --git a/app/src/main/java/foundation/e/blisslauncher/core/utils/AppUtils.java b/app/src/main/java/foundation/e/blisslauncher/core/utils/AppUtils.java index 449764afb2f023a520d55f5ddc939b4a68bd7c8d..577de930817238db6eea78ed785315d7e0fe5d64 100755 --- a/app/src/main/java/foundation/e/blisslauncher/core/utils/AppUtils.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/utils/AppUtils.java @@ -25,13 +25,14 @@ import android.content.pm.LauncherApps; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.UserManager; -import android.util.Log; import androidx.annotation.Nullable; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.IconsHandler; import foundation.e.blisslauncher.core.database.model.ApplicationItem; import foundation.e.blisslauncher.features.launcher.AppProvider; +import timber.log.Timber; + import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -56,7 +57,7 @@ public class AppUtils { // Handle multi-profile support introduced in Android 5 (#542) for (android.os.UserHandle profile : manager.getUserProfiles()) { UserHandle user = new UserHandle(manager.getSerialNumberForUser(profile), profile); - Log.i(TAG, "totalAppsBefore: " + sLauncherApps.getActivityList(null, profile).size()); + Timber.tag(TAG).i("totalAppsBefore: %s", sLauncherApps.getActivityList(null, profile).size()); List infos = sLauncherApps.getActivityList(null, profile); for (LauncherActivityInfo activityInfo : infos) { ApplicationInfo appInfo = activityInfo.getApplicationInfo(); @@ -80,7 +81,7 @@ public class AppUtils { appArrayMap.put(applicationItem.id, applicationItem); } } - Log.i(TAG, "Total Apps Loaded: " + appArrayMap.size()); + Timber.tag(TAG).i("Total Apps Loaded: %s", appArrayMap.size()); return appArrayMap; } diff --git a/app/src/main/java/foundation/e/blisslauncher/core/utils/GraphicsUtil.java b/app/src/main/java/foundation/e/blisslauncher/core/utils/GraphicsUtil.java index 47d965efcdf13ab309debd24881c58fe3535b9ae..afa8b9184ac627b3235df8eb8c0af2421622feef 100755 --- a/app/src/main/java/foundation/e/blisslauncher/core/utils/GraphicsUtil.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/utils/GraphicsUtil.java @@ -23,11 +23,12 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import android.util.Log; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.DeviceProfile; import foundation.e.blisslauncher.core.database.model.FolderItem; +import timber.log.Timber; + import java.util.HashMap; import java.util.Map; @@ -53,7 +54,7 @@ public class GraphicsUtil { int width = appIconWidth; int height = width; // Square icons - Log.i(TAG, "generateFolderIcon: " + width + "*" + height); + Timber.tag(TAG).i("generateFolderIcon: " + width + "*" + height); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); @@ -207,7 +208,7 @@ public class GraphicsUtil { return color; } else { - Log.i(TAG, "getDominantColor: white"); + Timber.tag(TAG).i("getDominantColor: white"); return Color.WHITE; } } diff --git a/app/src/main/java/foundation/e/blisslauncher/core/wallpaper/WallpaperManagerCompat.kt b/app/src/main/java/foundation/e/blisslauncher/core/wallpaper/WallpaperManagerCompat.kt index 4ccb598e062f5e33918620694287b8a6a2b497b3..febe01f77b870074a90eee8da891b7523ebc98fd 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/wallpaper/WallpaperManagerCompat.kt +++ b/app/src/main/java/foundation/e/blisslauncher/core/wallpaper/WallpaperManagerCompat.kt @@ -20,12 +20,12 @@ import android.app.WallpaperManager import android.content.Context import android.os.Handler import android.os.Looper -import android.util.Log import foundation.e.blisslauncher.core.utils.SingletonHolder import foundation.e.blisslauncher.core.utils.ensureOnMainThread import foundation.e.blisslauncher.core.utils.useApplicationContext import foundation.e.blisslauncher.core.wallpaper.WallpaperColorsCompat.Companion.HINT_SUPPORTS_DARK_THEME import java.lang.reflect.Method +import timber.log.Timber class WallpaperManagerCompat(val context: Context) { @@ -48,7 +48,7 @@ class WallpaperManagerCompat(val context: Context) { try { wcColorHintsMethod = WallpaperColors::class.java.getDeclaredMethod("getColorHints") } catch (exc: Exception) { - Log.e(TAG, "getColorHints not available", exc) + Timber.tag(TAG).e(exc, "getColorHints not available") } wallpaperManager.addOnColorsChangedListener( { colors, which -> @@ -72,7 +72,7 @@ class WallpaperManagerCompat(val context: Context) { try { hints = it.invoke(wallpaperColors) as Int } catch (e: Exception) { - Log.e(TAG, "error calling color hints", e) + Timber.tag(TAG).e(e, "error calling color hints") } } this.wallpaperColors = WallpaperColorsCompat(wallpaperColors.primaryColor.toArgb(), hints) diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/AppProvider.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/AppProvider.java index 04069a7b8b6d108fb8f8879f29e455390c13ea48..ec6e1ad2647cbe64f346144a920385f6467e8c31 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/AppProvider.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/AppProvider.java @@ -15,7 +15,6 @@ import android.os.Build; import android.os.Process; import android.os.UserManager; import android.provider.MediaStore; -import android.util.Log; import android.util.LongSparseArray; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.R; @@ -37,8 +36,11 @@ import foundation.e.blisslauncher.features.launcher.tasks.LoadDatabaseTask; import foundation.e.blisslauncher.features.launcher.tasks.LoadShortcutTask; import foundation.e.blisslauncher.features.shortcuts.DeepShortcutManager; import foundation.e.blisslauncher.features.shortcuts.ShortcutInfoCompat; +import timber.log.Timber; + import java.text.Collator; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -145,8 +147,8 @@ public class AppProvider { @Override public void onPackagesAvailable(String[] packageNames, android.os.UserHandle user, boolean replacing) { - Log.d(TAG, "onPackagesAvailable() called with: packageNames = [" + packageNames + "], user = [" + user - + "], replacing = [" + replacing + "]"); + Timber.tag(TAG).d("onPackagesAvailable() called with: packageNames = [" + Arrays.toString(packageNames) + + "], user = [" + user + "], replacing = [" + replacing + "]"); for (String packageName : packageNames) { PackageAddedRemovedHandler.handleEvent(mContext, "android.intent.action.MEDIA_MOUNTED", packageName, new UserHandle(manager.getSerialNumberForUser(user), user), false); @@ -155,23 +157,23 @@ public class AppProvider { @Override public void onPackagesUnavailable(String[] packageNames, android.os.UserHandle user, boolean replacing) { - Log.d(TAG, "onPackagesUnavailable() called with: packageNames = [" + packageNames + "], user = [" + user - + "], replacing = [" + replacing + "]"); + Timber.tag(TAG).d("onPackagesUnavailable() called with: packageNames = [" + + Arrays.toString(packageNames) + "], user = [" + user + "], replacing = [" + replacing + "]"); PackageAddedRemovedHandler.handleEvent(mContext, "android.intent.action.MEDIA_UNMOUNTED", null, new UserHandle(manager.getSerialNumberForUser(user), user), false); } @Override public void onPackagesSuspended(String[] packageNames, android.os.UserHandle user) { - Log.d(TAG, "onPackagesSuspended() called with: packageNames = [" + packageNames + "], user = [" + user - + "]"); + Timber.tag(TAG).d("onPackagesSuspended() called with: packageNames = [" + Arrays.toString(packageNames) + + "], user = [" + user + "]"); } @Override public void onPackagesUnsuspended(String[] packageNames, android.os.UserHandle user) { super.onPackagesUnsuspended(packageNames, user); - Log.d(TAG, "onPackagesUnsuspended() called with: packageNames = [" + packageNames + "], user = [" + user - + "]"); + Timber.tag(TAG).d("onPackagesUnsuspended() called with: packageNames = [" + + Arrays.toString(packageNames) + "], user = [" + user + "]"); } }); @@ -195,7 +197,7 @@ public class AppProvider { } public synchronized void reload(boolean force) { - Log.d(TAG, "reload() called"); + Timber.tag(TAG).d("reload() called"); isSdCardReady = Utilities.isBootCompleted(); @@ -213,42 +215,42 @@ public class AppProvider { } private synchronized void initializeAppLoading(LoadAppsTask loader) { - Log.d(TAG, "initializeAppLoading() called with: loader = [" + loader + "]"); + Timber.tag(TAG).d("initializeAppLoading() called with: loader = [" + loader + "]"); appsLoaded = false; loader.setAppProvider(this); loader.executeOnExecutor(AppExecutors.getInstance().appIO()); } private synchronized void initializeShortcutsLoading(LoadShortcutTask loader) { - Log.d(TAG, "initializeShortcutsLoading() called with: loader = [" + loader + "]"); + Timber.tag(TAG).d("initializeShortcutsLoading() called with: loader = [" + loader + "]"); shortcutsLoaded = false; loader.setAppProvider(this); loader.executeOnExecutor(AppExecutors.getInstance().shortcutIO()); } private synchronized void initializeDatabaseLoading(LoadDatabaseTask loader) { - Log.d(TAG, "initializeDatabaseLoading() called with: loader = [" + loader + "]"); + Timber.tag(TAG).d("initializeDatabaseLoading() called with: loader = [" + loader + "]"); databaseLoaded = false; loader.setAppProvider(this); loader.executeOnExecutor(AppExecutors.getInstance().diskIO()); } public synchronized void loadAppsOver(Map appItemsPair) { - Log.d(TAG, "loadAppsOver() called " + mStopped); + Timber.tag(TAG).d("loadAppsOver() called %s", mStopped); mApplicationItems = appItemsPair; appsLoaded = true; handleAllProviderLoaded(); } public synchronized void loadShortcutsOver(Map shortcuts) { - Log.d(TAG, "loadShortcutsOver() called with: shortcuts = [" + shortcuts + "]" + mStopped); + Timber.tag(TAG).d("loadShortcutsOver() called with: shortcuts = [" + shortcuts + "]" + mStopped); mShortcutInfoCompats = shortcuts; shortcutsLoaded = true; handleAllProviderLoaded(); } public synchronized void loadDatabaseOver(List databaseItems) { - Log.d(TAG, "loadDatabaseOver() called with: databaseItems = [" + Thread.currentThread().getName() + "]" + Timber.tag(TAG).d("loadDatabaseOver() called with: databaseItems = [" + Thread.currentThread().getName() + "]" + mStopped); this.mDatabaseItems = databaseItems; databaseLoaded = true; @@ -267,15 +269,15 @@ public class AppProvider { } private List prepareLauncherItems() { - Log.d(TAG, "prepareLauncherItems() called"); + Timber.tag(TAG).d("prepareLauncherItems() called"); /** Indices of folder in {@link #mLauncherItems}. */ LongSparseArray foldersIndex = new LongSparseArray<>(); List mLauncherItems = new ArrayList<>(); Collection applicationItems = mApplicationItems.values(); - Log.i(TAG, "Total number of apps: " + applicationItems.size()); - Log.i(TAG, "Total number of items in database: " + mDatabaseItems.size()); + Timber.tag(TAG).i("Total number of apps: %s", applicationItems.size()); + Timber.tag(TAG).i("Total number of items in database: %s", mDatabaseItems.size()); for (LauncherItem databaseItem : mDatabaseItems) { if (databaseItem.itemType == Constants.ITEM_TYPE_APPLICATION) { ApplicationItem applicationItem = mApplicationItems.get(databaseItem.id); @@ -283,9 +285,9 @@ public class AppProvider { UserHandle userHandle = new UserHandle(); if ((isAppOnSdcard(databaseItem.packageName, userHandle) || !isSdCardReady) && !DISABLED_PACKAGES.contains(databaseItem.packageName)) { - Log.d(TAG, "Missing package: " + databaseItem.packageName); - Log.d(TAG, "Is App on Sdcard " + isAppOnSdcard(databaseItem.packageName, userHandle)); - Log.d(TAG, "Is Sdcard ready " + isSdCardReady); + Timber.tag(TAG).d("Missing package: %s", databaseItem.packageName); + Timber.tag(TAG).d("Is App on Sdcard %s", isAppOnSdcard(databaseItem.packageName, userHandle)); + Timber.tag(TAG).d("Is Sdcard ready %s", isSdCardReady); pendingPackages.addToList(userHandle, databaseItem.packageName); applicationItem = new ApplicationItem(); @@ -315,7 +317,7 @@ public class AppProvider { FolderItem folderItem = (FolderItem) mLauncherItems.get(index); folderItem.items.add(applicationItem); } else { - Log.e("AppProvider", "folder not found for item: " + applicationItem.id); + Timber.tag("AppProvider").e("folder not found for item: %s", applicationItem.id); } } } else if (databaseItem.itemType == Constants.ITEM_TYPE_SHORTCUT) { @@ -419,7 +421,7 @@ public class AppProvider { private ShortcutItem prepareShortcutForOreo(LauncherItem databaseItem) { ShortcutInfoCompat info = mShortcutInfoCompats.get(databaseItem.id); if (info == null) { - Log.d(TAG, "prepareShortcutForOreo() called with: databaseItem = [" + databaseItem + "]"); + Timber.tag(TAG).d("prepareShortcutForOreo() called with: databaseItem = [" + databaseItem + "]"); return null; } @@ -466,7 +468,7 @@ public class AppProvider { } } - Collections.sort(mLauncherItems, (app1, app2) -> { + mLauncherItems.sort((app1, app2) -> { Collator collator = Collator.getInstance(); return collator.compare(app1.title.toString(), app2.title.toString()); }); diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/EventsObserverImpl.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/EventsObserverImpl.java index 171cf1cade3924a21bb0d907b2464448eb88548b..f59720048cfd04935ce198e0bb9b6892314a1ab2 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/EventsObserverImpl.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/EventsObserverImpl.java @@ -1,6 +1,5 @@ package foundation.e.blisslauncher.features.launcher; -import android.util.Log; import foundation.e.blisslauncher.core.events.AppAddEvent; import foundation.e.blisslauncher.core.events.AppChangeEvent; import foundation.e.blisslauncher.core.events.AppRemoveEvent; @@ -9,6 +8,8 @@ import foundation.e.blisslauncher.core.events.EventRelay; import foundation.e.blisslauncher.core.events.ForceReloadEvent; import foundation.e.blisslauncher.core.events.ShortcutAddEvent; import foundation.e.blisslauncher.core.events.TimeChangedEvent; +import timber.log.Timber; + import java.util.Calendar; public class EventsObserverImpl implements EventRelay.EventsObserver { @@ -23,7 +24,7 @@ public class EventsObserverImpl implements EventRelay.EventsObserver { @Override public void accept(Event event) { - Log.i(TAG, "accept: " + event.getEventType()); + Timber.tag(TAG).i("accept: %s", event.getEventType()); switch (event.getEventType()) { case AppAddEvent.TYPE : launcherActivity.onAppAddEvent((AppAddEvent) event); diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 2b21ca172240af7f22ff95ecbd75353a86b06a95..f74e5a067aad918b31e6cc92a7e6ff2d12ad0a1c 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -46,7 +46,6 @@ import android.os.UserManager; import android.provider.Settings; import android.text.Editable; import android.text.TextWatcher; -import android.util.Log; import android.view.ContextThemeWrapper; import android.view.DragEvent; import android.view.Gravity; @@ -163,6 +162,7 @@ import io.reactivex.disposables.CompositeDisposable; import io.reactivex.observers.DisposableObserver; import io.reactivex.schedulers.Schedulers; import me.relex.circleindicator.CircleIndicator; +import timber.log.Timber; public class LauncherActivity extends AppCompatActivity implements @@ -2067,7 +2067,7 @@ public class LauncherActivity extends AppCompatActivity private void deleteShortcutFromProvider(String id) { ContentResolver resolver = getContentResolver(); int count = resolver.delete(Uri.parse("content://foundation.e.pwaplayer.provider/pwa"), null, new String[]{id}); - Log.d("LauncherActivity", "Items deleted from pwa provider: " + count); + Timber.tag("LauncherActivity").d("Items deleted from pwa provider: " + count); } private void removeShortcutView(ShortcutItem shortcutItem, BlissFrameLayout blissFrameLayout) { diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/tasks/LoadShortcutTask.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/tasks/LoadShortcutTask.java index ffe9df383755d3d89d161ea9791269a8b27d5c4c..3844ba07c263d0f0737e95b8d1cc03a73555e64b 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/tasks/LoadShortcutTask.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/tasks/LoadShortcutTask.java @@ -2,10 +2,11 @@ package foundation.e.blisslauncher.features.launcher.tasks; import android.os.AsyncTask; import android.os.Process; -import android.util.Log; import foundation.e.blisslauncher.features.launcher.AppProvider; import foundation.e.blisslauncher.features.shortcuts.DeepShortcutManager; import foundation.e.blisslauncher.features.shortcuts.ShortcutInfoCompat; +import timber.log.Timber; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,7 +29,7 @@ public class LoadShortcutTask extends AsyncTask doInBackground(Void... voids) { List list = DeepShortcutManager.getInstance(mAppProvider.getContext()) .queryForPinnedShortcuts(null, Process.myUserHandle()); - Log.i(TAG, "doInBackground: " + list.size()); + Timber.tag(TAG).i("doInBackground: %s", list.size()); Map shortcutInfoMap = new HashMap<>(); for (ShortcutInfoCompat shortcutInfoCompat : list) { shortcutInfoMap.put(shortcutInfoCompat.getId(), shortcutInfoCompat); diff --git a/app/src/main/java/foundation/e/blisslauncher/features/notification/NotificationRepository.java b/app/src/main/java/foundation/e/blisslauncher/features/notification/NotificationRepository.java index 7066f652f79801dc53383abbd9a3f7af778f221d..23ea98e8aba35a57a312d05ab9289fe866b963d8 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/notification/NotificationRepository.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/notification/NotificationRepository.java @@ -2,13 +2,14 @@ package foundation.e.blisslauncher.features.notification; import android.app.Notification; import android.service.notification.StatusBarNotification; -import android.util.Log; import com.jakewharton.rxrelay2.BehaviorRelay; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import timber.log.Timber; + /** Created by Amit Kumar Email : mr.doc10jl96@gmail.com */ public class NotificationRepository { @@ -29,7 +30,7 @@ public class NotificationRepository { } public void updateNotification(List list) { - Log.d(TAG, "updateNotification() called with: list = [" + list.size() + "]"); + Timber.tag(TAG).d("updateNotification() called with: list = [" + list.size() + "]"); Set notificationSet = new HashSet<>(); for (StatusBarNotification statusBarNotification : list) { Notification notification = statusBarNotification.getNotification(); diff --git a/app/src/main/java/foundation/e/blisslauncher/features/shortcuts/DeepShortcutManager.java b/app/src/main/java/foundation/e/blisslauncher/features/shortcuts/DeepShortcutManager.java index 3cfa63288d8e27b04348c592f3b9587a7e750c13..a1fa481ec3d6e4a483b9b06a116e81d0bde8d8a3 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/shortcuts/DeepShortcutManager.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/shortcuts/DeepShortcutManager.java @@ -26,8 +26,9 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.UserHandle; -import android.util.Log; import foundation.e.blisslauncher.core.Utilities; +import timber.log.Timber; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -106,7 +107,7 @@ public class DeepShortcutManager { mLauncherApps.pinShortcuts(packageName, pinnedIds, user); mWasLastCallSuccess = true; } catch (SecurityException | IllegalStateException e) { - Log.w(TAG, "Failed to unpin shortcut", e); + Timber.tag(TAG).w(e, "Failed to unpin shortcut"); mWasLastCallSuccess = false; } } @@ -127,9 +128,9 @@ public class DeepShortcutManager { try { mLauncherApps.pinShortcuts(packageName, pinnedIds, user); mWasLastCallSuccess = true; - Log.d(TAG, "pinShortcut called: " + key); + Timber.tag(TAG).d("pinShortcut called: " + key); } catch (SecurityException | IllegalStateException e) { - Log.w(TAG, "Failed to pin shortcut", e); + Timber.tag(TAG).w(e, "Failed to pin shortcut"); mWasLastCallSuccess = false; } } @@ -143,7 +144,7 @@ public class DeepShortcutManager { mLauncherApps.startShortcut(packageName, id, sourceBounds, startActivityOptions, user); mWasLastCallSuccess = true; } catch (SecurityException | IllegalStateException e) { - Log.e(TAG, "Failed to start shortcut", e); + Timber.tag(TAG).e(e, "Failed to start shortcut"); mWasLastCallSuccess = false; } } @@ -157,7 +158,7 @@ public class DeepShortcutManager { mWasLastCallSuccess = true; return icon; } catch (SecurityException | IllegalStateException e) { - Log.e(TAG, "Failed to get shortcut icon", e); + Timber.tag(TAG).e(e, "Failed to get shortcut icon"); mWasLastCallSuccess = false; } } @@ -211,7 +212,7 @@ public class DeepShortcutManager { shortcutInfos = mLauncherApps.getShortcuts(q, user); mWasLastCallSuccess = true; } catch (SecurityException | IllegalStateException e) { - Log.e(TAG, "Failed to query for shortcuts", e); + Timber.tag(TAG).e(e, "Failed to query for shortcuts"); mWasLastCallSuccess = false; } if (shortcutInfos == null) { @@ -233,7 +234,7 @@ public class DeepShortcutManager { try { return mLauncherApps.hasShortcutHostPermission(); } catch (SecurityException | IllegalStateException e) { - Log.e(TAG, "Failed to make shortcut manager call", e); + Timber.tag(TAG).e(e, "Failed to make shortcut manager call"); } } return false; diff --git a/app/src/main/java/foundation/e/blisslauncher/features/shortcuts/InstallShortcutReceiver.java b/app/src/main/java/foundation/e/blisslauncher/features/shortcuts/InstallShortcutReceiver.java index e7bd6d1a05881fcd98bc4e1f2a57c02624f4eb0e..0085dd54ec0dc0b77774bdba09afabe26180f5d4 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/shortcuts/InstallShortcutReceiver.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/shortcuts/InstallShortcutReceiver.java @@ -8,7 +8,6 @@ import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.os.UserManager; -import android.util.Log; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.core.IconsHandler; import foundation.e.blisslauncher.core.Utilities; @@ -17,6 +16,8 @@ import foundation.e.blisslauncher.core.events.EventRelay; import foundation.e.blisslauncher.core.events.ShortcutAddEvent; import foundation.e.blisslauncher.core.utils.Constants; import foundation.e.blisslauncher.core.utils.UserHandle; +import timber.log.Timber; + import java.io.ByteArrayOutputStream; public class InstallShortcutReceiver extends BroadcastReceiver { @@ -56,11 +57,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver { } public static void queueShortcut(ShortcutInfoCompat info, Context context) { - Log.d(TAG, "queueShortcut() called with: info = [" + info + "], context = [" + context + "]"); + Timber.tag(TAG).d("queueShortcut() called with: info = [" + info + "], context = [" + context + "]"); UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); ShortcutItem shortcutItem = new ShortcutItem(); shortcutItem.id = info.getId(); - Log.i(TAG, "queueShortcut: " + shortcutItem.id); + Timber.tag(TAG).i("queueShortcut: " + shortcutItem.id); shortcutItem.user = new UserHandle(userManager.getSerialNumberForUser(info.getUserHandle()), info.getUserHandle()); shortcutItem.packageName = info.getPackage(); @@ -86,7 +87,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver { if (intent == null) { // If the intent is null, we can't construct a valid ShortcutInfo, so we return // null - Log.e(TAG, "Can't construct ShortcutInfo with null intent"); + Timber.tag(TAG).e("Can't construct ShortcutInfo with null intent"); return null; } diff --git a/app/src/main/java/foundation/e/blisslauncher/features/usagestats/AppUsageStats.java b/app/src/main/java/foundation/e/blisslauncher/features/usagestats/AppUsageStats.java index 544193ae4d655a9982af5a4cf54665600b0ce67d..4b2506dee6a6ca7065b040a4f49be12c8a1ebf7d 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/usagestats/AppUsageStats.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/usagestats/AppUsageStats.java @@ -7,13 +7,13 @@ import android.app.usage.UsageStatsManager; import android.content.Context; import android.content.Intent; import android.provider.Settings; -import android.util.Log; import android.widget.Toast; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.Preferences; +import timber.log.Timber; + import java.util.ArrayList; import java.util.Calendar; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -51,7 +51,7 @@ public class AppUsageStats { } if (aggregatedStats.size() == 0 && Preferences.shouldOpenUsageAccess(mContext)) { - Log.i(TAG, "The user may not allow the access to apps usage. "); + Timber.tag(TAG).i("The user may not allow the access to apps usage. "); Toast.makeText(mContext, mContext.getString(R.string.explanation_access_to_appusage_is_not_enabled), Toast.LENGTH_LONG).show(); mContext.startActivity(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)); @@ -59,7 +59,7 @@ public class AppUsageStats { } else { Set> set = aggregatedStats.entrySet(); List> list = new ArrayList<>(set); - Collections.sort(list, (o1, o2) -> Long.compare(o2.getValue().getTotalTimeInForeground(), + list.sort((o1, o2) -> Long.compare(o2.getValue().getTotalTimeInForeground(), o1.getValue().getTotalTimeInForeground())); for (Map.Entry stringUsageStatsEntry : list) { usageStats.add(stringUsageStatsEntry.getValue()); diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/CustomLocationPreference.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/CustomLocationPreference.java index e33b04f224ea8aad667103ff22febe1d18508e9d..4ed1f1af67e6ad4e8344b071e83b6ce3be26152a 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/CustomLocationPreference.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/CustomLocationPreference.java @@ -9,7 +9,6 @@ import android.os.Handler; import android.preference.EditTextPreference; import android.text.TextUtils; import android.util.AttributeSet; -import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.Toast; @@ -19,6 +18,7 @@ import java.util.HashSet; import java.util.List; import lineageos.weather.LineageWeatherManager; import lineageos.weather.WeatherLocation; +import timber.log.Timber; public class CustomLocationPreference extends EditTextPreference implements @@ -142,7 +142,7 @@ public class CustomLocationPreference extends EditTextPreference public void onLookupCityRequestCompleted(int status, final List locations) { mHandler.post(() -> { final Context context = getContext(); - Log.i(TAG, "onLookupCityRequestCompleted: " + status + " " + (locations == null)); + Timber.tag(TAG).i("onLookupCityRequestCompleted: " + status + " " + (locations == null)); if (locations == null || locations.isEmpty()) { Toast.makeText(context, context.getString(R.string.weather_retrieve_location_dialog_title), Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/DeviceStatusService.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/DeviceStatusService.java index 78e900b7374c694f623346b153c2e917ba69e987..5367100594337c54739895a89db36600c0cd6568 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/DeviceStatusService.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/DeviceStatusService.java @@ -7,8 +7,8 @@ import android.content.Intent; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.os.IBinder; -import android.util.Log; import foundation.e.blisslauncher.core.utils.Constants; +import timber.log.Timber; public class DeviceStatusService extends Service { @@ -26,7 +26,7 @@ public class DeviceStatusService extends Service { boolean hasConnection = !intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); if (D) - Log.d(TAG, "Got connectivity change, has connection: " + hasConnection); + Timber.tag(TAG).d("Got connectivity change, has connection: " + hasConnection); Intent i = new Intent(context, WeatherUpdateService.class); if (hasConnection) { @@ -50,14 +50,14 @@ public class DeviceStatusService extends Service { @Override public void onDestroy() { if (D) - Log.d(TAG, "Stopping service"); + Timber.tag(TAG).d("Stopping service"); unregisterReceiver(mDeviceStatusListenerReceiver); } @Override public int onStartCommand(Intent intent, int flags, int startId) { if (D) - Log.d(TAG, "Starting service"); + Timber.tag(TAG).d("Starting service"); return START_STICKY; } diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/ForecastBuilder.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/ForecastBuilder.java index 7b927e29f9b7d5538fc993277b94d27fa04a4255..235603c7240e2e7442c0864dc34d3910265672aa 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/ForecastBuilder.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/ForecastBuilder.java @@ -8,7 +8,6 @@ import static lineageos.providers.WeatherContract.WeatherColumns.WindSpeedUnit.M import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; @@ -23,6 +22,7 @@ import java.util.Locale; import java.util.TimeZone; import lineageos.weather.WeatherInfo; import lineageos.weather.util.WeatherUtils; +import timber.log.Timber; public class ForecastBuilder { @@ -41,7 +41,7 @@ public class ForecastBuilder { @SuppressLint("InflateParams") public static void buildLargePanel(Context context, View weatherPanel, WeatherInfo w) { if (weatherPanel == null) { - Log.d(TAG, "Invalid view passed"); + Timber.tag(TAG).d("Invalid view passed"); return; } @@ -125,7 +125,7 @@ public class ForecastBuilder { @SuppressLint("InflateParams") private static void buildSmallPanel(Context context, LinearLayout smallPanel, WeatherInfo w) { if (smallPanel == null) { - Log.d(TAG, "Invalid view passed"); + Timber.tag(TAG).d("Invalid view passed"); return; } diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherIconUtils.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherIconUtils.java index dbcc2525bb23ff1830efbb10b80c2b374ed02435..b4dd89085ace9268aec7ad5bf0432bed50ea317f 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherIconUtils.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherIconUtils.java @@ -12,9 +12,9 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.DisplayMetrics; -import android.util.Log; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.utils.Constants; +import timber.log.Timber; public class WeatherIconUtils { private static final String TAG = "WeatherIconUtils"; @@ -97,12 +97,12 @@ public class WeatherIconUtils { public static Bitmap getBitmapFromResource(Resources res, int resId, int density) { if (density == 0) { if (D) - Log.d(TAG, "Decoding resource id = " + resId + " for default density"); + Timber.tag(TAG).d("Decoding resource id = " + resId + " for default density"); return BitmapFactory.decodeResource(res, resId); } if (D) - Log.d(TAG, "Decoding resource id = " + resId + " for density = " + density); + Timber.tag(TAG).d("Decoding resource id = " + resId + " for density = " + density); Drawable d = res.getDrawableForDensity(resId, density); if (d instanceof BitmapDrawable) { BitmapDrawable bd = (BitmapDrawable) d; diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java index 2fd655ffe9c666dccaa73fa8272c09df0591cf8f..c6a56ee597f9369410107d124101c2378f92f8c2 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java @@ -5,7 +5,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.AttributeSet; -import android.util.Log; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; @@ -14,6 +13,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.Preferences; import foundation.e.blisslauncher.features.launcher.LauncherActivity; +import timber.log.Timber; public class WeatherInfoView extends LinearLayout { @@ -92,7 +92,7 @@ public class WeatherInfoView extends LinearLayout { private void updateWeatherPanel() { if (Preferences.getCachedWeatherInfo(getContext()) == null) { - Log.i("Weather", "getCacheWeatherInfo is null"); + Timber.tag("Weather").i("getCacheWeatherInfo is null"); mWeatherSetupTextView.setVisibility(VISIBLE); mWeatherPanel.setVisibility(GONE); mWeatherSetupTextView.setOnClickListener(v -> startWeatherPreferences()); diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherPreferences.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherPreferences.java index daf5c06f768951959240f3e4f888f0bc62e7a07a..97bd7e22be6a26fadace5e59d3d98e4d60d6fc8b 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherPreferences.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherPreferences.java @@ -17,13 +17,13 @@ import android.preference.PreferenceScreen; import android.preference.SwitchPreference; import android.provider.Settings; import android.text.TextUtils; -import android.util.Log; import android.widget.Toast; import androidx.annotation.NonNull; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.Preferences; import foundation.e.blisslauncher.core.utils.Constants; import lineageos.weather.LineageWeatherManager; +import timber.log.Timber; public class WeatherPreferences extends PreferenceActivity implements @@ -183,7 +183,7 @@ public class WeatherPreferences extends PreferenceActivity } if (Constants.DEBUG) { - Log.v(TAG, "Preference " + key + " changed, need update " + needWeatherUpdate + " force update " + Timber.tag(TAG).v("Preference " + key + " changed, need update " + needWeatherUpdate + " force update " + forceWeatherUpdate); } diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherSourceListenerService.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherSourceListenerService.java index e935ec462ab88c36a66c86a8102f1f2d68e9acbb..5c3fa4ffe0d7786c650adc6affb622e68effe1e3 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherSourceListenerService.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherSourceListenerService.java @@ -4,10 +4,10 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.IBinder; -import android.util.Log; import foundation.e.blisslauncher.core.Preferences; import foundation.e.blisslauncher.core.utils.Constants; import lineageos.weather.LineageWeatherManager; +import timber.log.Timber; public class WeatherSourceListenerService extends Service implements @@ -21,7 +21,7 @@ public class WeatherSourceListenerService extends Service @Override public void onWeatherServiceProviderChanged(String providerLabel) { if (D) - Log.d(TAG, "Weather Source changed " + providerLabel); + Timber.tag(TAG).d("Weather Source changed %s", providerLabel); Preferences.setWeatherSource(mContext, providerLabel); Preferences.setCachedWeatherInfo(mContext, 0, null); // The data contained in WeatherLocation is tightly coupled to the weather @@ -47,7 +47,7 @@ public class WeatherSourceListenerService extends Service weatherManager.registerWeatherServiceProviderChangeListener(this); mRegistered = true; if (D) - Log.d(TAG, "Listener registered"); + Timber.tag(TAG).d("Listener registered"); } @Override diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java index d7be85fdf0155b6f3963a7ceaf9bc70772b1a782..182169233a2fa69b9b1917afd230cdeaab68ea80 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java @@ -6,10 +6,11 @@ import android.content.Intent; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; -import android.util.Log; import androidx.annotation.Nullable; +import timber.log.Timber; + public class WeatherUpdateService extends Service { private static final String TAG = "WeatherUpdateService"; @@ -27,7 +28,7 @@ public class WeatherUpdateService extends Service { @SuppressLint("MissingPermission") @Override public void onCreate() { - Log.d(TAG, "onCreate"); + Timber.tag(TAG).d("onCreate"); mHandlerThread = new HandlerThread("WeatherUpdateServiceHandler"); mHandlerThread.start(); diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java index 9a10a3a2d80197c71c11476cd88814693000a82e..b3b27c7a8fa6419568902cb033b6c55fdb2077e9 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java @@ -8,7 +8,6 @@ import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationManager; import android.os.SystemClock; -import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -38,6 +37,7 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; +import timber.log.Timber; public class WeatherUpdater { @@ -98,7 +98,7 @@ public class WeatherUpdater { } private void updateWeather() { - Log.i(TAG, "Updating weather"); + Timber.tag(TAG).i("Updating weather"); Context context = mWeakContext.get(); if (Preferences.useCustomWeatherLocation(context)) { @@ -119,7 +119,7 @@ public class WeatherUpdater { @SuppressLint("MissingPermission") private void fetchNewLocation() { if (hasMissingPermissions()) { - Log.e(TAG, "Could not fetch location for missing permission"); + Timber.tag(TAG).e("Could not fetch location for missing permission"); return; } @@ -140,7 +140,7 @@ public class WeatherUpdater { } protected void requestWeatherUpdate(@NonNull Location location) { - Log.i(TAG, "Requesting weather info for location: " + location); + Timber.tag(TAG).i("Requesting weather info for location: %s", location); Context context = mWeakContext.get(); LineageWeatherManager weatherManager = LineageWeatherManager.getInstance(context); weatherManager.requestWeatherUpdate(location, (status, weatherInfo) -> notifyUi(context, weatherInfo, status)); @@ -148,11 +148,11 @@ public class WeatherUpdater { protected void requestCustomWeatherUpdate(@Nullable WeatherLocation location) { if (location == null) { - Log.w(TAG, "Custom location is null. Cannot request weather"); + Timber.tag(TAG).w("Custom location is null. Cannot request weather"); return; } - Log.i(TAG, "Requesting weather info for location: " + location); + Timber.tag(TAG).i("Requesting weather info for location: %s", location); Context context = mWeakContext.get(); LineageWeatherManager weatherManager = LineageWeatherManager.getInstance(context); weatherManager.requestWeatherUpdate(location, (status, weatherInfo) -> notifyUi(context, weatherInfo, status)); @@ -160,11 +160,11 @@ public class WeatherUpdater { private synchronized void onNewLocationFetched(@Nullable Location location) { if (location == null) { - Log.w(TAG, "Could not fetch any location"); + Timber.tag(TAG).w("Could not fetch any location"); return; } - Log.i(TAG, "New location fetched:" + location); + Timber.tag(TAG).i("New location fetched:%s", location); if (location.getProvider().equals(LocationManager.GPS_PROVIDER)) { mGpsLocation = location; @@ -182,11 +182,11 @@ public class WeatherUpdater { private void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int status) { if (weatherInfo == null) { - Log.i(TAG, "WeatherInfo is null. Status reported: " + status); + Timber.tag(TAG).i("WeatherInfo is null. Status reported: %s", status); return; } - Log.i(TAG, "WeatherInfo=" + weatherInfo); + Timber.tag(TAG).i("WeatherInfo=%s", weatherInfo); long now = SystemClock.elapsedRealtime(); Preferences.setCachedWeatherInfo(context, now, weatherInfo); @@ -215,7 +215,7 @@ public class WeatherUpdater { } private void reverseGeocodeLocation(@NonNull Location location) { - Log.i(TAG, "Reverse geocoding location " + location); + Timber.tag(TAG).i("Reverse geocoding location %s", location); final String url = "https://api.openweathermap.org/geo/1.0/reverse?lat=" + location.getLatitude() + "&lon=" + location.getLongitude() + "&limit=1&appid=" + mWeakContext.get().getString(R.string.default_key); @@ -228,7 +228,7 @@ public class WeatherUpdater { private void onReverseGeocoded(@NonNull Response response) { final ResponseBody body = response.body(); if (body == null) { - Log.w(TAG, "Reverse geocoding response is empty"); + Timber.tag(TAG).w("Reverse geocoding response is empty"); return; } @@ -238,12 +238,12 @@ public class WeatherUpdater { final JsonArray array = new JsonParser().parse(json).getAsJsonArray(); locales = array.get(0).getAsJsonObject().getAsJsonObject("local_names"); } catch (IOException | IllegalStateException | JsonSyntaxException exception) { - Log.e(TAG, "Exception caught", exception); + Timber.tag(TAG).e(exception, "Exception caught"); return; } if (locales == null) { - Log.e(TAG, "Could not get locales"); + Timber.tag(TAG).e("Could not get locales"); return; } @@ -277,7 +277,7 @@ public class WeatherUpdater { private final Callback mReverseGeocodeCallback = new Callback() { @Override public void onFailure(@NonNull Call call, @NonNull IOException e) { - Log.e(TAG, "Could not reverse geocode location", e); + Timber.tag(TAG).e(e, "Could not reverse geocode location"); } @Override diff --git a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetPicker.java b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetPicker.java index bf319d2686652d078ea0d3dec5ae9ac41cdfb754..ad48590a70900b664871148c93d48402129e4405 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetPicker.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetPicker.java @@ -11,12 +11,13 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Parcelable; import android.util.DisplayMetrics; -import android.util.Log; import android.widget.Toast; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import foundation.e.blisslauncher.R; +import timber.log.Timber; + import java.text.Collator; import java.util.ArrayList; import java.util.Collections; @@ -127,11 +128,11 @@ public class WidgetPicker extends Activity implements WidgetPickerAdapter.OnClic Resources packageResources = mPackageManager.getResourcesForApplication(info.provider.getPackageName()); icon = packageResources.getDrawableForDensity(info.icon, iconDensity); } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, "Can't load icon drawable 0x" + Integer.toHexString(info.icon) + " for provider: " + Timber.tag(TAG).w("Can't load icon drawable 0x" + Integer.toHexString(info.icon) + " for provider: " + info.provider); } if (icon == null) { - Log.w(TAG, "Can't load icon drawable 0x" + Integer.toHexString(info.icon) + " for provider: " + Timber.tag(TAG).w("Can't load icon drawable 0x" + Integer.toHexString(info.icon) + " for provider: " + info.provider); } } @@ -191,8 +192,8 @@ public class WidgetPicker extends Activity implements WidgetPickerAdapter.OnClic @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - Log.d(TAG, "onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + resultCode - + "], data = [" + data + "]"); + Timber.tag(TAG).d("onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + + resultCode + "], data = [" + data + "]"); if (requestCode == REQUEST_BIND_APPWIDGET) { int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (resultCode == RESULT_OK) { diff --git a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetViewBuilder.java b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetViewBuilder.java index 99093287a1d121a251c5ba6938654233f9da6562..d82478e1a9c1a3d433f8b200a6b3137079cfbc9e 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetViewBuilder.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetViewBuilder.java @@ -4,7 +4,6 @@ import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.os.Bundle; -import android.util.Log; import android.widget.LinearLayout; import androidx.annotation.NonNull; import foundation.e.blisslauncher.BlissLauncher; @@ -12,6 +11,7 @@ import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.customviews.RoundedWidgetView; import foundation.e.blisslauncher.core.utils.ThemesKt; import foundation.e.blisslauncher.features.launcher.LauncherActivity; +import timber.log.Timber; public class WidgetViewBuilder { @@ -38,7 +38,7 @@ public class WidgetViewBuilder { & AppWidgetProviderInfo.RESIZE_VERTICAL) == AppWidgetProviderInfo.RESIZE_VERTICAL) { launcherActivity.showWidgetResizeContainer(roundedWidgetView); } else { - Log.i(TAG, launcherActivity.getString(R.string.widget_is_not_resizable)); + Timber.tag(TAG).i(launcherActivity.getString(R.string.widget_is_not_resizable)); } return true; }); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6143679edb7f791e0f826cc8aca487affbe323d6..25a42ecb158cebb8aa40841aaad7865db0d8af47 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -67,10 +67,11 @@ mockito-core = "org.mockito:mockito-core:2.19.0" robolectric = "org.robolectric:robolectric:4.3" tools-desugar = "com.android.tools:desugar_jdk_libs:1.1.5" tools-leakcanary = "com.squareup.leakcanary:leakcanary-android:2.10" +tools-timber = "com.jakewharton.timber:timber:5.0.1" timber = "com.jakewharton.timber:timber:4.7.1" restriction-bypass = "com.github.ChickenHook:RestrictionBypass:2.2" elib = "foundation.e:elib:0.0.1-alpha11" -telemetry = "foundation.e.lib:telemetry:0.0.3-alpha" +telemetry = "foundation.e.lib:telemetry:0.0.4-alpha" [plugins] android-application = { id = "com.android.application", version.ref = "agp" }