Refactored Log calls to Timber

This commit is contained in:
Nite 2020-09-30 14:47:59 +02:00
parent 60b6a5dbde
commit 7217f2cca8
No known key found for this signature in database
GPG Key ID: 1D1AD59B1C6386C1
59 changed files with 286 additions and 405 deletions

View File

@ -10,4 +10,5 @@ android {
dependencies { dependencies {
api androidSupport.support api androidSupport.support
implementation other.timber
} }

View File

@ -328,7 +328,6 @@ public class DragSortController extends SimpleFloatViewManager implements View.O
final int numFooters = mDslv.getFooterViewsCount(); final int numFooters = mDslv.getFooterViewsCount();
final int count = mDslv.getCount(); final int count = mDslv.getCount();
// Log.d("mobeta", "touch down on position " + itemnum);
// We're only interested if the touch was on an // We're only interested if the touch was on an
// item that's not a header or footer. // item that's not a header or footer.
if (touchPos != AdapterView.INVALID_POSITION && touchPos >= numHeaders if (touchPos != AdapterView.INVALID_POSITION && touchPos >= numHeaders
@ -411,7 +410,6 @@ public class DragSortController extends SimpleFloatViewManager implements View.O
@Override @Override
public void onLongPress(MotionEvent e) { public void onLongPress(MotionEvent e) {
// Log.d("mobeta", "lift listener long pressed");
if (mHitPos != MISS && mDragInitMode == ON_LONG_PRESS) { if (mHitPos != MISS && mDragInitMode == ON_LONG_PRESS) {
mDslv.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); mDslv.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
startDrag(mHitPos, mCurrX - mItemX, mCurrY - mItemY); startDrag(mHitPos, mCurrX - mItemX, mCurrY - mItemY);
@ -446,7 +444,6 @@ public class DragSortController extends SimpleFloatViewManager implements View.O
@Override @Override
public final boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, public final boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) { float velocityY) {
// Log.d("mobeta", "on fling remove called");
if (mRemoveEnabled && mIsRemoving) { if (mRemoveEnabled && mIsRemoving) {
int w = mDslv.getWidth(); int w = mDslv.getWidth();
int minPos = w / 5; int minPos = w / 5;

View File

@ -6,7 +6,7 @@ import android.view.View;
import android.view.View.MeasureSpec; import android.view.View.MeasureSpec;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.util.Log; import timber.log.Timber;
/** /**
* Lightweight ViewGroup that wraps list items obtained from user's * Lightweight ViewGroup that wraps list items obtained from user's

View File

@ -7,7 +7,7 @@ import android.view.View.MeasureSpec;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.Checkable; import android.widget.Checkable;
import android.util.Log; import timber.log.Timber;
/** /**
* Lightweight ViewGroup that wraps list items obtained from user's * Lightweight ViewGroup that wraps list items obtained from user's

View File

@ -31,7 +31,7 @@ import android.graphics.drawable.Drawable;
import android.os.Environment; import android.os.Environment;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import timber.log.Timber;
import android.util.SparseBooleanArray; import android.util.SparseBooleanArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import android.view.Gravity; import android.view.Gravity;
@ -711,8 +711,6 @@ public class DragSortListView extends ListView {
DragSortItemView v; DragSortItemView v;
View child; View child;
// Log.d("mobeta",
// "getView: position="+position+" convertView="+convertView);
if (convertView != null) { if (convertView != null) {
v = (DragSortItemView) convertView; v = (DragSortItemView) convertView;
View oldChild = v.getChildAt(0); View oldChild = v.getChildAt(0);
@ -751,7 +749,6 @@ public class DragSortListView extends ListView {
final Drawable divider = getDivider(); final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight(); final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) { if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
@ -771,8 +768,6 @@ public class DragSortListView extends ListView {
b = expItem.getBottom() - childHeight; b = expItem.getBottom() - childHeight;
t = b - dividerHeight; t = b - dividerHeight;
} }
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread // Have to clip to support ColorDrawable on <= Gingerbread
canvas.save(); canvas.save();
canvas.clipRect(l, t, r, b); canvas.clipRect(l, t, r, b);
@ -818,11 +813,9 @@ public class DragSortListView extends ListView {
final int alpha = (int) (255f * mCurrFloatAlpha * alphaMod); final int alpha = (int) (255f * mCurrFloatAlpha * alphaMod);
canvas.save(); canvas.save();
// Log.d("mobeta", "clip rect bounds: " + canvas.getClipBounds());
canvas.translate(mFloatLoc.x, mFloatLoc.y); canvas.translate(mFloatLoc.x, mFloatLoc.y);
canvas.clipRect(0, 0, w, h); canvas.clipRect(0, 0, w, h);
// Log.d("mobeta", "clip rect bounds: " + canvas.getClipBounds());
canvas.saveLayerAlpha(0, 0, w, h, alpha, Canvas.ALL_SAVE_FLAG); canvas.saveLayerAlpha(0, 0, w, h, alpha, Canvas.ALL_SAVE_FLAG);
mFloatView.draw(canvas); mFloatView.draw(canvas);
canvas.restore(); canvas.restore();
@ -844,8 +837,7 @@ public class DragSortListView extends ListView {
} }
private void printPosData() { private void printPosData() {
Log.d("mobeta", "mSrcPos=" + mSrcPos + " mFirstExpPos=" + mFirstExpPos + " mSecondExpPos=" Timber.d("mSrcPos=%i mFirstExpPos=%i mSecondExpPos=%i", mSrcPos, mFirstExpPos, mSecondExpPos);
+ mSecondExpPos);
} }
private class HeightCache { private class HeightCache {
@ -989,13 +981,11 @@ public class DragSortListView extends ListView {
int divHeight = getDividerHeight(); int divHeight = getDividerHeight();
// Log.d("mobeta", "float mid="+mFloatViewMid);
int itemPos = startPos; int itemPos = startPos;
int itemTop = startTop; int itemTop = startTop;
if (mFloatViewMid < edge) { if (mFloatViewMid < edge) {
// scanning up for float position // scanning up for float position
// Log.d("mobeta", " edge="+edge);
while (itemPos >= 0) { while (itemPos >= 0) {
itemPos--; itemPos--;
itemHeight = getItemHeight(itemPos); itemHeight = getItemHeight(itemPos);
@ -1007,7 +997,6 @@ public class DragSortListView extends ListView {
itemTop -= itemHeight + divHeight; itemTop -= itemHeight + divHeight;
edge = getShuffleEdge(itemPos, itemTop); edge = getShuffleEdge(itemPos, itemTop);
// Log.d("mobeta", " edge="+edge);
if (mFloatViewMid >= edge) { if (mFloatViewMid >= edge) {
break; break;
@ -1017,7 +1006,6 @@ public class DragSortListView extends ListView {
} }
} else { } else {
// scanning down for float position // scanning down for float position
// Log.d("mobeta", " edge="+edge);
final int count = getCount(); final int count = getCount();
while (itemPos < count) { while (itemPos < count) {
if (itemPos == count - 1) { if (itemPos == count - 1) {
@ -1028,7 +1016,6 @@ public class DragSortListView extends ListView {
itemTop += divHeight + itemHeight; itemTop += divHeight + itemHeight;
itemHeight = getItemHeight(itemPos + 1); itemHeight = getItemHeight(itemPos + 1);
edge = getShuffleEdge(itemPos + 1, itemTop); edge = getShuffleEdge(itemPos + 1, itemTop);
// Log.d("mobeta", " edge="+edge);
// test for hit // test for hit
if (mFloatViewMid < edge) { if (mFloatViewMid < edge) {
@ -1060,7 +1047,6 @@ public class DragSortListView extends ListView {
edgeTop = edge; edgeTop = edge;
edgeBottom = lastEdge; edgeBottom = lastEdge;
} }
// Log.d("mobeta", "edgeTop="+edgeTop+" edgeBot="+edgeBottom);
int slideRgnHeight = (int) (0.5f * mSlideRegionFrac * edgeToEdge); int slideRgnHeight = (int) (0.5f * mSlideRegionFrac * edgeToEdge);
float slideRgnHeightF = (float) slideRgnHeight; float slideRgnHeightF = (float) slideRgnHeight;
@ -1072,8 +1058,6 @@ public class DragSortListView extends ListView {
mFirstExpPos = itemPos - 1; mFirstExpPos = itemPos - 1;
mSecondExpPos = itemPos; mSecondExpPos = itemPos;
mSlideFrac = 0.5f * ((float) (slideEdgeTop - mFloatViewMid)) / slideRgnHeightF; mSlideFrac = 0.5f * ((float) (slideEdgeTop - mFloatViewMid)) / slideRgnHeightF;
// Log.d("mobeta",
// "firstExp="+mFirstExpPos+" secExp="+mSecondExpPos+" slideFrac="+mSlideFrac);
} else if (mFloatViewMid < slideEdgeBottom) { } else if (mFloatViewMid < slideEdgeBottom) {
mFirstExpPos = itemPos; mFirstExpPos = itemPos;
mSecondExpPos = itemPos; mSecondExpPos = itemPos;
@ -1082,8 +1066,6 @@ public class DragSortListView extends ListView {
mSecondExpPos = itemPos + 1; mSecondExpPos = itemPos + 1;
mSlideFrac = 0.5f * (1.0f + ((float) (edgeBottom - mFloatViewMid)) mSlideFrac = 0.5f * (1.0f + ((float) (edgeBottom - mFloatViewMid))
/ slideRgnHeightF); / slideRgnHeightF);
// Log.d("mobeta",
// "firstExp="+mFirstExpPos+" secExp="+mSecondExpPos+" slideFrac="+mSlideFrac);
} }
} else { } else {
@ -1547,7 +1529,6 @@ public class DragSortListView extends ListView {
private void adjustOnReorder() { private void adjustOnReorder() {
final int firstPos = getFirstVisiblePosition(); final int firstPos = getFirstVisiblePosition();
// Log.d("mobeta", "first="+firstPos+" src="+mSrcPos);
if (mSrcPos < firstPos) { if (mSrcPos < firstPos) {
// collapsed src item is off screen; // collapsed src item is off screen;
// adjust the scroll after item heights have been fixed // adjust the scroll after item heights have been fixed
@ -1556,7 +1537,6 @@ public class DragSortListView extends ListView {
if (v != null) { if (v != null) {
top = v.getTop(); top = v.getTop();
} }
// Log.d("mobeta", "top="+top+" fvh="+mFloatViewHeight);
setSelectionFromTop(firstPos - 1, top - getPaddingTop()); setSelectionFromTop(firstPos - 1, top - getPaddingTop());
} }
} }
@ -1935,7 +1915,6 @@ public class DragSortListView extends ListView {
// first check cache for child height at this position // first check cache for child height at this position
int childHeight = mChildHeightCache.get(position); int childHeight = mChildHeightCache.get(position);
if (childHeight != -1) { if (childHeight != -1) {
// Log.d("mobeta", "found child height in cache!");
return childHeight; return childHeight;
} }
@ -2121,7 +2100,6 @@ public class DragSortListView extends ListView {
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// Log.d("mobeta", "onMeasure called");
if (mFloatView != null) { if (mFloatView != null) {
if (mFloatView.isLayoutRequested()) { if (mFloatView.isLayoutRequested()) {
measureFloatView(); measureFloatView();
@ -2159,7 +2137,6 @@ public class DragSortListView extends ListView {
doActionUpOrCancel(); doActionUpOrCancel();
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
// Log.d("mobeta", "calling stopDrag from onDragTouchEvent");
if (mDragState == DRAGGING) { if (mDragState == DRAGGING) {
stopDrag(false); stopDrag(false);
} }
@ -2326,7 +2303,6 @@ public class DragSortListView extends ListView {
if (updated) { if (updated) {
adjustAllItems(); adjustAllItems();
int scroll = adjustScroll(movePos, moveItem, oldFirstExpPos, oldSecondExpPos); int scroll = adjustScroll(movePos, moveItem, oldFirstExpPos, oldSecondExpPos);
// Log.d("mobeta", " adjust scroll="+scroll);
setSelectionFromTop(movePos, moveItem.getTop() + scroll - getPaddingTop()); setSelectionFromTop(movePos, moveItem.getTop() + scroll - getPaddingTop());
layoutChildren(); layoutChildren();
@ -2367,7 +2343,6 @@ public class DragSortListView extends ListView {
final int firstPos = getFirstVisiblePosition(); final int firstPos = getFirstVisiblePosition();
final int lastPos = getLastVisiblePosition(); final int lastPos = getLastVisiblePosition();
// Log.d("mobeta",
// "nHead="+numHeaders+" nFoot="+numFooters+" first="+firstPos+" last="+lastPos); // "nHead="+numHeaders+" nFoot="+numFooters+" first="+firstPos+" last="+lastPos);
int topLimit = getPaddingTop(); int topLimit = getPaddingTop();
if (firstPos < numHeaders) { if (firstPos < numHeaders) {
@ -2390,10 +2365,6 @@ public class DragSortListView extends ListView {
} }
} }
// Log.d("mobeta", "dragView top=" + (y - mDragDeltaY));
// Log.d("mobeta", "limit=" + limit);
// Log.d("mobeta", "mDragDeltaY=" + mDragDeltaY);
if (floatY < topLimit) { if (floatY < topLimit) {
mFloatLoc.y = topLimit; mFloatLoc.y = topLimit;
} else if (floatY + mFloatViewHeight > bottomLimit) { } else if (floatY + mFloatViewHeight > bottomLimit) {
@ -2865,7 +2836,6 @@ public class DragSortListView extends ListView {
return; return;
} }
// Log.d("mobeta", "scroll");
final int first = getFirstVisiblePosition(); final int first = getFirstVisiblePosition();
final int last = getLastVisiblePosition(); final int last = getLastVisiblePosition();
@ -2878,7 +2848,6 @@ public class DragSortListView extends ListView {
if (scrollDir == UP) { if (scrollDir == UP) {
View v = getChildAt(0); View v = getChildAt(0);
// Log.d("mobeta", "vtop="+v.getTop()+" padtop="+padTop);
if (v == null) { if (v == null) {
mScrolling = false; mScrolling = false;
return; return;
@ -2945,8 +2914,6 @@ public class DragSortListView extends ListView {
doDragFloatView(movePos, moveItem, false); doDragFloatView(movePos, moveItem, false);
mPrevTime = mCurrTime; mPrevTime = mCurrTime;
// Log.d("mobeta", " updated prevTime="+mPrevTime);
post(this); post(this);
} }
} }
@ -2968,10 +2935,10 @@ public class DragSortListView extends ListView {
if (!mFile.exists()) { if (!mFile.exists()) {
try { try {
mFile.createNewFile(); mFile.createNewFile();
Log.d("mobeta", "file created"); Timber.d("file created");
} catch (IOException e) { } catch (IOException e) {
Log.w("mobeta", "Could not create dslv_state.txt"); Timber.w("Could not create dslv_state.txt");
Log.d("mobeta", e.getMessage()); Timber.d(e.getMessage());
} }
} }

View File

@ -7,7 +7,7 @@ import android.widget.ListView;
import android.widget.ImageView; import android.widget.ImageView;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.util.Log; import timber.log.Timber;
/** /**
* Simple implementation of the FloatViewManager class. Uses list * Simple implementation of the FloatViewManager class. Uses list

View File

@ -9,4 +9,5 @@ android {
dependencies { dependencies {
implementation "androidx.appcompat:appcompat-resources:1.2.0" implementation "androidx.appcompat:appcompat-resources:1.2.0"
implementation other.timber
} }

View File

@ -16,7 +16,7 @@ import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import timber.log.Timber;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -88,11 +88,6 @@ public abstract class MenuDrawer extends ViewGroup {
OVERLAY, OVERLAY,
} }
/**
* Tag used when logging.
*/
private static final String TAG = "MenuDrawer";
/** /**
* Indicates whether debug code should be enabled. * Indicates whether debug code should be enabled.
*/ */
@ -1520,27 +1515,27 @@ public abstract class MenuDrawer extends ViewGroup {
protected void logDrawerState(int state) { protected void logDrawerState(int state) {
switch (state) { switch (state) {
case STATE_CLOSED: case STATE_CLOSED:
Log.d(TAG, "[DrawerState] STATE_CLOSED"); Timber.d("[DrawerState] STATE_CLOSED");
break; break;
case STATE_CLOSING: case STATE_CLOSING:
Log.d(TAG, "[DrawerState] STATE_CLOSING"); Timber.d("[DrawerState] STATE_CLOSING");
break; break;
case STATE_DRAGGING: case STATE_DRAGGING:
Log.d(TAG, "[DrawerState] STATE_DRAGGING"); Timber.d("[DrawerState] STATE_DRAGGING");
break; break;
case STATE_OPENING: case STATE_OPENING:
Log.d(TAG, "[DrawerState] STATE_OPENING"); Timber.d("[DrawerState] STATE_OPENING");
break; break;
case STATE_OPEN: case STATE_OPEN:
Log.d(TAG, "[DrawerState] STATE_OPEN"); Timber.d("[DrawerState] STATE_OPEN");
break; break;
default: default:
Log.d(TAG, "[DrawerState] Unknown: " + state); Timber.d("[DrawerState] Unknown: %s", state);
} }
} }

View File

@ -10,9 +10,6 @@ import android.view.VelocityTracker;
import android.view.View; import android.view.View;
public class OverlayDrawer extends DraggableDrawer { public class OverlayDrawer extends DraggableDrawer {
private static final String TAG = "OverlayDrawer";
private int mPeekSize; private int mPeekSize;
private Runnable mRevealRunnable = new Runnable() { private Runnable mRevealRunnable = new Runnable() {

View File

@ -3,9 +3,6 @@ package net.simonvt.menudrawer;
import android.view.animation.Interpolator; import android.view.animation.Interpolator;
class PeekInterpolator implements Interpolator { class PeekInterpolator implements Interpolator {
private static final String TAG = "PeekInterpolator";
private static final SinusoidalInterpolator SINUSOIDAL_INTERPOLATOR = new SinusoidalInterpolator(); private static final SinusoidalInterpolator SINUSOIDAL_INTERPOLATOR = new SinusoidalInterpolator();
@Override @Override

View File

@ -8,9 +8,6 @@ import android.view.MotionEvent;
import android.view.VelocityTracker; import android.view.VelocityTracker;
public class SlidingDrawer extends DraggableDrawer { public class SlidingDrawer extends DraggableDrawer {
private static final String TAG = "OverlayDrawer";
SlidingDrawer(Activity activity, int dragMode) { SlidingDrawer(Activity activity, int dragMode) {
super(activity, dragMode); super(activity, dragMode);
} }

View File

@ -3,14 +3,11 @@ package net.simonvt.menudrawer.compat;
import android.app.Activity; import android.app.Activity;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.util.Log; import timber.log.Timber;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public final class ActionBarHelper { public final class ActionBarHelper {
private static final String TAG = "ActionBarHelper";
static final boolean DEBUG = false; static final boolean DEBUG = false;
private Activity mActivity; private Activity mActivity;
@ -28,9 +25,8 @@ public final class ActionBarHelper {
mUsesCompat = true; mUsesCompat = true;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
if (DEBUG) { if (DEBUG) {
Log.e(TAG, Timber.e(e,
"Activity " + activity.getClass().getSimpleName() + " does not use a compatibility action bar", "Activity " + activity.getClass().getSimpleName() + " does not use a compatibility action bar");
e);
} }
} }

View File

@ -2,7 +2,7 @@ package net.simonvt.menudrawer.compat;
import android.app.Activity; import android.app.Activity;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.Log; import timber.log.Timber;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
@ -11,8 +11,6 @@ import java.lang.reflect.Method;
final class ActionBarHelperCompat { final class ActionBarHelperCompat {
private static final String TAG = "ActionBarHelperCompat";
private ActionBarHelperCompat() { private ActionBarHelperCompat() {
} }
@ -52,7 +50,7 @@ final class ActionBarHelperCompat {
sii.mHomeAsUpEnabled.invoke(sii.mActionBar, enabled); sii.mHomeAsUpEnabled.invoke(sii.mActionBar, enabled);
} catch (Throwable t) { } catch (Throwable t) {
if (ActionBarHelper.DEBUG) { if (ActionBarHelper.DEBUG) {
Log.e(TAG, "Unable to call setHomeAsUpEnabled", t); Timber.e(t, "Unable to call setHomeAsUpEnabled");
} }
} }
} }
@ -77,7 +75,7 @@ final class ActionBarHelperCompat {
mUpIndicatorView = (ImageView) parent.findViewById(upId); mUpIndicatorView = (ImageView) parent.findViewById(upId);
} catch (Throwable t) { } catch (Throwable t) {
if (ActionBarHelper.DEBUG) { if (ActionBarHelper.DEBUG) {
Log.e(TAG, "ABS action bar not found", t); Timber.e(t,"ABS action bar not found");
} }
} }
@ -99,7 +97,7 @@ final class ActionBarHelperCompat {
} catch (Throwable t) { } catch (Throwable t) {
if (ActionBarHelper.DEBUG) { if (ActionBarHelper.DEBUG) {
Log.e(TAG, "Unable to init SetIndicatorInfo for ABS", t); Timber.e(t, "Unable to init SetIndicatorInfo for ABS");
} }
} }
} }

View File

@ -4,7 +4,7 @@ import android.app.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.Log; import timber.log.Timber;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
@ -13,8 +13,6 @@ import java.lang.reflect.Method;
final class ActionBarHelperNative { final class ActionBarHelperNative {
private static final String TAG = "ActionBarHelperNative";
private ActionBarHelperNative() { private ActionBarHelperNative() {
} }
@ -31,12 +29,12 @@ final class ActionBarHelperNative {
sii.setHomeAsUpIndicator.invoke(actionBar, drawable); sii.setHomeAsUpIndicator.invoke(actionBar, drawable);
sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes); sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
} catch (Throwable t) { } catch (Throwable t) {
if (ActionBarHelper.DEBUG) Log.e(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", t); if (ActionBarHelper.DEBUG) Timber.e(t, "Couldn't set home-as-up indicator via JB-MR2 API");
} }
} else if (sii.upIndicatorView != null) { } else if (sii.upIndicatorView != null) {
sii.upIndicatorView.setImageDrawable(drawable); sii.upIndicatorView.setImageDrawable(drawable);
} else { } else {
if (ActionBarHelper.DEBUG) Log.e(TAG, "Couldn't set home-as-up indicator"); if (ActionBarHelper.DEBUG) Timber.e("Couldn't set home-as-up indicator");
} }
} }
@ -47,7 +45,7 @@ final class ActionBarHelperNative {
final ActionBar actionBar = activity.getActionBar(); final ActionBar actionBar = activity.getActionBar();
sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes); sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
} catch (Throwable t) { } catch (Throwable t) {
if (ActionBarHelper.DEBUG) Log.e(TAG, "Couldn't set content description via JB-MR2 API", t); if (ActionBarHelper.DEBUG) Timber.e(t, "Couldn't set content description via JB-MR2 API");
} }
} }
} }

View File

@ -37,6 +37,7 @@ ext.versions = [
testRunner : "1.0.1", testRunner : "1.0.1",
robolectric : "4.4", robolectric : "4.4",
dexter : "6.1.2", dexter : "6.1.2",
timber : "4.7.1",
] ]
ext.gradlePlugins = [ ext.gradlePlugins = [
@ -75,6 +76,7 @@ ext.other = [
koinViewModel : "org.koin:koin-android-viewmodel:$versions.koin", koinViewModel : "org.koin:koin-android-viewmodel:$versions.koin",
picasso : "com.squareup.picasso:picasso:$versions.picasso", picasso : "com.squareup.picasso:picasso:$versions.picasso",
dexter : "com.karumi:dexter:$versions.dexter", dexter : "com.karumi:dexter:$versions.dexter",
timber : "com.jakewharton.timber:timber:$versions.timber",
] ]
ext.testing = [ ext.testing = [

View File

@ -85,6 +85,7 @@ dependencies {
testImplementation testing.mockitoKotlin testImplementation testing.mockitoKotlin
testImplementation testing.kluent testImplementation testing.kluent
implementation other.dexter implementation other.dexter
implementation other.timber
} }
jacoco { jacoco {

View File

@ -26,7 +26,7 @@ import android.graphics.Point;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import timber.log.Timber;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.Display; import android.view.Display;
import android.view.GestureDetector; import android.view.GestureDetector;
@ -89,7 +89,6 @@ import static org.moire.ultrasonic.domain.PlayerState.STOPPED;
public class DownloadActivity extends SubsonicTabActivity implements OnGestureListener public class DownloadActivity extends SubsonicTabActivity implements OnGestureListener
{ {
private static final String TAG = DownloadActivity.class.getSimpleName();
private static final int DIALOG_SAVE_PLAYLIST = 100; private static final int DIALOG_SAVE_PLAYLIST = 100;
private static final int PERCENTAGE_OF_SCREEN_FOR_SWIPE = 5; private static final int PERCENTAGE_OF_SCREEN_FOR_SWIPE = 5;
@ -522,7 +521,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
} }
catch (Exception e) catch (Exception e)
{ {
Log.e(TAG, e.getMessage(), e); Timber.e(e);
} }
} }
}).start(); }).start();
@ -1065,7 +1064,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
} }
catch (Exception e) catch (Exception e)
{ {
Log.e(TAG, e.getMessage(), e); Timber.e(e);
} }
} }
}).start(); }).start();
@ -1097,7 +1096,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
} }
catch (Exception e) catch (Exception e)
{ {
Log.e(TAG, e.getMessage(), e); Timber.e(e);
} }
} }
}).start(); }).start();
@ -1129,7 +1128,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
} }
catch (Exception e) catch (Exception e)
{ {
Log.e(TAG, e.getMessage(), e); Timber.e(e);
} }
} }
}).start(); }).start();

View File

@ -22,7 +22,7 @@ package org.moire.ultrasonic.activity;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import timber.log.Timber;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -46,9 +46,6 @@ import java.util.List;
public class SelectGenreActivity extends SubsonicTabActivity implements AdapterView.OnItemClickListener public class SelectGenreActivity extends SubsonicTabActivity implements AdapterView.OnItemClickListener
{ {
private static final String TAG = SelectGenreActivity.class.getSimpleName();
private SwipeRefreshLayout refreshGenreListView; private SwipeRefreshLayout refreshGenreListView;
private ListView genreListView; private ListView genreListView;
private View emptyView; private View emptyView;
@ -122,7 +119,7 @@ public class SelectGenreActivity extends SubsonicTabActivity implements AdapterV
} }
catch (Exception x) catch (Exception x)
{ {
Log.e(TAG, "Failed to load genres", x); Timber.e(x, "Failed to load genres");
} }
return genres; return genres;

View File

@ -30,7 +30,7 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import android.util.Log; import timber.log.Timber;
import android.view.*; import android.view.*;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
@ -65,7 +65,6 @@ import kotlin.Lazy;
*/ */
public class SubsonicTabActivity extends ResultActivity implements OnClickListener public class SubsonicTabActivity extends ResultActivity implements OnClickListener
{ {
private static final String TAG = SubsonicTabActivity.class.getSimpleName();
private static final Pattern COMPILE = Pattern.compile(":"); private static final Pattern COMPILE = Pattern.compile(":");
protected static ImageLoader IMAGE_LOADER; protected static ImageLoader IMAGE_LOADER;
protected static String theme; protected static String theme;
@ -227,7 +226,7 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtras(getIntent()); intent.putExtras(getIntent());
startActivityForResultWithoutTransition(this, intent); startActivityForResultWithoutTransition(this, intent);
Log.d(TAG, "Restarting activity..."); Timber.d("Restarting activity...");
} }
@Override @Override
@ -413,7 +412,7 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
} }
catch (Exception x) catch (Exception x)
{ {
Log.w(TAG, "Failed to get notification cover art", x); Timber.w(x, "Failed to get notification cover art");
} }
} }
} }
@ -434,7 +433,7 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.w(String.format("Exception in hideNowPlaying: %s", ex), ex); Timber.w(ex, "Exception in hideNowPlaying");
} }
} }
@ -1064,7 +1063,7 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
} }
int trialDaysLeft = Util.getRemainingTrialDays(this); int trialDaysLeft = Util.getRemainingTrialDays(this);
Log.i(TAG, trialDaysLeft + " trial days left."); Timber.i("%s trial days left.", trialDaysLeft);
if (trialDaysLeft == 0) if (trialDaysLeft == 0)
{ {
@ -1238,11 +1237,11 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
printWriter.println("Ultrasonic version code: " + Util.getVersionCode(context)); printWriter.println("Ultrasonic version code: " + Util.getVersionCode(context));
printWriter.println(); printWriter.println();
throwable.printStackTrace(printWriter); throwable.printStackTrace(printWriter);
Log.i(TAG, "Stack trace written to " + file); Timber.i("Stack trace written to %s", file);
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.e(TAG, "Failed to write stack trace to " + file, x); Timber.e(x, "Failed to write stack trace to %s", file);
} }
finally finally
{ {

View File

@ -21,7 +21,7 @@ package org.moire.ultrasonic.audiofx;
import android.content.Context; import android.content.Context;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.audiofx.Equalizer; import android.media.audiofx.Equalizer;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.util.FileUtil; import org.moire.ultrasonic.util.FileUtil;
@ -35,9 +35,6 @@ import java.io.Serializable;
*/ */
public class EqualizerController public class EqualizerController
{ {
private static final String TAG = EqualizerController.class.getSimpleName();
private final Context context; private final Context context;
private Equalizer equalizer; private Equalizer equalizer;
private boolean released; private boolean released;
@ -81,7 +78,7 @@ public class EqualizerController
catch (Throwable x) catch (Throwable x)
{ {
equalizer = null; equalizer = null;
Log.w(TAG, "Failed to create equalizer.", x); Timber.w(x, "Failed to create equalizer.");
} }
} }
@ -96,7 +93,7 @@ public class EqualizerController
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, "Failed to save equalizer settings.", x); Timber.w(x, "Failed to save equalizer settings.");
} }
} }
@ -116,7 +113,7 @@ public class EqualizerController
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, "Failed to load equalizer settings.", x); Timber.w(x, "Failed to load equalizer settings.");
} }
} }
@ -147,7 +144,7 @@ public class EqualizerController
catch (Throwable x) catch (Throwable x)
{ {
equalizer = null; equalizer = null;
Log.w(TAG, "Failed to create equalizer.", x); Timber.w(x, "Failed to create equalizer.");
} }
} }

View File

@ -20,7 +20,7 @@ package org.moire.ultrasonic.audiofx;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.audiofx.Visualizer; import android.media.audiofx.Visualizer;
import android.util.Log; import timber.log.Timber;
/** /**
* Backward-compatible wrapper for {@link Visualizer}, which is API Level 9. * Backward-compatible wrapper for {@link Visualizer}, which is API Level 9.
@ -30,8 +30,6 @@ import android.util.Log;
*/ */
public class VisualizerController public class VisualizerController
{ {
private static final String TAG = VisualizerController.class.getSimpleName();
private static final int PREFERRED_CAPTURE_SIZE = 128; // Must be a power of two. private static final int PREFERRED_CAPTURE_SIZE = 128; // Must be a power of two.
private Visualizer visualizer; private Visualizer visualizer;
@ -73,7 +71,7 @@ public class VisualizerController
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, "Failed to create visualizer.", x); Timber.w(x, "Failed to create visualizer.");
} }
if (visualizer != null) if (visualizer != null)
@ -112,7 +110,7 @@ public class VisualizerController
catch (Throwable x) catch (Throwable x)
{ {
visualizer = null; visualizer = null;
Log.w(TAG, "Failed to create visualizer.", x); Timber.w(x, "Failed to create visualizer.");
} }
} }

View File

@ -11,7 +11,7 @@ import android.provider.SearchRecentSuggestions;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import android.util.Log; import timber.log.Timber;
import android.view.View; import android.view.View;
import org.koin.java.KoinJavaComponent; import org.koin.java.KoinJavaComponent;
@ -39,7 +39,6 @@ import static org.moire.ultrasonic.activity.ServerSelectorActivity.SERVER_SELECT
*/ */
public class SettingsFragment extends PreferenceFragment public class SettingsFragment extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener { implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String LOG_TAG = SettingsFragment.class.getSimpleName();
private ListPreference theme; private ListPreference theme;
private ListPreference videoPlayer; private ListPreference videoPlayer;
@ -161,7 +160,7 @@ public class SettingsFragment extends PreferenceFragment
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.d(LOG_TAG, "Preference changed: " + key); Timber.d("Preference changed: %s", key);
update(); update();
if (Constants.PREFERENCES_KEY_HIDE_MEDIA.equals(key)) { if (Constants.PREFERENCES_KEY_HIDE_MEDIA.equals(key)) {
@ -435,11 +434,11 @@ public class SettingsFragment extends PreferenceFragment
File nomediaDir = new File(FileUtil.getUltrasonicDirectory(getActivity()), ".nomedia"); File nomediaDir = new File(FileUtil.getUltrasonicDirectory(getActivity()), ".nomedia");
if (hide && !nomediaDir.exists()) { if (hide && !nomediaDir.exists()) {
if (!nomediaDir.mkdir()) { if (!nomediaDir.mkdir()) {
Log.w(LOG_TAG, "Failed to create " + nomediaDir); Timber.w("Failed to create %s", nomediaDir);
} }
} else if (nomediaDir.exists()) { } else if (nomediaDir.exists()) {
if (!nomediaDir.delete()) { if (!nomediaDir.delete()) {
Log.w(LOG_TAG, "Failed to delete " + nomediaDir); Timber.w("Failed to delete %s", nomediaDir);
} }
} }
Util.toast(getActivity(), R.string.settings_hide_media_toast, false); Util.toast(getActivity(), R.string.settings_hide_media_toast, false);

View File

@ -9,7 +9,7 @@ import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Environment; import android.os.Environment;
import android.util.Log; import timber.log.Timber;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.widget.RemoteViews; import android.widget.RemoteViews;
@ -24,8 +24,6 @@ import org.moire.ultrasonic.util.FileUtil;
public class UltrasonicAppWidgetProvider extends AppWidgetProvider public class UltrasonicAppWidgetProvider extends AppWidgetProvider
{ {
private final static String TAG = UltrasonicAppWidgetProvider.class.getSimpleName();
protected int layoutId; protected int layoutId;
@Override @Override
@ -171,7 +169,7 @@ public class UltrasonicAppWidgetProvider extends AppWidgetProvider
} }
catch (Exception x) catch (Exception x)
{ {
Log.e(TAG, "Failed to load cover art", x); Timber.e(x, "Failed to load cover art");
views.setImageViewResource(R.id.appwidget_coverart, R.drawable.unknown_album); views.setImageViewResource(R.id.appwidget_coverart, R.drawable.unknown_album);
} }

View File

@ -23,7 +23,7 @@ import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.util.Constants; import org.moire.ultrasonic.util.Constants;
import org.moire.ultrasonic.util.Util; import org.moire.ultrasonic.util.Util;
@ -35,8 +35,6 @@ import org.moire.ultrasonic.util.Util;
*/ */
public class BluetoothIntentReceiver extends BroadcastReceiver public class BluetoothIntentReceiver extends BroadcastReceiver
{ {
private static final String TAG = BluetoothIntentReceiver.class.getSimpleName();
@Override @Override
public void onReceive(Context context, Intent intent) public void onReceive(Context context, Intent intent)
{ {
@ -46,7 +44,7 @@ public class BluetoothIntentReceiver extends BroadcastReceiver
String name = device != null ? device.getName() : "Unknown"; String name = device != null ? device.getName() : "Unknown";
String address = device != null ? device.getAddress() : "Unknown"; String address = device != null ? device.getAddress() : "Unknown";
Log.d(TAG, String.format("A2DP State: %d; Action: %s; Device: %s; Address: %s", state, action, name, address)); Timber.d("A2DP State: %d; Action: %s; Device: %s; Address: %s", state, action, name, address);
boolean actionBluetoothDeviceConnected = false; boolean actionBluetoothDeviceConnected = false;
boolean actionBluetoothDeviceDisconnected = false; boolean actionBluetoothDeviceDisconnected = false;
@ -87,19 +85,19 @@ public class BluetoothIntentReceiver extends BroadcastReceiver
if (connected) if (connected)
{ {
Log.i(TAG, String.format("Connected to Bluetooth device %s address %s, requesting media button focus.", name, address)); Timber.i("Connected to Bluetooth device %s address %s, requesting media button focus.", name, address);
Util.registerMediaButtonEventReceiver(context, false); Util.registerMediaButtonEventReceiver(context, false);
} }
if (resume) if (resume)
{ {
Log.i(TAG, String.format("Connected to Bluetooth device %s address %s, resuming playback.", name, address)); Timber.i("Connected to Bluetooth device %s address %s, resuming playback.", name, address);
context.sendBroadcast(new Intent(Constants.CMD_RESUME_OR_PLAY).setPackage(context.getPackageName())); context.sendBroadcast(new Intent(Constants.CMD_RESUME_OR_PLAY).setPackage(context.getPackageName()));
} }
if (pause) if (pause)
{ {
Log.i(TAG, String.format("Disconnected from Bluetooth device %s address %s, requesting pause.", name, address)); Timber.i("Disconnected from Bluetooth device %s address %s, requesting pause.", name, address);
context.sendBroadcast(new Intent(Constants.CMD_PAUSE).setPackage(context.getPackageName())); context.sendBroadcast(new Intent(Constants.CMD_PAUSE).setPackage(context.getPackageName()));
} }
} }

View File

@ -23,7 +23,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.service.MediaPlayerLifecycleSupport; import org.moire.ultrasonic.service.MediaPlayerLifecycleSupport;
import org.moire.ultrasonic.util.Constants; import org.moire.ultrasonic.util.Constants;
@ -38,7 +38,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/ */
public class MediaButtonIntentReceiver extends BroadcastReceiver public class MediaButtonIntentReceiver extends BroadcastReceiver
{ {
private static final String TAG = MediaButtonIntentReceiver.class.getSimpleName();
private Lazy<MediaPlayerLifecycleSupport> lifecycleSupport = inject(MediaPlayerLifecycleSupport.class); private Lazy<MediaPlayerLifecycleSupport> lifecycleSupport = inject(MediaPlayerLifecycleSupport.class);
@Override @Override
@ -62,7 +61,7 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver
} }
Parcelable event = (Parcelable) extras.get(Intent.EXTRA_KEY_EVENT); Parcelable event = (Parcelable) extras.get(Intent.EXTRA_KEY_EVENT);
Log.i(TAG, "Got MEDIA_BUTTON key event: " + event); Timber.i("Got MEDIA_BUTTON key event: %s", event);
try try
{ {

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.receiver;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.service.MediaPlayerLifecycleSupport; import org.moire.ultrasonic.service.MediaPlayerLifecycleSupport;
@ -13,14 +13,13 @@ import static org.koin.java.KoinJavaComponent.inject;
public class UltrasonicIntentReceiver extends BroadcastReceiver public class UltrasonicIntentReceiver extends BroadcastReceiver
{ {
private static final String TAG = UltrasonicIntentReceiver.class.getSimpleName();
private Lazy<MediaPlayerLifecycleSupport> lifecycleSupport = inject(MediaPlayerLifecycleSupport.class); private Lazy<MediaPlayerLifecycleSupport> lifecycleSupport = inject(MediaPlayerLifecycleSupport.class);
@Override @Override
public void onReceive(Context context, Intent intent) public void onReceive(Context context, Intent intent)
{ {
String intentAction = intent.getAction(); String intentAction = intent.getAction();
Log.i(TAG, String.format("Received Ultrasonic Intent: %s", intentAction)); Timber.i("Received Ultrasonic Intent: %s", intentAction);
try try
{ {

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.service;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.media.AudioManager; import android.media.AudioManager;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.domain.PlayerState; import org.moire.ultrasonic.domain.PlayerState;
import org.moire.ultrasonic.util.Constants; import org.moire.ultrasonic.util.Constants;
@ -15,8 +15,6 @@ import static org.koin.java.KoinJavaComponent.inject;
public class AudioFocusHandler public class AudioFocusHandler
{ {
private static final String TAG = AudioFocusHandler.class.getSimpleName();
private static boolean hasFocus; private static boolean hasFocus;
private static boolean pauseFocus; private static boolean pauseFocus;
private static boolean lowerFocus; private static boolean lowerFocus;
@ -44,7 +42,7 @@ public class AudioFocusHandler
MediaPlayerController mediaPlayerController = mediaPlayerControllerLazy.getValue(); MediaPlayerController mediaPlayerController = mediaPlayerControllerLazy.getValue();
if ((focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) && !mediaPlayerController.isJukeboxEnabled()) if ((focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) && !mediaPlayerController.isJukeboxEnabled())
{ {
Log.v(TAG, "Lost Audio Focus"); Timber.v("Lost Audio Focus");
if (mediaPlayerController.getPlayerState() == PlayerState.STARTED) if (mediaPlayerController.getPlayerState() == PlayerState.STARTED)
{ {
SharedPreferences preferences = Util.getPreferences(context); SharedPreferences preferences = Util.getPreferences(context);
@ -63,7 +61,7 @@ public class AudioFocusHandler
} }
else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) else if (focusChange == AudioManager.AUDIOFOCUS_GAIN)
{ {
Log.v(TAG, "Regained Audio Focus"); Timber.v("Regained Audio Focus");
if (pauseFocus) if (pauseFocus)
{ {
pauseFocus = false; pauseFocus = false;
@ -80,11 +78,11 @@ public class AudioFocusHandler
hasFocus = false; hasFocus = false;
mediaPlayerController.pause(); mediaPlayerController.pause();
audioManager.abandonAudioFocus(this); audioManager.abandonAudioFocus(this);
Log.v(TAG, "Abandoned Audio Focus"); Timber.v("Abandoned Audio Focus");
} }
} }
}, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); }, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
Log.v(TAG, "Got Audio Focus"); Timber.v("Got Audio Focus");
} }
} }
} }

View File

@ -22,7 +22,7 @@ import android.content.Context;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.PowerManager; import android.os.PowerManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import timber.log.Timber;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.moire.ultrasonic.domain.MusicDirectory; import org.moire.ultrasonic.domain.MusicDirectory;
@ -52,7 +52,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/ */
public class DownloadFile public class DownloadFile
{ {
private static final String TAG = DownloadFile.class.getSimpleName();
private final Context context; private final Context context;
private final MusicDirectory.Entry song; private final MusicDirectory.Entry song;
private final File partialFile; private final File partialFile;
@ -234,7 +233,7 @@ public class DownloadFile
if (!ok) if (!ok)
{ {
Log.i(TAG, String.format("Failed to set last-modified date on %s, trying alternate method", file)); Timber.i("Failed to set last-modified date on %s, trying alternate method", file);
try try
{ {
@ -248,7 +247,7 @@ public class DownloadFile
} }
catch (Exception e) catch (Exception e)
{ {
Log.w(TAG, String.format("Failed to set last-modified date on %s", file)); Timber.w("Failed to set last-modified date on %s", file);
} }
} }
} }
@ -280,7 +279,7 @@ public class DownloadFile
} }
catch (IOException ex) catch (IOException ex)
{ {
Log.w(TAG, String.format("Failed to rename file %s to %s", completeFile, saveFile)); Timber.w("Failed to rename file %s to %s", completeFile, saveFile);
} }
this.isPlaying = isPlaying; this.isPlaying = isPlaying;
@ -310,7 +309,7 @@ public class DownloadFile
PowerManager pm = (PowerManager) context.getSystemService(POWER_SERVICE); PowerManager pm = (PowerManager) context.getSystemService(POWER_SERVICE);
wakeLock = pm.newWakeLock(SCREEN_DIM_WAKE_LOCK | ON_AFTER_RELEASE, toString()); wakeLock = pm.newWakeLock(SCREEN_DIM_WAKE_LOCK | ON_AFTER_RELEASE, toString());
wakeLock.acquire(10*60*1000L /*10 minutes*/); wakeLock.acquire(10*60*1000L /*10 minutes*/);
Log.i(TAG, String.format("Acquired wake lock %s", wakeLock)); Timber.i("Acquired wake lock %s", wakeLock);
} }
wifiLock = Util.createWifiLock(context, toString()); wifiLock = Util.createWifiLock(context, toString());
@ -318,7 +317,7 @@ public class DownloadFile
if (saveFile.exists()) if (saveFile.exists())
{ {
Log.i(TAG, String.format("%s already exists. Skipping.", saveFile)); Timber.i("%s already exists. Skipping.", saveFile);
return; return;
} }
if (completeFile.exists()) if (completeFile.exists())
@ -336,7 +335,7 @@ public class DownloadFile
} }
else else
{ {
Log.i(TAG, String.format("%s already exists. Skipping.", completeFile)); Timber.i("%s already exists. Skipping.", completeFile);
} }
return; return;
} }
@ -373,12 +372,12 @@ public class DownloadFile
if (response.getSecond()) if (response.getSecond())
{ {
Log.i(TAG, String.format("Executed partial HTTP GET, skipping %d bytes", partialFile.length())); Timber.i("Executed partial HTTP GET, skipping %d bytes", partialFile.length());
} }
out = new FileOutputStream(partialFile, response.getSecond()); out = new FileOutputStream(partialFile, response.getSecond());
long n = copy(response.getFirst(), out); long n = copy(response.getFirst(), out);
Log.i(TAG, String.format("Downloaded %d bytes to %s", n, partialFile)); Timber.i("Downloaded %d bytes to %s", n, partialFile);
out.flush(); out.flush();
out.close(); out.close();
@ -426,7 +425,7 @@ public class DownloadFile
if (!isCancelled()) if (!isCancelled())
{ {
failed = true; failed = true;
Log.w(TAG, String.format("Failed to download '%s'.", song), x); Timber.w(x, "Failed to download '%s'.", song);
} }
} }
@ -437,7 +436,7 @@ public class DownloadFile
if (wakeLock != null) if (wakeLock != null)
{ {
wakeLock.release(); wakeLock.release();
Log.i(TAG, String.format("Released wake lock %s", wakeLock)); Timber.i("Released wake lock %s", wakeLock);
} }
if (wifiLock != null) if (wifiLock != null)
{ {
@ -468,7 +467,7 @@ public class DownloadFile
} }
catch (Exception x) catch (Exception x)
{ {
Log.e(TAG, "Failed to get cover art.", x); Timber.e(x, "Failed to get cover art.");
} }
} }
@ -512,7 +511,7 @@ public class DownloadFile
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (now - lastLog > 3000L) if (now - lastLog > 3000L)
{ // Only every so often. { // Only every so often.
Log.i(TAG, String.format("Downloaded %s of %s", Util.formatBytes(count), song)); Timber.i("Downloaded %s of %s", Util.formatBytes(count), song);
lastLog = now; lastLog = now;
} }
} }

View File

@ -2,7 +2,7 @@ package org.moire.ultrasonic.service;
import android.content.Context; import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.util.Constants; import org.moire.ultrasonic.util.Constants;
import org.moire.ultrasonic.util.FileUtil; import org.moire.ultrasonic.util.FileUtil;
@ -18,8 +18,6 @@ import java.util.concurrent.locks.ReentrantLock;
*/ */
public class DownloadQueueSerializer public class DownloadQueueSerializer
{ {
private static final String TAG = DownloadQueueSerializer.class.getSimpleName();
public final Lock lock = new ReentrantLock(); public final Lock lock = new ReentrantLock();
public final AtomicBoolean setup = new AtomicBoolean(false); public final AtomicBoolean setup = new AtomicBoolean(false);
private Context context; private Context context;
@ -49,7 +47,7 @@ public class DownloadQueueSerializer
state.currentPlayingIndex = currentPlayingIndex; state.currentPlayingIndex = currentPlayingIndex;
state.currentPlayingPosition = currentPlayingPosition; state.currentPlayingPosition = currentPlayingPosition;
Log.i(TAG, String.format("Serialized currentPlayingIndex: %d, currentPlayingPosition: %d", state.currentPlayingIndex, state.currentPlayingPosition)); Timber.i("Serialized currentPlayingIndex: %d, currentPlayingPosition: %d", state.currentPlayingIndex, state.currentPlayingPosition);
FileUtil.serialize(context, state, Constants.FILENAME_DOWNLOADS_SER); FileUtil.serialize(context, state, Constants.FILENAME_DOWNLOADS_SER);
} }
@ -62,7 +60,7 @@ public class DownloadQueueSerializer
{ {
State state = FileUtil.deserialize(context, Constants.FILENAME_DOWNLOADS_SER); State state = FileUtil.deserialize(context, Constants.FILENAME_DOWNLOADS_SER);
if (state == null) return; if (state == null) return;
Log.i(TAG, "Deserialized currentPlayingIndex: " + state.currentPlayingIndex + ", currentPlayingPosition: " + state.currentPlayingPosition); Timber.i("Deserialized currentPlayingIndex: " + state.currentPlayingIndex + ", currentPlayingPosition: " + state.currentPlayingPosition);
afterDeserialized.accept(state); afterDeserialized.accept(state);
} }

View File

@ -1,7 +1,7 @@
package org.moire.ultrasonic.service; package org.moire.ultrasonic.service;
import android.content.Context; import android.content.Context;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.domain.MusicDirectory; import org.moire.ultrasonic.domain.MusicDirectory;
import org.moire.ultrasonic.util.LRUCache; import org.moire.ultrasonic.util.LRUCache;
@ -28,8 +28,6 @@ import static org.moire.ultrasonic.domain.PlayerState.STARTED;
*/ */
public class Downloader public class Downloader
{ {
private static final String TAG = Downloader.class.getSimpleName();
public final List<DownloadFile> downloadList = new ArrayList<>(); public final List<DownloadFile> downloadList = new ArrayList<>();
public final List<DownloadFile> backgroundDownloadList = new ArrayList<>(); public final List<DownloadFile> backgroundDownloadList = new ArrayList<>();
public DownloadFile currentDownloading; public DownloadFile currentDownloading;
@ -69,14 +67,14 @@ public class Downloader
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.e(TAG, "checkDownloads() failed.", x); Timber.e(x,"checkDownloads() failed.");
} }
} }
}; };
executorService = Executors.newSingleThreadScheduledExecutor(); executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleWithFixedDelay(downloadChecker, 5, 5, TimeUnit.SECONDS); executorService.scheduleWithFixedDelay(downloadChecker, 5, 5, TimeUnit.SECONDS);
Log.i(TAG, "Downloader created"); Timber.i("Downloader created");
} }
public void onDestroy() public void onDestroy()
@ -84,13 +82,13 @@ public class Downloader
stop(); stop();
clear(); clear();
clearBackground(); clearBackground();
Log.i(TAG, "Downloader destroyed"); Timber.i("Downloader destroyed");
} }
public void stop() public void stop()
{ {
if (executorService != null) executorService.shutdown(); if (executorService != null) executorService.shutdown();
Log.i(TAG, "Downloader stopped"); Timber.i("Downloader stopped");
} }
public synchronized void checkDownloads() public synchronized void checkDownloads()

View File

@ -4,15 +4,13 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.util.Log; import timber.log.Timber;
/** /**
* Monitors the state of the mobile's external storage * Monitors the state of the mobile's external storage
*/ */
public class ExternalStorageMonitor public class ExternalStorageMonitor
{ {
private static final String TAG = ExternalStorageMonitor.class.getSimpleName();
private Context context; private Context context;
private BroadcastReceiver ejectEventReceiver; private BroadcastReceiver ejectEventReceiver;
private boolean externalStorageAvailable = true; private boolean externalStorageAvailable = true;
@ -33,12 +31,12 @@ public class ExternalStorageMonitor
externalStorageAvailable = Intent.ACTION_MEDIA_MOUNTED.equals(intent.getAction()); externalStorageAvailable = Intent.ACTION_MEDIA_MOUNTED.equals(intent.getAction());
if (!externalStorageAvailable) if (!externalStorageAvailable)
{ {
Log.i(TAG, "External media is ejecting. Stopping playback."); Timber.i("External media is ejecting. Stopping playback.");
ejectedCallback.run(); ejectedCallback.run();
} }
else else
{ {
Log.i(TAG, "External media is available."); Timber.i("External media is available.");
} }
} }
}; };

View File

@ -20,7 +20,7 @@ package org.moire.ultrasonic.service;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import timber.log.Timber;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -58,7 +58,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/ */
public class JukeboxMediaPlayer public class JukeboxMediaPlayer
{ {
private static final String TAG = JukeboxMediaPlayer.class.getSimpleName();
private static final long STATUS_UPDATE_INTERVAL_SECONDS = 5L; private static final long STATUS_UPDATE_INTERVAL_SECONDS = 5L;
private final TaskQueue tasks = new TaskQueue(); private final TaskQueue tasks = new TaskQueue();
@ -98,7 +97,7 @@ public class JukeboxMediaPlayer
running.set(true); running.set(true);
startProcessTasks(); startProcessTasks();
Log.d(TAG, "Started Jukebox Service"); Timber.d("Started Jukebox Service");
} }
public void stopJukeboxService() public void stopJukeboxService()
@ -110,7 +109,7 @@ public class JukeboxMediaPlayer
{ {
serviceThread.interrupt(); serviceThread.interrupt();
} }
Log.d(TAG, "Stopped Jukebox Service"); Timber.d("Stopped Jukebox Service");
} }
private void startProcessTasks() private void startProcessTasks()
@ -211,13 +210,13 @@ public class JukeboxMediaPlayer
} }
else else
{ {
Log.e(TAG, "Failed to process jukebox task: " + x, x); Timber.e(x, "Failed to process jukebox task");
} }
} }
private void disableJukeboxOnError(Throwable x, final int resourceId) private void disableJukeboxOnError(Throwable x, final int resourceId)
{ {
Log.w(TAG, x.toString()); Timber.w(x.toString());
new Handler().post(new Runnable() new Handler().post(new Runnable()
{ {
@ -322,7 +321,7 @@ public class JukeboxMediaPlayer
public void setEnabled(boolean enabled) public void setEnabled(boolean enabled)
{ {
Log.d(TAG, String.format("Jukebox Service setting enabled to %b", enabled)); Timber.d("Jukebox Service setting enabled to %b", enabled);
this.enabled = enabled; this.enabled = enabled;
tasks.clear(); tasks.clear();
@ -371,7 +370,7 @@ public class JukeboxMediaPlayer
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, "Failed to clean-up task queue.", x); Timber.w(x, "Failed to clean-up task queue.");
} }
} }

View File

@ -15,7 +15,7 @@ import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.PowerManager; import android.os.PowerManager;
import android.util.Log; import timber.log.Timber;
import android.widget.SeekBar; import android.widget.SeekBar;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -49,8 +49,6 @@ import static org.moire.ultrasonic.domain.PlayerState.STARTED;
*/ */
public class LocalMediaPlayer public class LocalMediaPlayer
{ {
private static final String TAG = LocalMediaPlayer.class.getSimpleName();
public Consumer<DownloadFile> onCurrentPlayingChanged; public Consumer<DownloadFile> onCurrentPlayingChanged;
public Consumer<DownloadFile> onSongCompleted; public Consumer<DownloadFile> onSongCompleted;
public BiConsumer<PlayerState, DownloadFile> onPlayerStateChanged; public BiConsumer<PlayerState, DownloadFile> onPlayerStateChanged;
@ -196,7 +194,7 @@ public class LocalMediaPlayer
} }
} }
Log.i(TAG, "LocalMediaPlayer created"); Timber.i("LocalMediaPlayer created");
} }
public void onDestroy() public void onDestroy()
@ -245,10 +243,10 @@ public class LocalMediaPlayer
} }
catch (Throwable exception) catch (Throwable exception)
{ {
Log.w(TAG, "LocalMediaPlayer onDestroy exception: ", exception); Timber.w(exception, "LocalMediaPlayer onDestroy exception: ");
} }
Log.i(TAG, "LocalMediaPlayer destroyed"); Timber.i("LocalMediaPlayer destroyed");
} }
public EqualizerController getEqualizerController() public EqualizerController getEqualizerController()
@ -283,7 +281,7 @@ public class LocalMediaPlayer
public synchronized void setPlayerState(final PlayerState playerState) public synchronized void setPlayerState(final PlayerState playerState)
{ {
Log.i(TAG, String.format("%s -> %s (%s)", this.playerState.name(), playerState.name(), currentPlaying)); Timber.i("%s -> %s (%s)", this.playerState.name(), playerState.name(), currentPlaying);
this.playerState = playerState; this.playerState = playerState;
@ -324,7 +322,7 @@ public class LocalMediaPlayer
public synchronized void setCurrentPlaying(final DownloadFile currentPlaying) public synchronized void setCurrentPlaying(final DownloadFile currentPlaying)
{ {
Log.v(TAG, String.format("setCurrentPlaying %s", currentPlaying)); Timber.v("setCurrentPlaying %s", currentPlaying);
this.currentPlaying = currentPlaying; this.currentPlaying = currentPlaying;
updateRemoteControl(); updateRemoteControl();
@ -368,7 +366,7 @@ public class LocalMediaPlayer
public synchronized void setNextPlayerState(PlayerState playerState) public synchronized void setNextPlayerState(PlayerState playerState)
{ {
Log.i(TAG, String.format("Next: %s -> %s (%s)", nextPlayerState.name(), playerState.name(), nextPlaying)); Timber.i("Next: %s -> %s (%s)", nextPlayerState.name(), playerState.name(), nextPlaying);
nextPlayerState = playerState; nextPlayerState = playerState;
} }
@ -469,7 +467,7 @@ public class LocalMediaPlayer
setUpRemoteControlClient(); setUpRemoteControlClient();
} }
Log.i(TAG, String.format("In updateRemoteControl, playerState: %s [%d]", playerState, getPlayerPosition())); Timber.i("In updateRemoteControl, playerState: %s [%d]", playerState, getPlayerPosition());
if (playerState == STARTED) { if (playerState == STARTED) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
@ -664,7 +662,7 @@ public class LocalMediaPlayer
dataSource = String.format(Locale.getDefault(), "http://127.0.0.1:%d/%s", dataSource = String.format(Locale.getDefault(), "http://127.0.0.1:%d/%s",
proxy.getPort(), URLEncoder.encode(dataSource, Constants.UTF_8)); proxy.getPort(), URLEncoder.encode(dataSource, Constants.UTF_8));
Log.i(TAG, String.format("Data Source: %s", dataSource)); Timber.i("Data Source: %s", dataSource);
} }
else if (proxy != null) else if (proxy != null)
{ {
@ -672,7 +670,7 @@ public class LocalMediaPlayer
proxy = null; proxy = null;
} }
Log.i(TAG, "Preparing media player"); Timber.i("Preparing media player");
mediaPlayer.setDataSource(dataSource); mediaPlayer.setDataSource(dataSource);
setPlayerState(PREPARING); setPlayerState(PREPARING);
@ -706,7 +704,7 @@ public class LocalMediaPlayer
@Override @Override
public void onPrepared(MediaPlayer mp) public void onPrepared(MediaPlayer mp)
{ {
Log.i(TAG, "Media player prepared"); Timber.i("Media player prepared");
setPlayerState(PREPARED); setPlayerState(PREPARED);
@ -722,7 +720,7 @@ public class LocalMediaPlayer
{ {
if (position != 0) if (position != 0)
{ {
Log.i(TAG, String.format("Restarting player from position %d", position)); Timber.i("Restarting player from position %d", position);
seekTo(position); seekTo(position);
} }
cachedPosition = position; cachedPosition = position;
@ -817,7 +815,7 @@ public class LocalMediaPlayer
@Override @Override
public boolean onError(MediaPlayer mediaPlayer, int what, int extra) public boolean onError(MediaPlayer mediaPlayer, int what, int extra)
{ {
Log.w(TAG, String.format("Error on playing next (%d, %d): %s", what, extra, downloadFile)); Timber.w("Error on playing next (%d, %d): %s", what, extra, downloadFile);
return true; return true;
} }
}); });
@ -837,7 +835,7 @@ public class LocalMediaPlayer
@Override @Override
public boolean onError(MediaPlayer mediaPlayer, int what, int extra) public boolean onError(MediaPlayer mediaPlayer, int what, int extra)
{ {
Log.w(TAG, String.format("Error on playing file (%d, %d): %s", what, extra, downloadFile)); Timber.w("Error on playing file (%d, %d): %s", what, extra, downloadFile);
int pos = cachedPosition; int pos = cachedPosition;
reset(); reset();
downloadFile.setPlaying(false); downloadFile.setPlaying(false);
@ -860,7 +858,7 @@ public class LocalMediaPlayer
wakeLock.acquire(60000); wakeLock.acquire(60000);
int pos = cachedPosition; int pos = cachedPosition;
Log.i(TAG, String.format("Ending position %d of %d", pos, duration)); Timber.i("Ending position %d of %d", pos, duration);
if (!isPartial || (downloadFile.isWorkDone() && (Math.abs(duration - pos) < 1000))) if (!isPartial || (downloadFile.isWorkDone() && (Math.abs(duration - pos) < 1000)))
{ {
@ -897,7 +895,7 @@ public class LocalMediaPlayer
if (downloadFile.isWorkDone()) if (downloadFile.isWorkDone())
{ {
// Complete was called early even though file is fully buffered // Complete was called early even though file is fully buffered
Log.i(TAG, String.format("Requesting restart from %d of %d", pos, duration)); Timber.i("Requesting restart from %d of %d", pos, duration);
reset(); reset();
downloadFile.setPlaying(false); downloadFile.setPlaying(false);
doPlay(downloadFile, pos, true); doPlay(downloadFile, pos, true);
@ -905,7 +903,7 @@ public class LocalMediaPlayer
} }
else else
{ {
Log.i(TAG, String.format("Requesting restart from %d of %d", pos, duration)); Timber.i("Requesting restart from %d of %d", pos, duration);
reset(); reset();
bufferTask = new BufferTask(downloadFile, pos); bufferTask = new BufferTask(downloadFile, pos);
bufferTask.start(); bufferTask.start();
@ -960,7 +958,7 @@ public class LocalMediaPlayer
long byteCount = Math.max(100000, bitRate * 1024L / 8L * bufferLength); long byteCount = Math.max(100000, bitRate * 1024L / 8L * bufferLength);
// Find out how large the file should grow before resuming playback. // Find out how large the file should grow before resuming playback.
Log.i(TAG, String.format("Buffering from position %d and bitrate %d", position, bitRate)); Timber.i("Buffering from position %d and bitrate %d", position, bitRate);
expectedFileSize = (position * bitRate / 8) + byteCount; expectedFileSize = (position * bitRate / 8) + byteCount;
} }
@ -985,7 +983,7 @@ public class LocalMediaPlayer
boolean completeFileAvailable = downloadFile.isWorkDone(); boolean completeFileAvailable = downloadFile.isWorkDone();
long size = partialFile.length(); long size = partialFile.length();
Log.i(TAG, String.format("Buffering %s (%d/%d, %s)", partialFile, size, expectedFileSize, completeFileAvailable)); Timber.i("Buffering %s (%d/%d, %s)", partialFile, size, expectedFileSize, completeFileAvailable);
return completeFileAvailable || size >= expectedFileSize; return completeFileAvailable || size >= expectedFileSize;
} }
@ -1049,7 +1047,7 @@ public class LocalMediaPlayer
private boolean bufferComplete() private boolean bufferComplete()
{ {
boolean completeFileAvailable = downloadFile.isWorkDone(); boolean completeFileAvailable = downloadFile.isWorkDone();
Log.i(TAG, String.format("Buffering next %s (%d)", partialFile, partialFile.length())); Timber.i("Buffering next %s (%d)", partialFile, partialFile.length());
return completeFileAvailable && (playerState == PlayerState.STARTED || playerState == PlayerState.PAUSED); return completeFileAvailable && (playerState == PlayerState.STARTED || playerState == PlayerState.PAUSED);
} }
@ -1090,7 +1088,7 @@ public class LocalMediaPlayer
} }
catch (Exception e) catch (Exception e)
{ {
Log.w(TAG, "Crashed getting current position", e); Timber.w(e, "Crashed getting current position");
isRunning = false; isRunning = false;
positionCache = null; positionCache = null;
} }
@ -1100,7 +1098,7 @@ public class LocalMediaPlayer
private void handleError(Exception x) private void handleError(Exception x)
{ {
Log.w(TAG, String.format("Media player error: %s", x), x); Timber.w(x,"Media player error");
try try
{ {
@ -1108,13 +1106,13 @@ public class LocalMediaPlayer
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.w(TAG, String.format("Exception encountered when resetting media player: %s", ex), ex); Timber.w(ex, "Exception encountered when resetting media player");
} }
} }
private void handleErrorNext(Exception x) private void handleErrorNext(Exception x)
{ {
Log.w(TAG, String.format("Next Media player error: %s", x), x); Timber.w(x, "Next Media player error");
nextMediaPlayer.reset(); nextMediaPlayer.reset();
} }
} }

View File

@ -20,7 +20,7 @@ package org.moire.ultrasonic.service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import timber.log.Timber;
import org.koin.java.KoinJavaComponent; import org.koin.java.KoinJavaComponent;
import org.moire.ultrasonic.audiofx.EqualizerController; import org.moire.ultrasonic.audiofx.EqualizerController;
@ -53,8 +53,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/ */
public class MediaPlayerControllerImpl implements MediaPlayerController public class MediaPlayerControllerImpl implements MediaPlayerController
{ {
private static final String TAG = MediaPlayerControllerImpl.class.getSimpleName();
private boolean created = false; private boolean created = false;
private String suggestedPlaylistName; private String suggestedPlaylistName;
private boolean keepScreenOn; private boolean keepScreenOn;
@ -82,7 +80,7 @@ public class MediaPlayerControllerImpl implements MediaPlayerController
this.shufflePlayBuffer = shufflePlayBuffer; this.shufflePlayBuffer = shufflePlayBuffer;
this.localMediaPlayer = localMediaPlayer; this.localMediaPlayer = localMediaPlayer;
Log.i(TAG, "MediaPlayerControllerImpl constructed"); Timber.i("MediaPlayerControllerImpl constructed");
} }
public void onCreate() public void onCreate()
@ -98,7 +96,7 @@ public class MediaPlayerControllerImpl implements MediaPlayerController
setJukeboxEnabled(activeServerProvider.getValue().getActiveServer().getJukeboxByDefault()); setJukeboxEnabled(activeServerProvider.getValue().getActiveServer().getJukeboxByDefault());
created = true; created = true;
Log.i(TAG, "MediaPlayerControllerImpl created"); Timber.i("MediaPlayerControllerImpl created");
} }
public void onDestroy() public void onDestroy()
@ -109,7 +107,7 @@ public class MediaPlayerControllerImpl implements MediaPlayerController
downloader.onDestroy(); downloader.onDestroy();
created = false; created = false;
Log.i(TAG, "MediaPlayerControllerImpl destroyed"); Timber.i("MediaPlayerControllerImpl destroyed");
} }
@Override @Override
@ -536,7 +534,7 @@ public class MediaPlayerControllerImpl implements MediaPlayerController
} }
catch (Exception e) catch (Exception e)
{ {
Log.w(TAG, "Error getting user information", e); Timber.w(e, "Error getting user information");
} }
return false; return false;
@ -608,7 +606,7 @@ public class MediaPlayerControllerImpl implements MediaPlayerController
} }
catch (Exception e) catch (Exception e)
{ {
Log.e(TAG, e.getMessage(), e); Timber.e(e);
} }
} }
}).start(); }).start();

View File

@ -26,7 +26,7 @@ import android.content.SharedPreferences;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import timber.log.Timber;
import android.view.KeyEvent; import android.view.KeyEvent;
import org.moire.ultrasonic.R; import org.moire.ultrasonic.R;
@ -42,8 +42,6 @@ import org.moire.ultrasonic.util.Util;
*/ */
public class MediaPlayerLifecycleSupport public class MediaPlayerLifecycleSupport
{ {
private static final String TAG = MediaPlayerLifecycleSupport.class.getSimpleName();
private boolean created = false; private boolean created = false;
private DownloadQueueSerializer downloadQueueSerializer; // From DI private DownloadQueueSerializer downloadQueueSerializer; // From DI
private final MediaPlayerControllerImpl mediaPlayerController; // From DI private final MediaPlayerControllerImpl mediaPlayerController; // From DI
@ -60,7 +58,7 @@ public class MediaPlayerLifecycleSupport
this.context = context; this.context = context;
this.downloader = downloader; this.downloader = downloader;
Log.i(TAG, "LifecycleSupport constructed"); Timber.i("LifecycleSupport constructed");
} }
public void onCreate() public void onCreate()
@ -99,7 +97,7 @@ public class MediaPlayerLifecycleSupport
new CacheCleaner(context).clean(); new CacheCleaner(context).clean();
created = true; created = true;
Log.i(TAG, "LifecycleSupport created"); Timber.i("LifecycleSupport created");
} }
public void onDestroy() public void onDestroy()
@ -111,7 +109,7 @@ public class MediaPlayerLifecycleSupport
context.unregisterReceiver(headsetEventReceiver); context.unregisterReceiver(headsetEventReceiver);
mediaPlayerController.onDestroy(); mediaPlayerController.onDestroy();
created = false; created = false;
Log.i(TAG, "LifecycleSupport destroyed"); Timber.i("LifecycleSupport destroyed");
} }
public void receiveIntent(Intent intent) public void receiveIntent(Intent intent)
@ -120,7 +118,7 @@ public class MediaPlayerLifecycleSupport
String intentAction = intent.getAction(); String intentAction = intent.getAction();
if (intentAction == null || intentAction.isEmpty()) return; if (intentAction == null || intentAction.isEmpty()) return;
Log.i(TAG, String.format("Received intent: %s", intentAction)); Timber.i("Received intent: %s", intentAction);
if (intentAction.equals(Constants.CMD_PROCESS_KEYCODE)) { if (intentAction.equals(Constants.CMD_PROCESS_KEYCODE)) {
if (intent.getExtras() != null) { if (intent.getExtras() != null) {
@ -156,7 +154,7 @@ public class MediaPlayerLifecycleSupport
return; return;
} }
Log.i(TAG, String.format("Headset event for: %s", extras.get("name"))); Timber.i("Headset event for: %s", extras.get("name"));
final int state = extras.getInt("state"); final int state = extras.getInt("state");
if (state == 0) { if (state == 0) {
if (!mediaPlayerController.isJukeboxEnabled()) { if (!mediaPlayerController.isJukeboxEnabled()) {

View File

@ -10,7 +10,7 @@ import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Build; import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log; import timber.log.Timber;
import android.view.View; import android.view.View;
import android.widget.RemoteViews; import android.widget.RemoteViews;
@ -53,7 +53,6 @@ import static org.moire.ultrasonic.domain.PlayerState.STOPPED;
*/ */
public class MediaPlayerService extends Service public class MediaPlayerService extends Service
{ {
private static final String TAG = MediaPlayerService.class.getSimpleName();
private static final String NOTIFICATION_CHANNEL_ID = "org.moire.ultrasonic"; private static final String NOTIFICATION_CHANNEL_ID = "org.moire.ultrasonic";
private static final String NOTIFICATION_CHANNEL_NAME = "Ultrasonic background service"; private static final String NOTIFICATION_CHANNEL_NAME = "Ultrasonic background service";
private static final int NOTIFICATION_ID = 3033; private static final int NOTIFICATION_ID = 3033;
@ -115,7 +114,7 @@ public class MediaPlayerService extends Service
MediaPlayerService instance = getInstance(context); MediaPlayerService instance = getInstance(context);
if (instance == null) if (instance == null)
{ {
Log.e(TAG, "ExecuteOnStartedMediaPlayerService failed to get a MediaPlayerService instance!"); Timber.e("ExecuteOnStartedMediaPlayerService failed to get a MediaPlayerService instance!");
return; return;
} }
@ -179,7 +178,7 @@ public class MediaPlayerService extends Service
updateNotification(IDLE, null); updateNotification(IDLE, null);
instance = this; instance = this;
Log.i(TAG, "MediaPlayerService created"); Timber.i("MediaPlayerService created");
} }
@Override @Override
@ -203,7 +202,7 @@ public class MediaPlayerService extends Service
} catch (Throwable ignored) { } catch (Throwable ignored) {
} }
Log.i(TAG, "MediaPlayerService stopped"); Timber.i("MediaPlayerService stopped");
} }
private void stopIfIdle() private void stopIfIdle()
@ -396,7 +395,7 @@ public class MediaPlayerService extends Service
public synchronized void play(int index, boolean start) public synchronized void play(int index, boolean start)
{ {
Log.v(TAG, String.format("play requested for %d", index)); Timber.v("play requested for %d", index);
if (index < 0 || index >= downloader.downloadList.size()) if (index < 0 || index >= downloader.downloadList.size())
{ {
resetPlayback(); resetPlayback();
@ -623,12 +622,12 @@ public class MediaPlayerService extends Service
NotificationManagerCompat.from(this); NotificationManagerCompat.from(this);
notificationManager.notify(NOTIFICATION_ID, buildForegroundNotification(playerState, currentPlaying)); notificationManager.notify(NOTIFICATION_ID, buildForegroundNotification(playerState, currentPlaying));
} }
Log.w(TAG, "--- Updated notification"); Timber.w("--- Updated notification");
} }
else { else {
startForeground(NOTIFICATION_ID, buildForegroundNotification(playerState, currentPlaying)); startForeground(NOTIFICATION_ID, buildForegroundNotification(playerState, currentPlaying));
isInForeground = true; isInForeground = true;
Log.w(TAG, "--- Created Foreground notification"); Timber.w("--- Created Foreground notification");
} }
} }
} }
@ -680,7 +679,7 @@ public class MediaPlayerService extends Service
bigView.setImageViewBitmap(R.id.notification_image, nowPlayingImage); bigView.setImageViewBitmap(R.id.notification_image, nowPlayingImage);
} }
} catch (Exception x) { } catch (Exception x) {
Log.w(TAG, "Failed to get notification cover art", x); Timber.w(x, "Failed to get notification cover art");
contentView.setImageViewResource(R.id.notification_image, R.drawable.unknown_album); contentView.setImageViewResource(R.id.notification_image, R.drawable.unknown_album);
bigView.setImageViewResource(R.id.notification_image, R.drawable.unknown_album); bigView.setImageViewResource(R.id.notification_image, R.drawable.unknown_album);
} }

View File

@ -26,7 +26,7 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.domain.MusicDirectory; import org.moire.ultrasonic.domain.MusicDirectory;
import org.moire.ultrasonic.util.FileUtil; import org.moire.ultrasonic.util.FileUtil;
@ -36,8 +36,6 @@ import org.moire.ultrasonic.util.FileUtil;
*/ */
public class MediaStoreService public class MediaStoreService
{ {
private static final String TAG = MediaStoreService.class.getSimpleName();
private static final Uri ALBUM_ART_URI = Uri.parse("content://media/external/audio/albumart"); private static final Uri ALBUM_ART_URI = Uri.parse("content://media/external/audio/albumart");
private final Context context; private final Context context;
@ -92,7 +90,7 @@ public class MediaStoreService
MediaStore.MediaColumns.DATA + "=?", new String[]{MediaStore.Audio.keyFor(song.getTitle()), file.getAbsolutePath()}); MediaStore.MediaColumns.DATA + "=?", new String[]{MediaStore.Audio.keyFor(song.getTitle()), file.getAbsolutePath()});
if (n > 0) if (n > 0)
{ {
Log.i(TAG, "Deleting media store row for " + song); Timber.i("Deleting media store row for %s", song);
} }
} }
@ -118,7 +116,7 @@ public class MediaStoreService
values.put(MediaStore.Audio.AlbumColumns.ALBUM_ID, albumId); values.put(MediaStore.Audio.AlbumColumns.ALBUM_ID, albumId);
values.put(MediaStore.MediaColumns.DATA, albumArtFile.getPath()); values.put(MediaStore.MediaColumns.DATA, albumArtFile.getPath());
contentResolver.insert(ALBUM_ART_URI, values); contentResolver.insert(ALBUM_ART_URI, values);
Log.i(TAG, "Added album art: " + albumArtFile); Timber.i("Added album art: %s", albumArtFile);
} }
cursor.close(); cursor.close();

View File

@ -21,7 +21,7 @@ package org.moire.ultrasonic.service;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever; import android.media.MediaMetadataRetriever;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.api.subsonic.SubsonicAPIClient; import org.moire.ultrasonic.api.subsonic.SubsonicAPIClient;
import org.moire.ultrasonic.cache.PermanentFileStorage; import org.moire.ultrasonic.cache.PermanentFileStorage;
@ -70,7 +70,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/ */
public class OfflineMusicService extends RESTMusicService public class OfflineMusicService extends RESTMusicService
{ {
private static final String TAG = OfflineMusicService.class.getSimpleName();
private static final Pattern COMPILE = Pattern.compile(" "); private static final Pattern COMPILE = Pattern.compile(" ");
private Lazy<ActiveServerProvider> activeServerProvider = inject(ActiveServerProvider.class); private Lazy<ActiveServerProvider> activeServerProvider = inject(ActiveServerProvider.class);
@ -242,7 +241,7 @@ public class OfflineMusicService extends RESTMusicService
entry.setVideo(hasVideo != null); entry.setVideo(hasVideo != null);
Log.i("OfflineMusicService", String.format("Offline Stuff: %s", track)); Timber.i("Offline Stuff: %s", track);
if (track != null) if (track != null)
{ {
@ -262,10 +261,10 @@ public class OfflineMusicService extends RESTMusicService
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.e("OfflineMusicService", String.format("Offline Stuff: %s", ex)); Timber.e(ex,"Offline Stuff");
} }
Log.i("OfflineMusicService", String.format("Offline Stuff: Setting Track: %d", trackValue)); Timber.i("Offline Stuff: Setting Track: %d", trackValue);
entry.setTrack(trackValue); entry.setTrack(trackValue);
} }
@ -573,7 +572,7 @@ public class OfflineMusicService extends RESTMusicService
} }
catch (Exception e) catch (Exception e)
{ {
Log.w(TAG, String.format("Failed to delete old playlist file: %s", folder.getName())); Timber.w("Failed to delete old playlist file: %s", folder.getName());
} }
} }
} }
@ -653,7 +652,7 @@ public class OfflineMusicService extends RESTMusicService
} }
catch (Exception e) catch (Exception e)
{ {
Log.w(TAG, "Failed to save playlist: " + name); Timber.w("Failed to save playlist: %s", name);
} }
finally finally
{ {

View File

@ -24,7 +24,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.R; import org.moire.ultrasonic.R;
import org.moire.ultrasonic.api.subsonic.ApiNotSupportedException; import org.moire.ultrasonic.api.subsonic.ApiNotSupportedException;
@ -120,8 +120,6 @@ import static org.koin.java.KoinJavaComponent.inject;
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class RESTMusicService implements MusicService { public class RESTMusicService implements MusicService {
private static final String TAG = RESTMusicService.class.getSimpleName();
private Lazy<ActiveServerProvider> activeServerProvider = inject(ActiveServerProvider.class); private Lazy<ActiveServerProvider> activeServerProvider = inject(ActiveServerProvider.class);
private static final String MUSIC_FOLDER_STORAGE_NAME = "music_folder"; private static final String MUSIC_FOLDER_STORAGE_NAME = "music_folder";
@ -409,7 +407,7 @@ public class RESTMusicService implements MusicService {
fw.write(filePath + '\n'); fw.write(filePath + '\n');
} }
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, "Failed to save playlist: " + name); Timber.w("Failed to save playlist: %s", name);
throw e; throw e;
} finally { } finally {
bw.close(); bw.close();
@ -638,7 +636,7 @@ public class RESTMusicService implements MusicService {
boolean serverScaling = ActiveServerProvider.Companion.isServerScalingEnabled(context); boolean serverScaling = ActiveServerProvider.Companion.isServerScalingEnabled(context);
if (bitmap == null) { if (bitmap == null) {
Log.d(TAG, "Loading cover art for: " + entry); Timber.d("Loading cover art for: %s", entry);
final String id = entry.getCoverArt(); final String id = entry.getCoverArt();
if (TextUtils.isEmpty(id)) { if (TextUtils.isEmpty(id)) {

View File

@ -1,7 +1,7 @@
package org.moire.ultrasonic.service; package org.moire.ultrasonic.service;
import android.content.Context; import android.content.Context;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.data.ActiveServerProvider; import org.moire.ultrasonic.data.ActiveServerProvider;
import org.moire.ultrasonic.util.Util; import org.moire.ultrasonic.util.Util;
@ -14,8 +14,6 @@ import org.moire.ultrasonic.util.Util;
*/ */
public class Scrobbler public class Scrobbler
{ {
private static final String TAG = Scrobbler.class.getSimpleName();
private String lastSubmission; private String lastSubmission;
private String lastNowPlaying; private String lastNowPlaying;
@ -57,11 +55,11 @@ public class Scrobbler
try try
{ {
service.scrobble(id, submission, context, null); service.scrobble(id, submission, context, null);
Log.i(TAG, String.format("Scrobbled '%s' for %s", submission ? "submission" : "now playing", song)); Timber.i("Scrobbled '%s' for %s", submission ? "submission" : "now playing", song);
} }
catch (Exception x) catch (Exception x)
{ {
Log.i(TAG, String.format("Failed to scrobble'%s' for %s", submission ? "submission" : "now playing", song), x); Timber.i(x, "Failed to scrobble'%s' for %s", submission ? "submission" : "now playing", song);
} }
} }
}.start(); }.start();

View File

@ -20,7 +20,7 @@ package org.moire.ultrasonic.util;
import android.app.Activity; import android.app.Activity;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import timber.log.Timber;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
import org.moire.ultrasonic.R; import org.moire.ultrasonic.R;
import org.moire.ultrasonic.api.subsonic.ApiNotSupportedException; import org.moire.ultrasonic.api.subsonic.ApiNotSupportedException;
@ -38,8 +38,6 @@ import java.security.cert.CertificateException;
*/ */
public abstract class BackgroundTask<T> implements ProgressListener public abstract class BackgroundTask<T> implements ProgressListener
{ {
private static final String TAG = BackgroundTask.class.getSimpleName();
private final Activity activity; private final Activity activity;
private final Handler handler; private final Handler handler;
@ -67,7 +65,7 @@ public abstract class BackgroundTask<T> implements ProgressListener
protected void error(Throwable error) protected void error(Throwable error)
{ {
Log.w(TAG, String.format("Got exception: %s", error), error); Timber.w(error);
new ErrorDialog(activity, getErrorMessage(error), false); new ErrorDialog(activity, getErrorMessage(error), false);
} }

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.util;
import android.content.Context; import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.StatFs; import android.os.StatFs;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.data.ActiveServerProvider; import org.moire.ultrasonic.data.ActiveServerProvider;
import org.moire.ultrasonic.domain.Playlist; import org.moire.ultrasonic.domain.Playlist;
@ -34,8 +34,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/ */
public class CacheCleaner public class CacheCleaner
{ {
private static final String TAG = CacheCleaner.class.getSimpleName();
private static final long MIN_FREE_SPACE = 500 * 1024L * 1024L; private static final long MIN_FREE_SPACE = 500 * 1024L * 1024L;
private final Context context; private final Context context;
@ -56,7 +54,7 @@ public class CacheCleaner
catch (Exception ex) catch (Exception ex)
{ {
// If an exception is thrown, assume we execute correctly the next time // If an exception is thrown, assume we execute correctly the next time
Log.w(TAG, "Exception in CacheCleaner.clean", ex); Timber.w(ex, "Exception in CacheCleaner.clean");
} }
} }
@ -69,7 +67,7 @@ public class CacheCleaner
catch (Exception ex) catch (Exception ex)
{ {
// If an exception is thrown, assume we execute correctly the next time // If an exception is thrown, assume we execute correctly the next time
Log.w(TAG,"Exception in CacheCleaner.cleanSpace", ex); Timber.w(ex,"Exception in CacheCleaner.cleanSpace");
} }
} }
@ -82,7 +80,7 @@ public class CacheCleaner
catch (Exception ex) catch (Exception ex)
{ {
// If an exception is thrown, assume we execute correctly the next time // If an exception is thrown, assume we execute correctly the next time
Log.w(TAG, "Exception in CacheCleaner.cleanPlaylists", ex); Timber.w(ex, "Exception in CacheCleaner.cleanPlaylists");
} }
} }
@ -141,10 +139,10 @@ public class CacheCleaner
long bytesToDeleteFsLimit = Math.max(bytesUsedFs - minFsAvailability, 0L); long bytesToDeleteFsLimit = Math.max(bytesUsedFs - minFsAvailability, 0L);
long bytesToDelete = Math.max(bytesToDeleteCacheLimit, bytesToDeleteFsLimit); long bytesToDelete = Math.max(bytesToDeleteCacheLimit, bytesToDeleteFsLimit);
Log.i(TAG, String.format("File system : %s of %s available", Util.formatBytes(bytesAvailableFs), Util.formatBytes(bytesTotalFs))); Timber.i("File system : %s of %s available", Util.formatBytes(bytesAvailableFs), Util.formatBytes(bytesTotalFs));
Log.i(TAG, String.format("Cache limit : %s", Util.formatBytes(cacheSizeBytes))); Timber.i("Cache limit : %s", Util.formatBytes(cacheSizeBytes));
Log.i(TAG, String.format("Cache size before : %s", Util.formatBytes(bytesUsedBySubsonic))); Timber.i("Cache size before : %s", Util.formatBytes(bytesUsedBySubsonic));
Log.i(TAG, String.format("Minimum to delete : %s", Util.formatBytes(bytesToDelete))); Timber.i("Minimum to delete : %s", Util.formatBytes(bytesToDelete));
return bytesToDelete; return bytesToDelete;
} }
@ -175,7 +173,7 @@ public class CacheCleaner
} }
} }
Log.i(TAG, String.format("Deleted : %s", Util.formatBytes(bytesDeleted))); Timber.i("Deleted : %s", Util.formatBytes(bytesDeleted));
} }
private static void findCandidatesForDeletion(File file, List<File> files, List<File> dirs) private static void findCandidatesForDeletion(File file, List<File> files, List<File> dirs)
@ -259,7 +257,7 @@ public class CacheCleaner
} }
catch (RuntimeException x) catch (RuntimeException x)
{ {
Log.e(TAG, "Error in cache cleaning.", x); Timber.e(x, "Error in cache cleaning.");
} }
return null; return null;
@ -288,7 +286,7 @@ public class CacheCleaner
} }
catch (RuntimeException x) catch (RuntimeException x)
{ {
Log.e(TAG, "Error in cache cleaning.", x); Timber.e(x, "Error in cache cleaning.");
} }
return null; return null;
@ -318,7 +316,7 @@ public class CacheCleaner
} }
catch (RuntimeException x) catch (RuntimeException x)
{ {
Log.e(TAG, "Error in playlist cache cleaning.", x); Timber.e(x, "Error in playlist cache cleaning.");
} }
return null; return null;

View File

@ -18,7 +18,7 @@
*/ */
package org.moire.ultrasonic.util; package org.moire.ultrasonic.util;
import android.util.Log; import timber.log.Timber;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -29,9 +29,6 @@ import java.util.concurrent.atomic.AtomicReference;
*/ */
public abstract class CancellableTask public abstract class CancellableTask
{ {
private static final String TAG = CancellableTask.class.getSimpleName();
private final AtomicBoolean running = new AtomicBoolean(false); private final AtomicBoolean running = new AtomicBoolean(false);
private final AtomicBoolean cancelled = new AtomicBoolean(false); private final AtomicBoolean cancelled = new AtomicBoolean(false);
private final AtomicReference<Thread> thread = new AtomicReference<Thread>(); private final AtomicReference<Thread> thread = new AtomicReference<Thread>();
@ -39,7 +36,7 @@ public abstract class CancellableTask
public void cancel() public void cancel()
{ {
Log.i(TAG, String.format("Cancelling %s", CancellableTask.this)); Timber.i("Cancelling %s", CancellableTask.this);
cancelled.set(true); cancelled.set(true);
OnCancelListener listener = cancelListener.get(); OnCancelListener listener = cancelListener.get();
@ -51,7 +48,7 @@ public abstract class CancellableTask
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, "Error when invoking OnCancelListener.", x); Timber.w(x, "Error when invoking OnCancelListener.");
} }
} }
} }
@ -81,7 +78,7 @@ public abstract class CancellableTask
public void run() public void run()
{ {
running.set(true); running.set(true);
Log.i(TAG, String.format("Starting thread for %s", CancellableTask.this)); Timber.i("Starting thread for %s", CancellableTask.this);
try try
{ {
execute(); execute();
@ -89,7 +86,7 @@ public abstract class CancellableTask
finally finally
{ {
running.set(false); running.set(false);
Log.i(TAG, String.format("Stopping thread for %s", CancellableTask.this)); Timber.i("Stopping thread for %s", CancellableTask.this);
} }
} }
}); });

View File

@ -24,7 +24,7 @@ import android.graphics.BitmapFactory;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.activity.SubsonicTabActivity; import org.moire.ultrasonic.activity.SubsonicTabActivity;
import org.moire.ultrasonic.domain.MusicDirectory; import org.moire.ultrasonic.domain.MusicDirectory;
@ -48,7 +48,6 @@ import java.util.regex.Pattern;
*/ */
public class FileUtil public class FileUtil
{ {
private static final String TAG = FileUtil.class.getSimpleName();
private static final String[] FILE_SYSTEM_UNSAFE = {"/", "\\", "..", ":", "\"", "?", "*", "<", ">", "|"}; private static final String[] FILE_SYSTEM_UNSAFE = {"/", "\\", "..", ":", "\"", "?", "*", "<", ">", "|"};
private static final String[] FILE_SYSTEM_UNSAFE_DIR = {"\\", "..", ":", "\"", "?", "*", "<", ">", "|"}; private static final String[] FILE_SYSTEM_UNSAFE_DIR = {"\\", "..", ":", "\"", "?", "*", "<", ">", "|"};
private static final List<String> MUSIC_FILE_EXTENSIONS = Arrays.asList("mp3", "ogg", "aac", "flac", "m4a", "wav", "wma"); private static final List<String> MUSIC_FILE_EXTENSIONS = Arrays.asList("mp3", "ogg", "aac", "flac", "m4a", "wav", "wma");
@ -186,10 +185,10 @@ public class FileUtil
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.e(TAG, "Exception in BitmapFactory.decodeFile()", ex); Timber.e(ex, "Exception in BitmapFactory.decodeFile()");
} }
Log.i("getAvatarBitmap", String.valueOf(size)); Timber.i("getAvatarBitmap %i", String.valueOf(size));
if (bitmap != null) if (bitmap != null)
{ {
@ -199,7 +198,7 @@ public class FileUtil
} }
} }
return bitmap == null ? null : bitmap; return bitmap;
} }
return null; return null;
@ -256,10 +255,10 @@ public class FileUtil
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.e(TAG, "Exception in BitmapFactory.decodeFile()", ex); Timber.e(ex, "Exception in BitmapFactory.decodeFile()");
} }
Log.i("getAlbumArtBitmap", String.valueOf(size)); Timber.i("getAlbumArtBitmap %i", String.valueOf(size));
if (bitmap != null) if (bitmap != null)
{ {
@ -269,7 +268,7 @@ public class FileUtil
} }
} }
return bitmap == null ? null : bitmap; return bitmap;
} }
return null; return null;
@ -295,7 +294,7 @@ public class FileUtil
opt.inJustDecodeBounds = false; opt.inJustDecodeBounds = false;
} }
Log.i("getSampledBitmap", String.valueOf(size)); Timber.i("getSampledBitmap %i", String.valueOf(size));
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, opt); return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, opt);
} }
@ -344,7 +343,7 @@ public class FileUtil
{ {
if (!dir.mkdirs()) if (!dir.mkdirs())
{ {
Log.e(TAG, String.format("Failed to create directory %s", dir)); Timber.e("Failed to create directory %s", dir);
} }
} }
} }
@ -355,7 +354,7 @@ public class FileUtil
if (!dir.exists() && !dir.mkdirs()) if (!dir.exists() && !dir.mkdirs())
{ {
Log.e(TAG, String.format("Failed to create %s", name)); Timber.e("Failed to create %s", name);
} }
return dir; return dir;
@ -398,7 +397,7 @@ public class FileUtil
{ {
if (!dir.isDirectory()) if (!dir.isDirectory())
{ {
Log.w(TAG, String.format("%s exists but is not a directory.", dir)); Timber.w("%s exists but is not a directory.", dir);
return false; return false;
} }
} }
@ -406,24 +405,24 @@ public class FileUtil
{ {
if (dir.mkdirs()) if (dir.mkdirs())
{ {
Log.i(TAG, String.format("Created directory %s", dir)); Timber.i("Created directory %s", dir);
} }
else else
{ {
Log.w(TAG, String.format("Failed to create directory %s", dir)); Timber.w("Failed to create directory %s", dir);
return false; return false;
} }
} }
if (!dir.canRead()) if (!dir.canRead())
{ {
Log.w(TAG, String.format("No read permission for directory %s", dir)); Timber.w("No read permission for directory %s", dir);
return false; return false;
} }
if (!dir.canWrite()) if (!dir.canWrite())
{ {
Log.w(TAG, String.format("No write permission for directory %s", dir)); Timber.w("No write permission for directory %s", dir);
return false; return false;
} }
@ -484,7 +483,7 @@ public class FileUtil
if (files == null) if (files == null)
{ {
Log.w(TAG, String.format("Failed to list children for %s", dir.getPath())); Timber.w("Failed to list children for %s", dir.getPath());
return new TreeSet<File>(); return new TreeSet<File>();
} }
@ -556,12 +555,12 @@ public class FileUtil
{ {
out = new ObjectOutputStream(new FileOutputStream(file)); out = new ObjectOutputStream(new FileOutputStream(file));
out.writeObject(obj); out.writeObject(obj);
Log.i(TAG, String.format("Serialized object to %s", file)); Timber.i("Serialized object to %s", file);
return true; return true;
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, String.format("Failed to serialize object to %s", file)); Timber.w("Failed to serialize object to %s", file);
return false; return false;
} }
finally finally
@ -587,12 +586,12 @@ public class FileUtil
in = new ObjectInputStream(new FileInputStream(file)); in = new ObjectInputStream(new FileInputStream(file));
Object object = in.readObject(); Object object = in.readObject();
T result = (T) object; T result = (T) object;
Log.i(TAG, String.format("Deserialized object from %s", file)); Timber.i("Deserialized object from %s", file);
return result; return result;
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, String.format("Failed to deserialize object from %s", file), x); Timber.w(x,"Failed to deserialize object from %s", file);
return null; return null;
} }
finally finally

View File

@ -26,7 +26,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable; import android.graphics.drawable.TransitionDrawable;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import timber.log.Timber;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -50,8 +50,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class LegacyImageLoader implements Runnable, ImageLoader { public class LegacyImageLoader implements Runnable, ImageLoader {
private static final String TAG = LegacyImageLoader.class.getSimpleName();
private final LRUCache<String, Bitmap> cache = new LRUCache<>(150); private final LRUCache<String, Bitmap> cache = new LRUCache<>(150);
private final BlockingQueue<Task> queue; private final BlockingQueue<Task> queue;
private int imageSizeDefault; private int imageSizeDefault;
@ -121,7 +119,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
private void createLargeUnknownImage(Context context) { private void createLargeUnknownImage(Context context) {
Drawable drawable = context.getResources().getDrawable(R.drawable.unknown_album); Drawable drawable = context.getResources().getDrawable(R.drawable.unknown_album);
Log.i(TAG, "createLargeUnknownImage"); Timber.i("createLargeUnknownImage");
if (drawable != null) { if (drawable != null) {
largeUnknownImage = Util.createBitmapFromDrawable(drawable); largeUnknownImage = Util.createBitmapFromDrawable(drawable);
@ -260,7 +258,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
// Only apply image to the view if the view is intended for this entry // Only apply image to the view if the view is intended for this entry
if (entry != null && tagEntry != null && !entry.equals(tagEntry)) { if (entry != null && tagEntry != null && !entry.equals(tagEntry)) {
Log.i(TAG, "View is no longer valid, not setting ImageBitmap"); Timber.i("View is no longer valid, not setting ImageBitmap");
return; return;
} }
@ -299,7 +297,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
if (username != null && if (username != null &&
tagEntry != null && tagEntry != null &&
!username.equals(tagEntry)) { !username.equals(tagEntry)) {
Log.i(TAG, "View is no longer valid, not setting ImageBitmap"); Timber.i("View is no longer valid, not setting ImageBitmap");
return; return;
} }
@ -368,7 +366,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
running.set(false); running.set(false);
break; break;
} catch (Throwable x) { } catch (Throwable x) {
Log.e(TAG, "Unexpected exception in ImageLoader.", x); Timber.e(x, "Unexpected exception in ImageLoader.");
} }
} }
} }
@ -428,7 +426,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
: musicService.getAvatar(view.getContext(), username, size, saveToFile, highQuality, null); : musicService.getAvatar(view.getContext(), username, size, saveToFile, highQuality, null);
if (bitmap == null) { if (bitmap == null) {
Log.d(TAG, "Found empty album art."); Timber.d("Found empty album art.");
return; return;
} }
@ -448,7 +446,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
} }
}); });
} catch (Throwable x) { } catch (Throwable x) {
Log.e(TAG, "Failed to download album art.", x); Timber.e(x, "Failed to download album art.");
} }
} }
} }

View File

@ -21,7 +21,7 @@ package org.moire.ultrasonic.util;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.R; import org.moire.ultrasonic.R;
@ -30,9 +30,6 @@ import org.moire.ultrasonic.R;
*/ */
public abstract class ModalBackgroundTask<T> extends BackgroundTask<T> public abstract class ModalBackgroundTask<T> extends BackgroundTask<T>
{ {
private static final String TAG = ModalBackgroundTask.class.getSimpleName();
private final AlertDialog progressDialog; private final AlertDialog progressDialog;
private Thread thread; private Thread thread;
private final boolean finishActivityOnCancel; private final boolean finishActivityOnCancel;
@ -167,7 +164,7 @@ public abstract class ModalBackgroundTask<T> extends BackgroundTask<T>
@Override @Override
protected void error(Throwable error) protected void error(Throwable error)
{ {
Log.w(TAG, String.format("Got exception: %s", error), error); Timber.w(error);
new ErrorDialog(getActivity(), getErrorMessage(error), finishActivityOnCancel); new ErrorDialog(getActivity(), getErrorMessage(error), finishActivityOnCancel);
} }

View File

@ -7,7 +7,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log; import timber.log.Timber;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.core.content.PermissionChecker; import androidx.core.content.PermissionChecker;
@ -32,9 +32,6 @@ import static androidx.core.content.PermissionChecker.PERMISSION_DENIED;
* Contains static functions for Permission handling * Contains static functions for Permission handling
*/ */
public class PermissionUtil { public class PermissionUtil {
private static final String TAG = FileUtil.class.getSimpleName();
public interface PermissionRequestFinishedCallback { public interface PermissionRequestFinishedCallback {
void onPermissionRequestFinished(boolean hasPermission); void onPermissionRequestFinished(boolean hasPermission);
} }
@ -91,19 +88,19 @@ public class PermissionUtil {
@Override @Override
public void onPermissionsChecked(MultiplePermissionsReport report) { public void onPermissionsChecked(MultiplePermissionsReport report) {
if (report.areAllPermissionsGranted()) { if (report.areAllPermissionsGranted()) {
Log.i(TAG, "Permission granted to read / write external storage"); Timber.i("Permission granted to read / write external storage");
if (callback != null) callback.onPermissionRequestFinished(true); if (callback != null) callback.onPermissionRequestFinished(true);
return; return;
} }
if (report.isAnyPermissionPermanentlyDenied()) { if (report.isAnyPermissionPermanentlyDenied()) {
Log.i(TAG, "Found permanently denied permission to read / write external storage, offering settings"); Timber.i("Found permanently denied permission to read / write external storage, offering settings");
showSettingsDialog(context); showSettingsDialog(context);
if (callback != null) callback.onPermissionRequestFinished(false); if (callback != null) callback.onPermissionRequestFinished(false);
return; return;
} }
Log.i(TAG, "At least one permission is missing to read / write external storage"); Timber.i("At least one permission is missing to read / write external storage");
showWarning(context, context.getString(R.string.permissions_message_box_title), showWarning(context, context.getString(R.string.permissions_message_box_title),
context.getString(R.string.permissions_rationale_description_initial), null); context.getString(R.string.permissions_rationale_description_initial), null);
if (callback != null) callback.onPermissionRequestFinished(false); if (callback != null) callback.onPermissionRequestFinished(false);
@ -117,7 +114,7 @@ public class PermissionUtil {
}).withErrorListener(new PermissionRequestErrorListener() { }).withErrorListener(new PermissionRequestErrorListener() {
@Override @Override
public void onError(DexterError error) { public void onError(DexterError error) {
Log.e(TAG, String.format("An error has occurred during checking permissions with Dexter: %s", error.toString())); Timber.e("An error has occurred during checking permissions with Dexter: %s", error.toString());
} }
}) })
.check(); .check();
@ -138,20 +135,20 @@ public class PermissionUtil {
@Override @Override
public void onPermissionsChecked(MultiplePermissionsReport report) { public void onPermissionsChecked(MultiplePermissionsReport report) {
if (report.areAllPermissionsGranted()) { if (report.areAllPermissionsGranted()) {
Log.i(TAG, String.format("Permission granted to use cache directory %s", cacheLocation)); Timber.i("Permission granted to use cache directory %s", cacheLocation);
setCacheLocation(context, cacheLocation); setCacheLocation(context, cacheLocation);
if (callback != null) callback.onPermissionRequestFinished(true); if (callback != null) callback.onPermissionRequestFinished(true);
return; return;
} }
if (report.isAnyPermissionPermanentlyDenied()) { if (report.isAnyPermissionPermanentlyDenied()) {
Log.i(TAG, String.format("Found permanently denied permission to use cache directory %s, offering settings", cacheLocation)); Timber.i("Found permanently denied permission to use cache directory %s, offering settings", cacheLocation);
showSettingsDialog(context); showSettingsDialog(context);
if (callback != null) callback.onPermissionRequestFinished(false); if (callback != null) callback.onPermissionRequestFinished(false);
return; return;
} }
Log.i(TAG, String.format("At least one permission is missing to use directory %s ", cacheLocation)); Timber.i("At least one permission is missing to use directory %s ", cacheLocation);
setCacheLocation(context, FileUtil.getDefaultMusicDirectory(context).getPath()); setCacheLocation(context, FileUtil.getDefaultMusicDirectory(context).getPath());
showWarning(context, context.getString(R.string.permissions_message_box_title), showWarning(context, context.getString(R.string.permissions_message_box_title),
context.getString(R.string.permissions_permission_missing), null); context.getString(R.string.permissions_permission_missing), null);
@ -166,7 +163,7 @@ public class PermissionUtil {
}).withErrorListener(new PermissionRequestErrorListener() { }).withErrorListener(new PermissionRequestErrorListener() {
@Override @Override
public void onError(DexterError error) { public void onError(DexterError error) {
Log.e(TAG, String.format("An error has occurred during checking permissions with Dexter: %s", error.toString())); Timber.e("An error has occurred during checking permissions with Dexter: %s", error.toString());
} }
}) })
.check(); .check();

View File

@ -19,7 +19,7 @@
package org.moire.ultrasonic.util; package org.moire.ultrasonic.util;
import android.content.Context; import android.content.Context;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.data.ActiveServerProvider; import org.moire.ultrasonic.data.ActiveServerProvider;
import org.moire.ultrasonic.domain.MusicDirectory; import org.moire.ultrasonic.domain.MusicDirectory;
@ -38,7 +38,6 @@ import java.util.concurrent.TimeUnit;
*/ */
public class ShufflePlayBuffer public class ShufflePlayBuffer
{ {
private static final String TAG = ShufflePlayBuffer.class.getSimpleName();
private static final int CAPACITY = 50; private static final int CAPACITY = 50;
private static final int REFILL_THRESHOLD = 40; private static final int REFILL_THRESHOLD = 40;
@ -66,13 +65,13 @@ public class ShufflePlayBuffer
} }
}; };
executorService.scheduleWithFixedDelay(runnable, 1, 10, TimeUnit.SECONDS); executorService.scheduleWithFixedDelay(runnable, 1, 10, TimeUnit.SECONDS);
Log.i(TAG, "ShufflePlayBuffer created"); Timber.i("ShufflePlayBuffer created");
} }
public void onDestroy() public void onDestroy()
{ {
executorService.shutdown(); executorService.shutdown();
Log.i(TAG, "ShufflePlayBuffer destroyed"); Timber.i("ShufflePlayBuffer destroyed");
} }
public List<MusicDirectory.Entry> get(int size) public List<MusicDirectory.Entry> get(int size)
@ -87,7 +86,7 @@ public class ShufflePlayBuffer
result.add(buffer.remove(buffer.size() - 1)); result.add(buffer.remove(buffer.size() - 1));
} }
} }
Log.i(TAG, String.format("Taking %d songs from shuffle play buffer. %d remaining.", result.size(), buffer.size())); Timber.i("Taking %d songs from shuffle play buffer. %d remaining.", result.size(), buffer.size());
return result; return result;
} }
@ -112,12 +111,12 @@ public class ShufflePlayBuffer
synchronized (buffer) synchronized (buffer)
{ {
buffer.addAll(songs.getChildren()); buffer.addAll(songs.getChildren());
Log.i(TAG, String.format("Refilled shuffle play buffer with %d songs.", songs.getChildren().size())); Timber.i("Refilled shuffle play buffer with %d songs.", songs.getChildren().size());
} }
} }
catch (Exception x) catch (Exception x)
{ {
Log.w(TAG, "Failed to refill shuffle play buffer.", x); Timber.w(x, "Failed to refill shuffle play buffer.");
} }
} }

View File

@ -1,6 +1,6 @@
package org.moire.ultrasonic.util; package org.moire.ultrasonic.util;
import android.util.Log; import timber.log.Timber;
import org.moire.ultrasonic.domain.MusicDirectory; import org.moire.ultrasonic.domain.MusicDirectory;
import org.moire.ultrasonic.service.DownloadFile; import org.moire.ultrasonic.service.DownloadFile;
@ -26,8 +26,6 @@ import java.util.StringTokenizer;
public class StreamProxy implements Runnable public class StreamProxy implements Runnable
{ {
private static final String TAG = StreamProxy.class.getSimpleName();
private Thread thread; private Thread thread;
private boolean isRunning; private boolean isRunning;
private ServerSocket socket; private ServerSocket socket;
@ -50,7 +48,7 @@ public class StreamProxy implements Runnable
} }
catch (IOException e) catch (IOException e)
{ {
Log.e(TAG, "IOException initializing server", e); Timber.e(e, "IOException initializing server");
} }
} }
@ -84,7 +82,7 @@ public class StreamProxy implements Runnable
{ {
continue; continue;
} }
Log.i(TAG, "Client connected"); Timber.i("Client connected");
StreamToMediaPlayerTask task = new StreamToMediaPlayerTask(client); StreamToMediaPlayerTask task = new StreamToMediaPlayerTask(client);
if (task.processRequest()) if (task.processRequest())
@ -99,10 +97,10 @@ public class StreamProxy implements Runnable
} }
catch (IOException e) catch (IOException e)
{ {
Log.e(TAG, "Error connecting to client", e); Timber.e(e, "Error connecting to client");
} }
} }
Log.i(TAG, "Proxy interrupted. Shutting down."); Timber.i("Proxy interrupted. Shutting down.");
} }
private class StreamToMediaPlayerTask implements Runnable { private class StreamToMediaPlayerTask implements Runnable {
@ -122,12 +120,12 @@ public class StreamProxy implements Runnable
BufferedReader reader = new BufferedReader(new InputStreamReader(is), 8192); BufferedReader reader = new BufferedReader(new InputStreamReader(is), 8192);
firstLine = reader.readLine(); firstLine = reader.readLine();
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "Error parsing request", e); Timber.e(e, "Error parsing request");
return null; return null;
} }
if (firstLine == null) { if (firstLine == null) {
Log.i(TAG, "Proxy client closed connection without a request."); Timber.i("Proxy client closed connection without a request.");
return null; return null;
} }
@ -135,7 +133,7 @@ public class StreamProxy implements Runnable
st.nextToken(); // method st.nextToken(); // method
String uri = st.nextToken(); String uri = st.nextToken();
String realUri = uri.substring(1); String realUri = uri.substring(1);
Log.i(TAG, realUri); Timber.i(realUri);
return realUri; return realUri;
} }
@ -147,19 +145,19 @@ public class StreamProxy implements Runnable
} }
// Read HTTP headers // Read HTTP headers
Log.i(TAG, "Processing request: " + uri); Timber.i("Processing request: %s", uri);
try { try {
localPath = URLDecoder.decode(uri, Constants.UTF_8); localPath = URLDecoder.decode(uri, Constants.UTF_8);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
Log.e(TAG, "Unsupported encoding", e); Timber.e(e, "Unsupported encoding");
return false; return false;
} }
Log.i(TAG, String.format("Processing request for file %s", localPath)); Timber.i("Processing request for file %s", localPath);
File file = new File(localPath); File file = new File(localPath);
if (!file.exists()) { if (!file.exists()) {
Log.e(TAG, String.format("File %s does not exist", localPath)); Timber.e("File %s does not exist", localPath);
return false; return false;
} }
@ -169,11 +167,11 @@ public class StreamProxy implements Runnable
@Override @Override
public void run() public void run()
{ {
Log.i(TAG, "Streaming song in background"); Timber.i("Streaming song in background");
DownloadFile downloadFile = currentPlaying == null? null : currentPlaying.get(); DownloadFile downloadFile = currentPlaying == null? null : currentPlaying.get();
MusicDirectory.Entry song = downloadFile.getSong(); MusicDirectory.Entry song = downloadFile.getSong();
long fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8; long fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8;
Log.i(TAG, String.format("Streaming fileSize: %d", fileSize)); Timber.i("Streaming fileSize: %d", fileSize);
// Create HTTP header // Create HTTP header
String headers = "HTTP/1.0 200 OK\r\n"; String headers = "HTTP/1.0 200 OK\r\n";
@ -241,24 +239,24 @@ public class StreamProxy implements Runnable
// If we did nothing this batch, block for a second // If we did nothing this batch, block for a second
if (cbSentThisBatch == 0) if (cbSentThisBatch == 0)
{ {
Log.d(TAG, String.format("Blocking until more data appears (%d)", cbToSend)); Timber.d("Blocking until more data appears (%d)", cbToSend);
Util.sleepQuietly(1000L); Util.sleepQuietly(1000L);
} }
} }
} }
else else
{ {
Log.w(TAG, "Requesting data for completely downloaded file"); Timber.w("Requesting data for completely downloaded file");
} }
} }
catch (SocketException socketException) catch (SocketException socketException)
{ {
Log.e(TAG, "SocketException() thrown, proxy client has probably closed. This can exit harmlessly"); Timber.e("SocketException() thrown, proxy client has probably closed. This can exit harmlessly");
} }
catch (Exception e) catch (Exception e)
{ {
Log.e(TAG, "Exception thrown from streaming task:"); Timber.e("Exception thrown from streaming task:");
Log.e(TAG, String.format("%s : %s", e.getClass().getName(), e.getLocalizedMessage())); Timber.e("%s : %s", e.getClass().getName(), e.getLocalizedMessage());
} }
// Cleanup // Cleanup
@ -272,8 +270,8 @@ public class StreamProxy implements Runnable
} }
catch (IOException e) catch (IOException e)
{ {
Log.e(TAG, "IOException while cleaning up streaming task:"); Timber.e("IOException while cleaning up streaming task:");
Log.e(TAG, String.format("%s : %s", e.getClass().getName(), e.getLocalizedMessage())); Timber.e("%s : %s", e.getClass().getName(), e.getLocalizedMessage());
} }
} }
} }

View File

@ -41,7 +41,7 @@ import android.os.Environment;
import android.os.Parcelable; import android.os.Parcelable;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import timber.log.Timber;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -75,8 +75,6 @@ import java.util.regex.Pattern;
*/ */
public class Util public class Util
{ {
private static final String TAG = Util.class.getSimpleName();
private static final DecimalFormat GIGA_BYTE_FORMAT = new DecimalFormat("0.00 GB"); private static final DecimalFormat GIGA_BYTE_FORMAT = new DecimalFormat("0.00 GB");
private static final DecimalFormat MEGA_BYTE_FORMAT = new DecimalFormat("0.00 MB"); private static final DecimalFormat MEGA_BYTE_FORMAT = new DecimalFormat("0.00 MB");
private static final DecimalFormat KILO_BYTE_FORMAT = new DecimalFormat("0 KB"); private static final DecimalFormat KILO_BYTE_FORMAT = new DecimalFormat("0 KB");
@ -258,7 +256,7 @@ public class Util
throw new IOException(String.format("Failed to rename %s to %s", tmp, to)); throw new IOException(String.format("Failed to rename %s to %s", tmp, to));
} }
Log.i(TAG, String.format("Copied %s to %s", from, to)); Timber.i("Copied %s to %s", from, to);
} }
catch (IOException x) catch (IOException x)
{ {
@ -278,7 +276,7 @@ public class Util
{ {
if (from.renameTo(to)) if (from.renameTo(to))
{ {
Log.i(TAG, String.format("Renamed %s to %s", from, to)); Timber.i("Renamed %s to %s", from, to);
} }
else else
{ {
@ -307,11 +305,11 @@ public class Util
{ {
if (!file.delete()) if (!file.delete())
{ {
Log.w(TAG, String.format("Failed to delete file %s", file)); Timber.w("Failed to delete file %s", file);
return false; return false;
} }
Log.i(TAG, String.format("Deleted file %s", file)); Timber.i("Deleted file %s", file);
} }
return true; return true;
} }
@ -621,7 +619,7 @@ public class Util
} }
catch (InterruptedException x) catch (InterruptedException x)
{ {
Log.w(TAG, "Interrupted from sleep.", x); Timber.w(x, "Interrupted from sleep.");
} }
} }
@ -712,7 +710,7 @@ public class Util
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.unregisterMediaButtonEventReceiver(new ComponentName(context.getPackageName(), MediaButtonIntentReceiver.class.getName())); audioManager.unregisterMediaButtonEventReceiver(new ComponentName(context.getPackageName(), MediaButtonIntentReceiver.class.getName()));
Log.i(TAG, "MediaButtonEventReceiver unregistered."); Timber.i("MediaButtonEventReceiver unregistered.");
} }
public static MusicDirectory getSongsFromSearchResult(SearchResult searchResult) public static MusicDirectory getSongsFromSearchResult(SearchResult searchResult)

View File

@ -20,7 +20,7 @@ package org.moire.ultrasonic.view;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.Log; import timber.log.Timber;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
@ -40,7 +40,6 @@ import org.moire.ultrasonic.util.Util;
*/ */
public class AlbumView extends UpdateView public class AlbumView extends UpdateView
{ {
private static final String TAG = AlbumView.class.getSimpleName();
private static Drawable starDrawable; private static Drawable starDrawable;
private static Drawable starHollowDrawable; private static Drawable starHollowDrawable;
private static String theme; private static String theme;
@ -174,7 +173,7 @@ public class AlbumView extends UpdateView
} }
catch (Exception e) catch (Exception e)
{ {
Log.e(TAG, e.getMessage(), e); Timber.e(e);
} }
} }
}).start(); }).start();

View File

@ -22,7 +22,7 @@ import android.content.Context;
import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import timber.log.Timber;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.Checkable; import android.widget.Checkable;
@ -57,8 +57,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/ */
public class SongView extends UpdateView implements Checkable public class SongView extends UpdateView implements Checkable
{ {
private static final String TAG = SongView.class.getSimpleName();
private static Drawable starHollowDrawable; private static Drawable starHollowDrawable;
private static Drawable starDrawable; private static Drawable starDrawable;
private static Drawable pinImage; private static Drawable pinImage;
@ -296,7 +294,7 @@ public class SongView extends UpdateView implements Checkable
musicService.unstar(id, null, null, SongView.this.context, null); musicService.unstar(id, null, null, SongView.this.context, null);
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, e.getMessage(), e); Timber.e(e);
} }
} }
}).start(); }).start();

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.view;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log; import timber.log.Timber;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -16,7 +16,6 @@ import java.util.WeakHashMap;
public class UpdateView extends LinearLayout public class UpdateView extends LinearLayout
{ {
private static final String TAG = UpdateView.class.getSimpleName();
private static final WeakHashMap<UpdateView, ?> INSTANCES = new WeakHashMap<UpdateView, Object>(); private static final WeakHashMap<UpdateView, ?> INSTANCES = new WeakHashMap<UpdateView, Object>();
private static Handler backgroundHandler; private static Handler backgroundHandler;
@ -89,7 +88,7 @@ public class UpdateView extends LinearLayout
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, "Error when updating song views.", x); Timber.w(x, "Error when updating song views.");
} }
} }
@ -109,7 +108,7 @@ public class UpdateView extends LinearLayout
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, "Error when updating song views.", x); Timber.w(x, "Error when updating song views.");
} }
uiHandler.postDelayed(updateRunnable, Util.getViewRefreshInterval(context)); uiHandler.postDelayed(updateRunnable, Util.getViewRefreshInterval(context));
@ -133,7 +132,7 @@ public class UpdateView extends LinearLayout
} }
catch (Throwable x) catch (Throwable x)
{ {
Log.w(TAG, "Error when updating song views.", x); Timber.w(x, "Error when updating song views.");
} }
} }
}); });

View File

@ -2,7 +2,6 @@ package org.moire.ultrasonic.activity
import android.app.AlertDialog import android.app.AlertDialog
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.MenuItem import android.view.MenuItem
import android.widget.Button import android.widget.Button
import androidx.appcompat.app.ActionBar import androidx.appcompat.app.ActionBar
@ -30,6 +29,7 @@ import org.moire.ultrasonic.util.ErrorDialog
import org.moire.ultrasonic.util.ModalBackgroundTask import org.moire.ultrasonic.util.ModalBackgroundTask
import org.moire.ultrasonic.util.Util import org.moire.ultrasonic.util.Util
import retrofit2.Response import retrofit2.Response
import timber.log.Timber
/** /**
* This Activity provides a Form which can be used to edit the properties of a Server Setting. * This Activity provides a Form which can be used to edit the properties of a Server Setting.
@ -39,7 +39,6 @@ import retrofit2.Response
internal class EditServerActivity : AppCompatActivity() { internal class EditServerActivity : AppCompatActivity() {
companion object { companion object {
private val TAG = EditServerActivity::class.simpleName
const val EDIT_SERVER_INTENT_INDEX = "index" const val EDIT_SERVER_INTENT_INDEX = "index"
} }
@ -293,7 +292,7 @@ internal class EditServerActivity : AppCompatActivity() {
} }
override fun error(error: Throwable) { override fun error(error: Throwable) {
Log.w(TAG, error.toString(), error) Timber.w(error)
ErrorDialog( ErrorDialog(
activity, activity,
String.format( String.format(

View File

@ -3,7 +3,6 @@ package org.moire.ultrasonic.activity
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.MenuItem import android.view.MenuItem
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ListView import android.widget.ListView
@ -21,6 +20,7 @@ import org.moire.ultrasonic.activity.EditServerActivity.Companion.EDIT_SERVER_IN
import org.moire.ultrasonic.data.ActiveServerProvider import org.moire.ultrasonic.data.ActiveServerProvider
import org.moire.ultrasonic.service.MediaPlayerController import org.moire.ultrasonic.service.MediaPlayerController
import org.moire.ultrasonic.util.Util import org.moire.ultrasonic.util.Util
import timber.log.Timber
/** /**
* This Activity can be used to display all the configured Server Setting items. * This Activity can be used to display all the configured Server Setting items.
@ -32,7 +32,6 @@ import org.moire.ultrasonic.util.Util
internal class ServerSelectorActivity : AppCompatActivity() { internal class ServerSelectorActivity : AppCompatActivity() {
companion object { companion object {
private val TAG = ServerSelectorActivity::class.simpleName
const val SERVER_SELECTOR_MANAGE_MODE = "manageMode" const val SERVER_SELECTOR_MANAGE_MODE = "manageMode"
} }
@ -149,7 +148,7 @@ internal class ServerSelectorActivity : AppCompatActivity() {
} }
} }
} }
Log.i(TAG, "Active server was set to: $index") Timber.i("Active server was set to: $index")
} }
/** /**
@ -168,7 +167,7 @@ internal class ServerSelectorActivity : AppCompatActivity() {
if (index == activeServerIndex) setActiveServer(-1) if (index == activeServerIndex) setActiveServer(-1)
serverSettingsModel.deleteItem(index) serverSettingsModel.deleteItem(index)
Log.i(TAG, "Server deleted: $index") Timber.i("Server deleted: $index")
} }
.setNegativeButton(R.string.common_cancel) { dialog, _ -> .setNegativeButton(R.string.common_cancel) { dialog, _ ->
dialog.dismiss() dialog.dismiss()

View File

@ -3,7 +3,6 @@ package org.moire.ultrasonic.activity
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.preference.PreferenceManager import android.preference.PreferenceManager
import android.util.Log
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
@ -12,6 +11,7 @@ import kotlinx.coroutines.runBlocking
import org.moire.ultrasonic.data.ActiveServerProvider import org.moire.ultrasonic.data.ActiveServerProvider
import org.moire.ultrasonic.data.ServerSetting import org.moire.ultrasonic.data.ServerSetting
import org.moire.ultrasonic.data.ServerSettingDao import org.moire.ultrasonic.data.ServerSettingDao
import timber.log.Timber
/** /**
* ViewModel to be used in Activities which will handle Server Settings * ViewModel to be used in Activities which will handle Server Settings
@ -23,7 +23,6 @@ class ServerSettingsModel(
) : ViewModel() { ) : ViewModel() {
companion object { companion object {
private val TAG = ServerSettingsModel::class.simpleName
private const val PREFERENCES_KEY_SERVER_MIGRATED = "serverMigrated" private const val PREFERENCES_KEY_SERVER_MIGRATED = "serverMigrated"
// These constants were removed from Constants.java as they are deprecated and only used here // These constants were removed from Constants.java as they are deprecated and only used here
private const val PREFERENCES_KEY_JUKEBOX_BY_DEFAULT = "jukeboxEnabled" private const val PREFERENCES_KEY_JUKEBOX_BY_DEFAULT = "jukeboxEnabled"
@ -61,8 +60,7 @@ class ServerSettingsModel(
dbServerList.add(newServerSetting) dbServerList.add(newServerSetting)
repository.insert(newServerSetting) repository.insert(newServerSetting)
index++ index++
Log.i( Timber.i(
TAG,
"Imported server from Preferences to Database:" + "Imported server from Preferences to Database:" +
" ${newServerSetting.name}" " ${newServerSetting.name}"
) )
@ -149,7 +147,7 @@ class ServerSettingsModel(
val itemToBeDeleted = repository.findByIndex(index) val itemToBeDeleted = repository.findByIndex(index)
if (itemToBeDeleted != null) { if (itemToBeDeleted != null) {
repository.delete(itemToBeDeleted) repository.delete(itemToBeDeleted)
Log.d(TAG, "deleteItem deleted index: $index") Timber.d("deleteItem deleted index: $index")
reindexSettings() reindexSettings()
activeServerProvider.invalidateCache() activeServerProvider.invalidateCache()
} }
@ -165,7 +163,7 @@ class ServerSettingsModel(
viewModelScope.launch { viewModelScope.launch {
repository.update(serverSetting) repository.update(serverSetting)
activeServerProvider.invalidateCache() activeServerProvider.invalidateCache()
Log.d(TAG, "updateItem updated server setting: $serverSetting") Timber.d("updateItem updated server setting: $serverSetting")
} }
} }
@ -179,7 +177,7 @@ class ServerSettingsModel(
serverSetting.index = (repository.count() ?: 0) + 1 serverSetting.index = (repository.count() ?: 0) + 1
serverSetting.id = (repository.getMaxId() ?: 0) + 1 serverSetting.id = (repository.getMaxId() ?: 0) + 1
repository.insert(serverSetting) repository.insert(serverSetting)
Log.d(TAG, "saveNewItem saved server setting: $serverSetting") Timber.d("saveNewItem saved server setting: $serverSetting")
} }
} }
@ -240,7 +238,7 @@ class ServerSettingsModel(
setting.index = newIndex setting.index = newIndex
newIndex++ newIndex++
repository.update(setting) repository.update(setting)
Log.d(TAG, "reindexSettings saved $setting") Timber.d("reindexSettings saved $setting")
} }
} }
} }

View File

@ -5,17 +5,24 @@ import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin import org.koin.core.context.startKoin
import org.koin.core.logger.Level import org.koin.core.logger.Level
import org.moire.ultrasonic.BuildConfig
import org.moire.ultrasonic.di.appPermanentStorage import org.moire.ultrasonic.di.appPermanentStorage
import org.moire.ultrasonic.di.baseNetworkModule import org.moire.ultrasonic.di.baseNetworkModule
import org.moire.ultrasonic.di.directoriesModule import org.moire.ultrasonic.di.directoriesModule
import org.moire.ultrasonic.di.featureFlagsModule import org.moire.ultrasonic.di.featureFlagsModule
import org.moire.ultrasonic.di.mediaPlayerModule import org.moire.ultrasonic.di.mediaPlayerModule
import org.moire.ultrasonic.di.musicServiceModule import org.moire.ultrasonic.di.musicServiceModule
import timber.log.Timber
import timber.log.Timber.DebugTree
class UApp : MultiDexApplication() { class UApp : MultiDexApplication() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(DebugTree())
}
startKoin { startKoin {
// Use Koin Android Logger // Use Koin Android Logger
// TODO Current version of Koin has a bug, which forces the usage of Level.ERROR // TODO Current version of Koin has a bug, which forces the usage of Level.ERROR

View File

@ -1,7 +1,6 @@
package org.moire.ultrasonic.data package org.moire.ultrasonic.data
import android.content.Context import android.content.Context
import android.util.Log
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -11,6 +10,7 @@ import org.moire.ultrasonic.R
import org.moire.ultrasonic.service.MusicServiceFactory.resetMusicService import org.moire.ultrasonic.service.MusicServiceFactory.resetMusicService
import org.moire.ultrasonic.util.Constants import org.moire.ultrasonic.util.Constants
import org.moire.ultrasonic.util.Util import org.moire.ultrasonic.util.Util
import timber.log.Timber
/** /**
* This class can be used to retrieve the properties of the Active Server * This class can be used to retrieve the properties of the Active Server
@ -37,8 +37,7 @@ class ActiveServerProvider(
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
cachedServer = repository.findById(serverId) cachedServer = repository.findById(serverId)
} }
Log.d( Timber.d(
TAG,
"getActiveServer retrieved from DataBase, id: $serverId; " + "getActiveServer retrieved from DataBase, id: $serverId; " +
"cachedServer: $cachedServer" "cachedServer: $cachedServer"
) )
@ -67,7 +66,7 @@ class ActiveServerProvider(
* @param index: The index of the Active Server in the Server Selector List * @param index: The index of the Active Server in the Server Selector List
*/ */
fun setActiveServerByIndex(index: Int) { fun setActiveServerByIndex(index: Int) {
Log.d(TAG, "setActiveServerByIndex $index") Timber.d("setActiveServerByIndex $index")
if (index < 1) { if (index < 1) {
// Offline mode is selected // Offline mode is selected
setActiveServerId(context, 0) setActiveServerId(context, 0)
@ -85,7 +84,7 @@ class ActiveServerProvider(
* This should be called when the Active Server or one of its properties changes * This should be called when the Active Server or one of its properties changes
*/ */
fun invalidateCache() { fun invalidateCache() {
Log.d(TAG, "Cache is invalidated") Timber.d("Cache is invalidated")
cachedServer = null cachedServer = null
} }
@ -116,8 +115,6 @@ class ActiveServerProvider(
} }
companion object { companion object {
private val TAG = ActiveServerProvider::class.simpleName
/** /**
* Queries if the Active Server is the "Offline" mode of Ultrasonic * Queries if the Active Server is the "Offline" mode of Ultrasonic
* @return True, if the "Offline" mode is selected * @return True, if the "Offline" mode is selected

View File

@ -4,7 +4,6 @@ import android.content.Context
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Environment import android.os.Environment
import android.text.TextUtils import android.text.TextUtils
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -18,6 +17,7 @@ import java.util.LinkedList
import kotlin.Comparator import kotlin.Comparator
import org.moire.ultrasonic.R import org.moire.ultrasonic.R
import org.moire.ultrasonic.util.Util import org.moire.ultrasonic.util.Util
import timber.log.Timber
/** /**
* Adapter for the RecyclerView which handles listing, navigating and picking files * Adapter for the RecyclerView which handles listing, navigating and picking files
@ -281,7 +281,7 @@ internal class FilePickerAdapter : RecyclerView.Adapter<FilePickerAdapter.FileLi
val clickedFile = data[adapterPosition] val clickedFile = data[adapterPosition]
selectedDirectory = clickedFile.file!! selectedDirectory = clickedFile.file!!
fileLister(clickedFile.file!!) fileLister(clickedFile.file!!)
Log.d("FileLister", clickedFile.file!!.absolutePath) Timber.d(clickedFile.file!!.absolutePath)
} }
} }
} }