更新界面
This commit is contained in:
@@ -23,19 +23,10 @@
|
|||||||
"other_platform_oauth_client": []
|
"other_platform_oauth_client": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
],
|
|
||||||
"configuration_version": "1",
|
|
||||||
|
|
||||||
"project_info": {
|
|
||||||
"project_number": "735500663982",
|
|
||||||
"project_id": "kazesa-debug",
|
|
||||||
"storage_bucket": "kazesa-debug.firebasestorage.app"
|
|
||||||
},
|
},
|
||||||
"client": [
|
|
||||||
{
|
{
|
||||||
"client_info": {
|
"client_info": {
|
||||||
"mobilesdk_app_id": "1:735500663982:android:68276b2e9a0c230069013f",
|
"mobilesdk_app_id": "1:499897677610:android:f3b742fbea52bbfec09053",
|
||||||
"android_client_info": {
|
"android_client_info": {
|
||||||
"package_name": "io.legato.kazusa.debug"
|
"package_name": "io.legato.kazusa.debug"
|
||||||
}
|
}
|
||||||
@@ -43,7 +34,7 @@
|
|||||||
"oauth_client": [],
|
"oauth_client": [],
|
||||||
"api_key": [
|
"api_key": [
|
||||||
{
|
{
|
||||||
"current_key": "AIzaSyDt65UOURbutB8DnTOEGuDf6Vhw56T9nq4"
|
"current_key": "AIzaSyAaA79qTqF3S67JUVnUK7pdWx3Y3-sbOZI"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": {
|
"services": {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ data class AppReleaseInfo(
|
|||||||
val downloadUrl: String,
|
val downloadUrl: String,
|
||||||
val assetUrl: String
|
val assetUrl: String
|
||||||
) {
|
) {
|
||||||
val versionName: String = Regex("""legado_app_([\d.]+)""")
|
val versionName: String = Regex("""legado_app_([\d.]+)\.apk""")
|
||||||
.find(name)
|
.find(name)
|
||||||
?.groupValues?.get(1)
|
?.groupValues?.get(1)
|
||||||
?: ""
|
?: ""
|
||||||
|
|||||||
@@ -48,22 +48,27 @@ object AppUpdateGitHub : AppUpdate.AppUpdateInterface {
|
|||||||
.sortedByDescending { it.createdAt }
|
.sortedByDescending { it.createdAt }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun check(
|
override fun check(scope: CoroutineScope): Coroutine<AppUpdate.UpdateInfo> {
|
||||||
scope: CoroutineScope,
|
|
||||||
): Coroutine<AppUpdate.UpdateInfo> {
|
|
||||||
return Coroutine.async(scope) {
|
return Coroutine.async(scope) {
|
||||||
getLatestRelease()
|
val currentVersion = AppConst.appInfo.versionName
|
||||||
|
val releases = getLatestRelease()
|
||||||
.filter { it.appVariant == checkVariant }
|
.filter { it.appVariant == checkVariant }
|
||||||
.firstOrNull { it.versionName > AppConst.appInfo.versionName }
|
|
||||||
?.let {
|
|
||||||
|
val latest = releases
|
||||||
|
.firstOrNull { it.versionName > currentVersion }
|
||||||
|
|
||||||
|
if (latest != null) {
|
||||||
return@async AppUpdate.UpdateInfo(
|
return@async AppUpdate.UpdateInfo(
|
||||||
it.versionName,
|
latest.versionName,
|
||||||
it.note,
|
latest.note,
|
||||||
it.downloadUrl,
|
latest.downloadUrl,
|
||||||
it.name
|
latest.name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
?: throw NoStackTraceException("已是最新版本")
|
|
||||||
|
throw NoStackTraceException("已是最新版本")
|
||||||
}.timeout(10000)
|
}.timeout(10000)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import io.legato.kazusa.utils.startService
|
|||||||
|
|
||||||
object Download {
|
object Download {
|
||||||
|
|
||||||
|
|
||||||
fun start(context: Context, url: String, fileName: String) {
|
fun start(context: Context, url: String, fileName: String) {
|
||||||
context.startService<DownloadService> {
|
context.startService<DownloadService> {
|
||||||
action = IntentAction.start
|
action = IntentAction.start
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package io.legato.kazusa.ui.about
|
package io.legato.kazusa.ui.about
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
@@ -35,6 +33,7 @@ import io.legato.kazusa.utils.toastOnUi
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
|
||||||
class AboutFragment : PreferenceFragmentCompat() {
|
class AboutFragment : PreferenceFragmentCompat() {
|
||||||
|
|
||||||
@@ -103,23 +102,23 @@ class AboutFragment : PreferenceFragmentCompat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 加入qq群
|
// * 加入qq群
|
||||||
*/
|
// */
|
||||||
private fun joinQQGroup(key: String): Boolean {
|
// private fun joinQQGroup(key: String): Boolean {
|
||||||
val intent = Intent()
|
// val intent = Intent()
|
||||||
intent.data =
|
// intent.data =
|
||||||
Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D$key")
|
// "mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D$key".toUri()
|
||||||
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面
|
// // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面
|
||||||
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
// // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
kotlin.runCatching {
|
// kotlin.runCatching {
|
||||||
startActivity(intent)
|
// startActivity(intent)
|
||||||
return true
|
// return true
|
||||||
}.onFailure {
|
// }.onFailure {
|
||||||
toastOnUi("添加失败,请手动添加")
|
// toastOnUi("添加失败,请手动添加")
|
||||||
}
|
// }
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
|
|
||||||
private fun saveLog() {
|
private fun saveLog() {
|
||||||
Coroutine.async {
|
Coroutine.async {
|
||||||
@@ -131,7 +130,7 @@ class AboutFragment : PreferenceFragmentCompat() {
|
|||||||
appCtx.toastOnUi("未开启日志记录,请去其他设置里打开记录日志")
|
appCtx.toastOnUi("未开启日志记录,请去其他设置里打开记录日志")
|
||||||
delay(3000)
|
delay(3000)
|
||||||
}
|
}
|
||||||
val doc = FileDoc.fromUri(Uri.parse(backupPath), true)
|
val doc = FileDoc.fromUri(backupPath.toUri(), true)
|
||||||
copyLogs(doc)
|
copyLogs(doc)
|
||||||
copyHeapDump(doc)
|
copyHeapDump(doc)
|
||||||
appCtx.toastOnUi("已保存至备份目录")
|
appCtx.toastOnUi("已保存至备份目录")
|
||||||
@@ -153,7 +152,7 @@ class AboutFragment : PreferenceFragmentCompat() {
|
|||||||
appCtx.toastOnUi("开始创建堆转储")
|
appCtx.toastOnUi("开始创建堆转储")
|
||||||
System.gc()
|
System.gc()
|
||||||
CrashHandler.doHeapDump(true)
|
CrashHandler.doHeapDump(true)
|
||||||
val doc = FileDoc.fromUri(Uri.parse(backupPath), true)
|
val doc = FileDoc.fromUri(backupPath.toUri(), true)
|
||||||
if (!copyHeapDump(doc)) {
|
if (!copyHeapDump(doc)) {
|
||||||
appCtx.toastOnUi("未找到堆转储文件")
|
appCtx.toastOnUi("未找到堆转储文件")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.legato.kazusa.ui.about
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import io.legato.kazusa.BuildConfig
|
||||||
import io.legato.kazusa.R
|
import io.legato.kazusa.R
|
||||||
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
|
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
|
||||||
import io.legato.kazusa.databinding.DialogUpdateBinding
|
import io.legato.kazusa.databinding.DialogUpdateBinding
|
||||||
@@ -34,7 +35,13 @@ class UpdateDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_update) {
|
|||||||
|
|
||||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
//binding.toolBar.setBackgroundColor(primaryColor)
|
//binding.toolBar.setBackgroundColor(primaryColor)
|
||||||
binding.toolBar.title = arguments?.getString("newVersion")
|
|
||||||
|
binding.tvCurrentVersion.text = BuildConfig.VERSION_NAME
|
||||||
|
binding.tvVersion.text = arguments?.getString("newVersion")
|
||||||
|
|
||||||
|
binding.tvAbi.text = Build.SUPPORTED_ABIS.firstOrNull() ?: "unknown"
|
||||||
|
binding.tvUrl.text = arguments?.getString("url")
|
||||||
|
|
||||||
val updateBody = arguments?.getString("updateBody")
|
val updateBody = arguments?.getString("updateBody")
|
||||||
if (updateBody == null) {
|
if (updateBody == null) {
|
||||||
toastOnUi("没有数据")
|
toastOnUi("没有数据")
|
||||||
@@ -49,31 +56,33 @@ class UpdateDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_update) {
|
|||||||
.build()
|
.build()
|
||||||
.setMarkdown(binding.textView, updateBody)
|
.setMarkdown(binding.textView, updateBody)
|
||||||
}
|
}
|
||||||
binding.toolBar.inflateMenu(R.menu.app_update)
|
|
||||||
binding.toolBar.setOnMenuItemClickListener {
|
|
||||||
when (it.itemId) {
|
|
||||||
R.id.menu_download -> {
|
|
||||||
val url = arguments?.getString("url")
|
|
||||||
val baseName = arguments?.getString("name")
|
|
||||||
?.removeSuffix(".apk")
|
|
||||||
|
|
||||||
val abi = Build.SUPPORTED_ABIS.firstOrNull() ?: "universal"
|
binding.btnUpdate.setOnClickListener {
|
||||||
|
val urlPrefix = arguments?.getString("url")
|
||||||
|
val baseName = arguments?.getString("name")?.removeSuffix(".apk")
|
||||||
|
|
||||||
|
if (urlPrefix == null || baseName == null) {
|
||||||
|
toastOnUi("下载信息不完整")
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前 ABI 后缀
|
||||||
|
val abi = Build.SUPPORTED_ABIS.firstOrNull() ?: ""
|
||||||
val abiSuffix = when {
|
val abiSuffix = when {
|
||||||
abi.contains("arm64") -> "arm64-v8a"
|
abi.contains("arm64") -> "arm64-v8a"
|
||||||
abi.contains("armeabi") -> "armeabi-v7a"
|
abi.contains("armeabi") -> "armeabi-v7a"
|
||||||
else -> "universal"
|
else -> ""
|
||||||
}
|
}
|
||||||
|
|
||||||
val name = "${baseName}_$abiSuffix.apk"
|
// 拼接文件名和下载链接
|
||||||
|
val fileName = "${baseName}_$abiSuffix.apk"
|
||||||
|
val fullUrl = urlPrefix
|
||||||
|
.substringBeforeLast("/") + "/" + fileName
|
||||||
|
|
||||||
|
Download.start(requireContext(), fullUrl, fileName)
|
||||||
|
toastOnUi("开始下载: $fileName")
|
||||||
|
}
|
||||||
|
|
||||||
if (url != null && baseName != null) {
|
|
||||||
Download.start(requireContext(), url, name)
|
|
||||||
toastOnUi(R.string.download_start)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return@setOnMenuItemClickListener true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,148 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:paddingHorizontal="16dp">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<LinearLayout
|
||||||
android:id="@+id/tool_bar"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="?attr/actionBarStyle"
|
android:orientation="vertical"
|
||||||
app:titleTextAppearance="@style/ToolbarTitle" />
|
android:gravity="center"
|
||||||
|
android:paddingVertical="16dp">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="4dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:background="@drawable/bg_bottom_sheet_handle"
|
||||||
|
android:layout_marginBottom="16dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="2"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bottom_sheet_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="32dp"
|
||||||
|
android:text="检测到更新!"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn_update"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:icon="@drawable/ic_download"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginVertical="8dp">
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:strokeWidth="0dp"
|
||||||
|
app:cardBackgroundColor="?attr/colorSecondaryContainer">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_current_version"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?attr/textAppearanceBodyMedium"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:text="123"/>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/colorSecondary"
|
||||||
|
android:layout_marginHorizontal="8dp"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:strokeWidth="0dp"
|
||||||
|
app:cardBackgroundColor="?attr/colorPrimaryContainer">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_version"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?attr/textAppearanceBodyMedium"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:text="123"/>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:strokeWidth="0dp"
|
||||||
|
app:cardBackgroundColor="?attr/colorPrimaryContainer">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_abi"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:text="ABI: arm64-v8a"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
android:textAppearance="?attr/textAppearanceBodySmall" />
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_url"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="下载链接"
|
||||||
|
android:autoLink="web"
|
||||||
|
android:textAppearance="?attr/textAppearanceBodySmall"
|
||||||
|
android:textColor="?attr/colorPrimary"
|
||||||
|
android:paddingVertical="8dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:text="更新日志"/>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
<io.legato.kazusa.ui.widget.text.ScrollTextView
|
<io.legato.kazusa.ui.widget.text.ScrollTextView
|
||||||
android:id="@+id/text_view"
|
android:id="@+id/text_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="12dp"
|
android:paddingVertical="8dp"
|
||||||
android:textColor="@color/secondaryText"
|
|
||||||
android:textIsSelectable="true" />
|
android:textIsSelectable="true" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user