diff --git a/app/build.gradle b/app/build.gradle index 9b987db..ad05071 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,8 +31,8 @@ android { applicationId "com.coldmint.rust.pro" minSdkVersion 21 targetSdkVersion 33 - versionCode 26 - versionName "2.1 Bata4(2023-1-28)" + versionCode 27 + versionName "2.1 Bata5(2023-4-21)" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/assets/baseTemplate.rp b/app/src/main/assets/baseTemplate.rp deleted file mode 100644 index 979934e..0000000 Binary files a/app/src/main/assets/baseTemplate.rp and /dev/null differ diff --git a/app/src/main/assets/baseTemplate_v2.0.rp b/app/src/main/assets/baseTemplate_v2.0.rp new file mode 100644 index 0000000..258d88f Binary files /dev/null and b/app/src/main/assets/baseTemplate_v2.0.rp differ diff --git a/app/src/main/assets/dataBase.rdb b/app/src/main/assets/dataBase.rdb deleted file mode 100644 index 6ae5e5d..0000000 Binary files a/app/src/main/assets/dataBase.rdb and /dev/null differ diff --git a/app/src/main/assets/dataBase_en.rdb b/app/src/main/assets/dataBase_en.rdb deleted file mode 100644 index ef284b5..0000000 Binary files a/app/src/main/assets/dataBase_en.rdb and /dev/null differ diff --git a/app/src/main/assets/dataBase_v2.2.0.rdb b/app/src/main/assets/dataBase_v2.2.0.rdb new file mode 100644 index 0000000..7700f41 Binary files /dev/null and b/app/src/main/assets/dataBase_v2.2.0.rdb differ 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 f09020c..182d9b4 100644 --- a/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt @@ -19,6 +19,8 @@ import android.view.KeyEvent import android.view.LayoutInflater import android.view.MenuItem import android.view.View +import android.view.animation.Animation +import android.view.animation.RotateAnimation import android.widget.* import androidx.core.view.isVisible import androidx.core.widget.addTextChangedListener @@ -253,6 +255,39 @@ class EditModInfoActivity : BaseActivity() { return FileOperator.writeFile(mModClass.infoFile, resultBuilder.toString()) } + /** + * 执行旋转动画 + */ + private fun doRotateAnimation( + view: View, + fromDegrees: Float, + toDegrees: Float, event: ((Boolean) -> Unit)? = null + ) { + view.clearAnimation() + // 计算视图中心点的坐标 + val centerX = view.width / 2 + val centerY = view.height / 2 + // 创建旋转动画,并设置中心点为视图中心 + val rotateAnimation = + RotateAnimation(fromDegrees, toDegrees, centerX.toFloat(), centerY.toFloat()) + rotateAnimation.duration = 150 + rotateAnimation.fillAfter = true // 设置FillAfter属性为true,使动画结束后保持最后一帧的状态 + rotateAnimation.setAnimationListener(object : Animation.AnimationListener { + override fun onAnimationStart(animation: Animation) { + event?.invoke(false) + } + + override fun onAnimationEnd(animation: Animation) { + event?.invoke(true) + } + + override fun onAnimationRepeat(animation: Animation) { + } + }) + // 启动动画 + view.startAnimation(rotateAnimation) + } + fun initAction() { viewBinding.modNameEdit.addTextChangedListener { viewBinding.modNameInputLayout.isErrorEnabled = false @@ -408,13 +443,15 @@ class EditModInfoActivity : BaseActivity() { viewBinding.expandMusicList.isVisible = true viewBinding.enabledMusic.text = getString(R.string.disabled) } else { - showMusicConfigurationView(true) - viewBinding.musicListView.isVisible = false - viewBinding.addMusic.isVisible = false - viewBinding.expandMusicList.isVisible = false - viewBinding.enabledMusic.text = getText(R.string.enabled) - viewBinding.musicPathView.text = getString(R.string.no_enabled) - viewBinding.musicPathView.isVisible = true + showMusicConfigurationView(true) { + viewBinding.musicListView.isVisible = false + viewBinding.addMusic.isVisible = false + viewBinding.expandMusicList.clearAnimation() + viewBinding.expandMusicList.isVisible = false + viewBinding.enabledMusic.text = getText(R.string.enabled) + viewBinding.musicPathView.text = getString(R.string.no_enabled) + viewBinding.musicPathView.isVisible = true + } } } @@ -452,45 +489,47 @@ class EditModInfoActivity : BaseActivity() { * @param hide 隐藏视图 */ @SuppressLint("StringFormatMatches") - fun showMusicConfigurationView(hide: Boolean) { + fun showMusicConfigurationView(hide: Boolean, func: (() -> Unit)? = null) { if (hide) { - viewBinding.expandMusicList.setImageResource(R.drawable.animator_expand_off) - mExpandMusicList = false - viewBinding.musicOperation.isVisible = false - viewBinding.musicPathView.isVisible = false - } else { - viewBinding.expandMusicList.setImageResource(R.drawable.animator_expand_on) - mExpandMusicList = true - viewBinding.musicOperation.isVisible = true - val musicFolder = musicFolder - if (!musicFolder.exists()) { - musicFolder.mkdirs() - } - val files = ArrayList() - val fileArray = musicFolder.listFiles() - if (fileArray.isNotEmpty()) { - for (f in fileArray) { - if (FileOperator.getFileType(f) == "ogg") { - files.add(f) - } + doRotateAnimation(viewBinding.expandMusicList, 180f, 360f) { + if (it) { + mExpandMusicList = false + viewBinding.musicOperation.isVisible = false + viewBinding.musicPathView.isVisible = false + func?.invoke() } } - val mapAndMusicAdapter = MapAndMusicAdapter(this, files, true) - val layoutManager = StableLinearLayoutManager(this@EditModInfoActivity) - mapAndMusicAdapter.setItemChangeEvent { changeType, i, file, i2 -> - viewBinding.musicPathView.text = - String.format(getString(R.string.filenum), i2) - } - - viewBinding.musicListView.layoutManager = layoutManager - viewBinding.musicListView.adapter = mapAndMusicAdapter - viewBinding.musicPathView.isVisible = true - viewBinding.musicPathView.text = String.format(getString(R.string.filenum), files.size) - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - (viewBinding.expandMusicList.drawable as AnimatedVectorDrawable).start() } else { - (viewBinding.expandMusicList.drawable as AnimatedVectorDrawableCompat).start() + doRotateAnimation(viewBinding.expandMusicList, 0f, 180f) { + mExpandMusicList = true + viewBinding.musicOperation.isVisible = true + val musicFolder = musicFolder + if (!musicFolder.exists()) { + musicFolder.mkdirs() + } + val files = ArrayList() + val fileArray = musicFolder.listFiles() + if (fileArray.isNotEmpty()) { + for (f in fileArray) { + if (FileOperator.getFileType(f) == "ogg") { + files.add(f) + } + } + } + val mapAndMusicAdapter = MapAndMusicAdapter(this, files, true) + val layoutManager = StableLinearLayoutManager(this@EditModInfoActivity) + mapAndMusicAdapter.setItemChangeEvent { changeType, i, file, i2 -> + viewBinding.musicPathView.text = + String.format(getString(R.string.filenum), i2) + } + + viewBinding.musicListView.layoutManager = layoutManager + viewBinding.musicListView.adapter = mapAndMusicAdapter + viewBinding.musicPathView.isVisible = true + viewBinding.musicPathView.text = + String.format(getString(R.string.filenum), files.size) + func?.invoke() + } } } @@ -506,12 +545,14 @@ class EditModInfoActivity : BaseActivity() { viewBinding.mapPathView.isVisible = false viewBinding.enabledMap.text = getString(R.string.disabled) } else { - showMapConfigurationView(true) - viewBinding.expandMapList.isVisible = false - viewBinding.addMap.isVisible = false - viewBinding.enabledMap.text = getText(R.string.enabled) - viewBinding.mapPathView.text = getString(R.string.no_enabled) - viewBinding.mapPathView.isVisible = true + showMapConfigurationView(true) { + viewBinding.expandMapList.clearAnimation() + viewBinding.expandMapList.isVisible = false + viewBinding.addMap.isVisible = false + viewBinding.enabledMap.text = getText(R.string.enabled) + viewBinding.mapPathView.text = getString(R.string.no_enabled) + viewBinding.mapPathView.isVisible = true + } } } @@ -535,44 +576,48 @@ class EditModInfoActivity : BaseActivity() { * @param hide 隐藏视图 */ @SuppressLint("StringFormatMatches") - fun showMapConfigurationView(hide: Boolean) { + fun showMapConfigurationView(hide: Boolean, func: (() -> Unit)? = null) { if (hide) { - viewBinding.expandMapList.setImageResource(R.drawable.animator_expand_off) - mExpandMapList = false - viewBinding.mapOperation.isVisible = false - viewBinding.mapPathView.isVisible = false - } else { - viewBinding.expandMapList.setImageResource(R.drawable.animator_expand_on) - mExpandMapList = true - viewBinding.mapOperation.isVisible = true - val mapFolder = mapFolder - if (!mapFolder.exists()) { - mapFolder.mkdirs() - } - val files = ArrayList() - val fileArray = mapFolder.listFiles() - if (fileArray.isNotEmpty()) { - for (f in fileArray) { - if (FileOperator.getFileType(f) == "tmx") { - files.add(f) - } + doRotateAnimation(viewBinding.expandMapList, 180f, 360f) { + if (it) { + mExpandMapList = false + viewBinding.mapOperation.isVisible = false + viewBinding.mapPathView.isVisible = false + func?.invoke() } } - val mapAndMapAdapter = MapAndMusicAdapter(this, files, false) - val layoutManager = StableLinearLayoutManager(this@EditModInfoActivity) - mapAndMapAdapter.setItemChangeEvent { changeType, i, file, i2 -> - viewBinding.mapPathView.text = - String.format(getString(R.string.filenum), i2) - } - viewBinding.mapListView.layoutManager = layoutManager - viewBinding.mapListView.adapter = mapAndMapAdapter - viewBinding.mapPathView.isVisible = true - viewBinding.mapPathView.text = String.format(getString(R.string.filenum), files.size) - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - (viewBinding.expandMapList.drawable as AnimatedVectorDrawable).start() } else { - (viewBinding.expandMapList.drawable as AnimatedVectorDrawableCompat).start() + doRotateAnimation(viewBinding.expandMapList, 0f, 180f) { + if (it) { + mExpandMapList = true + viewBinding.mapOperation.isVisible = true + val mapFolder = mapFolder + if (!mapFolder.exists()) { + mapFolder.mkdirs() + } + val files = ArrayList() + val fileArray = mapFolder.listFiles() + if (fileArray.isNotEmpty()) { + for (f in fileArray) { + if (FileOperator.getFileType(f) == "tmx") { + files.add(f) + } + } + } + val mapAndMapAdapter = MapAndMusicAdapter(this, files, false) + val layoutManager = StableLinearLayoutManager(this@EditModInfoActivity) + mapAndMapAdapter.setItemChangeEvent { changeType, i, file, i2 -> + viewBinding.mapPathView.text = + String.format(getString(R.string.filenum), i2) + } + viewBinding.mapListView.layoutManager = layoutManager + viewBinding.mapListView.adapter = mapAndMapAdapter + viewBinding.mapPathView.isVisible = true + viewBinding.mapPathView.text = + String.format(getString(R.string.filenum), files.size) + func?.invoke() + } + } } } 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 532bb35..bdd3592 100644 --- a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt @@ -260,11 +260,16 @@ class MainActivity : BaseActivity() { val codeTable = menu.findItem(R.id.code_table) val mod = menu.findItem(R.id.mod_item) val community = menu.findItem(R.id.community_item) - val group = menu.findItem(R.id.user_group) - group.setOnMenuItemClickListener { - viewBinding.drawerlayout.closeDrawer((GravityCompat.START)) - val userGroupFragment = UserGroupFragment() - userGroupFragment.show(supportFragmentManager, "userGroup") +// val group = menu.findItem(R.id.user_group) +// group.setOnMenuItemClickListener { +// viewBinding.drawerlayout.closeDrawer((GravityCompat.START)) +// val userGroupFragment = UserGroupFragment() +// userGroupFragment.show(supportFragmentManager, "userGroup") +// false +// } + val gitHub = menu.findItem(R.id.github) + gitHub.setOnMenuItemClickListener { + AppOperator.useBrowserAccessWebPage(this,"https://github.com/Cold-Mint/RustAssistant") false } // val help = menu.findItem(R.id.help) diff --git a/app/src/main/java/com/coldmint/rust/pro/SettingsActivity.kt b/app/src/main/java/com/coldmint/rust/pro/SettingsActivity.kt index c8961cb..bb4448e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/SettingsActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/SettingsActivity.kt @@ -77,11 +77,11 @@ class SettingsActivity : BaseActivity() { true } - val obtainSourceCode = manager.findPreference(requireContext().getString(R.string.setting_obtain_source_code)) - obtainSourceCode!!.onPreferenceClickListener = Preference.OnPreferenceClickListener { - AppOperator.useBrowserAccessWebPage(requireContext(),"https://github.com/Cold-Mint/RustAssistant") - true - } +// val obtainSourceCode = manager.findPreference(requireContext().getString(R.string.setting_obtain_source_code)) +// obtainSourceCode!!.onPreferenceClickListener = Preference.OnPreferenceClickListener { +// AppOperator.useBrowserAccessWebPage(requireContext(),"https://github.com/Cold-Mint/RustAssistant") +// true +// } val game = manager.findPreference("set_game_pack") game!!.onPreferenceClickListener = Preference.OnPreferenceClickListener { diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/CommentAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/CommentAdapter.kt index f14210a..f8456aa 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/CommentAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/CommentAdapter.kt @@ -56,6 +56,9 @@ class CommentAdapter(context: Context, dataList: MutableList) : ) { val dataBaseManifest = data.getDataBaseManifest() viewBinding.databaseNameView.text = data.getDataSetName() - if (dataBaseManifest != null) { - viewBinding.databaseIntroduce.text = dataBaseManifest.describe - viewBinding.databaseOther.text = - dataBaseManifest.author + "|" + dataBaseManifest.versionName + val appVersion = AppOperator.getAppVersionNum(context) + if (dataBaseManifest == null) { + viewBinding.databaseIntroduce.text = context.getString(R.string.dataset_not_exist) + viewBinding.databaseOther.text = "" + viewBinding.databaseUse.isEnabled = false + } else { + Log.d( + "DataSetAdapter", + "appVersion: ${appVersion} name: ${data.getDataSetName()} minVersion: ${dataBaseManifest.minAppVersion}" + ) + if (dataBaseManifest.minAppVersion <= appVersion) { + viewBinding.databaseIntroduce.text = dataBaseManifest.describe + viewBinding.databaseOther.text = + dataBaseManifest.author + "|" + dataBaseManifest.versionName + viewBinding.databaseUse.isEnabled = true + } else { + viewBinding.databaseUse.isEnabled = false + viewBinding.databaseIntroduce.text = + context.getString(R.string.dataset_minversion_low) + viewBinding.databaseOther.text = "" + } } } diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/DynamicAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/DynamicAdapter.kt index 7f290cf..e4e8291 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/DynamicAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/DynamicAdapter.kt @@ -66,6 +66,9 @@ class DynamicAdapter(context: Context, dataList: MutableList val menu = GlobalMethod.createPopMenu(view) menu.menu.add(R.string.copy) 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 b21aa82..58cf965 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 @@ -109,6 +109,21 @@ class ModCommentsFragment(val modId: String) : BaseFragment { override fun onResponse(t: WebModCommentData) { @@ -124,34 +139,34 @@ class ModCommentsFragment(val modId: String) : BaseFragment itemCommentBinding.iconView.setOnClickListener { gotoUserPage(data.account) } } - viewBinding.recyclerView.adapter = adapter + adapter.setItemChangeEvent { changeType, i, data, i2 -> + viewBinding.titleView.text = + getString(R.string.discussion) + "(" + i2 + ")" + commentSizeChange(i2) + } + viewBinding.recyclerView.adapter = adapter } } override fun onFailure(e: Exception) { DebugHelper.printLog(key, "加载失败", isError = true) if (useLinearProgressIndicator) { - viewBinding.linearProgressIndicator.isVisible = false + viewBinding.linearProgressIndicator.visibility = View.INVISIBLE } viewBinding.titleView.text = getString(R.string.discussion) viewBinding.recyclerView.isVisible = false diff --git a/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt b/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt index a37b105..1a40716 100644 --- a/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt +++ b/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt @@ -347,15 +347,9 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio */ private fun initRes() { try { - val language = Locale.getDefault().language - DebugHelper.printLog("初始化资源", "语言" + language) - if (language == "zh") { - unzipDataSet("dataBase.rdb", true) - unzipDataSet("dataBase_en.rdb") - } else { - unzipDataSet("dataBase.rdb") - unzipDataSet("dataBase_en.rdb", true) - } +// val language = Locale.getDefault().language +// DebugHelper.printLog("初始化资源", "语言" + language) + unzipDataSet("dataBase_v2.2.0.rdb", true) val defaultValues = File(context.filesDir.absolutePath + "/values.json") if (!defaultValues.exists()) { @@ -368,7 +362,7 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio } catch (e: Exception) { e.printStackTrace() } - importingTemplatePackage("baseTemplate.rp") + importingTemplatePackage("baseTemplate_v2.0.rp") } diff --git a/app/src/main/res/layout/activity_edit_mod_info.xml b/app/src/main/res/layout/activity_edit_mod_info.xml index 67fee17..bfe0fae 100644 --- a/app/src/main/res/layout/activity_edit_mod_info.xml +++ b/app/src/main/res/layout/activity_edit_mod_info.xml @@ -51,9 +51,9 @@ + android:layout_height="wrap_content" + android:layout_marginLeft="8dp"> - @@ -260,12 +261,14 @@ android:text="@string/add" /> diff --git a/app/src/main/res/layout/database_item.xml b/app/src/main/res/layout/database_item.xml index cf32f64..02ce9e0 100644 --- a/app/src/main/res/layout/database_item.xml +++ b/app/src/main/res/layout/database_item.xml @@ -33,12 +33,12 @@ style="@style/TextAppearance.Material3.BodySmall"/>