refactor(app): 移除用户验证和社区模板功能
- 删除了用户验证相关代码,包括 StartViewModel 中的 verifyingUserInfo 函数- 移除了社区模板加载功能,包括 InstalledTemplateViewModel 中的 loadTemplate 函数 - 删除了与用户验证和社区模板相关的多个 Activity 和 Fragment 中的代码 -重置了版本号为 1.0
This commit is contained in:
parent
c4e7b3bcbd
commit
7c47b5c63f
|
@ -1,7 +1,6 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
// id "androidx.navigation.safeargs.kotlin"
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
|
@ -21,14 +20,13 @@ android {
|
|||
}
|
||||
}
|
||||
compileSdk 33
|
||||
// buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.coldmint.rust.lite"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 33
|
||||
versionCode 28
|
||||
versionName "1.0 Lite"
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
|
|
@ -227,10 +227,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
recreate()
|
||||
return
|
||||
}
|
||||
val error = startViewModel.signatureErrorLiveData.value ?: true
|
||||
if (!error) {
|
||||
startViewModel.verifyingUserInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
|||
* 模板社区
|
||||
*/
|
||||
class TemplateCommunityFragment : BaseFragment<FragmentTemplateCommunityBinding>() {
|
||||
val token = AppSettings.getValue(AppSettings.Setting.Token, "")
|
||||
val token = ""
|
||||
|
||||
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
|
||||
val divider = MaterialDividerItemDecoration(
|
||||
|
|
|
@ -64,10 +64,6 @@ class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
|
|||
R.string.fans_management -> {
|
||||
openUserList(account, false)
|
||||
}
|
||||
R.string.review_mod -> {
|
||||
val reviewIntent = Intent(requireContext(), ReviewModActivity::class.java)
|
||||
startActivity(reviewIntent)
|
||||
}
|
||||
R.string.report_to_deal -> {
|
||||
val startIntent = Intent(requireContext(), ReportListActivity::class.java)
|
||||
startActivity(startIntent)
|
||||
|
@ -116,50 +112,8 @@ class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
|
|||
// viewBinding.root.isFillViewport = false
|
||||
account = AppSettings.getValue(AppSettings.Setting.Account, "")
|
||||
viewBinding.myHomeView.setOnClickListener {
|
||||
val intent = Intent(
|
||||
requireActivity(),
|
||||
UserHomePageActivity::class.java
|
||||
)
|
||||
intent.putExtra("userId", account)
|
||||
startActivity(
|
||||
intent
|
||||
)
|
||||
|
||||
}
|
||||
val token = AppSettings.getValue(AppSettings.Setting.Token, "")
|
||||
User.getUserActivationInfo(token, object : ApiCallBack<ActivationInfo> {
|
||||
|
||||
override fun onFailure(e: Exception) {
|
||||
viewBinding.nameView.text = account
|
||||
loadRecyclerView(3)
|
||||
// val localTime =
|
||||
// AppSettings.getValue(AppSettings.Setting.ExpirationTime, 0.toLong())
|
||||
// viewBinding.expirationTimeView.text =
|
||||
// ServerConfiguration.toStringTime(localTime)
|
||||
}
|
||||
|
||||
override fun onResponse(t: ActivationInfo) {
|
||||
if (t.code == ServerConfiguration.Success_Code) {
|
||||
viewBinding.nameView.text = t.data.userName
|
||||
val icon = t.data.headIcon
|
||||
if (icon != null) {
|
||||
Glide.with(requireContext()).load(ServerConfiguration.getRealLink(icon))
|
||||
.apply(GlobalMethod.getRequestOptions(true))
|
||||
.into(viewBinding.headIconView)
|
||||
}
|
||||
viewBinding.coinView.text = String.format(
|
||||
getString(
|
||||
R.string.coin_number
|
||||
), t.data.coinNumber
|
||||
)
|
||||
loadRecyclerView(t.data.permission)
|
||||
} else {
|
||||
// Toast.makeText(requireContext(), t.toString(), Toast.LENGTH_SHORT).show()
|
||||
viewBinding.nameView.text = account
|
||||
loadRecyclerView(3)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
} else {
|
||||
viewBinding.progressBar.isVisible = false
|
||||
viewBinding.loginLayout.root.isVisible = true
|
||||
|
|
|
@ -113,155 +113,13 @@ class WebModDetailsFragment(val modId: String, val modNameLiveData: MutableLiveD
|
|||
* @param userId String
|
||||
*/
|
||||
fun gotoUserPage(userId: String) {
|
||||
val intent = Intent(
|
||||
requireContext(),
|
||||
UserHomePageActivity::class.java
|
||||
)
|
||||
intent.putExtra("userId", userId)
|
||||
startActivity(
|
||||
intent
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载页面信息
|
||||
*/
|
||||
private fun loadInfo() {
|
||||
val token = AppSettings.getValue(AppSettings.Setting.Token, "")
|
||||
WebMod.instance.getInfo(token, modId, object : ApiCallBack<WebModInfoData> {
|
||||
override fun onResponse(t: WebModInfoData) {
|
||||
if (!isAdded) {
|
||||
return
|
||||
}
|
||||
if (t.code == ServerConfiguration.Success_Code) {
|
||||
viewModel.developer = t.data.developer
|
||||
modNameLiveData.value = t.data.name
|
||||
viewModel.isOpen = t.data.hidden == 0
|
||||
viewModel.link = t.data.link
|
||||
viewBinding.loadLayout.isVisible = false
|
||||
viewBinding.contentLayout.isVisible = true
|
||||
val icon = t.data.icon
|
||||
if (!icon.isNullOrBlank()) {
|
||||
Glide.with(requireContext())
|
||||
.load(ServerConfiguration.getRealLink(icon))
|
||||
.apply(GlobalMethod.getRequestOptions())
|
||||
.into(viewBinding.iconView)
|
||||
}
|
||||
val screenshotListData = t.data.screenshots
|
||||
if (!screenshotListData.isNullOrBlank()) {
|
||||
val list = ArrayList<String>()
|
||||
val lineParser = LineParser()
|
||||
lineParser.symbol = ","
|
||||
lineParser.text = screenshotListData
|
||||
lineParser.analyse { _, lineData, _ ->
|
||||
list.add(lineData)
|
||||
true
|
||||
}
|
||||
val adapter = object : BannerImageAdapter<String>(list) {
|
||||
override fun onBindView(
|
||||
holder: BannerImageHolder?,
|
||||
data: String?,
|
||||
position: Int,
|
||||
size: Int
|
||||
) {
|
||||
if (data != null && holder != null) {
|
||||
Glide.with(requireContext())
|
||||
.load(ServerConfiguration.getRealLink(data))
|
||||
.apply(GlobalMethod.getRequestOptions())
|
||||
.into(holder.imageView)
|
||||
holder.imageView.setOnClickListener {v ->
|
||||
val bitmap = (v as ImageView).
|
||||
drawable?.let { (it as BitmapDrawable).bitmap }
|
||||
com.imageactivity.Image.start(requireActivity(), v, bitmap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// com.imageactivity.Image
|
||||
|
||||
viewBinding.banner.setAdapter(adapter)
|
||||
viewBinding.banner.addBannerLifecycleObserver(requireActivity())
|
||||
viewBinding.banner.indicator = CircleIndicator(requireActivity())
|
||||
viewBinding.banner.setIndicatorSelectedColorRes(R.color.blue_500)
|
||||
viewBinding.banner.isAutoLoop(false)
|
||||
} else {
|
||||
viewBinding.banner.isVisible = false
|
||||
}
|
||||
val tags = t.data.tags
|
||||
val lineParser = LineParser(tags)
|
||||
val tagList = ArrayList<String>()
|
||||
lineParser.symbol = ","
|
||||
lineParser.analyse { _, lineData, _ ->
|
||||
val tag = lineData.subSequence(1, lineData.length - 1).toString()
|
||||
tagList.add(tag)
|
||||
true
|
||||
}
|
||||
if (tagList.size > 0) {
|
||||
tagList.forEach {
|
||||
val chip = Chip(requireContext())
|
||||
chip.text = it
|
||||
val s = it
|
||||
chip.setOnClickListener {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("tag", s)
|
||||
bundle.putString(
|
||||
"title",
|
||||
String.format(getString(R.string.tag_title), s)
|
||||
)
|
||||
bundle.putString("action", "tag")
|
||||
val thisIntent =
|
||||
Intent(requireContext(), TagActivity::class.java)
|
||||
thisIntent.putExtra("data", bundle)
|
||||
startActivity(thisIntent)
|
||||
}
|
||||
viewBinding.chipGroup.addView(chip)
|
||||
}
|
||||
} else {
|
||||
viewBinding.chipGroup.isVisible = false
|
||||
}
|
||||
viewBinding.titleView.text = t.data.name
|
||||
TextStyleMaker.instance.load(
|
||||
viewBinding.modInfoView,
|
||||
t.data.describe
|
||||
) { type, data ->
|
||||
TextStyleMaker.instance.clickEvent(requireContext(), type, data)
|
||||
}
|
||||
viewBinding.numView.text =
|
||||
String.format(
|
||||
getString(R.string.unit_and_downloadnum),
|
||||
t.data.unitNumber,
|
||||
t.data.downloadNumber,
|
||||
t.data.versionName
|
||||
)
|
||||
viewBinding.updateTimeView.text =
|
||||
String.format(
|
||||
getString(R.string.recent_update),
|
||||
t.data.minVersion,
|
||||
t.data.updateTime
|
||||
)
|
||||
if (t.data.hidden == 0) {
|
||||
viewBinding.hideTextView.isVisible = false
|
||||
}
|
||||
loadDeveloperInfo(t.data.developer)
|
||||
} else {
|
||||
viewBinding.contentLayout.isVisible = false
|
||||
viewBinding.loadLayout.isVisible = true
|
||||
viewBinding.tipView.isVisible = true
|
||||
viewBinding.tipView.text = t.message
|
||||
viewBinding.progressBar.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: Exception) {
|
||||
viewBinding.contentLayout.isVisible = false
|
||||
viewBinding.loadLayout.isVisible = true
|
||||
viewBinding.progressBar.isVisible = false
|
||||
viewBinding.tipView.isVisible = true
|
||||
viewBinding.tipView.setText(R.string.network_error)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
|
@ -255,16 +255,6 @@ class TextStyleMaker private constructor() {
|
|||
intent.putExtra("data", bundle)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
"user" -> {
|
||||
val intent = Intent(
|
||||
context,
|
||||
UserHomePageActivity::class.java
|
||||
)
|
||||
intent.putExtra("userId", data)
|
||||
context.startActivity(
|
||||
intent
|
||||
)
|
||||
}
|
||||
"tag" -> {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("tag", data)
|
||||
|
|
|
@ -83,38 +83,6 @@ class InstalledTemplateViewModel : BaseViewModel() {
|
|||
* @param context Context
|
||||
*/
|
||||
fun loadTemplate(context: Context) {
|
||||
groupList.clear()
|
||||
itemList.clear()
|
||||
val token = AppSettings.getValue(AppSettings.Setting.Token,"")
|
||||
TemplatePhp.instance.getSubscriptionDataList(token,object :ApiCallBack<SubscriptionData>{
|
||||
override fun onResponse(t: SubscriptionData) {
|
||||
if (t.code == ServerConfiguration.Success_Code){
|
||||
LogCat.d("加载网络订阅模板", "正在处理。")
|
||||
t.data.forEach {
|
||||
groupList.add(it)
|
||||
val temList = ArrayList<Template>()
|
||||
itemList.add(temList)
|
||||
it.templateList.forEach {
|
||||
temList.add(it)
|
||||
}
|
||||
}
|
||||
loadLocalTemplate(context)
|
||||
loadCallBack?.invoke()
|
||||
}else{
|
||||
LogCat.w("加载网络订阅模板", t.message)
|
||||
loadLocalTemplate(context)
|
||||
loadCallBack?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: Exception) {
|
||||
e.printStackTrace()
|
||||
LogCat.e("加载网络订阅模板", e.toString())
|
||||
loadLocalTemplate(context)
|
||||
loadCallBack?.invoke()
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,61 +103,10 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio
|
|||
initRes()
|
||||
//初始化书签
|
||||
initBookmark()
|
||||
//验证用户信息
|
||||
verifyingUserInfo()
|
||||
CompletionItemConverter.init(getApplication())
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证用户信息
|
||||
*/
|
||||
fun verifyingUserInfo() {
|
||||
val status = AppSettings.getValue(AppSettings.Setting.LoginStatus, false)
|
||||
if (!status) {
|
||||
needLoginLiveData.value = true
|
||||
return
|
||||
}
|
||||
//验证登录
|
||||
val token = AppSettings.getValue(AppSettings.Setting.Token, "")
|
||||
if (token.isBlank()) {
|
||||
needLoginLiveData.value = true
|
||||
} else {
|
||||
User.getUserActivationInfo(token, object : ApiCallBack<ActivationInfo> {
|
||||
override fun onFailure(e: Exception) {
|
||||
// val localTime = AppSettings.getValue(
|
||||
// AppSettings.Setting.ExpirationTime,
|
||||
// 0.toLong()
|
||||
// )
|
||||
// if (localTime == (-2).toLong()) {
|
||||
// isActivationLiveData.value = true
|
||||
// } else {
|
||||
// val nowTime = System.currentTimeMillis()
|
||||
// //本地时间大于当前时间 激活
|
||||
// isActivationLiveData.value = localTime > nowTime
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
override fun onResponse(activationInfo: ActivationInfo) {
|
||||
if (activationInfo.code == ServerConfiguration.Success_Code) {
|
||||
userLiveData.value = activationInfo
|
||||
//更新本地激活时间
|
||||
val expirationTime = activationInfo.data.expirationTime
|
||||
val time = ServerConfiguration.toLongTime(expirationTime)
|
||||
isActivationLiveData.value = activationInfo.data.activation
|
||||
} else {
|
||||
// 用户登录失败
|
||||
verifyErrorMsgLiveData.value = activationInfo.message
|
||||
LogCat.d("验证失败", activationInfo.message)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化设置
|
||||
*/
|
||||
|
@ -202,17 +151,7 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio
|
|||
AppSettings.initSetting(AppSettings.Setting.ShareTip, true)
|
||||
AppSettings.initSetting(AppSettings.Setting.EnglishEditingMode, false)
|
||||
AppSettings.initSetting(AppSettings.Setting.NightModeFollowSystem, true)
|
||||
AppSettings.initSetting(AppSettings.Setting.UseTheCommunityAsTheLaunchPage, true)
|
||||
AppSettings.initSetting(AppSettings.Setting.SimpleDisplayOfAutoCompleteMenu, true)
|
||||
AppSettings.initSetting(
|
||||
AppSettings.Setting.ServerAddress,
|
||||
ServerConfiguration.defaultIp
|
||||
)
|
||||
ServerConfiguration.website =
|
||||
AppSettings.getValue(
|
||||
AppSettings.Setting.ServerAddress,
|
||||
ServerConfiguration.defaultIp
|
||||
)
|
||||
AppSettings.initSetting(
|
||||
AppSettings.Setting.MapFolder,
|
||||
Environment.getExternalStorageDirectory().absolutePath + "/rustedWarfare/maps/"
|
||||
|
|
Loading…
Reference in New Issue
Block a user