parent
31834b320d
commit
7cdbf8f613
|
|
@ -39,8 +39,8 @@ android {
|
||||||
applicationId = "com.img.rabbit"
|
applicationId = "com.img.rabbit"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 1
|
versionCode = 3
|
||||||
versionName = "1.0.0"
|
versionName = "1.0.3"
|
||||||
multiDexEnabled = true
|
multiDexEnabled = true
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,8 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
@OptIn(DelicateCoroutinesApi::class, ExperimentalPermissionsApi::class)
|
@OptIn(DelicateCoroutinesApi::class, ExperimentalPermissionsApi::class)
|
||||||
@SuppressLint("UnrememberedMutableState", "CoroutineCreationDuringComposition")
|
@SuppressLint("UnrememberedMutableState", "CoroutineCreationDuringComposition")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
// 必须在 super.onCreate 之前调用
|
|
||||||
val splashScreen = installSplashScreen()
|
val splashScreen = installSplashScreen()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
// 启用Edge-to-Edge模式(沉浸模式)
|
// 启用Edge-to-Edge模式(沉浸模式)
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@ class ConfigEntity {
|
||||||
var homeIconEntity: List<UniIconEntity>? = emptyList()
|
var homeIconEntity: List<UniIconEntity>? = emptyList()
|
||||||
@SerializedName("client.wgt.password") //WGT解压密码
|
@SerializedName("client.wgt.password") //WGT解压密码
|
||||||
var wgtPassword: String? = null
|
var wgtPassword: String? = null
|
||||||
|
@SerializedName("client.uni.open") //是否开启小程序模拟器
|
||||||
|
var isUniMpOpen: Boolean? = null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SerializedName("client.popup.display") //显示开关控制
|
@SerializedName("client.popup.display") //显示开关控制
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,8 @@ fun HomeScreen(
|
||||||
val TAG = "Rabbit_HomeScreen"
|
val TAG = "Rabbit_HomeScreen"
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope: CoroutineScope = rememberCoroutineScope()
|
val scope: CoroutineScope = rememberCoroutineScope()
|
||||||
val progressPair = mutableStateMapOf<String, Float>()
|
|
||||||
|
|
||||||
val reportViewModel = viewModel<ReportViewModel>()
|
val reportViewModel = viewModel<ReportViewModel>()
|
||||||
|
val progressPair = mutableStateMapOf<String, Float>()
|
||||||
|
|
||||||
// 获取当前路由状态
|
// 获取当前路由状态
|
||||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||||
|
|
@ -139,10 +138,7 @@ fun HomeScreen(
|
||||||
shape = RoundedCornerShape(topStart = 18.dp, topEnd = 18.dp)
|
shape = RoundedCornerShape(topStart = 18.dp, topEnd = 18.dp)
|
||||||
)
|
)
|
||||||
){
|
){
|
||||||
val homeIconConfig = homeIconConfig
|
// 顶部mask
|
||||||
//大于9时,每排展示3个,否则每排展示4个
|
|
||||||
val columnsCount = if((homeIconConfig?.size?:0) >= 9){ 3 }else{ 4 }
|
|
||||||
val rows = homeIconConfig?.chunked(columnsCount)?:emptyList()
|
|
||||||
item {
|
item {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(id = R.mipmap.ic_home_top_mask),
|
painter = painterResource(id = R.mipmap.ic_home_top_mask),
|
||||||
|
|
@ -163,252 +159,127 @@ fun HomeScreen(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item {
|
// 当配置开启模拟器时,展示模拟器部分
|
||||||
Column(
|
if(PreferenceUtil.getUserConfig()?.config?.isUniMpOpen?:false){
|
||||||
) {
|
//模拟器部分,大于9时,每排展示3个,否则每排展示4个
|
||||||
|
val columnsCount = if((homeIconConfig?.size?:0) >= 9){ 3 }else{ 4 }
|
||||||
|
val rows = homeIconConfig?.chunked(columnsCount)?:emptyList()
|
||||||
|
//模拟器
|
||||||
|
item {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.offset(y = (-36).dp)
|
|
||||||
.background(
|
|
||||||
color = Color.White,
|
|
||||||
shape = RoundedCornerShape(topStart = 18.dp, topEnd = 18.dp)
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
//通过配置展示-AD1(模拟器)
|
Column(
|
||||||
val uniVersionConfig = uniVersionConfig
|
modifier = Modifier
|
||||||
if(uniVersionConfig?.isNotEmpty() == true){
|
.fillMaxWidth()
|
||||||
val uniVersionSize = uniVersionConfig.size
|
.offset(y = (-36).dp)
|
||||||
//模拟器
|
.background(
|
||||||
Image(
|
color = Color.White,
|
||||||
painter = painterResource(id = R.mipmap.ic_home_title_0_mock),
|
shape = RoundedCornerShape(topStart = 18.dp, topEnd = 18.dp)
|
||||||
contentDescription = null,
|
)
|
||||||
contentScale = ContentScale.Crop,
|
) {
|
||||||
modifier = Modifier
|
//通过配置展示-AD1(模拟器)
|
||||||
.wrapContentWidth()
|
val uniVersionConfig = uniVersionConfig
|
||||||
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
|
if(uniVersionConfig?.isNotEmpty() == true){
|
||||||
)
|
val uniVersionSize = uniVersionConfig.size
|
||||||
Row(
|
//模拟器
|
||||||
modifier = Modifier
|
Image(
|
||||||
.fillMaxWidth()
|
painter = painterResource(id = R.mipmap.ic_home_title_0_mock),
|
||||||
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
|
contentDescription = null,
|
||||||
){
|
contentScale = ContentScale.Crop,
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.wrapContentWidth()
|
.wrapContentWidth()
|
||||||
.weight(1f)
|
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
|
||||||
.clickable(
|
)
|
||||||
indication = null,
|
Row(
|
||||||
interactionSource = remember { MutableInteractionSource() }
|
modifier = Modifier
|
||||||
) {
|
.fillMaxWidth()
|
||||||
val uniMp = uniVersionConfig[0]
|
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
|
||||||
val uniMpId = uniMp.unimp_id
|
){
|
||||||
// 处理点击事件,微信模拟器
|
Box(
|
||||||
if (UniAppUtils.isDownloadUniMp(uniMp)) {
|
|
||||||
//强制更新(更新释放新版本并启动)
|
|
||||||
UniAppUtils.downloadWGT(
|
|
||||||
context,
|
|
||||||
scope,
|
|
||||||
uniMp
|
|
||||||
) { uniState, _, progress ->
|
|
||||||
progressPair[uniMpId]
|
|
||||||
?: mutableMapOf<String, Float>().apply { put(uniMpId, 0f) }
|
|
||||||
when (uniState) {
|
|
||||||
UniMpUpdate.DOWNLOAD_START -> {
|
|
||||||
//资源开始下载
|
|
||||||
progressPair.apply { put(uniMpId, 0f) }
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_START")
|
|
||||||
}
|
|
||||||
|
|
||||||
UniMpUpdate.DOWNLOAD_FINISH -> {
|
|
||||||
//资源下载完成
|
|
||||||
progressPair.apply { put(uniMpId, 1f) }
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
|
||||||
}
|
|
||||||
|
|
||||||
UniMpUpdate.DOWNLOAD_FAIL -> {
|
|
||||||
//资源下载失败
|
|
||||||
progressPair.apply { put(uniMpId, -1f) }
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
//资源下载进度
|
|
||||||
if (progress != null) {
|
|
||||||
progressPair.apply {
|
|
||||||
put(
|
|
||||||
uniMpId,
|
|
||||||
progress
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Log.i(
|
|
||||||
"HomeScreen",
|
|
||||||
"DOWNLOAD_PROGRESS:$progress"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (UniAppUtils.isUpdate(uniMp)) {
|
|
||||||
// 提示更新(1、更新释放新版本并启动;2、直接启动现有版本)
|
|
||||||
UniAppUtils.currentUpdateUniMp = uniMp
|
|
||||||
scope.launch {
|
|
||||||
GlobalStateManager(context).storeGlobalUniUpdateNotify(
|
|
||||||
true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadingCallback?.showLoading()
|
|
||||||
//启动uni小程序(1、直接启动;2、释放并启动)
|
|
||||||
UniAppUtils.distributeUniMp(context, uniMp, reportViewModel) {
|
|
||||||
loadingCallback?.hideLoading()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
val uniMpId = uniVersionConfig[0].unimp_id
|
|
||||||
val uniIcon = uniVersionConfig[0].icon
|
|
||||||
AsyncImage(
|
|
||||||
model = uniIcon,
|
|
||||||
contentDescription = "微信模拟器图标",
|
|
||||||
contentScale = ContentScale.FillWidth,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.wrapContentWidth()
|
||||||
.aspectRatio(168 / 96f),
|
.weight(1f)
|
||||||
fallback = painterResource(id = R.mipmap.ic_wx_mock),
|
.clickable(
|
||||||
error = painterResource(id = R.mipmap.ic_wx_mock)
|
indication = null,
|
||||||
)
|
interactionSource = remember { MutableInteractionSource() }
|
||||||
|
|
||||||
//下载完成前显示
|
|
||||||
if((progressPair[uniMpId]?:0f) > 0f && (progressPair[uniMpId]?:0f) < 1f){
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.aspectRatio(168 / 96f)
|
|
||||||
.background(
|
|
||||||
Color(
|
|
||||||
0x66000000
|
|
||||||
), RoundedCornerShape(18.dp)
|
|
||||||
),
|
|
||||||
){
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.align(Alignment.Center)
|
|
||||||
.padding(horizontal = 12.dp)
|
|
||||||
) {
|
) {
|
||||||
// 使用 LinearProgressIndicator 显示确定性进度
|
val uniMp = uniVersionConfig[0]
|
||||||
LinearProgressIndicator(
|
val uniMpId = uniMp.unimp_id
|
||||||
progress = { progressPair[uniMpId]?:0f }, // 使用 Lambda 更新进度0~1
|
// 处理点击事件,微信模拟器
|
||||||
modifier = Modifier
|
if (UniAppUtils.isDownloadUniMp(uniMp)) {
|
||||||
.fillMaxWidth()
|
//强制更新(更新释放新版本并启动)
|
||||||
.height(8.dp)
|
UniAppUtils.downloadWGT(
|
||||||
)
|
context,
|
||||||
Text(
|
scope,
|
||||||
text = "下载${((progressPair[uniMpId]?:0f) * 100).toInt()}%",
|
uniMp
|
||||||
color = Color.White,
|
) { uniState, _, progress ->
|
||||||
fontSize = 12.sp,
|
progressPair[uniMpId]
|
||||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
?: mutableMapOf<String, Float>().apply { put(uniMpId, 0f) }
|
||||||
textAlign = TextAlign.Center,
|
when (uniState) {
|
||||||
)
|
UniMpUpdate.DOWNLOAD_START -> {
|
||||||
}
|
//资源开始下载
|
||||||
}
|
progressPair.apply { put(uniMpId, 0f) }
|
||||||
}
|
Log.i("HomeScreen", "DOWNLOAD_START")
|
||||||
|
|
||||||
}
|
|
||||||
Box(modifier = Modifier.width(7.dp))
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.wrapContentWidth()
|
|
||||||
.weight(1f)
|
|
||||||
.clickable(
|
|
||||||
indication = null,
|
|
||||||
interactionSource = remember { MutableInteractionSource() }
|
|
||||||
) {
|
|
||||||
val uniMp = uniVersionConfig[1]
|
|
||||||
val uniMpId = uniMp.unimp_id
|
|
||||||
// 处理点击事件,微信模拟器
|
|
||||||
if (UniAppUtils.isDownloadUniMp(uniMp)) {
|
|
||||||
//强制更新(更新释放新版本并启动)
|
|
||||||
UniAppUtils.downloadWGT(
|
|
||||||
context,
|
|
||||||
scope,
|
|
||||||
uniMp
|
|
||||||
) { uniState, _, progress ->
|
|
||||||
progressPair[uniMpId]
|
|
||||||
?: mutableMapOf<String, Float>().apply {
|
|
||||||
put(
|
|
||||||
uniMpId,
|
|
||||||
0f
|
|
||||||
)
|
|
||||||
}
|
|
||||||
when (uniState) {
|
|
||||||
UniMpUpdate.DOWNLOAD_START -> {
|
|
||||||
//资源开始下载
|
|
||||||
progressPair.apply { put(uniMpId, 0f) }
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_START")
|
|
||||||
}
|
|
||||||
|
|
||||||
UniMpUpdate.DOWNLOAD_FINISH -> {
|
|
||||||
//资源下载完成
|
|
||||||
progressPair.apply { put(uniMpId, 1f) }
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
|
||||||
}
|
|
||||||
|
|
||||||
UniMpUpdate.DOWNLOAD_FAIL -> {
|
|
||||||
//资源下载失败
|
|
||||||
progressPair.apply { put(uniMpId, -1f) }
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
//资源下载进度
|
|
||||||
if (progress != null) {
|
|
||||||
progressPair.apply {
|
|
||||||
put(
|
|
||||||
uniMpId,
|
|
||||||
progress
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Log.i(
|
|
||||||
"HomeScreen",
|
|
||||||
"DOWNLOAD_PROGRESS:$progress"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniMpUpdate.DOWNLOAD_FINISH -> {
|
||||||
|
//资源下载完成
|
||||||
|
progressPair.apply { put(uniMpId, 1f) }
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
||||||
|
}
|
||||||
|
|
||||||
|
UniMpUpdate.DOWNLOAD_FAIL -> {
|
||||||
|
//资源下载失败
|
||||||
|
progressPair.apply { put(uniMpId, -1f) }
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
//资源下载进度
|
||||||
|
if (progress != null) {
|
||||||
|
progressPair.apply {
|
||||||
|
put(
|
||||||
|
uniMpId,
|
||||||
|
progress
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Log.i(
|
||||||
|
"HomeScreen",
|
||||||
|
"DOWNLOAD_PROGRESS:$progress"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (UniAppUtils.isUpdate(uniMp)) {
|
||||||
} else if (UniAppUtils.isUpdate(uniMp)) {
|
// 提示更新(1、更新释放新版本并启动;2、直接启动现有版本)
|
||||||
// 提示更新(1、更新释放新版本并启动;2、直接启动现有版本)
|
UniAppUtils.currentUpdateUniMp = uniMp
|
||||||
UniAppUtils.currentUpdateUniMp = uniMp
|
scope.launch {
|
||||||
scope.launch {
|
GlobalStateManager(context).storeGlobalUniUpdateNotify(
|
||||||
GlobalStateManager(context).storeGlobalUniUpdateNotify(
|
true
|
||||||
true
|
)
|
||||||
)
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
loadingCallback?.showLoading()
|
||||||
loadingCallback?.showLoading()
|
//启动uni小程序(1、直接启动;2、释放并启动)
|
||||||
//启动uni小程序(1、直接启动;2、释放并启动)
|
UniAppUtils.distributeUniMp(context, uniMp, reportViewModel) {
|
||||||
UniAppUtils.distributeUniMp(context, uniMp, reportViewModel) {
|
loadingCallback?.hideLoading()
|
||||||
loadingCallback?.hideLoading()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
) {
|
||||||
) {
|
val uniMpId = uniVersionConfig[0].unimp_id
|
||||||
val uniMpId = uniVersionConfig[1].unimp_id
|
val uniIcon = uniVersionConfig[0].icon
|
||||||
val uniIcon = uniVersionConfig[1].icon
|
|
||||||
if(uniVersionSize>1){
|
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = uniIcon,
|
model = uniIcon,
|
||||||
contentDescription = "支付宝模拟器",
|
contentDescription = "微信模拟器图标",
|
||||||
contentScale = ContentScale.FillWidth,
|
contentScale = ContentScale.FillWidth,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.aspectRatio(168 / 96f),
|
.aspectRatio(168 / 96f),
|
||||||
fallback = painterResource(id = R.mipmap.ic_alipay_mock),
|
fallback = painterResource(id = R.mipmap.ic_wx_mock),
|
||||||
error = painterResource(id = R.mipmap.ic_alipay_mock)
|
error = painterResource(id = R.mipmap.ic_wx_mock)
|
||||||
)
|
)
|
||||||
|
|
||||||
//下载完成前显示
|
//下载完成前显示
|
||||||
|
|
@ -446,83 +317,217 @@ fun HomeScreen(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
items(rows) {rowItems ->
|
|
||||||
//通过配置展示-AD2
|
|
||||||
Row(
|
|
||||||
Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.offset(y = (-36).dp)
|
|
||||||
) {
|
|
||||||
for (item in rowItems) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
.clickable(
|
|
||||||
indication = null,
|
|
||||||
interactionSource = remember { MutableInteractionSource() }
|
|
||||||
) {
|
|
||||||
|
|
||||||
val uniVersion =
|
|
||||||
PreferenceUtil.getUserConfig()?.config?.uniVersionEntity?.firstOrNull { it.unimp_type == item.type }
|
|
||||||
if(uniVersion == null){
|
|
||||||
CenterToast.show("无可用资源...")
|
|
||||||
return@clickable
|
|
||||||
}
|
}
|
||||||
val uniMpId = uniVersion.unimp_id
|
Box(modifier = Modifier.width(7.dp))
|
||||||
UniAppUtils.currentUniMpJumpPatch = item.url
|
Box(
|
||||||
val wgtExists = UniAppUtils.wgtIsExists(uniMpId)
|
modifier = Modifier
|
||||||
if(!wgtExists){
|
.wrapContentWidth()
|
||||||
//是否下载
|
.weight(1f)
|
||||||
scope.launch {
|
.clickable(
|
||||||
UniAppUtils.currentDownloadUniMp = uniVersion
|
indication = null,
|
||||||
GlobalStateManager(context).storeGlobalUniDownloadNotify(true)
|
interactionSource = remember { MutableInteractionSource() }
|
||||||
|
) {
|
||||||
|
val uniMp = uniVersionConfig[1]
|
||||||
|
val uniMpId = uniMp.unimp_id
|
||||||
|
// 处理点击事件,微信模拟器
|
||||||
|
if (UniAppUtils.isDownloadUniMp(uniMp)) {
|
||||||
|
//强制更新(更新释放新版本并启动)
|
||||||
|
UniAppUtils.downloadWGT(
|
||||||
|
context,
|
||||||
|
scope,
|
||||||
|
uniMp
|
||||||
|
) { uniState, _, progress ->
|
||||||
|
progressPair[uniMpId]
|
||||||
|
?: mutableMapOf<String, Float>().apply {
|
||||||
|
put(
|
||||||
|
uniMpId,
|
||||||
|
0f
|
||||||
|
)
|
||||||
|
}
|
||||||
|
when (uniState) {
|
||||||
|
UniMpUpdate.DOWNLOAD_START -> {
|
||||||
|
//资源开始下载
|
||||||
|
progressPair.apply { put(uniMpId, 0f) }
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_START")
|
||||||
|
}
|
||||||
|
|
||||||
|
UniMpUpdate.DOWNLOAD_FINISH -> {
|
||||||
|
//资源下载完成
|
||||||
|
progressPair.apply { put(uniMpId, 1f) }
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
||||||
|
}
|
||||||
|
|
||||||
|
UniMpUpdate.DOWNLOAD_FAIL -> {
|
||||||
|
//资源下载失败
|
||||||
|
progressPair.apply { put(uniMpId, -1f) }
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
//资源下载进度
|
||||||
|
if (progress != null) {
|
||||||
|
progressPair.apply {
|
||||||
|
put(
|
||||||
|
uniMpId,
|
||||||
|
progress
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Log.i(
|
||||||
|
"HomeScreen",
|
||||||
|
"DOWNLOAD_PROGRESS:$progress"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (UniAppUtils.isUpdate(uniMp)) {
|
||||||
|
// 提示更新(1、更新释放新版本并启动;2、直接启动现有版本)
|
||||||
|
UniAppUtils.currentUpdateUniMp = uniMp
|
||||||
|
scope.launch {
|
||||||
|
GlobalStateManager(context).storeGlobalUniUpdateNotify(
|
||||||
|
true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadingCallback?.showLoading()
|
||||||
|
//启动uni小程序(1、直接启动;2、释放并启动)
|
||||||
|
UniAppUtils.distributeUniMp(context, uniMp, reportViewModel) {
|
||||||
|
loadingCallback?.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
val uniMpId = uniVersionConfig[1].unimp_id
|
||||||
|
val uniIcon = uniVersionConfig[1].icon
|
||||||
|
if(uniVersionSize>1){
|
||||||
|
AsyncImage(
|
||||||
|
model = uniIcon,
|
||||||
|
contentDescription = "支付宝模拟器",
|
||||||
|
contentScale = ContentScale.FillWidth,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.aspectRatio(168 / 96f),
|
||||||
|
fallback = painterResource(id = R.mipmap.ic_alipay_mock),
|
||||||
|
error = painterResource(id = R.mipmap.ic_alipay_mock)
|
||||||
|
)
|
||||||
|
|
||||||
|
//下载完成前显示
|
||||||
|
if((progressPair[uniMpId]?:0f) > 0f && (progressPair[uniMpId]?:0f) < 1f){
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.aspectRatio(168 / 96f)
|
||||||
|
.background(
|
||||||
|
Color(
|
||||||
|
0x66000000
|
||||||
|
), RoundedCornerShape(18.dp)
|
||||||
|
),
|
||||||
|
){
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.align(Alignment.Center)
|
||||||
|
.padding(horizontal = 12.dp)
|
||||||
|
) {
|
||||||
|
// 使用 LinearProgressIndicator 显示确定性进度
|
||||||
|
LinearProgressIndicator(
|
||||||
|
progress = { progressPair[uniMpId]?:0f }, // 使用 Lambda 更新进度0~1
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(8.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "下载${((progressPair[uniMpId]?:0f) * 100).toInt()}%",
|
||||||
|
color = Color.White,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
UniAppUtils.startUniMpPage(context = context, uniMpId = uniMpId, uniMpType = item.type, pagePath = item.url, reportViewModel = reportViewModel)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
|
||||||
Column {
|
|
||||||
Box(modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(8.dp))
|
|
||||||
AsyncImage(
|
|
||||||
model = item.icon,
|
|
||||||
contentDescription = item.text,
|
|
||||||
contentScale = ContentScale.FillWidth,
|
|
||||||
modifier = Modifier
|
|
||||||
.width(48.dp)
|
|
||||||
.aspectRatio(48 / 48f)
|
|
||||||
.align(Alignment.CenterHorizontally),
|
|
||||||
fallback = painterResource(id = R.mipmap.ic_alipay_mock),
|
|
||||||
error = painterResource(id = R.mipmap.ic_alipay_mock)
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = item.text,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
fontWeight = FontWeight.Normal,
|
|
||||||
color = Color(0xFF1A1A1A),
|
|
||||||
modifier = Modifier
|
|
||||||
.wrapContentSize()
|
|
||||||
.align(Alignment.CenterHorizontally)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// 如果最后一行不满,填充空白占位
|
}
|
||||||
if (rowItems.size < columnsCount) {
|
//模拟器指定页
|
||||||
Spacer(Modifier.weight((columnsCount - rowItems.size).toFloat()))
|
items(rows) {rowItems ->
|
||||||
|
//通过配置展示-AD2
|
||||||
|
Row(
|
||||||
|
Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.offset(y = (-36).dp)
|
||||||
|
) {
|
||||||
|
for (item in rowItems) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.clickable(
|
||||||
|
indication = null,
|
||||||
|
interactionSource = remember { MutableInteractionSource() }
|
||||||
|
) {
|
||||||
|
|
||||||
|
val uniVersion =
|
||||||
|
PreferenceUtil.getUserConfig()?.config?.uniVersionEntity?.firstOrNull { it.unimp_type == item.type }
|
||||||
|
if(uniVersion == null){
|
||||||
|
CenterToast.show("无可用资源...")
|
||||||
|
return@clickable
|
||||||
|
}
|
||||||
|
val uniMpId = uniVersion.unimp_id
|
||||||
|
UniAppUtils.currentUniMpJumpPatch = item.url
|
||||||
|
val wgtExists = UniAppUtils.wgtIsExists(uniMpId)
|
||||||
|
if(!wgtExists){
|
||||||
|
//是否下载
|
||||||
|
scope.launch {
|
||||||
|
UniAppUtils.currentDownloadUniMp = uniVersion
|
||||||
|
GlobalStateManager(context).storeGlobalUniDownloadNotify(true)
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
UniAppUtils.startUniMpPage(context = context, uniMpId = uniMpId, uniMpType = item.type, pagePath = item.url, reportViewModel = reportViewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
|
Box(modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(8.dp))
|
||||||
|
AsyncImage(
|
||||||
|
model = item.icon,
|
||||||
|
contentDescription = item.text,
|
||||||
|
contentScale = ContentScale.FillWidth,
|
||||||
|
modifier = Modifier
|
||||||
|
.width(48.dp)
|
||||||
|
.aspectRatio(48 / 48f)
|
||||||
|
.align(Alignment.CenterHorizontally),
|
||||||
|
fallback = painterResource(id = R.mipmap.ic_alipay_mock),
|
||||||
|
error = painterResource(id = R.mipmap.ic_alipay_mock)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = item.text,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
color = Color(0xFF1A1A1A),
|
||||||
|
modifier = Modifier
|
||||||
|
.wrapContentSize()
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果最后一行不满,填充空白占位
|
||||||
|
if (rowItems.size < columnsCount) {
|
||||||
|
Spacer(Modifier.weight((columnsCount - rowItems.size).toFloat()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//选尺寸制作
|
||||||
item {
|
item {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -794,6 +799,7 @@ fun HomeScreen(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//选证件制作
|
||||||
item {
|
item {
|
||||||
//选证件制作
|
//选证件制作
|
||||||
Column(
|
Column(
|
||||||
|
|
@ -1272,6 +1278,7 @@ fun HomeScreen(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//其他
|
||||||
item {
|
item {
|
||||||
//其他
|
//其他
|
||||||
Column(
|
Column(
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,12 @@ class GeneralViewModel: BaseViewModel(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val _agreementStatus = MutableLiveData<Boolean>()
|
private val _agreementStatus = MutableLiveData(PreferenceUtil.getAgreement())
|
||||||
val agreementStatus: LiveData<Boolean> = _agreementStatus
|
val agreementStatus: LiveData<Boolean> = _agreementStatus
|
||||||
|
fun setIsAgreement(agreement: Boolean){
|
||||||
|
PreferenceUtil.saveAgreement(agreement)
|
||||||
|
_agreementStatus.value = agreement
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// 注册网络监听
|
// 注册网络监听
|
||||||
|
|
@ -66,14 +70,12 @@ class GeneralViewModel: BaseViewModel(){
|
||||||
.build()
|
.build()
|
||||||
connectivityManager.registerNetworkCallback(request, networkCallback)
|
connectivityManager.registerNetworkCallback(request, networkCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化状态
|
// 初始化状态
|
||||||
_networkStatus.value = isNetworkAvailable()
|
_networkStatus.value = isNetworkAvailable()
|
||||||
// 初始化隐私政策状态
|
|
||||||
_agreementStatus.value = PreferenceUtil.getAgreement()
|
|
||||||
|
|
||||||
// 初始化微信API
|
// 初始化微信API
|
||||||
HeadParamUtils.applicationContext?.let { initWXApi(it) }
|
HeadParamUtils.applicationContext?.let { initWXApi(it) }
|
||||||
|
// 隐私政策状态
|
||||||
|
_agreementStatus.value = PreferenceUtil.getAgreement()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isNetworkAvailable(): Boolean {
|
private fun isNetworkAvailable(): Boolean {
|
||||||
|
|
@ -92,11 +94,6 @@ class GeneralViewModel: BaseViewModel(){
|
||||||
_isNavigationBarVisible.value = visible
|
_isNavigationBarVisible.value = visible
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setIsAgreement(agreement: Boolean){
|
|
||||||
PreferenceUtil.saveAgreement(agreement)
|
|
||||||
_agreementStatus.value = agreement
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initWXApi(context: Context) {
|
private fun initWXApi(context: Context) {
|
||||||
api = WXAPIFactory.createWXAPI(context, Constants.WxAppId, true)
|
api = WXAPIFactory.createWXAPI(context, Constants.WxAppId, true)
|
||||||
api.registerApp(Constants.WxAppId)
|
api.registerApp(Constants.WxAppId)
|
||||||
|
|
@ -116,18 +113,6 @@ class GeneralViewModel: BaseViewModel(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun wxPay(api: IWXAPI){
|
|
||||||
// val request = PayReq()
|
|
||||||
// request.appId = "wx7d1a7d1507482cef"
|
|
||||||
// request.partnerId = "1511850511";
|
|
||||||
// request.prepayId= "wx06112039579543463f9116a0527ce30001"
|
|
||||||
// request.packageValue = "Sign=WXPay"
|
|
||||||
// request.nonceStr= "QjlkDdZY54eKmvfKrtawJD9Cws7pvUh0"
|
|
||||||
// request.timeStamp= "1772767239"
|
|
||||||
// request.sign= "DOhyV8QBng20nrZxgV8l8+4DD1foi7XKRfPnhHbzf63qWvL2f3miKTqAVtoS1U9syO38ENXrS18XzWHRMNnoyWgTGLp/SxbZjRjqHvrLJKIa1pH0svdv/uPXK1GlvjqsMXgeoTEXn73aHBNlcctNaZ8GCWbxpg77kdcCJfM+qWOSQOMJOpKh8lTx4dQzhWqdOSzABkQJTg6TThNUN3/00yeN7K9wZ4JOpN+Tmtaliztp0wQ3iAHgAqZmhxwv7ZyRev2izpoukdJ2aBn/+xPK/Hs5kI2KM67x6quvrWiQV31GixU2i84ddI3uxn1DwR90f5iEyA10NOylPA+D9rOEUQ=="
|
|
||||||
// api.sendReq(request)
|
|
||||||
// }
|
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
connectivityManager.unregisterNetworkCallback(networkCallback)
|
connectivityManager.unregisterNetworkCallback(networkCallback)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue