Skip to content

Commit

Permalink
Fixed issue with runner for command.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptrr committed Sep 25, 2024
1 parent da0a773 commit 9d11169
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
minSdk = 27
//noinspection EditedTargetSdkVersion,ExpiredTargetSdkVersion
targetSdk = 28
versionCode = 8
versionName = "\"0.11.0-beta\""
versionCode = 9
versionName = "\"0.11.1-beta\""

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/autosec/pie/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class MainActivity : ComponentActivity() {
derivedStateOf { shareReceiverViewModel.currentExtrasDetails.value != null }
}


val editCommandScope = rememberCoroutineScope()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,26 +314,34 @@ fun CommandExtraInputs(command: CommandModel, parentSheetState: SheetState? = nu
shape = RoundedCornerShape(20),
//contentPadding = PaddingValues(vertical = 20.dp),
onClick = {
viewModel.viewModelScope.launch {
viewModel.main.viewModelScope.launch {

val gson = Gson()
val commandJson = gson.toJson(command)
val fileUrisJson = gson.toJson(fileUris ?: extraInputList.value)
try {
isLoading = true

val commandExtraInputsJson = gson.toJson(commandExtraInputs.value)
val gson = Gson()
val commandJson = gson.toJson(command)
val fileUrisJson = gson.toJson(fileUris ?: extraInputList.value)

val intent = Intent(context, ForegroundService::class.java).apply {
putExtra("command", commandJson)
putExtra("currentLink", currentLink ?: extraInput.value)
putExtra("fileUris", fileUrisJson)
putExtra("commandExtraInputs", commandExtraInputsJson)
}
val commandExtraInputsJson = gson.toJson(commandExtraInputs.value)

val intent = Intent(context, ForegroundService::class.java).apply {
putExtra("command", commandJson)
putExtra("currentLink", currentLink ?: extraInput.value)
putExtra("fileUris", fileUrisJson)
putExtra("commandExtraInputs", commandExtraInputsJson)
}

startForegroundService(context, intent)

isLoading = true
delay(900)
activity?.finish()
startForegroundService(context, intent)

if(parentSheetState != null){
delay(900)
activity?.finish()
}
}catch (e: Exception){
Timber.e(e)
}
}
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.autosec.pie.viewModels

import android.app.Application
import android.os.Environment
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -87,7 +88,7 @@ class CommandsListScreenViewModel(application: Application) : AndroidViewModel(a
val value = entry.value.asJsonObject
// Process the key-value pair

val directoryPath = value.get("path").asString
val directoryPath = "${Environment.getExternalStorageDirectory().absolutePath}/" + value.get("path").asString
val exec = value.get("exec").asString
val command = value.get("command").asString
val deleteSource = value.get("deleteSourceFile").asBoolean
Expand Down Expand Up @@ -120,7 +121,7 @@ class CommandsListScreenViewModel(application: Application) : AndroidViewModel(a
val value = entry.value.asJsonObject
// Process the key-value pair

val directoryPath = value.get("path").asString
val directoryPath = "${Environment.getExternalStorageDirectory().absolutePath}/" + value.get("path").asString
val exec = value.get("exec").asString
val command = value.get("command").asString
val deleteSource = value.get("deleteSourceFile").asBoolean
Expand Down Expand Up @@ -153,7 +154,7 @@ class CommandsListScreenViewModel(application: Application) : AndroidViewModel(a
val value = entry.value.asJsonObject
// Process the key-value pair

val directoryPath = value.get("path").asString
val directoryPath = "${Environment.getExternalStorageDirectory().absolutePath}/" + value.get("path").asString
val exec = value.get("exec").asString
val command = value.get("command").asString
val deleteSource = value.get("deleteSourceFile").asBoolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ class ShareReceiverViewModel(val application1: Application) : AndroidViewModel(a
else -> {}
}

currentExtrasDetails.value = null


viewModelScope.launch {
delay(900L)
currentExtrasDetails.value = null
}
}


Expand Down

0 comments on commit 9d11169

Please sign in to comment.