Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

123 #1

Merged
merged 14 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/android-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,24 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: set up kotlin
uses: fwilhe2/setup-kotlin@main
with:
version: 1.6.20
- name: Build with Gradle
run: chmod 777 ./gradlew && ./gradlew :inrt:assemble && ./gradlew inrt:cp2APP && ./gradlew :app:assembleRelease
run: |
chmod 777 ./gradlew
./gradlew :inrt:assemble
./gradlew :app:assembleRelease
- uses: actions/upload-artifact@v3
with:
name: apks
path: app/build/outputs/apk/v6/release/*
9 changes: 6 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Build inrt template
run: |
chmod 777 ./gradlew
Expand All @@ -41,6 +41,8 @@ jobs:
alias: ${{ secrets.AALIAS }}
keyStorePassword: ${{ secrets.AKEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.AKEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: "33.0.0"
- name: rename apk
run: |
cd build/app/signed
Expand Down Expand Up @@ -69,5 +71,6 @@ jobs:
access-key-secret: ${{ secrets.OSS_KEY_SECRET }}
- name: update apk to aliyun
if: github.repository == 'kkevsekk1/AutoX'
run: ossutil mkdir oss://autoxjsoss/autoxjs/${{ steps.vars.outputs.short_ref }}
ossutil cp -rf build/app/signed oss://autoxjsoss/autoxjs/${{ steps.vars.outputs.short_ref }}
run: |
ossutil mkdir oss://autoxjsoss/autoxjs/${{ steps.vars.outputs.short_ref }}
ossutil cp -rf build/app/signed oss://autoxjsoss/autoxjs/${{ steps.vars.outputs.short_ref }}
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
# Change Log
autoxjs 整个项目的一些更新日志,双版本号为稳定版(内容以修复的bug为主),单版本号为激进版本、发布新内容。

## [Unreleased](https://github.com/kkevsekk1/AutoX/compare/6.5.5...HEAD) 未发布
## [Unreleased](https://github.com/kkevsekk1/AutoX/compare/6.5.7...HEAD) 未发布


## [6.5.7] - 2024-1-14
@aiselp
* 修复运行ui脚本存在的内存泄露
* 截图逻辑优化,使截图权限在所有脚本共享
* 添加离线文档选项
@Lin
* 浏览器打开改为直接下载安装
* 修复"emit"报错
* 每次打开都是新任务,不受上一次打开文件内容的影响

[6.5.7]:https://github.com/kkevsekk1/AutoX/compare/6.5.6...6.5.7

## [6.5.6] - 2023-12-16
@aiselp
* 优化编辑器
@Lin
* 增加编辑器选择
* 编辑器优化
* 主页搜索优化


[6.5.6]:https://github.com/kkevsekk1/AutoX/compare/6.5.5...6.5.6

## [6.5.5] - 2023-11-10
@aiselp
Expand Down
3 changes: 2 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/build
/src/main/assets/docs
55 changes: 44 additions & 11 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import com.android.build.gradle.internal.tasks.factory.dependsOn
import okhttp3.Request
import java.util.Properties
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream

plugins {
id("com.android.application")
Expand Down Expand Up @@ -170,6 +173,7 @@ dependencies {

implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation(libs.androidx.webkit)

implementation(libs.bundles.accompanist)

Expand Down Expand Up @@ -233,21 +237,17 @@ dependencies {
implementation("com.thoughtbot:expandablerecyclerview:1.3")
// implementation("org.signal.autox:apkbuilder:1.0.3")
// RxJava
implementation("io.reactivex.rxjava2:rxjava:2.2.21")
implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
implementation(libs.rxjava2)
implementation(libs.rxjava2.rxandroid)
// Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.8.1")
releaseImplementation("com.squareup.leakcanary:leakcanary-android-no-op:1.6.3")
debugImplementation(libs.leakcanary.android)
// Optional, if you use support library fragments:
debugImplementation("com.squareup.leakcanary:leakcanary-support-fragment:1.6.3")
implementation("com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0")
implementation("com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2")
//Glide
implementation("com.github.bumptech.glide:glide:4.8.0") {
exclude(group = "com.android.support")
}
implementation("com.github.bumptech.glide:glide:4.8.0")
kapt("com.github.bumptech.glide:compiler:4.12.0")
annotationProcessor("com.github.bumptech.glide:compiler:4.12.0")
//joda time
Expand All @@ -260,9 +260,7 @@ dependencies {
implementation("com.tencent.bugly:crashreport:4.0.0")
api("com.tencent.tbs:tbssdk:44181")
// MaterialDialogCommon
implementation("com.afollestad.material-dialogs:commons:0.9.2.3") {
exclude(group = "com.android.support")
}
implementation("com.afollestad.material-dialogs:commons:0.9.2.3")
// WorkManager
implementation("androidx.work:work-runtime:2.7.1")
// Android job
Expand Down Expand Up @@ -333,4 +331,39 @@ tasks.named("clean").configure {
doFirst {
delete(File(assetsDir, "template.apk"))
}
}
//离线文档下载安装
val docsDir = File(projectDir, "src/main/assets/docs")
tasks.named("preBuild").dependsOn("installationDocumentation")
tasks.register("installationDocumentation") {
val docV1Uri = "https://codeload.github.com/kkevsekk1/kkevsekk1.github.io/zip/refs/heads/main"
val docV1Dir = File(docsDir, "v1")
doFirst {
if (File(docV1Dir, "index.html").isFile) {
return@doFirst
}
okhttp3.OkHttpClient().newCall(Request.Builder().url(docV1Uri).build()).execute()
.use { response ->
check(response.isSuccessful) { "installationDocumentation failed" }
val body = response.body!!
ZipInputStream(body.byteStream()).use { zip ->
var zipEntry: ZipEntry?;
while (true) {
zipEntry = zip.nextEntry ?: break
val file = File(docV1Dir, zipEntry.name.replaceFirst(Regex(".+?/"), ""))
if (zipEntry.isDirectory) {
file.mkdirs()
} else {
file.outputStream().use {
zip.copyTo(it)
}
}
zip.closeEntry()
}
}
}
}
}
tasks.named("clean").configure {
doFirst { delete(docsDir) }
}
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,17 @@
<action android:name="com.android.deskclock.ALARM_ALERT" />
</intent-filter>
</receiver>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<!-- If you are using androidx.startup to initialize other components -->
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>
</application>

</manifest>
23 changes: 20 additions & 3 deletions app/src/main/java/org/autojs/autojs/ui/main/components/main_ui.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.autojs.autojs.ui.main.components

import android.webkit.WebView
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.width
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.Icon
Expand All @@ -16,12 +17,15 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.stardust.util.IntentUtil
import org.autojs.autojs.ui.log.LogActivityKt
import org.autojs.autojs.ui.widget.WebDataKt
import org.autojs.autojs.ui.main.web.DocumentSource
import org.autojs.autojs.ui.main.web.DocumentSourceSelectDialog
import org.autojs.autoxjs.R

//主界面日志按钮
Expand All @@ -38,7 +42,7 @@ fun LogButton() {

//文档界面菜单按钮
@Composable
fun DocumentPageMenuButton(getWebView:()-> WebView) {
fun DocumentPageMenuButton(getWebView: () -> WebView) {
val context = LocalContext.current
Box {
var expanded by remember { mutableStateOf(false) }
Expand All @@ -53,7 +57,7 @@ fun DocumentPageMenuButton(getWebView:()-> WebView) {
onDismissRequest = { expanded = false }) {
DropdownMenuItem(onClick = {
dismissMenu()
getWebView().loadUrl(WebDataKt.homepage)
getWebView().loadUrl(DocumentSource.DOC_V1.uri)
}) {
Icon(Icons.Default.Home, contentDescription = null)
Text(text = "回到主页")
Expand All @@ -78,6 +82,19 @@ fun DocumentPageMenuButton(getWebView:()-> WebView) {
Icon(Icons.Default.Refresh, contentDescription = null)
Text(text = "刷新")
}
DropdownMenuItem(onClick = {
dismissMenu()
DocumentSourceSelectDialog(getWebView()).show()
}) {
Box(Modifier.width(20.dp)) {
Icon(
painterResource(id = R.drawable.community_list),
contentDescription = null
)
}

Text(text = "选择文档源")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.autojs.autojs.ui.main.web

import android.content.Context
import android.util.Log
import android.webkit.MimeTypeMap
import android.webkit.WebResourceResponse
import androidx.webkit.WebViewAssetLoader
import java.io.File
import java.io.IOException
import java.io.InputStream

class AssetsPathHandler(val context: Context, private val assetPath: String) :
WebViewAssetLoader.PathHandler {
private fun parsePath(path: String): String {
var newPath = File(assetPath, path.ifEmpty { "index.html" }).path
if (newPath.startsWith("/")) {
newPath = newPath.substring(1)
}
// println("path: $path to-------- newPath: $newPath")
return newPath
}

override fun handle(path: String): WebResourceResponse? {
return try {
val newPath = parsePath(path)
val `is`: InputStream = context.assets.open(newPath)
val ext = MimeTypeMap.getFileExtensionFromUrl(newPath)
val mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext)
WebResourceResponse(mimeType, null, `is`)
} catch (e: IOException) {
Log.e(TAG, "Error opening asset path: $path", e)
WebResourceResponse(null, null, null)
}
}

companion object {
const val TAG = "AssetsPathHandler"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.autojs.autojs.ui.main.web

enum class DocumentSource(val sourceName: String, val uri: String, val isLocal: Boolean = false) {
DOC_V1("在线文档", "http://doc.autoxjs.com/"),
DOC_V1_LOCAL("本地文档", "docs/v1", true)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.autojs.autojs.ui.main.web

import android.webkit.WebView
import com.afollestad.materialdialogs.MaterialDialog

class DocumentSourceSelectDialog(private val webView: WebView) {
private val documentSources = DocumentSource.values()
private var select: DocumentSource? = null
private val dialogBuilder = MaterialDialog.Builder(webView.context)
.title("选择文档源")
.items(documentSources.map { it.sourceName })
.itemsCallback { _, _, position, _ ->
select = documentSources[position]
}
.dismissListener { _ -> switchDocument() }

init {
val name = EditorAppManager.getSaveStatus(webView.context)
.getString(EditorAppManager.DocumentSourceKEY, DocumentSource.DOC_V1_LOCAL.name)!!
val documentSource = DocumentSource.valueOf(name)
val i = documentSources.lastIndexOf(documentSource)
dialogBuilder.itemsCallbackSingleChoice(if (i == -1) 0 else i) { _, _, position, _ ->
select = documentSources[position]
true
}
}

private fun switchDocument() {
val documentSource = select ?: return
EditorAppManager.switchDocument(webView, documentSource)
}

fun show(): MaterialDialog = dialogBuilder.show()
}
Loading
Loading