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

Commit f669faf

Browse files
committed
3.1.1
1 parent 298f6ac commit f669faf

File tree

7 files changed

+38
-23
lines changed

7 files changed

+38
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mirai-console的Android前端程序,可作为qq机器人使用,支持多种
3131

3232
最新的构建版本你可以到release或QQ群内找到
3333

34-
MiraiAndroid交流群:`1131127734`但是请注意,如果您违反了群内相关规定或是有其他不当行为你可能会被无理由移出本群
34+
MiraiAndroid交流群:~~`1131127734`(旧群群主被封)~~ 新群`206073050` 但是请注意,如果您违反了群内相关规定或是有其他不当行为你可能会被无理由移出本群
3535

3636
图标以及形象由画师<a href = "https://github.com/DazeCake">DazeCake</a>绘制
3737

app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ apply plugin: 'kotlin-kapt'
55
apply plugin: 'kotlinx-serialization'
66

77

8-
def CORE_VERSION = "2.4.0"
9-
def CONSOLE_VERSION = "2.4.0"
8+
def CORE_VERSION = "2.5.1"
9+
def CONSOLE_VERSION = "2.5.1"
1010
def LUAMIRAI_VERSION = "2.0.8"
1111

1212
android {
@@ -17,8 +17,8 @@ android {
1717
applicationId "io.github.mzdluo123.mirai.android"
1818
minSdkVersion 26
1919
targetSdkVersion 30
20-
versionCode 43
21-
versionName "3.1.0-dev4"
20+
versionCode 44
21+
versionName "3.1.1"
2222
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2323
buildConfigField("String", "COREVERSION", "\"$CORE_VERSION\"")
2424
buildConfigField("String", "CONSOLEVERSION", "\"$CONSOLE_VERSION\"")
@@ -132,7 +132,7 @@ dependencies {
132132
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.2'
133133

134134
//mirai-core
135-
implementation("net.mamoe:mirai-core-jvm:$CORE_VERSION")
135+
implementation("net.mamoe:mirai-core:$CORE_VERSION")
136136
// implementation("net.mamoe:mirai-core:$CORE_VERSION"){
137137
// exclude module: "mirai-core-utils"
138138
// // 修复Duplicate class

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,18 @@ import io.github.mzdluo123.mirai.android.utils.SafeDns
2121
import io.github.mzdluo123.mirai.android.utils.shareText
2222
import kotlinx.android.synthetic.main.activity_main.*
2323
import kotlinx.android.synthetic.main.app_bar_main.*
24-
import kotlinx.coroutines.*
24+
import kotlinx.coroutines.CoroutineExceptionHandler
25+
import kotlinx.coroutines.delay
26+
import kotlinx.coroutines.launch
2527
import kotlinx.serialization.json.Json
2628
import kotlinx.serialization.json.jsonObject
2729
import kotlinx.serialization.json.jsonPrimitive
28-
import okhttp3.OkHttpClient
29-
import okhttp3.Request
3030
import splitties.alertdialog.appcompat.alertDialog
3131
import splitties.alertdialog.appcompat.cancelButton
3232
import splitties.alertdialog.appcompat.message
3333
import splitties.alertdialog.appcompat.okButton
34-
import splitties.lifecycle.coroutines.coroutineScope
3534
import splitties.toast.toast
3635
import java.io.File
37-
import java.io.FileReader
3836

3937

4038
class MainActivity : AppCompatActivity() {
@@ -71,8 +69,9 @@ class MainActivity : AppCompatActivity() {
7169
(application as BotApplication).startBotService()
7270
setupListeners()
7371
crashCheck()
74-
if (BuildConfig.DEBUG) toast("跳过更新检查")
75-
else updateCheck()
72+
// if (BuildConfig.DEBUG) toast("跳过更新检查")
73+
// else updateCheck()
74+
updateCheck()
7675
}
7776

7877
override fun onSupportNavigateUp(): Boolean =
@@ -124,8 +123,8 @@ class MainActivity : AppCompatActivity() {
124123
// BotApplication.context.stopBotService()
125124
}
126125
lifecycleScope.launch(exceptionHandler) {
127-
val responseText = RequestUtil.get(UPDATE_URL){ dns(SafeDns()) }
128-
val responseJsonObject = Json.parseToJsonElement(responseText).jsonObject
126+
val responseText = RequestUtil.get(UPDATE_URL) { dns(SafeDns()) }
127+
val responseJsonObject = Json.parseToJsonElement(responseText ?: "").jsonObject
129128
if (!responseJsonObject.containsKey("url")) throw IllegalStateException("检查更新失败")
130129
val body = responseJsonObject["body"]?.jsonPrimitive?.content ?: "暂无更新记录"
131130
val htmlUrl = responseJsonObject["html_url"]!!.jsonPrimitive.content

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import io.github.mzdluo123.mirai.android.receiver.PushMsgReceiver
3030
import io.github.mzdluo123.mirai.android.script.ScriptManager
3131
import io.github.mzdluo123.mirai.android.utils.MiraiAndroidStatus
3232
import kotlinx.coroutines.CoroutineExceptionHandler
33+
import kotlinx.coroutines.Dispatchers
3334
import kotlinx.coroutines.cancel
3435
import kotlinx.coroutines.launch
3536
import net.mamoe.mirai.Bot
@@ -134,7 +135,7 @@ class BotService : LifecycleService() {
134135
//MiraiConsole.addBot().alsoLogin()
135136
// GlobalScope.launch(handler) { sendMessage("$qq login successes") }
136137
val bot = MiraiConsole.addBot(qq, pwd!!.chunkedHexToBytes())
137-
lifecycleScope.launch(handler) { bot.login() }
138+
lifecycleScope.launch(Dispatchers.Default + handler) { bot.login() }
138139
}
139140

140141
private fun registerDefaultCommand() {
@@ -248,7 +249,7 @@ class BotService : LifecycleService() {
248249
override fun runCmd(cmd: String?) {
249250
cmd?.let {
250251
//CommandManager.runCommand(ConsoleCommandSender, it)
251-
lifecycleScope.launch {
252+
lifecycleScope.launch(Dispatchers.Default) {
252253
ConsoleCommandSender.executeCommand(cmd)
253254
}
254255
}

app/src/main/java/io/github/mzdluo123/mirai/android/ui/about/AboutFragment.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class AboutFragment : Fragment() {
4545
github2_bth.setOnClickListener {
4646
openUrl("https://github.com/mzdluo123/MiraiAndroid")
4747
}
48+
btn_visit_forum.setOnClickListener {
49+
openUrl("https://mirai.mamoe.net/")
50+
}
4851
imageView2.setOnClickListener {
4952
if (click < 4) {
5053
click++
@@ -67,13 +70,13 @@ class AboutFragment : Fragment() {
6770

6871
/****************
6972
*
70-
* 发起添加群流程。群号:MiraiAndroid(1131127734) 的 key 为: df6wSbKtDBo3cMJ9ULtYAZeln5ZZuA9d
71-
* 调用 joinQQGroup(df6wSbKtDBo3cMJ9ULtYAZeln5ZZuA9d) 即可发起手Q客户端申请加群 MiraiAndroid(1131127734)
73+
* 发起添加群流程。群号:MiraiAndroid(206073050) 的 key 为: 2aqIV-MkAOvx53dwUl-VVUYZqn8UrFAJ
74+
* 调用 joinQQGroup(2aqIV-MkAOvx53dwUl-VVUYZqn8UrFAJ) 即可发起手Q客户端申请加群 MiraiAndroid(206073050)
7275
*
7376
* @param key 由官网生成的key
7477
* @return 返回true表示呼起手Q成功,返回false表示呼起失败
7578
*/
76-
private fun joinQQGroup(key: String): Boolean {
79+
fun joinQQGroup(key: String): Boolean {
7780
val intent = Intent()
7881
intent.data =
7982
Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26jump_from%3Dwebapi%26k%3D$key")
@@ -87,4 +90,5 @@ class AboutFragment : Fragment() {
8790
}
8891
}
8992

93+
9094
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import kotlin.coroutines.resumeWithException
77
import kotlin.coroutines.suspendCoroutine
88

99
object RequestUtil {
10-
suspend fun get(url: String,clientBuilder:OkHttpClient.Builder.()->Unit = {}):String {
10+
suspend fun get(url: String, clientBuilder: OkHttpClient.Builder.() -> Unit = {}): String? {
1111
val client = OkHttpClient.Builder().apply(clientBuilder).build()
1212
val request: Request = Request.Builder()
1313
.url(url)
@@ -19,8 +19,9 @@ object RequestUtil {
1919
override fun onFailure(call: Call, e: IOException) {
2020
continuation.resumeWithException(e)
2121
}
22+
2223
override fun onResponse(call: Call, response: Response) {
23-
continuation.resume(response.body.toString())
24+
continuation.resume(response.body?.string())
2425
}
2526
})
2627
}

app/src/main/res/layout/fragment_about.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,21 @@
193193
android:id="@+id/btn_join_group"
194194
android:layout_width="wrap_content"
195195
android:layout_height="wrap_content"
196+
android:layout_marginStart="64dp"
196197
android:layout_marginTop="8dp"
197198
android:text="加入交流群"
198-
app:layout_constraintEnd_toEndOf="parent"
199199
app:layout_constraintStart_toStartOf="parent"
200200
app:layout_constraintTop_toBottomOf="@+id/version_text" />
201+
202+
<Button
203+
android:id="@+id/btn_visit_forum"
204+
android:layout_width="93dp"
205+
android:layout_height="wrap_content"
206+
android:layout_marginTop="8dp"
207+
android:layout_marginEnd="64dp"
208+
android:text="访问论坛"
209+
app:layout_constraintEnd_toEndOf="parent"
210+
app:layout_constraintTop_toBottomOf="@+id/version_text" />
201211
</androidx.constraintlayout.widget.ConstraintLayout>
202212

203213

0 commit comments

Comments
 (0)