Compare commits

...

5 Commits

Author SHA1 Message Date
1d74bfc7a8 feat: 从SD卡兼容所有文件管理权限 2025-05-15 14:52:27 +08:00
3d118544bb Merge branch 'feat/GHZSCY-7890' into 'dev'
feat: 游戏详情-内容卡片 红点显示优化—客户端 https://jira.shanqu.cc/browse/GHZSCY-7890

See merge request halo/android/assistant-android!2190
2025-05-15 14:47:37 +08:00
730611362f feat: 游戏详情-内容卡片 红点显示优化—客户端 https://jira.shanqu.cc/browse/GHZSCY-7890 2025-05-15 14:47:37 +08:00
9825bb7d3f Merge branch 'feat/GHZSCY-7903' into 'dev'
feat: 关于插件说明的优化—客户端 https://jira.shanqu.cc/browse/GHZSCY-7903

See merge request halo/android/assistant-android!2189
2025-05-15 14:47:06 +08:00
7dfb69fd34 feat: 关于插件说明的优化—客户端 https://jira.shanqu.cc/browse/GHZSCY-7903 2025-05-15 14:47:06 +08:00
9 changed files with 132 additions and 28 deletions

View File

@ -3,9 +3,14 @@ package com.gh.vspace.installexternalgames
import android.Manifest
import android.app.Dialog
import android.content.ComponentName
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.provider.Settings
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.gh.common.util.DialogUtils
@ -37,6 +42,9 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
private var uninstallDisposable: Disposable? = null
private var shouldScan = false
override fun getLayoutId() = 0
override fun getInflatedLayout() =
@ -74,7 +82,24 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
adapter.notifyDataSetChanged()
}
requestStoragePermission()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) {
shouldScan = true
AlertDialog.Builder(requireContext()).setMessage("请在设置页面允许光环助手")
.setNegativeButton("") { dialog, which ->
val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
}.show()
} else {
mViewModel.scanPaths()
}
} else {
requestStoragePermission()
}
}
private fun requestStoragePermission() {
@ -96,6 +121,12 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
}
}
override fun onStart() {
super.onStart()
if (shouldScan) {
mViewModel.scanPaths()
}
}
private fun initView() {
dialog = DialogUtils.showWaitDialog(requireContext(), "")
@ -152,7 +183,7 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
}, true)
VHelper.newCwValidateVspaceBeforeAction(
requireContext(),null,
requireContext(), null,
) {
dialog.show()
}

View File

@ -37,7 +37,6 @@ import com.gh.gamecenter.gamedetail.detail.viewholder.GameDetailContentRecommend
import com.gh.gamecenter.gamedetail.entity.*
import com.gh.gamecenter.livedata.Event
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.login.user.UserRepository
import com.gh.gamecenter.manager.PackagesManager
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.vspace.VHelper
@ -105,7 +104,7 @@ class GameDetailViewModel(
private var relatedGameList = arrayListOf<GameEntity>()
// 内容卡片相关
private var contentCardList: List<ContentCardEntity>?= null
private var contentCardList: List<ContentCardEntity>? = null
private val contentCardSp by lazy {
HaloApp.getInstance().getSharedPreferences(SP_CONTENT_CARD, Context.MODE_PRIVATE)
}
@ -134,9 +133,9 @@ class GameDetailViewModel(
private var isGameUpdatable = false
private val compositeDisposable = CompositeDisposable()
private var userRelatedInfoReceivedCallback: (() -> Unit)? = null
init {
loadData()
}
@ -1117,6 +1116,14 @@ class GameDetailViewModel(
compositeDisposable.clear()
}
fun markContentCardRedDot(contentCardEntity: ContentCardEntity) {
SPUtils.setString(contentCardSp, RED_DOT_PREFIX + (gameId ?: "") + contentCardEntity.link.type, contentCardEntity.redDot.toString())
}
fun shouldShowContentCardRedDot(contentCardEntity: ContentCardEntity): Boolean {
return SPUtils.getString(contentCardSp, RED_DOT_PREFIX + (gameId ?: "") + contentCardEntity.link.type) != contentCardEntity.redDot.toString()
}
class Factory(
private val application: Application,
private val gameId: String?,
@ -1133,6 +1140,7 @@ class GameDetailViewModel(
companion object {
const val SP_CONTENT_CARD = "content_card"
const val TAG = "GameDetailViewModel"
const val RED_DOT_PREFIX = "red_dot_"
//[已领取/已淘号/再领/再淘]的礼包置底显示
fun sortLibaoList(libaoList: ArrayList<LibaoEntity>?) {

View File

@ -684,7 +684,7 @@ class GameDetailFragment : LazyFragment(), IScrollable {
null,
gameStatus = gameStatus
)
GameFunctionDialogFragment.show(requireContext(), gameDetailInfoTag.infoTags)
GameFunctionDialogFragment.show(requireContext(), gameEntity, gameDetailInfoTag.infoTags, gameDetailInfoTag.link)
}
}
}

View File

@ -1,6 +1,7 @@
package com.gh.gamecenter.gamedetail.detail.viewholder
import android.content.Context
import android.widget.TextView
import androidx.core.view.isVisible
import androidx.lifecycle.LifecycleOwner
import com.gh.common.constant.Config
@ -131,11 +132,9 @@ class GameDetailContentCardSingleItemViewHolder(
contentBannerView.startBannerLoop()
}
redDotTv.goneIf(!((contentCardEntity.link.type == TYPE_SERVER && contentCardEntity.server?.total != 0) || contentCardEntity.link.type == TYPE_GIFT)) {
if ((contentCardEntity.link.type == TYPE_SERVER) && (contentCardEntity.server?.calendar?.isNotEmpty() == true))
redDotTv.text = contentCardEntity.server?.total.toString()
if ((contentCardEntity.link.type == TYPE_GIFT) && (contentCardEntity.libao != null))
redDotTv.text = contentCardEntity.libao?.total.toString()
val showRedDot = contentCardEntity.redDot != 0 && viewModel.shouldShowContentCardRedDot(contentCardEntity)
redDotTv.goneIf(!showRedDot) {
redDotTv.text = contentCardEntity.redDot.toString()
}
val showNewTag = contentCardEntity.link.type == TYPE_ARCHIVE && contentCardEntity.archive != null && contentCardEntity.showNewTag
@ -173,11 +172,11 @@ class GameDetailContentCardSingleItemViewHolder(
confirmText = context.getString(com.gh.gamecenter.common.R.string.confirm),
cancelText = context.getString(com.gh.gamecenter.common.R.string.cancel),
confirmClickCallback = {
jumpToContentCardLink(context, contentCardEntity, viewModel)
jumpToContentCardLink(context, contentCardEntity, viewModel, redDotTv)
}
)
} else {
jumpToContentCardLink(context, contentCardEntity, viewModel)
jumpToContentCardLink(context, contentCardEntity, viewModel, redDotTv)
}
}
@ -189,11 +188,16 @@ class GameDetailContentCardSingleItemViewHolder(
}
}
fun jumpToContentCardLink(context: Context, contentCardEntity: ContentCardEntity, viewModel: GameDetailViewModel) {
fun jumpToContentCardLink(context: Context, contentCardEntity: ContentCardEntity, viewModel: GameDetailViewModel, redDotTv: TextView) {
val path = "游戏详情->内容卡片"
when (contentCardEntity.link.type) {
TYPE_GIFT,
TYPE_ARCHIVE -> {
if (contentCardEntity.link.type == TYPE_GIFT) {
viewModel.markContentCardRedDot(contentCardEntity)
redDotTv.isVisible = false
}
val type = if (contentCardEntity.link.type == TYPE_GIFT) GameDetailTabEntity.TYPE_GIFT else GameDetailTabEntity.TYPE_ARCHIVE
val tabList = viewModel.gameDetailTabListLiveData.value?.data
if (tabList?.find { it.type == type } != null) {
@ -208,6 +212,8 @@ class GameDetailContentCardSingleItemViewHolder(
TYPE_SERVER -> {
if (viewModel.game != null && contentCardEntity.server != null) {
viewModel.markContentCardRedDot(contentCardEntity)
redDotTv.isVisible = false
context.startActivity(
ServersCalendarActivity.getIntent(
context,

View File

@ -10,8 +10,6 @@ import com.gh.gamecenter.gamedetail.GameDetailViewModel
import com.gh.gamecenter.gamedetail.detail.viewholder.GameDetailContentCardSingleItemViewHolder.Companion.jumpToContentCardLink
import com.gh.gamecenter.gamedetail.entity.ContentCardEntity
import com.gh.gamecenter.gamedetail.entity.ContentCardEntity.Companion.TYPE_ARCHIVE
import com.gh.gamecenter.gamedetail.entity.ContentCardEntity.Companion.TYPE_GIFT
import com.gh.gamecenter.gamedetail.entity.ContentCardEntity.Companion.TYPE_SERVER
import com.gh.gamecenter.gamedetail.entity.GameDetailData
class GameDetailContentCardTripleItemViewHolder(
@ -74,11 +72,9 @@ class GameDetailContentCardTripleItemViewHolder(
titleTv.text = contentCardEntity.title
ImageUtils.display(iconIv, contentCardEntity.icon)
redDotTv.goneIf(!((contentCardEntity.link.type == TYPE_SERVER && contentCardEntity.server?.total != 0) || contentCardEntity.link.type == TYPE_GIFT)) {
if ((contentCardEntity.link.type == TYPE_SERVER) && (contentCardEntity.server?.calendar?.isNotEmpty() == true))
redDotTv.text = contentCardEntity.server?.total.toString()
if ((contentCardEntity.link.type == TYPE_GIFT) && (contentCardEntity.libao != null))
redDotTv.text = contentCardEntity.libao?.total.toString()
val showRedDot = contentCardEntity.redDot != 0 && viewModel.shouldShowContentCardRedDot(contentCardEntity)
redDotTv.goneIf(!showRedDot) {
redDotTv.text = contentCardEntity.redDot.toString()
}
val showNewTag = contentCardEntity.link.type == TYPE_ARCHIVE && contentCardEntity.archive != null && contentCardEntity.showNewTag
@ -116,11 +112,11 @@ class GameDetailContentCardTripleItemViewHolder(
confirmText = context.getString(com.gh.gamecenter.common.R.string.confirm),
cancelText = context.getString(com.gh.gamecenter.common.R.string.cancel),
confirmClickCallback = {
jumpToContentCardLink(context, contentCardEntity, viewModel)
jumpToContentCardLink(context, contentCardEntity, viewModel, redDotTv)
}
)
} else {
jumpToContentCardLink(context, contentCardEntity, viewModel)
jumpToContentCardLink(context, contentCardEntity, viewModel, redDotTv)
}
}

View File

@ -9,19 +9,29 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.base.fragment.BaseBottomDialogFragment
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.databinding.DialogGameDetailRecyclerViewBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.gamedetail.entity.GameDetailInfoTag
import com.lightgame.utils.AppManager
class GameFunctionDialogFragment: BaseBottomDialogFragment<DialogGameDetailRecyclerViewBinding>() {
private var infoTags: List<GameDetailInfoTag.InfoTag> = arrayListOf()
private var linkEntity: LinkEntity? = null
private var gameEntity: GameEntity? = null
private val adapter by lazy { GameFunctionAdapter(requireContext(), infoTags) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
gameEntity = arguments?.getParcelable(EntranceConsts.KEY_GAME_ENTITY)
infoTags = arguments?.getParcelableArrayList(KEY_INFO_TAG) ?: arrayListOf()
linkEntity = arguments?.getParcelable(EntranceConsts.KEY_LINK)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -30,6 +40,28 @@ class GameFunctionDialogFragment: BaseBottomDialogFragment<DialogGameDetailRecyc
mBinding.closeIv.setOnClickListener {
dismissAllowingStateLoss()
}
mBinding.subtitleTv.goneIf(linkEntity == null) {
mBinding.subtitleTv.text = linkEntity?.text
mBinding.subtitleTv.setOnClickListener { _ ->
linkEntity?.let {
DirectUtils.directToLinkPage(requireContext(), it, "游戏详情-功能说明", "")
SensorsBridge.trackGameDetailModuleClick(
gameEntity?.id,
gameEntity?.name,
gameEntity?.categoryChinese,
"组件内容",
"功能标签",
"功能标签",
null,
subModuleName = "跳转入口",
linkType = it.type,
linkId = it.link,
linkText = it.text,
gameStatus = null
)
}
}
}
mBinding.recyclerView.run {
layoutManager = LinearLayoutManager(requireContext())
adapter = this@GameFunctionDialogFragment.adapter
@ -46,7 +78,7 @@ class GameFunctionDialogFragment: BaseBottomDialogFragment<DialogGameDetailRecyc
const val KEY_INFO_TAG = "info_tag"
@JvmStatic
fun show(context: Context?, infoTags: List<GameDetailInfoTag.InfoTag>) {
fun show(context: Context?, gameEntity: GameEntity?, infoTags: List<GameDetailInfoTag.InfoTag>, linkEntity: LinkEntity?) {
val fragmentActivity: FragmentActivity = if (context is FragmentActivity) {
context
} else if (BuildConfig.DEBUG) {
@ -65,7 +97,9 @@ class GameFunctionDialogFragment: BaseBottomDialogFragment<DialogGameDetailRecyc
val dialogFragment = GameFunctionDialogFragment()
dialogFragment.arguments = bundleOf(
KEY_INFO_TAG to infoTags
EntranceConsts.KEY_GAME_ENTITY to gameEntity,
KEY_INFO_TAG to infoTags,
EntranceConsts.KEY_LINK to linkEntity
)
dialogFragment.show(fragmentActivity.supportFragmentManager, GameFunctionDialogFragment::class.java.name)
}

View File

@ -31,6 +31,13 @@ class ContentCardEntity(
var showNewTag: Boolean = false,
) {
val redDot
get() = when (link.type) {
TYPE_SERVER -> server?.total ?: 0
TYPE_GIFT -> libao?.total ?: 0
else -> 0
}
@Keep
class Dialog(
@SerializedName("_id")

View File

@ -219,7 +219,9 @@ data class GameDetailInfoTag(
@SerializedName("info_tags")
val infoTags: List<InfoTag> = listOf(), // 功能标签
@SerializedName("request_speed_status")
val requestSpeedStatus: String = "" // 求加速状态, on/off
val requestSpeedStatus: String = "", // 求加速状态, on/off
@SerializedName("plugin_tutorial_link")
val link: LinkEntity? = null, // 插件教程链接
) {
@Parcelize
data class InfoTag(

View File

@ -25,7 +25,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:gravity="center"
android:textColor="@color/text_primary"
android:textSize="@dimen/secondary_title_text_size"
@ -35,6 +34,27 @@
app:layout_constraintTop_toTopOf="@+id/closeIv"
tools:text="其他2款游戏" />
<TextView
android:id="@+id/subtitleTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:includeFontPadding="false"
android:lines="1"
android:textColor="@color/text_theme"
android:textSize="@dimen/secondary_size"
android:visibility="gone"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="@+id/titleTv"
app:layout_constraintEnd_toStartOf="@+id/closeIv"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/titleTv"
app:layout_constraintTop_toTopOf="@+id/titleTv"
tools:text="使用教程使用教程使用教程使用教程使用教程使用教程使用教程使用教程"
tools:visibility="visible" />
<View
android:id="@+id/divider"
android:layout_width="0dp"