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).
This commit is contained in:
p0we7 2024-12-29 20:05:50 +08:00
parent 565d1d7a81
commit 51ec7d0388
2 changed files with 4 additions and 4 deletions
app/src/main/java/com/github/kr328/clash

View file

@ -60,7 +60,7 @@ class LogsActivity : BaseActivity<LogsDesign>() {
}
private fun loadFiles(): List<LogFile> {
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<LogsDesign>() {
private fun deleteAllLogs() {
logsDir.deleteRecursively()
}
}
}

View file

@ -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")
get() = filesDir.resolve("clash")