From: Soren Stoutner Date: Thu, 23 May 2024 21:26:54 +0000 (-0700) Subject: Fix some files not being displayed in the file picker. https://redmine.stoutner... X-Git-Tag: v3.18~1 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=f40bd0b76668119cdf4043f1fafecafb1a0869b9;p=PrivacyBrowserAndroid.git Fix some files not being displayed in the file picker. https://redmine.stoutner.com/issues/1197 --- diff --git a/app/build.gradle b/app/build.gradle index 900ddf9b..b69d2c95 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -82,23 +82,23 @@ android { dependencies { // Include the following AndroidX libraries. - implementation "androidx.activity:activity-ktx:1.8.2" + implementation "androidx.activity:activity-ktx:1.9.0" implementation 'androidx.arch.core:core-common:2.2.0' implementation 'androidx.arch.core:core-runtime:2.2.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' - implementation 'androidx.core:core-ktx:1.12.0' + implementation 'androidx.core:core-ktx:1.13.1' implementation 'androidx.drawerlayout:drawerlayout:1.2.0' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.0' implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.viewpager:viewpager:1.0.0' - implementation 'androidx.webkit:webkit:1.10.0' + implementation 'androidx.webkit:webkit:1.11.0' // Include the Kotlin standard library. This should be the same version number listed in project build.gradle. implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.20' // Include the Google material library. - implementation 'com.google.android.material:material:1.11.0' + implementation 'com.google.android.material:material:1.12.0' } diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.kt index fe7d0808..343f8e9a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.kt @@ -1,7 +1,7 @@ /* * Copyright 2016-2024 Soren Stoutner . * - * This file is part of Privacy Browser Android . + * This file is part of Privacy Browser Android . * * Privacy Browser Android is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -627,9 +627,9 @@ class BookmarksActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBookma } } - public override fun onSaveInstanceState(savedInstanceState: Bundle) { + public override fun onSaveInstanceState(outState: Bundle) { // Run the default commands. - super.onSaveInstanceState(savedInstanceState) + super.onSaveInstanceState(outState) // Get the sparse boolean array of the checked items. val checkedBookmarksSparseBooleanArray = bookmarksListView.checkedItemPositions @@ -646,9 +646,9 @@ class BookmarksActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBookma } } - // Store the variables in the saved instance state. - savedInstanceState.putLong(CURRENT_FOLDER_ID, currentFolderId) - savedInstanceState.putIntegerArrayList(CHECKED_BOOKMARKS_ARRAY_LIST, checkedBookmarksArrayList) + // Store the variables in the out state. + outState.putLong(CURRENT_FOLDER_ID, currentFolderId) + outState.putIntegerArrayList(CHECKED_BOOKMARKS_ARRAY_LIST, checkedBookmarksArrayList) } override fun onCreateOptionsMenu(menu: Menu): Boolean { diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt index 9804e5f5..4199dd4e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt @@ -632,13 +632,13 @@ class BookmarksDatabaseViewActivity : AppCompatActivity(), EditBookmarkDatabaseV return true } - public override fun onSaveInstanceState(savedInstanceState: Bundle) { + public override fun onSaveInstanceState(outState: Bundle) { // Run the default commands. - super.onSaveInstanceState(savedInstanceState) + super.onSaveInstanceState(outState) // Store the class variables in the bundle. - savedInstanceState.putInt(CURRENT_FOLDER_DATABASE_ID, currentFolderDatabaseId) - savedInstanceState.putBoolean(SORT_BY_DISPLAY_ORDER, sortByDisplayOrder) + outState.putInt(CURRENT_FOLDER_DATABASE_ID, currentFolderDatabaseId) + outState.putBoolean(SORT_BY_DISPLAY_ORDER, sortByDisplayOrder) } override fun saveBookmark(dialogFragment: DialogFragment, selectedBookmarkDatabaseId: Int) { diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt index 4996568e..e0e06876 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt @@ -1,7 +1,7 @@ /* * Copyright 2017-2024 Soren Stoutner . * - * This file is part of Privacy Browser Android . + * This file is part of Privacy Browser Android . * * Privacy Browser Android is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -603,9 +603,9 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI return true } - override fun onSaveInstanceState(savedInstanceState: Bundle) { + override fun onSaveInstanceState(outState: Bundle) { // Run the default commands. - super.onSaveInstanceState(savedInstanceState) + super.onSaveInstanceState(outState) // Get a handle for the domain settings scrollview. val domainSettingsScrollView = findViewById(R.id.domain_settings_scrollview) @@ -613,9 +613,9 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI // Check to see if the domain settings scrollview exists. if (domainSettingsScrollView == null) { // The domain settings are not displayed. // Store the domain settings status in the bundle. - savedInstanceState.putBoolean(DOMAIN_SETTINGS_DISPLAYED, false) - savedInstanceState.putInt(DOMAIN_SETTINGS_DATABASE_ID, -1) - savedInstanceState.putInt(DOMAIN_SETTINGS_SCROLL_Y, 0) + outState.putBoolean(DOMAIN_SETTINGS_DISPLAYED, false) + outState.putInt(DOMAIN_SETTINGS_DATABASE_ID, -1) + outState.putInt(DOMAIN_SETTINGS_SCROLL_Y, 0) } else { // The domain settings are displayed. // Save any changes that have been made to the domain settings. saveDomainSettings(coordinatorLayout) @@ -624,9 +624,9 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI val domainSettingsScrollY = domainSettingsScrollView.scrollY // Store the domain settings status in the bundle. - savedInstanceState.putBoolean(DOMAIN_SETTINGS_DISPLAYED, true) - savedInstanceState.putInt(DOMAIN_SETTINGS_DATABASE_ID, DomainSettingsFragment.databaseId) - savedInstanceState.putInt(DOMAIN_SETTINGS_SCROLL_Y, domainSettingsScrollY) + outState.putBoolean(DOMAIN_SETTINGS_DISPLAYED, true) + outState.putInt(DOMAIN_SETTINGS_DATABASE_ID, DomainSettingsFragment.databaseId) + outState.putInt(DOMAIN_SETTINGS_SCROLL_Y, domainSettingsScrollY) } // Check to see if the domains listview exists. @@ -635,7 +635,7 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI val domainsListViewPosition = domainsListView!!.firstVisiblePosition // Store the listview position in the bundle. - savedInstanceState.putInt(LISTVIEW_POSITION, domainsListViewPosition) + outState.putInt(LISTVIEW_POSITION, domainsListViewPosition) } } diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.kt index 36d1e725..77019932 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.kt @@ -1,7 +1,7 @@ /* - * Copyright 2018-2023 Soren Stoutner . + * Copyright 2018-2024 Soren Stoutner . * - * This file is part of Privacy Browser Android . + * This file is part of Privacy Browser Android . * * Privacy Browser Android is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -452,25 +452,25 @@ class ImportExportActivity : AppCompatActivity() { } } - public override fun onSaveInstanceState(savedInstanceState: Bundle) { + public override fun onSaveInstanceState(outState: Bundle) { // Run the default commands. - super.onSaveInstanceState(savedInstanceState) + super.onSaveInstanceState(outState) // Save the visibility of the views. - savedInstanceState.putInt(ENCRYPTION_PASSWORD_TEXTINPUTLAYOUT_VISIBILITY, encryptionPasswordTextInputLayout.visibility) - savedInstanceState.putInt(OPEN_KEYCHAIN_REQUIRED_TEXTVIEW_VISIBILITY, openKeychainRequiredTextView.visibility) - savedInstanceState.putInt(SETTINGS_FILE_LOCATION_CARDVIEW_VISIBILITY, settingsFileLocationCardView.visibility) - savedInstanceState.putInt(SETTINGS_FILE_NAME_LINEARLAYOUT_VISIBILITY, settingsFileNameLinearLayout.visibility) - savedInstanceState.putInt(OPEN_KEYCHAIN_IMPORT_INSTRUCTIONS_TEXTVIEW_VISIBILITY, openKeychainImportInstructionsTextView.visibility) - savedInstanceState.putInt(SETTINGS_IMPORT_EXPORT_BUTTON_VISIBILITY, settingsImportExportButton.visibility) - savedInstanceState.putInt(BOOKMARKS_FILE_NAME_LINEARLAYOUT_VISIBILITY, bookmarksFileNameLinearLayout.visibility) - savedInstanceState.putInt(BOOKMARKS_IMPORT_EXPORT_BUTTON_VISIBILITY, bookmarksImportExportButton.visibility) + outState.putInt(ENCRYPTION_PASSWORD_TEXTINPUTLAYOUT_VISIBILITY, encryptionPasswordTextInputLayout.visibility) + outState.putInt(OPEN_KEYCHAIN_REQUIRED_TEXTVIEW_VISIBILITY, openKeychainRequiredTextView.visibility) + outState.putInt(SETTINGS_FILE_LOCATION_CARDVIEW_VISIBILITY, settingsFileLocationCardView.visibility) + outState.putInt(SETTINGS_FILE_NAME_LINEARLAYOUT_VISIBILITY, settingsFileNameLinearLayout.visibility) + outState.putInt(OPEN_KEYCHAIN_IMPORT_INSTRUCTIONS_TEXTVIEW_VISIBILITY, openKeychainImportInstructionsTextView.visibility) + outState.putInt(SETTINGS_IMPORT_EXPORT_BUTTON_VISIBILITY, settingsImportExportButton.visibility) + outState.putInt(BOOKMARKS_FILE_NAME_LINEARLAYOUT_VISIBILITY, bookmarksFileNameLinearLayout.visibility) + outState.putInt(BOOKMARKS_IMPORT_EXPORT_BUTTON_VISIBILITY, bookmarksImportExportButton.visibility) // Save the text. - savedInstanceState.putString(SETTINGS_FILE_NAME_TEXT, settingsFileNameEditText.text.toString()) - savedInstanceState.putString(SETTINGS_IMPORT_EXPORT_BUTTON_TEXT, settingsImportExportButton.text.toString()) - savedInstanceState.putString(BOOKMARKS_FILE_NAME_TEXT, bookmarksFileNameEditText.text.toString()) - savedInstanceState.putString(BOOKMARKS_IMPORT_EXPORT_BUTTON_VISIBILITY, bookmarksImportExportButton.text.toString()) + outState.putString(SETTINGS_FILE_NAME_TEXT, settingsFileNameEditText.text.toString()) + outState.putString(SETTINGS_IMPORT_EXPORT_BUTTON_TEXT, settingsImportExportButton.text.toString()) + outState.putString(BOOKMARKS_FILE_NAME_TEXT, bookmarksFileNameEditText.text.toString()) + outState.putString(BOOKMARKS_IMPORT_EXPORT_BUTTON_VISIBILITY, bookmarksImportExportButton.text.toString()) } fun onClickBookmarksRadioButton(view: View) { diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt index a0e5ad8a..b33fc7fe 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt @@ -327,12 +327,12 @@ class LogcatActivity : AppCompatActivity() { } } - public override fun onSaveInstanceState(savedInstanceState: Bundle) { + public override fun onSaveInstanceState(outState: Bundle) { // Run the default commands. - super.onSaveInstanceState(savedInstanceState) + super.onSaveInstanceState(outState) // Store the scroll Y position in the bundle. - savedInstanceState.putInt(SCROLL_Y, logcatWebView.scrollY) + outState.putInt(SCROLL_Y, logcatWebView.scrollY) } // The view parameter cannot be removed because it is called from the layout onClick. diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index 042af73d..a1d8ecc7 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -393,14 +393,14 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook private var ultraPrivacy: ArrayList>>? = null private var waitingForProxy = false - // Define the save webpage image activity result launcher. It must be defined before `onCreate()` is run or the app will crash. + // Define the browse file upload activity result launcher. It must be defined before `onCreate()` is run or the app will crash. private val browseFileUploadActivityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult -> // Pass the file to the WebView. fileChooserCallback.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(activityResult.resultCode, activityResult.data)) } // Define the save URL activity result launcher. It must be defined before `onCreate()` is run or the app will crash. - private val saveUrlActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("*/*")) { fileUri -> + private val saveUrlActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("*/*")) { fileUri -> // Only save the URL if the file URI is not null, which happens if the user exited the file picker by pressing back. if (fileUri != null) { // Instantiate the save URL coroutine. @@ -415,7 +415,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } // Define the save webpage archive activity result launcher. It must be defined before `onCreate()` is run or the app will crash. - private val saveWebpageArchiveActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("multipart/related")) { fileUri -> + private val saveWebpageArchiveActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("multipart/related")) { fileUri -> // Only save the webpage archive if the file URI is not null, which happens if the user exited the file picker by pressing back. if (fileUri != null) { // Get a cursor from the content resolver. @@ -488,7 +488,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } // Define the save webpage image activity result launcher. It must be defined before `onCreate()` is run or the app will crash. - private val saveWebpageImageActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("image/png")) { fileUri -> + private val saveWebpageImageActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("image/png")) { fileUri -> // Only save the webpage image if the file URI is not null, which happens if the user exited the file picker by pressing back. if (fileUri != null) { // Instantiate the save webpage image coroutine. @@ -894,9 +894,9 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook pendingDialogsArrayList.clear() } - public override fun onSaveInstanceState(savedInstanceState: Bundle) { + public override fun onSaveInstanceState(outState: Bundle) { // Run the default commands. - super.onSaveInstanceState(savedInstanceState) + super.onSaveInstanceState(outState) // Only save the instance state if the WebView state adapter is not null, which will be the case if the app is restarting to change the initial app theme. if (webViewStateAdapter != null) { @@ -934,11 +934,11 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook val currentTabPosition = tabLayout.selectedTabPosition // Store the saved states in the bundle. - savedInstanceState.putBoolean(BOOKMARKS_DRAWER_PINNED, bookmarksDrawerPinned) - savedInstanceState.putString(PROXY_MODE, proxyMode) - savedInstanceState.putParcelableArrayList(SAVED_NESTED_SCROLL_WEBVIEW_STATE_ARRAY_LIST, savedNestedScrollWebViewStateArrayList) - savedInstanceState.putParcelableArrayList(SAVED_STATE_ARRAY_LIST, savedStateArrayList) - savedInstanceState.putInt(SAVED_TAB_POSITION, currentTabPosition) + outState.putBoolean(BOOKMARKS_DRAWER_PINNED, bookmarksDrawerPinned) + outState.putString(PROXY_MODE, proxyMode) + outState.putParcelableArrayList(SAVED_NESTED_SCROLL_WEBVIEW_STATE_ARRAY_LIST, savedNestedScrollWebViewStateArrayList) + outState.putParcelableArrayList(SAVED_STATE_ARRAY_LIST, savedStateArrayList) + outState.putInt(SAVED_TAB_POSITION, currentTabPosition) } } @@ -5002,26 +5002,17 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Store the file path callback. fileChooserCallback = filePathCallback - // Create an intent to open a chooser based on the file chooser parameters. - val fileChooserIntent = fileChooserParams.createIntent() - - // Check to see if the file chooser intent resolves to an installed package. - if (fileChooserIntent.resolveActivity(packageManager) != null) { // The file chooser intent is fine. - // Launch the file chooser intent. - browseFileUploadActivityResultLauncher.launch(fileChooserIntent) - } else { // The file chooser intent will cause a crash. - // Create a generic intent to open a chooser. - val genericFileChooserIntent = Intent(Intent.ACTION_GET_CONTENT) + // Create a file chooser intent. + val fileChooserIntent = Intent(Intent.ACTION_GET_CONTENT) - // Request an openable file. - genericFileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE) + // Request an openable file. + fileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE) - // Set the file type to everything. - genericFileChooserIntent.type = "*/*" + // Set the file type to everything. The file chooser params cannot be used to create the intent because it only selects the first specified file type. See . + fileChooserIntent.type = "*/*" - // Launch the generic file chooser intent. - browseFileUploadActivityResultLauncher.launch(genericFileChooserIntent) - } + // Launch the file chooser intent. + browseFileUploadActivityResultLauncher.launch(fileChooserIntent) // Handle the event. return true diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/RequestsActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/RequestsActivity.kt index 11efe094..5a0d0ef5 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/RequestsActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/RequestsActivity.kt @@ -1,7 +1,7 @@ /* - * Copyright 2018-2023 Soren Stoutner . + * Copyright 2018-2024 Soren Stoutner . * - * This file is part of Privacy Browser Android . + * This file is part of Privacy Browser Android . * * Privacy Browser Android is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -245,15 +245,15 @@ class RequestsActivity : AppCompatActivity(), ViewRequestListener { } } - public override fun onSaveInstanceState(savedInstanceState: Bundle) { + public override fun onSaveInstanceState(outState: Bundle) { // Run the default commands. - super.onSaveInstanceState(savedInstanceState) + super.onSaveInstanceState(outState) // Get the listview position. val listViewPosition = requestsListView.firstVisiblePosition // Store the listview position in the bundle. - savedInstanceState.putInt(LISTVIEW_POSITION, listViewPosition) + outState.putInt(LISTVIEW_POSITION, listViewPosition) } override fun onPrevious(currentId: Int) { diff --git a/build.gradle b/build.gradle index 8573ba5c..c963cfe3 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.3.2' + classpath 'com.android.tools.build:gradle:8.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20" // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b49cb335..1f5b0c3d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -20,4 +20,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip