From 51ec7d0388f60f2ea54492fceffe67ce4d1dc2bc Mon Sep 17 00:00:00 2001 From: p0we7 Date: Sun, 29 Dec 2024 20:05:50 +0800 Subject: [PATCH] Modify log file saving location to external storage. Modify log file saving location to external storage. * Change `logsDir` in `Files.kt` to use external storage directory if available, otherwise fallback to internal storage. * Update `LogsActivity.kt` to use `logsDir` for loading log files instead of `cacheDir`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/MetaCubeX/ClashMetaForAndroid?shareId=XXXX-XXXX-XXXX-XXXX). --- app/src/main/java/com/github/kr328/clash/LogsActivity.kt | 4 ++-- app/src/main/java/com/github/kr328/clash/util/Files.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/kr328/clash/LogsActivity.kt b/app/src/main/java/com/github/kr328/clash/LogsActivity.kt index 0a482b65..b6a00293 100644 --- a/app/src/main/java/com/github/kr328/clash/LogsActivity.kt +++ b/app/src/main/java/com/github/kr328/clash/LogsActivity.kt @@ -60,7 +60,7 @@ class LogsActivity : BaseActivity() { } private fun loadFiles(): List { - val list = cacheDir.resolve("logs").listFiles()?.toList() ?: emptyList() + val list = logsDir.listFiles()?.toList() ?: emptyList() return list.mapNotNull { LogFile.parseFromFileName(it.name) } } @@ -68,4 +68,4 @@ class LogsActivity : BaseActivity() { private fun deleteAllLogs() { logsDir.deleteRecursively() } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/github/kr328/clash/util/Files.kt b/app/src/main/java/com/github/kr328/clash/util/Files.kt index 9b696c8a..008062cc 100644 --- a/app/src/main/java/com/github/kr328/clash/util/Files.kt +++ b/app/src/main/java/com/github/kr328/clash/util/Files.kt @@ -4,7 +4,7 @@ import android.content.Context import java.io.File val Context.logsDir: File - get() = cacheDir.resolve("logs") + get() = getExternalFilesDir(null)?.resolve("logs") ?: cacheDir.resolve("logs") val Context.clashDir: File - get() = filesDir.resolve("clash") \ No newline at end of file + get() = filesDir.resolve("clash")