X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Factivities%2FPrivacyCellActivity.kt;h=55d7c92e4111d2cc3a58af10497b715093ba3955;hp=13cfe7bda17cd00a996ae16b5303fb76b3160e91;hb=5d8e96c54cad4115e962eac556c10f871807f02f;hpb=fb7c0422487bfb7cbb65427468c2688c24b4b99b 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 13cfe7b..55d7c92 100644 --- a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt +++ b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt @@ -26,7 +26,7 @@ import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle -import android.telephony.PhoneStateListener +import android.telephony.PhoneStateListener // This can be replaced by `TelephonyCallback` once the minimum API >= 31. import android.telephony.ServiceState import android.telephony.TelephonyDisplayInfo import android.telephony.TelephonyManager @@ -56,7 +56,7 @@ import com.stoutner.privacycell.services.RealtimeMonitoringService class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener, PhonePermissionDialog.StoragePermissionDialogListener { // Declare the class variables. private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle - private lateinit var phoneStateListener: PhoneStateListener + private lateinit var phoneStateListener: PhoneStateListener // The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. // Declare the class views. private lateinit var drawerLayout: DrawerLayout @@ -135,7 +135,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem } }) - // Define the phone state listener. + // Define the phone state listener. The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. phoneStateListener = object : PhoneStateListener() { override fun onDisplayInfoChanged(telephonyDisplayInfo: TelephonyDisplayInfo) { // Populate the stingray security information. @@ -217,8 +217,9 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_LTE_CA) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_LTE_ADVANCED_PRO) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_NSA) - TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_NSA_MMWAVE) - else -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_NSA_MMWAVE) + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_NSA_MMWAVE) // Can be removed once the minimum API >= 31. + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_ADVANCED) + else -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NONE) } // Show the alert dialog. @@ -326,7 +327,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem // Get a handle for the telephony manager. val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager - // Unregister the telephony manager listener. + // Unregister the telephony manager listener. The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE) } @@ -478,7 +479,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem // Get a handle for the telephony manager. val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager - // Listen to changes in the cell network state. + // 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_DISPLAY_INFO_CHANGED or PhoneStateListener.LISTEN_SERVICE_STATE) } @@ -516,7 +517,8 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA -> arrayOf(getString(R.string.lte_ca), getString(R.string.lte_ca_detail)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO -> arrayOf(getString(R.string.lte_advanced_pro), getString(R.string.lte_advanced_pro_detail)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA -> arrayOf(getString(R.string.nr_nsa), getString(R.string.nr_nsa_detail)) - TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> arrayOf(getString(R.string.nr_nsa_mmwave), getString(R.string.nr_nsa_mmwave_detail)) + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> arrayOf(getString(R.string.nr_nsa_mmwave), getString(R.string.nr_nsa_mmwave_detail)) // Can be removed once the minimum API >= 31. + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED -> arrayOf(getString(R.string.nr_advanced), getString(R.string.nr_advanced_detail)) else -> arrayOf(getString(R.string.error), "") } }