Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId = "com.am.stbus"
minSdk = 23
targetSdk = 36
versionCode = 83
versionName = "4.0.2"
versionCode = 84
versionName = "4.0.3"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -30,6 +30,9 @@ android {
}
release {
isMinifyEnabled = true
firebaseCrashlytics {
mappingFileUploadEnabled = true
}
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand All @@ -44,6 +47,7 @@ android {
jvmTarget = "11"
}
buildFeatures {
buildConfig = true
compose = true
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
public static <fields>;
}
-keep class **.R$*

-keepattributes SourceFile,LineNumberTable # Keep file names and line numbers.
-keep public class * extends java.lang.Exception # Optional: Keep custom exceptions.
11 changes: 8 additions & 3 deletions app/src/main/java/com/am/stbus/SplitBusApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ import com.am.stbus.common.di.networkModule
import com.am.stbus.common.di.repositoryModule
import com.am.stbus.common.di.useCaseModule
import com.am.stbus.common.di.viewModelModule
import com.am.stbus.common.utils.ProductionTree
import com.jakewharton.threetenabp.AndroidThreeTen
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
import timber.log.Timber


class SplitBusApplication : Application() {

Expand Down Expand Up @@ -68,9 +71,11 @@ class SplitBusApplication : Application() {
}

private fun setupTimber() {
/* if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}*/
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
} else {
Timber.plant(ProductionTree())
}
}

private fun setupThreeTen() {
Expand Down
66 changes: 66 additions & 0 deletions app/src/main/java/com/am/stbus/common/utils/ProductionTree.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* MIT License
*
* Copyright (c) 2013 - 2026 Antonio Marin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.am.stbus.common.utils

import android.util.Log
import com.google.firebase.crashlytics.FirebaseCrashlytics
import timber.log.Timber

class ProductionTree : Timber.Tree() {

private val crashlytics = FirebaseCrashlytics.getInstance()

override fun log(
priority: Int,
tag: String?,
message: String,
t: Throwable?
) {
when (priority) {
Log.VERBOSE,
Log.DEBUG -> {
// Ignore in production
}

Log.INFO -> {
// Optional: send to analytics
}

Log.WARN -> {
// Optional: send warnings somewhere
}

Log.ERROR,
Log.ASSERT -> {
if (t != null) {
crashlytics.recordException(t)
} else {
crashlytics.log("${tag ?: "NO_TAG"}: $message")
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ fun HomeScreenPreview() {
.fillMaxSize()
) {
HomeScreen(emptyList(), emptyList(), {}) { }
//omeScreen()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,15 @@ class BusStopArrivalsDetailViewModel(

var busStopTimes: List<BusStopTimes>? = null

init {
Timber.d("Debugging - BusStopArrivalsDetailViewModel init")
}

fun getBusStopArrivals(onPullToRefresh: Boolean, busStopId: Int) {
if (!onPullToRefresh) {
busStopTimes = emptyList()
}
Timber.d("Debugging - get bus stop arrival $busStopId")
pullToRefreshLoading = onPullToRefresh
viewModelScope.launch {
val result = getDeparturesUseCase.run(busStopId)

result.onSuccess { busStopArrivals ->
Timber.d("onSuccess $busStopId ${busStopArrivals}")
busStopTimes = busStopArrivals.map {
BusStopTimes(
lineNumber = it.lineNumber ?: "",
Expand All @@ -69,7 +63,8 @@ class BusStopArrivalsDetailViewModel(
loading = false
pullToRefreshLoading = false
}.onFailure {
Timber.d("onFailure $busStopId $it")
Timber.wtf("onFailure $busStopId $it")
Timber.wtf(it)
busStopTimes = null
pullToRefreshLoading = false
loading = false
Expand All @@ -93,15 +88,3 @@ class BusStopArrivalsDetailViewModel(
)

}


/*
@Serializable
data class BusStopArrival(
@SerialName("lineNumber")
val lineNumber: String?,
@SerialName("title")
val title: String?,
@SerialName("time")
val time: String?,
)*/
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ class TimetablesDetailViewModel(

var timetableData: GetTimetableDetailDataUseCase.TimetableDetailData? = null

init {
Timber.d("Debugging - TimetablesDetailViewModel init")
}

fun getTimetableData(websiteTitle: String) {
loading = true
viewModelScope.launch(Dispatchers.IO) {
Expand All @@ -55,6 +51,8 @@ class TimetablesDetailViewModel(
timetableData = it
loading = false
}.onFailure {
Timber.wtf("onFailure $websiteTitle $it")
Timber.wtf(it)
timetableData = null
loading = false
}
Expand Down