diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index 9434615..e59365f 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.bin and b/.gradle/7.3.3/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.lock b/.gradle/7.3.3/executionHistory/executionHistory.lock index 212c280..ec7aa76 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.lock and b/.gradle/7.3.3/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.bin b/.gradle/7.3.3/fileHashes/fileHashes.bin index 979d461..43b8ad8 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.bin and b/.gradle/7.3.3/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.lock b/.gradle/7.3.3/fileHashes/fileHashes.lock index e6513ea..b57c3af 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.lock and b/.gradle/7.3.3/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin index 4c8770a..7d5e9c7 100644 Binary files a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin and b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 3e5cf1e..e801e84 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 404e2de..6018074 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 98dba26..848b22b 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/app/build.gradle b/app/build.gradle index 9896bdf..472ca82 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,9 +30,9 @@ android { defaultConfig { applicationId "com.coldmint.rust.pro" minSdkVersion 21 - targetSdkVersion 32 - versionCode 23 - versionName "2.1 Bata1_patch6(2022-10-1)" + targetSdkVersion 33 + versionCode 24 + versionName "2.1 Bata2(2023-1-14)" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/coldmint/rust/pro/AboutActivity.kt b/app/src/main/java/com/coldmint/rust/pro/AboutActivity.kt index 2285c9a..4b738dc 100644 --- a/app/src/main/java/com/coldmint/rust/pro/AboutActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/AboutActivity.kt @@ -54,14 +54,13 @@ class AboutActivity : BaseActivity() { |

《铁锈助手》2.0版本,用零零散散的时间开发了1年。开发语言以及开发环境都特别的正式了。

|

环境移到了电脑上使用《Android Studio》开发,开发语言也从java迁移至了Kotlin。

| - |

为了安全使用了加固。

| | """.trimMargin() viewBinding.aboutView.text = Html.fromHtml(aboutText) val time = AppSettings.getValue(com.coldmint.rust.pro.tool.AppSettings.Setting.ExpirationTime, 0.toLong()) if (time == 0.toLong()) { - viewBinding.expirationTimeView.text = getString(R.string.please_login_first) + viewBinding.expirationTimeView.text = getString(R.string.tourist_pattern) } else { val stringTime = ServerConfiguration.toStringTime(time) viewBinding.expirationTimeView.text = diff --git a/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt b/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt index 5978c3c..33206d6 100644 --- a/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt @@ -9,6 +9,7 @@ import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.pro.adapters.GuideAdapter import com.coldmint.rust.pro.base.BaseActivity import com.coldmint.rust.pro.databean.GuideData @@ -27,9 +28,9 @@ class CreationWizardActivity : BaseActivity() { createMod = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { if (it.resultCode == RESULT_OK) { finish() - Log.d("创建单位", "收到了数据,关闭界面。") + LogCat.d("创建单位", "收到了数据,关闭界面。") } else { - Log.d("创建单位", "没有收到数据。") + LogCat.d("创建单位", "没有收到数据。") } } val temType = intent.getStringExtra("type") diff --git a/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt b/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt index c89ac62..b7e6ff9 100644 --- a/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt @@ -116,11 +116,11 @@ class EditModInfoActivity : BaseActivity() { if (description != null) { viewBinding.modDescribeEdit.setText(description) } - val bitmap = mModClass.modIcon - if (bitmap == null) { + val modIcon = mModClass.modIcon + if (modIcon == null) { loadDefaultImage() } else { - Glide.with(this@EditModInfoActivity).load(bitmap) + Glide.with(this@EditModInfoActivity).load(modIcon) .apply(GlobalMethod.getRequestOptions()).into(viewBinding.iconView) mNeedIcon = true } diff --git a/app/src/main/java/com/coldmint/rust/pro/ErrorActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ErrorActivity.kt index 22ee38b..56ad211 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ErrorActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ErrorActivity.kt @@ -14,6 +14,7 @@ import android.view.MenuItem import android.view.View import androidx.core.view.isVisible import com.coldmint.rust.core.dataBean.ApiResponse +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.tool.FileOperator import com.coldmint.rust.core.web.ErrorReport @@ -51,7 +52,7 @@ class ErrorActivity() : BaseActivity() { errorInfo.activityLog = CustomActivityOnCrash.getActivityLogFromIntent(intent) } viewBinding.errorInfo.text = errorInfo.allErrorDetails - Log.e("错误日志", errorInfo.allErrorDetails) + LogCat.e("错误日志", errorInfo.allErrorDetails) if (AppSettings.getValue(AppSettings.Setting.ExperiencePlan, true)) { val info = packageManager.getPackageInfo(packageName, 0) ErrorReport.instance.send( diff --git a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt index 1d8b479..c9b6c12 100644 --- a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt @@ -697,13 +697,15 @@ class FileManagerActivity : BaseActivity() { }.setGestureInsetBottomIgnored(true).show() } else if (viewModel.startTypeData == FileManagerViewModel.StartType.DEFAULT) { val type = FileOperator.getFileType(file) - val data = AppSettings.getValue(AppSettings.Setting.SourceFileType,"ini,template") + val data = AppSettings.getValue( + AppSettings.Setting.SourceFileType, + "ini,template" + ) val line = LineParser(data) var isSourceFile = false line.symbol = "," line.analyse { lineNum, lineData, isEnd -> - if (type == lineData) - { + if (type == lineData) { isSourceFile = true return@analyse false } @@ -852,7 +854,13 @@ class FileManagerActivity : BaseActivity() { return@observe } val root = getString(R.string.root_path) - val path = root + it.substring(viewModel.getRootPath().length) + val rootLength = viewModel.getRootPath().length + val nowLength = it.length + val path = if (rootLength < nowLength) { + root + it.substring(rootLength) + }else{ + it + } val lineParser = LineParser(path) lineParser.symbol = "/" lineParser.parserSymbol = true diff --git a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt index b5f0c3d..d59bb22 100644 --- a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt @@ -21,6 +21,7 @@ import com.coldmint.dialog.InputDialog import com.coldmint.rust.core.dataBean.ApiResponse import com.coldmint.rust.core.dataBean.LoginRequestData import com.coldmint.rust.core.dataBean.user.UserData +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.web.ServerConfiguration import com.coldmint.rust.core.web.User @@ -41,7 +42,7 @@ class LoginActivity : BaseActivity() { // transparentStatusBar().statusBarDarkFont(true) // .transparentNavigationBar().navigationBarDarkIcon(true) // } - Log.d("应用识别码", AppSettings.getValue(AppSettings.Setting.AppID, "无")) + LogCat.d("应用识别码", AppSettings.getValue(AppSettings.Setting.AppID, "无")) viewBinding.changeServerView.isVisible = BuildConfig.DEBUG viewBinding.changePasswordView.setOnClickListener { val intent = Intent(this, ChangePasswordActivity::class.java) diff --git a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt index d3b284a..25fab8e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt @@ -30,6 +30,7 @@ import com.coldmint.rust.core.CompressionManager import com.coldmint.rust.core.LocalTemplatePackage import com.coldmint.rust.core.dataBean.AppUpdateData import com.coldmint.rust.core.dataBean.template.TemplateInfo +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.interfaces.UnzipListener import com.coldmint.rust.core.tool.* @@ -150,7 +151,7 @@ class MainActivity : BaseActivity() { fun ifNeedShowUpdate(data: AppUpdateData.Data) { val key = "应用更新" if (ServerConfiguration.isTestServer()) { - Log.w(key, "当前为本地测试服务器,已禁用更新检查。") + LogCat.w(key, "当前为本地测试服务器,已禁用更新检查。") return } val executorService = Executors.newSingleThreadExecutor() @@ -160,34 +161,15 @@ class MainActivity : BaseActivity() { val checkBetaUpdate = AppSettings.getValue(AppSettings.Setting.CheckBetaUpdate, false) var needShowDialog = false - //如果自身是Beta版,则强制更新Beta版本 - if (BuildConfig.DEBUG && packageInfo.versionName.contains("Beta")) { - data.forced = true - //版本名不一致,是Beta模式 - if (packageInfo.versionName != data.versionName) { - needShowDialog = true - Log.d(key, "是测试模式,版本名称不一致") + if (data.versionNumber > packageInfo.versionCode) { + if (data.isBeta) { + if (checkBetaUpdate) { + needShowDialog = true + } } else { - Log.d(key, "是测试模式,并且是Beta版本") - } - } else if (checkBetaUpdate) { - //版本名不一致 - if (packageInfo.versionName != data.versionName) { needShowDialog = true - Log.d(key, "开启了检查Beta版本,版本名称不一致") - } else { - Log.d(key, "开启了检查Beta版本,无需更新") - } - } else { - //版本号不一致 - if (packageInfo.versionCode != data.versionNumber) { - needShowDialog = true - Log.d(key, "正式打包模式,版本号不一致") - } else { - Log.d(key, "正式打包模式,版本号一致无需更新") } } - if (!needShowDialog) { return@submit } @@ -392,22 +374,33 @@ class MainActivity : BaseActivity() { AppSettings.Setting.ExpirationTime, 0.toLong() ) - val time = ServerConfiguration.toStringTime( - longTime + val loginStatus = AppSettings.getValue( + AppSettings.Setting.LoginStatus, + false ) val activationItem = menu.findItem(R.id.activation_item) - if (time == ServerConfiguration.ForeverTime) { - activationItem.isVisible = false + if (loginStatus) { + val time = ServerConfiguration.toStringTime( + longTime + ) + if (time == ServerConfiguration.ForeverTime) { + activationItem.isVisible = false + } else { + activationItem.isVisible = true + if (isActive) { + activationItem.title = getText(R.string.renewal) + } else { + activationItem.title = getText(R.string.activate) + } + activationItem.setOnMenuItemClickListener { + startActivity(Intent(this, ActivateActivity::class.java)) + false + } + } } else { - activationItem.isVisible = true - if (isActive) { - activationItem.title = getText(R.string.renewal) - } - activationItem.setOnMenuItemClickListener { - startActivity(Intent(this, ActivateActivity::class.java)) - false - } + activationItem.isVisible = false } + } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { @@ -653,9 +646,7 @@ class MainActivity : BaseActivity() { startViewModel.needLoginLiveData.observe(this) { if (it) { - Glide.with(this).load(R.drawable.head_icon) - .apply(GlobalMethod.getRequestOptions(true, grayscale = false)) - .into(headLayout.imageView) + headLayout.imageView.setImageResource(R.drawable.head_icon) headLayout.nameView.text = getString(R.string.click_profile_picture_login) headLayout.emailView.text = "" headLayout.imageView.setOnClickListener { diff --git a/app/src/main/java/com/coldmint/rust/pro/PayActivity.kt b/app/src/main/java/com/coldmint/rust/pro/PayActivity.kt index be05cb7..dbcec21 100644 --- a/app/src/main/java/com/coldmint/rust/pro/PayActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/PayActivity.kt @@ -25,6 +25,7 @@ import android.view.MenuItem import androidx.core.view.isVisible import com.coldmint.dialog.CoreDialog import com.coldmint.rust.core.dataBean.OrderDataBean +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.tool.AppOperator import com.coldmint.rust.core.tool.FileOperator @@ -241,7 +242,7 @@ class PayActivity : BaseActivity() { timeBuilder.append("秒") } setMoney(timeBuilder.toString(), t.data.price) - Log.d("秒", timeBuilder.toString()) + LogCat.d("秒", timeBuilder.toString()) } override fun onFinish() { diff --git a/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt b/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt index 3f0b853..cb71afa 100644 --- a/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt +++ b/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt @@ -5,13 +5,18 @@ import android.content.Context import android.os.Environment import android.util.Log import cat.ereza.customactivityoncrash.config.CaocConfig +import com.coldmint.rust.core.debug.LogCat +import com.coldmint.rust.core.debug.LogCatObserver import com.coldmint.rust.core.web.ServerConfiguration import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.tool.CompletionItemConverter import com.coldmint.rust.pro.tool.GlobalMethod import com.google.android.material.color.DynamicColors import com.google.android.material.color.DynamicColorsOptions +import com.google.firebase.crashlytics.ktx.crashlytics +import com.google.firebase.ktx.Firebase import com.hjq.language.MultiLanguages +import com.youth.banner.BuildConfig import java.util.* class RustApplication : Application() { @@ -30,6 +35,12 @@ class RustApplication : Application() { ) }.build() DynamicColors.applyToActivitiesIfAvailable(this, options) + LogCat.attachObserver(object : LogCatObserver{ + override fun onReceiveLog(msg: String) { + Firebase.crashlytics.log(msg) + } + }) + LogCat.setEnable(!BuildConfig.DEBUG) //程序崩溃 CaocConfig.Builder.create() .backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT) //default: CaocConfig.BACKGROUND_MODE_SHOW_CUSTOM @@ -52,4 +63,6 @@ class RustApplication : Application() { override fun attachBaseContext(base: Context?) { super.attachBaseContext(MultiLanguages.attach(base)) } + + } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/TemplateParserActivity.kt b/app/src/main/java/com/coldmint/rust/pro/TemplateParserActivity.kt index 50c0da6..aa756a8 100644 --- a/app/src/main/java/com/coldmint/rust/pro/TemplateParserActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/TemplateParserActivity.kt @@ -30,6 +30,7 @@ import com.coldmint.rust.core.dataBean.ListParserDataBean import com.coldmint.rust.core.dataBean.template.LocalTemplateFile import com.coldmint.rust.core.dataBean.template.TemplatePackage import com.coldmint.rust.core.dataBean.template.WebTemplateData +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.interfaces.TemplateParser import com.coldmint.rust.core.templateParser.InputParser @@ -140,7 +141,7 @@ class TemplateParserActivity : BaseActivity() { } val isLocal = intent.getBooleanExtra("isLocal", false) if (isLocal) { - Log.d("模板解析器", "读取本地模板$link") + LogCat.d("模板解析器", "读取本地模板$link") viewModel.setTemplate(LocalTemplateFile(File(link))) val templateParserList = viewModel.getTemplateParserList(this) templateParserList.forEach { @@ -150,7 +151,7 @@ class TemplateParserActivity : BaseActivity() { viewBinding.nestedScrollView.isVisible = true title = viewModel.getTemplateName(language) } else { - Log.d("模板解析器", "加载网络模板$link") + LogCat.d("模板解析器", "加载网络模板$link") TemplatePhp.instance.getTemplate(link, object : ApiCallBack { override fun onResponse(t: WebTemplateData) { if (t.code == ServerConfiguration.Success_Code) { diff --git a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt index bc1c21b..62ec184 100644 --- a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt @@ -39,7 +39,7 @@ import com.gyf.immersionbar.ktx.immersionBar class UserHomePageActivity : BaseActivity() { lateinit var userId: String - lateinit var account: String + var account: String? = null var userName: String? = null var fans: Int = 0 val userHomeStateAdapter by lazy { @@ -83,10 +83,7 @@ class UserHomePageActivity : BaseActivity() { } val temAccount = AppSettings.getValue(AppSettings.Setting.Account, "") - if (temAccount.isBlank()) { - showError("请先登录") - return - } else { + if (temAccount.isNotBlank()) { account = temAccount } viewBinding.toolbar.title = "" @@ -120,42 +117,46 @@ class UserHomePageActivity : BaseActivity() { * 初始化按钮 */ private fun initButton() { - if (account == userId) { - viewBinding.button.text = getString(R.string.editData) - } else { - Community.getFollowState(account, userId, object : ApiCallBack { - override fun onResponse(t: ApiResponse) { - if (t.code == ServerConfiguration.Success_Code) { - val data = t.data - if (data != null && ServerConfiguration.isEvent(data)) { - when (data) { - "@event:已互粉" -> { - viewBinding.button.text = getString(R.string.each_other_follow) - } - "@event:已关注" -> { - viewBinding.button.text = getString(R.string.followed) - } - "@event:关注" -> { - viewBinding.button.text = getString(R.string.follow) - } - "@event:拒绝关注" -> { - viewBinding.button.text = getString(R.string.reject_follow) - viewBinding.button.isEnabled = false + if (account == null) { + viewBinding.button.text = getString(R.string.please_login_first) + viewBinding.button.isEnabled = false + }else{ + if (account == userId) { + viewBinding.button.text = getString(R.string.editData) + } else { + Community.getFollowState(account!!, userId, object : ApiCallBack { + override fun onResponse(t: ApiResponse) { + if (t.code == ServerConfiguration.Success_Code) { + val data = t.data + if (data != null && ServerConfiguration.isEvent(data)) { + when (data) { + "@event:已互粉" -> { + viewBinding.button.text = getString(R.string.each_other_follow) + } + "@event:已关注" -> { + viewBinding.button.text = getString(R.string.followed) + } + "@event:关注" -> { + viewBinding.button.text = getString(R.string.follow) + } + "@event:拒绝关注" -> { + viewBinding.button.text = getString(R.string.reject_follow) + viewBinding.button.isEnabled = false + } } } + } else { + } - } else { + } + + override fun onFailure(e: Exception) { } - } - override fun onFailure(e: Exception) { - - } - - }) + }) + } } - } /** @@ -394,7 +395,7 @@ class UserHomePageActivity : BaseActivity() { ) ) viewBinding.button.setText(R.string.request_data) - Community.follow(account, userId, object : ApiCallBack { + Community.follow(account!!, userId, object : ApiCallBack { override fun onResponse(t: ApiResponse) { viewBinding.button.setBackgroundColor( GlobalMethod.getColorPrimary( @@ -442,7 +443,7 @@ class UserHomePageActivity : BaseActivity() { ) viewBinding.button.setText(R.string.request_data) Community.deFollow( - account, + account!!, userId, object : ApiCallBack { override fun onResponse(t: ApiResponse) { @@ -474,7 +475,7 @@ class UserHomePageActivity : BaseActivity() { }) }.setNegativeButton(R.string.dialog_cancel) { - }.show() + }.show() } getString(R.string.editData) -> { val intent = Intent(this, EditUserInfoActivity::class.java) diff --git a/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt b/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt index bb8950b..68f9690 100644 --- a/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt @@ -183,6 +183,14 @@ class WebModInfoActivity : BaseActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.report_item -> { + if (token.isBlank()) { + Snackbar.make( + viewBinding.button, + R.string.please_login_first, + Snackbar.LENGTH_SHORT + ).show() + return true + } if (adapter.isOpen()) { val thisIntent = Intent(this, ReportActivity::class.java) val bundle = Bundle() @@ -215,7 +223,7 @@ class WebModInfoActivity : BaseActivity() { link + "website/pages/modPage.php?&modId=" + modId, appUpdateLink ) - AppOperator.shareText(this,getString(R.string.share_mod),s) + AppOperator.shareText(this, getString(R.string.share_mod), s) } R.id.update_record -> { GlobalMethod.showUpdateLog(this, modId) diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/FileAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/FileAdapter.kt index ccdddd5..fff0af4 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/FileAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/FileAdapter.kt @@ -24,7 +24,7 @@ import java.lang.StringBuilder import java.text.SimpleDateFormat import java.util.ArrayList -class FileAdapter( context: Context, dataList: MutableList) : +class FileAdapter(context: Context, dataList: MutableList) : BaseAdapter(context, dataList), PopupTextProvider { /** @@ -204,6 +204,9 @@ class FileAdapter( context: Context, dataList: MutableList) : override fun getPopupText(position: Int): String { + if (position >= dataList.size) { + return "#" + } val file = dataList[position] val data = when (sortType) { FileManagerViewModel.SortType.BY_NAME -> { diff --git a/app/src/main/java/com/coldmint/rust/pro/base/BaseAppendAutoCompleteHelper.kt b/app/src/main/java/com/coldmint/rust/pro/base/BaseAppendAutoCompleteHelper.kt index a7e06de..fe9cf69 100644 --- a/app/src/main/java/com/coldmint/rust/pro/base/BaseAppendAutoCompleteHelper.kt +++ b/app/src/main/java/com/coldmint/rust/pro/base/BaseAppendAutoCompleteHelper.kt @@ -6,6 +6,7 @@ import android.text.Editable import android.text.TextWatcher import android.util.Log import android.widget.ArrayAdapter +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.pro.interfaces.AutoCompleteHelper import com.google.android.material.textfield.MaterialAutoCompleteTextView @@ -61,7 +62,7 @@ abstract class BaseAppendAutoCompleteHelper(context: Context) : AutoCompleteHelp if (index > -1) { val end = string.substring(index) var num = 0 - Log.d("附加提示列表", "截取 " + end) + LogCat.d("附加提示列表", "截取 " + end) for (data in mDataList) { if (data.startsWith(end)) { num++ @@ -70,7 +71,7 @@ abstract class BaseAppendAutoCompleteHelper(context: Context) : AutoCompleteHelp 1 ) val value = h1 + h2 - Log.d("附加提示列表", "提示 " + h1 + " | " + h2) + LogCat.d("附加提示列表", "提示 " + h1 + " | " + h2) adapter.add(value) } if (num == maxNum) { @@ -79,7 +80,7 @@ abstract class BaseAppendAutoCompleteHelper(context: Context) : AutoCompleteHelp } } else { var num = 0 - Log.d("附加提示列表", "没有符号 " + string) + LogCat.d("附加提示列表", "没有符号 " + string) for (email in mDataList) { num++ adapter.add(string + email) diff --git a/app/src/main/java/com/coldmint/rust/pro/edit/RustAutoComplete.kt b/app/src/main/java/com/coldmint/rust/pro/edit/RustAutoComplete.kt index 0e5e3ec..d9daa83 100644 --- a/app/src/main/java/com/coldmint/rust/pro/edit/RustAutoComplete.kt +++ b/app/src/main/java/com/coldmint/rust/pro/edit/RustAutoComplete.kt @@ -194,7 +194,7 @@ class RustAutoComplete(val context: Context) : EnglishMode { // //// val value = //// lineData.subSequence(keyIndex + key.length, lineData.length).toString().trim() -//// Log.d("值", value) +//// LogCat.d("值", value) // //搜索值 // // frontIndex 前面冒号的位置 // val frontIndex = lineData.lastIndexOf(key, keyIndex - key.length) diff --git a/app/src/main/java/com/coldmint/rust/pro/edit/autoComplete/CodeAutoCompleteJob.kt b/app/src/main/java/com/coldmint/rust/pro/edit/autoComplete/CodeAutoCompleteJob.kt index 5ececdc..56ec152 100644 --- a/app/src/main/java/com/coldmint/rust/pro/edit/autoComplete/CodeAutoCompleteJob.kt +++ b/app/src/main/java/com/coldmint/rust/pro/edit/autoComplete/CodeAutoCompleteJob.kt @@ -177,7 +177,7 @@ class CodeAutoCompleteJob : AutoCompleteJob { // val value = // lineData.subSequence(keyIndex + key.length, lineData.length).toString().trim() -// Log.d("值", value) +// LogCat.d("值", value) //搜索值 // frontIndex 前面冒号的位置 val frontIndex = lineData.lastIndexOf(key, keyIndex - key.length) diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt index 739ff2e..e06263e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt @@ -36,12 +36,11 @@ class FollowFragment : BaseFragment() { * 加载视图如果需要更新的话 */ fun loadViewIfNeed() { - val selfAccount = AppSettings.getValue(AppSettings.Setting.Account, "") - if (selfAccount.isBlank()) { - showTip(R.string.please_login_first) - } else { + val loginStatus = AppSettings.getValue(AppSettings.Setting.LoginStatus, false) + if (loginStatus) { + val account = AppSettings.getValue(AppSettings.Setting.Account, "") Community.getUserList( - selfAccount, + account, limit = -1, apiCallBack = object : ApiCallBack { override fun onResponse(t: FollowUserListData) { @@ -110,6 +109,8 @@ class FollowFragment : BaseFragment() { } }) + } else { + showTip(R.string.follow_introduction) } } @@ -129,6 +130,9 @@ class FollowFragment : BaseFragment() { * @param t DynamicItemDataBean */ fun getDynamicSuccess(t: DynamicItemDataBean) { + if (!isAdded) { + return + } val data = t.data?.toMutableList() if (t.code == ServerConfiguration.Success_Code && data != null) { val adapter = DynamicAdapter(requireContext(), data) diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt index e328efe..59edb50 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt @@ -129,6 +129,11 @@ class InsertCoinsFragment(val modId: String) : BaseFragment { override fun onResponse(t: CoinStatusData) { viewBinding.button.isEnabled = !t.data diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/InstalledTemplateFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/InstalledTemplateFragment.kt index 7236952..e60adb2 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/InstalledTemplateFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/InstalledTemplateFragment.kt @@ -21,6 +21,7 @@ import com.coldmint.rust.core.LocalTemplatePackage import com.coldmint.rust.core.dataBean.template.LocalTemplateFile import com.coldmint.rust.core.dataBean.template.Template import com.coldmint.rust.core.dataBean.template.TemplatePackage +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.core.tool.FileOperator import com.coldmint.rust.pro.FileManagerActivity import com.coldmint.rust.pro.R @@ -133,11 +134,11 @@ class InstalledTemplateFragment : BaseFragment startTemplateParserActivity = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { if (it.resultCode == Activity.RESULT_OK) { - Log.d("启动模板解析器", "收到成功回调,关闭界面。") + LogCat.d("启动模板解析器", "收到成功回调,关闭界面。") requireActivity().setResult(AppCompatActivity.RESULT_OK, it.data) requireActivity().finish() } else { - Log.w("启动模板解析器", "未收到有效回调。") + LogCat.w("启动模板解析器", "未收到有效回调。") } } viewModel.createPathLiveData.observe(this) { @@ -157,9 +158,9 @@ class InstalledTemplateFragment : BaseFragment ) if (this::mTemplateAdapter.isInitialized) { mTemplateAdapter.setCreatePath(it) - Log.d("创建目录观察者", "模板适配器设置目录为${it}。") + LogCat.d("创建目录观察者", "模板适配器设置目录为${it}。") } else { - Log.e("创建目录观察者", "模板适配器没有设置目录。") + LogCat.e("创建目录观察者", "模板适配器没有设置目录。") } } viewModel.setLoadCallBack { @@ -172,7 +173,7 @@ class InstalledTemplateFragment : BaseFragment viewBinding.expandableList.setAdapter(mTemplateAdapter) val path = viewModel.createPathLiveData.value.toString() mTemplateAdapter.setCreatePath(path) - Log.d("创建目录观察者", "模板适配器设置目录为${path}。") + LogCat.d("创建目录观察者", "模板适配器设置目录为${path}。") } viewModel.loadTemplate(requireContext()) } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt index 8d461cf..a9076c4 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt @@ -28,7 +28,7 @@ import com.google.android.material.divider.MaterialDividerItemDecoration import com.google.android.material.snackbar.Snackbar /** - * 模组评论适配器 + * 模组评论 */ class ModCommentsFragment(val modId: String) : BaseFragment() { override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { @@ -46,10 +46,13 @@ class ModCommentsFragment(val modId: String) : BaseFragment button.isEnabled = false WebMod.instance.sendComment( - AppSettings.getValue(AppSettings.Setting.Token, ""), + token, modId, s, object : ApiCallBack { diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt index 7313401..13939a1 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt @@ -7,6 +7,7 @@ import android.view.LayoutInflater import androidx.core.view.isVisible import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager +import com.bumptech.glide.Glide import com.coldmint.rust.core.ModClass import com.coldmint.rust.core.dataBean.ModConfigurationData import com.coldmint.rust.core.tool.DebugHelper @@ -303,7 +304,7 @@ class ModFragment : BaseFragment() { ) ) } else { - modDialogBinding.modIcon.setImageBitmap(modClass.modIcon) + Glide.with(requireContext()).load(modClass.modIcon).into(modDialogBinding.modIcon) } } else { val drawable = context.getDrawable(R.drawable.file) diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/RankingFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/RankingFragment.kt index ad59d03..3da8809 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/RankingFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/RankingFragment.kt @@ -81,12 +81,11 @@ class RankingFragment : BaseFragment() { viewBinding.downloadChip.isChecked = true } -// override fun onResume() { -// loadMods() -// super.onResume() -// } fun loadMods() { + viewBinding.progressBar.isVisible = true + viewBinding.textview.isVisible = false + viewBinding.swipeRefreshLayout.isVisible = false WebMod.instance.list(object : ApiCallBack { override fun onResponse(t: WebModListData) { if (t.code == ServerConfiguration.Success_Code) { @@ -95,7 +94,6 @@ class RankingFragment : BaseFragment() { viewBinding.progressBar.isVisible = false viewBinding.textview.isVisible = false viewBinding.swipeRefreshLayout.isVisible = true -// Toast.makeText(requireContext(),"加载"+list.size,Toast.LENGTH_SHORT).show() val adapter = createAdapter(list) viewBinding.recyclerView.adapter = adapter linearLayoutManager.scrollToPositionWithOffset( diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/SaveTemplateFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/SaveTemplateFragment.kt index 1378603..d435771 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/SaveTemplateFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/SaveTemplateFragment.kt @@ -12,6 +12,7 @@ import com.coldmint.rust.core.LocalTemplatePackage import com.coldmint.rust.core.dataBean.ApiResponse import com.coldmint.rust.core.dataBean.WebTemplatePackageListData import com.coldmint.rust.core.dataBean.template.TemplatePackage +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.tool.FileOperator import com.coldmint.rust.core.web.TemplatePhp @@ -152,7 +153,7 @@ class SaveTemplateFragment(val name: String, val json: JSONObject) : BottomSheet ) ) if (templateDirectory.exists() && templateDirectory.isDirectory) { - Log.d("加载本地模板", "正在读取" + templateDirectory.absolutePath) + LogCat.d("加载本地模板", "正在读取" + templateDirectory.absolutePath) val files = templateDirectory.listFiles() if (files.isNotEmpty()) { files.forEach { @@ -162,19 +163,19 @@ class SaveTemplateFragment(val name: String, val json: JSONObject) : BottomSheet LocalTemplatePackage(it) if (templatePackage.isTemplate) { list.add(templatePackage) - Log.w("加载本地模板", "已添加,文件" + it.absolutePath) + LogCat.w("加载本地模板", "已添加,文件" + it.absolutePath) } else { - Log.w("加载本地模板", "文件" + it.absolutePath + "不是模板包") + LogCat.w("加载本地模板", "文件" + it.absolutePath + "不是模板包") } } else { - Log.w("加载本地模板", "文件" + it.absolutePath + "不是文件夹") + LogCat.w("加载本地模板", "文件" + it.absolutePath + "不是文件夹") } } } else { - Log.w("加载本地模板", "目录" + templateDirectory.absolutePath + "内,没有文件,无法加载。") + LogCat.w("加载本地模板", "目录" + templateDirectory.absolutePath + "内,没有文件,无法加载。") } } else { - Log.e("加载本地模板", "模板目录不存在或不是文件夹" + templateDirectory.absolutePath) + LogCat.e("加载本地模板", "模板目录不存在或不是文件夹" + templateDirectory.absolutePath) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt index 908b17e..35fd9e6 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt @@ -4,6 +4,7 @@ import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.widget.Toast +import androidx.core.view.isVisible import androidx.recyclerview.widget.GridLayoutManager import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions @@ -102,8 +103,27 @@ class UserInfoFragment : BaseFragment() { override fun onResume() { super.onResume() - val token = AppSettings.getValue(AppSettings.Setting.Token, "") - if (token.isNotBlank()) { + viewBinding.progressBar.isVisible = true + viewBinding.loginLayout.root.isVisible = false + viewBinding.contentLayout.isVisible = false + val loginStatus = AppSettings.getValue(AppSettings.Setting.LoginStatus, false) + if (loginStatus) { + viewBinding.progressBar.isVisible = false + viewBinding.loginLayout.root.isVisible = false + viewBinding.contentLayout.isVisible = true + 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 { override fun onFailure(e: Exception) { @@ -126,9 +146,8 @@ class UserInfoFragment : BaseFragment() { } viewBinding.coinView.text = String.format( getString( - R.string.coin_number, - t.data.coinNumber - ) + R.string.coin_number + ), t.data.coinNumber ) loadRecyclerView(t.data.permission) } else { @@ -139,24 +158,26 @@ class UserInfoFragment : BaseFragment() { } }) + } else { + viewBinding.progressBar.isVisible = false + viewBinding.loginLayout.root.isVisible = true + viewBinding.contentLayout.isVisible = false + viewBinding.root.isFillViewport = true } } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { - account = AppSettings.getValue(AppSettings.Setting.Account, "") - viewBinding.myHomeView.setOnClickListener { - val intent = Intent( - requireActivity(), - UserHomePageActivity::class.java - ) - intent.putExtra("userId", account) - startActivity( - intent - ) - } - viewBinding.logOutButton.setOnClickListener { AppSettings.setValue(AppSettings.Setting.LoginStatus, false) +// GlobalMethod.isActive = false + AppSettings.setValue( + AppSettings.Setting.ExpirationTime, + 0.toLong() + ) + (requireActivity() as MainActivity).startViewModel.isActivationLiveData.value = false + startActivity(Intent(requireContext(), LoginActivity::class.java)) + } + viewBinding.loginLayout.logView.setOnClickListener { startActivity(Intent(requireContext(), LoginActivity::class.java)) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/WebModDetailsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/WebModDetailsFragment.kt index 8335b8a..545b544 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/WebModDetailsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/WebModDetailsFragment.kt @@ -5,6 +5,7 @@ import android.os.Bundle import android.view.LayoutInflater import androidx.core.view.isVisible import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModelProvider import com.bumptech.glide.Glide import com.coldmint.rust.core.dataBean.mod.WebModInfoData import com.coldmint.rust.core.dataBean.user.SpaceInfoData @@ -21,6 +22,8 @@ import com.coldmint.rust.pro.databinding.FragmentWebModDetailsBinding import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.tool.GlobalMethod import com.coldmint.rust.pro.tool.TextStyleMaker +import com.coldmint.rust.pro.viewmodel.StartViewModel +import com.coldmint.rust.pro.viewmodel.WebModDetailsViewModel import com.google.android.material.chip.Chip import com.youth.banner.adapter.BannerImageAdapter import com.youth.banner.holder.BannerImageHolder @@ -29,17 +32,22 @@ import com.youth.banner.indicator.CircleIndicator /** * 模组详情碎片 */ -class WebModDetailsFragment(val modId: String,val modNameLiveData: MutableLiveData) : BaseFragment() { - private var developer: String? = null +class WebModDetailsFragment(val modId: String, val modNameLiveData: MutableLiveData) : + BaseFragment() { + private val viewModel: WebModDetailsViewModel by lazy { + ViewModelProvider(requireActivity())[WebModDetailsViewModel::class.java] + } - //此模组是否对外开放 - private var isOpen = false - private var link: String? = null + + //Kotlin次构造函数 + constructor() : this("", MutableLiveData()) { + + } fun getLink(): String? { - return link + return viewModel.link } /** @@ -47,10 +55,12 @@ class WebModDetailsFragment(val modId: String,val modNameLiveData: MutableLiveDa * @return Boolean */ fun isOpen(): Boolean { - return isOpen + return viewModel.isOpen } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { + viewModel.modId = modId + viewModel.modNameLiveData = modNameLiveData loadInfo() } @@ -62,7 +72,7 @@ class WebModDetailsFragment(val modId: String,val modNameLiveData: MutableLiveDa fun loadDeveloperInfo(userId: String) { User.getSpaceInfo(userId, object : ApiCallBack { override fun onResponse(t: SpaceInfoData) { - if (t.code == ServerConfiguration.Success_Code) { + if (t.code == ServerConfiguration.Success_Code && isAdded) { val icon = t.data.headIcon if (icon != null) { Glide.with(requireContext()) @@ -78,7 +88,6 @@ class WebModDetailsFragment(val modId: String,val modNameLiveData: MutableLiveDa ServerConfiguration.numberToString(t.data.praise) ) viewBinding.userInfoView.text = info - viewBinding.cardView.postDelayed({ viewBinding.cardView.isVisible = true viewBinding.openUserSpace.setOnClickListener { @@ -122,10 +131,10 @@ class WebModDetailsFragment(val modId: String,val modNameLiveData: MutableLiveDa WebMod.instance.getInfo(token, modId, object : ApiCallBack { override fun onResponse(t: WebModInfoData) { if (t.code == ServerConfiguration.Success_Code) { - developer = t.data.developer + viewModel.developer = t.data.developer modNameLiveData.value = t.data.name - isOpen = t.data.hidden == 0 - link = t.data.link + viewModel.isOpen = t.data.hidden == 0 + viewModel.link = t.data.link viewBinding.loadLayout.isVisible = false viewBinding.contentLayout.isVisible = true val icon = t.data.icon diff --git a/app/src/main/java/com/coldmint/rust/pro/viewmodel/InstalledTemplateViewModel.kt b/app/src/main/java/com/coldmint/rust/pro/viewmodel/InstalledTemplateViewModel.kt index 07df868..d6a5c8a 100644 --- a/app/src/main/java/com/coldmint/rust/pro/viewmodel/InstalledTemplateViewModel.kt +++ b/app/src/main/java/com/coldmint/rust/pro/viewmodel/InstalledTemplateViewModel.kt @@ -8,6 +8,7 @@ import com.coldmint.rust.core.dataBean.SubscriptionData import com.coldmint.rust.core.dataBean.template.LocalTemplateFile import com.coldmint.rust.core.dataBean.template.Template import com.coldmint.rust.core.dataBean.template.TemplatePackage +import com.coldmint.rust.core.debug.LogCat import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.interfaces.FileFinderListener import com.coldmint.rust.core.tool.FileFinder2 @@ -88,7 +89,7 @@ class InstalledTemplateViewModel : BaseViewModel() { TemplatePhp.instance.getSubscriptionDataList(token,object :ApiCallBack{ override fun onResponse(t: SubscriptionData) { if (t.code == ServerConfiguration.Success_Code){ - Log.d("加载网络订阅模板", "正在处理。") + LogCat.d("加载网络订阅模板", "正在处理。") t.data.forEach { groupList.add(it) val temList = ArrayList