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

View File

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

View File

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

View File

@ -9,4 +9,5 @@ android {
dependencies {
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.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import timber.log.Timber;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -88,11 +88,6 @@ public abstract class MenuDrawer extends ViewGroup {
OVERLAY,
}
/**
* Tag used when logging.
*/
private static final String TAG = "MenuDrawer";
/**
* Indicates whether debug code should be enabled.
*/
@ -1520,27 +1515,27 @@ public abstract class MenuDrawer extends ViewGroup {
protected void logDrawerState(int state) {
switch (state) {
case STATE_CLOSED:
Log.d(TAG, "[DrawerState] STATE_CLOSED");
Timber.d("[DrawerState] STATE_CLOSED");
break;
case STATE_CLOSING:
Log.d(TAG, "[DrawerState] STATE_CLOSING");
Timber.d("[DrawerState] STATE_CLOSING");
break;
case STATE_DRAGGING:
Log.d(TAG, "[DrawerState] STATE_DRAGGING");
Timber.d("[DrawerState] STATE_DRAGGING");
break;
case STATE_OPENING:
Log.d(TAG, "[DrawerState] STATE_OPENING");
Timber.d("[DrawerState] STATE_OPENING");
break;
case STATE_OPEN:
Log.d(TAG, "[DrawerState] STATE_OPEN");
Timber.d("[DrawerState] STATE_OPEN");
break;
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;
public class OverlayDrawer extends DraggableDrawer {
private static final String TAG = "OverlayDrawer";
private int mPeekSize;
private Runnable mRevealRunnable = new Runnable() {

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@ package net.simonvt.menudrawer.compat;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.util.Log;
import timber.log.Timber;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@ -11,8 +11,6 @@ import java.lang.reflect.Method;
final class ActionBarHelperCompat {
private static final String TAG = "ActionBarHelperCompat";
private ActionBarHelperCompat() {
}
@ -52,7 +50,7 @@ final class ActionBarHelperCompat {
sii.mHomeAsUpEnabled.invoke(sii.mActionBar, enabled);
} catch (Throwable t) {
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);
} catch (Throwable t) {
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) {
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.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.Log;
import timber.log.Timber;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@ -13,8 +13,6 @@ import java.lang.reflect.Method;
final class ActionBarHelperNative {
private static final String TAG = "ActionBarHelperNative";
private ActionBarHelperNative() {
}
@ -31,12 +29,12 @@ final class ActionBarHelperNative {
sii.setHomeAsUpIndicator.invoke(actionBar, drawable);
sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
} 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) {
sii.upIndicatorView.setImageDrawable(drawable);
} 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();
sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
} 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",
robolectric : "4.4",
dexter : "6.1.2",
timber : "4.7.1",
]
ext.gradlePlugins = [
@ -75,6 +76,7 @@ ext.other = [
koinViewModel : "org.koin:koin-android-viewmodel:$versions.koin",
picasso : "com.squareup.picasso:picasso:$versions.picasso",
dexter : "com.karumi:dexter:$versions.dexter",
timber : "com.jakewharton.timber:timber:$versions.timber",
]
ext.testing = [

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import android.util.Log;
import timber.log.Timber;
import android.view.*;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
@ -65,7 +65,6 @@ import kotlin.Lazy;
*/
public class SubsonicTabActivity extends ResultActivity implements OnClickListener
{
private static final String TAG = SubsonicTabActivity.class.getSimpleName();
private static final Pattern COMPILE = Pattern.compile(":");
protected static ImageLoader IMAGE_LOADER;
protected static String theme;
@ -227,7 +226,7 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtras(getIntent());
startActivityForResultWithoutTransition(this, intent);
Log.d(TAG, "Restarting activity...");
Timber.d("Restarting activity...");
}
@Override
@ -413,7 +412,7 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
}
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)
{
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);
Log.i(TAG, trialDaysLeft + " trial days left.");
Timber.i("%s trial days left.", trialDaysLeft);
if (trialDaysLeft == 0)
{
@ -1238,11 +1237,11 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
printWriter.println("Ultrasonic version code: " + Util.getVersionCode(context));
printWriter.println();
throwable.printStackTrace(printWriter);
Log.i(TAG, "Stack trace written to " + file);
Timber.i("Stack trace written to %s", file);
}
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
{

View File

@ -21,7 +21,7 @@ package org.moire.ultrasonic.audiofx;
import android.content.Context;
import android.media.MediaPlayer;
import android.media.audiofx.Equalizer;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.util.FileUtil;
@ -35,9 +35,6 @@ import java.io.Serializable;
*/
public class EqualizerController
{
private static final String TAG = EqualizerController.class.getSimpleName();
private final Context context;
private Equalizer equalizer;
private boolean released;
@ -81,7 +78,7 @@ public class EqualizerController
catch (Throwable x)
{
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)
{
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)
{
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)
{
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.audiofx.Visualizer;
import android.util.Log;
import timber.log.Timber;
/**
* Backward-compatible wrapper for {@link Visualizer}, which is API Level 9.
@ -30,8 +30,6 @@ import android.util.Log;
*/
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 Visualizer visualizer;
@ -73,7 +71,7 @@ public class VisualizerController
}
catch (Throwable x)
{
Log.w(TAG, "Failed to create visualizer.", x);
Timber.w(x, "Failed to create visualizer.");
}
if (visualizer != null)
@ -112,7 +110,7 @@ public class VisualizerController
catch (Throwable x)
{
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.StringRes;
import android.util.Log;
import timber.log.Timber;
import android.view.View;
import org.koin.java.KoinJavaComponent;
@ -39,7 +39,6 @@ import static org.moire.ultrasonic.activity.ServerSelectorActivity.SERVER_SELECT
*/
public class SettingsFragment extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String LOG_TAG = SettingsFragment.class.getSimpleName();
private ListPreference theme;
private ListPreference videoPlayer;
@ -161,7 +160,7 @@ public class SettingsFragment extends PreferenceFragment
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.d(LOG_TAG, "Preference changed: " + key);
Timber.d("Preference changed: %s", key);
update();
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");
if (hide && !nomediaDir.exists()) {
if (!nomediaDir.mkdir()) {
Log.w(LOG_TAG, "Failed to create " + nomediaDir);
Timber.w("Failed to create %s", nomediaDir);
}
} else if (nomediaDir.exists()) {
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);

View File

@ -9,7 +9,7 @@ import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.Environment;
import android.util.Log;
import timber.log.Timber;
import android.view.KeyEvent;
import android.widget.RemoteViews;
@ -24,8 +24,6 @@ import org.moire.ultrasonic.util.FileUtil;
public class UltrasonicAppWidgetProvider extends AppWidgetProvider
{
private final static String TAG = UltrasonicAppWidgetProvider.class.getSimpleName();
protected int layoutId;
@Override
@ -171,7 +169,7 @@ public class UltrasonicAppWidgetProvider extends AppWidgetProvider
}
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);
}

View File

@ -23,7 +23,7 @@ import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.util.Constants;
import org.moire.ultrasonic.util.Util;
@ -35,8 +35,6 @@ import org.moire.ultrasonic.util.Util;
*/
public class BluetoothIntentReceiver extends BroadcastReceiver
{
private static final String TAG = BluetoothIntentReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent)
{
@ -46,7 +44,7 @@ public class BluetoothIntentReceiver extends BroadcastReceiver
String name = device != null ? device.getName() : "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 actionBluetoothDeviceDisconnected = false;
@ -87,19 +85,19 @@ public class BluetoothIntentReceiver extends BroadcastReceiver
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);
}
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()));
}
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()));
}
}

View File

@ -23,7 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.service.MediaPlayerLifecycleSupport;
import org.moire.ultrasonic.util.Constants;
@ -38,7 +38,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/
public class MediaButtonIntentReceiver extends BroadcastReceiver
{
private static final String TAG = MediaButtonIntentReceiver.class.getSimpleName();
private Lazy<MediaPlayerLifecycleSupport> lifecycleSupport = inject(MediaPlayerLifecycleSupport.class);
@Override
@ -62,7 +61,7 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver
}
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
{

View File

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

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.service;
import android.content.Context;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.domain.PlayerState;
import org.moire.ultrasonic.util.Constants;
@ -15,8 +15,6 @@ import static org.koin.java.KoinJavaComponent.inject;
public class AudioFocusHandler
{
private static final String TAG = AudioFocusHandler.class.getSimpleName();
private static boolean hasFocus;
private static boolean pauseFocus;
private static boolean lowerFocus;
@ -44,7 +42,7 @@ public class AudioFocusHandler
MediaPlayerController mediaPlayerController = mediaPlayerControllerLazy.getValue();
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)
{
SharedPreferences preferences = Util.getPreferences(context);
@ -63,7 +61,7 @@ public class AudioFocusHandler
}
else if (focusChange == AudioManager.AUDIOFOCUS_GAIN)
{
Log.v(TAG, "Regained Audio Focus");
Timber.v("Regained Audio Focus");
if (pauseFocus)
{
pauseFocus = false;
@ -80,11 +78,11 @@ public class AudioFocusHandler
hasFocus = false;
mediaPlayerController.pause();
audioManager.abandonAudioFocus(this);
Log.v(TAG, "Abandoned Audio Focus");
Timber.v("Abandoned Audio Focus");
}
}
}, 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.os.PowerManager;
import android.text.TextUtils;
import android.util.Log;
import timber.log.Timber;
import org.jetbrains.annotations.NotNull;
import org.moire.ultrasonic.domain.MusicDirectory;
@ -52,7 +52,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/
public class DownloadFile
{
private static final String TAG = DownloadFile.class.getSimpleName();
private final Context context;
private final MusicDirectory.Entry song;
private final File partialFile;
@ -234,7 +233,7 @@ public class DownloadFile
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
{
@ -248,7 +247,7 @@ public class DownloadFile
}
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)
{
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;
@ -310,7 +309,7 @@ public class DownloadFile
PowerManager pm = (PowerManager) context.getSystemService(POWER_SERVICE);
wakeLock = pm.newWakeLock(SCREEN_DIM_WAKE_LOCK | ON_AFTER_RELEASE, toString());
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());
@ -318,7 +317,7 @@ public class DownloadFile
if (saveFile.exists())
{
Log.i(TAG, String.format("%s already exists. Skipping.", saveFile));
Timber.i("%s already exists. Skipping.", saveFile);
return;
}
if (completeFile.exists())
@ -336,7 +335,7 @@ public class DownloadFile
}
else
{
Log.i(TAG, String.format("%s already exists. Skipping.", completeFile));
Timber.i("%s already exists. Skipping.", completeFile);
}
return;
}
@ -373,12 +372,12 @@ public class DownloadFile
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());
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.close();
@ -426,7 +425,7 @@ public class DownloadFile
if (!isCancelled())
{
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)
{
wakeLock.release();
Log.i(TAG, String.format("Released wake lock %s", wakeLock));
Timber.i("Released wake lock %s", wakeLock);
}
if (wifiLock != null)
{
@ -468,7 +467,7 @@ public class DownloadFile
}
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();
if (now - lastLog > 3000L)
{ // 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;
}
}

View File

@ -2,7 +2,7 @@ package org.moire.ultrasonic.service;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.util.Constants;
import org.moire.ultrasonic.util.FileUtil;
@ -18,8 +18,6 @@ import java.util.concurrent.locks.ReentrantLock;
*/
public class DownloadQueueSerializer
{
private static final String TAG = DownloadQueueSerializer.class.getSimpleName();
public final Lock lock = new ReentrantLock();
public final AtomicBoolean setup = new AtomicBoolean(false);
private Context context;
@ -49,7 +47,7 @@ public class DownloadQueueSerializer
state.currentPlayingIndex = currentPlayingIndex;
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);
}
@ -62,7 +60,7 @@ public class DownloadQueueSerializer
{
State state = FileUtil.deserialize(context, Constants.FILENAME_DOWNLOADS_SER);
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);
}

View File

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

View File

@ -4,15 +4,13 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
import timber.log.Timber;
/**
* Monitors the state of the mobile's external storage
*/
public class ExternalStorageMonitor
{
private static final String TAG = ExternalStorageMonitor.class.getSimpleName();
private Context context;
private BroadcastReceiver ejectEventReceiver;
private boolean externalStorageAvailable = true;
@ -33,12 +31,12 @@ public class ExternalStorageMonitor
externalStorageAvailable = Intent.ACTION_MEDIA_MOUNTED.equals(intent.getAction());
if (!externalStorageAvailable)
{
Log.i(TAG, "External media is ejecting. Stopping playback.");
Timber.i("External media is ejecting. Stopping playback.");
ejectedCallback.run();
}
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.os.Handler;
import android.util.Log;
import timber.log.Timber;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@ -58,7 +58,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/
public class JukeboxMediaPlayer
{
private static final String TAG = JukeboxMediaPlayer.class.getSimpleName();
private static final long STATUS_UPDATE_INTERVAL_SECONDS = 5L;
private final TaskQueue tasks = new TaskQueue();
@ -98,7 +97,7 @@ public class JukeboxMediaPlayer
running.set(true);
startProcessTasks();
Log.d(TAG, "Started Jukebox Service");
Timber.d("Started Jukebox Service");
}
public void stopJukeboxService()
@ -110,7 +109,7 @@ public class JukeboxMediaPlayer
{
serviceThread.interrupt();
}
Log.d(TAG, "Stopped Jukebox Service");
Timber.d("Stopped Jukebox Service");
}
private void startProcessTasks()
@ -211,13 +210,13 @@ public class JukeboxMediaPlayer
}
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)
{
Log.w(TAG, x.toString());
Timber.w(x.toString());
new Handler().post(new Runnable()
{
@ -322,7 +321,7 @@ public class JukeboxMediaPlayer
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;
tasks.clear();
@ -371,7 +370,7 @@ public class JukeboxMediaPlayer
}
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.Looper;
import android.os.PowerManager;
import android.util.Log;
import timber.log.Timber;
import android.widget.SeekBar;
import org.jetbrains.annotations.NotNull;
@ -49,8 +49,6 @@ import static org.moire.ultrasonic.domain.PlayerState.STARTED;
*/
public class LocalMediaPlayer
{
private static final String TAG = LocalMediaPlayer.class.getSimpleName();
public Consumer<DownloadFile> onCurrentPlayingChanged;
public Consumer<DownloadFile> onSongCompleted;
public BiConsumer<PlayerState, DownloadFile> onPlayerStateChanged;
@ -196,7 +194,7 @@ public class LocalMediaPlayer
}
}
Log.i(TAG, "LocalMediaPlayer created");
Timber.i("LocalMediaPlayer created");
}
public void onDestroy()
@ -245,10 +243,10 @@ public class LocalMediaPlayer
}
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()
@ -283,7 +281,7 @@ public class LocalMediaPlayer
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;
@ -324,7 +322,7 @@ public class LocalMediaPlayer
public synchronized void setCurrentPlaying(final DownloadFile currentPlaying)
{
Log.v(TAG, String.format("setCurrentPlaying %s", currentPlaying));
Timber.v("setCurrentPlaying %s", currentPlaying);
this.currentPlaying = currentPlaying;
updateRemoteControl();
@ -368,7 +366,7 @@ public class LocalMediaPlayer
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;
}
@ -469,7 +467,7 @@ public class LocalMediaPlayer
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 (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",
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)
{
@ -672,7 +670,7 @@ public class LocalMediaPlayer
proxy = null;
}
Log.i(TAG, "Preparing media player");
Timber.i("Preparing media player");
mediaPlayer.setDataSource(dataSource);
setPlayerState(PREPARING);
@ -706,7 +704,7 @@ public class LocalMediaPlayer
@Override
public void onPrepared(MediaPlayer mp)
{
Log.i(TAG, "Media player prepared");
Timber.i("Media player prepared");
setPlayerState(PREPARED);
@ -722,7 +720,7 @@ public class LocalMediaPlayer
{
if (position != 0)
{
Log.i(TAG, String.format("Restarting player from position %d", position));
Timber.i("Restarting player from position %d", position);
seekTo(position);
}
cachedPosition = position;
@ -817,7 +815,7 @@ public class LocalMediaPlayer
@Override
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;
}
});
@ -837,7 +835,7 @@ public class LocalMediaPlayer
@Override
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;
reset();
downloadFile.setPlaying(false);
@ -860,7 +858,7 @@ public class LocalMediaPlayer
wakeLock.acquire(60000);
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)))
{
@ -897,7 +895,7 @@ public class LocalMediaPlayer
if (downloadFile.isWorkDone())
{
// 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();
downloadFile.setPlaying(false);
doPlay(downloadFile, pos, true);
@ -905,7 +903,7 @@ public class LocalMediaPlayer
}
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();
bufferTask = new BufferTask(downloadFile, pos);
bufferTask.start();
@ -960,7 +958,7 @@ public class LocalMediaPlayer
long byteCount = Math.max(100000, bitRate * 1024L / 8L * bufferLength);
// 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;
}
@ -985,7 +983,7 @@ public class LocalMediaPlayer
boolean completeFileAvailable = downloadFile.isWorkDone();
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;
}
@ -1049,7 +1047,7 @@ public class LocalMediaPlayer
private boolean bufferComplete()
{
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);
}
@ -1090,7 +1088,7 @@ public class LocalMediaPlayer
}
catch (Exception e)
{
Log.w(TAG, "Crashed getting current position", e);
Timber.w(e, "Crashed getting current position");
isRunning = false;
positionCache = null;
}
@ -1100,7 +1098,7 @@ public class LocalMediaPlayer
private void handleError(Exception x)
{
Log.w(TAG, String.format("Media player error: %s", x), x);
Timber.w(x,"Media player error");
try
{
@ -1108,13 +1106,13 @@ public class LocalMediaPlayer
}
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)
{
Log.w(TAG, String.format("Next Media player error: %s", x), x);
Timber.w(x, "Next Media player error");
nextMediaPlayer.reset();
}
}

View File

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

View File

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

View File

@ -10,7 +10,7 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;
import timber.log.Timber;
import android.view.View;
import android.widget.RemoteViews;
@ -53,7 +53,6 @@ import static org.moire.ultrasonic.domain.PlayerState.STOPPED;
*/
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_NAME = "Ultrasonic background service";
private static final int NOTIFICATION_ID = 3033;
@ -115,7 +114,7 @@ public class MediaPlayerService extends Service
MediaPlayerService instance = getInstance(context);
if (instance == null)
{
Log.e(TAG, "ExecuteOnStartedMediaPlayerService failed to get a MediaPlayerService instance!");
Timber.e("ExecuteOnStartedMediaPlayerService failed to get a MediaPlayerService instance!");
return;
}
@ -179,7 +178,7 @@ public class MediaPlayerService extends Service
updateNotification(IDLE, null);
instance = this;
Log.i(TAG, "MediaPlayerService created");
Timber.i("MediaPlayerService created");
}
@Override
@ -203,7 +202,7 @@ public class MediaPlayerService extends Service
} catch (Throwable ignored) {
}
Log.i(TAG, "MediaPlayerService stopped");
Timber.i("MediaPlayerService stopped");
}
private void stopIfIdle()
@ -396,7 +395,7 @@ public class MediaPlayerService extends Service
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())
{
resetPlayback();
@ -623,12 +622,12 @@ public class MediaPlayerService extends Service
NotificationManagerCompat.from(this);
notificationManager.notify(NOTIFICATION_ID, buildForegroundNotification(playerState, currentPlaying));
}
Log.w(TAG, "--- Updated notification");
Timber.w("--- Updated notification");
}
else {
startForeground(NOTIFICATION_ID, buildForegroundNotification(playerState, currentPlaying));
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);
}
} 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);
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.net.Uri;
import android.provider.MediaStore;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.domain.MusicDirectory;
import org.moire.ultrasonic.util.FileUtil;
@ -36,8 +36,6 @@ import org.moire.ultrasonic.util.FileUtil;
*/
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 final Context context;
@ -92,7 +90,7 @@ public class MediaStoreService
MediaStore.MediaColumns.DATA + "=?", new String[]{MediaStore.Audio.keyFor(song.getTitle()), file.getAbsolutePath()});
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.MediaColumns.DATA, albumArtFile.getPath());
contentResolver.insert(ALBUM_ART_URI, values);
Log.i(TAG, "Added album art: " + albumArtFile);
Timber.i("Added album art: %s", albumArtFile);
}
cursor.close();

View File

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

View File

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

View File

@ -1,7 +1,7 @@
package org.moire.ultrasonic.service;
import android.content.Context;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.data.ActiveServerProvider;
import org.moire.ultrasonic.util.Util;
@ -14,8 +14,6 @@ import org.moire.ultrasonic.util.Util;
*/
public class Scrobbler
{
private static final String TAG = Scrobbler.class.getSimpleName();
private String lastSubmission;
private String lastNowPlaying;
@ -57,11 +55,11 @@ public class Scrobbler
try
{
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)
{
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();

View File

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

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.util;
import android.content.Context;
import android.os.AsyncTask;
import android.os.StatFs;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.data.ActiveServerProvider;
import org.moire.ultrasonic.domain.Playlist;
@ -34,8 +34,6 @@ import static org.koin.java.KoinJavaComponent.inject;
*/
public class CacheCleaner
{
private static final String TAG = CacheCleaner.class.getSimpleName();
private static final long MIN_FREE_SPACE = 500 * 1024L * 1024L;
private final Context context;
@ -56,7 +54,7 @@ public class CacheCleaner
catch (Exception ex)
{
// 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)
{
// 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)
{
// 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 bytesToDelete = Math.max(bytesToDeleteCacheLimit, bytesToDeleteFsLimit);
Log.i(TAG, String.format("File system : %s of %s available", Util.formatBytes(bytesAvailableFs), Util.formatBytes(bytesTotalFs)));
Log.i(TAG, String.format("Cache limit : %s", Util.formatBytes(cacheSizeBytes)));
Log.i(TAG, String.format("Cache size before : %s", Util.formatBytes(bytesUsedBySubsonic)));
Log.i(TAG, String.format("Minimum to delete : %s", Util.formatBytes(bytesToDelete)));
Timber.i("File system : %s of %s available", Util.formatBytes(bytesAvailableFs), Util.formatBytes(bytesTotalFs));
Timber.i("Cache limit : %s", Util.formatBytes(cacheSizeBytes));
Timber.i("Cache size before : %s", Util.formatBytes(bytesUsedBySubsonic));
Timber.i("Minimum to delete : %s", Util.formatBytes(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)
@ -259,7 +257,7 @@ public class CacheCleaner
}
catch (RuntimeException x)
{
Log.e(TAG, "Error in cache cleaning.", x);
Timber.e(x, "Error in cache cleaning.");
}
return null;
@ -288,7 +286,7 @@ public class CacheCleaner
}
catch (RuntimeException x)
{
Log.e(TAG, "Error in cache cleaning.", x);
Timber.e(x, "Error in cache cleaning.");
}
return null;
@ -318,7 +316,7 @@ public class CacheCleaner
}
catch (RuntimeException x)
{
Log.e(TAG, "Error in playlist cache cleaning.", x);
Timber.e(x, "Error in playlist cache cleaning.");
}
return null;

View File

@ -18,7 +18,7 @@
*/
package org.moire.ultrasonic.util;
import android.util.Log;
import timber.log.Timber;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@ -29,9 +29,6 @@ import java.util.concurrent.atomic.AtomicReference;
*/
public abstract class CancellableTask
{
private static final String TAG = CancellableTask.class.getSimpleName();
private final AtomicBoolean running = new AtomicBoolean(false);
private final AtomicBoolean cancelled = new AtomicBoolean(false);
private final AtomicReference<Thread> thread = new AtomicReference<Thread>();
@ -39,7 +36,7 @@ public abstract class CancellableTask
public void cancel()
{
Log.i(TAG, String.format("Cancelling %s", CancellableTask.this));
Timber.i("Cancelling %s", CancellableTask.this);
cancelled.set(true);
OnCancelListener listener = cancelListener.get();
@ -51,7 +48,7 @@ public abstract class CancellableTask
}
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()
{
running.set(true);
Log.i(TAG, String.format("Starting thread for %s", CancellableTask.this));
Timber.i("Starting thread for %s", CancellableTask.this);
try
{
execute();
@ -89,7 +86,7 @@ public abstract class CancellableTask
finally
{
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.Environment;
import android.text.TextUtils;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.activity.SubsonicTabActivity;
import org.moire.ultrasonic.domain.MusicDirectory;
@ -48,7 +48,6 @@ import java.util.regex.Pattern;
*/
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_DIR = {"\\", "..", ":", "\"", "?", "*", "<", ">", "|"};
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)
{
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)
{
@ -199,7 +198,7 @@ public class FileUtil
}
}
return bitmap == null ? null : bitmap;
return bitmap;
}
return null;
@ -256,10 +255,10 @@ public class FileUtil
}
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)
{
@ -269,7 +268,7 @@ public class FileUtil
}
}
return bitmap == null ? null : bitmap;
return bitmap;
}
return null;
@ -295,7 +294,7 @@ public class FileUtil
opt.inJustDecodeBounds = false;
}
Log.i("getSampledBitmap", String.valueOf(size));
Timber.i("getSampledBitmap %i", String.valueOf(size));
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, opt);
}
@ -344,7 +343,7 @@ public class FileUtil
{
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())
{
Log.e(TAG, String.format("Failed to create %s", name));
Timber.e("Failed to create %s", name);
}
return dir;
@ -398,7 +397,7 @@ public class FileUtil
{
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;
}
}
@ -406,24 +405,24 @@ public class FileUtil
{
if (dir.mkdirs())
{
Log.i(TAG, String.format("Created directory %s", dir));
Timber.i("Created directory %s", dir);
}
else
{
Log.w(TAG, String.format("Failed to create directory %s", dir));
Timber.w("Failed to create directory %s", dir);
return false;
}
}
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;
}
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;
}
@ -484,7 +483,7 @@ public class FileUtil
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>();
}
@ -556,12 +555,12 @@ public class FileUtil
{
out = new ObjectOutputStream(new FileOutputStream(file));
out.writeObject(obj);
Log.i(TAG, String.format("Serialized object to %s", file));
Timber.i("Serialized object to %s", file);
return true;
}
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;
}
finally
@ -587,12 +586,12 @@ public class FileUtil
in = new ObjectInputStream(new FileInputStream(file));
Object object = in.readObject();
T result = (T) object;
Log.i(TAG, String.format("Deserialized object from %s", file));
Timber.i("Deserialized object from %s", file);
return result;
}
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;
}
finally

View File

@ -26,7 +26,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import timber.log.Timber;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@ -50,8 +50,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author Sindre Mehus
*/
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 BlockingQueue<Task> queue;
private int imageSizeDefault;
@ -121,7 +119,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
private void createLargeUnknownImage(Context context) {
Drawable drawable = context.getResources().getDrawable(R.drawable.unknown_album);
Log.i(TAG, "createLargeUnknownImage");
Timber.i("createLargeUnknownImage");
if (drawable != null) {
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
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;
}
@ -299,7 +297,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
if (username != null &&
tagEntry != null &&
!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;
}
@ -368,7 +366,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
running.set(false);
break;
} 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);
if (bitmap == null) {
Log.d(TAG, "Found empty album art.");
Timber.d("Found empty album art.");
return;
}
@ -448,7 +446,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
}
});
} 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.AlertDialog;
import android.content.DialogInterface;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.R;
@ -30,9 +30,6 @@ import org.moire.ultrasonic.R;
*/
public abstract class ModalBackgroundTask<T> extends BackgroundTask<T>
{
private static final String TAG = ModalBackgroundTask.class.getSimpleName();
private final AlertDialog progressDialog;
private Thread thread;
private final boolean finishActivityOnCancel;
@ -167,7 +164,7 @@ public abstract class ModalBackgroundTask<T> extends BackgroundTask<T>
@Override
protected void error(Throwable error)
{
Log.w(TAG, String.format("Got exception: %s", error), error);
Timber.w(error);
new ErrorDialog(getActivity(), getErrorMessage(error), finishActivityOnCancel);
}

View File

@ -7,7 +7,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import timber.log.Timber;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.PermissionChecker;
@ -32,9 +32,6 @@ import static androidx.core.content.PermissionChecker.PERMISSION_DENIED;
* Contains static functions for Permission handling
*/
public class PermissionUtil {
private static final String TAG = FileUtil.class.getSimpleName();
public interface PermissionRequestFinishedCallback {
void onPermissionRequestFinished(boolean hasPermission);
}
@ -91,19 +88,19 @@ public class PermissionUtil {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
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);
return;
}
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);
if (callback != null) callback.onPermissionRequestFinished(false);
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),
context.getString(R.string.permissions_rationale_description_initial), null);
if (callback != null) callback.onPermissionRequestFinished(false);
@ -117,7 +114,7 @@ public class PermissionUtil {
}).withErrorListener(new PermissionRequestErrorListener() {
@Override
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();
@ -138,20 +135,20 @@ public class PermissionUtil {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
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);
if (callback != null) callback.onPermissionRequestFinished(true);
return;
}
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);
if (callback != null) callback.onPermissionRequestFinished(false);
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());
showWarning(context, context.getString(R.string.permissions_message_box_title),
context.getString(R.string.permissions_permission_missing), null);
@ -166,7 +163,7 @@ public class PermissionUtil {
}).withErrorListener(new PermissionRequestErrorListener() {
@Override
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();

View File

@ -19,7 +19,7 @@
package org.moire.ultrasonic.util;
import android.content.Context;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.data.ActiveServerProvider;
import org.moire.ultrasonic.domain.MusicDirectory;
@ -38,7 +38,6 @@ import java.util.concurrent.TimeUnit;
*/
public class ShufflePlayBuffer
{
private static final String TAG = ShufflePlayBuffer.class.getSimpleName();
private static final int CAPACITY = 50;
private static final int REFILL_THRESHOLD = 40;
@ -66,13 +65,13 @@ public class ShufflePlayBuffer
}
};
executorService.scheduleWithFixedDelay(runnable, 1, 10, TimeUnit.SECONDS);
Log.i(TAG, "ShufflePlayBuffer created");
Timber.i("ShufflePlayBuffer created");
}
public void onDestroy()
{
executorService.shutdown();
Log.i(TAG, "ShufflePlayBuffer destroyed");
Timber.i("ShufflePlayBuffer destroyed");
}
public List<MusicDirectory.Entry> get(int size)
@ -87,7 +86,7 @@ public class ShufflePlayBuffer
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;
}
@ -112,12 +111,12 @@ public class ShufflePlayBuffer
synchronized (buffer)
{
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)
{
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;
import android.util.Log;
import timber.log.Timber;
import org.moire.ultrasonic.domain.MusicDirectory;
import org.moire.ultrasonic.service.DownloadFile;
@ -26,8 +26,6 @@ import java.util.StringTokenizer;
public class StreamProxy implements Runnable
{
private static final String TAG = StreamProxy.class.getSimpleName();
private Thread thread;
private boolean isRunning;
private ServerSocket socket;
@ -50,7 +48,7 @@ public class StreamProxy implements Runnable
}
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;
}
Log.i(TAG, "Client connected");
Timber.i("Client connected");
StreamToMediaPlayerTask task = new StreamToMediaPlayerTask(client);
if (task.processRequest())
@ -99,10 +97,10 @@ public class StreamProxy implements Runnable
}
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 {
@ -122,12 +120,12 @@ public class StreamProxy implements Runnable
BufferedReader reader = new BufferedReader(new InputStreamReader(is), 8192);
firstLine = reader.readLine();
} catch (IOException e) {
Log.e(TAG, "Error parsing request", e);
Timber.e(e, "Error parsing request");
return 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;
}
@ -135,7 +133,7 @@ public class StreamProxy implements Runnable
st.nextToken(); // method
String uri = st.nextToken();
String realUri = uri.substring(1);
Log.i(TAG, realUri);
Timber.i(realUri);
return realUri;
}
@ -147,19 +145,19 @@ public class StreamProxy implements Runnable
}
// Read HTTP headers
Log.i(TAG, "Processing request: " + uri);
Timber.i("Processing request: %s", uri);
try {
localPath = URLDecoder.decode(uri, Constants.UTF_8);
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "Unsupported encoding", e);
Timber.e(e, "Unsupported encoding");
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);
if (!file.exists()) {
Log.e(TAG, String.format("File %s does not exist", localPath));
Timber.e("File %s does not exist", localPath);
return false;
}
@ -169,11 +167,11 @@ public class StreamProxy implements Runnable
@Override
public void run()
{
Log.i(TAG, "Streaming song in background");
Timber.i("Streaming song in background");
DownloadFile downloadFile = currentPlaying == null? null : currentPlaying.get();
MusicDirectory.Entry song = downloadFile.getSong();
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
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 (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);
}
}
}
else
{
Log.w(TAG, "Requesting data for completely downloaded file");
Timber.w("Requesting data for completely downloaded file");
}
}
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)
{
Log.e(TAG, "Exception thrown from streaming task:");
Log.e(TAG, String.format("%s : %s", e.getClass().getName(), e.getLocalizedMessage()));
Timber.e("Exception thrown from streaming task:");
Timber.e("%s : %s", e.getClass().getName(), e.getLocalizedMessage());
}
// Cleanup
@ -272,8 +270,8 @@ public class StreamProxy implements Runnable
}
catch (IOException e)
{
Log.e(TAG, "IOException while cleaning up streaming task:");
Log.e(TAG, String.format("%s : %s", e.getClass().getName(), e.getLocalizedMessage()));
Timber.e("IOException while cleaning up streaming task:");
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.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.util.Log;
import timber.log.Timber;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
@ -75,8 +75,6 @@ import java.util.regex.Pattern;
*/
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 MEGA_BYTE_FORMAT = new DecimalFormat("0.00 MB");
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));
}
Log.i(TAG, String.format("Copied %s to %s", from, to));
Timber.i("Copied %s to %s", from, to);
}
catch (IOException x)
{
@ -278,7 +276,7 @@ public class Util
{
if (from.renameTo(to))
{
Log.i(TAG, String.format("Renamed %s to %s", from, to));
Timber.i("Renamed %s to %s", from, to);
}
else
{
@ -307,11 +305,11 @@ public class Util
{
if (!file.delete())
{
Log.w(TAG, String.format("Failed to delete file %s", file));
Timber.w("Failed to delete file %s", file);
return false;
}
Log.i(TAG, String.format("Deleted file %s", file));
Timber.i("Deleted file %s", file);
}
return true;
}
@ -621,7 +619,7 @@ public class Util
}
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.unregisterMediaButtonEventReceiver(new ComponentName(context.getPackageName(), MediaButtonIntentReceiver.class.getName()));
Log.i(TAG, "MediaButtonEventReceiver unregistered.");
Timber.i("MediaButtonEventReceiver unregistered.");
}
public static MusicDirectory getSongsFromSearchResult(SearchResult searchResult)

View File

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

View File

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

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.view;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import timber.log.Timber;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.LinearLayout;
@ -16,7 +16,6 @@ import java.util.WeakHashMap;
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 Handler backgroundHandler;
@ -89,7 +88,7 @@ public class UpdateView extends LinearLayout
}
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)
{
Log.w(TAG, "Error when updating song views.", x);
Timber.w(x, "Error when updating song views.");
}
uiHandler.postDelayed(updateRunnable, Util.getViewRefreshInterval(context));
@ -133,7 +132,7 @@ public class UpdateView extends LinearLayout
}
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.os.Bundle
import android.util.Log
import android.view.MenuItem
import android.widget.Button
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.Util
import retrofit2.Response
import timber.log.Timber
/**
* 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() {
companion object {
private val TAG = EditServerActivity::class.simpleName
const val EDIT_SERVER_INTENT_INDEX = "index"
}
@ -293,7 +292,7 @@ internal class EditServerActivity : AppCompatActivity() {
}
override fun error(error: Throwable) {
Log.w(TAG, error.toString(), error)
Timber.w(error)
ErrorDialog(
activity,
String.format(

View File

@ -3,7 +3,6 @@ package org.moire.ultrasonic.activity
import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.MenuItem
import android.widget.AdapterView
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.service.MediaPlayerController
import org.moire.ultrasonic.util.Util
import timber.log.Timber
/**
* 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() {
companion object {
private val TAG = ServerSelectorActivity::class.simpleName
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)
serverSettingsModel.deleteItem(index)
Log.i(TAG, "Server deleted: $index")
Timber.i("Server deleted: $index")
}
.setNegativeButton(R.string.common_cancel) { dialog, _ ->
dialog.dismiss()

View File

@ -3,7 +3,6 @@ package org.moire.ultrasonic.activity
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@ -12,6 +11,7 @@ import kotlinx.coroutines.runBlocking
import org.moire.ultrasonic.data.ActiveServerProvider
import org.moire.ultrasonic.data.ServerSetting
import org.moire.ultrasonic.data.ServerSettingDao
import timber.log.Timber
/**
* ViewModel to be used in Activities which will handle Server Settings
@ -23,7 +23,6 @@ class ServerSettingsModel(
) : ViewModel() {
companion object {
private val TAG = ServerSettingsModel::class.simpleName
private const val PREFERENCES_KEY_SERVER_MIGRATED = "serverMigrated"
// These constants were removed from Constants.java as they are deprecated and only used here
private const val PREFERENCES_KEY_JUKEBOX_BY_DEFAULT = "jukeboxEnabled"
@ -61,8 +60,7 @@ class ServerSettingsModel(
dbServerList.add(newServerSetting)
repository.insert(newServerSetting)
index++
Log.i(
TAG,
Timber.i(
"Imported server from Preferences to Database:" +
" ${newServerSetting.name}"
)
@ -149,7 +147,7 @@ class ServerSettingsModel(
val itemToBeDeleted = repository.findByIndex(index)
if (itemToBeDeleted != null) {
repository.delete(itemToBeDeleted)
Log.d(TAG, "deleteItem deleted index: $index")
Timber.d("deleteItem deleted index: $index")
reindexSettings()
activeServerProvider.invalidateCache()
}
@ -165,7 +163,7 @@ class ServerSettingsModel(
viewModelScope.launch {
repository.update(serverSetting)
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.id = (repository.getMaxId() ?: 0) + 1
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
newIndex++
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.core.context.startKoin
import org.koin.core.logger.Level
import org.moire.ultrasonic.BuildConfig
import org.moire.ultrasonic.di.appPermanentStorage
import org.moire.ultrasonic.di.baseNetworkModule
import org.moire.ultrasonic.di.directoriesModule
import org.moire.ultrasonic.di.featureFlagsModule
import org.moire.ultrasonic.di.mediaPlayerModule
import org.moire.ultrasonic.di.musicServiceModule
import timber.log.Timber
import timber.log.Timber.DebugTree
class UApp : MultiDexApplication() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(DebugTree())
}
startKoin {
// Use Koin Android Logger
// 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
import android.content.Context
import android.util.Log
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@ -11,6 +10,7 @@ import org.moire.ultrasonic.R
import org.moire.ultrasonic.service.MusicServiceFactory.resetMusicService
import org.moire.ultrasonic.util.Constants
import org.moire.ultrasonic.util.Util
import timber.log.Timber
/**
* This class can be used to retrieve the properties of the Active Server
@ -37,8 +37,7 @@ class ActiveServerProvider(
withContext(Dispatchers.IO) {
cachedServer = repository.findById(serverId)
}
Log.d(
TAG,
Timber.d(
"getActiveServer retrieved from DataBase, id: $serverId; " +
"cachedServer: $cachedServer"
)
@ -67,7 +66,7 @@ class ActiveServerProvider(
* @param index: The index of the Active Server in the Server Selector List
*/
fun setActiveServerByIndex(index: Int) {
Log.d(TAG, "setActiveServerByIndex $index")
Timber.d("setActiveServerByIndex $index")
if (index < 1) {
// Offline mode is selected
setActiveServerId(context, 0)
@ -85,7 +84,7 @@ class ActiveServerProvider(
* This should be called when the Active Server or one of its properties changes
*/
fun invalidateCache() {
Log.d(TAG, "Cache is invalidated")
Timber.d("Cache is invalidated")
cachedServer = null
}
@ -116,8 +115,6 @@ class ActiveServerProvider(
}
companion object {
private val TAG = ActiveServerProvider::class.simpleName
/**
* Queries if the Active Server is the "Offline" mode of Ultrasonic
* @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.os.Environment
import android.text.TextUtils
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -18,6 +17,7 @@ import java.util.LinkedList
import kotlin.Comparator
import org.moire.ultrasonic.R
import org.moire.ultrasonic.util.Util
import timber.log.Timber
/**
* 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]
selectedDirectory = clickedFile.file!!
fileLister(clickedFile.file!!)
Log.d("FileLister", clickedFile.file!!.absolutePath)
Timber.d(clickedFile.file!!.absolutePath)
}
}
}