]> gitweb.stoutner.com Git - PrivacyCell.git/commitdiff
Make the additional info color always match the data color. https://redmine.stoutner...
authorSoren Stoutner <soren@stoutner.com>
Sat, 13 Dec 2025 22:37:50 +0000 (15:37 -0700)
committerSoren Stoutner <soren@stoutner.com>
Sat, 13 Dec 2025 22:37:50 +0000 (15:37 -0700)
app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt
app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt

index 3b89b88b4377b72963e6e8d0af7331ebe5f85446..2973c25aa7b5c33851257128080f0bef5abbbcee 100644 (file)
@@ -25,7 +25,6 @@ package com.stoutner.privacycell.activities
 import android.Manifest
 import android.annotation.SuppressLint
 import android.app.ActivityManager
-import android.content.Context
 import android.content.Intent
 import android.content.pm.PackageManager
 import android.os.Build
@@ -163,7 +162,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem
         val protocolHelper = ProtocolHelper()
 
         // Get a handle for the subscription manager.
-        val subscriptionManager = getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
+        val subscriptionManager = getSystemService(TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
 
         // Define the phone state listener.  The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31.
         phoneStateListener = object : PhoneStateListener() {
@@ -285,18 +284,25 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem
                 additionalNetworkInfoTextView.text = getString(R.string.additional_network_info, additionalNetworkInfoStringArray[0])
                 additionalNetworkInfoDetailsTextView.text = additionalNetworkInfoStringArray[1]
 
-                // Set the color of the data network.
+                // Set the color of the data network text views.
                 when (dataNetworkSecurityStatus) {
-                    ProtocolHelper.SECURE -> dataNetworkTextView.setTextColor(getColor(R.color.blue_text))
-                    ProtocolHelper.INSECURE -> dataNetworkTextView.setTextColor(getColor(R.color.yellow_text))
-                    ProtocolHelper.ANTIQUATED -> dataNetworkTextView.setTextColor(getColor(R.color.red_text))
-                }
+                    ProtocolHelper.SECURE -> {
+                        // Set the color of the data network text views to be blue.
+                        dataNetworkTextView.setTextColor(getColor(R.color.blue_text))
+                        additionalNetworkInfoTextView.setTextColor(getColor(R.color.blue_text))
+                    }
 
-                // Set the color of the additional network info.
-                when (protocolHelper.checkAdditionalNetworkInfo(additionalNetworkInfoTypeInt)) {
-                    ProtocolHelper.SECURE -> additionalNetworkInfoTextView.setTextColor(getColor(R.color.blue_text))
-                    ProtocolHelper.INSECURE -> additionalNetworkInfoTextView.setTextColor(getColor(R.color.yellow_text))
-                    ProtocolHelper.ANTIQUATED -> additionalNetworkInfoTextView.setTextColor(getColor(R.color.red_text))
+                    ProtocolHelper.INSECURE -> {
+                        // Set the color of the data network text views to be yellow.
+                        dataNetworkTextView.setTextColor(getColor(R.color.yellow_text))
+                        additionalNetworkInfoTextView.setTextColor(getColor(R.color.yellow_text))
+                    }
+
+                    ProtocolHelper.ANTIQUATED -> {
+                        // Set the color of the data network text views to be red.
+                        dataNetworkTextView.setTextColor(getColor(R.color.red_text))
+                        additionalNetworkInfoTextView.setTextColor(getColor(R.color.red_text))
+                    }
                 }
 
                 // Set the data network click listener.
@@ -355,7 +361,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem
         // Start the realtime monitoring service if it is enabled.
         if (realtimeMonitoring) {
             // Get a handle for the activity manager.
-            val activityManager: ActivityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
+            val activityManager: ActivityManager = getSystemService(ACTIVITY_SERVICE) as ActivityManager
 
             // Get a list of the running service info.  The deprecated `getRunningServices()` now only returns services stared by Privacy Cell, but that is all we want to know anyway.
             val runningServiceInfoList: List<ActivityManager.RunningServiceInfo> = activityManager.getRunningServices(1)
@@ -407,7 +413,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem
         super.onStop()
 
         // Get a handle for the telephony manager.
-        val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
+        val telephonyManager = getSystemService(TELEPHONY_SERVICE) as TelephonyManager
 
         // Unregister the telephony manager listener.  The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31.
         telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE)
@@ -567,7 +573,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem
 
     private fun registerTelephonyManagerListener() {
         // Get a handle for the telephony manager.
-        val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
+        val telephonyManager = getSystemService(TELEPHONY_SERVICE) as TelephonyManager
 
         // Listen to changes in the cell network state.  The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31.
         telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE or PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED)
index 8cc1bc966c759e7a8d8d59d8337ec983d24dca3d..90ff725393fc67258ae5f8f39fb96e13236fce31 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2023 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2023, 2025 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Cell <https://www.stoutner.com/privacy-cell/>.
  *
@@ -70,21 +70,6 @@ class ProtocolHelper {
         }
     }
 
-    fun checkAdditionalNetworkInfo(additionalNetworkInfoType: Int): Int {
-        return if ((additionalNetworkInfoType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE) ||
-                   (additionalNetworkInfoType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED)) {
-            // The additional network info is secure.
-            SECURE
-        } else {
-            // The additional network info is insecure.
-            // TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA
-            // TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO
-            // TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA
-            // TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -- Can be removed once the minimum API >= 31.
-            INSECURE
-        }
-    }
-
     fun getNetworkTypeStringArray(networkType: Int, context: Context) : Array<String> {
         // Return the string array that corresponds to the network type.  The deprecated `NETWORK_TYPE_IDEN` can be removed once the minimum API >= 34.
         @Suppress("DEPRECATION")