-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3af84c
commit 9a90cc3
Showing
14 changed files
with
141 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
app/src/main/java/com/nasahacker/steelmind/ui/DebugLogsActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="@color/iconColor" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@color/iconColor" android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z"/> | ||
|
||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:context=".ui.DebugLogsActivity"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<com.google.android.material.appbar.MaterialToolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:menu="@menu/delete_menu" | ||
app:title="Debug Logs" /> | ||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
android:id="@+id/logstv" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:fontFamily="@font/roboto" | ||
android:padding="@dimen/_8sdp" | ||
android:textIsSelectable="true" | ||
tools:text="Hello" /> | ||
</ScrollView> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters