]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Fix some files not being displayed in the file picker. https://redmine.stoutner...
authorSoren Stoutner <soren@stoutner.com>
Thu, 23 May 2024 21:26:54 +0000 (14:26 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 23 May 2024 21:26:54 +0000 (14:26 -0700)
app/build.gradle
app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.kt
app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt
app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt
app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.kt
app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt
app/src/main/java/com/stoutner/privacybrowser/activities/RequestsActivity.kt
build.gradle
gradle/wrapper/gradle-wrapper.properties

index 900ddf9bc86073aabd2bb6ec82f085d53fd08d88..b69d2c95e63772b21c985dff174f2c0b639bd177 100644 (file)
@@ -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'
 }
index fe7d080854cd60654136491e3b17d3343a53230c..343f8e9af0aa57b57c733b9d18ed0e1a10cfd571 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2016-2024 Soren Stoutner <soren@stoutner.com>.
  *
- * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
+ * This file is part of Privacy Browser Android <https://www.stoutner.com/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 {
index 9804e5f59709eb408267a6221da1c70567dc4807..4199dd4e4436da81725128dc46842997b0473f3e 100644 (file)
@@ -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) {
index 4996568e1e79084b865a75b4098f670a89a2a53a..e0e068769ea1ed8888aee4ab4e7d7169c3858606 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2017-2024 Soren Stoutner <soren@stoutner.com>.
  *
- * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
+ * This file is part of Privacy Browser Android <https://www.stoutner.com/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<ScrollView>(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)
         }
     }
 
index 36d1e725a3b190cecfa5c77c35d59a3bee6b79dd..77019932b8a14323d42c6a0e94ed33f251e08b45 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Copyright 2018-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2018-2024 Soren Stoutner <soren@stoutner.com>.
  *
- * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
+ * This file is part of Privacy Browser Android <https://www.stoutner.com/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) {
index a0e5ad8ab831acbc7785089bf336b9eaf57cad6d..b33fc7fe0ba206d3c74e17778ecd7e3eb0883d10 100644 (file)
@@ -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.
index 042af73dce4f9258440b6da318dcdbfaac7ba25d..a1d8ecc78220aefd7b6a310dbdb0f62b4785befe 100644 (file)
@@ -393,14 +393,14 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook
     private var ultraPrivacy: ArrayList<List<Array<String>>>? = 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<String, Uri>(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<String, Uri>(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<String, Uri>(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 <https://redmine.stoutner.com/issues/1197>.
+                fileChooserIntent.type = "*/*"
 
-                    // Launch the generic file chooser intent.
-                    browseFileUploadActivityResultLauncher.launch(genericFileChooserIntent)
-                }
+                // Launch the file chooser intent.
+                browseFileUploadActivityResultLauncher.launch(fileChooserIntent)
 
                 // Handle the event.
                 return true
index 11efe094d9d8fc8c88a2e07eddea9154735b5cd8..5a0d0ef596a3aef33ff895be360106437b0a5c6c 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Copyright 2018-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2018-2024 Soren Stoutner <soren@stoutner.com>.
  *
- * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
+ * This file is part of Privacy Browser Android <https://www.stoutner.com/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) {
index 8573ba5c6ae06bbf3f2e48f2c1514f454b2f34e7..c963cfe32d8fa714b133be682cc63f114c4fe073 100644 (file)
@@ -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
index b49cb33594b58737a88c2a1c077863cea30b6ef1..1f5b0c3d1476376c739b61b3f3154adecd764f09 100644 (file)
@@ -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