]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt
Add options to copy, share, and save View Headers. https://redmine.stoutner.com...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / AboutVersionFragment.kt
index b60303c581b335aa64983bc474c4fb1d0f8993b6..03fa6f052e4f6bb3c79a0f3b0bdda9930c6711f4 100644 (file)
@@ -327,8 +327,7 @@ class AboutVersionFragment : Fragment() {
 
         // Get the Orbot version name if Orbot is installed.
         val orbot: String = try {
-            // Store the version name.  The newer `getPackageInfo()` may be used once the minimum API >= 33.
-            @Suppress("DEPRECATION")
+            // Store the version name.
             requireContext().packageManager.getPackageInfo("org.torproject.android", 0).versionName
         } catch (exception: PackageManager.NameNotFoundException) {  // Orbot is not installed.
             // Store an empty string.
@@ -337,13 +336,11 @@ class AboutVersionFragment : Fragment() {
 
         // Get the I2P version name if I2P is installed.
         val i2p: String = try {
-            // Check to see if the F-Droid flavor is installed.  The newer `getPackageInfo()` may be used once the minimum API >= 33.
-            @Suppress("DEPRECATION")
+            // Check to see if the F-Droid flavor is installed.
             requireContext().getString(R.string.fdroid_flavor, requireContext().packageManager.getPackageInfo("net.i2p.android.router", 0).versionName)
         } catch (exception: PackageManager.NameNotFoundException) {  // The F-Droid flavor is not installed.
             try {
-                // Check to see if the F-Droid flavor is installed.  The newer `getPackageInfo()` may be used once the minimum API >= 33.
-                @Suppress("DEPRECATION")
+                // Check to see if the F-Droid flavor is installed.
                 requireContext().getString(R.string.google_play_flavor, requireContext().packageManager.getPackageInfo("net.i2p.android", 0).versionName)
             } catch (exception: PackageManager.NameNotFoundException) {  // The Google Play flavor is not installed either.
                 // Store an empty string.
@@ -353,8 +350,7 @@ class AboutVersionFragment : Fragment() {
 
         // Get the OpenKeychain version name if it is installed.
         val openKeychain: String = try {
-            // Store the version name.  The newer `getPackageInfo()` may be used once the minimum API >= 33.
-            @Suppress("DEPRECATION")
+            // Store the version name.
             requireContext().packageManager.getPackageInfo("org.sufficientlysecure.keychain", 0).versionName
         } catch (exception: PackageManager.NameNotFoundException) {  // OpenKeychain is not installed.
             // Store an empty string.
@@ -632,14 +628,15 @@ class AboutVersionFragment : Fragment() {
                 // Get a handle for the clipboard manager.
                 val clipboardManager = (requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager)
 
-                // Save the about version string in a clip data.
+                // Place the about version string in a clip data.
                 val aboutVersionClipData = ClipData.newPlainText(getString(R.string.about), aboutVersionString)
 
                 // Place the clip data on the clipboard.
                 clipboardManager.setPrimaryClip(aboutVersionClipData)
 
-                // Display a snackbar.
-                Snackbar.make(aboutVersionLayout, R.string.version_info_copied, Snackbar.LENGTH_SHORT).show()
+                // Display a snackbar if the API <= 32 (Android 12L).  Beginning in Android 13 the OS displays a notification that covers up the snackbar.
+                if (Build.VERSION.SDK_INT <= 32)
+                    Snackbar.make(aboutVersionLayout, R.string.version_info_copied, Snackbar.LENGTH_SHORT).show()
 
                 // Consume the event.
                 return true
@@ -649,20 +646,20 @@ class AboutVersionFragment : Fragment() {
                 // Get the about version string.
                 val aboutString = getAboutVersionString()
 
-                // Create an email intent.
-                val emailIntent = Intent(Intent.ACTION_SEND)
+                // Create a share intent.
+                val shareIntent = Intent(Intent.ACTION_SEND)
 
                 // Add the about version string to the intent.
-                emailIntent.putExtra(Intent.EXTRA_TEXT, aboutString)
+                shareIntent.putExtra(Intent.EXTRA_TEXT, aboutString)
 
                 // Set the MIME type.
-                emailIntent.type = "text/plain"
+                shareIntent.type = "text/plain"
 
                 // Set the intent to open in a new task.
-                emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+                shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
 
                 // Make it so.
-                startActivity(Intent.createChooser(emailIntent, getString(R.string.share)))
+                startActivity(Intent.createChooser(shareIntent, getString(R.string.share)))
 
                 // Consume the event.
                 return true
@@ -683,6 +680,7 @@ class AboutVersionFragment : Fragment() {
                 // Consume the event.
                 return true
             }
+
             else -> {  // The home button was selected.
                 // Run the parents class on return.
                 return super.onOptionsItemSelected(menuItem)