X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Factivities%2FPrivacyCell.kt;h=acdc97b6757a980dcb2eab2cfc7be47a2471d52b;hp=eec29e4f08b3626b2b8f1ef625859ca9a578cfcd;hb=1b722c3d327fa2d571abee745a115a1f54ab2a27;hpb=8484f5cbc7f74e008624d0cd13af4a6f964ee516 diff --git a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCell.kt b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCell.kt index eec29e4..acdc97b 100644 --- a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCell.kt +++ b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCell.kt @@ -14,14 +14,16 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Privacy Browser. If not, see . + * along with Privacy Cell. If not, see . */ package com.stoutner.privacycell.activities import android.Manifest import android.content.Context +import android.content.Intent import android.content.pm.PackageManager +import android.net.Uri import android.os.Bundle import android.telephony.PhoneStateListener import android.telephony.ServiceState @@ -30,6 +32,7 @@ import android.telephony.TelephonyManager import android.view.MenuItem import android.view.View import android.widget.ImageView +import android.widget.LinearLayout import android.widget.TextView import androidx.appcompat.app.ActionBar @@ -55,12 +58,16 @@ class PrivacyCell : AppCompatActivity(), NavigationView.OnNavigationItemSelected // Declare the views. private lateinit var drawerLayout: DrawerLayout - private lateinit var secureFromStingrayImageView: ImageView - private lateinit var secureFromStingrayTextView: TextView + private lateinit var stingrayLinearLayout: LinearLayout + private lateinit var stingrayImageView: ImageView + private lateinit var stingrayTextView: TextView + private lateinit var voiceNetworkLinearLayout: LinearLayout private lateinit var voiceNetworkTextView: TextView private lateinit var voiceNetworkDetailsTextView: TextView + private lateinit var dataNetworkLinearLayout: LinearLayout private lateinit var dataNetworkTextView: TextView private lateinit var dataNetworkDetailsTextView: TextView + private lateinit var additionalNetworkInfoLinearLayout: LinearLayout private lateinit var additionalNetworkInfoTextView: TextView private lateinit var additionalNetworkInfoDetailsTextView: TextView @@ -74,12 +81,16 @@ class PrivacyCell : AppCompatActivity(), NavigationView.OnNavigationItemSelected // Get handles for the views. drawerLayout = findViewById(R.id.drawerlayout) val toolbar = findViewById(R.id.toolbar) - secureFromStingrayImageView = findViewById(R.id.secure_from_stingray_imageview) - secureFromStingrayTextView = findViewById(R.id.secure_from_stingray_textview) + stingrayLinearLayout = findViewById(R.id.stingray_linearlayout) + stingrayImageView = findViewById(R.id.stingray_imageview) + stingrayTextView = findViewById(R.id.stingray_textview) + voiceNetworkLinearLayout = findViewById(R.id.voice_network_linearlayout) voiceNetworkTextView = findViewById(R.id.voice_network) voiceNetworkDetailsTextView = findViewById(R.id.voice_network_details) + dataNetworkLinearLayout = findViewById(R.id.data_network_linearlayout) dataNetworkTextView = findViewById(R.id.data_network) dataNetworkDetailsTextView = findViewById(R.id.data_network_details) + additionalNetworkInfoLinearLayout = findViewById(R.id.additional_network_info_linearlayout) additionalNetworkInfoTextView = findViewById(R.id.additional_network_info) additionalNetworkInfoDetailsTextView = findViewById(R.id.additional_network_info_details) val navigationView = findViewById(R.id.navigationview) @@ -203,6 +214,61 @@ class PrivacyCell : AppCompatActivity(), NavigationView.OnNavigationItemSelected // Show the alert dialog. contributorsDialogFragment.show(supportFragmentManager, getString(R.string.contributors)) } + + R.id.news -> { // News. + // Create a news URL intent. + val newsUrlIntent = Intent(Intent.ACTION_VIEW) + + // Add the URL to the intent. + newsUrlIntent.data = Uri.parse("https://www.stoutner.com/category/privacy-cell/") + + // Make it so. + startActivity(newsUrlIntent) + } + + R.id.roadmap -> { // Roadmap. + // Create a roadmap URL intent. + val roadmapUrlIntent = Intent(Intent.ACTION_VIEW) + + // Add the URL to the intent. + roadmapUrlIntent.data = Uri.parse("https://www.stoutner.com/category/privacy-cell-roadmap/") + + // Make it so. + startActivity(roadmapUrlIntent) + } + + R.id.bug_tracker -> { // Bug tracker. + // Create a bug tracker URL intent. + val bugTrackerUrlIntent = Intent(Intent.ACTION_VIEW) + + // Add the URL to the intent. + bugTrackerUrlIntent.data = Uri.parse("https://redmine.stoutner.com/projects/privacy-cell/issues") + + // Make it so. + startActivity(bugTrackerUrlIntent) + } + + R.id.forum -> { // Forum. + // Create a forum URL intent. + val forumUrlIntent = Intent(Intent.ACTION_VIEW) + + // Add the URL to the intent. + forumUrlIntent.data = Uri.parse("https://redmine.stoutner.com/projects/privacy-cell/boards") + + // Make it so. + startActivity(forumUrlIntent) + } + + R.id.donations -> { // Donations. + // Create a donations URL intent. + val donationsUrlIntent = Intent(Intent.ACTION_VIEW) + + // Add the URL to the intent. + donationsUrlIntent.data = Uri.parse("https://www.stoutner.com/donations/") + + // Make it so. + startActivity(donationsUrlIntent) + } } // Close the navigation drawer. @@ -229,7 +295,7 @@ class PrivacyCell : AppCompatActivity(), NavigationView.OnNavigationItemSelected populatePrivacyCell() } else { // The read phone state permission was denied. // Display the phone permission text on the main activity. - secureFromStingrayTextView.text = getString(R.string.phone_permission_text) + stingrayTextView.text = getString(R.string.phone_permission_text) } } } @@ -241,32 +307,88 @@ class PrivacyCell : AppCompatActivity(), NavigationView.OnNavigationItemSelected // Populate the stingray security information. if (telephonyDisplayInfo.networkType == TelephonyManager.NETWORK_TYPE_NR) { // This is a secure 5G NR SA network. // Populate the image view. - secureFromStingrayImageView.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.secure_5g_nr_sa)) + stingrayImageView.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.secure_5g_nr_sa)) // Set the text. - secureFromStingrayTextView.text = getString(R.string.secure_from_stingray) + stingrayTextView.text = getString(R.string.secure_from_stingray) // Set the text color. - secureFromStingrayTextView.setTextColor(getColor(R.color.blue_text)) + stingrayTextView.setTextColor(getColor(R.color.blue_text)) } else { // This is not a secure 5G NR SA network. // Populate the image view. - secureFromStingrayImageView.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.not_secure)) + stingrayImageView.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.not_secure)) // Set the text. - secureFromStingrayTextView.text = getString(R.string.not_secure_from_stingray) + stingrayTextView.text = getString(R.string.not_secure_from_stingray) // Set the text color. - secureFromStingrayTextView.setTextColor(getColor(R.color.red_text)) + stingrayTextView.setTextColor(getColor(R.color.red_text)) + } + + // Get the strings that correspond to the network information. + val dataNetworkType = getNetworkType(telephonyDisplayInfo.networkType) + val additionalNetworkInfo = getAdditionalNetworkInfo(telephonyDisplayInfo.overrideNetworkType) - // Get the strings that correspond to the network information. - val dataNetworkType = getNetworkType(telephonyDisplayInfo.networkType) - val additionalNetworkInfo = getAdditionalNetworkInfo(telephonyDisplayInfo.overrideNetworkType) + // Populate the data network text views. + dataNetworkTextView.text = getString(R.string.data_network, dataNetworkType[0]) + dataNetworkDetailsTextView.text = dataNetworkType[1] + additionalNetworkInfoTextView.text = getString(R.string.additional_network_info, additionalNetworkInfo[0]) + additionalNetworkInfoDetailsTextView.text = additionalNetworkInfo[1] - // Populate the data network text views. - dataNetworkTextView.text = getString(R.string.data_network, dataNetworkType[0]) - dataNetworkDetailsTextView.text = dataNetworkType[1] - additionalNetworkInfoTextView.text = getString(R.string.additional_network_info, additionalNetworkInfo[0]) - additionalNetworkInfoDetailsTextView.text = additionalNetworkInfo[1] + // Set the stingray click listener. + stingrayLinearLayout.setOnClickListener { + // Instantiate the stingray dialog fragment. + val stingrayDialogFragment = WebViewDialog().type(WebViewDialog.STINGRAY) + + // Show the alert dialog. + stingrayDialogFragment.show(supportFragmentManager, getString(R.string.stingrays)) + } + + // Set the data network click listener. + dataNetworkLinearLayout.setOnClickListener { + // Instantiate the data network dialog fragment according to the network type. + val dataNetworkDialogFragment = when (telephonyDisplayInfo.networkType) { + TelephonyManager.NETWORK_TYPE_UNKNOWN -> WebViewDialog().type(WebViewDialog.NETWORK_UNKNOWN) + TelephonyManager.NETWORK_TYPE_GPRS -> WebViewDialog().type(WebViewDialog.NETWORK_GPRS) + TelephonyManager.NETWORK_TYPE_EDGE -> WebViewDialog().type(WebViewDialog.NETWORK_EDGE) + TelephonyManager.NETWORK_TYPE_UMTS -> WebViewDialog().type(WebViewDialog.NETWORK_UMTS) + TelephonyManager.NETWORK_TYPE_CDMA -> WebViewDialog().type(WebViewDialog.NETWORK_CDMA) + TelephonyManager.NETWORK_TYPE_EVDO_0 -> WebViewDialog().type(WebViewDialog.NETWORK_EVDO_0) + TelephonyManager.NETWORK_TYPE_EVDO_A -> WebViewDialog().type(WebViewDialog.NETWORK_EVDO_A) + TelephonyManager.NETWORK_TYPE_1xRTT -> WebViewDialog().type(WebViewDialog.NETWORK_1xRTT) + TelephonyManager.NETWORK_TYPE_HSDPA -> WebViewDialog().type(WebViewDialog.NETWORK_HSDPA) + TelephonyManager.NETWORK_TYPE_HSUPA -> WebViewDialog().type(WebViewDialog.NETWORK_HSUPA) + TelephonyManager.NETWORK_TYPE_HSPA -> WebViewDialog().type(WebViewDialog.NETWORK_HSPA) + TelephonyManager.NETWORK_TYPE_IDEN -> WebViewDialog().type(WebViewDialog.NETWORK_IDEN) + TelephonyManager.NETWORK_TYPE_EVDO_B -> WebViewDialog().type(WebViewDialog.NETWORK_EVDO_B) + TelephonyManager.NETWORK_TYPE_LTE -> WebViewDialog().type(WebViewDialog.NETWORK_LTE) + TelephonyManager.NETWORK_TYPE_EHRPD -> WebViewDialog().type(WebViewDialog.NETWORK_EHRPD) + TelephonyManager.NETWORK_TYPE_HSPAP -> WebViewDialog().type(WebViewDialog.NETWORK_HSPAP) + TelephonyManager.NETWORK_TYPE_GSM -> WebViewDialog().type(WebViewDialog.NETWORK_GSM) + TelephonyManager.NETWORK_TYPE_TD_SCDMA -> WebViewDialog().type(WebViewDialog.NETWORK_TD_SCDMA) + TelephonyManager.NETWORK_TYPE_IWLAN -> WebViewDialog().type(WebViewDialog.NETWORK_IWLAN) + TelephonyManager.NETWORK_TYPE_NR -> WebViewDialog().type(WebViewDialog.NETWORK_NR) + else -> WebViewDialog().type(WebViewDialog.NETWORK_UNKNOWN) + } + + // Show the alert dialog. + dataNetworkDialogFragment.show(supportFragmentManager, getString(R.string.voice_network)) + } + + // Set the additional network info click listener. + additionalNetworkInfoLinearLayout.setOnClickListener { + // Instantiate the initial network info dialog fragment according to the network type. + val additionalNetworkInfoDialogFragment = when (telephonyDisplayInfo.overrideNetworkType) { + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NONE) + 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) + } + + // Show the alert dialog. + additionalNetworkInfoDialogFragment.show(supportFragmentManager, getString(R.string.voice_network)) } } @@ -280,6 +402,37 @@ class PrivacyCell : AppCompatActivity(), NavigationView.OnNavigationItemSelected // Populate the voice network text views. voiceNetworkTextView.text = getString(R.string.voice_network, voiceNetworkType[0]) voiceNetworkDetailsTextView.text = voiceNetworkType[1] + + // Set the voice network click listener. + voiceNetworkLinearLayout.setOnClickListener { + // Instantiate the voice network dialog fragment according to the network type. + val voiceNetworkDialogFragment = when (networkRegistrationInfo.accessNetworkTechnology) { + TelephonyManager.NETWORK_TYPE_UNKNOWN -> WebViewDialog().type(WebViewDialog.NETWORK_UNKNOWN) + TelephonyManager.NETWORK_TYPE_GPRS -> WebViewDialog().type(WebViewDialog.NETWORK_GPRS) + TelephonyManager.NETWORK_TYPE_EDGE -> WebViewDialog().type(WebViewDialog.NETWORK_EDGE) + TelephonyManager.NETWORK_TYPE_UMTS -> WebViewDialog().type(WebViewDialog.NETWORK_UMTS) + TelephonyManager.NETWORK_TYPE_CDMA -> WebViewDialog().type(WebViewDialog.NETWORK_CDMA) + TelephonyManager.NETWORK_TYPE_EVDO_0 -> WebViewDialog().type(WebViewDialog.NETWORK_EVDO_0) + TelephonyManager.NETWORK_TYPE_EVDO_A -> WebViewDialog().type(WebViewDialog.NETWORK_EVDO_A) + TelephonyManager.NETWORK_TYPE_1xRTT -> WebViewDialog().type(WebViewDialog.NETWORK_1xRTT) + TelephonyManager.NETWORK_TYPE_HSDPA -> WebViewDialog().type(WebViewDialog.NETWORK_HSDPA) + TelephonyManager.NETWORK_TYPE_HSUPA -> WebViewDialog().type(WebViewDialog.NETWORK_HSUPA) + TelephonyManager.NETWORK_TYPE_HSPA -> WebViewDialog().type(WebViewDialog.NETWORK_HSPA) + TelephonyManager.NETWORK_TYPE_IDEN -> WebViewDialog().type(WebViewDialog.NETWORK_IDEN) + TelephonyManager.NETWORK_TYPE_EVDO_B -> WebViewDialog().type(WebViewDialog.NETWORK_EVDO_B) + TelephonyManager.NETWORK_TYPE_LTE -> WebViewDialog().type(WebViewDialog.NETWORK_LTE) + TelephonyManager.NETWORK_TYPE_EHRPD -> WebViewDialog().type(WebViewDialog.NETWORK_EHRPD) + TelephonyManager.NETWORK_TYPE_HSPAP -> WebViewDialog().type(WebViewDialog.NETWORK_HSPAP) + TelephonyManager.NETWORK_TYPE_GSM -> WebViewDialog().type(WebViewDialog.NETWORK_GSM) + TelephonyManager.NETWORK_TYPE_TD_SCDMA -> WebViewDialog().type(WebViewDialog.NETWORK_TD_SCDMA) + TelephonyManager.NETWORK_TYPE_IWLAN -> WebViewDialog().type(WebViewDialog.NETWORK_IWLAN) + TelephonyManager.NETWORK_TYPE_NR -> WebViewDialog().type(WebViewDialog.NETWORK_NR) + else -> WebViewDialog().type(WebViewDialog.NETWORK_UNKNOWN) + } + + // Show the alert dialog. + voiceNetworkDialogFragment.show(supportFragmentManager, getString(R.string.voice_network)) + } } }, PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED or PhoneStateListener.LISTEN_SERVICE_STATE) } @@ -288,7 +441,7 @@ class PrivacyCell : AppCompatActivity(), NavigationView.OnNavigationItemSelected // Return the string that corresponds to the network type. return when(networkType) { TelephonyManager.NETWORK_TYPE_UNKNOWN -> arrayOf(getString(R.string.unknown), "") - TelephonyManager.NETWORK_TYPE_GPRS -> arrayOf(getString(R.string.gprs), getString(R.string.gprs_detal)) + TelephonyManager.NETWORK_TYPE_GPRS -> arrayOf(getString(R.string.gprs), getString(R.string.gprs_detail)) TelephonyManager.NETWORK_TYPE_EDGE -> arrayOf(getString(R.string.edge), getString(R.string.edge_detail)) TelephonyManager.NETWORK_TYPE_UMTS -> arrayOf(getString(R.string.umts), getString(R.string.umts_detail)) TelephonyManager.NETWORK_TYPE_CDMA -> arrayOf(getString(R.string.cdma), getString(R.string.cdma_detail)) @@ -317,8 +470,8 @@ class PrivacyCell : AppCompatActivity(), NavigationView.OnNavigationItemSelected TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE -> arrayOf(getString(R.string.none), "") 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.lte_nr_nsa), getString(R.string.lte_nr_nsa_detail)) - TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> arrayOf(getString(R.string.lte_nr_nsa_mmwave), getString(R.string.lte_nr_nsa_mmwave_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)) else -> arrayOf(getString(R.string.error), "") } }