X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FViewHeadersActivity.kt;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FViewHeadersActivity.kt;h=b18365a5954362eef3e67a53815ffc806462f8d1;hp=3b6bb26f8d8de2d2dab1f8bdc5a5e1e1bd5cece1;hb=e065315a36c804626a7dba38d3edad05e9fdb473;hpb=7a54e6907e74196a4840a2434dd13e2b68a95db4 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 3b6bb26f..b18365a5 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2023 Soren Stoutner . + * Copyright 2017-2024 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -104,23 +104,17 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener private val saveTextActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("text/plain")) { fileUri -> // Only save the file if the URI is not null, which happens if the user exited the file picker by pressing back. if (fileUri != null) { - // Initialize the file name string from the file URI last path segment. - var fileNameString = fileUri.lastPathSegment + // Get a cursor from the content resolver. + val contentResolverCursor = contentResolver.query(fileUri, null, null, null)!! - // Query the exact file name if the API >= 26. - if (Build.VERSION.SDK_INT >= 26) { - // Get a cursor from the content resolver. - val contentResolverCursor = contentResolver.query(fileUri, null, null, null)!! + // Move to the first row. + contentResolverCursor.moveToFirst() - // Move to the first row. - contentResolverCursor.moveToFirst() + // Get the file name from the cursor. + val fileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME)) - // Get the file name from the cursor. - fileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME)) - - // Close the cursor. - contentResolverCursor.close() - } + // Close the cursor. + contentResolverCursor.close() try { // Get the about version string.