From c8893805296e71409a3c7f37a09e083edbb23eaf Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Wed, 1 Jan 2025 10:33:33 -0700 Subject: [PATCH] Fix crash if third-party apps are not installed. https://redmine.stoutner.com/issues/1254 --- COPYING | 3 ++- app/src/main/assets/de/about_changelog.html | 2 +- app/src/main/assets/de/about_licenses.html | 26 +++++++++--------- app/src/main/assets/en/about_changelog.html | 2 +- app/src/main/assets/en/about_licenses.html | 25 ++++++++--------- app/src/main/assets/es/about_changelog.html | 2 +- app/src/main/assets/es/about_licenses.html | 27 ++++++++++--------- app/src/main/assets/fr/about_changelog.html | 2 +- app/src/main/assets/fr/about_licenses.html | 25 ++++++++--------- app/src/main/assets/it/about_changelog.html | 2 +- app/src/main/assets/it/about_licenses.html | 25 ++++++++--------- .../main/assets/pt-rBR/about_changelog.html | 2 +- .../main/assets/pt-rBR/about_licenses.html | 25 ++++++++--------- app/src/main/assets/ru/about_changelog.html | 2 +- app/src/main/assets/ru/about_licenses.html | 25 ++++++++--------- app/src/main/assets/tr/about_changelog.html | 2 +- app/src/main/assets/tr/about_licenses.html | 25 ++++++++--------- .../main/assets/zh-rCN/about_changelog.html | 2 +- .../main/assets/zh-rCN/about_licenses.html | 25 ++++++++--------- .../activities/AboutActivity.kt | 26 +++++++++--------- .../activities/ImportExportActivity.kt | 13 ++++++--- .../fragments/AboutVersionFragment.kt | 22 +++++++++++---- 22 files changed, 169 insertions(+), 141 deletions(-) diff --git a/COPYING b/COPYING index b7227ff6..0ff468bf 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,5 @@ -Privacy Browser Android copyright 2015-2024 Soren Stoutner . +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2016-2025 Soren Stoutner This file is part of Privacy Browser Android . diff --git a/app/src/main/assets/de/about_changelog.html b/app/src/main/assets/de/about_changelog.html index c1a9dcc1..83ccd3db 100644 --- a/app/src/main/assets/de/about_changelog.html +++ b/app/src/main/assets/de/about_changelog.html @@ -34,7 +34,7 @@

3.19 (Code-Version 76)

-

31. Dezember 2024 - Mindest-API 26, Ziel-API 35

+

31. Dezember 2024 - Mindest-API 26, Ziel-API 35

  • Option hinzugefügt, um Lesezeichen alphabetisch zu sortieren.
  • Optionen für "Nach oben bewegen" und "Nach unten bewegen" von Lesezeichen hinzugefügt.
  • diff --git a/app/src/main/assets/de/about_licenses.html b/app/src/main/assets/de/about_licenses.html index e35273d2..9e7ec4a2 100644 --- a/app/src/main/assets/de/about_licenses.html +++ b/app/src/main/assets/de/about_licenses.html @@ -1,24 +1,24 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -34,7 +34,7 @@

    Copyright:

    -

    Privacy Browser ist copyright 2015-2024 von Soren Stoutner.

    +

    Privacy Browser ist copyright 2015-2025 von Soren Stoutner.

    Lizenz:

    Privacy Browser ist veröffentlicht unter der GPLv3+ Lizenz. The full text of the license is below. diff --git a/app/src/main/assets/en/about_changelog.html b/app/src/main/assets/en/about_changelog.html index 0f2a7767..6cc5e578 100644 --- a/app/src/main/assets/en/about_changelog.html +++ b/app/src/main/assets/en/about_changelog.html @@ -30,7 +30,7 @@

    3.19 (version code 76)

    -

    31 December 2024 - minimum API 26, target API 35

    +

    31 December 2024 - minimum API 26, target API 35

    • Add an option to sort bookmarks alphabetically.
    • Add "move to top" and "move to bottom" options for bookmarks.
    • diff --git a/app/src/main/assets/en/about_licenses.html b/app/src/main/assets/en/about_licenses.html index 65bfb288..a27e6a99 100644 --- a/app/src/main/assets/en/about_licenses.html +++ b/app/src/main/assets/en/about_licenses.html @@ -1,20 +1,21 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -30,7 +31,7 @@

      Copyright

      -

      Privacy Browser copyright 2015-2024 Soren Stoutner.

      +

      Privacy Browser copyright 2015-2025 Soren Stoutner.

      License

      Privacy Browser is released under the GPLv3+ license. The full text of the license is below. diff --git a/app/src/main/assets/es/about_changelog.html b/app/src/main/assets/es/about_changelog.html index e8b3bf61..d5e2fa96 100644 --- a/app/src/main/assets/es/about_changelog.html +++ b/app/src/main/assets/es/about_changelog.html @@ -32,7 +32,7 @@

      3.19 (código de versión 76)

      -

      31 de diciembre de 2024 - API mínimo 26, API objetivo 35

      +

      31 de diciembre de 2024 - API mínimo 26, API objetivo 35

      • Añadir una opción para ordenar los favoritos alfabéticamente.
      • Añadir las opciones "mover arriba" y "mover abajo" para los favoritos.
      • diff --git a/app/src/main/assets/es/about_licenses.html b/app/src/main/assets/es/about_licenses.html index b8eea778..8a92454c 100644 --- a/app/src/main/assets/es/about_licenses.html +++ b/app/src/main/assets/es/about_licenses.html @@ -1,22 +1,23 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -32,7 +33,7 @@

        Derechos de autor

        -

        Navegador Privado tiene derechos de autor 2015-2024 por Soren Stoutner.

        +

        Navegador Privado tiene derechos de autor 2015-2025 por Soren Stoutner.

        Licencia

        Navegador Privado está liberado bajo la licencia GPLv3+. diff --git a/app/src/main/assets/fr/about_changelog.html b/app/src/main/assets/fr/about_changelog.html index db37f379..5b239d2c 100644 --- a/app/src/main/assets/fr/about_changelog.html +++ b/app/src/main/assets/fr/about_changelog.html @@ -32,7 +32,7 @@

        3.19 (version du code 76)

        -

        31 Décembre 2024 - API minimale : 26, API optimale : 35

        +

        31 Décembre 2024 - API minimale : 26, API optimale : 35

        • Ajout d'une option pour trier les favoris par ordre alphabétique.
        • Ajout des options "déplacer en haut" et "déplacer en bas" pour les favoris.
        • diff --git a/app/src/main/assets/fr/about_licenses.html b/app/src/main/assets/fr/about_licenses.html index fdd59829..f8c1ee3d 100644 --- a/app/src/main/assets/fr/about_licenses.html +++ b/app/src/main/assets/fr/about_licenses.html @@ -1,22 +1,23 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -32,7 +33,7 @@

          Copyright

          -

          Privacy Browser copyright 2015-2024 Soren Stoutner.

          +

          Privacy Browser copyright 2015-2025 Soren Stoutner.

          Licence

          rivacy Browser est publié sous la licence GPLv3+. Le texte complet de la licence est ci-dessous. diff --git a/app/src/main/assets/it/about_changelog.html b/app/src/main/assets/it/about_changelog.html index d5c47c75..ea5ac49f 100644 --- a/app/src/main/assets/it/about_changelog.html +++ b/app/src/main/assets/it/about_changelog.html @@ -32,7 +32,7 @@

          3.19 (versione codice 76)

          -

          31 Dicembre 2024 - minima API 26, target API 35

          +

          31 Dicembre 2024 - minima API 26, target API 35

          • Add an option to sort bookmarks alphabetically.
          • Add "move to top" and "move to bottom" options for bookmarks.
          • diff --git a/app/src/main/assets/it/about_licenses.html b/app/src/main/assets/it/about_licenses.html index 0f6e5633..07fc5093 100644 --- a/app/src/main/assets/it/about_licenses.html +++ b/app/src/main/assets/it/about_licenses.html @@ -1,22 +1,23 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -32,7 +33,7 @@

            Copyright

            -

            Privacy Browser copyright 2015-2024: Soren Stoutner.

            +

            Privacy Browser copyright 2015-2025: Soren Stoutner.

            Licenza

            Privacy Browser è rilasciato con Licenza GPLv3+ . diff --git a/app/src/main/assets/pt-rBR/about_changelog.html b/app/src/main/assets/pt-rBR/about_changelog.html index 710c277f..37287880 100644 --- a/app/src/main/assets/pt-rBR/about_changelog.html +++ b/app/src/main/assets/pt-rBR/about_changelog.html @@ -32,7 +32,7 @@

            3.19 (código de versão 76)

            -

            31 de dezembro de 2024 - minimum API 26, target API 35

            +

            31 de dezembro de 2024 - minimum API 26, target API 35

            • Add an option to sort bookmarks alphabetically.
            • Add "move to top" and "move to bottom" options for bookmarks.
            • diff --git a/app/src/main/assets/pt-rBR/about_licenses.html b/app/src/main/assets/pt-rBR/about_licenses.html index d6a47a02..9837013a 100644 --- a/app/src/main/assets/pt-rBR/about_licenses.html +++ b/app/src/main/assets/pt-rBR/about_licenses.html @@ -1,22 +1,23 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -32,7 +33,7 @@

              Copyright

              -

              Privacy Browser copyright 2015-2024 Soren Stoutner.

              +

              Privacy Browser copyright 2015-2025 Soren Stoutner.

              License

              Privacy Browser is released under the GPLv3+ license. The full text of the license is below. diff --git a/app/src/main/assets/ru/about_changelog.html b/app/src/main/assets/ru/about_changelog.html index 3ac1cf6c..b064444e 100644 --- a/app/src/main/assets/ru/about_changelog.html +++ b/app/src/main/assets/ru/about_changelog.html @@ -30,7 +30,7 @@

              3.19 (код версии 76)

              -

              31 декабря 2024 года - минимальный API 26, целевой API 35

              +

              31 декабря 2024 года - минимальный API 26, целевой API 35

              • Добавлена возможность сортировки закладок в алфавитном порядке.
              • Добавлена возможность перемещать закладки вверх и вниз".
              • diff --git a/app/src/main/assets/ru/about_licenses.html b/app/src/main/assets/ru/about_licenses.html index 649efed4..5ef5a967 100644 --- a/app/src/main/assets/ru/about_licenses.html +++ b/app/src/main/assets/ru/about_licenses.html @@ -1,20 +1,21 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -30,7 +31,7 @@

                Авторские права

                -

                Авторские права Privacy Browser 2015-2024 Soren Stoutner.

                +

                Авторские права Privacy Browser 2015-2025 Soren Stoutner.

                Лицензия

                Privacy Browser выпущен под лицензией GPLv3+. Полный текст лицензии приведен ниже. diff --git a/app/src/main/assets/tr/about_changelog.html b/app/src/main/assets/tr/about_changelog.html index f2f2e6d5..981960a2 100644 --- a/app/src/main/assets/tr/about_changelog.html +++ b/app/src/main/assets/tr/about_changelog.html @@ -30,7 +30,7 @@

                3.19 (version code 76)

                -

                31 Aralık 2024 - minimum API 26, target API 35

                +

                31 Aralık 2024 - minimum API 26, target API 35

                • Add an option to sort bookmarks alphabetically.
                • Add "move to top" and "move to bottom" options for bookmarks.
                • diff --git a/app/src/main/assets/tr/about_licenses.html b/app/src/main/assets/tr/about_licenses.html index c1a5f6c6..684bb37f 100644 --- a/app/src/main/assets/tr/about_licenses.html +++ b/app/src/main/assets/tr/about_licenses.html @@ -1,20 +1,21 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -30,7 +31,7 @@

                  Telif Hakkı

                  -

                  Privacy Browser telif hakkı 2015-2024 Soren Stoutner.

                  +

                  Privacy Browser telif hakkı 2015-2025 Soren Stoutner.

                  Lisans

                  Privacy Browser GPLv3+ lisansı altında yayınlandı. Lisansın tam metni aşağıdadır. diff --git a/app/src/main/assets/zh-rCN/about_changelog.html b/app/src/main/assets/zh-rCN/about_changelog.html index 44b5ad59..04da575e 100644 --- a/app/src/main/assets/zh-rCN/about_changelog.html +++ b/app/src/main/assets/zh-rCN/about_changelog.html @@ -32,7 +32,7 @@

                  3.19 (version code 76)

                  -

                  31 December 2024 - 最低支持API 26, 最高支持API 35

                  +

                  31 December 2024 - 最低支持API 26, 最高支持API 35

                  • Add an option to sort bookmarks alphabetically.
                  • Add "move to top" and "move to bottom" options for bookmarks.
                  • diff --git a/app/src/main/assets/zh-rCN/about_licenses.html b/app/src/main/assets/zh-rCN/about_licenses.html index ac8c5520..ca3c73d3 100644 --- a/app/src/main/assets/zh-rCN/about_licenses.html +++ b/app/src/main/assets/zh-rCN/about_licenses.html @@ -1,22 +1,23 @@ + You should have received a copy of the GNU General Public License along with + this program. If not, see . --> @@ -32,7 +33,7 @@

                    Copyright

                    -

                    Privacy Browser copyright 2015-2024 Soren Stoutner.

                    +

                    Privacy Browser copyright 2015-2025 Soren Stoutner.

                    证书

                    Privacy Browser基于GPLv3+ license发布。 diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.kt index bd2a837d..85e05191 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.kt @@ -1,20 +1,20 @@ -/* - * Copyright 2016-2023 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2016-2023 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. * - * Privacy Browser Android is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser Android. If not, see . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ package com.stoutner.privacybrowser.activities 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 f0b89d98..62b46a82 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.kt @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2018-2024 Soren Stoutner + * SPDX-FileCopyrightText: 2018-2025 Soren Stoutner * * This file is part of Privacy Browser Android . * @@ -20,6 +20,7 @@ package com.stoutner.privacybrowser.activities import android.content.Intent +import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle import android.os.Handler @@ -235,8 +236,14 @@ class ImportExportActivity : AppCompatActivity() { // Display the home arrow on the support action bar. actionBar.setDisplayHomeAsUpEnabled(true) - // Find out if OpenKeychain is installed. If the safe call (`?.`) is null, the Elvis operator (`?"`) returns the following value instead, which is `false`. - openKeychainInstalled = packageManager.getPackageInfo("org.sufficientlysecure.keychain", 0).versionName?.isNotEmpty() ?: false + // Find out if OpenKeychain is installed. + openKeychainInstalled = try { + // If the safe call (`?.`) is null, the Elvis operator (`?"`) returns the following value instead, which is `false`. + packageManager.getPackageInfo("org.sufficientlysecure.keychain", 0).versionName?.isNotEmpty() ?: false + } catch (exception: PackageManager.NameNotFoundException) { + // The package is not installed + false + } // Get handles for the views. scrollView = findViewById(R.id.scrollview) 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 ad884b81..64a7dda4 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 @@ /* SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2016-2024 Soren Stoutner + * SPDX-FileCopyrightText: 2016-2025 Soren Stoutner * * This file is part of Privacy Browser Android . * @@ -397,8 +397,14 @@ class AboutVersionFragment : Fragment() { val webViewPackageName = webViewPackageInfo.packageName val webViewVersion = webViewPackageInfo.versionName - // Get the Orbot version name if Orbot is installed. If the safe call (`?.`) is null, the Elvis operator (`?"`) returns the following value instead, which is an empty string. - val orbot: String = requireContext().packageManager.getPackageInfo("org.torproject.android", 0)?.versionName ?: "" + // Get the Orbot version name if Orbot is installed. + val orbot: String = try { + // If the safe call (`?.`) is null, the Elvis operator (`?"`) returns the following value instead, which is an empty string. + requireContext().packageManager.getPackageInfo("org.torproject.android", 0).versionName ?: "" + } catch (exception: PackageManager.NameNotFoundException) { + // Store an empty string. + "" + } // Get the I2P version name if I2P is installed. val i2p: String = try { @@ -414,8 +420,14 @@ class AboutVersionFragment : Fragment() { } } - // Get the OpenKeychain version name if it is installed. If the safe call (`?.`) is null, the Elvis operator (`?"`) returns the following value instead, which is an empty string. - val openKeychain: String = requireContext().packageManager.getPackageInfo("org.sufficientlysecure.keychain", 0)?.versionName ?: "" + // Get the OpenKeychain version name if it is installed. + val openKeychain: String = try { + // If the safe call (`?.`) is null, the Elvis operator (`?"`) returns the following value instead, which is an empty string. + requireContext().packageManager.getPackageInfo("org.sufficientlysecure.keychain", 0).versionName ?: "" + } catch (exception: PackageManager.NameNotFoundException) { + // Store an empty string. + "" + } // Create a spannable string builder for the hardware and software text views that need multiple colors of text. val brandStringBuilder = SpannableStringBuilder(brandLabel + brand) -- 2.47.2