pull/1327/merge
deniscerri 3 weeks ago
parent aea0edc3ae
commit a3fb076fa2
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

@ -290,6 +290,7 @@ class MainActivity : BaseActivity() {
} }
cookieViewModel.updateCookiesFile() cookieViewModel.updateCookiesFile()
installLauncher = ApkInstallUtil.registerInstallLauncher(this)
val intent = intent val intent = intent
handleIntents(intent) handleIntents(intent)

@ -101,28 +101,29 @@ object BgUtilsPoTokenGeneratorUtil {
val hasDeno = RuntimeManager.getInstance().denoLocation.isAvailable val hasDeno = RuntimeManager.getInstance().denoLocation.isAvailable
progress?.invoke("Downloading node-modules...") progress?.invoke("Downloading node-modules...")
if (hasNode) { //TODO READD
val nodeResponse = RuntimeManager.getInstance().executeNpm( // if (hasNode) {
command = "install --ignore-scripts", // val nodeResponse = RuntimeManager.getInstance().executeNpm(
executeDirectory = File(serverFolder, "server")) { _, _, line -> // command = "install --ignore-scripts",
progress?.invoke(line) // executeDirectory = File(serverFolder, "server")) { _, _, line ->
} // progress?.invoke(line)
if (nodeResponse.exitCode != 0) { // }
progress?.invoke(nodeResponse.err) // if (nodeResponse.exitCode != 0) {
return Result.failure(Exception(nodeResponse.err)) // progress?.invoke(nodeResponse.err)
} // return Result.failure(Exception(nodeResponse.err))
// }
progress?.invoke("Building typescript files...") //
val nodeResponse2 = RuntimeManager.getInstance().executeNode( // progress?.invoke("Building typescript files...")
command = "node_modules/typescript/bin/tsc", // val nodeResponse2 = RuntimeManager.getInstance().executeNode(
executeDirectory = File(serverFolder, "server")) { _, _, line -> // command = "node_modules/typescript/bin/tsc",
progress?.invoke(line) // executeDirectory = File(serverFolder, "server")) { _, _, line ->
} // progress?.invoke(line)
if (nodeResponse2.exitCode != 0) { // }
progress?.invoke(nodeResponse2.err) // if (nodeResponse2.exitCode != 0) {
return Result.failure(Exception(nodeResponse2.err)) // progress?.invoke(nodeResponse2.err)
} // return Result.failure(Exception(nodeResponse2.err))
} // }
// }
if (hasDeno) { if (hasDeno) {
val denoResponse = RuntimeManager.getInstance().executeDeno( val denoResponse = RuntimeManager.getInstance().executeDeno(

@ -2764,6 +2764,7 @@ object UiUtil {
installLauncher: ActivityResultLauncher<Intent> installLauncher: ActivityResultLauncher<Intent>
) { ) {
val customView = layoutInflater.inflate(R.layout.layout_update_snackbar, null) val customView = layoutInflater.inflate(R.layout.layout_update_snackbar, null)
customView.findViewById<TextView>(R.id.newVersionTitle).text = context.getString(R.string.version_ready_to_download, v.tag_name)
val triggerAction = View.OnClickListener { val triggerAction = View.OnClickListener {
container.removeView(customView) container.removeView(customView)
showNewAppUpdateDialog(v, context, updateUtil, lifecycleOwner, preferences, installLauncher) showNewAppUpdateDialog(v, context, updateUtil, lifecycleOwner, preferences, installLauncher)
@ -2788,6 +2789,8 @@ object UiUtil {
) { ) {
if (context.isFinishing || context.isDestroyed) return if (context.isFinishing || context.isDestroyed) return
var positiveButton: Button? = null var positiveButton: Button? = null
var negativeButton: Button? = null
var neutralButton: Button? = null
var tmpDownloadJob: Job? = null var tmpDownloadJob: Job? = null
val skippedVersions = preferences.getString("skip_updates", "")?.split(",")?.distinct()?.toMutableList() ?: mutableListOf() val skippedVersions = preferences.getString("skip_updates", "")?.split(",")?.distinct()?.toMutableList() ?: mutableListOf()
@ -2822,6 +2825,9 @@ object UiUtil {
mw.setMarkdown(textView, v.body) mw.setMarkdown(textView, v.body)
positiveButton = view.getButton(android.app.AlertDialog.BUTTON_POSITIVE) positiveButton = view.getButton(android.app.AlertDialog.BUTTON_POSITIVE)
negativeButton = view.getButton(android.app.AlertDialog.BUTTON_NEGATIVE)
neutralButton = view.getButton(android.app.AlertDialog.BUTTON_NEUTRAL)
positiveButton?.setOnClickListener { positiveButton?.setOnClickListener {
positiveButton.isEnabled = false positiveButton.isEnabled = false
positiveButton.text = "0%" positiveButton.text = "0%"
@ -2853,13 +2859,17 @@ object UiUtil {
fileResp.onSuccess { file -> fileResp.onSuccess { file ->
lifecycleScope.launch { lifecycleScope.launch {
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
positiveButton.text = context.getString(R.string.please_wait)
negativeButton.isEnabled = false
neutralButton.isEnabled = false
ApkInstallUtil.installApk(context, file, installLauncher) { result -> ApkInstallUtil.installApk(context, file, installLauncher) { result ->
result.onSuccess { result.onSuccess {
}.onFailure { f -> }.onFailure { f ->
Snackbar.make(context.findViewById(R.id.frame_layout), f.message ?: "", Snackbar.LENGTH_LONG).show() Snackbar.make(context.findViewById(R.id.frame_layout), f.message ?: "", Snackbar.LENGTH_LONG).show()
} }
view.dismiss()
} }
view.dismiss()
} }
} }
} }

Loading…
Cancel
Save