Add starting modules from manager
This commit is contained in:
parent
f7c6af53ec
commit
415f434d08
|
|
@ -15,7 +15,7 @@ buildscript {
|
|||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r")
|
||||
classpath("org.eclipse.jgit:org.eclipse.jgit:6.3.0.202209071007-r")
|
||||
classpath(kotlin("gradle-plugin", version = "1.7.10"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@ android {
|
|||
}
|
||||
|
||||
sourceSets["main"].assets.srcDirs(rootProject.projectDir.resolve("out/assets"))
|
||||
|
||||
applicationVariants.all {
|
||||
kotlin.sourceSets {
|
||||
getByName(name) {
|
||||
kotlin.srcDir("build/generated/ksp/$name/kotlin")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
|
|
@ -49,12 +57,6 @@ afterEvaluate {
|
|||
val variantLowered = variant.name.toLowerCase()
|
||||
val variantCapped = variant.name.capitalize()
|
||||
|
||||
kotlin.sourceSets {
|
||||
getByName(variant.name) {
|
||||
kotlin.srcDir("build/generated/ksp/${variant.name}/kotlin")
|
||||
}
|
||||
}
|
||||
|
||||
task<Copy>("copy${variantCapped}Assets") {
|
||||
dependsOn(":appstub:copy$variantCapped")
|
||||
dependsOn(":patch-loader:copy$variantCapped")
|
||||
|
|
@ -96,7 +98,6 @@ dependencies {
|
|||
implementation("androidx.preference:preference:1.2.0")
|
||||
implementation("androidx.room:room-ktx:$roomVersion")
|
||||
implementation("androidx.room:room-runtime:$roomVersion")
|
||||
implementation("com.google.accompanist:accompanist-drawablepainter:$accompanistVersion")
|
||||
implementation("com.google.accompanist:accompanist-navigation-animation:$accompanistVersion")
|
||||
implementation("com.google.accompanist:accompanist-pager:$accompanistVersion")
|
||||
implementation("com.google.accompanist:accompanist-swiperefresh:$accompanistVersion")
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ fun AnywhereDropdown(
|
|||
}
|
||||
|
||||
LaunchedEffect(state) {
|
||||
if (state is PressInteraction.Press) {
|
||||
val i = state as PressInteraction.Press
|
||||
offset = i.pressPosition
|
||||
}
|
||||
if (state is PressInteraction.Release) {
|
||||
val i = state as PressInteraction.Release
|
||||
offset = i.press.pressPosition
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ fun AppManageBody(
|
|||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false },
|
||||
onClick = { expanded = true },
|
||||
onLongClick = { expanded = true },
|
||||
surface = {
|
||||
AppItem(
|
||||
icon = LSPPackageManager.getIcon(it.first),
|
||||
|
|
@ -164,6 +165,10 @@ fun AppManageBody(
|
|||
)
|
||||
}
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(text = it.first.label, color = MaterialTheme.colorScheme.primary) },
|
||||
onClick = {}, enabled = false
|
||||
)
|
||||
val shizukuUnavailable = stringResource(R.string.shizuku_unavailable)
|
||||
if (it.second.lspConfig.VERSION_CODE < LSPConfig.instance.VERSION_CODE || BuildConfig.DEBUG) {
|
||||
DropdownMenuItem(
|
||||
|
|
|
|||
|
|
@ -1,15 +1,20 @@
|
|||
package org.lsposed.lspatch.ui.page.manage
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.Settings
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
|
|
@ -25,6 +30,7 @@ import org.lsposed.lspatch.util.LSPPackageManager
|
|||
|
||||
@Composable
|
||||
fun ModuleManageBody() {
|
||||
val context = LocalContext.current
|
||||
val viewModel = viewModel<ModuleManageViewModel>()
|
||||
if (viewModel.appList.isEmpty()) {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
|
|
@ -45,10 +51,11 @@ fun ModuleManageBody() {
|
|||
key = { it.first.app.packageName }
|
||||
) {
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
val launchIntent = remember { LSPPackageManager.getLaunchIntentForPackage(it.first.app.packageName) }
|
||||
AnywhereDropdown(
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false },
|
||||
onClick = { /* TODO: Start module */ },
|
||||
onClick = { launchIntent?.let { context.startActivity(it) } },
|
||||
onLongClick = { expanded = true },
|
||||
surface = {
|
||||
AppItem(
|
||||
|
|
@ -74,7 +81,26 @@ fun ModuleManageBody() {
|
|||
)
|
||||
}
|
||||
) {
|
||||
// TODO: Implement
|
||||
DropdownMenuItem(
|
||||
text = { Text(text = it.first.label, color = MaterialTheme.colorScheme.primary) },
|
||||
onClick = {}, enabled = false
|
||||
)
|
||||
if (launchIntent != null) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.manage_module_settings)) },
|
||||
onClick = { context.startActivity(launchIntent) }
|
||||
)
|
||||
}
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.manage_app_info)) },
|
||||
onClick = {
|
||||
val intent = Intent(
|
||||
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts("package", it.first.app.packageName, null)
|
||||
)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,4 +187,27 @@ object LSPPackageManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getLaunchIntentForPackage(packageName: String): Intent? {
|
||||
val intentToResolve = Intent(Intent.ACTION_MAIN)
|
||||
intentToResolve.addCategory(Intent.CATEGORY_INFO)
|
||||
intentToResolve.setPackage(packageName)
|
||||
var ris = lspApp.packageManager.queryIntentActivities(intentToResolve, 0)
|
||||
|
||||
if (ris.size <= 0) {
|
||||
intentToResolve.removeCategory(Intent.CATEGORY_INFO)
|
||||
intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
intentToResolve.setPackage(packageName)
|
||||
ris = lspApp.packageManager.queryIntentActivities(intentToResolve, 0)
|
||||
}
|
||||
|
||||
if (ris.size <= 0) return null
|
||||
|
||||
return Intent(intentToResolve)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.setClassName(
|
||||
ris[0].activityInfo.packageName,
|
||||
ris[0].activityInfo.name
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
<string name="manage_optimize_failed">Optimize failed</string>
|
||||
<string name="manage_uninstall_successfully">Uninstall successfully</string>
|
||||
<string name="manage_no_modules">No modules yet</string>
|
||||
<string name="manage_module_settings">Module settings</string>
|
||||
<string name="manage_app_info">App info</string>
|
||||
|
||||
<!-- New Patch Screen -->
|
||||
<string name="screen_new_patch">New Patch</string>
|
||||
|
|
|
|||
Loading…
Reference in New Issue