]> gitweb.stoutner.com Git - PrivacyCell.git/blobdiff - app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt
Add a logcat activity. https://redmine.stoutner.com/issues/768
[PrivacyCell.git] / app / src / main / java / com / stoutner / privacycell / activities / PrivacyCellActivity.kt
index cd0e1a1fcc10eb15355be338eb476418815f756d..618ef569cd052a79ca5cb67ff85cf119675a60d5 100644 (file)
@@ -55,8 +55,6 @@ import com.stoutner.privacycell.services.RealtimeMonitoringService
 
 class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener, PhonePermissionDialog.StoragePermissionDialogListener {
     // Declare the class variables.
-    private lateinit var context: Context
-    private lateinit var telephonyManager: TelephonyManager
     private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
 
     // Declare the views.
@@ -109,10 +107,6 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem
         additionalNetworkInfoDetailsTextView = findViewById(R.id.additional_network_info_details)
         val navigationView = findViewById<NavigationView>(R.id.navigationview)
 
-        // Get handles for the context and the telephony manager.
-        context = this
-        telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
-
         // Set the support action bar.
         setSupportActionBar(toolbar)
 
@@ -211,6 +205,14 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem
                 startActivity(settingsIntent)
             }
 
+            R.id.logcat -> {  // Logcat.
+                // Create an intent to load the Logcat activity.
+                val logcatIntent = Intent(this, LogcatActivity::class.java)
+
+                // Make it so.
+                startActivity(logcatIntent)
+            }
+
             R.id.permissions -> {  // Permissions.
                 // Instantiate the permissions dialog fragment.
                 val permissionsDialogFragment = WebViewDialog().type(WebViewDialog.PERMISSIONS)
@@ -337,6 +339,9 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem
     }
 
     private fun populatePrivacyCell(context: Context) {
+        // Get a handle for the telephony manager.
+        val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
+
         // Listen to changes in the cell network state.
         telephonyManager.listen(object : PhoneStateListener() {
             override fun onDisplayInfoChanged(telephonyDisplayInfo: TelephonyDisplayInfo) {