diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/LogcatActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/LogcatActivity.kt index 872f32ea..d56395b8 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/LogcatActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/LogcatActivity.kt @@ -1,6 +1,8 @@ package com.v2ray.ang.ui import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.text.method.ScrollingMovementMethod import android.view.Menu import android.view.MenuItem @@ -24,15 +26,22 @@ class LogcatActivity : BaseActivity() { title = getString(R.string.title_logcat) supportActionBar?.setDisplayHomeAsUpEnabled(true) - logcat() + logcat(false) } - private fun logcat() { + private fun logcat(shouldFlushLog: Boolean) { try { pb_waiting.visibility = View.VISIBLE doAsync { + if (shouldFlushLog) { + val lst = LinkedHashSet() + lst.add("logcat") + lst.add("-c") + val process = Runtime.getRuntime().exec(lst.toTypedArray()) + process.waitFor() + } val lst = LinkedHashSet() lst.add("logcat") lst.add("-d") @@ -49,9 +58,11 @@ class LogcatActivity : BaseActivity() { tv_logcat.text = allText tv_logcat.movementMethod = ScrollingMovementMethod() pb_waiting.visibility = View.GONE + Handler(Looper.getMainLooper()).post { sv_logcat.fullScroll(View.FOCUS_DOWN) } } } } catch (e: IOException) { + e.printStackTrace() } } @@ -66,7 +77,10 @@ class LogcatActivity : BaseActivity() { toast(R.string.toast_success) true } - + R.id.delete -> { + logcat(true) + true + } else -> super.onOptionsItemSelected(item) } } diff --git a/V2rayNG/app/src/main/res/menu/menu_logcat.xml b/V2rayNG/app/src/main/res/menu/menu_logcat.xml index cabe6c2e..42042a67 100644 --- a/V2rayNG/app/src/main/res/menu/menu_logcat.xml +++ b/V2rayNG/app/src/main/res/menu/menu_logcat.xml @@ -6,4 +6,9 @@ android:icon="@drawable/ic_copy_white" android:title="@string/logcat_copy" app:showAsAction="always" /> + \ No newline at end of file diff --git a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml index 36fc90aa..535748f3 100644 --- a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml @@ -135,6 +135,7 @@ Logcat 复制 + 删除 导出全部配置至剪贴板 订阅设置 备注 diff --git a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml index 09b6ba66..b80cd7e8 100644 --- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml @@ -137,6 +137,7 @@ Logcat 複製 + 刪除 匯出全部配置至剪貼簿 訂閱設定 備註 diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index 29c03bf9..6865872a 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -136,6 +136,7 @@ Logcat Copy + Delete Export all config to clipboard Subscription setting remarks