parent
85d03e0390
commit
c97842e9ab
|
|
@ -6,6 +6,130 @@ plugins {
|
|||
kotlin("plugin.serialization") version "2.3.0"
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.img.rabbit"
|
||||
compileSdk = 36
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
viewBinding = true
|
||||
}
|
||||
|
||||
aaptOptions {
|
||||
additionalParameters("--auto-add-overlay")
|
||||
}
|
||||
|
||||
androidResources {
|
||||
ignoreAssetsPattern = "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
jniLibs {
|
||||
useLegacyPackaging = true
|
||||
}
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
// 注意:Kotlin 1.8.x 以后建议检查与 Compose 编译器的版本兼容性
|
||||
kotlinCompilerExtensionVersion = "1.4.8"
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.img.rabbit"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
multiDexEnabled = true
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
}
|
||||
|
||||
ndk {
|
||||
abiFilters.addAll(listOf("arm64-v8a", "x86_64", "x86", "armeabi-v7a"))
|
||||
}
|
||||
|
||||
// 仅保留基础占位符,渠道相关的移至下方 flavor 处理
|
||||
manifestPlaceholders.putAll(mapOf(
|
||||
"GETUI_APPID" to (project.findProperty("GETUI_APPID") as? String ?: "cYHNI4KThh6SxZUsf9RiU2"),
|
||||
"HUAWEI_APP_ID" to "",
|
||||
"XIAOMI_APP_ID" to "",
|
||||
"XIAOMI_APP_KEY" to "",
|
||||
"OPPO_APP_KEY" to "",
|
||||
"OPPO_APP_SECRET" to "",
|
||||
"VIVO_APP_ID" to "",
|
||||
"VIVO_APP_KEY" to "",
|
||||
"HONOR_APP_ID" to "",
|
||||
"apk.applicationId" to "com.img.rabbit",
|
||||
"GT_INSTALL_CHANNEL" to "test" // 默认值
|
||||
|
||||
))
|
||||
|
||||
resConfigs("en", "zh-rCN")
|
||||
}
|
||||
|
||||
// 1. 配置签名信息(解决文件找不到的问题)
|
||||
signingConfigs {
|
||||
create("config") {
|
||||
// 使用相对路径,请确保 bidinfo.keystore 放在 app 目录下
|
||||
val keystorePath = project.findProperty("RELEASE_STORE_FILE") as? String ?: "bidinfo.keystore"
|
||||
storeFile = file(keystorePath)
|
||||
storePassword = project.findProperty("RELEASE_STORE_PASSWORD") as? String ?: "你的密码"
|
||||
keyAlias = project.findProperty("RELEASE_KEY_ALIAS") as? String ?: "你的别名"
|
||||
keyPassword = project.findProperty("RELEASE_KEY_PASSWORD") as? String ?: "你的密码"
|
||||
|
||||
enableV1Signing = true
|
||||
enableV2Signing = true
|
||||
enableV3Signing = true
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 配置渠道维度
|
||||
flavorDimensions.add("channel")
|
||||
|
||||
// 3. 配置具体渠道
|
||||
productFlavors {
|
||||
create("general") { dimension = "channel" }
|
||||
create("xiaomi") { dimension = "channel" }
|
||||
create("huawei") { dimension = "channel" }
|
||||
create("oppo") { dimension = "channel" }
|
||||
create("vivo") { dimension = "channel" }
|
||||
|
||||
// 自动将渠道名同步给个推和友盟的渠道占位符
|
||||
all {
|
||||
manifestPlaceholders["UMENG_CHANNEL"] = name
|
||||
manifestPlaceholders["GT_INSTALL_CHANNEL"] = name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
buildTypes {
|
||||
getByName("debug") {
|
||||
isMinifyEnabled = false
|
||||
signingConfig = signingConfigs.getByName("config")
|
||||
}
|
||||
getByName("release") {
|
||||
// 建议开启混淆以减少启动耗时和体积
|
||||
isMinifyEnabled = false
|
||||
isShrinkResources = false
|
||||
signingConfig = signingConfigs.getByName("config")
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
android {
|
||||
namespace = "com.img.rabbit"
|
||||
compileSdk = 36
|
||||
|
|
@ -112,6 +236,7 @@ android {
|
|||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
configurations {
|
||||
all {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ import com.google.accompanist.permissions.isGranted
|
|||
import com.google.accompanist.permissions.rememberPermissionState
|
||||
import com.google.accompanist.permissions.shouldShowRationale
|
||||
import com.img.rabbit.R
|
||||
import com.img.rabbit.components.CenterToast
|
||||
import com.img.rabbit.provider.utils.NetworkUtils.globalNetworkStatus
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
@SuppressLint("UnrememberedMutableState")
|
||||
|
|
@ -220,6 +222,10 @@ fun UpdateDialog(
|
|||
indication = null,
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
) {
|
||||
if (!globalNetworkStatus) {
|
||||
CenterToast.show("网络已断开,请检查网络连接")
|
||||
return@clickable
|
||||
}
|
||||
// 执行下载更新
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
onStatusChange(false, false, url)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.img.rabbit.viewmodel
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.img.rabbit.components.CenterToast
|
||||
import com.img.rabbit.provider.utils.NetworkUtils.globalNetworkStatus
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -14,6 +15,7 @@ open class BaseViewModel : ViewModel() {
|
|||
|
||||
fun mLaunch(block: suspend () -> Unit) {
|
||||
if (!globalNetworkStatus) {
|
||||
CenterToast.show("网络已断开,请检查网络连接")
|
||||
isLoading.value = false // 加载完成
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue