Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 5f7a282

Browse files
committed
修复了部分系统无法编译插件的问题
1 parent 8f3684b commit 5f7a282

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

app/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ dependencies {
130130
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
131131
implementation 'com.google.android.material:material:1.3.0'
132132

133-
implementation 'androidx.core:core-ktx:1.5.0-rc01'
133+
implementation 'androidx.core:core-ktx:1.6.0-rc01'
134134

135135
//androidx-appcompat
136-
implementation 'androidx.appcompat:appcompat:1.2.0'
136+
implementation 'androidx.appcompat:appcompat:1.3.0'
137137

138138
//androidx-legacy
139139
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
@@ -156,7 +156,7 @@ dependencies {
156156
implementation 'androidx.preference:preference:1.1.1'
157157

158158
//kotlinx-coroutines
159-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2"
159+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0"
160160
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
161161

162162
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0"
@@ -193,7 +193,7 @@ dependencies {
193193
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
194194

195195
//yaml
196-
implementation 'net.mamoe.yamlkt:yamlkt:0.7.5'
196+
implementation 'net.mamoe.yamlkt:yamlkt:0.9.0'
197197
implementation group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.2'
198198

199199
//okhttp3
@@ -204,6 +204,9 @@ dependencies {
204204

205205
implementation 'com.fanjun:keeplive:1.1.22'
206206

207+
implementation group: 'commons-io', name: 'commons-io', version: '2.10.0'
208+
209+
207210
// fuck!! 他不能在Android平台工作
208211
// implementation 'org.codehaus.groovy:groovy:2.4.6:grooid'
209212

app/src/main/java/io/github/mzdluo123/mirai/android/activity/PluginImportActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class PluginImportActivity : AppCompatActivity() {
6868
"无法编译插件 \n${throwable}",
6969
Toast.LENGTH_LONG
7070
).show()
71+
throwable.printStackTrace()
7172
}
7273
}
7374

@@ -80,17 +81,20 @@ class PluginImportActivity : AppCompatActivity() {
8081
val name = withContext(Dispatchers.Main) {
8182
askFileName()
8283
} ?: return@launch
84+
// 从contentprovider 读取插件数据到缓存
8385
withContext(Dispatchers.IO) {
8486
copyToFileDir(
8587
uri,
8688
name,
8789
this@PluginImportActivity.getExternalFilesDir(null)!!.absolutePath
8890
)
8991
}
92+
// 编译插件
9093
pluginViewModel.compilePlugin(
9194
File(baseContext.getExternalFilesDir(null), name),
9295
desugaring_checkBox.isChecked
9396
)
97+
// 删除缓存
9498
withContext(Dispatchers.IO) {
9599
File(this@PluginImportActivity.getExternalFilesDir(null), name).delete()
96100
}

app/src/main/java/io/github/mzdluo123/mirai/android/service/BotService.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import net.mamoe.mirai.console.rootDir
4646
import net.mamoe.mirai.event.GlobalEventChannel
4747
import net.mamoe.mirai.event.events.BotOnlineEvent
4848
import net.mamoe.mirai.message.data.At
49+
import net.mamoe.mirai.utils.MiraiLogger
4950
import java.nio.file.Paths
5051
import kotlin.system.exitProcess
5152

@@ -135,7 +136,12 @@ class BotService : LifecycleService() {
135136
// 新的自动登录
136137
//MiraiConsole.addBot().alsoLogin()
137138
// GlobalScope.launch(handler) { sendMessage("$qq login successes") }
138-
val bot = MiraiConsole.addBot(qq, pwd!!.chunkedHexToBytes())
139+
val bot = MiraiConsole.addBot(qq, pwd!!.chunkedHexToBytes(),){
140+
if (AppSettings.printToLogcat){
141+
this.networkLoggerSupplier = {MiraiLogger.create("NetLog")}
142+
}
143+
}
144+
139145
lifecycleScope.launch(Dispatchers.Default + handler) { bot.login() }
140146
}
141147

app/src/main/java/io/github/mzdluo123/mirai/android/ui/plugin/PluginViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class PluginViewModel : ViewModel() {
7373
val out = compiler.compile(file, desugaring)
7474
compiler.copyResourcesAndMove(file, out)
7575
}
76+
7677
}
7778

7879
private fun deleteDir(path: File) {

app/src/main/java/io/github/mzdluo123/mirai/android/utils/DexCompiler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import net.lingala.zip4j.exception.ZipException;
1111

1212

13+
import org.apache.commons.io.FileUtils;
14+
1315
import java.io.File;
1416
import java.io.IOException;
1517
import java.util.ArrayList;
@@ -76,6 +78,8 @@ public void copyResourcesAndMove(File origin, File newFile) throws IOException {
7678
newZip.addFiles(resources);
7779
}
7880
newZip.addFolder(new File(tempDir, "META-INF"));
79-
newFile.renameTo(new File(pluginDir, newFile.getName()));
81+
// 自带的moveto在遇到不同文件系统的时候会失败
82+
FileUtils.moveFile(newFile,new File(pluginDir, newFile.getName()));
83+
8084
}
8185
}

0 commit comments

Comments
 (0)