diff --git a/MPChartLib/build.gradle.kts b/MPChartLib/build.gradle.kts index 24d278d21..eced556ba 100644 --- a/MPChartLib/build.gradle.kts +++ b/MPChartLib/build.gradle.kts @@ -41,6 +41,7 @@ dependencies { implementation("androidx.annotation:annotation:1.9.1") implementation("androidx.core:core:1.17.0") implementation("androidx.activity:activity-ktx:1.12.2") + implementation("com.github.AppDevNext.Logcat:LogcatCoreLib:3.4") testImplementation("junit:junit:4.13.2") } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarChart.kt index be3c9359f..bd4e5a60e 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarChart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarChart.kt @@ -3,7 +3,6 @@ package com.github.mikephil.charting.charts import android.content.Context import android.graphics.RectF import android.util.AttributeSet -import android.util.Log import com.github.mikephil.charting.components.YAxis import com.github.mikephil.charting.data.BarData import com.github.mikephil.charting.data.BarEntry @@ -11,6 +10,7 @@ import com.github.mikephil.charting.highlight.BarHighlighter import com.github.mikephil.charting.highlight.Highlight import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider import com.github.mikephil.charting.renderer.BarChartRenderer +import timber.log.Timber import java.util.Locale /** @@ -105,7 +105,7 @@ open class BarChart : BarLineChartBase, BarDataProvider { */ override fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? { if (mData == null) { - Log.e(LOG_TAG, "Can't select by touch. No data set.") + Timber.e("Can't select by touch. No data set.") return null } else { highlighter?.let { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java index 8a7adb01b..15b4f8002 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java @@ -35,6 +35,7 @@ import com.github.mikephil.charting.utils.UtilsKtKt; import androidx.annotation.NonNull; +import timber.log.Timber; /** * Base-class of LineChart, BarChart, ScatterChart and CandleStickChart. @@ -320,7 +321,7 @@ protected void onDraw(@NonNull Canvas canvas) { totalTime += drawtime; drawCycles += 1; long average = totalTime / drawCycles; - Log.i(LOG_TAG, "Drawtime: " + drawtime + " ms, average: " + average + " ms, cycles: " + drawCycles); + Timber.i("Drawtime: " + drawtime + " ms, average: " + average + " ms, cycles: " + drawCycles); } } @@ -335,7 +336,7 @@ public void resetTracking() { protected void prepareValuePxMatrix() { if (isLogEnabled()) { - Log.i(LOG_TAG, "Preparing Value-Px Matrix, xmin: " + mXAxis.mAxisMinimum + ", xmax: " + mXAxis.mAxisMaximum + ", xdelta: " + mXAxis.mAxisRange); + Timber.i("Preparing Value-Px Matrix, xmin: " + mXAxis.mAxisMinimum + ", xmax: " + mXAxis.mAxisMaximum + ", xdelta: " + mXAxis.mAxisRange); } mRightAxisTransformer.prepareMatrixValuePx(mXAxis.mAxisMinimum, mXAxis.mAxisRange, mAxisRight.mAxisRange, mAxisRight.mAxisMinimum); @@ -353,12 +354,12 @@ public void notifyDataSetChanged() { if (mData == null) { if (isLogEnabled()) { - Log.i(LOG_TAG, "Preparing... DATA NOT SET."); + Timber.i("Preparing... DATA NOT SET."); } return; } else { if (isLogEnabled()) { - Log.i(LOG_TAG, "Preparing..."); + Timber.i("Preparing data..."); } } @@ -520,8 +521,8 @@ public void calculateOffsets() { getViewPortHandler().restrainViewPort(Math.max(minOffset, offsetLeft), Math.max(minOffset, offsetTop), Math.max(minOffset, offsetRight), Math.max(minOffset, offsetBottom)); if (isLogEnabled()) { - Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom); - Log.i(LOG_TAG, "Content: " + getViewPortHandler().getContentRect()); + Timber.i("offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom); + Timber.i("Content: " + getViewPortHandler().getContentRect()); } } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.kt index 9848ef681..7bc59df3a 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.kt @@ -12,7 +12,6 @@ import android.graphics.RectF import android.graphics.Typeface import android.text.TextUtils import android.util.AttributeSet -import android.util.Log import android.view.View import android.view.ViewGroup import android.view.accessibility.AccessibilityEvent @@ -45,6 +44,7 @@ import com.github.mikephil.charting.utils.ViewPortHandler import com.github.mikephil.charting.utils.convertDpToPixel import com.github.mikephil.charting.utils.getDecimals import com.github.mikephil.charting.utils.initUtils +import timber.log.Timber import kotlin.math.abs import kotlin.math.max @@ -274,7 +274,7 @@ abstract class Chart>?> : ViewGroup, IBase mInfoPaint!!.textSize = 12f.convertDpToPixel() if (this.isLogEnabled) { - Log.i("", "Chart.init()") + Timber.i("Chart.init()") // enable being detected by ScreenReader setFocusable(true) @@ -339,7 +339,7 @@ abstract class Chart>?> : ViewGroup, IBase notifyDataSetChanged() if (this.isLogEnabled) { - Log.i(LOG_TAG, "Data is set.") + Timber.i("Data is set.") } } @@ -649,7 +649,7 @@ abstract class Chart>?> : ViewGroup, IBase this.highlighted = null } else { if (this.isLogEnabled) { - Log.i(LOG_TAG, "Highlighted: $high") + Timber.i("Highlighted: $high") } entry = mData!!.getEntryForHighlight(high) @@ -685,7 +685,7 @@ abstract class Chart>?> : ViewGroup, IBase */ open fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? { if (mData == null) { - Log.e(LOG_TAG, "Can't select by touch. No data set.") + Timber.e("Can't select by touch. No data set.") return null } else { return this.highlighter!!.getHighlight(x, y) @@ -1292,17 +1292,17 @@ abstract class Chart>?> : ViewGroup, IBase override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { if (this.isLogEnabled) { - Log.i(LOG_TAG, "OnSizeChanged()") + Timber.i("OnSizeChanged()") } if (w > 0 && h > 0 && w < 10000 && h < 10000) { if (this.isLogEnabled) { - Log.i(LOG_TAG, "Setting chart dimens, width: $w, height: $h") + Timber.i("Setting chart dimens, width: $w, height: $h") } viewPortHandler.setChartDimens(w.toFloat(), h.toFloat()) } else { if (this.isLogEnabled) { - Log.w(LOG_TAG, "*Avoiding* setting chart dimens! width: $w, height: $h") + Timber.w("*Avoiding* setting chart dimens! width: $w, height: $h") } } @@ -1334,7 +1334,7 @@ abstract class Chart>?> : ViewGroup, IBase override fun onDetachedFromWindow() { super.onDetachedFromWindow() - //Log.i(LOG_TAG, "Detaching..."); + //Timber.i("Detaching..."); if (mUnbind) { unbindDrawables(this) } @@ -1380,7 +1380,7 @@ abstract class Chart>?> : ViewGroup, IBase override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean { val completed = super.dispatchPopulateAccessibilityEvent(event) - Log.d(LOG_TAG, "Dispatch called for Chart and completed as $completed") + Timber.d("Dispatch called for Chart and completed as $completed") event.text.add(this.accessibilityDescription) @@ -1393,8 +1393,6 @@ abstract class Chart>?> : ViewGroup, IBase } // endregion companion object { - const val LOG_TAG: String = "AndroidChart" - /** * paint for the grid background (only line and barchart) */ diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/CombinedChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/CombinedChart.kt index d257241de..7aa6f0a2b 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/CombinedChart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/CombinedChart.kt @@ -3,7 +3,6 @@ package com.github.mikephil.charting.charts import android.content.Context import android.graphics.Canvas import android.util.AttributeSet -import android.util.Log import com.github.mikephil.charting.data.BarData import com.github.mikephil.charting.data.BubbleData import com.github.mikephil.charting.data.CandleData @@ -16,6 +15,7 @@ import com.github.mikephil.charting.highlight.Highlight import com.github.mikephil.charting.interfaces.dataprovider.CombinedDataProvider import com.github.mikephil.charting.interfaces.datasets.IDataSet import com.github.mikephil.charting.renderer.CombinedChartRenderer +import timber.log.Timber /** * This chart class allows the combination of lines, bars, scatter and candle @@ -97,7 +97,7 @@ open class CombinedChart : BarLineChartBase, CombinedDataProvider */ override fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? { if (mData == null) { - Log.e(LOG_TAG, "Can't select by touch. No data set.") + Timber.e("Can't select by touch. No data set.") return null } else { highlighter?.let { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/HorizontalBarChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/HorizontalBarChart.kt index c8a9b3ad0..0b56c5460 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/HorizontalBarChart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/HorizontalBarChart.kt @@ -3,7 +3,6 @@ package com.github.mikephil.charting.charts import android.content.Context import android.graphics.RectF import android.util.AttributeSet -import android.util.Log import com.github.mikephil.charting.components.Legend.LegendHorizontalAlignment import com.github.mikephil.charting.components.Legend.LegendOrientation import com.github.mikephil.charting.components.Legend.LegendVerticalAlignment @@ -21,6 +20,7 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.MPPointF.Companion.getInstance import com.github.mikephil.charting.utils.TransformerHorizontalBarChart import com.github.mikephil.charting.utils.convertDpToPixel +import timber.log.Timber import kotlin.math.max import kotlin.math.min @@ -154,9 +154,11 @@ open class HorizontalBarChart : BarChart { XAxisPosition.BOTTOM -> { offsetLeft += xLabelWidth } + XAxisPosition.TOP -> { offsetRight += xLabelWidth } + XAxisPosition.BOTH_SIDED -> { offsetLeft += xLabelWidth offsetRight += xLabelWidth @@ -164,7 +166,7 @@ open class HorizontalBarChart : BarChart { XAxisPosition.TOP_INSIDE -> TODO() XAxisPosition.BOTTOM_INSIDE -> TODO() - null -> Log.w(LOG_TAG, "XAxisPosition is null") + null -> Timber.w("XAxisPosition is null") } } @@ -183,11 +185,8 @@ open class HorizontalBarChart : BarChart { ) if (isLogEnabled) { - Log.i( - LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " + - offsetRight + ", offsetBottom: " + offsetBottom - ) - Log.i(LOG_TAG, "Content: " + viewPortHandler.contentRect) + Timber.i("offsetLeft: $offsetLeft, offsetTop: $offsetTop, offsetRight: $offsetRight, offsetBottom: $offsetBottom") + Timber.i("Content: ${viewPortHandler.contentRect}") } prepareOffsetMatrix() @@ -255,7 +254,7 @@ open class HorizontalBarChart : BarChart { override fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? { if (mData == null) { if (isLogEnabled) { - Log.e(LOG_TAG, "Can't select by touch. No data set.") + Timber.e("Can't select by touch. No data set.") } return null } else { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.kt index 3f5009cfe..5c0aa4ab4 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.kt @@ -4,7 +4,6 @@ import android.animation.ObjectAnimator import android.annotation.SuppressLint import android.content.Context import android.util.AttributeSet -import android.util.Log import android.view.MotionEvent import com.github.mikephil.charting.animation.Easing.EasingFunction import com.github.mikephil.charting.components.Legend.LegendHorizontalAlignment @@ -19,6 +18,7 @@ import com.github.mikephil.charting.utils.MPPointF.Companion.getInstance import com.github.mikephil.charting.utils.MPPointF.Companion.recycleInstance import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.convertDpToPixel +import timber.log.Timber import kotlin.math.acos import kotlin.math.cos import kotlin.math.max @@ -222,7 +222,7 @@ abstract class PieRadarChartBase>> viewPortHandler.chartHeight * legend.maxSizePercent ) - LegendVerticalAlignment.CENTER -> Log.e(LOG_TAG, "LegendCenter/VerticalCenter not supported for PieRadarChart") + LegendVerticalAlignment.CENTER -> Timber.e("LegendCenter/VerticalCenter not supported for PieRadarChart") } } } @@ -247,7 +247,7 @@ abstract class PieRadarChartBase>> when (legend.verticalAlignment) { LegendVerticalAlignment.TOP -> legendTop = yLegendOffset LegendVerticalAlignment.BOTTOM -> legendBottom = yLegendOffset - LegendVerticalAlignment.CENTER -> Log.e(LOG_TAG, "LegendCenter/HorizontalCenter not supported for PieRadarChart") + LegendVerticalAlignment.CENTER -> Timber.e("LegendCenter/HorizontalCenter not supported for PieRadarChart") } } } @@ -282,7 +282,7 @@ abstract class PieRadarChartBase>> viewPortHandler.restrainViewPort(offsetLeft, offsetTop, offsetRight, offsetBottom) if (isLogEnabled) - Log.i(LOG_TAG, "offsetLeft: $offsetLeft, offsetTop: $offsetTop, offsetRight: $offsetRight, offsetBottom: $offsetBottom") + Timber.i("offsetLeft: $offsetLeft, offsetTop: $offsetTop, offsetRight: $offsetRight, offsetBottom: $offsetBottom") } /** diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.kt index 4598bf152..1fe3024fe 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.kt @@ -3,10 +3,10 @@ package com.github.mikephil.charting.components import android.graphics.Color import android.graphics.DashPathEffect import android.graphics.Paint -import android.util.Log import com.github.mikephil.charting.formatter.DefaultAxisValueFormatter import com.github.mikephil.charting.formatter.IAxisValueFormatter import com.github.mikephil.charting.utils.convertDpToPixel +import timber.log.Timber import kotlin.math.abs /** @@ -398,10 +398,7 @@ abstract class AxisBase : ComponentBase() { limitLines.add(l) if (limitLines.size > 6) { - Log.e( - "MPAndroiChart", - "Warning! You have more than 6 LimitLines on your axis, do you really want that?" - ) + Timber.e("Warning! You have more than 6 LimitLines on your axis, do you really want that?") } } @@ -412,10 +409,7 @@ abstract class AxisBase : ComponentBase() { limitRanges.add(l) if (limitRanges.size > 6) { - Log.e( - "MPAndroiChart", - "Warning! You have more than 6 LimitLines on your axis, do you really want that?" - ) + Timber.e("Warning! You have more than 6 LimitLines on your axis, do you really want that?") } } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/ChartData.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/data/ChartData.kt index b46cabf66..c7783aaed 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/ChartData.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/ChartData.kt @@ -1,11 +1,11 @@ package com.github.mikephil.charting.data import android.graphics.Typeface -import android.util.Log import com.github.mikephil.charting.components.YAxis.AxisDependency import com.github.mikephil.charting.formatter.IValueFormatter import com.github.mikephil.charting.highlight.Highlight import com.github.mikephil.charting.interfaces.datasets.IDataSet +import timber.log.Timber import java.io.Serializable import java.util.Collections @@ -376,7 +376,7 @@ abstract class ChartData> : Serializable { calcMinMax(entry, set.axisDependency) } else { - Log.e("addEntry", "Cannot add Entry because dataSetIndex too high or too low.") + Timber.e("Cannot add Entry because dataSetIndex too high or too low.") } } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/CombinedData.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/data/CombinedData.kt index ca3d2a5f3..0d0c73e37 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/CombinedData.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/CombinedData.kt @@ -4,6 +4,7 @@ import android.util.Log import com.github.mikephil.charting.components.YAxis import com.github.mikephil.charting.highlight.Highlight import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet +import timber.log.Timber import java.lang.Float import kotlin.Boolean import kotlin.Deprecated @@ -197,19 +198,19 @@ class CombinedData : BarLineScatterCandleBubbleData( override fun getEntryForIndex(index: Int): T? { if (index < 0) { - Log.e("DataSet", "index $index is < 0 for getEntryForIndex") + Timber.e("index $index is < 0 for getEntryForIndex") return null } else if (index >= mEntries!!.size) { - Log.e("DataSet", "index " + index + "/" + mEntries!!.size + " is out of range for getEntryForIndex") + Timber.e("index " + index + "/" + mEntries!!.size + " is out of range for getEntryForIndex") return null } return mEntries!![index] diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/LineDataSet.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/data/LineDataSet.kt index 0ca89e322..b5a55abc9 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/LineDataSet.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/LineDataSet.kt @@ -3,12 +3,12 @@ package com.github.mikephil.charting.data import android.content.Context import android.graphics.Color import android.graphics.DashPathEffect -import android.util.Log import com.github.mikephil.charting.formatter.DefaultFillFormatter import com.github.mikephil.charting.formatter.IFillFormatter import com.github.mikephil.charting.interfaces.datasets.ILineDataSet import com.github.mikephil.charting.utils.ColorTemplate import com.github.mikephil.charting.utils.convertDpToPixel +import timber.log.Timber open class LineDataSet(yVals: MutableList?, label: String = "") : LineRadarDataSet(yVals, label), ILineDataSet { /** @@ -179,7 +179,7 @@ open class LineDataSet(yVals: MutableList?, label: String = "") : LineRad if (value >= 1f) { mCircleRadius = value.convertDpToPixel() } else { - Log.e("LineDataSet", "Circle radius cannot be < 1") + Timber.e("Circle radius cannot be < 1") } } @@ -193,7 +193,7 @@ open class LineDataSet(yVals: MutableList?, label: String = "") : LineRad if (value >= 0.5f) { mCircleHoleRadius = value.convertDpToPixel() } else { - Log.e("LineDataSet", "Circle radius cannot be < 0.5") + Timber.e("Circle radius cannot be < 0.5") } } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.kt index afadfa9c3..f5b00841e 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.kt @@ -1,8 +1,8 @@ package com.github.mikephil.charting.data -import android.util.Log import com.github.mikephil.charting.highlight.Highlight import com.github.mikephil.charting.interfaces.datasets.IPieDataSet +import timber.log.Timber /** * A PieData object can only represent one DataSet. Unlike all other charts, the @@ -34,7 +34,7 @@ class PieData : ChartData { get() { super.dataSets?.let { if (it.isEmpty()) { - Log.e("AndroidChart", "Found multiple data sets while pie chart only allows one") + Timber.e("Found multiple data sets while pie chart only allows one") } } return super.dataSets diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieEntry.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieEntry.kt index ee5cdabbf..4f4e5f9bf 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieEntry.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieEntry.kt @@ -2,7 +2,7 @@ package com.github.mikephil.charting.data import android.annotation.SuppressLint import android.graphics.drawable.Drawable -import android.util.Log +import timber.log.Timber @SuppressLint("ParcelCreator") class PieEntry : Entry { @@ -43,12 +43,12 @@ class PieEntry : Entry { @set:Deprecated("") override var x: Float get() { - Log.i("DEPRECATED", "Pie entries do not have x values") + Timber.i("Pie entries do not have x values") return super.x } set(x) { super.x = x - Log.i("DEPRECATED", "Pie entries do not have x values") + Timber.i("Pie entries do not have x values") } override fun copy(): PieEntry { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/listener/BarLineChartTouchListener.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/listener/BarLineChartTouchListener.kt index 07e4e6f89..1364c027e 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/listener/BarLineChartTouchListener.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/listener/BarLineChartTouchListener.kt @@ -2,7 +2,6 @@ package com.github.mikephil.charting.listener import android.annotation.SuppressLint import android.graphics.Matrix -import android.util.Log import android.view.MotionEvent import android.view.VelocityTracker import android.view.View @@ -16,6 +15,7 @@ import com.github.mikephil.charting.interfaces.datasets.IDataSet import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.convertDpToPixel +import timber.log.Timber import kotlin.math.abs import kotlin.math.sqrt @@ -503,7 +503,7 @@ class BarLineChartTouchListener( chart.zoom(scaleX, scaleY, trans.x, trans.y) if (chart.isLogEnabled) - Log.i("BarlineChartTouch", "Double-Tap, Zooming In, x: ${trans.x} y: ${trans.y}") + Timber.i("Double-Tap, Zooming In, x: ${trans.x} y: ${trans.y}") onChartGestureListener?.onChartScale(e, scaleX, scaleY) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.kt index 8db78db8d..b7d2f2ed8 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.kt @@ -1,7 +1,6 @@ package com.github.mikephil.charting.renderer import android.graphics.Canvas -import android.util.Log import com.github.mikephil.charting.animation.ChartAnimator import com.github.mikephil.charting.highlight.Highlight import com.github.mikephil.charting.interfaces.dataprovider.ScatterDataProvider @@ -10,6 +9,7 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler import com.github.mikephil.charting.utils.convertDpToPixel +import timber.log.Timber import kotlin.math.ceil import kotlin.math.min @@ -43,7 +43,7 @@ open class ScatterChartRenderer(@JvmField var dataProvider: ScatterDataProvider, val renderer = dataSet.shapeRenderer if (renderer == null) { - Log.i("MISSING", "There's no IShapeRenderer specified for ScatterDataSet") + Timber.i("There's no IShapeRenderer specified for ScatterDataSet") return } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/AssetManagerUtils.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/AssetManagerUtils.kt index 6fcaa77e5..ec5c17d50 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/AssetManagerUtils.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/AssetManagerUtils.kt @@ -1,9 +1,10 @@ package com.github.mikephil.charting.utils import android.content.res.AssetManager -import android.util.Log +import android.webkit.ConsoleMessage import com.github.mikephil.charting.data.BarEntry import com.github.mikephil.charting.data.Entry +import timber.log.Timber import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader @@ -12,7 +13,6 @@ import java.nio.charset.StandardCharsets /** * Utilities class for interacting with the assets and the devices storage to load and save DataSet objects from and to .txt files. */ -private const val LOG = "Chart-FileUtils" /** * Loads an array of Entries from a textfile from the assets folder. @@ -46,7 +46,7 @@ fun AssetManager.loadEntriesFromAssets(path: String): MutableList { } } } catch (e: IOException) { - Log.e(LOG, e.toString()) + Timber.e(e.toString()) } return entries @@ -65,7 +65,7 @@ fun AssetManager.loadBarEntriesFromAssets(path: String): MutableList { } } } catch (e: IOException) { - Log.e(LOG, e.toString()) + Timber.e(e.toString()) } return entries diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/UtilsKt.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/UtilsKt.kt index 98af308d6..cf3dd707f 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/utils/UtilsKt.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/utils/UtilsKt.kt @@ -3,9 +3,8 @@ package com.github.mikephil.charting.utils import android.content.Context import android.os.Build import android.util.DisplayMetrics -import android.util.Log -import android.util.Log.i import android.view.ViewConfiguration +import timber.log.Timber import java.lang.Double import kotlin.Boolean import kotlin.Char @@ -18,7 +17,6 @@ import kotlin.math.ceil import kotlin.math.log10 import kotlin.math.pow import kotlin.math.roundToInt -import kotlin.time.times var metrics: DisplayMetrics? = null var minimumFlingVelocity = 0 @@ -73,10 +71,7 @@ fun kotlin.Double.roundToNextSignificant(): Float { */ fun Float.convertDpToPixel(): Float { if (metrics == null) { - Log.e( - "chartLib-Utils", - "Utils NOT INITIALIZED. You need to call Utils.init(...) at least once before calling Utils.convertDpToPixel(...). Otherwise conversion does not take place." - ) + Timber.e("Utils NOT INITIALIZED. You need to call Utils.init(...) at least once before calling Utils.convertDpToPixel(...). Otherwise conversion does not take place.") return this } else return this * metrics!!.density diff --git a/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt index e78eeb411..24907a240 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt @@ -40,6 +40,7 @@ class HorizontalBarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartV binding.seekBarX.setOnSeekBarChangeListener(this) binding.chart1.setOnChartValueSelectedListener(this) + binding.chart1.isLogEnabled = true // chart.setHighlightEnabled(false); binding.chart1.setDrawBarShadow(false)