Skip to content

Commit

Permalink
We still need Workaround for 221643630
Browse files Browse the repository at this point in the history
use logger for Banking
workaroung for R8 bug
improve error handling in WebInputService
  • Loading branch information
mtotschnig committed Aug 24, 2023
1 parent ca2d3b5 commit c7df654
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 148 deletions.
4 changes: 3 additions & 1 deletion fints/src/main/java/org/totschnig/fints/Banking.kt
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ class Banking : ProtectedFragmentActivity() {
}

AlertDialog(
//https://issuetracker.google.com/issues/221643630
properties = DialogProperties(
dismissOnClickOutside = false
dismissOnClickOutside = false,
usePlatformDefaultWidth = false
),
onDismissRequest = {
dialogShown.value = null
Expand Down
12 changes: 7 additions & 5 deletions fints/src/main/java/org/totschnig/fints/BankingViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import org.totschnig.myexpenses.db2.loadBanks
import org.totschnig.myexpenses.db2.saveAccountAttributes
import org.totschnig.myexpenses.db2.saveTransactionAttributes
import org.totschnig.myexpenses.db2.updateAccount
import org.totschnig.myexpenses.feature.BankingFeature
import org.totschnig.myexpenses.model.ContribFeature
import org.totschnig.myexpenses.model.Transaction
import org.totschnig.myexpenses.model2.Bank
Expand Down Expand Up @@ -135,7 +136,7 @@ class BankingViewModel(application: Application) : ContentResolvingAndroidViewMo
}

private fun log(msg: String) {
Timber.tag("FinTS").i(msg)
Timber.tag(BankingFeature.TAG).i(msg)
}

private fun error(msg: String) {
Expand Down Expand Up @@ -317,15 +318,15 @@ class BankingViewModel(application: Application) : ContentResolvingAndroidViewMo
val status: HBCIExecStatus = handle.execute()

if (!status.isOK) {
error(status.toString())
_workState.value = WorkState.Done()
return@doHBCI
status.toString()
CrashHandler.report(Exception("Status was not ok"))
}

val result = umsatzJob.jobResult as GVRKUms

if (!result.isOK) {
error(result.toString())
log(result.toString())
_workState.value = WorkState.Done()
return@doHBCI
}
Expand Down Expand Up @@ -425,6 +426,7 @@ class BankingViewModel(application: Application) : ContentResolvingAndroidViewMo

if (!result.isOK) {
error(result.toString())
log(result.toString())
return@doHBCI
}

Expand Down Expand Up @@ -486,7 +488,7 @@ class BankingViewModel(application: Application) : ContentResolvingAndroidViewMo
inner class MyHBCICallback(private val bankingCredentials: BankingCredentials) :
AbstractHBCICallback() {
override fun log(msg: String, level: Int, date: Date, trace: StackTraceElement) {
Timber.tag("FinTS").d(msg)
log(msg)
}

override fun callback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.totschnig.myexpenses.activity.OnboardingActivity;
import org.totschnig.myexpenses.di.AppComponent;
import org.totschnig.myexpenses.di.DaggerAppComponent;
import org.totschnig.myexpenses.feature.BankingFeature;
import org.totschnig.myexpenses.feature.FeatureManager;
import org.totschnig.myexpenses.feature.OcrFeature;
import org.totschnig.myexpenses.model.CurrencyContext;
Expand Down Expand Up @@ -259,6 +260,7 @@ public void setupLogging() {
Timber.plant(new TagFilterFileLoggingTree(this, LicenceHandler.TAG));
Timber.plant(new TagFilterFileLoggingTree(this, BaseTransactionProvider.TAG));
Timber.plant(new TagFilterFileLoggingTree(this, OcrFeature.TAG));
Timber.plant(new TagFilterFileLoggingTree(this, BankingFeature.TAG));
} catch (Exception e) {
CrashHandler.report(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.totschnig.myexpenses.di

import androidx.annotation.Keep
import dagger.Module
import dagger.Provides
import org.totschnig.myexpenses.feature.BankingFeature
Expand All @@ -8,8 +9,17 @@ import org.totschnig.myexpenses.feature.OcrFeature
import org.totschnig.myexpenses.preference.PrefHandler
import org.totschnig.myexpenses.util.distrib.DistributionHelper
import timber.log.Timber
import java.time.LocalDateTime
import java.time.ZoneId
import javax.inject.Singleton

// workaround for https://issuetracker.google.com/issues/297226570
// force R8 to keep toInstant method
@Keep
object Bogus {
fun calculateInstant() = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()
}

@Module
open class FeatureModule {
private var ocrFeature: OcrFeature? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import androidx.fragment.app.FragmentManager
import org.totschnig.myexpenses.db2.FinTsAttribute

interface BankingFeature {
companion object {
const val TAG = "Banking"
}
fun startBankingList(context: Context) {}

fun startSyncFragment(bankId: Long, accountId: Long, fragmentManager: FragmentManager) {}
Expand Down
Loading

0 comments on commit c7df654

Please sign in to comment.