Skip to content

Commit

Permalink
Action.sh Suppport 12/13
Browse files Browse the repository at this point in the history
  • Loading branch information
1q23lyc45 committed Dec 21, 2024
1 parent 1318574 commit df333c2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
28 changes: 23 additions & 5 deletions app/src/main/java/com/topjohnwu/magisk/ui/module/ActionFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.widget.Toast
import androidx.core.view.MenuProvider
import androidx.core.view.isVisible
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.arch.BaseFragment
import com.topjohnwu.magisk.arch.viewModel
import com.topjohnwu.magisk.core.ktx.toast
import com.topjohnwu.magisk.databinding.FragmentActionMd2Binding
import com.topjohnwu.magisk.ui.flash.FlashViewModel
import timber.log.Timber
Expand Down Expand Up @@ -45,11 +47,27 @@ class ActionFragment : BaseFragment<FragmentActionMd2Binding>(), MenuProvider {
ActionViewModel.State.FAILED -> R.string.failure
}
)
if (it != ActionViewModel.State.RUNNING) {
binding.closeBtn.apply {
if (!this.isVisible) this.show()
if (!this.isFocused) this.requestFocus()
when (it) {
ActionViewModel.State.SUCCESS -> {
activity?.apply {
toast(
getString(
com.topjohnwu.magisk.core.R.string.done_action,
this@ActionFragment.viewModel.args.name
), Toast.LENGTH_LONG
)
onBackPressed()
}
}

ActionViewModel.State.FAILED -> {
binding.closeBtn.apply {
if (!this.isVisible) this.show()
if (!this.isFocused) this.requestFocus()
}
}

else -> {}
}
}
}
Expand Down Expand Up @@ -89,7 +107,7 @@ class ActionFragment : BaseFragment<FragmentActionMd2Binding>(), MenuProvider {
}

override fun onBackPressed(): Boolean {
if (!binding.closeBtn.isVisible) return true
if (viewModel.state.value == ActionViewModel.State.RUNNING) return true
return super.onBackPressed()
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/raw/manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ check_encryption() {
run_action() {
local MODID="$1"
cd "/data/adb/modules/$MODID"
ASH_STANDALONE=1 sh ./action.sh
sh ./action.sh
local RES=$?
cd /
return $RES
}

##########################
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
<string name="flashing">Flashing…</string>
<string name="running">Running...</string>
<string name="done">Done!</string>
<string name="done_action">Done running action of %1$s</string>
<string name="failure">Failed!</string>
<string name="hide_app_title">Hiding the Magisk app…</string>
<string name="open_link_failed_toast">No app found to open the link</string>
Expand Down

0 comments on commit df333c2

Please sign in to comment.