mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Change default type verification to create document
This commit is contained in:
@@ -286,7 +286,8 @@ class FileDatabaseSelectActivity : SpecialModeActivity(),
|
|||||||
// Show open and create button or special mode
|
// Show open and create button or special mode
|
||||||
when (mSpecialMode) {
|
when (mSpecialMode) {
|
||||||
SpecialMode.DEFAULT -> {
|
SpecialMode.DEFAULT -> {
|
||||||
if (ExternalFileHelper.allowCreateDocumentByStorageAccessFramework(packageManager)) {
|
if (ExternalFileHelper.allowCreateDocumentByStorageAccessFramework(packageManager,
|
||||||
|
"application/x-keepass")) {
|
||||||
// There is an activity which can handle this intent.
|
// There is an activity which can handle this intent.
|
||||||
createDatabaseButtonView?.visibility = View.VISIBLE
|
createDatabaseButtonView?.visibility = View.VISIBLE
|
||||||
} else{
|
} else{
|
||||||
|
|||||||
@@ -291,13 +291,14 @@ class ExternalFileHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InlinedApi")
|
@SuppressLint("InlinedApi")
|
||||||
fun allowCreateDocumentByStorageAccessFramework(packageManager: PackageManager): Boolean {
|
fun allowCreateDocumentByStorageAccessFramework(packageManager: PackageManager,
|
||||||
|
typeString: String = "application/octet-stream"): Boolean {
|
||||||
return when {
|
return when {
|
||||||
// To check if a custom file manager can manage the ACTION_CREATE_DOCUMENT
|
// To check if a custom file manager can manage the ACTION_CREATE_DOCUMENT
|
||||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT -> {
|
Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT -> {
|
||||||
packageManager.queryIntentActivities(Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
packageManager.queryIntentActivities(Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
||||||
addCategory(Intent.CATEGORY_OPENABLE)
|
addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
type = "application/x-keepass"
|
type = typeString
|
||||||
}, PackageManager.MATCH_DEFAULT_ONLY).isNotEmpty()
|
}, PackageManager.MATCH_DEFAULT_ONLY).isNotEmpty()
|
||||||
}
|
}
|
||||||
else -> true
|
else -> true
|
||||||
|
|||||||
Reference in New Issue
Block a user