X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FAboutVersionFragment.kt;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FAboutVersionFragment.kt;h=163e41d104cf4b6e9187c2586ece84196e973804;hp=eeaae384d561ec956049a0241fa796ddf379729b;hb=e065315a36c804626a7dba38d3edad05e9fdb473;hpb=7a54e6907e74196a4840a2434dd13e2b68a95db4 diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt b/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt index eeaae384..163e41d1 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 Soren Stoutner . + * Copyright 2016-2024 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -41,11 +41,11 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import android.webkit.WebView import android.widget.TextView import androidx.activity.result.contract.ActivityResultContracts import androidx.fragment.app.Fragment -import androidx.webkit.WebViewCompat import com.google.android.material.snackbar.Snackbar @@ -162,23 +162,17 @@ class AboutVersionFragment : Fragment() { private val saveAboutVersionTextActivityResultLauncher = 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 = requireActivity().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 = requireActivity().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. @@ -307,8 +301,8 @@ class AboutVersionFragment : Fragment() { val serialNumberLabel = getString(R.string.serial_number) val signatureAlgorithmLabel = getString(R.string.signature_algorithm) - // Get the current WebView package info. This can be replaced by the direct call once the minimum API >= 26. - val webViewPackageInfo = WebViewCompat.getCurrentWebViewPackage(requireContext())!! + // Get the current WebView package info. + val webViewPackageInfo = WebView.getCurrentWebViewPackage()!! // Get the device's information and store it in strings. val brand = Build.BRAND