parent
decdad3de1
commit
328b62e757
|
|
@ -4,10 +4,10 @@
|
||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2026-03-11T08:00:19.371243300Z">
|
<DropdownSelection timestamp="2026-03-11T09:00:47.807813Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=Y5DELZR46DZTCI9D" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=JRBI89BIE6AI5TG6" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.google.accompanist.permissions.ExperimentalPermissionsApi
|
import com.google.accompanist.permissions.ExperimentalPermissionsApi
|
||||||
|
import com.img.rabbit.bean.request.ReportKey
|
||||||
|
import com.img.rabbit.bean.request.ReportRequest
|
||||||
|
import com.img.rabbit.bean.request.ReportType
|
||||||
|
import com.img.rabbit.components.CenterToast
|
||||||
import com.img.rabbit.components.GlobalToast
|
import com.img.rabbit.components.GlobalToast
|
||||||
import com.img.rabbit.config.Constants
|
import com.img.rabbit.config.Constants
|
||||||
import com.img.rabbit.config.Constants.agreementUrl
|
import com.img.rabbit.config.Constants.agreementUrl
|
||||||
|
|
@ -114,7 +118,16 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
val updateUserConfigNotify by GlobalStateManager(context).globalUserConfigNotifyFlow().collectAsState(initial = false)
|
val updateUserConfigNotify by GlobalStateManager(context).globalUserConfigNotifyFlow().collectAsState(initial = false)
|
||||||
val updateUniUpdateNotify by GlobalStateManager(context).globalUniUpdateNotifyFlow().collectAsState(initial = false)
|
val updateUniUpdateNotify by GlobalStateManager(context).globalUniUpdateNotifyFlow().collectAsState(initial = false)
|
||||||
val updateGlobalLoadingNotify by GlobalStateManager(context).isGlobalLoadingFlow().collectAsState(initial = false)
|
val updateGlobalLoadingNotify by GlobalStateManager(context).isGlobalLoadingFlow().collectAsState(initial = false)
|
||||||
|
//重置状态信息(防止异常退出导致状态失效)
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
GlobalStateManager(context).apply {
|
||||||
|
storeGlobalUpdateNotify(false)
|
||||||
|
storeGlobalUniDownloadNotify(false)
|
||||||
|
storeGlobalUserConfigNotify(false)
|
||||||
|
storeGlobalUniUpdateNotify(false)
|
||||||
|
storeGlobalLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 设置启动页显示条件
|
// 设置启动页显示条件
|
||||||
splashScreen.setKeepOnScreenCondition {
|
splashScreen.setKeepOnScreenCondition {
|
||||||
|
|
@ -171,6 +184,76 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//提示下载小程序资源(在跳转指定页面时,未下载资源需要提示)
|
||||||
|
val progressWGTToPageState = mutableFloatStateOf(0f)
|
||||||
|
LaunchedEffect(updateUniDownloadNotify) {
|
||||||
|
if(updateUniDownloadNotify == true) {
|
||||||
|
UniAppUtils.currentDownloadUniMp?.let{
|
||||||
|
UniAppUtils.downloadReleaseWgt(
|
||||||
|
coroutineScope,
|
||||||
|
it,
|
||||||
|
onProgress = { uniState, progress ->
|
||||||
|
when (uniState) {
|
||||||
|
UniMpUpdate.DOWNLOAD_START -> {
|
||||||
|
//资源开始下载
|
||||||
|
progressWGTToPageState.floatValue = 0f
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_START")
|
||||||
|
}
|
||||||
|
|
||||||
|
UniMpUpdate.DOWNLOAD_FINISH -> {
|
||||||
|
//资源下载完成
|
||||||
|
progressWGTToPageState.floatValue = 1f
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
||||||
|
coroutineScope.launch {
|
||||||
|
GlobalStateManager(context).storeGlobalUniDownloadNotify(
|
||||||
|
false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UniMpUpdate.DOWNLOAD_FAIL -> {
|
||||||
|
//资源下载失败
|
||||||
|
progressWGTToPageState.floatValue = -1f
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
||||||
|
coroutineScope.launch {
|
||||||
|
GlobalStateManager(context).storeGlobalUniDownloadNotify(
|
||||||
|
false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
//资源下载进度
|
||||||
|
if (progress != null) {
|
||||||
|
progressWGTToPageState.floatValue = progress
|
||||||
|
Log.i("HomeScreen", "DOWNLOAD_PROGRESS:$progress")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRelease = { isSuccess->
|
||||||
|
if(isSuccess){
|
||||||
|
//资源下载完成后,启动小程序到指定位置
|
||||||
|
val uniMpEntity = UniAppUtils.currentDownloadUniMp
|
||||||
|
if (uniMpEntity != null && UniAppUtils.isRelease(uniMpEntity.unimp_id)) {
|
||||||
|
UniAppUtils.startUniMpPage(
|
||||||
|
context = context,
|
||||||
|
uniMpId = uniMpEntity.unimp_id,
|
||||||
|
uniMpType = uniMpEntity.unimp_type,
|
||||||
|
pagePath = UniAppUtils.currentUniMpJumpPatch ?: "",
|
||||||
|
reportViewModel = reportViewModel
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
reportViewModel = reportViewModel
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AppTheme {
|
AppTheme {
|
||||||
SplashScreenContent{
|
SplashScreenContent{
|
||||||
//未同意提示政策弹窗
|
//未同意提示政策弹窗
|
||||||
|
|
@ -217,67 +300,8 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
//提示下载小程序资源(在跳转指定页面时,未下载资源需要提示)
|
//提示下载小程序资源(在跳转指定页面时,未下载资源需要提示)
|
||||||
val progressWGTToPageState = mutableFloatStateOf(0f)
|
|
||||||
if(updateUniDownloadNotify == true){
|
if(updateUniDownloadNotify == true){
|
||||||
UniAppUtils.currentDownloadUniMp?.let {
|
UniAppUtils.currentDownloadUniMp?.let {
|
||||||
UniAppUtils.downloadReleaseWgt(
|
|
||||||
coroutineScope,
|
|
||||||
it,
|
|
||||||
onProgress = { uniState, progress ->
|
|
||||||
when (uniState) {
|
|
||||||
UniMpUpdate.DOWNLOAD_START -> {
|
|
||||||
//资源开始下载
|
|
||||||
progressWGTToPageState.floatValue = 0f
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_START")
|
|
||||||
}
|
|
||||||
|
|
||||||
UniMpUpdate.DOWNLOAD_FINISH -> {
|
|
||||||
//资源下载完成
|
|
||||||
progressWGTToPageState.floatValue = 1f
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
|
||||||
coroutineScope.launch {
|
|
||||||
GlobalStateManager(context).storeGlobalUniDownloadNotify(
|
|
||||||
false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UniMpUpdate.DOWNLOAD_FAIL -> {
|
|
||||||
//资源下载失败
|
|
||||||
progressWGTToPageState.floatValue = -1f
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
|
||||||
coroutineScope.launch {
|
|
||||||
GlobalStateManager(context).storeGlobalUniDownloadNotify(
|
|
||||||
false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
//资源下载进度
|
|
||||||
if (progress != null) {
|
|
||||||
progressWGTToPageState.floatValue = progress
|
|
||||||
Log.i("HomeScreen", "DOWNLOAD_PROGRESS:$progress")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onRelease = {
|
|
||||||
//资源下载完成后,启动小程序到指定位置
|
|
||||||
val uniMpEntity = UniAppUtils.currentDownloadUniMp
|
|
||||||
if (uniMpEntity != null) {
|
|
||||||
UniAppUtils.startUniMpPage(
|
|
||||||
context = context,
|
|
||||||
uniMpId = uniMpEntity.unimp_id,
|
|
||||||
uniMpType = uniMpEntity.unimp_type,
|
|
||||||
pagePath = UniAppUtils.currentUniMpJumpPatch ?: "",
|
|
||||||
reportViewModel = reportViewModel
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
reportViewModel = reportViewModel
|
|
||||||
)
|
|
||||||
TipsUniMpToPageDialog(
|
TipsUniMpToPageDialog(
|
||||||
title = "下载资源",
|
title = "下载资源",
|
||||||
content1 = "需要下载完资源才能运行,请稍后...",
|
content1 = "需要下载完资源才能运行,请稍后...",
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,6 @@ fun HomeScreen(
|
||||||
if(updateUserConfigNotify == true){
|
if(updateUserConfigNotify == true){
|
||||||
homeIconConfig = PreferenceUtil.getUserConfig()?.config?.homeIconEntity
|
homeIconConfig = PreferenceUtil.getUserConfig()?.config?.homeIconEntity
|
||||||
uniVersionConfig = PreferenceUtil.getUserConfig()?.config?.uniVersionEntity
|
uniVersionConfig = PreferenceUtil.getUserConfig()?.config?.uniVersionEntity
|
||||||
|
|
||||||
Log.i(TAG,"-------------->HomeScreen页面,用户配置已经刷新")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ object UniAppUtils {
|
||||||
return FileUtils.instance?.fileIsExists(wgtFile) == true && FileUtils.getFileSize(wgtFile) > 0
|
return FileUtils.instance?.fileIsExists(wgtFile) == true && FileUtils.getFileSize(wgtFile) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isRelease(uniMpId: String): Boolean{
|
fun isRelease(uniMpId: String): Boolean{
|
||||||
return DCUniMPSDK.getInstance().isExistsApp(uniMpId)
|
return DCUniMPSDK.getInstance().isExistsApp(uniMpId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue