diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d82023e..6610dc8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,13 +2,12 @@ - - - + + + @@ -38,7 +40,6 @@ - diff --git a/app/src/main/java/com/nasahacker/steelmind/ui/DebugLogsActivity.kt b/app/src/main/java/com/nasahacker/steelmind/ui/DebugLogsActivity.kt new file mode 100644 index 0000000..63b1975 --- /dev/null +++ b/app/src/main/java/com/nasahacker/steelmind/ui/DebugLogsActivity.kt @@ -0,0 +1,77 @@ +package com.nasahacker.steelmind.ui + +import android.os.Bundle +import android.view.Menu +import android.view.MenuInflater +import android.widget.TextView +import android.widget.Toast +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import androidx.lifecycle.lifecycleScope +import com.nasahacker.steelmind.BuildConfig +import com.nasahacker.steelmind.R +import com.nasahacker.steelmind.databinding.ActivityDebugLogsBinding +import kotlinx.coroutines.* +import java.io.BufferedReader +import java.io.IOException +import java.io.InputStreamReader + +class DebugLogsActivity : AppCompatActivity() { + private val binding by lazy { ActivityDebugLogsBinding.inflate(layoutInflater) } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContentView(binding.root) + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) + insets + } + + setSupportActionBar(binding.toolbar) + supportActionBar?.setDisplayHomeAsUpEnabled(true) + + binding.toolbar.setNavigationOnClickListener { + onBackPressedDispatcher.onBackPressed() + } + + binding.toolbar.setOnMenuItemClickListener { + if (it.itemId == R.id.deleteAll) { + binding.logstv.text = "" + Toast.makeText(this, getString(R.string.success), Toast.LENGTH_SHORT).show() + } + true + } + + startLogcatReader() + } + + override fun onCreateOptionsMenu(menu: Menu?): Boolean { + menuInflater.inflate(R.menu.delete_menu, menu) + return true + } + + + private fun startLogcatReader() { + lifecycleScope.launch(Dispatchers.IO) { + try { + val process = Runtime.getRuntime().exec("logcat") + val bufferedReader = BufferedReader(InputStreamReader(process.inputStream)) + var line: String? + while (bufferedReader.readLine().also { line = it } != null) { + val log = line!! + + withContext(Dispatchers.Main) { + binding.logstv.append("\n$log") + } + } + } catch (e: IOException) { + e.printStackTrace() + } + } + } + +} diff --git a/app/src/main/java/com/nasahacker/steelmind/ui/HistoryActivity.kt b/app/src/main/java/com/nasahacker/steelmind/ui/HistoryActivity.kt index 042f346..3afa8e1 100644 --- a/app/src/main/java/com/nasahacker/steelmind/ui/HistoryActivity.kt +++ b/app/src/main/java/com/nasahacker/steelmind/ui/HistoryActivity.kt @@ -72,7 +72,7 @@ class HistoryActivity : AppCompatActivity(), OnClickListener { } override fun onCreateOptionsMenu(menu: Menu?): Boolean { - menuInflater.inflate(R.menu.history_menu, menu) + menuInflater.inflate(R.menu.delete_menu, menu) return true } diff --git a/app/src/main/java/com/nasahacker/steelmind/ui/MainActivity.kt b/app/src/main/java/com/nasahacker/steelmind/ui/MainActivity.kt index d0f5daa..e51d9df 100644 --- a/app/src/main/java/com/nasahacker/steelmind/ui/MainActivity.kt +++ b/app/src/main/java/com/nasahacker/steelmind/ui/MainActivity.kt @@ -161,6 +161,7 @@ class MainActivity : AppCompatActivity() { R.id.top_history -> startActivity(Intent(this, HistoryActivity::class.java)) R.id.top_export -> handleExportAction() R.id.top_import -> pickJsonFileLauncher.launch(arrayOf("application/json")) + R.id.debug_logs -> startActivity(Intent(this, DebugLogsActivity::class.java)) R.id.top_license -> LibsBuilder() .withActivityTitle(getString(R.string.open_source_licenses)) .start(this) diff --git a/app/src/main/res/drawable/baseline_bug_report_24.xml b/app/src/main/res/drawable/baseline_bug_report_24.xml new file mode 100644 index 0000000..0e2461d --- /dev/null +++ b/app/src/main/res/drawable/baseline_bug_report_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/file_export_24px.xml b/app/src/main/res/drawable/file_export_24px.xml index 783669e..a09b248 100644 --- a/app/src/main/res/drawable/file_export_24px.xml +++ b/app/src/main/res/drawable/file_export_24px.xml @@ -3,8 +3,8 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" - android:tint="?attr/colorControlNormal"> + android:tint="@color/iconColor"> diff --git a/app/src/main/res/drawable/file_open_24px.xml b/app/src/main/res/drawable/file_open_24px.xml index c94ebed..8bdf268 100644 --- a/app/src/main/res/drawable/file_open_24px.xml +++ b/app/src/main/res/drawable/file_open_24px.xml @@ -3,8 +3,8 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" - android:tint="?attr/colorControlNormal"> + android:tint="@color/iconColor"> diff --git a/app/src/main/res/drawable/history_24px.xml b/app/src/main/res/drawable/history_24px.xml index 93ca20d..50d0407 100644 --- a/app/src/main/res/drawable/history_24px.xml +++ b/app/src/main/res/drawable/history_24px.xml @@ -3,8 +3,8 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" - android:tint="?attr/colorControlNormal"> + android:tint="@color/iconColor"> diff --git a/app/src/main/res/drawable/license_24px.xml b/app/src/main/res/drawable/license_24px.xml index 99b9354..c2740bd 100644 --- a/app/src/main/res/drawable/license_24px.xml +++ b/app/src/main/res/drawable/license_24px.xml @@ -3,8 +3,8 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" - android:tint="?attr/colorControlNormal"> + android:tint="@color/iconColor"> diff --git a/app/src/main/res/drawable/more_vert_24px.xml b/app/src/main/res/drawable/more_vert_24px.xml index e4aa85d..8fbcb65 100644 --- a/app/src/main/res/drawable/more_vert_24px.xml +++ b/app/src/main/res/drawable/more_vert_24px.xml @@ -3,8 +3,8 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" - android:tint="?attr/colorControlNormal"> + android:tint="@color/iconColor"> diff --git a/app/src/main/res/layout/activity_debug_logs.xml b/app/src/main/res/layout/activity_debug_logs.xml new file mode 100644 index 0000000..9aad6d6 --- /dev/null +++ b/app/src/main/res/layout/activity_debug_logs.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_history.xml b/app/src/main/res/layout/activity_history.xml index 36dbf9f..0976f69 100644 --- a/app/src/main/res/layout/activity_history.xml +++ b/app/src/main/res/layout/activity_history.xml @@ -16,7 +16,7 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" - app:menu="@menu/history_menu" + app:menu="@menu/delete_menu" app:title="History" /> diff --git a/app/src/main/res/menu/history_menu.xml b/app/src/main/res/menu/delete_menu.xml similarity index 100% rename from app/src/main/res/menu/history_menu.xml rename to app/src/main/res/menu/delete_menu.xml diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml index d6100ab..acb7ce0 100644 --- a/app/src/main/res/menu/main_menu.xml +++ b/app/src/main/res/menu/main_menu.xml @@ -21,6 +21,10 @@ android:id="@+id/top_export" android:icon="@drawable/file_export_24px" android:title="Export Data" /> +