mirror of
https://github.com/izzy2lost/aab2apk.git
synced 2026-06-19 01:20:08 -07:00
Added Clear Logs Button
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 34 KiB |
+51
-13
@@ -6,6 +6,9 @@ import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.loadSvgPainter
|
||||
import androidx.compose.ui.res.useResource
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@@ -29,13 +32,13 @@ import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
import java.net.URI
|
||||
import utils.Strings
|
||||
import java.nio.file.Paths
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun App(fileStorageHelper: FileStorageHelper, savedPath: String?) {
|
||||
val density = LocalDensity.current // to calculate the intrinsic size of vector images (SVG, XML)
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
var logs by remember { mutableStateOf("========== Logs View ==========\n\n") }
|
||||
var logs by remember { mutableStateOf("") }
|
||||
var bundletoolPath by remember { mutableStateOf("") }
|
||||
var aabFilePath by remember { mutableStateOf(Pair<String, String>("", "")) }
|
||||
var isLoading by remember { mutableStateOf(false) }
|
||||
@@ -53,8 +56,11 @@ fun App(fileStorageHelper: FileStorageHelper, savedPath: String?) {
|
||||
var keyAlias by remember { mutableStateOf("") }
|
||||
var keyPassword by remember { mutableStateOf("") }
|
||||
var isAutoUnzip by remember { mutableStateOf(true) }
|
||||
var savedJarPath by remember { mutableStateOf(savedPath) }
|
||||
|
||||
savedPath?.let {
|
||||
|
||||
//TODO: KNOWN ISSUE - Can't update file path once saved, For now Delete path.kb file inside storage directory.
|
||||
savedJarPath?.let {
|
||||
bundletoolPath = it
|
||||
saveJarPath = true
|
||||
}
|
||||
@@ -93,14 +99,6 @@ fun App(fileStorageHelper: FileStorageHelper, savedPath: String?) {
|
||||
Log.i("Command $cmd")
|
||||
logs += "Executing Command : \n$cmd\n"
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
//Save Path in Storage
|
||||
if (savedPath == null) {
|
||||
fileStorageHelper.save("path", bundletoolPath)
|
||||
} else {
|
||||
if (fileStorageHelper.delete("path"))
|
||||
saveJarPath = false
|
||||
}
|
||||
|
||||
val runtime = Runtime.getRuntime()
|
||||
val startTime = System.currentTimeMillis()
|
||||
try {
|
||||
@@ -129,6 +127,19 @@ fun App(fileStorageHelper: FileStorageHelper, savedPath: String?) {
|
||||
logs += "\nFile will be saved at ${aabFilePath.first.removeSuffix("\\")}.\n"
|
||||
isLoading = false
|
||||
}
|
||||
|
||||
//Save Path in Storage
|
||||
//If We don't have any saved path in file storage and save jar path option is checked.Then,we can save new value in storage.
|
||||
if (savedJarPath == null && saveJarPath) {
|
||||
fileStorageHelper.save("path", bundletoolPath)
|
||||
}
|
||||
// If we have saved path in file storage, and it is not changed and save jar path is checked. Then, we can update the value in file storage.
|
||||
else if (savedJarPath != null && savedJarPath != bundletoolPath && saveJarPath) {
|
||||
fileStorageHelper.save("path", bundletoolPath)
|
||||
} else {
|
||||
if (fileStorageHelper.delete("path"))
|
||||
saveJarPath = false
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
isLoading = false
|
||||
@@ -360,9 +371,36 @@ fun App(fileStorageHelper: FileStorageHelper, savedPath: String?) {
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.padding(8.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
modifier = Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, bottom = 8.dp),
|
||||
verticalAlignment = Alignment.Bottom
|
||||
) {
|
||||
Text(
|
||||
text = Strings.LOGS_VIEW,
|
||||
style = Styles.TextStyleBold(20.sp),
|
||||
modifier = Modifier.padding(start = 0.dp, end = 0.dp, bottom = 8.dp)
|
||||
)
|
||||
Button(
|
||||
modifier = Modifier.padding(end = 0.dp, bottom = 8.dp),
|
||||
onClick = {
|
||||
logs = ""
|
||||
},
|
||||
) {
|
||||
Text(
|
||||
text = Strings.CLEAR_LOGS,
|
||||
style = Styles.TextStyleBold(13.sp),
|
||||
)
|
||||
Spacer(modifier = Modifier.size(ButtonDefaults.IconSpacing))
|
||||
Icon(
|
||||
painter = useResource("clear.svg") { loadSvgPainter(it, density) },
|
||||
contentDescription = "Clear",
|
||||
modifier = Modifier.size(ButtonDefaults.IconSize),
|
||||
)
|
||||
}
|
||||
}
|
||||
TextField(
|
||||
modifier = Modifier.fillMaxSize().padding(start = 20.dp, end = 20.dp, bottom = 20.dp),
|
||||
modifier = Modifier.fillMaxSize().padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
|
||||
value = logs,
|
||||
textStyle = Styles.TextStyleMedium(16.sp),
|
||||
onValueChange = {},
|
||||
|
||||
@@ -30,4 +30,6 @@ object Strings {
|
||||
const val FILE_OPTIONS = "File Options"
|
||||
const val AUTO_UNZIP = "Automatically Unzip and Delete Apks File"
|
||||
const val AUTO_UNZIP_INFO = "Automatically Unzip and Delete Apks File"
|
||||
const val CLEAR_LOGS = "Clear Logs"
|
||||
const val LOGS_VIEW = "Logs View"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m656-120-56-56 84-84-84-84 56-56 84 84 84-84 56 56-83 84 83 84-56 56-84-83-84 83Zm-176 0q-138 0-240.5-91.5T122-440h82q14 104 92.5 172T480-200q11 0 20.5-.5T520-203v81q-10 1-19.5 1.5t-20.5.5ZM120-560v-240h80v94q51-64 124.5-99T480-840q150 0 255 105t105 255h-80q0-117-81.5-198.5T480-760q-69 0-129 32t-101 88h110v80H120Zm414 190-94-94v-216h80v184l56 56-42 70Z"/></svg>
|
||||
|
After Width: | Height: | Size: 460 B |
Reference in New Issue
Block a user