From: Soren Stoutner Date: Sat, 13 Dec 2025 22:37:50 +0000 (-0700) Subject: Make the additional info color always match the data color. https://redmine.stoutner... X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=ec35747b95487df8a2bc9d391ff05a2b083f84d7;p=PrivacyCell.git Make the additional info color always match the data color. https://redmine.stoutner.com/issues/1282 --- diff --git a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt index 3b89b88..2973c25 100644 --- a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt +++ b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt @@ -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.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) diff --git a/app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt b/app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt index 8cc1bc9..90ff725 100644 --- a/app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt +++ b/app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2022-2023 Soren Stoutner + * SPDX-FileCopyrightText: 2022-2023, 2025 Soren Stoutner * * This file is part of 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 { // 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")