Skip to content

Commit

Permalink
Merge pull request #1250 from aiselp/setup-v7
Browse files Browse the repository at this point in the history
bug修复,界面更新
  • Loading branch information
kkevsekk1 authored Nov 13, 2024
2 parents db8d672 + 40c90d0 commit 3f73e48
Show file tree
Hide file tree
Showing 119 changed files with 2,032 additions and 2,219 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ dependencies {
// Flurry
implementation("com.flurry.android:analytics:13.1.0@aar")
// tencent
implementation("com.tencent.bugly:crashreport:4.0.0")
implementation("com.tencent.tbs:tbssdk:44181")
// MaterialDialogCommon
implementation("com.afollestad.material-dialogs:commons:0.9.2.3")
Expand All @@ -241,7 +240,6 @@ dependencies {
implementation(project(":autojs"))
implementation(project(":apkbuilder"))
implementation(project(":codeeditor"))
implementation("androidx.multidex:multidex:2.0.1")

// ViewModel
implementation(libs.lifecycle.viewmodel.ktx)
Expand Down
12 changes: 4 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@
<activity
android:name="org.autojs.autojs.ui.settings.SettingsActivity"
android:theme="@style/M3AppTheme" />
<activity
android:name="org.autojs.autojs.ui.error.ErrorReportActivity"
android:theme="@style/M3AppTheme" />
<activity
android:name="org.autojs.autojs.external.tasker.TaskerScriptEditActivity"
android:configChanges="orientation|screenSize" />
Expand Down Expand Up @@ -219,6 +216,7 @@
<service
android:name="org.autojs.autojs.external.tile.LayoutBoundsTile"
android:exported="true"
android:process="@string/text_script_process_name"
android:icon="@drawable/ic_circular_menu_bounds"
android:label="@string/text_inspect_layout_bounds"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
Expand All @@ -233,6 +231,7 @@
<service
android:name="org.autojs.autojs.external.tile.LayoutHierarchyTile"
android:exported="true"
android:process="@string/text_script_process_name"
android:icon="@drawable/ic_circular_menu_hierarchy"
android:label="@string/text_inspect_layout_hierarchy"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
Expand Down Expand Up @@ -333,9 +332,6 @@
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
<service
android:name="com.stardust.enhancedfloaty.FloatyService"
android:process="@string/text_script_process_name" />
<service
android:name="org.autojs.autojs.ui.floating.FloatyService"
android:process="@string/text_script_process_name" />
Expand All @@ -353,8 +349,8 @@
</receiver>
<receiver
android:name="org.autojs.autojs.timing.TaskReceiver"
android:process="@string/text_script_process_name"
android:exported="false">
android:exported="false"
android:process="@string/text_script_process_name">
<intent-filter>
<action android:name="com.stardust.autojs.action.task" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ private fun PackagingOptionCard(model: BuildViewModel) {
onValueChange = { model.abiList = it },
label = stringResource(R.string.text_abi)
)
CheckboxOption(model::useNodejs,"启用nodejs引擎")
CheckboxOption(model::isRequiredOpenCv, stringResource(R.string.text_required_opencv))
CheckboxOption(
model::isRequiredMlKitOCR,
Expand Down
17 changes: 12 additions & 5 deletions app/src/main/java/com/aiselp/autox/ui/material3/DrawerPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import com.stardust.autojs.IndependentScriptService
import com.stardust.autojs.core.pref.PrefKey
import com.stardust.notification.NotificationListenerService
import com.stardust.toast
import com.stardust.util.ClipboardUtil
import com.stardust.util.IntentUtil
import com.stardust.view.accessibility.AccessibilityService
import io.github.g00fy2.quickie.QRResult
Expand Down Expand Up @@ -558,7 +559,7 @@ fun USBDebugSwitch() {

@Composable
fun SwitchTimedTaskScheduler() {
val dialog = DialogController()
val dialog = remember { DialogController() }
val scope = rememberCoroutineScope()
TextButton(onClick = { scope.launch { dialog.show() } }) {
Text(text = stringResource(id = R.string.text_switch_timed_task_scheduler))
Expand Down Expand Up @@ -642,9 +643,9 @@ private fun Feedback() {

@Composable
private fun CheckForUpdate(model: DrawerViewModel = viewModel()) {
var showDialog by rememberSaveable { mutableStateOf(false) }
val scope = rememberCoroutineScope()
val dialog = DialogController()
val context = LocalContext.current
val dialog = remember { DialogController() }
var enabled by rememberSaveable { mutableStateOf(true) }

TextButton(
Expand Down Expand Up @@ -674,11 +675,17 @@ private fun CheckForUpdate(model: DrawerViewModel = viewModel()) {
},
positiveText = stringResource(id = R.string.text_download),
onPositiveClick = {
showDialog = false
scope.launch { dialog.dismiss() }
model.downloadApk()
},
negativeText = stringResource(id = R.string.cancel),
onNegativeClick = { showDialog = false },
onNegativeClick = { scope.launch { dialog.dismiss() } },
neutralText = stringResource(R.string.text_copy_link),
onNeutralClick = {
ClipboardUtil.setClip(context, model.getApkNameAndDownloadLink().second)
scope.launch { dialog.dismiss() }
toast(context, R.string.text_copy_successfully)
}
) {
val date = rememberSaveable {
Instant.parse(model.githubReleaseInfo!!.createdAt)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.aiselp.autox.ui.material3

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.FloatingActionButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp


@Composable
fun MainFloatingActionButton(
modifier: Modifier = Modifier,
onClick: () -> Unit,
content: @Composable () -> Unit
) {
FloatingActionButton(
modifier =
Modifier
.padding(16.dp)
.then(modifier), onClick = onClick
) {
content()
}
}
87 changes: 87 additions & 0 deletions app/src/main/java/com/aiselp/autox/ui/material3/MainTopAppBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.aiselp.autox.ui.material3

import android.content.Intent
import android.os.Build
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.aiselp.autojs.codeeditor.EditActivity
import com.aiselp.autox.ui.material3.components.MenuTopAppBar
import org.autojs.autojs.ui.log.LogActivityKt
import org.autojs.autojs.ui.main.BottomNavigationItem
import org.autojs.autoxjs.R


@Composable
fun MainTopAppBar(
openMenuRequest: () -> Unit,
actions: @Composable () -> Unit = {}
) {
val context = LocalContext.current
MenuTopAppBar(
title = stringResource(id = R.string.app_name),
openMenuRequest = openMenuRequest,
actions = {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
EditorButton()
}
LogButton()
actions()
}
)
}

@Composable
private fun EditorButton() {
val context = LocalContext.current
IconButton(onClick = {
context.startActivity(Intent(context, EditActivity::class.java))
}) {
Icon(
imageVector = Icons.Default.Edit,
contentDescription = "editor"
)
}
}

//主界面日志按钮
@Composable
private fun LogButton() {
val context = LocalContext.current
IconButton(onClick = { LogActivityKt.start(context) }) {
Icon(
painter = painterResource(id = R.drawable.ic_logcat),
contentDescription = stringResource(id = R.string.text_logcat)
)
}
}

@Composable
fun BottomBar(
items: List<BottomNavigationItem>,
currentSelected: Int,
onSelectedChange: (Int) -> Unit
) {
NavigationBar {
items.forEachIndexed { i, item ->
NavigationBarItem(
selected = i == currentSelected,
onClick = { onSelectedChange(i) },
label = { Text(text = item.label) },
icon = {
Icon(
painter = painterResource(id = item.icon),
contentDescription = item.label
)
})
}
}
}
21 changes: 5 additions & 16 deletions app/src/main/java/org/autojs/autojs/App.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.autojs.autojs

import android.annotation.SuppressLint
import android.app.Application
import android.app.LocaleManager
import android.content.Intent
import android.os.Build
Expand All @@ -13,25 +14,22 @@ import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.core.os.LocaleListCompat
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.multidex.MultiDexApplication
import androidx.work.Configuration
import com.aiselp.autox.engine.NodeScriptEngine.Companion.initModuleResource
import com.aiselp.autox.ui.material3.activity.ErrorReportActivity
import com.flurry.android.FlurryAgent
import com.stardust.app.GlobalAppContext
import com.stardust.autojs.core.pref.PrefKey
import com.stardust.autojs.servicecomponents.ScriptServiceConnection
import com.stardust.autojs.util.ProcessUtils
import com.stardust.theme.ThemeColor
import com.tencent.bugly.Bugly
import com.tencent.bugly.crashreport.CrashReport
import org.autojs.autojs.autojs.AutoJs
import org.autojs.autojs.autojs.key.GlobalKeyObserver
import org.autojs.autojs.external.receiver.DynamicBroadcastReceivers
import org.autojs.autojs.theme.ThemeColorManagerCompat
import org.autojs.autojs.timing.TimedTaskManager
import org.autojs.autojs.timing.TimedTaskScheduler
import org.autojs.autojs.tool.CrashHandler
import org.autojs.autojs.ui.error.ErrorReportActivity
import org.autojs.autojs.ui.main.MainActivity
import org.autojs.autoxjs.BuildConfig
import org.autojs.autoxjs.R
import java.lang.ref.WeakReference
Expand All @@ -40,7 +38,7 @@ import java.lang.ref.WeakReference
* Created by Stardust on 2017/1/27.
*/

class App : MultiDexApplication(), Configuration.Provider {
class App : Application(), Configuration.Provider {
lateinit var dynamicBroadcastReceivers: DynamicBroadcastReceivers
private set

Expand All @@ -64,16 +62,7 @@ class App : MultiDexApplication(), Configuration.Provider {
}

private fun setUpDebugEnvironment() {
Bugly.isDev = false
val crashHandler = CrashHandler(ErrorReportActivity::class.java)

val strategy = CrashReport.UserStrategy(applicationContext)
strategy.setCrashHandleCallback(crashHandler)

CrashReport.initCrashReport(applicationContext, BUGLY_APP_ID, false, strategy)

crashHandler.setBuglyHandler(Thread.getDefaultUncaughtExceptionHandler())
Thread.setDefaultUncaughtExceptionHandler(crashHandler)
ErrorReportActivity.install(this, MainActivity::class.java)
}

private fun init() {
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/org/autojs/autojs/build/ApkBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,20 @@ class ApkBuilder(
private fun copyLibraries(config: ProjectConfig) {
config.libs.addAllIfNotExist(Constant.Libraries.TERMINAL_EMULATOR)
config.abis.forEach { abi ->
val abiDir = File(nativePath, abi)
if (!abiDir.isDirectory) return@forEach
if (config.useNodejs) {
abiDir.list()?.find {
it.startsWith("libjavet-")
}?.let {
File(abiDir, it).copyTo(
File(workspacePath, "lib/$abi/$it"), true
)
}
}
config.libs.forEach { name ->
kotlin.runCatching {
File(nativePath, "$abi/$name").copyTo(
File(abiDir, name).copyTo(
File(workspacePath, "lib/$abi/$name"),
overwrite = true
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package org.autojs.autojs.external.tile;

import android.os.Build;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

import com.stardust.view.accessibility.NodeInfo;

import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
import org.autojs.autojs.ui.floating.layoutinspector.LayoutBoundsFloatyWindow;

@RequiresApi(api = Build.VERSION_CODES.N)
public class LayoutBoundsTile extends LayoutInspectTileService {
@NonNull
@Override
protected FullScreenFloatyWindow onCreateWindow(NodeInfo capture) {
return new LayoutBoundsFloatyWindow(capture) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.autojs.autojs.external.tile;

import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.annotation.NonNull;

import com.stardust.view.accessibility.NodeInfo;

import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
import org.autojs.autojs.ui.floating.layoutinspector.LayoutHierarchyFloatyWindow;

@RequiresApi(api = Build.VERSION_CODES.N)
public class LayoutHierarchyTile extends LayoutInspectTileService {
@NonNull
@Override
protected FullScreenFloatyWindow onCreateWindow(NodeInfo capture) {
return new LayoutHierarchyFloatyWindow(capture) {
Expand Down
Loading

0 comments on commit 3f73e48

Please sign in to comment.