Add export config to clipboard
This commit is contained in:
@@ -2,6 +2,7 @@ package com.hiddify.hiddify
|
||||
|
||||
import android.util.Log
|
||||
import com.hiddify.hiddify.bg.BoxService
|
||||
import com.hiddify.hiddify.constant.Alert
|
||||
import com.hiddify.hiddify.constant.Status
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
@@ -24,6 +25,7 @@ class MethodHandler(private val scope: CoroutineScope) : FlutterPlugin,
|
||||
enum class Trigger(val method: String) {
|
||||
ParseConfig("parse_config"),
|
||||
ChangeConfigOptions("change_config_options"),
|
||||
GenerateConfig("generate_config"),
|
||||
Start("start"),
|
||||
Stop("stop"),
|
||||
Restart("restart"),
|
||||
@@ -70,6 +72,21 @@ class MethodHandler(private val scope: CoroutineScope) : FlutterPlugin,
|
||||
}
|
||||
}
|
||||
|
||||
Trigger.GenerateConfig.method -> {
|
||||
scope.launch {
|
||||
result.runCatching {
|
||||
val args = call.arguments as Map<*, *>
|
||||
val path = args["path"] as String
|
||||
val options = Settings.configOptions
|
||||
if (options.isBlank() || path.isBlank()) {
|
||||
error("blank properties")
|
||||
}
|
||||
val config = BoxService.buildConfig(path, options)
|
||||
success(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Trigger.Start.method -> {
|
||||
scope.launch {
|
||||
result.runCatching {
|
||||
|
||||
@@ -72,6 +72,10 @@ class BoxService(
|
||||
}
|
||||
}
|
||||
|
||||
fun buildConfig(path: String, options: String):String {
|
||||
return Mobile.buildConfig(path, options)
|
||||
}
|
||||
|
||||
fun start() {
|
||||
val intent = runBlocking {
|
||||
withContext(Dispatchers.IO) {
|
||||
|
||||
Reference in New Issue
Block a user