manager: Enhanced External Selection Sharing Single/Batch Module Installation

- Reduce the delay exit time in seconds
This commit is contained in:
ShirkNeko
2025-10-08 19:16:30 +08:00
parent 230ca54d63
commit ca7b53370e
4 changed files with 45 additions and 13 deletions

View File

@@ -37,6 +37,16 @@
<data android:mimeType="application/zip" /> <data android:mimeType="application/zip" />
<data android:scheme="content" /> <data android:scheme="content" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/zip" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/zip" />
</intent-filter>
</activity> </activity>
<activity-alias <activity-alias

View File

@@ -1,6 +1,7 @@
package com.sukisu.ultra.ui package com.sukisu.ultra.ui
import android.content.Context import android.content.Context
import android.content.Intent
import android.content.res.Configuration import android.content.res.Configuration
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
@@ -95,14 +96,35 @@ class MainActivity : ComponentActivity() {
} }
// Check if launched with a ZIP file // Check if launched with a ZIP file
val zipUri: ArrayList<Uri>? = if (intent.data != null) { val zipUri: ArrayList<Uri>? = when (intent?.action) {
arrayListOf(intent.data!!) Intent.ACTION_SEND -> {
} else { val uri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { intent.getParcelableExtra(Intent.EXTRA_STREAM, Uri::class.java)
intent.getParcelableArrayListExtra("uris", Uri::class.java) } else {
} else { @Suppress("DEPRECATION")
@Suppress("DEPRECATION") intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
intent.getParcelableArrayListExtra("uris") }
uri?.let { arrayListOf(it) }
}
Intent.ACTION_SEND_MULTIPLE -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM, Uri::class.java)
} else {
@Suppress("DEPRECATION")
intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM)
}
}
else -> when {
intent?.data != null -> arrayListOf(intent.data!!)
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> {
intent.getParcelableArrayListExtra("uris", Uri::class.java)
}
else -> {
@Suppress("DEPRECATION")
intent.getParcelableArrayListExtra("uris")
}
} }
} }

View File

@@ -241,7 +241,7 @@ fun FlashScreen(navigator: DestinationsNavigator, flashIt: FlashIt) {
// 如果是外部安装或需要自动退出的模块更新且不需要重启,延迟后自动返回 // 如果是外部安装或需要自动退出的模块更新且不需要重启,延迟后自动返回
if (isExternalInstall || shouldAutoExit) { if (isExternalInstall || shouldAutoExit) {
scope.launch { scope.launch {
kotlinx.coroutines.delay(2000) kotlinx.coroutines.delay(1000)
if (shouldAutoExit) { if (shouldAutoExit) {
val sharedPref = context.getSharedPreferences("kernel_flash_prefs", Context.MODE_PRIVATE) val sharedPref = context.getSharedPreferences("kernel_flash_prefs", Context.MODE_PRIVATE)
sharedPref.edit { remove("auto_exit_after_flash") } sharedPref.edit { remove("auto_exit_after_flash") }
@@ -344,7 +344,7 @@ fun FlashScreen(navigator: DestinationsNavigator, flashIt: FlashIt) {
} else if ((isExternalInstall || shouldAutoExit) && flashIt is FlashIt.FlashModules && flashIt.currentIndex >= flashIt.uris.size - 1) { } else if ((isExternalInstall || shouldAutoExit) && flashIt is FlashIt.FlashModules && flashIt.currentIndex >= flashIt.uris.size - 1) {
// 如果是外部安装或需要自动退出且是最后一个模块,安装完成后自动返回 // 如果是外部安装或需要自动退出且是最后一个模块,安装完成后自动返回
scope.launch { scope.launch {
kotlinx.coroutines.delay(2000) kotlinx.coroutines.delay(1000)
if (shouldAutoExit) { if (shouldAutoExit) {
val sharedPref = context.getSharedPreferences("kernel_flash_prefs", Context.MODE_PRIVATE) val sharedPref = context.getSharedPreferences("kernel_flash_prefs", Context.MODE_PRIVATE)
sharedPref.edit { remove("auto_exit_after_flash") } sharedPref.edit { remove("auto_exit_after_flash") }
@@ -354,7 +354,7 @@ fun FlashScreen(navigator: DestinationsNavigator, flashIt: FlashIt) {
} else if ((isExternalInstall || shouldAutoExit) && flashIt is FlashIt.FlashModule) { } else if ((isExternalInstall || shouldAutoExit) && flashIt is FlashIt.FlashModule) {
// 如果是外部安装或需要自动退出的单个模块,安装完成后自动返回 // 如果是外部安装或需要自动退出的单个模块,安装完成后自动返回
scope.launch { scope.launch {
kotlinx.coroutines.delay(2000) kotlinx.coroutines.delay(1000)
if (shouldAutoExit) { if (shouldAutoExit) {
val sharedPref = context.getSharedPreferences("kernel_flash_prefs", Context.MODE_PRIVATE) val sharedPref = context.getSharedPreferences("kernel_flash_prefs", Context.MODE_PRIVATE)
sharedPref.edit { remove("auto_exit_after_flash") } sharedPref.edit { remove("auto_exit_after_flash") }

View File

@@ -115,10 +115,10 @@ fun KernelFlashScreen(
showFloatAction = true showFloatAction = true
KernelFlashStateHolder.isFlashing = false KernelFlashStateHolder.isFlashing = false
// 如果需要自动退出,延迟3秒后退出 // 如果需要自动退出,延迟1.5秒后退出
if (shouldAutoExit) { if (shouldAutoExit) {
scope.launch { scope.launch {
delay(3000) delay(1500)
val sharedPref = context.getSharedPreferences("kernel_flash_prefs", Context.MODE_PRIVATE) val sharedPref = context.getSharedPreferences("kernel_flash_prefs", Context.MODE_PRIVATE)
sharedPref.edit { remove("auto_exit_after_flash") } sharedPref.edit { remove("auto_exit_after_flash") }
(context as? ComponentActivity)?.finish() (context as? ComponentActivity)?.finish()