Skip to content

Commit f9f2335

Browse files
authored
Merge pull request #484 from AppDevNext/TimberLogging
Timber logging
2 parents 3721eaa + eecdb65 commit f9f2335

24 files changed

+102
-127
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ dependencies {
6565
implementation("androidx.compose.ui:ui-tooling-preview")
6666
implementation("androidx.activity:activity-compose:1.12.1")
6767
implementation("androidx.compose.material:material-icons-extended")
68+
implementation("com.github.AppDevNext.Logcat:LogcatCoreLib:3.4")
6869
debugImplementation("androidx.compose.ui:ui-tooling")
6970

7071
// Compose testing

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
android:hardwareAccelerated="true"
99
android:icon="@drawable/ic_launcher"
1010
android:label="@string/app_name"
11+
android:name="info.hannes.logcat.LoggingApplication"
1112
android:theme="@style/AppTheme">
1213
<activity
1314
android:name="info.appdev.chartexample.notimportant.MainActivity"

app/src/main/kotlin/info/appdev/chartexample/BarChartActivity.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.content.Intent
55
import android.content.pm.PackageManager
66
import android.graphics.RectF
77
import android.os.Bundle
8-
import android.util.Log
98
import android.view.Menu
109
import android.view.MenuItem
1110
import android.widget.SeekBar
@@ -31,10 +30,11 @@ import com.github.mikephil.charting.listener.OnChartValueSelectedListener
3130
import com.github.mikephil.charting.utils.Fill
3231
import com.github.mikephil.charting.utils.MPPointF
3332
import info.appdev.chartexample.DataTools.Companion.getValues
33+
import info.appdev.chartexample.custom.XYMarkerView
3434
import info.appdev.chartexample.formatter.DayAxisValueFormatter
3535
import info.appdev.chartexample.formatter.MyAxisValueFormatter
36-
import info.appdev.chartexample.custom.XYMarkerView
3736
import info.appdev.chartexample.notimportant.DemoBase
37+
import timber.log.Timber
3838

3939
class BarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {
4040
private var chart: BarChart? = null
@@ -296,17 +296,12 @@ class BarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelect
296296
chart!!.getBarBounds(entry as BarEntry, bounds)
297297
val position = chart!!.getPosition(entry, AxisDependency.LEFT)
298298

299-
Log.i("bounds", bounds.toString())
300-
Log.i("position", position.toString())
301-
302-
Log.i(
303-
"x-index",
304-
("low: " + chart!!.lowestVisibleX + ", high: "
305-
+ chart!!.highestVisibleX)
306-
)
299+
Timber.i("bounds $bounds")
300+
Timber.i("position = $position")
301+
Timber.i("x-index low: ${+chart!!.lowestVisibleX}, high: ${+chart!!.highestVisibleX}")
307302

308303
MPPointF.recycleInstance(position)
309304
}
310305

311-
override fun onNothingSelected() {}
306+
override fun onNothingSelected() = Unit
312307
}

app/src/main/kotlin/info/appdev/chartexample/BarChartActivityMultiDataset.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.content.Intent
55
import android.content.pm.PackageManager
66
import android.graphics.Color
77
import android.os.Bundle
8-
import android.util.Log
98
import android.view.Menu
109
import android.view.MenuItem
1110
import android.widget.SeekBar
@@ -27,6 +26,7 @@ import com.github.mikephil.charting.listener.OnChartValueSelectedListener
2726
import info.appdev.chartexample.DataTools.Companion.getValues
2827
import info.appdev.chartexample.custom.MyMarkerView
2928
import info.appdev.chartexample.notimportant.DemoBase
29+
import timber.log.Timber
3030
import java.util.Locale
3131

3232
class BarChartActivityMultiDataset : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {
@@ -255,10 +255,8 @@ class BarChartActivityMultiDataset : DemoBase(), OnSeekBarChangeListener, OnChar
255255
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
256256

257257
override fun onValueSelected(entry: Entry, highlight: Highlight) {
258-
Log.i("Activity", "Selected: " + entry.toString() + ", dataSet: " + highlight.dataSetIndex)
258+
Timber.i("Selected: $entry, dataSet: ${highlight.dataSetIndex}")
259259
}
260260

261-
override fun onNothingSelected() {
262-
Log.i("Activity", "Nothing selected.")
263-
}
261+
override fun onNothingSelected() = Unit
264262
}

app/src/main/kotlin/info/appdev/chartexample/BarChartActivitySinus.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class BarChartActivitySinus : DemoBase(), OnSeekBarChangeListener {
3838

3939
binding.chart1.description.isEnabled = false
4040

41-
// if more than 60 entries are displayed in the chart, no values will be
42-
// drawn
41+
// if more than 60 entries are displayed in the chart, no values will be drawn
4342
binding.chart1.setMaxVisibleValueCount(60)
4443

4544
// scaling can now only be done on x- and y-axis separately

app/src/main/kotlin/info/appdev/chartexample/BubbleChartActivity.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.content.Intent
55
import android.content.pm.PackageManager
66
import android.graphics.Color
77
import android.os.Bundle
8-
import android.util.Log
98
import android.view.Menu
109
import android.view.MenuItem
1110
import android.widget.SeekBar
@@ -28,6 +27,7 @@ import com.github.mikephil.charting.utils.ColorTemplate
2827
import com.github.mikephil.charting.utils.MPPointF
2928
import info.appdev.chartexample.DataTools.Companion.getValues
3029
import info.appdev.chartexample.notimportant.DemoBase
30+
import timber.log.Timber
3131

3232
class BubbleChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {
3333
private var chart: BubbleChart? = null
@@ -225,12 +225,12 @@ class BubbleChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSel
225225
}
226226

227227
override fun onValueSelected(entry: Entry, highlight: Highlight) {
228-
Log.i("VAL SELECTED", "Value: " + entry.y + ", xIndex: " + entry.x + ", DataSet index: " + highlight.dataSetIndex)
228+
Timber.i("Value: " + entry.y + ", xIndex: " + entry.x + ", DataSet index: " + highlight.dataSetIndex)
229229
}
230230

231-
override fun onNothingSelected() {}
231+
override fun onNothingSelected() = Unit
232232

233-
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
233+
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
234234

235-
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
235+
override fun onStopTrackingTouch(seekBar: SeekBar?) = Unit
236236
}

app/src/main/kotlin/info/appdev/chartexample/DataTools.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package info.appdev.chartexample
33
import android.content.Context
44
import android.graphics.Color
55
import android.graphics.DashPathEffect
6-
import android.util.Log
76
import androidx.core.content.ContextCompat
87
import com.github.mikephil.charting.charts.LineChart
98
import com.github.mikephil.charting.data.Entry
@@ -13,6 +12,7 @@ import com.github.mikephil.charting.formatter.IFillFormatter
1312
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider
1413
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet
1514
import com.github.mikephil.charting.utils.getSDKInt
15+
import timber.log.Timber
1616

1717
class DataTools {
1818
companion object {
@@ -143,7 +143,7 @@ class DataTools {
143143
}
144144

145145
fun setData(context: Context, lineChart: LineChart, count: Int = VAL_COUNT, range: Float = VAL_RANGE) {
146-
Log.d("setData", "$count= range=$range")
146+
Timber.d("count=$count range=$range")
147147
val values = ArrayList<Entry>()
148148
if (count == VAL_COUNT) {
149149
VAL_FIX.forEachIndexed { index, d ->

app/src/main/kotlin/info/appdev/chartexample/DrawChartActivity.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ package info.appdev.chartexample
44
import android.Manifest
55
import android.content.pm.PackageManager
66
import android.os.Bundle
7-
import android.util.Log
87
import android.view.Menu
98
import android.view.MenuItem
109
import androidx.core.content.ContextCompat
11-
import com.github.mikephil.charting.charts.Chart
1210
import com.github.mikephil.charting.data.DataSet
1311
import com.github.mikephil.charting.data.Entry
1412
import com.github.mikephil.charting.data.LineData
@@ -18,6 +16,7 @@ import com.github.mikephil.charting.listener.OnChartValueSelectedListener
1816
import com.github.mikephil.charting.listener.OnDrawListener
1917
import info.appdev.chartexample.databinding.ActivityDrawChartBinding
2018
import info.appdev.chartexample.notimportant.DemoBase
19+
import timber.log.Timber
2120

2221
/**
2322
* This Activity demonstrates drawing into the Chart with the finger. Both line,
@@ -125,25 +124,25 @@ class DrawChartActivity : DemoBase(), OnChartValueSelectedListener, OnDrawListen
125124
}
126125

127126
override fun onValueSelected(entry: Entry, highlight: Highlight) {
128-
Log.i("VAL SELECTED", ("Value: " + entry.y + ", xIndex: " + entry.x + ", DataSet index: " + highlight.dataSetIndex))
127+
Timber.i(("Value: " + entry.y + ", xIndex: " + entry.x + ", DataSet index: " + highlight.dataSetIndex))
129128
}
130129

131130
override fun onNothingSelected() = Unit
132131

133132
/** callback for each new entry drawn with the finger */
134133
override fun onEntryAdded(entry: Entry) {
135-
Log.i(Chart.LOG_TAG, entry.toString())
134+
Timber.i(entry.toString())
136135
}
137136

138137
/** callback when a DataSet has been drawn (when lifting the finger) */
139138
override fun onDrawFinished(dataSet: DataSet<*>) {
140-
Log.i(Chart.LOG_TAG, "DataSet drawn. " + dataSet.toSimpleString())
139+
Timber.i("DataSet drawn. " + dataSet.toSimpleString())
141140

142141
// prepare the legend again
143142
binding.chart1.data?.let { binding.chart1.legendRenderer.computeLegend(it) }
144143
}
145144

146145
override fun onEntryMoved(entry: Entry) {
147-
Log.i(Chart.LOG_TAG, "Point moved $entry")
146+
Timber.i("Point moved $entry")
148147
}
149148
}

app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.content.Intent
55
import android.content.pm.PackageManager
66
import android.graphics.RectF
77
import android.os.Bundle
8-
import android.util.Log
98
import android.view.Menu
109
import android.view.MenuItem
1110
import android.widget.SeekBar
@@ -26,6 +25,7 @@ import info.appdev.chartexample.DataTools.Companion.getValues
2625
import info.appdev.chartexample.notimportant.DemoBase
2726
import androidx.core.net.toUri
2827
import info.appdev.chartexample.databinding.ActivityHorizontalbarchartBinding
28+
import timber.log.Timber
2929

3030
class HorizontalBarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {
3131

@@ -249,8 +249,8 @@ class HorizontalBarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartV
249249
.getAxisDependency()
250250
)
251251

252-
Log.i("bounds", bounds.toString())
253-
Log.i("position", position.toString())
252+
Timber.i(bounds.toString())
253+
Timber.i(position.toString())
254254

255255
MPPointF.recycleInstance(position)
256256
}

app/src/main/kotlin/info/appdev/chartexample/HorizontalBarNegativeChartActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.content.Intent
55
import android.content.pm.PackageManager
66
import android.graphics.RectF
77
import android.os.Bundle
8-
import android.util.Log
98
import android.view.Menu
109
import android.view.MenuItem
1110
import android.widget.SeekBar
@@ -27,6 +26,7 @@ import com.github.mikephil.charting.listener.OnChartValueSelectedListener
2726
import com.github.mikephil.charting.utils.MPPointF
2827
import info.appdev.chartexample.DataTools.Companion.getValues
2928
import info.appdev.chartexample.notimportant.DemoBase
29+
import timber.log.Timber
3030

3131
class HorizontalBarNegativeChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {
3232
private var chart: HorizontalBarChart? = null
@@ -256,8 +256,8 @@ class HorizontalBarNegativeChartActivity : DemoBase(), OnSeekBarChangeListener,
256256
.getAxisDependency()
257257
)
258258

259-
Log.i("bounds", bounds.toString())
260-
Log.i("position", position.toString())
259+
Timber.i("bounds $bounds")
260+
Timber.i("position $position")
261261

262262
MPPointF.recycleInstance(position)
263263
}

0 commit comments

Comments
 (0)