mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-06 07:20:47 -05:00
Remove legacy UI infrastructure and migrate dialogs to Compose
Replace the imperative MagiskDialog/DialogBuilder system with Compose-idiomatic dialogs using miuix SuperDialog. Remove ViewEvent, UIActivity, ViewModelHolder, and all old dialog classes. Migrate ViewModels to expose dialog state via StateFlow instead of holding Activity references. Remove LiveData from FlashViewModel and ActionViewModel. Delete orphaned resources (XML menus, drawables, styles). Provide LocalContentColor in MagiskTheme to fix dark theme text visibility across all miuix components. Made-with: Cursor
This commit is contained in:
@@ -29,19 +29,6 @@ interface ContentResultCallback: ActivityResultCallback<Uri>, Parcelable {
|
||||
|
||||
interface UntrackedActivity
|
||||
|
||||
interface IActivityExtension {
|
||||
val extension: ActivityExtension
|
||||
fun withPermission(permission: String, callback: (Boolean) -> Unit) {
|
||||
extension.withPermission(permission, callback)
|
||||
}
|
||||
fun withAuthentication(callback: (Boolean) -> Unit) {
|
||||
extension.withAuthentication(callback)
|
||||
}
|
||||
fun getContent(type: String, callback: ContentResultCallback) {
|
||||
extension.getContent(type, callback)
|
||||
}
|
||||
}
|
||||
|
||||
class ActivityExtension(private val activity: ComponentActivity) {
|
||||
|
||||
private var permissionCallback: ((Boolean) -> Unit)? = null
|
||||
|
||||
@@ -27,8 +27,9 @@ import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
interface SplashScreenHost : IActivityExtension {
|
||||
interface SplashScreenHost {
|
||||
val splashController: SplashController<*>
|
||||
val extension: ActivityExtension
|
||||
|
||||
fun onCreateUi(savedInstanceState: Bundle?)
|
||||
fun showInvalidStateMessage()
|
||||
@@ -45,7 +46,6 @@ class SplashController<T>(private val activity: T)
|
||||
|
||||
fun preOnCreate() {
|
||||
if (isRunningAsStub && !splashShown) {
|
||||
// Manually apply splash theme for stub
|
||||
activity.theme.applyStyle(R.style.StubSplashTheme, true)
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,6 @@ class SplashController<T>(private val activity: T)
|
||||
activity.runOnUiThread {
|
||||
splashShown = true
|
||||
if (isRunningAsStub) {
|
||||
// Re-launch main activity without splash theme
|
||||
activity.relaunch()
|
||||
} else {
|
||||
if (activity.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||
@@ -102,7 +101,6 @@ class SplashController<T>(private val activity: T)
|
||||
|
||||
if (packageName != APP_PACKAGE_NAME) {
|
||||
runCatching {
|
||||
// Hidden, remove com.topjohnwu.magisk if exist as it could be malware
|
||||
packageManager.getApplicationInfo(APP_PACKAGE_NAME, 0)
|
||||
Shell.cmd("(pm uninstall $APP_PACKAGE_NAME)& >/dev/null 2>&1").exec()
|
||||
}
|
||||
@@ -117,20 +115,16 @@ class SplashController<T>(private val activity: T)
|
||||
|
||||
if (isPackageMigration) {
|
||||
runOnUiThread {
|
||||
// Relaunch the process after package migration
|
||||
StubApk.restartProcess(this)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Validate stub APK
|
||||
if (isRunningAsStub && (
|
||||
// Version mismatch
|
||||
Info.stub!!.version != BuildConfig.STUB_VERSION ||
|
||||
// Not properly patched
|
||||
intent.component!!.className.contains(AppMigration.PLACEHOLDER))
|
||||
) {
|
||||
withPermission(REQUEST_INSTALL_PACKAGES) { granted ->
|
||||
extension.withPermission(REQUEST_INSTALL_PACKAGES) { granted ->
|
||||
if (granted) {
|
||||
lifecycleScope.launch {
|
||||
val apk = File(cacheDir, "stub.apk")
|
||||
@@ -152,10 +146,8 @@ class SplashController<T>(private val activity: T)
|
||||
JobService.schedule(this)
|
||||
Shortcuts.setupDynamic(this)
|
||||
|
||||
// Pre-fetch network services
|
||||
ServiceLocator.networkService
|
||||
|
||||
// Wait for root service
|
||||
RootUtils.Connection.await()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.topjohnwu.magisk.core.AppContext
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.core.JobService
|
||||
import com.topjohnwu.magisk.core.R
|
||||
import com.topjohnwu.magisk.core.base.IActivityExtension
|
||||
import com.topjohnwu.magisk.core.base.ActivityExtension
|
||||
import com.topjohnwu.magisk.core.cmp
|
||||
import com.topjohnwu.magisk.core.di.ServiceLocator
|
||||
import com.topjohnwu.magisk.core.intent
|
||||
@@ -105,12 +105,12 @@ class DownloadEngine(session: DownloadSession) : DownloadSession by session, Dow
|
||||
}
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
fun <T> startWithActivity(
|
||||
activity: T,
|
||||
fun startWithActivity(
|
||||
activity: ComponentActivity,
|
||||
extension: ActivityExtension,
|
||||
subject: Subject
|
||||
) where T : ComponentActivity, T : IActivityExtension {
|
||||
activity.withPermission(Manifest.permission.POST_NOTIFICATIONS) {
|
||||
// Always download regardless of notification permission status
|
||||
) {
|
||||
extension.withPermission(Manifest.permission.POST_NOTIFICATIONS) {
|
||||
start(activity.applicationContext, subject)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user