diff --git a/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/BankingPersistenceJson.kt b/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/BankingPersistenceJson.kt index 31265b83..111d4086 100644 --- a/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/BankingPersistenceJson.kt +++ b/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/BankingPersistenceJson.kt @@ -1,16 +1,17 @@ package net.dankito.banking.persistence +import net.dankito.utils.multiplatform.File import net.dankito.banking.ui.model.Customer import net.dankito.banking.ui.model.AccountTransaction import net.dankito.banking.ui.model.BankAccount import net.dankito.banking.util.ISerializer -import net.dankito.banking.util.JacksonJsonSerializer -import java.io.File +import java.io.FileOutputStream +import java.net.URL open class BankingPersistenceJson( protected val jsonFile: File, - protected val serializer: ISerializer = JacksonJsonSerializer() + protected val serializer: ISerializer ) : IBankingPersistence { @@ -28,7 +29,7 @@ open class BankingPersistenceJson( } override fun readPersistedAccounts(): List { - return serializer.deserializeListOr(jsonFile, Customer::class.java, listOf()) + return serializer.deserializeListOr(jsonFile, Customer::class, listOf()) } @@ -36,4 +37,13 @@ open class BankingPersistenceJson( // done when called saveOrUpdateAccount() } + + override fun saveUrlToFile(url: String, file: File) { + URL(url).openConnection().getInputStream().buffered().use { iconInputStream -> + FileOutputStream(file).use { fileOutputStream -> + iconInputStream.copyTo(fileOutputStream) + } + } + } + } \ No newline at end of file diff --git a/ui/BankingAndroidApp/build.gradle b/ui/BankingAndroidApp/build.gradle index 15f1a1c7..1ff8feca 100644 --- a/ui/BankingAndroidApp/build.gradle +++ b/ui/BankingAndroidApp/build.gradle @@ -78,9 +78,7 @@ android { } dependencies { - implementation project(":fints4k"), { - exclude group: "com.soywiz.korlibs.klock", module: "klock-android" // klock-jvm already adds required extensions, to avoid duplicates - } + implementation project(":fints4k") implementation project(':BankingUiCommon') diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt index db6ae8d6..b148da0b 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt @@ -4,9 +4,9 @@ import android.content.Context import androidx.appcompat.app.AppCompatActivity import dagger.Module import dagger.Provides +import net.dankito.utils.multiplatform.File import net.dankito.banking.ui.android.RouterAndroid import net.dankito.banking.ui.android.util.CurrentActivityTracker -import net.dankito.banking.ui.android.util.Base64ServiceAndroid import net.dankito.banking.fints4kBankingClientCreator import net.dankito.banking.persistence.IBankingPersistence import net.dankito.banking.persistence.LuceneBankingPersistence @@ -17,6 +17,7 @@ import net.dankito.banking.ui.IRouter import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.bankfinder.IBankFinder import net.dankito.banking.bankfinder.LuceneBankFinder +import net.dankito.utils.multiplatform.toFile import net.dankito.banking.util.* import net.dankito.banking.util.extraction.IInvoiceDataExtractor import net.dankito.banking.util.extraction.ITextExtractorRegistry @@ -28,7 +29,6 @@ import net.dankito.text.extraction.pdf.iText2PdfTextExtractor import net.dankito.utils.ThreadPool import net.dankito.utils.web.client.IWebClient import net.dankito.utils.web.client.OkHttpWebClient -import java.io.File import javax.inject.Named import javax.inject.Singleton @@ -59,7 +59,7 @@ class BankingModule(private val applicationContext: Context) { @Singleton @Named(DataFolderKey) fun provideDataFolder(applicationContext: Context) : File { - return ensureFolderExists(applicationContext.filesDir, "data") + return ensureFolderExists(applicationContext.filesDir.toFile(), "data") } @Provides @@ -93,7 +93,7 @@ class BankingModule(private val applicationContext: Context) { textExtractorRegistry: ITextExtractorRegistry, router: IRouter, invoiceDataExtractor: IInvoiceDataExtractor, serializer: ISerializer, asyncRunner: IAsyncRunner) : BankingPresenter { return BankingPresenter(bankingClientCreator, bankFinder, dataFolder, persister, - remitteeSearcher, bankIconFinder, textExtractorRegistry, router, invoiceDataExtractor, serializer, asyncRunner) + router, remitteeSearcher, bankIconFinder, textExtractorRegistry, invoiceDataExtractor, serializer, asyncRunner) } @Provides @@ -110,8 +110,8 @@ class BankingModule(private val applicationContext: Context) { @Provides @Singleton - fun provideBankingClientCreator() : IBankingClientCreator { - return fints4kBankingClientCreator() + fun provideBankingClientCreator(serializer: ISerializer) : IBankingClientCreator { + return fints4kBankingClientCreator(serializer) } @Provides diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt index e1024ae6..707a96df 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt @@ -24,7 +24,6 @@ import net.dankito.banking.ui.android.extensions.closePopupOnBackButtonPress import net.dankito.banking.ui.android.listener.ListItemSelectedListener import net.dankito.banking.ui.android.util.StandardAutocompleteCallback import net.dankito.banking.ui.android.util.StandardTextWatcher -import net.dankito.banking.search.IRemitteeSearcher import net.dankito.banking.search.Remittee import net.dankito.banking.ui.model.BankAccount import net.dankito.banking.ui.model.parameters.TransferMoneyData @@ -32,6 +31,7 @@ import net.dankito.banking.ui.model.responses.BankingClientResponse import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.util.InputValidator import net.dankito.banking.bankfinder.BankInfo +import net.dankito.utils.multiplatform.toBigDecimal import net.dankito.utils.android.extensions.asActivity import java.math.BigDecimal import java.text.DecimalFormatSymbols @@ -242,7 +242,7 @@ open class TransferMoneyDialog : DialogFragment() { inputValidator.convertToAllowedSepaCharacters(edtxtRemitteeName.text.toString()), edtxtRemitteeIban.text.toString().replace(" ", ""), edtxtRemitteeBic.text.toString().replace(" ", ""), - amount, + amount.toBigDecimal(), inputValidator.convertToAllowedSepaCharacters(edtxtUsage.text.toString()), chkbxInstantPayment.isChecked ) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/util/Base64ServiceAndroid.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/util/Base64ServiceAndroid.kt deleted file mode 100644 index 58f7e38a..00000000 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/util/Base64ServiceAndroid.kt +++ /dev/null @@ -1,22 +0,0 @@ -package net.dankito.banking.ui.android.util - -import android.util.Base64 -import net.dankito.banking.util.IBase64Service -import java.nio.charset.Charset - - -open class Base64ServiceAndroid : IBase64Service { - - override fun encode(text: String, charset: Charset): String { - val bytes = text.toByteArray(charset) - - return Base64.encodeToString(bytes, Base64.NO_WRAP) - } - - override fun decode(base64: String, charset: Charset): String { - val decoded = Base64.decode(base64, Base64.NO_WRAP) - - return String(decoded, charset) - } - -} \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/MainActivityFloatingActionMenuButton.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/MainActivityFloatingActionMenuButton.kt index f01d087d..02f56293 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/MainActivityFloatingActionMenuButton.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/MainActivityFloatingActionMenuButton.kt @@ -7,6 +7,7 @@ import androidx.fragment.app.FragmentActivity import com.github.clans.fab.FloatingActionButton import com.github.clans.fab.FloatingActionMenu import kotlinx.android.synthetic.main.view_floating_action_button_main.view.* +import net.dankito.utils.multiplatform.toFile import net.dankito.banking.ui.android.R import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPdfResult import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPdfResultType @@ -78,7 +79,7 @@ open class MainActivityFloatingActionMenuButton( selectedFile?.let { lastSelectedFolder = selectedFile.parentFile - val result = presenter.transferMoneyWithDataFromPdf(selectedFile) + val result = presenter.transferMoneyWithDataFromPdf(selectedFile.toFile()) if (result.type != ExtractTransferMoneyDataFromPdfResultType.Success) { showTransferMoneyWithDataFromPdfError(activity, selectedFile, result) diff --git a/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt b/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt index 5c5d3819..60066a33 100755 --- a/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt +++ b/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt @@ -1,17 +1,18 @@ package net.dankito.banking.ui.javafx.dialogs.mainwindow import javafx.scene.control.SplitPane +import net.dankito.utils.multiplatform.File import net.dankito.banking.fints4kBankingClientCreator import net.dankito.banking.ui.javafx.RouterJavaFx import net.dankito.banking.ui.javafx.controls.AccountTransactionsView import net.dankito.banking.ui.javafx.controls.AccountsView import net.dankito.banking.ui.javafx.dialogs.mainwindow.controls.MainMenuBar -import net.dankito.banking.ui.javafx.util.Base64ServiceJava8 import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.util.BankIconFinder import net.dankito.banking.bankfinder.LuceneBankFinder import net.dankito.banking.persistence.LuceneBankingPersistence import net.dankito.banking.search.LuceneRemitteeSearcher +import net.dankito.banking.util.JacksonJsonSerializer import net.dankito.banking.util.extraction.JavaTextExtractorRegistry import net.dankito.text.extraction.TextExtractorRegistry import net.dankito.text.extraction.TikaTextExtractor @@ -19,10 +20,8 @@ import net.dankito.text.extraction.image.Tesseract4CommandlineImageTextExtractor import net.dankito.text.extraction.image.model.OcrLanguage import net.dankito.text.extraction.image.model.TesseractConfig import net.dankito.text.extraction.pdf.* -import net.dankito.utils.web.client.OkHttpWebClient import tornadofx.* import tornadofx.FX.Companion.messages -import java.io.File class MainWindow : View(messages["application.title"]) { @@ -33,6 +32,8 @@ class MainWindow : View(messages["application.title"]) { private val indexFolder = ensureFolderExists(dataFolder, "index") + private val serializer = JacksonJsonSerializer() + private val tesseractTextExtractor = Tesseract4CommandlineImageTextExtractor(TesseractConfig(listOf(OcrLanguage.English, OcrLanguage.German))) private val textExtractorRegistry = JavaTextExtractorRegistry(TextExtractorRegistry(pdffontsPdfTypeDetector(), listOf( @@ -41,12 +42,12 @@ class MainWindow : View(messages["application.title"]) { tesseractTextExtractor, TikaTextExtractor() ))) - private val presenter = BankingPresenter(fints4kBankingClientCreator(), + private val presenter = BankingPresenter(fints4kBankingClientCreator(serializer), LuceneBankFinder(indexFolder), dataFolder, LuceneBankingPersistence(indexFolder, databaseFolder), - LuceneRemitteeSearcher(indexFolder), BankIconFinder(), textExtractorRegistry, RouterJavaFx()) + RouterJavaFx(), LuceneRemitteeSearcher(indexFolder), BankIconFinder(), textExtractorRegistry) // private val presenter = BankingPresenter(hbci4jBankingClientCreator(), LuceneBankFinder(indexFolder), -// dataFolder, LuceneBankingPersistence(indexFolder, databaseFolder), LuceneRemitteeSearcher(indexFolder), -// BankIconFinder(), textExtractorRegistry, RouterJavaFx()) +// dataFolder, LuceneBankingPersistence(indexFolder, databaseFolder), RouterJavaFx(), LuceneRemitteeSearcher(indexFolder), +// BankIconFinder(), textExtractorRegistry) diff --git a/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/controls/MainMenuBar.kt b/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/controls/MainMenuBar.kt index 282b99aa..27dc1c9e 100644 --- a/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/controls/MainMenuBar.kt +++ b/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/controls/MainMenuBar.kt @@ -5,6 +5,7 @@ import javafx.scene.input.KeyCode import javafx.scene.input.KeyCodeCombination import javafx.scene.input.KeyCombination import javafx.stage.FileChooser +import net.dankito.utils.multiplatform.toFile import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPdfResult import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPdfResultType import net.dankito.banking.ui.presenter.BankingPresenter @@ -79,7 +80,7 @@ open class MainMenuBar(protected val presenter: BankingPresenter) : View() { fileChooser.showOpenDialog(currentStage)?.let { pdfFile -> lastSelectedFolder = pdfFile.parentFile - val result = presenter.transferMoneyWithDataFromPdf(pdfFile) + val result = presenter.transferMoneyWithDataFromPdf(pdfFile.toFile()) if (result.type != ExtractTransferMoneyDataFromPdfResultType.Success) { showTransferMoneyWithDataFromPdfError(pdfFile, result) diff --git a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/cashtransfer/TransferMoneyDialog.kt b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/cashtransfer/TransferMoneyDialog.kt index fe27881e..76b653b9 100644 --- a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/cashtransfer/TransferMoneyDialog.kt +++ b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/cashtransfer/TransferMoneyDialog.kt @@ -19,6 +19,7 @@ import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.util.InputValidator import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.search.Remittee +import net.dankito.utils.multiplatform.toBigDecimal import net.dankito.banking.ui.javafx.extensions.focusNextControl import net.dankito.utils.javafx.ui.controls.AutoCompletionSearchTextField import net.dankito.utils.javafx.ui.controls.autocompletionsearchtextfield @@ -352,7 +353,7 @@ open class TransferMoneyDialog @JvmOverloads constructor( inputValidator.convertToAllowedSepaCharacters(remitteeName.value), remitteeIban.value.replace(" ", ""), remitteeBic.value.replace(" ", ""), - amount.value.toBigDecimal(), + amount.value.toBigDecimal().toBigDecimal(), inputValidator.convertToAllowedSepaCharacters(usage.value), instantPayment.value ) diff --git a/ui/BankingUiCommon/build.gradle b/ui/BankingUiCommon/build.gradle index 8dd3dd36..3b6ab6f2 100644 --- a/ui/BankingUiCommon/build.gradle +++ b/ui/BankingUiCommon/build.gradle @@ -1,41 +1,165 @@ -apply plugin: 'java-library' -apply plugin: 'kotlin' +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "com.android.library" + id "maven-publish" +} ext.artifactName = "banking-ui-common" -sourceCompatibility = "1.7" -targetCompatibility = "1.7" +kotlin { + jvm { + compilations.main.kotlinOptions { + jvmTarget = "1.6" + } + } -compileKotlin { - kotlinOptions.jvmTarget = "1.6" -} -compileTestKotlin { - kotlinOptions.jvmTarget = "1.6" + targets { + // Select iOS target for real device or emulator. + final def iOSIsRealDevice = System.getenv('SDK_NAME')?.startsWith("iphoneos") + final def iOSTarget = iOSIsRealDevice ? presets.iosArm64 : presets.iosX64 + + // iOS target. + fromPreset(iOSTarget, 'ios') { + binaries { + framework { + baseName = "BankingUiCommon" + } + } + } + } + + + sourceSets { + commonMain { + dependencies { + api kotlin("stdlib-common") + api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlinCoroutinesVersion" + + // TODO: try to get rid of this import + api project(":fints4k") + + api project(":BankFinder") + } + } + + commonTest { + dependencies { + implementation kotlin("test-common") + implementation kotlin("test-annotations-common") + + implementation "ch.tutteli.atrium:atrium-fluent-en_GB:$atriumVersion" + } + } + + + jvmMain { + dependencies { + api "net.dankito.utils:java-utils:$javaUtilsVersion" + + api "net.dankito.text.extraction:text-extractor-common:$textExtractorVersion" + api "net.dankito.text.extraction:text-info-extractor:$textInfoExtractorVersion" + + implementation "net.dankito.utils:favicon-finder:1.0.0-SNAPSHOT" + + implementation "org.jsoup:jsoup:1.13.1" + } + } + + jvmTest { + dependencies { + implementation kotlin("test-junit") + + implementation "junit:junit:$junitVersion" +// implementation "org.junit.jupiter:junit-jupiter:$junit5Version" +// runtimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" + + implementation "org.assertj:assertj-core:$assertJVersion" + implementation "org.mockito:mockito-core:$mockitoVersion" + + implementation "ch.tutteli.atrium:atrium-api-fluent-en_GB-jdk8:$atriumVersion" + + implementation "org.slf4j:slf4j-simple:$slf4jVersion" + } + + } + + + iosMain { + dependencies { + api "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion" + api "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$kotlinCoroutinesVersion" + } + } + + } } -dependencies { - api "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" +// Task to generate iOS framework for xcode projects. +task packForXCode(type: Sync) { - api "net.dankito.utils:java-utils:$javaUtilsVersion" + final File frameworkDir = new File(buildDir, "xcode-frameworks") + final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG' - api project(":BankFinder") + final def framework = kotlin.targets.ios.binaries.getFramework("", mode) - api "net.dankito.text.extraction:text-extractor-common:$textExtractorVersion" - api "net.dankito.text.extraction:text-info-extractor:$textInfoExtractorVersion" + inputs.property "mode", mode + dependsOn framework.linkTask - implementation "net.dankito.utils:favicon-finder:1.0.0-SNAPSHOT" + from { framework.outputFile.parentFile } + into frameworkDir - implementation "org.jsoup:jsoup:1.13.1" + doLast { + new File(frameworkDir, 'gradlew').with { + text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n" + setExecutable(true) + } + } +} - // TODO: try to get rid of this import - api project(':fints4k') +// Run packForXCode when building. +tasks.build.dependsOn packForXCode - testImplementation "junit:junit:$junitVersion" - testImplementation "org.assertj:assertj-core:$assertJVersion" +android { + compileSdkVersion androidCompileSdkVersion + + + defaultConfig { + minSdkVersion androidMinSdkVersion + targetSdkVersion androidTargetSdkVersion + + versionName version + versionCode appVersionCode + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + packagingOptions { + pickFirst 'META-INF/ktor-http.kotlin_module' + pickFirst 'META-INF/kotlinx-io.kotlin_module' + pickFirst 'META-INF/atomicfu.kotlin_module' + pickFirst 'META-INF/ktor-utils.kotlin_module' + pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module' + pickFirst 'META-INF/ktor-client-core.kotlin_module' + pickFirst 'META-INF/DEPENDENCIES' + pickFirst 'META-INF/NOTICE' + pickFirst 'META-INF/LICENSE' + pickFirst 'META-INF/LICENSE.txt' + pickFirst 'META-INF/NOTICE.txt' + } + + lintOptions { + abortOnError false + } - testImplementation "org.slf4j:slf4j-simple:$slf4jVersion" } \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/persistence/IBankingPersistence.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/persistence/IBankingPersistence.kt similarity index 85% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/persistence/IBankingPersistence.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/persistence/IBankingPersistence.kt index f91ae7fc..b51b2e33 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/persistence/IBankingPersistence.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/persistence/IBankingPersistence.kt @@ -1,5 +1,6 @@ package net.dankito.banking.persistence +import net.dankito.utils.multiplatform.File import net.dankito.banking.ui.model.Customer import net.dankito.banking.ui.model.AccountTransaction import net.dankito.banking.ui.model.BankAccount @@ -16,4 +17,6 @@ interface IBankingPersistence { fun saveOrUpdateAccountTransactions(bankAccount: BankAccount, transactions: List) + fun saveUrlToFile(url: String, file: File) + } \ No newline at end of file diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/persistence/NoOpBankingPersistence.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/persistence/NoOpBankingPersistence.kt new file mode 100644 index 00000000..c607a575 --- /dev/null +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/persistence/NoOpBankingPersistence.kt @@ -0,0 +1,33 @@ +package net.dankito.banking.persistence + +import net.dankito.banking.ui.model.AccountTransaction +import net.dankito.banking.ui.model.BankAccount +import net.dankito.banking.ui.model.Customer +import net.dankito.utils.multiplatform.File + + +open class NoOpBankingPersistence : IBankingPersistence { + + override fun saveOrUpdateAccount(customer: Customer, allCustomers: List) { + + } + + override fun deleteAccount(customer: Customer, allCustomers: List) { + + } + + override fun readPersistedAccounts(): List { + return listOf() + } + + + override fun saveOrUpdateAccountTransactions(bankAccount: BankAccount, transactions: List) { + + } + + + override fun saveUrlToFile(url: String, file: File) { + + } + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/search/IRemitteeSearcher.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/search/IRemitteeSearcher.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/search/IRemitteeSearcher.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/search/IRemitteeSearcher.kt diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/search/NoOpRemitteeSearcher.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/search/NoOpRemitteeSearcher.kt new file mode 100644 index 00000000..b3f9b7c2 --- /dev/null +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/search/NoOpRemitteeSearcher.kt @@ -0,0 +1,10 @@ +package net.dankito.banking.search + + +open class NoOpRemitteeSearcher : IRemitteeSearcher { + + override fun findRemittees(query: String): List { + return listOf() + } + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/search/Remittee.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/search/Remittee.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/search/Remittee.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/search/Remittee.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/BankingClientCallback.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/BankingClientCallback.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/BankingClientCallback.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/BankingClientCallback.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClient.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/IBankingClient.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClient.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/IBankingClient.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClientCreator.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/IBankingClientCreator.kt similarity index 90% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClientCreator.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/IBankingClientCreator.kt index f2497c05..17a3d47c 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClientCreator.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/IBankingClientCreator.kt @@ -1,8 +1,8 @@ package net.dankito.banking.ui +import net.dankito.utils.multiplatform.File import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.util.IAsyncRunner -import java.io.File interface IBankingClientCreator { diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IRouter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/IRouter.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IRouter.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/IRouter.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/AccountTransaction.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt similarity index 83% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/AccountTransaction.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt index 387403b5..555e25de 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/AccountTransaction.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt @@ -1,14 +1,14 @@ package net.dankito.banking.ui.model -import com.fasterxml.jackson.annotation.JsonIdentityInfo -import com.fasterxml.jackson.annotation.ObjectIdGenerators -import java.math.BigDecimal -import java.text.DateFormat -import java.text.SimpleDateFormat -import java.util.* +//import com.fasterxml.jackson.annotation.JsonIdentityInfo +//import com.fasterxml.jackson.annotation.ObjectIdGenerators +import net.dankito.utils.multiplatform.BigDecimal +import net.dankito.utils.multiplatform.Date +import net.dankito.utils.multiplatform.DateFormatStyle +import net.dankito.utils.multiplatform.DateFormatter -@JsonIdentityInfo(property = "id", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references +//@JsonIdentityInfo(property = "id", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references open class AccountTransaction( open val bankAccount: BankAccount, open val amount: BigDecimal, @@ -50,7 +50,7 @@ open class AccountTransaction( ) { companion object { - val IdDateFormat = SimpleDateFormat("yyyy.MM.dd") + val IdDateFormat = DateFormatter("yyyy.MM.dd") } @@ -62,7 +62,7 @@ open class AccountTransaction( 0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "", "", null, null, "", null) // for object deserializers - internal constructor() : this(BankAccount(), BigDecimal.ZERO, "","", Date(), null, null, null, null, Date(), 0, null, BigDecimal.ZERO, BigDecimal.ZERO, + internal constructor() : this(BankAccount(), BigDecimal.Zero, "","", Date(), null, null, null, null, Date(), 0, null, BigDecimal.Zero, BigDecimal.Zero, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "", "", null, null, "", null) @@ -79,7 +79,7 @@ open class AccountTransaction( if (other !is AccountTransaction) return false if (bankAccount != other.bankAccount) return false - if (amount.compareTo(other.amount) != 0) return false + if (amount != other) return false // TODO: does this work? if (currency != other.currency) return false if (unparsedUsage != other.unparsedUsage) return false if (bookingDate != other.bookingDate) return false @@ -108,7 +108,7 @@ open class AccountTransaction( override fun toString(): String { - return "${DateFormat.getDateInstance(DateFormat.MEDIUM).format(valueDate)} $amount $otherPartyName: $usage" + return "${DateFormatter(DateFormatStyle.Medium).format(valueDate)} $amount $otherPartyName: $usage" } } \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt similarity index 80% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt index c03e5ffb..560065ac 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt @@ -1,12 +1,14 @@ package net.dankito.banking.ui.model -import com.fasterxml.jackson.annotation.JsonIdentityInfo -import com.fasterxml.jackson.annotation.ObjectIdGenerators -import java.math.BigDecimal -import java.util.* +//import com.fasterxml.jackson.annotation.JsonIdentityInfo +//import com.fasterxml.jackson.annotation.ObjectIdGenerators +import net.dankito.utils.multiplatform.BigDecimal +import net.dankito.utils.multiplatform.Date +import net.dankito.utils.multiplatform.UUID +import kotlin.jvm.JvmOverloads -@JsonIdentityInfo(property = "id", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references +//@JsonIdentityInfo(property = "id", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references open class BankAccount @JvmOverloads constructor( open val customer: Customer, open val identifier: String, @@ -14,7 +16,7 @@ open class BankAccount @JvmOverloads constructor( open var iban: String?, open var subAccountNumber: String?, open val customerId: String, - open var balance: BigDecimal = BigDecimal.ZERO, + open var balance: BigDecimal = BigDecimal.Zero, open var currency: String = "EUR", open var type: BankAccountType = BankAccountType.Girokonto, open val productName: String? = null, @@ -30,7 +32,7 @@ open class BankAccount @JvmOverloads constructor( internal constructor() : this(Customer(), "", "", null, null, "") // for object deserializers - open var id: String = UUID.randomUUID().toString() + open var id: String = UUID.random() open val displayName: String diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccountType.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccountType.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccountType.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccountType.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/Customer.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/Customer.kt similarity index 70% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/Customer.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/Customer.kt index 0bd4948e..d77a96fb 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/Customer.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/Customer.kt @@ -1,15 +1,16 @@ package net.dankito.banking.ui.model -import com.fasterxml.jackson.annotation.JsonIdentityInfo -import com.fasterxml.jackson.annotation.ObjectIdGenerators +//import com.fasterxml.jackson.annotation.JsonIdentityInfo +//import com.fasterxml.jackson.annotation.ObjectIdGenerators +import net.dankito.utils.multiplatform.BigDecimal +import net.dankito.utils.multiplatform.UUID +import net.dankito.utils.multiplatform.sum import net.dankito.banking.ui.model.tan.TanMedium import net.dankito.banking.ui.model.tan.TanMediumStatus import net.dankito.banking.ui.model.tan.TanProcedure -import java.math.BigDecimal -import java.util.* -@JsonIdentityInfo(property = "id", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references +//@JsonIdentityInfo(property = "id", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references open class Customer( val bankCode: String, val customerId: String, @@ -27,7 +28,7 @@ open class Customer( internal constructor() : this("", "", "", "", "", "", "") // for object deserializers - var id: String = UUID.randomUUID().toString() + var id: String = UUID.random() var supportedTanProcedures: List = listOf() @@ -44,7 +45,7 @@ open class Customer( get() = bankName val balance: BigDecimal - get() = accounts.map { it.balance }.fold(BigDecimal.ZERO) { acc, e -> acc + e } + get() = accounts.map { it.balance }.sum() val transactions: List get() = accounts.flatMap { it.bookedTransactions } diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/MessageLogEntry.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntry.kt similarity index 82% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/MessageLogEntry.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntry.kt index 89bbd60d..ff5050d6 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/MessageLogEntry.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntry.kt @@ -1,6 +1,6 @@ package net.dankito.banking.ui.model -import java.util.* +import net.dankito.utils.multiplatform.Date open class MessageLogEntry( diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/SelectedAccountType.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/SelectedAccountType.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/SelectedAccountType.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/SelectedAccountType.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/moneytransfer/ExtractTransferMoneyDataFromPdfResult.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/moneytransfer/ExtractTransferMoneyDataFromPdfResult.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/moneytransfer/ExtractTransferMoneyDataFromPdfResult.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/moneytransfer/ExtractTransferMoneyDataFromPdfResult.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/moneytransfer/ExtractTransferMoneyDataFromPdfResultType.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/moneytransfer/ExtractTransferMoneyDataFromPdfResultType.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/moneytransfer/ExtractTransferMoneyDataFromPdfResultType.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/moneytransfer/ExtractTransferMoneyDataFromPdfResultType.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/parameters/GetTransactionsParameter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/parameters/GetTransactionsParameter.kt similarity index 90% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/parameters/GetTransactionsParameter.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/parameters/GetTransactionsParameter.kt index 3e00671f..222c7733 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/parameters/GetTransactionsParameter.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/parameters/GetTransactionsParameter.kt @@ -1,7 +1,7 @@ package net.dankito.banking.ui.model.parameters +import net.dankito.utils.multiplatform.Date import net.dankito.banking.ui.model.AccountTransaction -import java.util.* open class GetTransactionsParameter( diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/parameters/TransferMoneyData.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/parameters/TransferMoneyData.kt similarity index 89% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/parameters/TransferMoneyData.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/parameters/TransferMoneyData.kt index aa627fbd..9280cc35 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/parameters/TransferMoneyData.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/parameters/TransferMoneyData.kt @@ -1,7 +1,7 @@ package net.dankito.banking.ui.model.parameters +import net.dankito.utils.multiplatform.BigDecimal import net.dankito.banking.ui.model.AccountTransaction -import java.math.BigDecimal open class TransferMoneyData( @@ -20,7 +20,7 @@ open class TransferMoneyData( transaction.otherPartyName ?: "", transaction.otherPartyAccountId ?: "", transaction.otherPartyBankCode ?: "", - BigDecimal.ZERO, + BigDecimal.Zero, "" ) } diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/responses/AddAccountResponse.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/AddAccountResponse.kt similarity index 94% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/responses/AddAccountResponse.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/AddAccountResponse.kt index 2cf18520..6aa5855a 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/responses/AddAccountResponse.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/AddAccountResponse.kt @@ -1,9 +1,9 @@ package net.dankito.banking.ui.model.responses +import net.dankito.utils.multiplatform.BigDecimal import net.dankito.banking.ui.model.Customer import net.dankito.banking.ui.model.AccountTransaction import net.dankito.banking.ui.model.BankAccount -import java.math.BigDecimal open class AddAccountResponse( diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/responses/BankingClientResponse.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/BankingClientResponse.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/responses/BankingClientResponse.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/BankingClientResponse.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt similarity index 92% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt index fd08ceea..7d1980d9 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt @@ -1,8 +1,8 @@ package net.dankito.banking.ui.model.responses +import net.dankito.utils.multiplatform.BigDecimal import net.dankito.banking.ui.model.AccountTransaction import net.dankito.banking.ui.model.BankAccount -import java.math.BigDecimal open class GetTransactionsResponse( diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/settings/AppSettings.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/AppSettings.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/settings/AppSettings.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/AppSettings.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/settings/ITanView.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/ITanView.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/settings/ITanView.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/ITanView.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/settings/TanProcedureSettings.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/TanProcedureSettings.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/settings/TanProcedureSettings.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/TanProcedureSettings.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/EnterTanGeneratorAtcResult.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/EnterTanGeneratorAtcResult.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/EnterTanGeneratorAtcResult.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/EnterTanGeneratorAtcResult.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/EnterTanResult.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/EnterTanResult.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/EnterTanResult.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/EnterTanResult.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/FlickerCode.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/FlickerCode.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/FlickerCode.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/FlickerCode.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/FlickerCodeTanChallenge.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/FlickerCodeTanChallenge.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/FlickerCodeTanChallenge.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/FlickerCodeTanChallenge.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/ImageTanChallenge.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/ImageTanChallenge.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/ImageTanChallenge.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/ImageTanChallenge.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/MobilePhoneTanMedium.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/MobilePhoneTanMedium.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/MobilePhoneTanMedium.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/MobilePhoneTanMedium.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanChallenge.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanChallenge.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanChallenge.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanChallenge.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanGeneratorTanMedium.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanGeneratorTanMedium.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanGeneratorTanMedium.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanGeneratorTanMedium.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanImage.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanImage.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanImage.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanImage.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanMedium.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanMedium.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanMedium.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanMedium.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanMediumStatus.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanMediumStatus.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanMediumStatus.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanMediumStatus.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanProcedure.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanProcedure.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanProcedure.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanProcedure.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanProcedureType.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanProcedureType.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/tan/TanProcedureType.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanProcedureType.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt similarity index 92% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt index 964d53b8..927de65d 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -17,6 +17,7 @@ import net.dankito.banking.ui.model.tan.TanGeneratorTanMedium import net.dankito.banking.bankfinder.IBankFinder import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.search.IRemitteeSearcher +import net.dankito.banking.search.NoOpRemitteeSearcher import net.dankito.banking.search.Remittee import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPdfResult import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPdfResultType @@ -25,14 +26,10 @@ import net.dankito.banking.ui.model.settings.AppSettings import net.dankito.banking.util.* import net.dankito.banking.util.extraction.IInvoiceDataExtractor import net.dankito.banking.util.extraction.ITextExtractorRegistry -import net.dankito.banking.util.extraction.JavaInvoiceDataExtractor -import org.slf4j.LoggerFactory -import java.io.File -import java.io.FileOutputStream -import java.math.BigDecimal -import java.net.URL -import java.text.SimpleDateFormat -import java.util.* +import net.dankito.banking.util.extraction.NoOpInvoiceDataExtractor +import net.dankito.banking.util.extraction.NoOpTextExtractorRegistry +import net.dankito.utils.multiplatform.* +import net.dankito.utils.multiplatform.log.LoggerFactory import kotlin.collections.ArrayList @@ -41,21 +38,21 @@ open class BankingPresenter( protected val bankFinder: IBankFinder, protected val dataFolder: File, protected val persister: IBankingPersistence, - protected val remitteeSearcher: IRemitteeSearcher, - protected val bankIconFinder: IBankIconFinder, - protected val textExtractorRegistry: ITextExtractorRegistry, protected val router: IRouter, - protected val invoiceDataExtractor: IInvoiceDataExtractor = JavaInvoiceDataExtractor(), - protected val serializer: ISerializer = JacksonJsonSerializer(), + protected val remitteeSearcher: IRemitteeSearcher = NoOpRemitteeSearcher(), + protected val bankIconFinder: IBankIconFinder = NoOpBankIconFinder(), + protected val textExtractorRegistry: ITextExtractorRegistry = NoOpTextExtractorRegistry(), + protected val invoiceDataExtractor: IInvoiceDataExtractor = NoOpInvoiceDataExtractor(), + protected val serializer: ISerializer = NoOpSerializer(), protected val asyncRunner: IAsyncRunner = CoroutinesAsyncRunner() ) { companion object { protected const val OneDayMillis = 24 * 60 * 60 * 1000 - protected val MessageLogEntryDateFormat = SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS") + protected val MessageLogEntryDateFormatter = DateFormatter("yyyy.MM.dd HH:mm:ss.SSS") - private val log = LoggerFactory.getLogger(BankingPresenter::class.java) + private val log = LoggerFactory.getLogger(BankingPresenter::class) } @@ -127,7 +124,7 @@ open class BankingPresenter( try { newClient.restoreData() } catch (e: Exception) { - log.error("Could not deserialize customer data of $customer", e) + log.error(e) { "Could not deserialize customer data of $customer" } // TODO: show error message to user } @@ -138,7 +135,7 @@ open class BankingPresenter( selectedAllBankAccounts() // TODO: save last selected bank account(s) } catch (e: Exception) { - log.error("Could not deserialize persisted accounts with persister $persister", e) + log.error(e) { "Could not deserialize persisted accounts with persister $persister" } } } @@ -194,14 +191,14 @@ open class BankingPresenter( bankIconFinder.findIconForBank(customer.bankName)?.let { bankIconUrl -> val bankIconFile = saveBankIconToDisk(customer, bankIconUrl) - customer.iconUrl = "file://" + bankIconFile.absolutePath // without 'file://' Android will not find it + customer.iconUrl = "file://" + bankIconFile.getAbsolutePath() // without 'file://' Android will not find it persistAccount(customer) callAccountsChangedListeners() } } catch (e: Exception) { - log.error("Could not get icon for bank ${customer.bankName}", e) + log.error(e) { "Could not get icon for bank ${customer.bankName}" } } } @@ -212,28 +209,24 @@ open class BankingPresenter( val extension = getIconFileExtension(bankIconUrl) val bankIconFile = File(bankIconsDir, customer.bankCode + if (extension != null) (".$extension") else "") - URL(bankIconUrl).openConnection().getInputStream().buffered().use { iconInputStream -> - FileOutputStream(bankIconFile).use { fileOutputStream -> - iconInputStream.copyTo(fileOutputStream) - } - } + persister.saveUrlToFile(bankIconUrl, bankIconFile) return bankIconFile } protected open fun getIconFileExtension(bankIconUrl: String): String? { try { - var iconFilename = File(bankIconUrl).name + var iconFilename = File(bankIconUrl).filename if (iconFilename.contains('?')) { iconFilename = iconFilename.substring(0, iconFilename.indexOf('?')) } - val extension = File(iconFilename).extension + val extension = File(iconFilename).fileExtension if (extension.isNotBlank()) { return extension } } catch (e: Exception) { - log.info("Could not get icon file extension from url '$bankIconUrl'", e) + log.info(e) { "Could not get icon file extension from url '$bankIconUrl'" } } return null @@ -308,7 +301,7 @@ open class BankingPresenter( } protected open fun updateBankAccountTransactionsAsync(bankAccount: BankAccount, abortIfTanIsRequired: Boolean, callback: (GetTransactionsResponse) -> Unit) { - val fromDate = bankAccount.lastRetrievedTransactionsTimestamp?.let { Date(it.time - OneDayMillis) } // one day before last received transactions + val fromDate = bankAccount.lastRetrievedTransactionsTimestamp?.let { Date(it.millisSinceEpoch - OneDayMillis) } // one day before last received transactions fetchAccountTransactionsAsync(bankAccount, fromDate, abortIfTanIsRequired, callback) } @@ -348,7 +341,7 @@ open class BankingPresenter( } open fun formatAmount(amount: BigDecimal): String { - return String.format("%.02f", amount) + return amount.format("%.02f") } @@ -391,7 +384,7 @@ open class BankingPresenter( val transferMoneyData = TransferMoneyData("", invoiceData.potentialIban ?: "", invoiceData.potentialBic ?: "", - invoiceData.potentialTotalAmount ?: BigDecimal.ZERO, "") + invoiceData.potentialTotalAmount ?: BigDecimal.Zero, "") showTransferMoneyDialog(null, transferMoneyData) } else { @@ -481,7 +474,7 @@ open class BankingPresenter( } return logEntries.map { entry -> - MessageLogEntryDateFormat.format(entry.time) + " " + entry.customer.bankCode + " " + entry.message + MessageLogEntryDateFormatter.format(entry.time) + " " + entry.customer.bankCode + " " + entry.message } } @@ -608,15 +601,15 @@ open class BankingPresenter( protected open fun getAccountTransactionsForBankAccounts(bankAccounts: Collection): List { - return bankAccounts.flatMap { it.bookedTransactions }.sortedByDescending { it.valueDate } // TODO: someday add unbooked transactions + return bankAccounts.flatMap { it.bookedTransactions }.sortedByDescending { it.valueDate.millisSinceEpoch } // TODO: someday add unbooked transactions } protected open fun getBalanceForAccounts(customers: Collection): BigDecimal { - return customers.map { it.balance }.fold(BigDecimal.ZERO) { acc, e -> acc + e } + return customers.map { it.balance }.sum() } protected open fun sumBalance(singleBalances: Collection): BigDecimal { - return singleBalances.fold(BigDecimal.ZERO) { acc, e -> acc + e } + return singleBalances.sum() } @@ -631,17 +624,17 @@ open class BankingPresenter( try { serializer.serializeObject(appSettings, getAppSettingsFile()) } catch (e: Exception) { - log.error("Could not persist AppSettings to file ${getAppSettingsFile()}", e) + log.error(e) { "Could not persist AppSettings to file ${getAppSettingsFile()}" } } } protected open fun readAppSettings() { try { - serializer.deserializeObject(getAppSettingsFile(), AppSettings::class.java)?.let { + serializer.deserializeObject(getAppSettingsFile(), AppSettings::class)?.let { appSettings = it } } catch (e: Exception) { - log.error("Could not read AppSettings from file ${getAppSettingsFile()}", e) + log.error(e) { "Could not read AppSettings from file ${getAppSettingsFile()}" } } } diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/util/FlickerCodeAnimator.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/util/FlickerCodeAnimator.kt new file mode 100644 index 00000000..9b3b01d2 --- /dev/null +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/util/FlickerCodeAnimator.kt @@ -0,0 +1,95 @@ +package net.dankito.banking.ui.util + +import net.dankito.banking.ui.model.tan.FlickerCode +import net.dankito.banking.fints.tan.Bit +import net.dankito.banking.fints.tan.FlickerCanvas +import net.dankito.utils.multiplatform.log.LoggerFactory +import kotlin.jvm.JvmOverloads +import kotlin.jvm.Volatile + + +open class FlickerCodeAnimator { + + companion object { + const val MinFrequency = 2 + const val MaxFrequency = 40 + const val DefaultFrequency = 20 + + private val log = LoggerFactory.getLogger(FlickerCodeAnimator::class) + } + + + protected var currentFrequency: Int = DefaultFrequency + + protected var currentStepIndex = 0 + + @Volatile + protected var isPaused = false + +// protected var calculateAnimationThread: Thread? = null + + + + @JvmOverloads + open fun animateFlickerCode(flickerCode: FlickerCode, frequency: Int = DefaultFrequency, showStep: (Array) -> Unit) { + currentFrequency = frequency + currentStepIndex = 0 + val steps = FlickerCanvas(flickerCode.parsedDataSet).steps + + stop() // stop may still running previous animation + +// calculateAnimationThread = Thread({ calculateAnimation(steps, showStep) }, "CalculateFlickerCodeAnimation") +// +// calculateAnimationThread?.start() + } + +// protected open fun calculateAnimation(steps: List>, showStep: (Array) -> Unit) { +// while (Thread.currentThread().isInterrupted == false) { +// if (isPaused == false) { +// val nextStep = steps[currentStepIndex] +// +// showStep(nextStep) +// +// currentStepIndex++ +// if (currentStepIndex >= steps.size) { +// currentStepIndex = 0 // all steps shown, start again from beginning +// } +// } +// +// try { +// TimeUnit.MILLISECONDS.sleep(1000L / currentFrequency) +// } catch (ignored: Exception) { +// Thread.currentThread().interrupt() +// } +// } +// } + + open fun pause() { + this.isPaused = true + } + + open fun resume() { + this.isPaused = false + } + + open fun stop() { + try { +// if (calculateAnimationThread?.isInterrupted == false) { +// calculateAnimationThread?.interrupt() +// calculateAnimationThread?.join(500) +// +// calculateAnimationThread = null +// } + } catch (e: Exception) { + log.warn(e) { "Could not stop calculateAnimationThread" } + } + } + + + open fun setFrequency(frequency: Int) { + if (frequency in MinFrequency..MaxFrequency) { + currentFrequency = frequency + } + } + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/CoroutinesAsyncRunner.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/CoroutinesAsyncRunner.kt similarity index 59% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/CoroutinesAsyncRunner.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/CoroutinesAsyncRunner.kt index 979465d3..8ccca952 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/CoroutinesAsyncRunner.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/CoroutinesAsyncRunner.kt @@ -1,14 +1,13 @@ package net.dankito.banking.util -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -open class CoroutinesAsyncRunner : IAsyncRunner { +open class CoroutinesAsyncRunner : IAsyncRunner { // TODO: remove (coroutines in common) override fun runAsync(runnable: () -> Unit) { - GlobalScope.launch(Dispatchers.IO) { + GlobalScope.launch { runnable() } } diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/Extensions.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/Extensions.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/Extensions.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/Extensions.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/IAsyncRunner.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/IAsyncRunner.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/IAsyncRunner.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/IAsyncRunner.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/IBankIconFinder.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/IBankIconFinder.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/IBankIconFinder.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/IBankIconFinder.kt diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/ISerializer.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/ISerializer.kt new file mode 100644 index 00000000..311370d3 --- /dev/null +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/ISerializer.kt @@ -0,0 +1,16 @@ +package net.dankito.banking.util + +import net.dankito.utils.multiplatform.File +import kotlin.reflect.KClass + + +interface ISerializer { + + fun serializeObject(obj: Any, outputFile: File) + + fun deserializeObject(serializedObjectFile: File, objectClass: KClass, vararg genericParameterTypes: KClass<*>): T? + + fun deserializeListOr(serializedObjectFile: File, genericListParameterType: KClass, + defaultValue: List = listOf()) : List + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/InputValidator.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/InputValidator.kt similarity index 81% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/InputValidator.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/InputValidator.kt index 76c7da6f..453fdd9f 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/InputValidator.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/InputValidator.kt @@ -2,7 +2,6 @@ package net.dankito.banking.util import net.dankito.banking.fints.messages.segmente.implementierte.sepa.ISepaMessageCreator import net.dankito.banking.fints.messages.segmente.implementierte.sepa.SepaMessageCreator -import java.util.regex.Pattern open class InputValidator { @@ -22,7 +21,7 @@ open class InputValidator { * (https://en.wikipedia.org/wiki/International_Bank_Account_Number#Structure) */ const val IbanPatternString = "[A-Z]{2}\\d{2}[A-Z0-9]{10,30}" - val IbanPattern = Pattern.compile("^" + IbanPatternString + "\$") + val IbanPattern = Regex("^" + IbanPatternString + "\$") /** * The IBAN should not contain spaces when transmitted electronically. When printed it is expressed in groups @@ -30,9 +29,9 @@ open class InputValidator { * (https://en.wikipedia.org/wiki/International_Bank_Account_Number#Structure) */ const val IbanWithSpacesPatternString = "[A-Z]{2}\\d{2}\\s([A-Z0-9]{4}\\s){3}[A-Z0-9\\s]{1,18}" - val IbanWithSpacesPattern = Pattern.compile("^" + IbanWithSpacesPatternString + "\$") + val IbanWithSpacesPattern = Regex("^" + IbanWithSpacesPatternString + "\$") - val InvalidIbanCharactersPattern = Pattern.compile("[^A-Z0-9 ]") + val InvalidIbanCharactersPattern = Regex("[^A-Z0-9 ]") /** @@ -47,12 +46,12 @@ open class InputValidator { * Where an eight digit code is given, it may be assumed that it refers to the primary office. */ const val BicPatternString = "[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}(?:\\b|[A-Z0-9]{03})" - val BicPattern = Pattern.compile("^" + BicPatternString + "$") + val BicPattern = Regex("^" + BicPatternString + "$") - val InvalidBicCharactersPattern = Pattern.compile("[^A-Z0-9]") + val InvalidBicCharactersPattern = Regex("[^A-Z0-9]") - val InvalidSepaCharactersPattern = Pattern.compile("[^${SepaMessageCreator.AllowedSepaCharacters}]+") + val InvalidSepaCharactersPattern = Regex("[^${SepaMessageCreator.AllowedSepaCharacters}]+") } @@ -60,7 +59,7 @@ open class InputValidator { open fun isValidIban(stringToTest: String): Boolean { - return IbanPattern.matcher(stringToTest.replace(" ", "")).matches() + return IbanPattern.matches(stringToTest.replace(" ", "")) } open fun getInvalidIbanCharacters(string: String): String { @@ -69,7 +68,7 @@ open class InputValidator { open fun isValidBic(stringToTest: String): Boolean { - return BicPattern.matcher(stringToTest).matches() + return BicPattern.matches(stringToTest) } open fun getInvalidBicCharacters(string: String): String { @@ -114,16 +113,8 @@ open class InputValidator { } - open fun getInvalidCharacters(string: String, pattern: Pattern): String { - val illegalCharacters = mutableSetOf() - - val matcher = pattern.matcher(string) - - while (matcher.find()) { - illegalCharacters.add(matcher.group()) - } - - return illegalCharacters.joinToString("") + open fun getInvalidCharacters(string: String, pattern: Regex): String { + return pattern.findAll(string).joinToString("") } } \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/NoOpBankIconFinder.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/NoOpBankIconFinder.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/NoOpBankIconFinder.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/NoOpBankIconFinder.kt diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/NoOpSerializer.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/NoOpSerializer.kt new file mode 100644 index 00000000..b0c2bda9 --- /dev/null +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/NoOpSerializer.kt @@ -0,0 +1,21 @@ +package net.dankito.banking.util + +import net.dankito.utils.multiplatform.File +import kotlin.reflect.KClass + + +open class NoOpSerializer : ISerializer { + + override fun serializeObject(obj: Any, outputFile: File) { + + } + + override fun deserializeObject(serializedObjectFile: File, objectClass: KClass, vararg genericParameterTypes: KClass<*>): T? { + return null + } + + override fun deserializeListOr(serializedObjectFile: File, genericListParameterType: KClass, defaultValue: List): List { + return defaultValue + } + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/ExtractionResult.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/ExtractionResult.kt similarity index 89% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/ExtractionResult.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/ExtractionResult.kt index 7f1b4d03..161f0502 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/ExtractionResult.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/ExtractionResult.kt @@ -1,7 +1,5 @@ package net.dankito.banking.util.extraction -import java.lang.Exception - open class ExtractionResult( open val couldExtractText: Boolean, diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/IInvoiceDataExtractor.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/IInvoiceDataExtractor.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/IInvoiceDataExtractor.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/IInvoiceDataExtractor.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/ITextExtractorRegistry.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/ITextExtractorRegistry.kt similarity index 77% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/ITextExtractorRegistry.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/ITextExtractorRegistry.kt index 713478de..ea254aae 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/ITextExtractorRegistry.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/ITextExtractorRegistry.kt @@ -1,6 +1,6 @@ package net.dankito.banking.util.extraction -import java.io.File +import net.dankito.utils.multiplatform.File interface ITextExtractorRegistry { diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/InvoiceData.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/InvoiceData.kt similarity index 84% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/InvoiceData.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/InvoiceData.kt index 5ebd172f..f94ec65b 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/InvoiceData.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/InvoiceData.kt @@ -1,6 +1,6 @@ package net.dankito.banking.util.extraction -import java.math.BigDecimal +import net.dankito.utils.multiplatform.BigDecimal open class InvoiceData( diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/NoOpInvoiceDataExtractor.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/NoOpInvoiceDataExtractor.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/NoOpInvoiceDataExtractor.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/NoOpInvoiceDataExtractor.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/NoOpTextExtractorRegistry.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/NoOpTextExtractorRegistry.kt similarity index 85% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/NoOpTextExtractorRegistry.kt rename to ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/NoOpTextExtractorRegistry.kt index 53be291f..f8993e3e 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/NoOpTextExtractorRegistry.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/util/extraction/NoOpTextExtractorRegistry.kt @@ -1,6 +1,6 @@ package net.dankito.banking.util.extraction -import java.io.File +import net.dankito.utils.multiplatform.File open class NoOpTextExtractorRegistry : ITextExtractorRegistry { diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/BankIconFinder.kt b/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/BankIconFinder.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/BankIconFinder.kt rename to ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/BankIconFinder.kt diff --git a/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/JacksonJsonSerializer.kt b/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/JacksonJsonSerializer.kt new file mode 100644 index 00000000..8f83be81 --- /dev/null +++ b/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/JacksonJsonSerializer.kt @@ -0,0 +1,24 @@ +package net.dankito.banking.util + +import net.dankito.utils.multiplatform.File +import kotlin.reflect.KClass + + +open class JacksonJsonSerializer( + protected val serializer: net.dankito.utils.serialization.ISerializer = net.dankito.utils.serialization.JacksonJsonSerializer() +) : ISerializer { + + override fun serializeObject(obj: Any, outputFile: File) { + return serializer.serializeObject(obj, outputFile) + } + + override fun deserializeObject(serializedObjectFile: File, objectClass: KClass, + vararg genericParameterTypes: KClass<*>): T? { + return serializer.deserializeObject(serializedObjectFile, objectClass.java, *genericParameterTypes.map { it.java }.toTypedArray()) + } + + override fun deserializeListOr(serializedObjectFile: File, genericListParameterType: KClass, defaultValue: List): List { + return serializer.deserializeListOr(serializedObjectFile, genericListParameterType.java, defaultValue) + } + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/ThreadPoolAsyncRunner.kt b/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/ThreadPoolAsyncRunner.kt similarity index 100% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/ThreadPoolAsyncRunner.kt rename to ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/ThreadPoolAsyncRunner.kt diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/JavaInvoiceDataExtractor.kt b/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/extraction/JavaInvoiceDataExtractor.kt similarity index 92% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/JavaInvoiceDataExtractor.kt rename to ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/extraction/JavaInvoiceDataExtractor.kt index 6adda2aa..277f470e 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/JavaInvoiceDataExtractor.kt +++ b/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/extraction/JavaInvoiceDataExtractor.kt @@ -1,5 +1,6 @@ package net.dankito.banking.util.extraction +import net.dankito.utils.multiplatform.toBigDecimal import net.dankito.text.extraction.info.invoice.InvoiceDataExtractor diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/JavaTextExtractorRegistry.kt b/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/extraction/JavaTextExtractorRegistry.kt similarity index 94% rename from ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/JavaTextExtractorRegistry.kt rename to ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/extraction/JavaTextExtractorRegistry.kt index bfbf5a3a..2b07e15b 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/extraction/JavaTextExtractorRegistry.kt +++ b/ui/BankingUiCommon/src/jvmMain/kotlin/net/dankito/banking/util/extraction/JavaTextExtractorRegistry.kt @@ -1,8 +1,8 @@ package net.dankito.banking.util.extraction +import net.dankito.utils.multiplatform.File import net.dankito.text.extraction.TextExtractorRegistry import net.dankito.text.extraction.model.ErrorType -import java.io.File open class JavaTextExtractorRegistry( diff --git a/ui/BankingUiCommon/src/test/kotlin/net/dankito/banking/util/BankIconFinderTest.kt b/ui/BankingUiCommon/src/jvmTest/kotlin/net/dankito/banking/util/BankIconFinderTest.kt similarity index 99% rename from ui/BankingUiCommon/src/test/kotlin/net/dankito/banking/util/BankIconFinderTest.kt rename to ui/BankingUiCommon/src/jvmTest/kotlin/net/dankito/banking/util/BankIconFinderTest.kt index 3c1ef096..fb860961 100644 --- a/ui/BankingUiCommon/src/test/kotlin/net/dankito/banking/util/BankIconFinderTest.kt +++ b/ui/BankingUiCommon/src/jvmTest/kotlin/net/dankito/banking/util/BankIconFinderTest.kt @@ -1,6 +1,5 @@ package net.dankito.banking.util -import net.dankito.banking.bankfinder.InMemoryBankFinder import org.assertj.core.api.Assertions.assertThat import org.junit.Test diff --git a/ui/BankingUiCommon/src/main/AndroidManifest.xml b/ui/BankingUiCommon/src/main/AndroidManifest.xml new file mode 100644 index 00000000..b274b3a1 --- /dev/null +++ b/ui/BankingUiCommon/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/util/FlickerCodeAnimator.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/util/FlickerCodeAnimator.kt deleted file mode 100644 index feb9ae1e..00000000 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/util/FlickerCodeAnimator.kt +++ /dev/null @@ -1,94 +0,0 @@ -package net.dankito.banking.ui.util - -import net.dankito.banking.ui.model.tan.FlickerCode -import net.dankito.banking.fints.tan.Bit -import net.dankito.banking.fints.tan.FlickerCanvas -import org.slf4j.LoggerFactory -import java.util.concurrent.TimeUnit - - -open class FlickerCodeAnimator { // TODO: move to fints44 - - companion object { - const val MinFrequency = 2 - const val MaxFrequency = 40 - const val DefaultFrequency = 20 - - private val log = LoggerFactory.getLogger(FlickerCodeAnimator::class.java) - } - - - protected var currentFrequency: Int = DefaultFrequency - - protected var currentStepIndex = 0 - - @Volatile - protected var isPaused = false - - protected var calculateAnimationThread: Thread? = null - - - - @JvmOverloads - open fun animateFlickerCode(flickerCode: FlickerCode, frequency: Int = DefaultFrequency, showStep: (Array) -> Unit) { - currentFrequency = frequency - currentStepIndex = 0 - val steps = FlickerCanvas(flickerCode.parsedDataSet).steps - - stop() // stop may still running previous animation - - calculateAnimationThread = Thread({ calculateAnimation(steps, showStep) }, "CalculateFlickerCodeAnimation") - - calculateAnimationThread?.start() - } - - protected open fun calculateAnimation(steps: List>, showStep: (Array) -> Unit) { - while (Thread.currentThread().isInterrupted == false) { - if (isPaused == false) { - val nextStep = steps[currentStepIndex] - - showStep(nextStep) - - currentStepIndex++ - if (currentStepIndex >= steps.size) { - currentStepIndex = 0 // all steps shown, start again from beginning - } - } - - try { - TimeUnit.MILLISECONDS.sleep(1000L / currentFrequency) - } catch (ignored: Exception) { - Thread.currentThread().interrupt() - } - } - } - - open fun pause() { - this.isPaused = true - } - - open fun resume() { - this.isPaused = false - } - - open fun stop() { - try { - if (calculateAnimationThread?.isInterrupted == false) { - calculateAnimationThread?.interrupt() - calculateAnimationThread?.join(500) - - calculateAnimationThread = null - } - } catch (e: Exception) { - log.warn("Could not stop calculateAnimationThread", e) - } - } - - - open fun setFrequency(frequency: Int) { - if (frequency in MinFrequency..MaxFrequency) { - currentFrequency = frequency - } - } - -} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/ISerializer.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/ISerializer.kt deleted file mode 100644 index 423982df..00000000 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/ISerializer.kt +++ /dev/null @@ -1,15 +0,0 @@ -package net.dankito.banking.util - -import java.io.File - - -interface ISerializer { - - fun serializeObject(obj: Any, outputFile: File) - - fun deserializeObject(serializedObjectFile: File, objectClass: Class, vararg genericParameterTypes: Class<*>): T? - - fun deserializeListOr(serializedObjectFile: File, genericListParameterType: Class, - defaultValue: List = listOf()) : List - -} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/JacksonJsonSerializer.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/JacksonJsonSerializer.kt deleted file mode 100644 index fa7aa96b..00000000 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/JacksonJsonSerializer.kt +++ /dev/null @@ -1,24 +0,0 @@ -package net.dankito.banking.util - -import net.dankito.utils.serialization.JacksonJsonSerializer -import java.io.File - - -open class JacksonJsonSerializer( - protected val serializer: net.dankito.utils.serialization.ISerializer = JacksonJsonSerializer() -) : ISerializer { - - override fun serializeObject(obj: Any, outputFile: File) { - return serializer.serializeObject(obj, outputFile) - } - - override fun deserializeObject(serializedObjectFile: File, objectClass: Class, - vararg genericParameterTypes: Class<*>): T? { - return serializer.deserializeObject(serializedObjectFile, objectClass, *genericParameterTypes) - } - - override fun deserializeListOr(serializedObjectFile: File, genericListParameterType: Class, defaultValue: List): List { - return serializer.deserializeListOr(serializedObjectFile, genericListParameterType, defaultValue) - } - -} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/NoOpSerializer.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/NoOpSerializer.kt deleted file mode 100644 index 47af3fcf..00000000 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/NoOpSerializer.kt +++ /dev/null @@ -1,20 +0,0 @@ -package net.dankito.banking.util - -import java.io.File - - -open class NoOpSerializer : ISerializer { - - override fun serializeObject(obj: Any, outputFile: File) { - - } - - override fun deserializeObject(serializedObjectFile: File, objectClass: Class, vararg genericParameterTypes: Class<*>): T? { - return null - } - - override fun deserializeListOr(serializedObjectFile: File, genericListParameterType: Class, defaultValue: List): List { - return defaultValue - } - -} \ No newline at end of file diff --git a/ui/fints4kBankingClient/build.gradle b/ui/fints4kBankingClient/build.gradle index fdadc2eb..e1ac3ae0 100644 --- a/ui/fints4kBankingClient/build.gradle +++ b/ui/fints4kBankingClient/build.gradle @@ -34,24 +34,22 @@ kotlin { sourceSets { commonMain { dependencies { - implementation kotlin("stdlib-common") - - implementation project(":BankingUiCommon") - implementation project(":fints4k") + api project(":BankingUiCommon") + api project(":fints4k") } } jvmMain { dependencies { - api kotlin("stdlib-jdk7") + } } iosMain { dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion" + } }