Merge branch 'feature-GHZS-796' into 'dev-5.18.0'

feat:优化设置模块 https://jira.shanqu.cc/browse/GHZS-796

See merge request halo/android/assistant-android!585
This commit is contained in:
叶子维
2022-12-21 15:05:14 +08:00
33 changed files with 227 additions and 132 deletions

View File

@ -42,8 +42,7 @@ import com.gh.gamecenter.login.utils.LoginHelper
import com.gh.gamecenter.login.utils.QuickLoginHelper
import com.gh.gamecenter.login.view.LoginActivity
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
import com.gh.gamecenter.setting.view.AboutActivity
import com.gh.gamecenter.setting.view.security.BindPhoneActivity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.vspace.VHelper
import com.halo.assistant.HaloApp
import com.lightgame.download.DataWatcher
@ -55,8 +54,6 @@ import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.util.*
import kotlin.collections.HashMap
import kotlin.collections.HashSet
class DefaultJsApi(var context: Context, val entrance: String = "", private var mFragment: Fragment? = null) {
@ -298,7 +295,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun bindPhone(msg: Any) {
val intent = BindPhoneActivity.getNormalIntent(context, false)
val intent = SettingBridge.getBindPhoneNormalIntent(context, false)
context.startActivity(intent)
}
@ -444,7 +441,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun checkUpdateGhzs(msg: Any) {
context.startActivity(AboutActivity.getIntent(context, true))
context.startActivity(SettingBridge.getAboutIntent(context, true))
}
@JavascriptInterface

View File

@ -29,7 +29,6 @@ import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.databinding.DialogDeviceRemindBinding
import com.gh.gamecenter.entity.DeviceDialogEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
import com.google.gson.reflect.TypeToken
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
@ -53,7 +52,7 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
private val dataWatcher = object : DataWatcher() {
override fun onDataChanged(downloadEntity: DownloadEntity) {
if (downloadEntity.status == DownloadStatus.done && downloadEntity.name == gameEntity.name) {
val autoInstall = SPUtils.getBoolean(GameDownloadSettingFragment.AUTO_INSTALL_SP_KEY, true)
val autoInstall = SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true)
if (autoInstall) {
dismiss()
}

View File

@ -92,8 +92,7 @@ import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.entity.SimpleGameEntity;
import com.gh.gamecenter.entity.TrackableEntity;
import com.gh.gamecenter.login.entity.Badge;
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment;
import com.gh.gamecenter.setting.view.security.BindPhoneActivity;
import com.gh.gamecenter.setting.SettingBridge;
import com.gh.gamecenter.suggest.SuggestType;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.download.DownloadEntity;
@ -215,7 +214,7 @@ public class DialogUtils {
} else if (NetworkUtils.isWifiConnected(context)
|| filter4GorSize(context, size)) {
callBack.onResponse(false);
} else if (!SPUtils.getBoolean(GameDownloadSettingFragment.getTrafficDownloadHintKey(), true)) {
} else if (!SPUtils.getBoolean(getTrafficDownloadHintKey(), true)) {
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"), 500);
callBack.onResponse(false);
} else {
@ -226,6 +225,10 @@ public class DialogUtils {
}
}
private static String getTrafficDownloadHintKey() {
return PackageUtils.getGhVersionName() + "traffic_download_hint";
}
private static boolean filter4GorSize(Context context, String size) {
try {
if (TextUtils.isEmpty(size)) {
@ -287,7 +290,7 @@ public class DialogUtils {
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "连上WiFi后自动下载");
});
allowAlways.setOnClickListener(v -> {
SPUtils.setBoolean(GameDownloadSettingFragment.getTrafficDownloadHintKey(), false);
SPUtils.setBoolean(getTrafficDownloadHintKey(), false);
AppExecutor.getUiExecutor().executeWithDelay(() -> {
// 显示了弹窗以后,即便下面这个 toast 放在 listener.onConfirm 后调用也是显示 listener.onConfirm 里的 toast
// 喷了,延时包治疑难杂症
@ -2045,7 +2048,7 @@ public class DialogUtils {
binding.bindPhoneBtn.setOnClickListener(v -> {
dialog.dismiss();
Intent intent = BindPhoneActivity.getNormalIntent(finalContext, false);
Intent intent = SettingBridge.INSTANCE.getBindPhoneNormalIntent(finalContext, false);
finalContext.startActivity(intent);
});

View File

@ -65,8 +65,7 @@ import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.servers.GameServerTestActivity
import com.gh.gamecenter.servers.GameServersActivity
import com.gh.gamecenter.setting.view.security.BindPhoneActivity
import com.gh.gamecenter.setting.view.SettingActivity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.gamecenter.subject.SubjectActivity
import com.gh.gamecenter.suggest.SuggestType
import com.gh.gamecenter.tag.TagsActivity
@ -359,7 +358,7 @@ object DirectUtils {
"mobile_bind" -> {
CheckLoginUtils.checkLogin(context, entrance) {
context.startActivity(BindPhoneActivity.getNormalIntent(context, false))
context.startActivity(SettingBridge.getBindPhoneNormalIntent(context, false))
}
}
@ -389,7 +388,7 @@ object DirectUtils {
"etiquette_exam" -> directToRegulationTestPage(context)
"setting" -> context.startActivity(SettingActivity.getIntent(context, false, entrance))
"setting" -> context.startActivity(SettingBridge.getSettingIntent(context, false, entrance))
"index_page" -> directToHomeTab(context)

View File

@ -1,6 +1,5 @@
package com.gh.common.util
import android.preference.PreferenceManager
import com.gh.common.constant.Config
import com.gh.common.exposure.ExposureUtils
import com.gh.common.simulator.SimulatorDownloadManager
@ -23,7 +22,6 @@ import com.gh.gamecenter.entity.SimpleGameEntity
import com.gh.gamecenter.entity.SimulatorEntity
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
import com.gh.gamecenter.suggest.SuggestType
import com.gh.vspace.VHelper
import com.halo.assistant.HaloApp
@ -266,7 +264,7 @@ object DownloadObserver {
} else {
val downloadType = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
// 是否是自动安装
val isAutoInstall = SPUtils.getBoolean(GameDownloadSettingFragment.AUTO_INSTALL_SP_KEY, true)
val isAutoInstall = SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true)
if (downloadType == Constants.SIMULATOR_DOWNLOAD || isAutoInstall) {
if (FileUtils.isEmptyFile(downloadEntity.path)) {
Utils.toast(mApplication, R.string.install_failure_hint)

View File

@ -22,7 +22,6 @@ import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.packagehelper.PackageRepository
import com.gh.gamecenter.packagehelper.PackageViewModel
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
import com.halo.assistant.HaloApp
import com.lightgame.download.DownloadEntity
import com.lightgame.download.FileUtils
@ -109,7 +108,7 @@ object PackageObserver {
DownloadManager.getInstance().cancel(mDownloadEntity.url, false, true, false)
if (SPUtils.getBoolean(GameDownloadSettingFragment.CONCERN_GAME_SP_KEY, true)) { //设置页面控制是否安装后自动关注
if (SPUtils.getBoolean(Constants.SP_CONCERN_GAME, true)) { //设置页面控制是否安装后自动关注
// 安装后关注游戏
val finalDownloadEntity = mDownloadEntity
RetrofitManager.getInstance().api

View File

@ -39,6 +39,7 @@ import com.gh.common.util.NewLogUtils;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
import com.gh.gamecenter.common.callback.OnRequestCallBackListener;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.ExtensionsKt;
@ -59,7 +60,6 @@ import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.newsdetail.NewsDetailAdapter;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.gamecenter.setting.view.SettingsFragment;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadEntity;
import com.lightgame.utils.Utils;
@ -319,7 +319,7 @@ public class NewsDetailActivity extends DownloadToolbarActivity implements OnCli
}
sp = PreferenceManager.getDefaultSharedPreferences(this);
fontsize = sp.getInt(SettingsFragment.FONT_SIZE_SP_KEY, 1);
fontsize = sp.getInt(Constants.SP_FONT_SIZE, 1);
if (fontsize == 0) {
fontsize = 1;
}
@ -556,14 +556,14 @@ public class NewsDetailActivity extends DownloadToolbarActivity implements OnCli
if ((R11 - R12) > scrollSize && fontsize > 1) {
fontsize--;
adapter.setFontSize(fontsize);
sp.edit().putInt(SettingsFragment.FONT_SIZE_SP_KEY, fontsize).apply();
sp.edit().putInt(Constants.SP_FONT_SIZE, fontsize).apply();
String fontSizeText = getFontSize(fontsize);
Utils.toast(this, fontSizeText);
}
if ((R11 - R12) < -scrollSize && fontsize < 4) {
fontsize++;
adapter.setFontSize(fontsize);
sp.edit().putInt(SettingsFragment.FONT_SIZE_SP_KEY, fontsize).apply();
sp.edit().putInt(Constants.SP_FONT_SIZE, fontsize).apply();
String fontSizeText = getFontSize(fontsize);
Utils.toast(this, fontSizeText);
}

View File

@ -12,7 +12,6 @@ import com.gh.gamecenter.common.utils.safelyGetInRelease
import com.gh.gamecenter.core.utils.MD5Utils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.entity.ForumVideoEntity
import com.gh.gamecenter.setting.view.VideoSettingFragment
import com.gh.gamecenter.video.detail.CustomManager
import com.halo.assistant.HaloApp
import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer
@ -150,15 +149,15 @@ class ForumScrollCalculatorHelper(
if (gsyBaseVideoPlayer != null && !gsyBaseVideoPlayer!!.isInPlayingState) {
val videoOption =
SPUtils.getString(Constants.SP_CONTENT_VIDEO_OPTION, VideoSettingFragment.VIDEO_OPTION_WIFI)
?: VideoSettingFragment.VIDEO_OPTION_WIFI
SPUtils.getString(Constants.SP_CONTENT_VIDEO_OPTION, Constants.VIDEO_OPTION_WIFI)
?: Constants.VIDEO_OPTION_WIFI
when (videoOption) {
VideoSettingFragment.VIDEO_OPTION_ALL -> {
Constants.VIDEO_OPTION_ALL -> {
startPlayLogic(gsyBaseVideoPlayer)
}
VideoSettingFragment.VIDEO_OPTION_WIFI -> {
Constants.VIDEO_OPTION_WIFI -> {
if (NetworkUtils.isWifiConnected(HaloApp.getInstance().application)) {
startPlayLogic(gsyBaseVideoPlayer)
}

View File

@ -29,7 +29,6 @@ import com.gh.gamecenter.game.rank.RankCollectionAdapter
import com.gh.gamecenter.gamecollection.square.GameCollectionListItemData
import com.gh.gamecenter.home.BlankDividerViewHolder
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.setting.view.SettingsFragment
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
import io.reactivex.Observable
@ -97,7 +96,7 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
// 游戏库才需要展示"猜你喜欢"专题
if (blockData?.text == "游戏库"
&& blockData?.name == "游戏库"
&& SPUtils.getBoolean(SettingsFragment.PERSONAL_RECOMMEND_SP_KEY, true)
&& SPUtils.getBoolean(Constants.SP_PERSONAL_RECOMMEND, true)
) {
getSmartColumn()
}

View File

@ -55,7 +55,6 @@ import com.gh.gamecenter.qa.article.detail.CommentItemData
import com.gh.gamecenter.qa.comment.CommentActivity
import com.gh.gamecenter.qa.comment.base.BaseCommentAdapter
import com.gh.gamecenter.qa.comment.base.BaseCommentViewModel
import com.gh.gamecenter.setting.view.VideoSettingFragment
import com.gh.gamecenter.video.detail.CustomManager
import com.google.android.material.appbar.AppBarLayout
import com.halo.assistant.HaloApp
@ -692,15 +691,15 @@ class GameCollectionDetailFragment :
//val trafficVideo = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.TRAFFIC_VIDEO_SP_KEY, false)
val videoOption = SPUtils.getString(
Constants.SP_HOME_OR_DETAIL_VIDEO_OPTION,
VideoSettingFragment.VIDEO_OPTION_WIFI
Constants.VIDEO_OPTION_WIFI
)
?: VideoSettingFragment.VIDEO_OPTION_WIFI
?: Constants.VIDEO_OPTION_WIFI
when (videoOption) {
VideoSettingFragment.VIDEO_OPTION_ALL -> {
Constants.VIDEO_OPTION_ALL -> {
startPlayLogic(isAutoPlay = true)
}
VideoSettingFragment.VIDEO_OPTION_WIFI -> {
Constants.VIDEO_OPTION_WIFI -> {
if (NetworkUtils.isWifiConnected(requireContext()) /*|| !trafficVideo*/) {
if (mListViewModel.isTopVideoPartlyCached(video.url)) {
startPlayLogic(isAutoPlay = true)

View File

@ -75,7 +75,6 @@ import com.gh.gamecenter.gamedetail.video.TopVideoView
import com.gh.gamecenter.home.video.ScrollCalculatorHelper
import com.gh.gamecenter.login.user.UserViewModel
import com.gh.gamecenter.packagehelper.PackageViewModel
import com.gh.gamecenter.setting.view.VideoSettingFragment
import com.gh.gamecenter.simulatorgame.SimulatorGameActivity
import com.gh.gamecenter.tag.TagsActivity
import com.gh.gamecenter.video.detail.CustomManager
@ -1365,15 +1364,15 @@ class GameDetailFragment : ToolbarFragment(), IScrollable {
//val trafficVideo = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.TRAFFIC_VIDEO_SP_KEY, false)
val videoOption = SPUtils.getString(
Constants.SP_HOME_OR_DETAIL_VIDEO_OPTION,
VideoSettingFragment.VIDEO_OPTION_WIFI
Constants.VIDEO_OPTION_WIFI
)
?: VideoSettingFragment.VIDEO_OPTION_WIFI
?: Constants.VIDEO_OPTION_WIFI
when (videoOption) {
VideoSettingFragment.VIDEO_OPTION_ALL -> {
Constants.VIDEO_OPTION_ALL -> {
mVideoBinding.player.startPlayLogic(isAutoPlay = true)
}
VideoSettingFragment.VIDEO_OPTION_WIFI -> {
Constants.VIDEO_OPTION_WIFI -> {
if (NetworkUtils.isWifiConnected(requireContext()) /*|| !trafficVideo*/) {
if (mViewModel.isTopVideoPartlyCached(topVideo.url)) {
mVideoBinding.player.startPlayLogic(isAutoPlay = true)

View File

@ -38,7 +38,7 @@ import com.gh.gamecenter.home.discovercard.HomeDiscoverCardViewHolder
import com.gh.gamecenter.home.gamecollection.HomeGameCollectionViewHolder
import com.gh.gamecenter.home.slide.HomeSlideListAdapter
import com.gh.gamecenter.home.slide.HomeSlideListViewHolder
import com.gh.gamecenter.setting.view.AboutActivity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.vspace.HomeRecentVGameAdapter
import com.gh.vspace.HomeRecentVGameViewHolder
import com.gh.vspace.VHelper
@ -228,7 +228,7 @@ class HomeFragmentAdapter(
private fun bindUnknown(holder: ReuseViewHolder) {
holder.itemView.setOnClickListener {
mContext.startActivity(AboutActivity.getIntent(mContext, true))
mContext.startActivity(SettingBridge.getAboutIntent(mContext, true))
}
}

View File

@ -24,7 +24,6 @@ import com.gh.gamecenter.game.rank.RankCollectionAdapter
import com.gh.gamecenter.gamecollection.square.GameCollectionListItemData
import com.gh.gamecenter.packagehelper.PackageRepository
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.setting.view.SettingsFragment
import com.gh.vspace.VGameItemData
import com.gh.vspace.VHelper
import com.halo.assistant.HaloApp
@ -100,7 +99,7 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
// 触发列表刷新行为时亦刷新内存中的备用游戏库列表
GameSubstituteRepositoryHelper.refreshRepositoryFromLocal()
if (SPUtils.getBoolean(SettingsFragment.PERSONAL_RECOMMEND_SP_KEY, true)) {
if (SPUtils.getBoolean(Constants.SP_PERSONAL_RECOMMEND, true)) {
getSmartColumn()
}

View File

@ -21,7 +21,7 @@ import com.gh.gamecenter.core.utils.PageSwitchDataHelper
import com.gh.gamecenter.databinding.HomeSlideListItemBinding
import com.gh.gamecenter.entity.HomeSlide
import com.gh.gamecenter.home.HomeItemData
import com.gh.gamecenter.setting.view.AboutActivity
import com.gh.gamecenter.setting.SettingBridge
import com.lightgame.adapter.BaseRecyclerAdapter
import com.lightgame.download.DownloadEntity
import java.lang.ref.WeakReference
@ -116,7 +116,7 @@ class HomeSlideListAdapter(
"新首页-轮播图[${homeSlide.linkText}<-||->${homeSlide.title}=${homeSlide.linkType}=$actualPositionString]",
exposureEvent,
unknownCallback = {
mContext.startActivity(AboutActivity.getIntent(mContext, true))
mContext.startActivity(SettingBridge.getAboutIntent(mContext, true))
})
}

View File

@ -9,7 +9,6 @@ import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.utils.NetworkUtils
import com.gh.gamecenter.core.utils.MD5Utils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.setting.view.VideoSettingFragment
import com.gh.gamecenter.video.detail.CustomManager
import com.halo.assistant.HaloApp
import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer
@ -98,15 +97,15 @@ class ScrollCalculatorHelper(private val mListRv: RecyclerView, private val mPla
if (gsyBaseVideoPlayer != null && !gsyBaseVideoPlayer!!.isInPlayingState) {
val videoOption =
SPUtils.getString(Constants.SP_HOME_OR_DETAIL_VIDEO_OPTION, VideoSettingFragment.VIDEO_OPTION_WIFI)
?: VideoSettingFragment.VIDEO_OPTION_WIFI
SPUtils.getString(Constants.SP_HOME_OR_DETAIL_VIDEO_OPTION, Constants.VIDEO_OPTION_WIFI)
?: Constants.VIDEO_OPTION_WIFI
when (videoOption) {
VideoSettingFragment.VIDEO_OPTION_ALL -> {
Constants.VIDEO_OPTION_ALL -> {
startPlayLogic(gsyBaseVideoPlayer)
}
VideoSettingFragment.VIDEO_OPTION_WIFI -> {
Constants.VIDEO_OPTION_WIFI -> {
if (NetworkUtils.isWifiConnected(HaloApp.getInstance().application)) {
startPlayLogic(gsyBaseVideoPlayer)
}

View File

@ -46,6 +46,7 @@ import com.gh.gamecenter.adapter.viewholder.NewsDetailCommentListViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsDetailGameViewHolder;
import com.gh.gamecenter.adapter.viewholder.UnAvaliableWebviewViewHolder;
import com.gh.gamecenter.common.callback.OnRequestCallBackListener;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.utils.ExtensionsKt;
@ -74,7 +75,6 @@ import com.gh.gamecenter.entity.NewsDetailEntity;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.qa.editor.OnLinkClickListener;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.gamecenter.setting.view.SettingsFragment;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.utils.Utils;
@ -259,7 +259,7 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
mWebSettings = viewHolder.binding.newsdetailItemWvContent.getSettings();
mWebSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
mWebSettings.setTextZoom(defaultTextZoom + sp.getInt(SettingsFragment.FONT_SIZE_SP_KEY, 1) * 15);
mWebSettings.setTextZoom(defaultTextZoom + sp.getInt(Constants.SP_FONT_SIZE, 1) * 15);
ExtensionsKt.enableForceDark(viewHolder.binding.newsdetailItemWvContent, DarkModeUtils.INSTANCE.isDarkModeOn(mContext));
ExtensionsKt.setTransparentBackground(viewHolder.binding.newsdetailItemWvContent);
viewHolder.binding.newsdetailItemWvContent.setHtml(mNewsDetailEntity.getContent(), true);

View File

@ -4,7 +4,9 @@ import android.content.Context
import android.os.Build
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.util.*
import com.gh.common.util.CheckLoginUtils
import com.gh.common.util.DataCollectionUtils
import com.gh.common.util.DirectUtils
import com.gh.common.util.NewFlatLogUtils
import com.gh.gamecenter.*
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
@ -16,7 +18,7 @@ import com.gh.gamecenter.entity.AddonLinkEntity
import com.gh.gamecenter.game.upload.GameSubmissionActivity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.message.MessageUnreadRepository
import com.gh.gamecenter.setting.view.security.SecurityActivity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.gamecenter.simulatorgame.SimulatorGameActivity
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
import com.gh.gamecenter.toolbox.ToolBoxBlockActivity
@ -93,7 +95,7 @@ class HaloPersonalBannerAdapter(context: Context) : BaseRecyclerAdapter<Recycler
}
"账号安全" -> {
if (UserManager.getInstance().isLoggedIn) {
mContext.startActivity(SecurityActivity.getIntent(mContext, "我的光环-账号安全"))
mContext.startActivity(SettingBridge.getSecurityIntent(mContext, "我的光环-账号安全"))
} else {
CheckLoginUtils.checkLogin(mContext, "我的光环-账号安全") {}
}

View File

@ -51,7 +51,7 @@ import com.gh.gamecenter.mygame.MyGameActivity
import com.gh.gamecenter.mypost.MyPostActivity
import com.gh.gamecenter.personalhome.UserHomeViewModel
import com.gh.gamecenter.room.AppDatabase
import com.gh.gamecenter.setting.view.SettingActivity
import com.gh.gamecenter.setting.SettingBridge
import com.google.android.material.appbar.AppBarLayout
import com.halo.assistant.HaloApp
import com.jakewharton.rxbinding2.view.RxView
@ -591,7 +591,7 @@ class HaloPersonalFragment : BaseLazyFragment() {
iconIv.setImageResource(R.drawable.ic_personal_setting)
root.setOnClickListener {
NewFlatLogUtils.logHaloSelfClick("其他功能", "设置")
startActivity(SettingActivity.getIntent(requireContext(), false, "我的光环"))
startActivity(SettingBridge.getSettingIntent(requireContext(), false, "我的光环"))
}
}
mStubBinding.feedbackItem.run {

View File

@ -20,7 +20,7 @@ import com.gh.gamecenter.game.upload.GameSubmissionActivity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.message.MessageUnreadRepository
import com.gh.gamecenter.savegame.GameArchiveListActivity
import com.gh.gamecenter.setting.view.security.SecurityActivity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.gamecenter.simulatorgame.SimulatorGameActivity
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
import com.gh.gamecenter.toolbox.ToolBoxBlockActivity
@ -101,7 +101,7 @@ class HaloPersonalFunctionAdapter(context: Context) : BaseRecyclerAdapter<Recycl
}
"账号安全" -> {
if (UserManager.getInstance().isLoggedIn) {
mContext.startActivity(SecurityActivity.getIntent(mContext, "我的光环-账号安全"))
mContext.startActivity(SettingBridge.getSecurityIntent(mContext, "我的光环-账号安全"))
} else {
CheckLoginUtils.checkLogin(mContext, "我的光环-账号安全") {}
}

View File

@ -21,7 +21,7 @@ import com.gh.gamecenter.game.upload.GameSubmissionActivity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.message.MessageUnreadRepository
import com.gh.gamecenter.savegame.GameArchiveListActivity
import com.gh.gamecenter.setting.view.security.SecurityActivity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.gamecenter.simulatorgame.SimulatorGameActivity
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
import com.gh.gamecenter.toolbox.ToolBoxBlockActivity
@ -119,7 +119,7 @@ class HaloPersonalRecommendAdapter(val context: Context) : BaseRecyclerAdapter<R
}
"账号安全" -> {
if (UserManager.getInstance().isLoggedIn) {
mContext.startActivity(SecurityActivity.getIntent(mContext, "我的光环-账号安全"))
mContext.startActivity(SettingBridge.getSecurityIntent(mContext, "我的光环-账号安全"))
} else {
CheckLoginUtils.checkLogin(mContext, "我的光环-账号安全") {}
}

View File

@ -0,0 +1,43 @@
package com.gh.gamecenter.setting
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.ISettingProvider
/**
* 与设置模块桥接的桥
*/
object SettingBridge {
private val mSettingProvider by lazy {
ARouter.getInstance().build(RouteConsts.provider.setting).navigation() as? ISettingProvider
}
fun getSettingIntent(context: Context, isUpdate: Boolean, entrance: String): Intent {
return mSettingProvider?.getSettingIntent(context, isUpdate, entrance) ?: Intent(
context,
MainActivity::class.java
)
}
fun getSecurityIntent(context: Context, entrance: String, isLogoutStyle: Boolean = false): Intent {
return mSettingProvider?.getSecurityIntent(context, entrance, isLogoutStyle) ?: Intent(
context,
MainActivity::class.java
)
}
fun getAboutIntent(context: Context?, isUpdate: Boolean): Intent {
return mSettingProvider?.getAboutIntent(context, isUpdate) ?: Intent(context, MainActivity::class.java)
}
fun getBindPhoneNormalIntent(context: Context, isChangePhone: Boolean): Intent {
return mSettingProvider?.getBindPhoneNormalIntent(context, isChangePhone) ?: Intent(
context,
MainActivity::class.java
)
}
}

View File

@ -43,7 +43,6 @@ import com.gh.gamecenter.eventbus.EBRecommed
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.qa.comment.CommentActivity
import com.gh.gamecenter.qa.dialog.MoreFunctionPanelDialog
import com.gh.gamecenter.setting.view.SettingsFragment
import com.gh.gamecenter.video.game.GameVideoActivity
import com.halo.assistant.HaloApp
import com.jakewharton.rxbinding2.view.RxView
@ -562,7 +561,7 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
override fun showWifiDialog() {
val trafficVideo = PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(SettingsFragment.TRAFFIC_VIDEO_SP_KEY, false)
.getBoolean(Constants.SP_TRAFFIC_VIDEO, false)
val nonWifiTips = SPUtils.getBoolean(Constants.SP_NON_WIFI_TIPS, true)
if (!trafficVideo) {
if (nonWifiTips) {

View File

@ -44,8 +44,7 @@
android:textSize="@dimen/primary_text_size"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/setting_security" />
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/redDot"
@ -70,7 +69,6 @@
android:textColor="@color/text_subtitleDesc"
android:textSize="@dimen/secondary_size"
android:visibility="gone"
tools:text="@string/setting_personal_recommend_hint"
tools:visibility="gone" />
</LinearLayout>

View File

@ -33,8 +33,7 @@
android:textSize="@dimen/primary_text_size"
android:includeFontPadding="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/setting_security" />
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/redDot"
@ -58,8 +57,7 @@
android:lineHeight="16dp"
android:textColor="@color/text_subtitleDesc"
android:textSize="@dimen/secondary_size"
android:visibility="gone"
tools:text="@string/setting_personal_recommend_hint" />
android:visibility="gone" />
</LinearLayout>

View File

@ -71,6 +71,7 @@
<string name="setting_sdk_list">接入第三方SDK目录</string>
<string name="setting_permission_and_usage">权限申请与使用情况说明</string>
<string name="setting_children_policy">儿童隐私保护声明</string>
<string name="setting_cache_size_def">0.0M</string>
<string name="sharecard_qrcode_hint">长按二维码查看详情</string>
<string name="sharecard_from">分享自『光环助手』App</string>
<string name="suggest_content_hint">请详细描述你遇到的问题\\n↓↓你还可以上传截图</string>

View File

@ -444,4 +444,15 @@ public class Constants {
public static final String SP_ADDONS_RECOMMEND_HAVE_READ = "addons_recommend_have_read";
//启动广告
public static final String SP_STARTUP_AD_TIMESTAMP = "startup_ad_timestamp";
public static final String SP_AUTO_INSTALL = "autoinstall";
public static final String SP_CONCERN_GAME = "concerngame";
public static final String SP_TRAFFIC_VIDEO = "tranfficvideo";
public static final String SP_FONT_SIZE = "fontsize";
public static final String SP_PERSONAL_RECOMMEND = "personalrecommend";
public static final String SP_USAGE_STATUS = "usage_status_sp_key";
public static final String VIDEO_OPTION_ALL = "video_option_all";
public static final String VIDEO_OPTION_WIFI = "video_option_wifi";
public static final String VIDEO_OPTION_CLOSE = "video_option_close";
}

View File

@ -59,6 +59,8 @@ object RouteConsts {
const val quickLogin = "/login/quickLogin"
const val energyTask = "/energy/energyTask"
const val setting = "/settings/setting"
}
}

View File

@ -16,6 +16,7 @@ import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.databinding.DialogAlertDefaultBinding
import com.gh.gamecenter.common.databinding.DialogGuideBinding
import com.gh.gamecenter.common.databinding.DialogProgressBinding
import com.gh.gamecenter.core.provider.ISettingProvider
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.core.utils.MtaHelper
import com.lightgame.utils.AppManager
@ -334,7 +335,9 @@ object DialogHelper {
"检查升级",
"取消",
confirmClickCallback = {
ARouter.getInstance().build(RouteConsts.activity.aboutActivity).navigation()
val settingProvider =
ARouter.getInstance().build(RouteConsts.provider.setting).navigation() as? ISettingProvider
context.startActivity(settingProvider?.getAboutIntent(context, true))
},
uiModificationCallback = {
it.titleTv.gravity = Gravity.CENTER

View File

@ -0,0 +1,17 @@
package com.gh.gamecenter.core.provider
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.facade.template.IProvider
interface ISettingProvider : IProvider {
fun getSettingIntent(context: Context, isUpdate: Boolean, entrance: String): Intent?
fun getSecurityIntent(context: Context, entrance: String, isLogoutStyle: Boolean): Intent?
fun getBindPhoneNormalIntent(context: Context, isChangePhone: Boolean): Intent?
fun getAboutIntent(context: Context?, isUpdate: Boolean): Intent?
}

View File

@ -0,0 +1,36 @@
package com.gh.gamecenter.setting.provider
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.ISettingProvider
import com.gh.gamecenter.setting.view.AboutActivity
import com.gh.gamecenter.setting.view.SettingActivity
import com.gh.gamecenter.setting.view.security.BindPhoneActivity
import com.gh.gamecenter.setting.view.security.SecurityActivity
@Route(path = RouteConsts.provider.setting, name = "Setting暴露服务")
class SettingProviderImpl : ISettingProvider {
override fun getSettingIntent(context: Context, isUpdate: Boolean, entrance: String): Intent {
return SettingActivity.getIntent(context, isUpdate, entrance)
}
override fun getSecurityIntent(context: Context, entrance: String, isLogoutStyle: Boolean): Intent {
return SecurityActivity.getIntent(context, entrance, isLogoutStyle)
}
override fun getBindPhoneNormalIntent(context: Context, isChangePhone: Boolean): Intent {
return BindPhoneActivity.getNormalIntent(context, isChangePhone)
}
override fun getAboutIntent(context: Context?, isUpdate: Boolean): Intent {
return AboutActivity.getIntent(context, isUpdate)
}
override fun init(context: Context?) {
// do nothing
}
}

View File

@ -10,6 +10,7 @@ import android.view.View
import androidx.core.content.FileProvider
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.utils.setSwitchAnimation
import com.gh.gamecenter.common.utils.toColor
@ -42,12 +43,12 @@ class GameDownloadSettingFragment : ToolbarFragment() {
switchLottie.visibility = View.VISIBLE
root.setOnClickListener {
if (switchLottie.isAnimating) return@setOnClickListener
val status = SPUtils.getBoolean(AUTO_INSTALL_SP_KEY, true)
val status = SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true)
MtaHelper.onEvent("我的光环_设置", "设置功能", "下载完成自动安装游戏")
MtaHelper.onEvent("我的光环_设置", "自动安装游戏", if (status) "关闭" else "打开")
switchLottie.setSwitchAnimation(status)
switchLottie.playAnimation()
SPUtils.setBoolean(AUTO_INSTALL_SP_KEY, !status)
SPUtils.setBoolean(Constants.SP_AUTO_INSTALL, !status)
}
}
mBinding?.concernGameItem?.run {
@ -55,12 +56,12 @@ class GameDownloadSettingFragment : ToolbarFragment() {
switchLottie.visibility = View.VISIBLE
root.setOnClickListener {
if (switchLottie.isAnimating) return@setOnClickListener
val status = SPUtils.getBoolean(CONCERN_GAME_SP_KEY, true)
val status = SPUtils.getBoolean(Constants.SP_CONCERN_GAME, true)
MtaHelper.onEvent("我的光环_设置", "设置功能", "安装完成自动关注游戏")
MtaHelper.onEvent("我的光环_设置", "自动关注游戏", if (status) "关闭" else "打开")
switchLottie.setSwitchAnimation(status)
switchLottie.playAnimation()
SPUtils.setBoolean(CONCERN_GAME_SP_KEY, !status)
SPUtils.setBoolean(Constants.SP_CONCERN_GAME, !status)
}
}
mBinding?.trafficItem?.run {
@ -104,8 +105,8 @@ class GameDownloadSettingFragment : ToolbarFragment() {
}
}
mBinding?.run {
autoInstallItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(AUTO_INSTALL_SP_KEY, true))
concernGameItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(CONCERN_GAME_SP_KEY, true))
autoInstallItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true))
concernGameItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(Constants.SP_CONCERN_GAME, true))
trafficItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(getTrafficDownloadHintKey(), false))
}
}
@ -134,17 +135,13 @@ class GameDownloadSettingFragment : ToolbarFragment() {
super.onDarkModeChanged()
mBinding?.run {
root.setBackgroundColor(R.color.background.toColor(requireContext()))
autoInstallItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(AUTO_INSTALL_SP_KEY, true))
concernGameItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(CONCERN_GAME_SP_KEY, true))
autoInstallItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true))
concernGameItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(Constants.SP_CONCERN_GAME, true))
trafficItem.switchLottie.setSwitchAnimation(SPUtils.getBoolean(getTrafficDownloadHintKey(), false))
}
}
companion object {
const val AUTO_INSTALL_SP_KEY = "autoinstall"
const val CONCERN_GAME_SP_KEY = "concerngame"
const val TRAFFIC_VIDEO_SP_KEY = "tranfficvideo"
@JvmStatic
fun getTrafficDownloadHintKey(): String {
val packageUtils =

View File

@ -128,12 +128,12 @@ class SettingsFragment : ToolbarFragment() {
mBinding.personalRecommendItem.switchLottie.setSwitchAnimation(
SPUtils.getBoolean(
PERSONAL_RECOMMEND_SP_KEY,
Constants.SP_PERSONAL_RECOMMEND,
true
)
)
checkSizeIndex = SPUtils.getInt(FONT_SIZE_SP_KEY, 1)
checkSizeIndex = SPUtils.getInt(Constants.SP_FONT_SIZE, 1)
if (checkSizeIndex == 0) {
checkSizeIndex = 1
}
@ -183,7 +183,7 @@ class SettingsFragment : ToolbarFragment() {
}
val usageStatsHelper = ARouter.getInstance().build(RouteConsts.provider.usageStatsHelper)
.navigation() as? IUsageStatsHelperProvider
if (usageStatsHelper?.checkForPermission() == true && SPUtils.getBoolean(USAGE_STATUS_SP_KEY, true)) {
if (usageStatsHelper?.checkForPermission() == true && SPUtils.getBoolean(Constants.SP_USAGE_STATUS, true)) {
mUsageStatus = true
val energyTaskHelper =
ARouter.getInstance().build(RouteConsts.provider.energyTask).navigation() as? IEnergyTaskProvider
@ -345,10 +345,10 @@ class SettingsFragment : ToolbarFragment() {
switchLottie.visibility = View.VISIBLE
root.setOnClickListener {
if (switchLottie.isAnimating) return@setOnClickListener
val status = SPUtils.getBoolean(PERSONAL_RECOMMEND_SP_KEY, true)
val status = SPUtils.getBoolean(Constants.SP_PERSONAL_RECOMMEND, true)
switchLottie.setSwitchAnimation(status)
switchLottie.playAnimation()
SPUtils.setBoolean(PERSONAL_RECOMMEND_SP_KEY, !status)
SPUtils.setBoolean(Constants.SP_PERSONAL_RECOMMEND, !status)
}
}
mBinding.aboutItem.run {
@ -511,7 +511,7 @@ class SettingsFragment : ToolbarFragment() {
ARouter.getInstance().build(RouteConsts.provider.energyTask).navigation() as? IEnergyTaskProvider
energyTaskHelper?.postEnergyTask("open_game_time")
}
SPUtils.setBoolean(USAGE_STATUS_SP_KEY, usageStatsHelper?.checkForPermission() == true)
SPUtils.setBoolean(Constants.SP_USAGE_STATUS, usageStatsHelper?.checkForPermission() == true)
initUsageStats()
}
@ -526,7 +526,7 @@ class SettingsFragment : ToolbarFragment() {
saveCurrentSetting()
}
private fun saveCurrentSetting() = SPUtils.setInt(FONT_SIZE_SP_KEY, checkSizeIndex)
private fun saveCurrentSetting() = SPUtils.setInt(Constants.SP_FONT_SIZE, checkSizeIndex)
override fun onResume() {
super.onResume()
@ -609,7 +609,7 @@ class SettingsFragment : ToolbarFragment() {
mBinding.root.setBackgroundColor(R.color.background.toColor(requireContext()))
mBinding.personalRecommendItem.switchLottie.setSwitchAnimation(
SPUtils.getBoolean(
PERSONAL_RECOMMEND_SP_KEY,
Constants.SP_PERSONAL_RECOMMEND,
true
)
)
@ -618,12 +618,6 @@ class SettingsFragment : ToolbarFragment() {
}
companion object {
const val AUTO_INSTALL_SP_KEY = "autoinstall"
const val CONCERN_GAME_SP_KEY = "concerngame"
const val TRAFFIC_VIDEO_SP_KEY = "tranfficvideo"
const val FONT_SIZE_SP_KEY = "fontsize"
const val PERSONAL_RECOMMEND_SP_KEY = "personalrecommend"
const val USAGE_STATUS_SP_KEY = "usage_status_sp_key"
const val INSERT_MOBILE_CODE = 411
const val USAGE_STATUS_REQUEST_CODE = 233
}

View File

@ -34,9 +34,9 @@ class VideoSettingFragment : ToolbarFragment() {
titleTv.text = getString(R.string.all_network_auto_play)
selectedIv.visibility = View.VISIBLE
root.setOnClickListener {
if (!isCurrentContentStatus(VIDEO_OPTION_ALL)) {
setContentVideoOption(VIDEO_OPTION_ALL)
SPUtils.setString(SP_CONTENT_VIDEO_OPTION, VIDEO_OPTION_ALL)
if (!isCurrentContentStatus(Constants.VIDEO_OPTION_ALL)) {
setContentVideoOption(Constants.VIDEO_OPTION_ALL)
SPUtils.setString(SP_CONTENT_VIDEO_OPTION, Constants.VIDEO_OPTION_ALL)
}
}
}
@ -44,9 +44,9 @@ class VideoSettingFragment : ToolbarFragment() {
titleTv.text = getString(R.string.only_wifi_auto_play)
selectedIv.visibility = View.VISIBLE
root.setOnClickListener {
if (!isCurrentContentStatus(VIDEO_OPTION_WIFI)) {
setContentVideoOption(VIDEO_OPTION_WIFI)
SPUtils.setString(SP_CONTENT_VIDEO_OPTION, VIDEO_OPTION_WIFI)
if (!isCurrentContentStatus(Constants.VIDEO_OPTION_WIFI)) {
setContentVideoOption(Constants.VIDEO_OPTION_WIFI)
SPUtils.setString(SP_CONTENT_VIDEO_OPTION, Constants.VIDEO_OPTION_WIFI)
}
}
}
@ -54,9 +54,9 @@ class VideoSettingFragment : ToolbarFragment() {
titleTv.text = getString(R.string.close_auto_play)
selectedIv.visibility = View.VISIBLE
root.setOnClickListener {
if (!isCurrentContentStatus(VIDEO_OPTION_CLOSE)) {
setContentVideoOption(VIDEO_OPTION_CLOSE)
SPUtils.setString(SP_CONTENT_VIDEO_OPTION, VIDEO_OPTION_CLOSE)
if (!isCurrentContentStatus(Constants.VIDEO_OPTION_CLOSE)) {
setContentVideoOption(Constants.VIDEO_OPTION_CLOSE)
SPUtils.setString(SP_CONTENT_VIDEO_OPTION, Constants.VIDEO_OPTION_CLOSE)
}
}
}
@ -64,9 +64,9 @@ class VideoSettingFragment : ToolbarFragment() {
titleTv.text = getString(R.string.all_network_auto_play)
selectedIv.visibility = View.VISIBLE
root.setOnClickListener {
if (!isCurrentHomeOrDetailStatus(VIDEO_OPTION_ALL)) {
setHomeOrDetailVideoOption(VIDEO_OPTION_ALL)
SPUtils.setString(SP_HOME_OR_DETAIL_VIDEO_OPTION, VIDEO_OPTION_ALL)
if (!isCurrentHomeOrDetailStatus(Constants.VIDEO_OPTION_ALL)) {
setHomeOrDetailVideoOption(Constants.VIDEO_OPTION_ALL)
SPUtils.setString(SP_HOME_OR_DETAIL_VIDEO_OPTION, Constants.VIDEO_OPTION_ALL)
}
}
}
@ -74,9 +74,9 @@ class VideoSettingFragment : ToolbarFragment() {
titleTv.text = getString(R.string.only_wifi_auto_play)
selectedIv.visibility = View.VISIBLE
root.setOnClickListener {
if (!isCurrentHomeOrDetailStatus(VIDEO_OPTION_WIFI)) {
setHomeOrDetailVideoOption(VIDEO_OPTION_WIFI)
SPUtils.setString(SP_HOME_OR_DETAIL_VIDEO_OPTION, VIDEO_OPTION_WIFI)
if (!isCurrentHomeOrDetailStatus(Constants.VIDEO_OPTION_WIFI)) {
setHomeOrDetailVideoOption(Constants.VIDEO_OPTION_WIFI)
SPUtils.setString(SP_HOME_OR_DETAIL_VIDEO_OPTION, Constants.VIDEO_OPTION_WIFI)
}
}
}
@ -84,9 +84,9 @@ class VideoSettingFragment : ToolbarFragment() {
titleTv.text = getString(R.string.close_auto_play)
selectedIv.visibility = View.VISIBLE
root.setOnClickListener {
if (!isCurrentHomeOrDetailStatus(VIDEO_OPTION_CLOSE)) {
setHomeOrDetailVideoOption(VIDEO_OPTION_CLOSE)
SPUtils.setString(SP_HOME_OR_DETAIL_VIDEO_OPTION, VIDEO_OPTION_CLOSE)
if (!isCurrentHomeOrDetailStatus(Constants.VIDEO_OPTION_CLOSE)) {
setHomeOrDetailVideoOption(Constants.VIDEO_OPTION_CLOSE)
SPUtils.setString(SP_HOME_OR_DETAIL_VIDEO_OPTION, Constants.VIDEO_OPTION_CLOSE)
}
}
}
@ -106,9 +106,11 @@ class VideoSettingFragment : ToolbarFragment() {
}
private fun initStatus() {
mContentVideoOptionSelected = SPUtils.getString(SP_CONTENT_VIDEO_OPTION, VIDEO_OPTION_WIFI) ?: VIDEO_OPTION_WIFI
mContentVideoOptionSelected =
SPUtils.getString(SP_CONTENT_VIDEO_OPTION, Constants.VIDEO_OPTION_WIFI) ?: Constants.VIDEO_OPTION_WIFI
mHomeOrDetailVideoOptionSelected =
SPUtils.getString(SP_HOME_OR_DETAIL_VIDEO_OPTION, VIDEO_OPTION_WIFI) ?: VIDEO_OPTION_WIFI
SPUtils.getString(SP_HOME_OR_DETAIL_VIDEO_OPTION, Constants.VIDEO_OPTION_WIFI)
?: Constants.VIDEO_OPTION_WIFI
setContentVideoOption(mContentVideoOptionSelected)
setHomeOrDetailVideoOption(mHomeOrDetailVideoOptionSelected)
mBinding?.muteItem?.switchLottie?.setSwitchAnimation(SPUtils.getBoolean(SP_VIDEO_PLAY_MUTE, true))
@ -117,19 +119,19 @@ class VideoSettingFragment : ToolbarFragment() {
private fun setContentVideoOption(status: String) {
mBinding?.run {
when (status) {
VIDEO_OPTION_ALL -> {
Constants.VIDEO_OPTION_ALL -> {
contentVideoOptionAllItem.selectedIv.setImageResource(R.drawable.ic_selector_selected)
contentVideoOptionWifiItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
contentVideoOptionCloseItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
}
VIDEO_OPTION_WIFI -> {
Constants.VIDEO_OPTION_WIFI -> {
contentVideoOptionAllItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
contentVideoOptionWifiItem.selectedIv.setImageResource(R.drawable.ic_selector_selected)
contentVideoOptionCloseItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
}
VIDEO_OPTION_CLOSE -> {
Constants.VIDEO_OPTION_CLOSE -> {
contentVideoOptionAllItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
contentVideoOptionWifiItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
contentVideoOptionCloseItem.selectedIv.setImageResource(R.drawable.ic_selector_selected)
@ -141,19 +143,19 @@ class VideoSettingFragment : ToolbarFragment() {
private fun setHomeOrDetailVideoOption(status: String) {
mBinding?.run {
when (status) {
VIDEO_OPTION_ALL -> {
Constants.VIDEO_OPTION_ALL -> {
homeOrDetailVideoOptionAllItem.selectedIv.setImageResource(R.drawable.ic_selector_selected)
homeOrDetailVideoOptionWifiItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
homeOrDetailVideoOptionCloseItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
}
VIDEO_OPTION_WIFI -> {
Constants.VIDEO_OPTION_WIFI -> {
homeOrDetailVideoOptionAllItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
homeOrDetailVideoOptionWifiItem.selectedIv.setImageResource(R.drawable.ic_selector_selected)
homeOrDetailVideoOptionCloseItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
}
VIDEO_OPTION_CLOSE -> {
Constants.VIDEO_OPTION_CLOSE -> {
homeOrDetailVideoOptionAllItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
homeOrDetailVideoOptionWifiItem.selectedIv.setImageResource(R.drawable.ic_selector_default)
homeOrDetailVideoOptionCloseItem.selectedIv.setImageResource(R.drawable.ic_selector_selected)
@ -163,11 +165,17 @@ class VideoSettingFragment : ToolbarFragment() {
}
private fun isCurrentContentStatus(status: String): Boolean {
return status == SPUtils.getString(SP_CONTENT_VIDEO_OPTION, VIDEO_OPTION_WIFI) ?: VIDEO_OPTION_WIFI
return status == SPUtils.getString(
SP_CONTENT_VIDEO_OPTION,
Constants.VIDEO_OPTION_WIFI
) ?: Constants.VIDEO_OPTION_WIFI
}
private fun isCurrentHomeOrDetailStatus(status: String): Boolean {
return status == SPUtils.getString(SP_HOME_OR_DETAIL_VIDEO_OPTION, VIDEO_OPTION_WIFI) ?: VIDEO_OPTION_WIFI
return status == SPUtils.getString(
SP_HOME_OR_DETAIL_VIDEO_OPTION,
Constants.VIDEO_OPTION_WIFI
) ?: Constants.VIDEO_OPTION_WIFI
}
override fun onDarkModeChanged() {
@ -182,8 +190,5 @@ class VideoSettingFragment : ToolbarFragment() {
const val SP_CONTENT_VIDEO_OPTION = Constants.SP_CONTENT_VIDEO_OPTION
const val SP_HOME_OR_DETAIL_VIDEO_OPTION = Constants.SP_HOME_OR_DETAIL_VIDEO_OPTION
const val SP_VIDEO_PLAY_MUTE = Constants.SP_VIDEO_PLAY_MUTE
const val VIDEO_OPTION_ALL = "video_option_all"
const val VIDEO_OPTION_WIFI = "video_option_wifi"
const val VIDEO_OPTION_CLOSE = "video_option_close"
}
}