@@ -6,6 +6,7 @@ import android.net.Uri
66import android.os.Bundle
77import android.os.Handler
88import android.os.Looper
9+ import android.text.SpannableString
910import android.view.Menu
1011import android.view.MenuItem
1112import android.view.View
@@ -349,12 +350,15 @@ class ActionPage : AppCompatActivity() {
349350 val extraParams = hashMapOf(" state" to menuOption.key, " menu_id" to menuOption.key)
350351
351352 lifecycleScope.launch(Dispatchers .IO ) {
352- ScriptEnvironmen .executeResultRoot(this @ActionPage, config.pageHandlerSh, config, extraParams)
353+ val output = ScriptEnvironmen .executeResultRoot(this @ActionPage, config.pageHandlerSh, config, extraParams)
353354
354355 if (! isActive) return @launch
355356
356357 withContext(Dispatchers .Main ) {
357358 if (isFinishing || isDestroyed) return @withContext
359+ if (! output.isNullOrBlank()) {
360+ SilentShellOutputHandler (this @ActionPage).processOutput(output)
361+ }
358362 when {
359363 menuOption.autoFinish -> finish()
360364 menuOption.reloadPage -> recreate()
@@ -368,6 +372,27 @@ class ActionPage : AppCompatActivity() {
368372 }
369373 }
370374
375+ private class SilentShellOutputHandler (context : android.content.Context ) : ShellHandlerBase(context) {
376+ override fun onProgress (current : Int , total : Int ) {
377+ // Chạy ẩn không có UI để hiển thị tiến trình -> bỏ qua có chủ đích.
378+ }
379+
380+ override fun onStart (msg : Any? ) {}
381+ override fun onStart (forceStop : Runnable ? ) {}
382+ override fun onExit (msg : Any? ) {}
383+ override fun updateLog (msg : SpannableString ? ) {
384+ // Chạy ẩn không có log view -> bỏ qua có chủ đích.
385+ }
386+
387+ fun processOutput (output : String ) {
388+ output.lineSequence().forEach { line ->
389+ if (line.isNotBlank()) {
390+ onReaderMsg(line)
391+ }
392+ }
393+ }
394+ }
395+
371396 private fun loadPageConfig (showLoading : Boolean = true) {
372397 val config = currentPageConfig ? : return
373398
0 commit comments