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-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff_plain;h=HEAD;hp=5641898ccc58ebfb969ffcfcee76c00702051831 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 b9f161e8..4199dd4e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.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 @@ -104,9 +104,8 @@ class BookmarksDatabaseViewActivity : AppCompatActivity(), EditBookmarkDatabaseV val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false) // Disable screenshots if not allowed. - if (!allowScreenshots) { + if (!allowScreenshots) window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) - } // Run the default commands. super.onCreate(savedInstanceState) @@ -129,7 +128,7 @@ class BookmarksDatabaseViewActivity : AppCompatActivity(), EditBookmarkDatabaseV setContentView(R.layout.bookmarks_databaseview_top_appbar) } - // Get a handle for the toolbar. + // Get handles for the views. val toolbar = findViewById(R.id.bookmarks_databaseview_toolbar) bookmarksListView = findViewById(R.id.bookmarks_databaseview_listview) @@ -633,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 214ebf21..b33fc7fe 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt @@ -246,7 +246,7 @@ class LogcatActivity : AppCompatActivity() { override fun onOptionsItemSelected(menuItem: MenuItem): Boolean { // Run the commands that correlate to the selected menu item. - return when (menuItem.itemId) { + when (menuItem.itemId) { R.id.search -> { // Search was selected. // Set the minimum height of the search linear layout to match the toolbar. searchLinearLayout.minimumHeight = toolbar.height @@ -273,7 +273,7 @@ class LogcatActivity : AppCompatActivity() { logcatWebView.resumeTimers() // Consume the event. - true + return true } R.id.copy -> { // Copy was selected. @@ -291,7 +291,7 @@ class LogcatActivity : AppCompatActivity() { Snackbar.make(logcatWebView, R.string.logcat_copied, Snackbar.LENGTH_SHORT).show() // Consume the event. - true + return true } R.id.save -> { // Save was selected. @@ -299,7 +299,7 @@ class LogcatActivity : AppCompatActivity() { saveLogcatActivityResultLauncher.launch(getString(R.string.privacy_browser_logcat_txt, BuildConfig.VERSION_NAME)) // Consume the event. - true + return true } R.id.clear -> { // Clear was selected. @@ -317,22 +317,22 @@ class LogcatActivity : AppCompatActivity() { } // Consume the event. - true + return true } - else -> { // The home button was pushed. + else -> { // The home button was selected. // Do not consume the event. The system will process the home command. - super.onOptionsItemSelected(menuItem) + return super.onOptionsItemSelected(menuItem) } } } - 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/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt index 8a0cc653..8e72b596 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt @@ -46,7 +46,6 @@ import androidx.appcompat.app.ActionBar import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.constraintlayout.widget.ConstraintLayout -import androidx.core.app.NavUtils import androidx.lifecycle.ViewModelProvider import androidx.preference.PreferenceManager import androidx.swiperefreshlayout.widget.SwipeRefreshLayout @@ -152,9 +151,8 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false) // Disable screenshots if not allowed. - if (!allowScreenshots) { + if (!allowScreenshots) window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) - } // Run the default commands. super.onCreate(savedInstanceState) @@ -167,11 +165,10 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener val userAgent = intent.getStringExtra(USER_AGENT)!! // Set the content view. - if (bottomAppBar) { + if (bottomAppBar) setContentView(R.layout.view_headers_bottom_appbar) - } else { + else setContentView(R.layout.view_headers_top_appbar) - } // Get a handle for the toolbar. val toolbar = findViewById(R.id.toolbar) @@ -186,7 +183,7 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener actionBar.setCustomView(R.layout.view_headers_appbar_custom_view) // Instruct the action bar to display a custom layout. - actionBar.displayOptions = ActionBar.DISPLAY_SHOW_CUSTOM + actionBar.displayOptions = ActionBar.DISPLAY_SHOW_CUSTOM or ActionBar.DISPLAY_HOME_AS_UP // Get handles for the views. urlEditText = findViewById(R.id.url_edittext) @@ -427,7 +424,7 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener } override fun onOptionsItemSelected(menuItem: MenuItem): Boolean { - // Run the appropriate commands. + // Run the commands that correlate to the selected menu item. when (menuItem.itemId) { R.id.copy_headers -> { // Copy the headers. // Get the headers string. @@ -502,18 +499,12 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener } else -> { // The home button was selected. - // Run the parents class on return. + // Do not consume the event. The system will process the home command. return super.onOptionsItemSelected(menuItem) } } } - // This method must be named `goBack()` and must have a View argument to match the default back arrow in the app bar or a crash occurs. - fun goBack(@Suppress("UNUSED_PARAMETER") view: View) { - // Go home. - NavUtils.navigateUpFromSameTask(this) - } - private fun getHeadersString(): String { // Initialize a headers string builder. val headersStringBuilder = StringBuilder() diff --git a/app/src/main/res/color/button_background_selector.xml b/app/src/main/res/color/button_background_selector.xml index a21d2724..dbb36f95 100644 --- a/app/src/main/res/color/button_background_selector.xml +++ b/app/src/main/res/color/button_background_selector.xml @@ -1,9 +1,9 @@ - - + - - - - - - + android:layout_width="match_parent" + android:hint="@string/url" + android:imeOptions="actionGo" + android:inputType="textUri" + android:selectAllOnFocus="true" + tools:ignore="Autofill" /> diff --git a/app/src/main/res/layout/view_headers_bottom_appbar.xml b/app/src/main/res/layout/view_headers_bottom_appbar.xml index 0219c09a..7dbab777 100644 --- a/app/src/main/res/layout/view_headers_bottom_appbar.xml +++ b/app/src/main/res/layout/view_headers_bottom_appbar.xml @@ -100,7 +100,7 @@ android:text="@string/ciphers" android:onClick="showCiphers" app:backgroundTint="@color/button_background_selector" - android:textColor="@color/button_text_selector" + android:textColor="@color/white" tools:ignore="ButtonStyle" /> diff --git a/app/src/main/res/layout/view_headers_top_appbar.xml b/app/src/main/res/layout/view_headers_top_appbar.xml index 588ff6b7..34207a5b 100644 --- a/app/src/main/res/layout/view_headers_top_appbar.xml +++ b/app/src/main/res/layout/view_headers_top_appbar.xml @@ -122,7 +122,7 @@ android:text="@string/ciphers" android:onClick="showCiphers" app:backgroundTint="@color/button_background_selector" - android:textColor="@color/button_text_selector" + android:textColor="@color/white" tools:ignore="ButtonStyle" /> diff --git a/build.gradle b/build.gradle index c390d1f0..c963cfe3 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.3.1' + 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