Tried to fix bug that due to scoped storage on Android 10 and above no files are displayed in AndroidFileChooserDialog at least on Android 10. Set target SDK version therefore to Android 10 (for details see https://developer.android.com/training/data-storage/use-cases#opt-out-scoped-storage). TODO: remove debug log output after fixing the bug completely
This commit is contained in:
parent
94e4c7b542
commit
103968710c
|
@ -43,13 +43,13 @@ ext {
|
|||
|
||||
/* Android */
|
||||
|
||||
androidCompileSdkVersion = 30
|
||||
androidCompileSdkVersion = 29
|
||||
|
||||
androidBuildToolsVersion = "30.0.2"
|
||||
androidBuildToolsVersion = "29.0.2"
|
||||
|
||||
androidMinSdkVersion = 21 // TODO: fix SSLv3 / TLS and set back to 16
|
||||
|
||||
androidTargetSdkVersion = 30
|
||||
androidTargetSdkVersion = 29
|
||||
|
||||
|
||||
fileChooserDialogVersion = "1.3.0-androidx"
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||
|
||||
|
||||
<!-- FileChooserDialog for reading PDFs and exporting CSVs -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<!-- Both are required for ZXing -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
|
@ -25,6 +29,7 @@
|
|||
android:supportsRtl="true"
|
||||
android:hardwareAccelerated="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
>
|
||||
|
||||
<activity
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.dankito.banking.ui.android.views
|
|||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
|
@ -18,6 +19,7 @@ import net.dankito.filechooserdialog.FileChooserDialog
|
|||
import net.dankito.filechooserdialog.model.FileChooserDialogConfig
|
||||
import net.dankito.utils.android.extensions.asActivity
|
||||
import net.dankito.utils.android.permissions.IPermissionsService
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
|
||||
|
||||
|
@ -27,6 +29,12 @@ open class MainActivityFloatingActionMenuButton(
|
|||
protected val presenter: BankingPresenter
|
||||
) : FloatingActionMenuButton(floatingActionMenu) {
|
||||
|
||||
companion object {
|
||||
// TODO: remove again as soon as bug that no files are displayed in FileChooserDialog (on Android 10 and higher?) is fixed
|
||||
private val log = LoggerFactory.getLogger(MainActivityFloatingActionMenuButton::class.java)
|
||||
}
|
||||
|
||||
|
||||
protected lateinit var fabTransferMoney: FloatingActionButton
|
||||
|
||||
protected lateinit var fabMoneyTransferFromScanningQrCode: FloatingActionButton
|
||||
|
@ -96,6 +104,13 @@ open class MainActivityFloatingActionMenuButton(
|
|||
|
||||
protected open fun showTransferMoneyDialogWithDataFromPdf() {
|
||||
(floatingActionMenu.context.asActivity() as? FragmentActivity)?.let { activity ->
|
||||
// TODO: remove again as soon as bug that no files are displayed in FileChooserDialog (on Android 10 and higher?) is fixed
|
||||
log.info("config.initialDirectory = ${presenter.appSettings.lastSelectedOpenPdfFolder}, Environment.getExternalStorageDirectory() = ${Environment.getExternalStorageDirectory()}, " +
|
||||
"Downloads dir = ${Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)}")
|
||||
log.info("External storage files: ${Environment.getExternalStorageDirectory()?.listFiles()?.map { it.name }}")
|
||||
log.info("getExternalStorageState() = ${Environment.getExternalStorageState()}, isExternalStorageEmulated() = ${Environment.isExternalStorageEmulated()}, " +
|
||||
"isExternalStorageRemovable() = ${Environment.isExternalStorageRemovable()}")
|
||||
|
||||
val config = FileChooserDialogConfig(listOf("*.pdf"), presenter.appSettings.lastSelectedOpenPdfFolder.toFile())
|
||||
|
||||
FileChooserDialog().showOpenSingleFileDialog(activity, permissionsService, config) { _, selectedFile ->
|
||||
|
|
Loading…
Reference in New Issue