From 45b64d4cf242b28abd6747681086f0a080fca009 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 12 Oct 2021 16:46:31 -0700 Subject: [PATCH] Add a logcat activity. https://redmine.stoutner.com/issues/768 --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 9 +- app/src/main/assets/en/licenses.html | 4 + app/src/main/assets/es/licenses.html | 4 + app/src/main/assets/fr/licenses.html | 4 + .../main/assets/images/bug_report_rounded.svg | 10 +- .../assets/images/call_to_action_rounded.svg | 10 +- .../images/chrome_reader_mode_rounded.svg | 10 +- app/src/main/assets/images/close_rounded.svg | 30 ++ .../assets/images/content_copy_outlined.svg | 30 ++ .../assets/images/fact_check_outlined.svg | 54 ++-- .../images/format_list_bulleted_rounded.svg | 10 +- app/src/main/assets/images/forum_rounded.svg | 10 +- app/src/main/assets/images/groups_filled.svg | 10 +- .../main/assets/images/list_alt_rounded.svg | 30 ++ app/src/main/assets/images/map_rounded.svg | 10 +- app/src/main/assets/images/not_secure.svg | 46 +-- .../main/assets/images/payments_rounded.svg | 10 +- .../assets/images/phone_android_outlined.svg | 10 +- app/src/main/assets/images/policy_filled.svg | 18 +- app/src/main/assets/images/privacy_cell.svg | 62 ++--- app/src/main/assets/images/save_outlined.svg | 30 ++ .../main/assets/images/settings_rounded.svg | 10 +- .../assets/images/text_snippet_outlined.svg | 10 +- app/src/main/assets/it/licenses.html | 4 + app/src/main/assets/ru/licenses.html | 4 + .../privacycell/activities/LogcatActivity.kt | 263 ++++++++++++++++++ .../activities/PrivacyCellActivity.kt | 8 + app/src/main/res/drawable/clear.xml | 13 + app/src/main/res/drawable/copy.xml | 14 + app/src/main/res/drawable/logcat.xml | 14 + app/src/main/res/drawable/save.xml | 13 + .../main/res/layout/logcat_bottom_appbar.xml | 67 +++++ app/src/main/res/layout/logcat_top_appbar.xml | 64 +++++ app/src/main/res/menu/logcat_options_menu.xml | 45 +++ .../menu/navigation_menu_bottom_appbar.xml | 8 +- .../res/menu/navigation_menu_top_appbar.xml | 26 +- app/src/main/res/values-es/strings.xml | 20 +- app/src/main/res/values-fr/strings.xml | 20 +- app/src/main/res/values-it/strings.xml | 20 +- app/src/main/res/values-night/colors.xml | 9 + app/src/main/res/values-ru/strings.xml | 20 +- app/src/main/res/values/colors.xml | 9 + app/src/main/res/values/strings.xml | 32 ++- 44 files changed, 898 insertions(+), 207 deletions(-) create mode 100644 app/src/main/assets/images/close_rounded.svg create mode 100644 app/src/main/assets/images/content_copy_outlined.svg create mode 100644 app/src/main/assets/images/list_alt_rounded.svg create mode 100644 app/src/main/assets/images/save_outlined.svg create mode 100644 app/src/main/java/com/stoutner/privacycell/activities/LogcatActivity.kt create mode 100644 app/src/main/res/drawable/clear.xml create mode 100644 app/src/main/res/drawable/copy.xml create mode 100644 app/src/main/res/drawable/logcat.xml create mode 100644 app/src/main/res/drawable/save.xml create mode 100644 app/src/main/res/layout/logcat_bottom_appbar.xml create mode 100644 app/src/main/res/layout/logcat_top_appbar.xml create mode 100644 app/src/main/res/menu/logcat_options_menu.xml diff --git a/app/build.gradle b/app/build.gradle index 58c3959..5c2d717 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,6 +52,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.core:core-ktx:1.6.0' implementation 'androidx.preference:preference-ktx:1.1.1' + implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.webkit:webkit:1.4.0' implementation 'androidx.work:work-runtime-ktx:2.6.0' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4400b2c..2196ce8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -61,13 +61,20 @@ - + + + + diff --git a/app/src/main/assets/en/licenses.html b/app/src/main/assets/en/licenses.html index a370ba5..c6914ce 100644 --- a/app/src/main/assets/en/licenses.html +++ b/app/src/main/assets/en/licenses.html @@ -55,14 +55,18 @@

bug_report_rounded.

call_to_action_rounded.

chrome_reader_mode_rounded.

+

close_rounded.

+

content_copy_outlined.

fact_checked_outlined.

format_list_bulleted_rounded.

forum_rounded.

groups_filled.

+

list_alt_rounded.

map_rounded.

payments_rounded.

phone_android_outlined.

policy_filled.

+

save_outlined.

settings_rounded.

text_snippet_outlined.

diff --git a/app/src/main/assets/es/licenses.html b/app/src/main/assets/es/licenses.html index 8eb61d5..cae1254 100644 --- a/app/src/main/assets/es/licenses.html +++ b/app/src/main/assets/es/licenses.html @@ -58,14 +58,18 @@

bug_report_rounded.

call_to_action_rounded.

chrome_reader_mode_rounded.

+

close_rounded.

+

content_copy_outlined.

fact_checked_outlined.

format_list_bulleted_rounded.

forum_rounded.

groups_filled.

+

list_alt_rounded.

map_rounded.

payments_rounded.

phone_android_outlined.

policy_filled.

+

save_outlined.

settings_rounded.

text_snippet_outlined.

diff --git a/app/src/main/assets/fr/licenses.html b/app/src/main/assets/fr/licenses.html index cb7f10c..7855e78 100644 --- a/app/src/main/assets/fr/licenses.html +++ b/app/src/main/assets/fr/licenses.html @@ -57,14 +57,18 @@

bug_report_rounded.

call_to_action_rounded.

chrome_reader_mode_rounded.

+

close_rounded.

+

content_copy_outlined.

fact_checked_outlined.

format_list_bulleted_rounded.

forum_rounded.

groups_filled.

+

list_alt_rounded.

map_rounded.

payments_rounded.

phone_android_outlined.

policy_filled.

+

save_outlined.

settings_rounded.

text_snippet_outlined.

diff --git a/app/src/main/assets/images/bug_report_rounded.svg b/app/src/main/assets/images/bug_report_rounded.svg index fbac78c..3ec48b0 100644 --- a/app/src/main/assets/images/bug_report_rounded.svg +++ b/app/src/main/assets/images/bug_report_rounded.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/call_to_action_rounded.svg b/app/src/main/assets/images/call_to_action_rounded.svg index e81a073..9921a52 100644 --- a/app/src/main/assets/images/call_to_action_rounded.svg +++ b/app/src/main/assets/images/call_to_action_rounded.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/chrome_reader_mode_rounded.svg b/app/src/main/assets/images/chrome_reader_mode_rounded.svg index 5d92442..855df2c 100644 --- a/app/src/main/assets/images/chrome_reader_mode_rounded.svg +++ b/app/src/main/assets/images/chrome_reader_mode_rounded.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/close_rounded.svg b/app/src/main/assets/images/close_rounded.svg new file mode 100644 index 0000000..f895cea --- /dev/null +++ b/app/src/main/assets/images/close_rounded.svg @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/app/src/main/assets/images/content_copy_outlined.svg b/app/src/main/assets/images/content_copy_outlined.svg new file mode 100644 index 0000000..3c33f2d --- /dev/null +++ b/app/src/main/assets/images/content_copy_outlined.svg @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/app/src/main/assets/images/fact_check_outlined.svg b/app/src/main/assets/images/fact_check_outlined.svg index 91cb8af..2bcbcd6 100644 --- a/app/src/main/assets/images/fact_check_outlined.svg +++ b/app/src/main/assets/images/fact_check_outlined.svg @@ -21,31 +21,31 @@ along with Privacy Cell. If not, see . --> - - - - - - - - - - + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 20 20" + id="icon" > + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/images/format_list_bulleted_rounded.svg b/app/src/main/assets/images/format_list_bulleted_rounded.svg index b1f2851..4ea9b14 100644 --- a/app/src/main/assets/images/format_list_bulleted_rounded.svg +++ b/app/src/main/assets/images/format_list_bulleted_rounded.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/forum_rounded.svg b/app/src/main/assets/images/forum_rounded.svg index 50edc80..0179ccf 100644 --- a/app/src/main/assets/images/forum_rounded.svg +++ b/app/src/main/assets/images/forum_rounded.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/groups_filled.svg b/app/src/main/assets/images/groups_filled.svg index d2aee47..72b0f80 100644 --- a/app/src/main/assets/images/groups_filled.svg +++ b/app/src/main/assets/images/groups_filled.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/list_alt_rounded.svg b/app/src/main/assets/images/list_alt_rounded.svg new file mode 100644 index 0000000..c07743c --- /dev/null +++ b/app/src/main/assets/images/list_alt_rounded.svg @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/app/src/main/assets/images/map_rounded.svg b/app/src/main/assets/images/map_rounded.svg index 201f4c5..84bafe2 100644 --- a/app/src/main/assets/images/map_rounded.svg +++ b/app/src/main/assets/images/map_rounded.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/not_secure.svg b/app/src/main/assets/images/not_secure.svg index b97f532..adfa508 100644 --- a/app/src/main/assets/images/not_secure.svg +++ b/app/src/main/assets/images/not_secure.svg @@ -21,27 +21,27 @@ along with Privacy Cell. If not, see . --> - - - - - - - - - - - - - - - + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 256 256" > + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/images/payments_rounded.svg b/app/src/main/assets/images/payments_rounded.svg index d252807..8a9b2b6 100644 --- a/app/src/main/assets/images/payments_rounded.svg +++ b/app/src/main/assets/images/payments_rounded.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/phone_android_outlined.svg b/app/src/main/assets/images/phone_android_outlined.svg index 1b95ff9..cdf565f 100644 --- a/app/src/main/assets/images/phone_android_outlined.svg +++ b/app/src/main/assets/images/phone_android_outlined.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/policy_filled.svg b/app/src/main/assets/images/policy_filled.svg index abae45e..84820fe 100644 --- a/app/src/main/assets/images/policy_filled.svg +++ b/app/src/main/assets/images/policy_filled.svg @@ -21,15 +21,15 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 20 20" + id="icon" > - + - + \ No newline at end of file diff --git a/app/src/main/assets/images/privacy_cell.svg b/app/src/main/assets/images/privacy_cell.svg index 4119232..24ed58a 100644 --- a/app/src/main/assets/images/privacy_cell.svg +++ b/app/src/main/assets/images/privacy_cell.svg @@ -21,36 +21,36 @@ along with Privacy Cell. If not, see . --> - - - - - - - - - - - - - - - - - - - - + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 256 256" > + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file diff --git a/app/src/main/assets/images/save_outlined.svg b/app/src/main/assets/images/save_outlined.svg new file mode 100644 index 0000000..d5ab83d --- /dev/null +++ b/app/src/main/assets/images/save_outlined.svg @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/app/src/main/assets/images/settings_rounded.svg b/app/src/main/assets/images/settings_rounded.svg index 85b72e6..e68c928 100644 --- a/app/src/main/assets/images/settings_rounded.svg +++ b/app/src/main/assets/images/settings_rounded.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + \ No newline at end of file diff --git a/app/src/main/assets/images/text_snippet_outlined.svg b/app/src/main/assets/images/text_snippet_outlined.svg index ca49d3e..121240c 100644 --- a/app/src/main/assets/images/text_snippet_outlined.svg +++ b/app/src/main/assets/images/text_snippet_outlined.svg @@ -21,10 +21,10 @@ along with Privacy Cell. If not, see . --> + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + id="icon" > - + diff --git a/app/src/main/assets/it/licenses.html b/app/src/main/assets/it/licenses.html index 3a00ff0..a16c917 100644 --- a/app/src/main/assets/it/licenses.html +++ b/app/src/main/assets/it/licenses.html @@ -58,14 +58,18 @@

bug_report_rounded.

call_to_action_rounded.

chrome_reader_mode_rounded.

+

close_rounded.

+

content_copy_outlined.

fact_checked_outlined.

format_list_bulleted_rounded.

forum_rounded.

groups_filled.

+

list_alt_rounded.

map_rounded.

payments_rounded.

phone_android_outlined.

policy_filled.

+

save_outlined.

settings_rounded.

text_snippet_outlined.

diff --git a/app/src/main/assets/ru/licenses.html b/app/src/main/assets/ru/licenses.html index a370ba5..c6914ce 100644 --- a/app/src/main/assets/ru/licenses.html +++ b/app/src/main/assets/ru/licenses.html @@ -55,14 +55,18 @@

bug_report_rounded.

call_to_action_rounded.

chrome_reader_mode_rounded.

+

close_rounded.

+

content_copy_outlined.

fact_checked_outlined.

format_list_bulleted_rounded.

forum_rounded.

groups_filled.

+

list_alt_rounded.

map_rounded.

payments_rounded.

phone_android_outlined.

policy_filled.

+

save_outlined.

settings_rounded.

text_snippet_outlined.

diff --git a/app/src/main/java/com/stoutner/privacycell/activities/LogcatActivity.kt b/app/src/main/java/com/stoutner/privacycell/activities/LogcatActivity.kt new file mode 100644 index 0000000..122ccc5 --- /dev/null +++ b/app/src/main/java/com/stoutner/privacycell/activities/LogcatActivity.kt @@ -0,0 +1,263 @@ +/* + * Copyright © 2021 Soren Stoutner . + * + * This file is part of Privacy Cell . + * + * Privacy Cell is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Privacy Cell is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Privacy Cell. If not, see . + */ + +package com.stoutner.privacycell.activities + +import android.content.ClipData +import android.content.ClipboardManager +import android.net.Uri +import android.os.Bundle +import android.provider.OpenableColumns +import android.util.TypedValue +import android.view.Menu +import android.view.MenuItem +import android.widget.ScrollView +import android.widget.TextView + +import androidx.activity.result.contract.ActivityResultContracts +import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.widget.Toolbar +import androidx.preference.PreferenceManager +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout + +import com.google.android.material.snackbar.Snackbar + +import com.stoutner.privacycell.R + +import java.io.BufferedReader +import java.io.IOException +import java.io.InputStreamReader +import java.lang.Exception +import java.nio.charset.StandardCharsets + +// Define the class constants. +private const val SCROLLVIEW_POSITION = "scrollview_position" + +class LogcatActivity : AppCompatActivity() { + // Define the class variables. + private var scrollViewYPositionInt = 0 + + // Define the class views. + private lateinit var swipeRefreshLayout: SwipeRefreshLayout + private lateinit var logcatScrollView: ScrollView + private lateinit var logcatTextView: TextView + + // Define the save logcat activity result launcher. + private val saveLogcatActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument()) { fileNameUri: Uri? -> + // Only save the file if the URI is not null, which happens if the user exited the file picker by pressing back. + if (fileNameUri != null) { + try { + // Get the logcat as a string. + val logcatString = logcatTextView.text.toString() + + // Open an output stream. + val outputStream = contentResolver.openOutputStream(fileNameUri)!! + + // Write the logcat string to the output stream. + outputStream.write(logcatString.toByteArray(StandardCharsets.UTF_8)) + + // Close the output stream. + outputStream.close() + + // Get a cursor from the content resolver. + val contentResolverCursor = contentResolver.query(fileNameUri, null, null, null)!! + + // Move to the first row. + contentResolverCursor.moveToFirst() + + // Get the file name from the cursor. + val fileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)) + + // Close the cursor. + contentResolverCursor.close() + + // Display a snackbar with the saved logcat information. + Snackbar.make(logcatTextView, getString(R.string.logcat_saved, fileNameString), Snackbar.LENGTH_SHORT).show() + } catch (exception: Exception) { + // Display a snackbar with the error message. + Snackbar.make(logcatTextView, getString(R.string.error_saving_logcat, exception.toString()), Snackbar.LENGTH_INDEFINITE).show() + } + } + } + + public override fun onCreate(savedInstanceState: Bundle?) { + // Run the default commands. + super.onCreate(savedInstanceState) + + // Get a handle for the shared preferences. + val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) + + // Get the bottom app bar preference. + val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false) + + // Set the content view. + if (bottomAppBar) { + setContentView(R.layout.logcat_bottom_appbar) + } else { + setContentView(R.layout.logcat_top_appbar) + } + + // Get handles for the views. + val toolbar = findViewById(R.id.toolbar) + swipeRefreshLayout = findViewById(R.id.swiperefreshlayout) + logcatScrollView = findViewById(R.id.scrollview) + logcatTextView = findViewById(R.id.logcat_textview) + + // Set the toolbar as the action bar. + setSupportActionBar(toolbar) + + // Get a handle for the action bar. + val actionBar = supportActionBar!! + + // Display the back arrow in the action bar. + actionBar.setDisplayHomeAsUpEnabled(true) + + // Implement swipe to refresh. + swipeRefreshLayout.setOnRefreshListener { + // Get the current logcat. + getLogcat() + } + + // Set the swipe refresh color scheme according to the theme. + swipeRefreshLayout.setColorSchemeResources(R.color.blue_text) + + // Initialize a color background typed value. + val colorBackgroundTypedValue = TypedValue() + + // Get the color background from the theme. + theme.resolveAttribute(android.R.attr.colorBackground, colorBackgroundTypedValue, true) + + // Get the color background int from the typed value. + val colorBackgroundInt = colorBackgroundTypedValue.data + + // Set the swipe refresh background color. + swipeRefreshLayout.setProgressBackgroundColorSchemeColor(colorBackgroundInt) + + // Check to see if the activity has been restarted. + if (savedInstanceState != null) { + // Get the saved scrollview position. + scrollViewYPositionInt = savedInstanceState.getInt(SCROLLVIEW_POSITION) + } + + // Get the logcat. + getLogcat() + } + + override fun onCreateOptionsMenu(menu: Menu): Boolean { + // Inflate the menu. This adds items to the action bar. + menuInflater.inflate(R.menu.logcat_options_menu, menu) + + // Display the menu. + return true + } + + override fun onOptionsItemSelected(menuItem: MenuItem): Boolean { + // Run the commands that correlate to the selected menu item. + return when (menuItem.itemId) { + R.id.copy -> { // Copy was selected. + // Get a handle for the clipboard manager. + val clipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager + + // Save the logcat in a clip data. + val logcatClipData = ClipData.newPlainText(getString(R.string.logcat), logcatTextView.text) + + // Place the clip data on the clipboard. + clipboardManager.setPrimaryClip(logcatClipData) + + // Display a snackbar. + Snackbar.make(logcatTextView, R.string.logcat_copied, Snackbar.LENGTH_SHORT).show() + + // Consume the event. + true + } + + R.id.save -> { // Save was selected. + // Open the file picker. + saveLogcatActivityResultLauncher.launch(getString(R.string.privacy_cell_logcat_txt)) + + // Consume the event. + true + } + + R.id.clear -> { // Clear was selected. + try { + // Clear the logcat. `-c` clears the logcat. `-b all` clears all the buffers (instead of just crash, main, and system). + val process = Runtime.getRuntime().exec("logcat -b all -c") + + // Wait for the process to finish. + process.waitFor() + + // Reset the scroll view Y position int. + scrollViewYPositionInt = 0 + + // Reload the logcat. + getLogcat() + } catch (exception: Exception) { + // Do nothing. + } + + // Consume the event. + true + } + + else -> { // The home button was pushed. + // Do not consume the event. The system will process the home command. + super.onOptionsItemSelected(menuItem) + } + } + } + + public override fun onSaveInstanceState(savedInstanceState: Bundle) { + // Run the default commands. + super.onSaveInstanceState(savedInstanceState) + + // Get the scrollview Y position. + val scrollViewYPositionInt = logcatScrollView.scrollY + + // Store the scrollview Y position in the bundle. + savedInstanceState.putInt(SCROLLVIEW_POSITION, scrollViewYPositionInt) + } + + private fun getLogcat() { + try { + // Get the logcat. `-b all` gets all the buffers (instead of just crash, main, and system). `-v long` produces more complete information. `-d` dumps the logcat and exits. + val getLogcatProcess = Runtime.getRuntime().exec("logcat -b all -v long -d") + + // Wrap the logcat in a buffered reader. + val logcatBufferedReader = BufferedReader(InputStreamReader(getLogcatProcess.inputStream)) + + // Display the logcat. + logcatTextView.text = logcatBufferedReader.readText() + + // Close the buffered reader. + logcatBufferedReader.close() + } catch (exception: IOException) { + // Do nothing. + } + + // Update the scroll position after the text is populated. + logcatTextView.post { + // Set the scroll position. + logcatScrollView.scrollY = scrollViewYPositionInt + } + + // Stop the swipe to refresh animation if it is displayed. + swipeRefreshLayout.isRefreshing = false + } +} \ No newline at end of file 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 091586f..618ef56 100644 --- a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt +++ b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt @@ -205,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) diff --git a/app/src/main/res/drawable/clear.xml b/app/src/main/res/drawable/clear.xml new file mode 100644 index 0000000..35870ea --- /dev/null +++ b/app/src/main/res/drawable/clear.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/copy.xml b/app/src/main/res/drawable/copy.xml new file mode 100644 index 0000000..f51eb87 --- /dev/null +++ b/app/src/main/res/drawable/copy.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/logcat.xml b/app/src/main/res/drawable/logcat.xml new file mode 100644 index 0000000..1024d6a --- /dev/null +++ b/app/src/main/res/drawable/logcat.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/save.xml b/app/src/main/res/drawable/save.xml new file mode 100644 index 0000000..1705dc1 --- /dev/null +++ b/app/src/main/res/drawable/save.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/logcat_bottom_appbar.xml b/app/src/main/res/layout/logcat_bottom_appbar.xml new file mode 100644 index 0000000..49d9adb --- /dev/null +++ b/app/src/main/res/layout/logcat_bottom_appbar.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/logcat_top_appbar.xml b/app/src/main/res/layout/logcat_top_appbar.xml new file mode 100644 index 0000000..3e3a53a --- /dev/null +++ b/app/src/main/res/layout/logcat_top_appbar.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/logcat_options_menu.xml b/app/src/main/res/menu/logcat_options_menu.xml new file mode 100644 index 0000000..f81aa28 --- /dev/null +++ b/app/src/main/res/menu/logcat_options_menu.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/navigation_menu_bottom_appbar.xml b/app/src/main/res/menu/navigation_menu_bottom_appbar.xml index cdbf1d8..7173dd6 100644 --- a/app/src/main/res/menu/navigation_menu_bottom_appbar.xml +++ b/app/src/main/res/menu/navigation_menu_bottom_appbar.xml @@ -87,10 +87,16 @@ + + + android:orderInCategory="120" /> \ No newline at end of file diff --git a/app/src/main/res/menu/navigation_menu_top_appbar.xml b/app/src/main/res/menu/navigation_menu_top_appbar.xml index 7b18f98..2504912 100644 --- a/app/src/main/res/menu/navigation_menu_top_appbar.xml +++ b/app/src/main/res/menu/navigation_menu_top_appbar.xml @@ -25,37 +25,43 @@ android:icon="@drawable/settings" android:orderInCategory="10" /> + + + android:orderInCategory="30" /> + android:orderInCategory="40" /> + android:orderInCategory="50" /> + android:orderInCategory="60" /> + android:orderInCategory="70" /> @@ -64,25 +70,25 @@ android:id="@+id/news" android:title="@string/news" android:icon="@drawable/news" - android:orderInCategory="70" /> + android:orderInCategory="80" /> + android:orderInCategory="90" /> + android:orderInCategory="100" /> + android:orderInCategory="110" /> @@ -91,6 +97,6 @@ android:id="@+id/donations" android:title="@string/donations" android:icon="@drawable/donations" - android:orderInCategory="110" /> + android:orderInCategory="120" /> \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 99cbee6..51db896 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -49,16 +49,6 @@ Foro Donaciones - - Monitorización - Monitorización en tiempo real - Coloca un icono en la barra de estado que monitoriza la red celular. - Notificación de red segura - Notificación de red insegura - Interfaz - Barra inferior de app - Mueve la barra de aplicaciones a la parte inferior de la pantalla. Al cambiar esta configuración se reiniciará Privacy Cell. - Desconocido GPRS – 2.5G/3G @@ -121,6 +111,16 @@ Stingrays Cerrar + + Monitorización + Monitorización en tiempo real + Coloca un icono en la barra de estado que monitoriza la red celular. + Notificación de red segura + Notificación de red insegura + Interfaz + Barra inferior de app + Mueve la barra de aplicaciones a la parte inferior de la pantalla. Al cambiar esta configuración se reiniciará Privacy Cell. + Seguro Inseguro diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b3d3a56..ebf3c6b 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -49,16 +49,6 @@ Forum Dons - - Supervision - Supervision en temps-réel - Placez une icône dans la barre d\'état qui surveille le réseau cellulaire. - Notification de réseau sécurisé - Notification de réseau non sécurisé - Interface - Barre d\'apps inférieure - Déplacer la barre d\'apps en bas de l\'écran. La modification de ce paramètre entraîne le redémarrage de Privacy Cell. - Inconnu GPRS – 2.5G/3G @@ -121,6 +111,16 @@ IMSI-catcher Fermer + + Supervision + Supervision en temps-réel + Placez une icône dans la barre d\'état qui surveille le réseau cellulaire. + Notification de réseau sécurisé + Notification de réseau non sécurisé + Interface + Barre d\'apps inférieure + Déplacer la barre d\'apps en bas de l\'écran. La modification de ce paramètre entraîne le redémarrage de Privacy Cell. + Sécurisé Non-sécurisé diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 26c589e..d3bf213 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -49,16 +49,6 @@ Forum Donazioni - - Monitoraggio - Monitoraggio in tempo reale - Aggiunge un\'icona nella barra di stato che monitora la rete cellulare. - Notifica di rete sicura - Notifica di rete insicura - Interfaccia - Barra dell\'app in basso - Sposta la barra dell\'app nella parte inferiore dello schermo. La modifica di questa impostazione provoca il riavvio di Privacy Cell. - Sconosciuta GPRS – 2.5G/3G @@ -121,6 +111,16 @@ Stingray Chiudi + + Monitoraggio + Monitoraggio in tempo reale + Aggiunge un\'icona nella barra di stato che monitora la rete cellulare. + Notifica di rete sicura + Notifica di rete insicura + Interfaccia + Barra dell\'app in basso + Sposta la barra dell\'app nella parte inferiore dello schermo. La modifica di questa impostazione provoca il riavvio di Privacy Cell. + Sicura Insicura diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 4566de8..fed68ea 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -23,19 +23,28 @@ @color/violet_500 @color/violet_500 @color/gray_500 + @color/white @color/salmon #FF000000 + #FF2196F3 #FF1976D2 #FF0D47A1 + #FF9E9E9E #FF757575 + #FF202020 + #FFE53935 #FFD32F2F + #FFFC684E + #FFC73625 + #FF8AB4F8 + #FFFFFFFF \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 3069875..62089e1 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -47,16 +47,6 @@ Форум Пожертвования - - Мониторинг - Мониторинг в реальном времени - Поместить в строку состояния значок для отслеживания сотовой сети. - Уведомление о безопасной сети - Уведомление о небезопасной сети - Интерфейс - Панель приложения внизу - Переместить панель приложения в нижнюю часть экрана. Изменение этой настройки приведет к перезапуску Privacy Cell. - Неизвестно GPRS – 2.5G/3G @@ -119,6 +109,16 @@ Stingrays Закрыть + + Мониторинг + Мониторинг в реальном времени + Поместить в строку состояния значок для отслеживания сотовой сети. + Уведомление о безопасной сети + Уведомление о небезопасной сети + Интерфейс + Панель приложения внизу + Переместить панель приложения в нижнюю часть экрана. Изменение этой настройки приведет к перезапуску Privacy Cell. + Безопасна Небезопасна diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f49cbd0..584c22d 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -23,19 +23,28 @@ @color/blue_700 @color/blue_700 @color/gray_600 + @color/gray_925 @color/red_700 #FF000000 + #FF2196F3 #FF1976D2 #FF0D47A1 + #FF9E9E9E #FF757575 + #FF202020 + #FFE53935 #FFD32F2F + #FFFC684E + #FFC73625 + #FF8AB4F8 + #FFFFFFFF \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d4b5d61..551e449 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -49,18 +49,9 @@ Roadmap Bug Tracker Forum + Logcat Donations - - Monitoring - Realtime monitoring - Place an icon in the status bar that monitors the cell network. - Secure network notification - Insecure network notification - Interface - Bottom app bar - Move the app bar to the bottom of the screen. Changing this setting will restart Privacy Cell. - Unknown GPRS – 2.5G/3G @@ -123,6 +114,27 @@ Stingrays Close + + Monitoring + Realtime monitoring + Place an icon in the status bar that monitors the cell network. + Secure network notification + Insecure network notification + Interface + Bottom app bar + Move the app bar to the bottom of the screen. Changing this setting will restart Privacy Cell. + + + Copy + Save + Clear + Logcat copied. + Privacy Cell Logcat.txt + %1$s saved. + Error saving logcat: \u0020 %1$s + Secure Insecure -- 2.45.2