-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Command Executor for executing commands. - Added Generic Loading Dialog - Saved ADB path to storage - TODO : Need to add Device options if ADB setup is done - Updated kotlin_lint.yml
- Loading branch information
1 parent
cd2c737
commit ee1dc9e
Showing
12 changed files
with
336 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
name: kotlin_lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
pull_request: | ||
paths: | ||
- "**/*.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
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,55 @@ | ||
package command | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import java.io.BufferedReader | ||
import java.io.InputStreamReader | ||
|
||
class CommandExecutor { | ||
|
||
fun executeCommand( | ||
cmd: String, | ||
coroutineScope: CoroutineScope, | ||
onSuccess: (String) -> Unit, | ||
onFailure: (Throwable) -> Unit | ||
) { | ||
coroutineScope.launch(Dispatchers.IO){ | ||
try { | ||
val runtime = Runtime.getRuntime() | ||
val startTime = System.currentTimeMillis() | ||
|
||
val process = runtime.exec(cmd) | ||
val outputReader = BufferedReader(InputStreamReader(process.inputStream)) | ||
val errorReader = BufferedReader(InputStreamReader(process.errorStream)) | ||
|
||
var output = "" | ||
var errorOutput = "" | ||
|
||
// Read command output | ||
var line: String? | ||
while (outputReader.readLine().also { line = it } != null) { | ||
output += line + "\n" | ||
} | ||
|
||
// Read error output | ||
while (errorReader.readLine().also { line = it } != null) { | ||
errorOutput += line + "\n" | ||
} | ||
|
||
process.waitFor() | ||
val endTime = System.currentTimeMillis() | ||
if (process.exitValue() == 0) { | ||
val executionTime = ((endTime - startTime) / 1000).toString() + "s" | ||
onSuccess("$cmd\n$output\nCommand Executed in $executionTime") | ||
} else { | ||
val exception = Exception("Command execution failed: $cmd$errorOutput") | ||
onFailure(exception) | ||
} | ||
} catch (e: Exception) { | ||
onFailure(e) | ||
} | ||
} | ||
} | ||
|
||
} |
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,73 @@ | ||
package ui.components | ||
|
||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import androidx.compose.foundation.TooltipArea | ||
import androidx.compose.foundation.TooltipPlacement | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.wrapContentWidth | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.shadow | ||
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.font.FontWeight | ||
import androidx.compose.ui.unit.DpOffset | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import ui.Styles | ||
|
||
@OptIn(ExperimentalFoundationApi::class) | ||
@Composable | ||
fun ButtonWithToolTip(label: String, onClick: () -> Unit, toolTipText: String = "", icon: String = "info", buttonColors: ButtonColors = ButtonDefaults.buttonColors()) { | ||
val density = LocalDensity.current // to calculate the intrinsic size of vector images (SVG, XML) | ||
Button( | ||
onClick = { | ||
onClick.invoke() | ||
}, | ||
colors = buttonColors, | ||
modifier = Modifier.padding(start = 16.dp, top = 8.dp, end = 16.dp, bottom = 8.dp) | ||
.wrapContentWidth(), | ||
) { | ||
Text( | ||
text = label, | ||
style = Styles.TextStyleMedium(16.sp), | ||
color = Color.White, | ||
fontWeight = FontWeight.Medium, | ||
) | ||
if (toolTipText.isNotEmpty()) { | ||
TooltipArea( | ||
tooltip = { | ||
// composable tooltip content | ||
Surface( | ||
modifier = Modifier.shadow(4.dp), | ||
color = Color(255, 255, 210), | ||
shape = RoundedCornerShape(4.dp) | ||
) { | ||
Text( | ||
text = toolTipText, | ||
color = Color.Black, | ||
style = Styles.TextStyleMedium(12.sp), | ||
modifier = Modifier.padding(10.dp) | ||
) | ||
} | ||
}, | ||
delayMillis = 200, // in milliseconds | ||
tooltipPlacement = TooltipPlacement.CursorPoint( | ||
alignment = Alignment.BottomEnd, | ||
offset = DpOffset.Zero // tooltip offset | ||
) | ||
) { | ||
Icon( | ||
painter = useResource("$icon.svg") { loadSvgPainter(it, density) }, | ||
contentDescription = icon, | ||
modifier = Modifier.padding(start = 8.dp) | ||
) | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.