Implemented saving lastSelectedOpenPdfFolder and lastSelectedImportFolder
This commit is contained in:
parent
013c6fa088
commit
8787b2ffd7
|
@ -1,6 +1,10 @@
|
||||||
package net.dankito.utils.multiplatform
|
package net.dankito.utils.multiplatform
|
||||||
|
|
||||||
|
|
||||||
|
fun String?.toFile(): java.io.File? {
|
||||||
|
return this?.let { File(it) }
|
||||||
|
}
|
||||||
|
|
||||||
fun java.util.Date.toDate(): Date {
|
fun java.util.Date.toDate(): Date {
|
||||||
return Date(this.time)
|
return Date(this.time)
|
||||||
}
|
}
|
|
@ -190,7 +190,7 @@ open class RoomBankingPersistence(protected open val applicationContext: Context
|
||||||
|
|
||||||
override fun saveOrUpdateAppSettings(appSettings: AppSettings) {
|
override fun saveOrUpdateAppSettings(appSettings: AppSettings) {
|
||||||
val mapped = net.dankito.banking.persistence.model.AppSettings(appSettings.automaticallyUpdateAccountsAfterMinutes,
|
val mapped = net.dankito.banking.persistence.model.AppSettings(appSettings.automaticallyUpdateAccountsAfterMinutes,
|
||||||
appSettings.lockAppAfterMinutes, appSettings.screenshotsAllowed, appSettings.lastSelectedExportFolder)
|
appSettings.lockAppAfterMinutes, appSettings.screenshotsAllowed, appSettings.lastSelectedOpenPdfFolder, appSettings.lastSelectedImportFolder, appSettings.lastSelectedExportFolder)
|
||||||
database.appSettingsDao().saveOrUpdate(mapped)
|
database.appSettingsDao().saveOrUpdate(mapped)
|
||||||
|
|
||||||
saveOrUpdateTanMethodSettings(appSettings.flickerCodeSettings, FlickerCodeTanMethodSettingsId)
|
saveOrUpdateTanMethodSettings(appSettings.flickerCodeSettings, FlickerCodeTanMethodSettingsId)
|
||||||
|
@ -215,6 +215,8 @@ open class RoomBankingPersistence(protected open val applicationContext: Context
|
||||||
settings.automaticallyUpdateAccountsAfterMinutes = persistedSettings.automaticallyUpdateAccountsAfterMinutes
|
settings.automaticallyUpdateAccountsAfterMinutes = persistedSettings.automaticallyUpdateAccountsAfterMinutes
|
||||||
settings.lockAppAfterMinutes = persistedSettings.lockAppAfterMinutes
|
settings.lockAppAfterMinutes = persistedSettings.lockAppAfterMinutes
|
||||||
settings.screenshotsAllowed = persistedSettings.screenshotsAllowed
|
settings.screenshotsAllowed = persistedSettings.screenshotsAllowed
|
||||||
|
settings.lastSelectedOpenPdfFolder = persistedSettings.lastSelectedOpenPdfFolder
|
||||||
|
settings.lastSelectedImportFolder = persistedSettings.lastSelectedImportFolder
|
||||||
settings.lastSelectedExportFolder = persistedSettings.lastSelectedExportFolder
|
settings.lastSelectedExportFolder = persistedSettings.lastSelectedExportFolder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ open class AppSettings(
|
||||||
open var automaticallyUpdateAccountsAfterMinutes: Int? = AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes,
|
open var automaticallyUpdateAccountsAfterMinutes: Int? = AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes,
|
||||||
open var lockAppAfterMinutes: Int? = null,
|
open var lockAppAfterMinutes: Int? = null,
|
||||||
open var screenshotsAllowed: Boolean = false,
|
open var screenshotsAllowed: Boolean = false,
|
||||||
|
open var lastSelectedOpenPdfFolder: String? = null,
|
||||||
|
open var lastSelectedImportFolder: String? = null,
|
||||||
open var lastSelectedExportFolder: String? = null
|
open var lastSelectedExportFolder: String? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.dankito.banking.ui.model.TypedBankData
|
||||||
import net.dankito.filechooserdialog.FileChooserDialog
|
import net.dankito.filechooserdialog.FileChooserDialog
|
||||||
import net.dankito.filechooserdialog.model.FileChooserDialogConfig
|
import net.dankito.filechooserdialog.model.FileChooserDialogConfig
|
||||||
import net.dankito.utils.android.permissions.IPermissionsService
|
import net.dankito.utils.android.permissions.IPermissionsService
|
||||||
|
import net.dankito.utils.multiplatform.toFile
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -123,7 +124,7 @@ open class SettingsDialog : SettingsDialogBase() {
|
||||||
|
|
||||||
|
|
||||||
protected open fun exportAccountTransactions() {
|
protected open fun exportAccountTransactions() {
|
||||||
val initialDirectory = presenter.appSettings.lastSelectedExportFolder?.let { File(it) }
|
val initialDirectory = presenter.appSettings.lastSelectedExportFolder.toFile()
|
||||||
val suggestedFilename = getExportCsvSuggestedFilename()
|
val suggestedFilename = getExportCsvSuggestedFilename()
|
||||||
|
|
||||||
// val intent = Intent(Intent.ACTION_CREATE_DOCUMENT)
|
// val intent = Intent(Intent.ACTION_CREATE_DOCUMENT)
|
||||||
|
|
|
@ -33,8 +33,6 @@ open class MainActivityFloatingActionMenuButton(
|
||||||
|
|
||||||
protected lateinit var fabTransferMoneyFromPdf: FloatingActionButton
|
protected lateinit var fabTransferMoneyFromPdf: FloatingActionButton
|
||||||
|
|
||||||
protected var lastSelectedFolder: File? = null
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupButtons(floatingActionMenu)
|
setupButtons(floatingActionMenu)
|
||||||
|
@ -98,12 +96,10 @@ open class MainActivityFloatingActionMenuButton(
|
||||||
|
|
||||||
protected open fun showTransferMoneyDialogWithDataFromPdf() {
|
protected open fun showTransferMoneyDialogWithDataFromPdf() {
|
||||||
(floatingActionMenu.context.asActivity() as? FragmentActivity)?.let { activity ->
|
(floatingActionMenu.context.asActivity() as? FragmentActivity)?.let { activity ->
|
||||||
val config = FileChooserDialogConfig(listOf("*.pdf"), lastSelectedFolder)
|
val config = FileChooserDialogConfig(listOf("*.pdf"), presenter.appSettings.lastSelectedOpenPdfFolder.toFile())
|
||||||
|
|
||||||
FileChooserDialog().showOpenSingleFileDialog(activity, permissionsService, config) { _, selectedFile ->
|
FileChooserDialog().showOpenSingleFileDialog(activity, permissionsService, config) { _, selectedFile ->
|
||||||
selectedFile?.let {
|
selectedFile?.let {
|
||||||
lastSelectedFolder = selectedFile.parentFile
|
|
||||||
|
|
||||||
val result = presenter.showTransferMoneyDialogWithDataFromPdf(selectedFile.toFile())
|
val result = presenter.showTransferMoneyDialogWithDataFromPdf(selectedFile.toFile())
|
||||||
|
|
||||||
if (result.type != ExtractTransferMoneyDataFromPdfResultType.Success) {
|
if (result.type != ExtractTransferMoneyDataFromPdfResultType.Success) {
|
||||||
|
|
|
@ -28,8 +28,6 @@ open class MainMenuBar(protected val presenter: BankingPresenter) : View() {
|
||||||
|
|
||||||
protected val areAccountsThatCanTransferMoneyAdded = SimpleBooleanProperty()
|
protected val areAccountsThatCanTransferMoneyAdded = SimpleBooleanProperty()
|
||||||
|
|
||||||
protected var lastSelectedFolder: File? = null
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
presenter.addBanksChangedListener {
|
presenter.addBanksChangedListener {
|
||||||
|
@ -89,12 +87,10 @@ open class MainMenuBar(protected val presenter: BankingPresenter) : View() {
|
||||||
protected open fun showTransferMoneyDialogWithDataFromPdf() {
|
protected open fun showTransferMoneyDialogWithDataFromPdf() {
|
||||||
val fileChooser = FileChooser()
|
val fileChooser = FileChooser()
|
||||||
|
|
||||||
fileChooser.initialDirectory = lastSelectedFolder
|
fileChooser.initialDirectory = presenter.appSettings.lastSelectedOpenPdfFolder.toFile()
|
||||||
fileChooser.extensionFilters.add(FileChooser.ExtensionFilter("PDFs (*.pdf)", "*.pdf"))
|
fileChooser.extensionFilters.add(FileChooser.ExtensionFilter("PDFs (*.pdf)", "*.pdf"))
|
||||||
|
|
||||||
fileChooser.showOpenDialog(currentStage)?.let { pdfFile ->
|
fileChooser.showOpenDialog(currentStage)?.let { pdfFile ->
|
||||||
lastSelectedFolder = pdfFile.parentFile
|
|
||||||
|
|
||||||
val result = presenter.showTransferMoneyDialogWithDataFromPdf(pdfFile.toFile())
|
val result = presenter.showTransferMoneyDialogWithDataFromPdf(pdfFile.toFile())
|
||||||
|
|
||||||
if (result.type != ExtractTransferMoneyDataFromPdfResultType.Success) {
|
if (result.type != ExtractTransferMoneyDataFromPdfResultType.Success) {
|
||||||
|
|
|
@ -10,6 +10,8 @@ open class AppSettings(
|
||||||
open var flickerCodeSettings: TanMethodSettings? = null,
|
open var flickerCodeSettings: TanMethodSettings? = null,
|
||||||
open var qrCodeSettings: TanMethodSettings? = null,
|
open var qrCodeSettings: TanMethodSettings? = null,
|
||||||
open var photoTanSettings: TanMethodSettings? = null,
|
open var photoTanSettings: TanMethodSettings? = null,
|
||||||
|
open var lastSelectedOpenPdfFolder: String? = null, // File is not that easily persistable so modeled it as string
|
||||||
|
open var lastSelectedImportFolder: String? = null, // File is not that easily persistable so modeled it as string
|
||||||
open var lastSelectedExportFolder: String? = null // File is not that easily persistable so modeled it as string
|
open var lastSelectedExportFolder: String? = null // File is not that easily persistable so modeled it as string
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
|
@ -630,6 +630,9 @@ open class BankingPresenter(
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun showTransferMoneyDialogWithDataFromPdf(pdf: File): ExtractTransferMoneyDataFromPdfResult {
|
open fun showTransferMoneyDialogWithDataFromPdf(pdf: File): ExtractTransferMoneyDataFromPdfResult {
|
||||||
|
appSettings.lastSelectedOpenPdfFolder = pdf.parent?.getAbsolutePath()
|
||||||
|
appSettingsChanged()
|
||||||
|
|
||||||
val extractionResult = textExtractorRegistry.extractTextWithBestExtractorForFile(pdf)
|
val extractionResult = textExtractorRegistry.extractTextWithBestExtractorForFile(pdf)
|
||||||
|
|
||||||
if (extractionResult.couldExtractText == false || extractionResult.text == null) {
|
if (extractionResult.couldExtractText == false || extractionResult.text == null) {
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
<entity name="PersistedAppSettings" representedClassName="PersistedAppSettings" syncable="YES" codeGenerationType="class">
|
<entity name="PersistedAppSettings" representedClassName="PersistedAppSettings" syncable="YES" codeGenerationType="class">
|
||||||
<attribute name="automaticallyUpdateAccountsAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="360" usesScalarValueType="NO"/>
|
<attribute name="automaticallyUpdateAccountsAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="360" usesScalarValueType="NO"/>
|
||||||
<attribute name="lastSelectedExportFolder" optional="YES" attributeType="String"/>
|
<attribute name="lastSelectedExportFolder" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="lastSelectedImportFolder" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="lastSelectedOpenPdfFolder" optional="YES" attributeType="String"/>
|
||||||
<attribute name="lockAppAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="-1" usesScalarValueType="NO"/>
|
<attribute name="lockAppAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="-1" usesScalarValueType="NO"/>
|
||||||
<attribute name="screenshotsAllowed" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
<attribute name="screenshotsAllowed" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||||
<relationship name="flickerCodeSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/>
|
<relationship name="flickerCodeSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/>
|
||||||
|
@ -110,7 +112,7 @@
|
||||||
</entity>
|
</entity>
|
||||||
<elements>
|
<elements>
|
||||||
<element name="PersistedAccountTransaction" positionX="-36" positionY="45" width="128" height="553"/>
|
<element name="PersistedAccountTransaction" positionX="-36" positionY="45" width="128" height="553"/>
|
||||||
<element name="PersistedAppSettings" positionX="-45" positionY="144" width="128" height="148"/>
|
<element name="PersistedAppSettings" positionX="-45" positionY="144" width="128" height="178"/>
|
||||||
<element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="418"/>
|
<element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="418"/>
|
||||||
<element name="PersistedBankData" positionX="-63" positionY="-18" width="128" height="298"/>
|
<element name="PersistedBankData" positionX="-63" positionY="-18" width="128" height="298"/>
|
||||||
<element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/>
|
<element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/>
|
||||||
|
|
|
@ -325,6 +325,8 @@ class Mapper {
|
||||||
flickerCodeSettings: map(settings.flickerCodeSettings),
|
flickerCodeSettings: map(settings.flickerCodeSettings),
|
||||||
qrCodeSettings: map(settings.qrCodeSettings),
|
qrCodeSettings: map(settings.qrCodeSettings),
|
||||||
photoTanSettings: map(settings.photoTanSettings),
|
photoTanSettings: map(settings.photoTanSettings),
|
||||||
|
lastSelectedOpenPdfFolder: settings.lastSelectedOpenPdfFolder,
|
||||||
|
lastSelectedImportFolder: settings.lastSelectedImportFolder,
|
||||||
lastSelectedExportFolder: settings.lastSelectedExportFolder)
|
lastSelectedExportFolder: settings.lastSelectedExportFolder)
|
||||||
|
|
||||||
mapped.technicalId = settings.objectIDAsString
|
mapped.technicalId = settings.objectIDAsString
|
||||||
|
@ -343,6 +345,8 @@ class Mapper {
|
||||||
mapped.qrCodeSettings = map(settings.qrCodeSettings, context)
|
mapped.qrCodeSettings = map(settings.qrCodeSettings, context)
|
||||||
mapped.photoTanSettings = map(settings.photoTanSettings, context)
|
mapped.photoTanSettings = map(settings.photoTanSettings, context)
|
||||||
|
|
||||||
|
mapped.lastSelectedOpenPdfFolder = settings.lastSelectedOpenPdfFolder
|
||||||
|
mapped.lastSelectedImportFolder = settings.lastSelectedImportFolder
|
||||||
mapped.lastSelectedExportFolder = settings.lastSelectedExportFolder
|
mapped.lastSelectedExportFolder = settings.lastSelectedExportFolder
|
||||||
|
|
||||||
return mapped
|
return mapped
|
||||||
|
|
Loading…
Reference in New Issue