diff --git a/app/build.gradle b/app/build.gradle index 8511155..640390f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { minSdkVersion 23 targetSdkVersion 33 versionCode 28 - versionName "2.1.1 Bata6(2024-2-17)" + versionName "2.1.1 Bata6(2024-4-18)" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c295d67..5386758 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,6 +43,8 @@ + + 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 32e1a38..286504b 100644 --- a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt @@ -1,6 +1,5 @@ package com.coldmint.rust.pro - import android.content.Intent import android.content.pm.PackageInfo import android.content.pm.PackageManager @@ -27,7 +26,6 @@ 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.AppOperator -import com.coldmint.rust.core.tool.DebugHelper import com.coldmint.rust.core.tool.FileOperator import com.coldmint.rust.core.web.AppUpdate import com.coldmint.rust.core.web.ServerConfiguration @@ -42,12 +40,12 @@ import com.google.android.material.color.DynamicColors import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.snackbar.Snackbar import com.google.gson.Gson -//import com.gyf.immersionbar.ImmersionBar import org.json.JSONObject import java.io.File import java.util.concurrent.Executors import java.util.zip.ZipEntry + class MainActivity : BaseActivity() { private lateinit var appBarConfiguration: AppBarConfiguration @@ -293,13 +291,13 @@ class MainActivity : BaseActivity() { false }*/ -/* template.setOnMenuItemClickListener { - viewBinding.mainButton.postOnAnimationDelayed({ -// viewBinding.tabLayout.isVisible = true - viewBinding.mainButton.show() - }, hideViewDelay) - false - }*/ + /* template.setOnMenuItemClickListener { + viewBinding.mainButton.postOnAnimationDelayed({ + // viewBinding.tabLayout.isVisible = true + viewBinding.mainButton.show() + }, hideViewDelay) + false + }*/ codeTable.setOnMenuItemClickListener { startActivity(Intent(this@MainActivity, CodeTableActivity::class.java)) @@ -628,13 +626,13 @@ class MainActivity : BaseActivity() { return true } -/*不知道干什么的代码 - override fun onSupportNavigateUp(): Boolean { - val navController = findNavController(R.id.baseFragment) - return navController.navigateUp(appBarConfiguration) - || super.onSupportNavigateUp() - } -*/ + /*不知道干什么的代码 + override fun onSupportNavigateUp(): Boolean { + val navController = findNavController(R.id.baseFragment) + return navController.navigateUp(appBarConfiguration) + || super.onSupportNavigateUp() + } + */ override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == R.id.search) { @@ -755,6 +753,4 @@ class MainActivity : BaseActivity() { startViewModel.initAllData() } } - - } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt b/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt index 20814e3..134d455 100644 --- a/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt @@ -46,7 +46,7 @@ class SearchActivity : BaseActivity() { viewBinding.hotSearchView2.layoutManager = FlexboxLayoutManager(this) viewBinding.hotSearchView2.adapter = adapter viewBinding.deleat.setOnClickListener { - val dialog = MaterialAlertDialogBuilder(this@SearchActivity); + val dialog = MaterialAlertDialogBuilder(this@SearchActivity) dialog.setTitle(R.string.search_history) dialog.setMessage(R.string.clear_all_history) dialog.setPositiveButton(R.string.dialog_ok) { _, _ -> @@ -87,6 +87,9 @@ class SearchActivity : BaseActivity() { val editor = getSharedPreferences(sharedPreferencesKey, Context.MODE_PRIVATE).edit() editor.putStringSet("data", list.toSet()) editor.apply() + if (!viewBinding.searchView.isVisible) { + viewBinding.searchLayout.isVisible = true + } } fun search(string: String) { @@ -128,7 +131,7 @@ class SearchActivity : BaseActivity() { override fun getItemCount(): Int { val empty = list.isEmpty() - viewBinding.textview1Text1.isVisible = empty + viewBinding.searchLayout.isVisible = !empty viewBinding.deleat.isVisible = !empty return list.size } diff --git a/app/src/main/java/com/coldmint/rust/pro/TurretDesignActivity.kt b/app/src/main/java/com/coldmint/rust/pro/TurretDesignActivity.kt index 681e818..de49936 100644 --- a/app/src/main/java/com/coldmint/rust/pro/TurretDesignActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/TurretDesignActivity.kt @@ -2,19 +2,22 @@ package com.coldmint.rust.pro import android.annotation.SuppressLint import android.os.Bundle -import android.text.Editable -import android.text.TextWatcher -import android.view.* +import android.view.KeyEvent +import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuItem import android.widget.Toast +import androidx.recyclerview.widget.LinearLayoutManager import com.coldmint.dialog.CoreDialog import com.coldmint.rust.core.ModClass import com.coldmint.rust.core.SourceFile +import com.coldmint.rust.core.turret.CoordinateData import com.coldmint.rust.core.turret.TurretManager +import com.coldmint.rust.pro.adapters.DesignAdapter import com.coldmint.rust.pro.base.BaseActivity import com.coldmint.rust.pro.databinding.ActivityTurretDesignBinding import com.coldmint.rust.pro.fragments.EditTurretInfoFragment import com.coldmint.rust.pro.tool.GlobalMethod -import com.google.android.material.snackbar.Snackbar import java.io.File /** @@ -24,34 +27,30 @@ class TurretDesignActivity : BaseActivity() { private lateinit var turretManager: TurretManager - @SuppressLint("RestrictedApi") + @SuppressLint("RestrictedApi", "SetTextI18n") override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { if (canUseView) { setReturnButton() title = getString(R.string.turret_design) val modPath = intent.getStringExtra("modPath") val filePath = intent.getStringExtra("filePath") - if (modPath == null) { showError("请设置模组路径") return } - if (filePath == null) { showError("请设置文件路径") return } - val modClass = ModClass(File(modPath)) val sourceFile = SourceFile(File(filePath), modClass) val mainImage = sourceFile.findResourceFilesFromSection("image", "graphics", false) if (mainImage.isNullOrEmpty()) { - showError(getString(R.string.please_set_main_image)) return } else { val file = mainImage[0] - if (!file.exists()){ + if (!file.exists()) { showError(getString(R.string.file_not_exist)) return } @@ -59,59 +58,64 @@ class TurretDesignActivity : BaseActivity() { viewBinding.turretSketchpadView.setImage(file.absolutePath) turretManager = sourceFile.getTurretManager() turretManager.installerAllTurret( - viewBinding.frameLayout, - viewBinding.turretSketchpadView + viewBinding.frameLayout, + viewBinding.turretSketchpadView ) turretManager - .setCoordinateChangeListener { gameCoordinateData, turretData -> - viewBinding.infoView.text = - "x:${gameCoordinateData.x} y:${gameCoordinateData.y}" - } + .setCoordinateChangeListener { gameCoordinateData, _ -> + viewBinding.infoView.text = + "x:${gameCoordinateData.x} y:${gameCoordinateData.y}" + } //设置自动完成 - viewBinding.autoCompleteText.addTextChangedListener(object : TextWatcher { - override fun beforeTextChanged( - s: CharSequence?, - start: Int, - count: Int, - after: Int - ) { - } - - override fun onTextChanged( - s: CharSequence?, - start: Int, - before: Int, - count: Int - ) { - - } - - override fun afterTextChanged(s: Editable?) { - turretManager.useTurret(s.toString()) - } - - }) val nameList = ArrayList() var isFirst = true + val designAdapter = DesignAdapter(object : DesignAdapter.Click { + override fun onclick(str: String) { + turretManager.useTurret(str) + turretManager.turretList.forEach lab@{ + if (it.name == str) { + viewBinding.infoView.text = + "x:${it.gameCoordinateData.x} y:${it.gameCoordinateData.y}" + return@lab + } + } + } + + override fun onclickImage() { + turretManager.turretList.forEach{ + val turretView = turretManager.getTurretView(it.name) + turretView?.invalidate() + } + } + }) turretManager.turretList.forEach { if (isFirst) { - viewBinding.autoCompleteText.setText(it.name) + designAdapter.string = it + turretManager.useTurret(it.name) + viewBinding.infoView.text = + "x:${it.gameCoordinateData.x} y:${it.gameCoordinateData.y}" isFirst = false } nameList.add(it.name) } - viewBinding.autoCompleteText.setSimpleItems(nameList.toTypedArray()) +// viewBinding.autoCompleteText.setSimpleItems(nameList.toTypedArray()) + viewBinding.recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false) + viewBinding.recyclerView.isNestedScrollingEnabled = false + designAdapter.list = turretManager.turretList - - } - - viewBinding.button.setOnClickListener { - val data = turretManager.getTurretView(viewBinding.autoCompleteText.text.toString()) - if (data != null) { - val editTurretInfoFragment = EditTurretInfoFragment(data) - editTurretInfoFragment.show(supportFragmentManager, "Edit") - } else { - Toast.makeText(this, R.string.not_find_turret, Toast.LENGTH_SHORT).show() + viewBinding.recyclerView.adapter = designAdapter + viewBinding.button.setOnClickListener { + val data = turretManager.getTurretView(designAdapter.string.name) + if (data != null) { + val editTurretInfoFragment = EditTurretInfoFragment(data,object :EditTurretInfoFragment.ButtonClick{ + override fun onSaveButtonClick(x: Int, y: Int) { + viewBinding.infoView.text = "x:$x y:$y" + } + }) + editTurretInfoFragment.show(supportFragmentManager, "Edit") + } else { + Toast.makeText(this, R.string.not_find_turret, Toast.LENGTH_SHORT).show() + } } } } @@ -131,10 +135,10 @@ class TurretDesignActivity : BaseActivity() { //如果不建议显示,且正在显示那么提示用户 if (viewBinding.turretSketchpadView.drawCoordinate) { CoreDialog(this).setTitle(R.string.turret_design) - .setMessage(R.string.automatically_disable_coordinate_system) - .setPositiveButton(R.string.dialog_ok) { + .setMessage(R.string.automatically_disable_coordinate_system) + .setPositiveButton(R.string.dialog_ok) { - }.show() + }.show() viewBinding.turretSketchpadView.drawCoordinate = false } item.isEnabled = false @@ -155,7 +159,7 @@ class TurretDesignActivity : BaseActivity() { /** * 保存数据 */ - fun saveData() { + private fun saveData() { turretManager.saveChange() finish() } @@ -164,14 +168,16 @@ class TurretDesignActivity : BaseActivity() { when (item.itemId) { R.id.display_coordinate_system -> { viewBinding.turretSketchpadView.drawCoordinate = - !viewBinding.turretSketchpadView.drawCoordinate + !viewBinding.turretSketchpadView.drawCoordinate item.isChecked = viewBinding.turretSketchpadView.drawCoordinate } + R.id.show_guides -> { viewBinding.turretSketchpadView.drawAuxiliaryLine = - !viewBinding.turretSketchpadView.drawAuxiliaryLine + !viewBinding.turretSketchpadView.drawAuxiliaryLine item.isChecked = viewBinding.turretSketchpadView.drawAuxiliaryLine } + android.R.id.home -> { saveData() } diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/CommunityAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/CommunityAdapter.kt index c84aa0f..cddfb9a 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/CommunityAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/CommunityAdapter.kt @@ -1,9 +1,13 @@ package com.coldmint.rust.pro.adapters -import android.os.Parcelable +import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.viewpager2.adapter.FragmentStateAdapter -import com.coldmint.rust.pro.fragments.* +import com.coldmint.rust.pro.fragments.FollowFragment +import com.coldmint.rust.pro.fragments.NullFragment +import com.coldmint.rust.pro.fragments.RankingFragment +import com.coldmint.rust.pro.fragments.RecommendedFragment +import com.coldmint.rust.pro.fragments.UserInfoFragment class CommunityAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) { override fun getItemCount(): Int { diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/DesignAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/DesignAdapter.kt new file mode 100644 index 0000000..e6e8ad2 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/DesignAdapter.kt @@ -0,0 +1,71 @@ +package com.coldmint.rust.pro.adapters + +import android.annotation.SuppressLint +import android.util.TypedValue +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.RecyclerView +import com.coldmint.rust.core.turret.TurretData +import com.coldmint.rust.pro.R +import com.coldmint.rust.pro.databinding.ItemTabBinding +import com.muqing.VH +import com.muqing.gj + +/** + * @author Cold Mint + * @date 2022/1/10 8:49 + */ +class DesignAdapter(private val onclick: Click) : RecyclerView.Adapter>() { + + var list: ArrayList = arrayListOf() + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { + return VH(ItemTabBinding.inflate(LayoutInflater.from(parent.context), parent, false)) + } + + override fun getItemCount(): Int { + return list.size + } + + lateinit var string: TurretData + + @SuppressLint("NotifyDataSetChanged") + override fun onBindViewHolder(holder: VH, position: Int) { + holder.binging.button.text = list[position].name + gj.sc(list[position].imageFile) + + if (string == list[position]) { + holder.binging.root.isEnabled = false + holder.binging.root.setCardBackgroundColor(ContextCompat.getColor(holder.itemView.context, R.color.material_grey_200)) + } else { + holder.binging.root.isEnabled = true + val typedValue = TypedValue() + holder.itemView.context.theme.resolveAttribute(R.attr.colorPrimaryContainer, typedValue, true) + val colorPrimary = typedValue.data + holder.binging.root.setCardBackgroundColor(colorPrimary) + + } + holder.binging.root.setOnClickListener { + string = list[holder.absoluteAdapterPosition] + notifyDataSetChanged() + onclick.onclick(string.name) + //todo + } + if (list[holder.absoluteAdapterPosition].isImage) { + holder.binging.imageview.setImageResource(R.drawable.visibility) + }else{ + holder.binging.imageview.setImageResource(R.drawable.visibility_off) + } + holder.binging.imageview.setOnClickListener{ + list[holder.absoluteAdapterPosition].isImage = !list[holder.absoluteAdapterPosition].isImage + notifyItemChanged(holder.absoluteAdapterPosition) + onclick.onclickImage() + } + } + interface Click { + fun onclick(str: String) + fun onclickImage() + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/WarehouseAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/WarehouseAdapter.kt index 58f8cdd..136e9fd 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/WarehouseAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/WarehouseAdapter.kt @@ -1,5 +1,6 @@ package com.coldmint.rust.pro.adapters +import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.viewpager2.adapter.FragmentStateAdapter import com.coldmint.rust.pro.fragments.* diff --git a/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt b/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt index 2a778c6..70cff2c 100644 --- a/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt @@ -56,7 +56,6 @@ abstract class BaseActivity : finish() } dialog.show() - } } diff --git a/app/src/main/java/com/coldmint/rust/pro/dialog/CommentDialog.kt b/app/src/main/java/com/coldmint/rust/pro/dialog/CommentDialog.kt index 83eac84..c3657a9 100644 --- a/app/src/main/java/com/coldmint/rust/pro/dialog/CommentDialog.kt +++ b/app/src/main/java/com/coldmint/rust/pro/dialog/CommentDialog.kt @@ -4,20 +4,13 @@ import android.R import android.content.Context import android.text.Editable import android.text.TextWatcher -import android.util.Log import android.view.* import android.widget.ArrayAdapter import android.widget.Button import androidx.appcompat.app.AlertDialog -import androidx.core.view.isVisible -import com.coldmint.dialog.AppDialog import com.coldmint.dialog.BaseAppDialog -import com.coldmint.dialog.BaseBottomDialog -import com.coldmint.dialog.InputDialog import com.coldmint.rust.pro.databinding.DialogCommentBinding -import com.coldmint.rust.pro.tool.LinkAutoCompleteHelper import com.coldmint.rust.pro.tool.TextStyleMaker -import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.textfield.TextInputLayout @@ -68,7 +61,7 @@ class CommentDialog(context: Context) : BaseAppDialog(context) { //已闭合{}。 }else{ //正在输入内容 - adapter.add(text + '}') + adapter.add("$text}") } } else { //没有指定{开始位置 diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt index 496da83..2fc7c87 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt @@ -2,6 +2,7 @@ package com.coldmint.rust.pro.fragments import android.os.Bundle import android.view.LayoutInflater +import androidx.viewpager2.widget.ViewPager2 import com.coldmint.rust.pro.R import com.coldmint.rust.pro.adapters.CommunityAdapter import com.coldmint.rust.pro.base.BaseFragment @@ -13,26 +14,6 @@ class CommunityFragment : BaseFragment() { if (!isAdded) { return } - TabLayoutMediator(viewBinding.tabLayout, viewBinding.pager) - { tab, position -> - when (position) { - 0 -> { - tab.text = getText(R.string.recommended) - } - - 1 -> { - tab.text = getText(R.string.follow) - } - - 2 -> { - tab.text = getText(R.string.ranking) - } - - 3 -> { - tab.text = getText(R.string.my) - } - } - }.attach() /* else { viewBinding.pager.postDelayed({ loadTab() }, MainActivity.linkInterval) }*/ @@ -46,6 +27,43 @@ class CommunityFragment : BaseFragment() { override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { viewBinding.pager.adapter = CommunityAdapter(this) viewBinding.pager.isSaveEnabled = false + viewBinding.pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { + override fun onPageSelected(position: Int) { + when (position) { + 0 -> { + viewBinding.bottomnavigationView.selectedItemId = R.id.action_recommended + } + 1 -> { + viewBinding.bottomnavigationView.selectedItemId = R.id.action_follow + } + 2 -> { + viewBinding.bottomnavigationView.selectedItemId = R.id.action_ranking + } + 3 -> { + viewBinding.bottomnavigationView.selectedItemId = R.id.action_my + } + } + } + }) + viewBinding.bottomnavigationView.setOnItemSelectedListener { + when (it.itemId) { + R.id.action_recommended -> { + viewBinding.pager.currentItem = 0 + } + R.id.action_follow -> { + viewBinding.pager.currentItem = 1 + } + R.id.action_ranking -> { + viewBinding.pager.currentItem = 2 + } + R.id.action_my -> { + viewBinding.pager.currentItem = 3 + } + } + true + } + + loadTab() } } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/EditTurretInfoFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/EditTurretInfoFragment.kt index bc3ad98..d1e2645 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/EditTurretInfoFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/EditTurretInfoFragment.kt @@ -7,27 +7,24 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.coldmint.rust.core.turret.CoordinateData -import com.coldmint.rust.core.turret.TurretData import com.coldmint.rust.core.turret.TurretView import com.coldmint.rust.pro.R -import com.coldmint.rust.pro.base.BaseFragment import com.coldmint.rust.pro.databinding.FragmentEditTurretInfoBinding -import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment /** * 编辑炮塔信息碎片 * @property fragmentEditTurretInfoBinding FragmentEditTurretInfoBinding */ -class EditTurretInfoFragment(val turretView: TurretView) : BottomSheetDialogFragment() { +class EditTurretInfoFragment(private val turretView: TurretView, private val buttonclick: ButtonClick) : BottomSheetDialogFragment() { private lateinit var fragmentEditTurretInfoBinding: FragmentEditTurretInfoBinding override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { fragmentEditTurretInfoBinding = - FragmentEditTurretInfoBinding.inflate(layoutInflater, container, false) + FragmentEditTurretInfoBinding.inflate(layoutInflater, container, false) return fragmentEditTurretInfoBinding.root } @@ -53,7 +50,7 @@ class EditTurretInfoFragment(val turretView: TurretView) : BottomSheetDialogFrag val text = s.toString() if (text.isBlank()) { fragmentEditTurretInfoBinding.xInputEditLayout.error = - getString(R.string.please_enter_the_x_coordinate) + getString(R.string.please_enter_the_x_coordinate) } else { fragmentEditTurretInfoBinding.xInputEditLayout.isErrorEnabled = false } @@ -73,7 +70,7 @@ class EditTurretInfoFragment(val turretView: TurretView) : BottomSheetDialogFrag val text = s.toString() if (text.isBlank()) { fragmentEditTurretInfoBinding.yInputEditLayout.error = - getString(R.string.please_enter_the_y_coordinate) + getString(R.string.please_enter_the_y_coordinate) } else { fragmentEditTurretInfoBinding.yInputEditLayout.isErrorEnabled = false } @@ -84,8 +81,12 @@ class EditTurretInfoFragment(val turretView: TurretView) : BottomSheetDialogFrag val x = fragmentEditTurretInfoBinding.xInputEditText.text.toString().toInt() val y = fragmentEditTurretInfoBinding.yInputEditText.text.toString().toInt() turretView.setGameCoordinateData(CoordinateData(x, y)) - + buttonclick.onSaveButtonClick(x, y) dialog?.dismiss() } } + + interface ButtonClick { + fun onSaveButtonClick(x: Int, y: Int) + } } \ No newline at end of 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 5b42ef1..b29759c 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 @@ -1,14 +1,9 @@ package com.coldmint.rust.pro.fragments import android.content.Intent -import android.os.Build import android.os.Bundle -import android.view.Gravity import android.view.LayoutInflater -import android.widget.PopupMenu -import android.widget.Toast import androidx.core.view.isVisible -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.coldmint.rust.core.dataBean.mod.WebModListData import com.coldmint.rust.core.interfaces.ApiCallBack @@ -20,14 +15,13 @@ import com.coldmint.rust.pro.adapters.WebModAdapter import com.coldmint.rust.pro.base.BaseFragment import com.coldmint.rust.pro.databinding.FragmentRankingBinding import com.coldmint.rust.pro.ui.StableLinearLayoutManager -import com.google.android.material.chip.Chip import me.zhanghai.android.fastscroll.FastScrollerBuilder /** * 排行榜 */ class RankingFragment : BaseFragment() { - var webModAdapter: WebModAdapter? = null + private var webModAdapter: WebModAdapter? = null var lastOffset = 0 var lastPosition = 0 var linearLayoutManager: StableLinearLayoutManager? = null @@ -39,7 +33,7 @@ class RankingFragment : BaseFragment() { viewBinding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) - var layoutManager = viewBinding.recyclerView.layoutManager + val layoutManager = viewBinding.recyclerView.layoutManager if (layoutManager != null) { //获取第一个可视视图 val topView = layoutManager.getChildAt(0) @@ -54,25 +48,25 @@ class RankingFragment : BaseFragment() { loadMods() viewBinding.swipeRefreshLayout.isRefreshing = false } - viewBinding.downloadChip.setOnCheckedChangeListener { buttonView, isChecked -> + viewBinding.downloadChip.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { sortMode = WebMod.SortMode.Download_Number loadMods() } } - viewBinding.unitChip.setOnCheckedChangeListener { buttonView, isChecked -> + viewBinding.unitChip.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { sortMode = WebMod.SortMode.Unit_Number loadMods() } } - viewBinding.coinChip.setOnCheckedChangeListener { buttonView, isChecked -> + viewBinding.coinChip.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { sortMode = WebMod.SortMode.Coin_Number loadMods() } } - viewBinding.updateChip.setOnCheckedChangeListener { buttonView, isChecked -> + viewBinding.updateChip.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { sortMode = WebMod.SortMode.Update_Number loadMods() @@ -82,7 +76,7 @@ class RankingFragment : BaseFragment() { } - fun loadMods() { + private fun loadMods() { viewBinding.progressBar.isVisible = true viewBinding.textview.isVisible = false viewBinding.swipeRefreshLayout.isVisible = false @@ -93,18 +87,18 @@ class RankingFragment : BaseFragment() { } if (t.code == ServerConfiguration.Success_Code) { val list = t.data - if (list != null && list.isNotEmpty()) { + if (!list.isNullOrEmpty()) { viewBinding.progressBar.isVisible = false viewBinding.textview.isVisible = false viewBinding.swipeRefreshLayout.isVisible = true val adapter = createAdapter(list) viewBinding.recyclerView.adapter = adapter linearLayoutManager?.scrollToPositionWithOffset( - lastPosition, - lastOffset + lastPosition, + lastOffset ) FastScrollerBuilder(viewBinding.recyclerView).useMd2Style() - .setPopupTextProvider(adapter).build() + .setPopupTextProvider(adapter).build() } else { showInfoToView(R.string.network_error) } @@ -134,7 +128,7 @@ class RankingFragment : BaseFragment() { webModAdapter!!.setNewDataList(dataList) webModAdapter!! } - adapter.setItemEvent { i, webModItemBinding, viewHolder, data -> + adapter.setItemEvent { _, webModItemBinding, _, data -> webModItemBinding.root.setOnClickListener { val bundle = Bundle() bundle.putString("modId", data.id) @@ -157,7 +151,7 @@ class RankingFragment : BaseFragment() { viewBinding.swipeRefreshLayout.isVisible = false viewBinding.textview.isVisible = true if (textRes == null) { - viewBinding.textview.setText(textRes) + viewBinding.textview.text = textRes } else { viewBinding.textview.text = text ?: "" } diff --git a/app/src/main/java/com/coldmint/rust/pro/viewmodel/EditViewModel.kt b/app/src/main/java/com/coldmint/rust/pro/viewmodel/EditViewModel.kt index 740b052..5f505ef 100644 --- a/app/src/main/java/com/coldmint/rust/pro/viewmodel/EditViewModel.kt +++ b/app/src/main/java/com/coldmint/rust/pro/viewmodel/EditViewModel.kt @@ -37,7 +37,7 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application */ var targetFile: File? = null - val codeTranslate by lazy { + private val codeTranslate by lazy { val c = CodeTranslate(getApplication()) c.setCompileErrorRecordFun { //将信息上传至FireBase @@ -70,6 +70,7 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application /** * 获取当前使用的apk包存放目录 */ + @Suppress("unused") val apkFolder by lazy { GameSynchronizer.getPackAgeFolder( getApplication(), AppSettings.getValue( @@ -97,12 +98,13 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application * @return String? */ fun getNowOpenFilePath(): String { - val temPath = nowFilePath +/* val temPath = nowFilePath return if (temPath == null) { "" } else { temPath - } + }*/ + return nowFilePath ?: "" } @@ -403,7 +405,7 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application Locale.getDefault().language ) ) + " (" + file.file.name + ")" - val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()) val historyDao = fileDataBase.getHistoryDao() val newHistoryRecord = HistoryRecord( path, diff --git a/app/src/main/java/com/muqing/VH.java b/app/src/main/java/com/muqing/VH.java new file mode 100644 index 0000000..6630666 --- /dev/null +++ b/app/src/main/java/com/muqing/VH.java @@ -0,0 +1,12 @@ +package com.muqing; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import androidx.viewbinding.ViewBinding; +public class VH extends RecyclerView.ViewHolder { + + public Binging binging; + public VH(@NonNull Binging itemView) { + super(itemView.getRoot()); + this.binging = itemView; + } +} diff --git a/app/src/main/java/com/muqing/gj.java b/app/src/main/java/com/muqing/gj.java index 3778df3..c90b353 100644 --- a/app/src/main/java/com/muqing/gj.java +++ b/app/src/main/java/com/muqing/gj.java @@ -20,7 +20,7 @@ import java.util.Collections; /** @noinspection unused*/ public class gj { - public static String log_TAB = "打印"; + public final static String log_TAB = "输出"; public static void ts(Context a, Object b) { Toast.makeText(a, b.toString(), Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/res/drawable/group.xml b/app/src/main/res/drawable/group.xml new file mode 100644 index 0000000..96df541 --- /dev/null +++ b/app/src/main/res/drawable/group.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/home.xml b/app/src/main/res/drawable/home.xml new file mode 100644 index 0000000..4c9b11e --- /dev/null +++ b/app/src/main/res/drawable/home.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/leaderboard.xml b/app/src/main/res/drawable/leaderboard.xml new file mode 100644 index 0000000..dc62f82 --- /dev/null +++ b/app/src/main/res/drawable/leaderboard.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/recommend.xml b/app/src/main/res/drawable/recommend.xml new file mode 100644 index 0000000..dd257f2 --- /dev/null +++ b/app/src/main/res/drawable/recommend.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/visibility.xml b/app/src/main/res/drawable/visibility.xml new file mode 100644 index 0000000..a517597 --- /dev/null +++ b/app/src/main/res/drawable/visibility.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/visibility_off.xml b/app/src/main/res/drawable/visibility_off.xml new file mode 100644 index 0000000..8776a81 --- /dev/null +++ b/app/src/main/res/drawable/visibility_off.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ecaddb9..9361d3c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,8 +4,8 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawerlayout" android:layout_width="match_parent" - android:fitsSystemWindows="false" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:fitsSystemWindows="false"> + card_view:ignore="UseCompoundDrawables" + android:layout_marginBottom="9dp"> - - + tools:context=".TurretDesignActivity"> + + + - - + android:layout_height="0dp" + app:layout_constraintBottom_toTopOf="@+id/cardView" + app:layout_constraintTop_toTopOf="parent"> - + app:cardUseCompatPadding="true" + app:layout_constraintBottom_toBottomOf="parent"> - - - - - - - - - - - - - - - + - - diff --git a/app/src/main/res/layout/fragment_community.xml b/app/src/main/res/layout/fragment_community.xml index 6b0d317..c4e13c9 100644 --- a/app/src/main/res/layout/fragment_community.xml +++ b/app/src/main/res/layout/fragment_community.xml @@ -1,15 +1,18 @@ - + android:layout_height="0dp" + android:layout_weight="1"/> + + diff --git a/app/src/main/res/layout/fragment_warehouse.xml b/app/src/main/res/layout/fragment_warehouse.xml index c6038cb..27f8c4a 100644 --- a/app/src/main/res/layout/fragment_warehouse.xml +++ b/app/src/main/res/layout/fragment_warehouse.xml @@ -4,11 +4,9 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> - - + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main_bottom.xml b/app/src/main/res/menu/menu_main_bottom.xml new file mode 100644 index 0000000..0414a37 --- /dev/null +++ b/app/src/main/res/menu/menu_main_bottom.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/main_viewpaper.xml b/app/src/main/res/navigation/main_viewpaper.xml new file mode 100644 index 0000000..870db0f --- /dev/null +++ b/app/src/main/res/navigation/main_viewpaper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretData.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretData.kt index a783be2..9afb2f6 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretData.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretData.kt @@ -8,8 +8,9 @@ import java.io.File * @constructor */ data class TurretData( - val name: String, - var gameCoordinateData: CoordinateData, - var scaleValue: Float = 1f, - var imageFile: File? = null + val name: String, + var gameCoordinateData: CoordinateData, + var scaleValue: Float = 1f, + var imageFile: File? = null, + var isImage: Boolean = true ) \ No newline at end of file diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretManager.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretManager.kt index 21ddf39..b35ca39 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretManager.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretManager.kt @@ -1,6 +1,5 @@ package com.coldmint.rust.core.turret -import android.util.Log import android.view.ViewGroup import com.coldmint.rust.core.SourceFile import com.coldmint.rust.core.debug.LogCat @@ -12,7 +11,7 @@ import java.io.File * 此类用于管理源文件内的炮塔数据 * @constructor */ -class TurretManager(val sourceFile: SourceFile) { +class TurretManager(private val sourceFile: SourceFile) { /** @@ -47,6 +46,7 @@ class TurretManager(val sourceFile: SourceFile) { } init { + turretList.clear() val allSection = sourceFile.allSection val size = allSection.size if (size > 0) { @@ -54,7 +54,7 @@ class TurretManager(val sourceFile: SourceFile) { sourceFile.findResourceFilesFromSection("image_turret", "graphics", false) var defaultImageFile: File? = null if (!defaultImageList.isNullOrEmpty()) { - defaultImageFile = defaultImageList.get(0) + defaultImageFile = defaultImageList[0] LogCat.d("炮塔管理器-默认图像", defaultImageFile.absolutePath) } allSection.forEach { @@ -65,17 +65,17 @@ class TurretManager(val sourceFile: SourceFile) { var x = 0 var y = 0 val xData = sourceFile.readValueFromSection("x", it) - if (xData != null && xData.isNotBlank()) { + if (!xData.isNullOrBlank()) { x = xData.toFloat().toInt() } val yData = sourceFile.readValueFromSection("y", it) - if (yData != null&& yData.isNotBlank()) { + if (!yData.isNullOrBlank()) { y = yData.toFloat().toInt() } val turretData = TurretData(name, CoordinateData(x, y)) val fileList = sourceFile.findResourceFilesFromSection("image", it, false) if (!fileList.isNullOrEmpty()) { - val file = fileList.get(0) + val file = fileList[0] turretData.imageFile = file LogCat.d("炮塔管理器-$name", "设置炮塔图像" + file.absolutePath) } else { @@ -153,7 +153,7 @@ class TurretManager(val sourceFile: SourceFile) { * @param frameLayout FrameLayout * @param sourceFile SourceFile */ - fun installerTurret( + private fun installerTurret( viewGroup: ViewGroup, turretData: TurretData, turretSketchpadView: TurretSketchpadView diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretSketchpadView.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretSketchpadView.kt index 20d575c..7cf7bab 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretSketchpadView.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretSketchpadView.kt @@ -1,13 +1,10 @@ package com.coldmint.rust.core.turret +import android.annotation.SuppressLint import android.content.Context import android.graphics.* import android.util.AttributeSet -import android.util.Log import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import android.widget.RelativeLayout import com.coldmint.rust.core.R import com.coldmint.rust.core.debug.LogCat @@ -15,10 +12,9 @@ import com.coldmint.rust.core.debug.LogCat * 炮塔画板 * @constructor */ +@SuppressLint("CustomViewStyleable") class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null) : View(context, attributeSet) { - - companion object { /** * 缩放图像 @@ -37,8 +33,8 @@ class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null) bitmap, 0, 0, - bitmap.getWidth(), - bitmap.getHeight(), + bitmap.width, + bitmap.height, matrix, true ) @@ -268,6 +264,17 @@ class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null) canvas.drawBitmap(temBitmap, startX.toFloat(), startY.toFloat(), paint) temBitmap.recycle() } +/* val canvasWidth = width.toFloat() + val canvasHeight = height.toFloat() + val bitmapW = bitmap.width + val bitmapH = bitmap.height + + // 计算图像要在画布上居中的坐标 + val centerX = (canvasWidth - bitmapW) / 2 + val centerY = (canvasHeight - bitmapH) / 2 + // 绘制居中位图 + canvas.drawBitmap(bitmap, centerX, centerY, paint) + bitmap.recycle()*/ } override fun onDraw(canvas: Canvas?) { diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretView.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretView.kt index a6f369e..db6e2e6 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretView.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretView.kt @@ -3,16 +3,12 @@ package com.coldmint.rust.core.turret import android.annotation.SuppressLint import android.content.Context import android.graphics.Bitmap -import android.graphics.Bitmap.createBitmap import android.graphics.BitmapFactory import android.graphics.Canvas import android.graphics.Paint import android.util.AttributeSet -import android.util.Log import android.view.MotionEvent import android.view.View -import android.widget.Toast -import com.coldmint.rust.core.R import com.coldmint.rust.core.debug.LogCat /** @@ -20,7 +16,7 @@ import com.coldmint.rust.core.debug.LogCat * @constructor */ class TurretView(context: Context, attributeSet: AttributeSet? = null) : - View(context, attributeSet) { + View(context, attributeSet) { private var debugKey = "炮塔视图" private lateinit var turretData: TurretData @@ -104,7 +100,7 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) : * 设置炮塔坐标数据 * @param coordinateData */ - fun setTurretGameCoordinateData(coordinateData: CoordinateData) { + private fun setTurretGameCoordinateData(coordinateData: CoordinateData) { if (this::turretData.isInitialized) { turretData.gameCoordinateData = coordinateData } @@ -116,6 +112,7 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) : * @param event MotionEvent * @return Boolean 返回true已被处理 */ + @SuppressLint("ClickableViewAccessibility") override fun onTouchEvent(event: MotionEvent?): Boolean { if (event != null) { val action = event.action @@ -123,6 +120,7 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) : MotionEvent.ACTION_DOWN -> { return canDrag } + MotionEvent.ACTION_MOVE -> { LogCat.d(debugKey, "收到移动${turretData.name} 可拖动状态${canDrag}") if (canDrag) { @@ -144,6 +142,10 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) : @SuppressLint("DrawAllocation") override fun onDraw(canvas: Canvas?) { super.onDraw(canvas) + if (!turretData.isImage) { + //不可显示图像 + return + } if (this::turretData.isInitialized) { if (turretSketchpadView == null) { LogCat.e(debugKey, "未绑定画板,停止绘制。") @@ -159,20 +161,23 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) : LogCat.e(debugKey, "无法加载炮塔图像。") return } else { - if (turretData.scaleValue != 1f) { - bitmap = TurretSketchpadView.scaleBitmap( - bitmap, turretData.scaleValue - ) - } + /* if (turretData.scaleValue != 1f) { + bitmap = TurretSketchpadView.scaleBitmap( + bitmap, turretData.scaleValue + ) + }*/ + bitmap = TurretSketchpadView.scaleBitmap( + bitmap, 10F + ) val androidCoordinate = - turretSketchpadView!!.toAndroidCoordinate(turretData.gameCoordinateData) + turretSketchpadView!!.toAndroidCoordinate(turretData.gameCoordinateData) bitmapW = bitmap!!.width - bitmapH = bitmap!!.height + bitmapH = bitmap.height canvas?.drawBitmap( - bitmap, - (androidCoordinate.x - bitmapW / 2).toFloat(), - (androidCoordinate.y - bitmapH / 2).toFloat(), - paint + bitmap, + (androidCoordinate.x - bitmapW / 2).toFloat(), + (androidCoordinate.y - bitmapH / 2).toFloat(), + paint ) if (!bitmap.isRecycled) { bitmap.recycle() diff --git a/dialog/src/main/java/com/coldmint/dialog/BaseBottomDialog.kt b/dialog/src/main/java/com/coldmint/dialog/BaseBottomDialog.kt index a9a497c..7254ebc 100644 --- a/dialog/src/main/java/com/coldmint/dialog/BaseBottomDialog.kt +++ b/dialog/src/main/java/com/coldmint/dialog/BaseBottomDialog.kt @@ -1,12 +1,8 @@ package com.coldmint.dialog import android.content.Context -import android.os.Bundle import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup -import androidx.appcompat.app.AlertDialog -import androidx.fragment.app.DialogFragment import androidx.viewbinding.ViewBinding import com.google.android.material.bottomsheet.BottomSheetDialog