diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt b/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt index 8a38fa557..126d856aa 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt @@ -1,7 +1,6 @@ package io.github.wulkanowy.services.sync import android.content.Context -import android.os.Build.VERSION_CODES.LOLLIPOP import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.BigTextStyle import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT @@ -17,9 +16,9 @@ import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository import io.github.wulkanowy.data.repositories.semester.SemesterRepository import io.github.wulkanowy.data.repositories.student.StudentRepository import io.github.wulkanowy.sdk.exception.FeatureDisabledException +import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException import io.github.wulkanowy.services.sync.channels.DebugChannel import io.github.wulkanowy.services.sync.works.Work -import io.github.wulkanowy.utils.AppInfo import io.github.wulkanowy.utils.getCompatColor import io.reactivex.Completable import io.reactivex.Single @@ -33,8 +32,7 @@ class SyncWorker @AssistedInject constructor( private val semesterRepository: SemesterRepository, private val works: Set<@JvmSuppressWildcards Work>, private val preferencesRepository: PreferencesRepository, - private val notificationManager: NotificationManagerCompat, - private val appInfo: AppInfo + private val notificationManager: NotificationManagerCompat ) : RxWorker(appContext, workerParameters) { override fun createWork(): Single { @@ -47,6 +45,10 @@ class SyncWorker @AssistedInject constructor( .flatMapCompletable { semester -> Completable.mergeDelayError(works.map { work -> work.create(student, semester) + .onErrorResumeNext { + if (it is FeatureDisabledException || it is FeatureNotAvailableException) Completable.complete() + else Completable.error(it) + } .doOnSubscribe { Timber.i("${work::class.java.simpleName} is starting") } .doOnError { Timber.i("${work::class.java.simpleName} result: An exception occurred") } .doOnComplete { Timber.i("${work::class.java.simpleName} result: Success") } @@ -57,11 +59,11 @@ class SyncWorker @AssistedInject constructor( .onErrorReturn { Timber.e(it, "There was an error during synchronization") when { - it is FeatureDisabledException -> Result.success() inputData.getBoolean("one_time", false) -> { Result.failure(Data.Builder() .putString("error", it.toString()) - .build()) + .build() + ) } else -> Result.retry() } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt index 6323dbe1e..90c4e38ef 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt @@ -133,7 +133,7 @@ class GradeStatisticsPresenter @Inject constructor( showSubjects(true) } }, { - Timber.e("Loading grade stats subjects result: An exception occurred") + Timber.i("Loading grade stats subjects result: An exception occurred") errorHandler.dispatch(it) }) ) @@ -179,7 +179,7 @@ class GradeStatisticsPresenter @Inject constructor( } analytics.logEvent("load_grade_statistics", "items" to it.size, "force_refresh" to forceRefresh) }) { - Timber.e("Loading grade stats result: An exception occurred") + Timber.i("Loading grade stats result: An exception occurred") errorHandler.dispatch(it) }) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt index b292ded53..9a21fb910 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt @@ -70,7 +70,7 @@ class LoginRecoverPresenter @Inject constructor( .subscribe({ (resetUrl, siteKey) -> view?.loadReCaptcha(siteKey, resetUrl) }) { - Timber.e("Obtain captcha site key result: An exception occurred") + Timber.i("Obtain captcha site key result: An exception occurred") errorHandler.dispatch(it) }) } @@ -120,7 +120,7 @@ class LoginRecoverPresenter @Inject constructor( analytics.logEvent("account_recover", "register" to host, "symbol" to symbol, "success" to true) }) { - Timber.e("Send recover request result: An exception occurred") + Timber.i("Send recover request result: An exception occurred") errorHandler.dispatch(it) analytics.logEvent("account_recover", "register" to host, "symbol" to symbol, "success" to false) }) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessagePresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessagePresenter.kt index 385c12ff7..aec79f9db 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessagePresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessagePresenter.kt @@ -135,12 +135,12 @@ class SendMessagePresenter @Inject constructor( if (selectedRecipientChips.isNotEmpty()) setSelectedRecipients(selectedRecipientChips) showContent(true) } else { - Timber.e("Loading recipients result: Can't find the reporting unit") + Timber.i("Loading recipients result: Can't find the reporting unit") view?.showEmpty(true) } } }, { - Timber.e("Loading recipients result: An exception occurred") + Timber.i("Loading recipients result: An exception occurred") view?.showContent(true) errorHandler.dispatch(it) })) diff --git a/app/src/play/java/io/github/wulkanowy/utils/CrashlyticsUtils.kt b/app/src/play/java/io/github/wulkanowy/utils/CrashlyticsUtils.kt index 5c661f1ae..ef269ec73 100644 --- a/app/src/play/java/io/github/wulkanowy/utils/CrashlyticsUtils.kt +++ b/app/src/play/java/io/github/wulkanowy/utils/CrashlyticsUtils.kt @@ -7,6 +7,9 @@ import com.crashlytics.android.core.CrashlyticsCore import fr.bipi.tressence.crash.CrashlyticsLogExceptionTree import fr.bipi.tressence.crash.CrashlyticsLogTree import io.fabric.sdk.android.Fabric +import io.github.wulkanowy.sdk.exception.FeatureDisabledException +import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException +import java.net.UnknownHostException fun initCrashlytics(context: Context, appInfo: AppInfo) { Fabric.with(Fabric.Builder(context) @@ -21,6 +24,13 @@ fun initCrashlytics(context: Context, appInfo: AppInfo) { .build()) } -class CrashlyticsTree : CrashlyticsLogTree(Log.VERBOSE) +class CrashlyticsTree : CrashlyticsLogTree(Log.VERBOSE) { + + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { + if (t is FeatureDisabledException || t is FeatureNotAvailableException || t is UnknownHostException) return + + super.log(priority, tag, message, t) + } +} class CrashlyticsExceptionTree : CrashlyticsLogExceptionTree()