1.修复近期收集的严重崩溃问题。2.调整全部页面仅竖屏显示。3.优化弹出菜单的样式适配M3。4.调整默认编辑框颜色。5.优化搜索结果页面的显示。6.解决替换文本崩溃的问题。

This commit is contained in:
Cold-Mint 2023-01-26 16:07:55 +08:00
parent c8f45509c4
commit 7dd6e16c49
44 changed files with 251 additions and 196 deletions

Binary file not shown.

View File

@ -26,19 +26,24 @@
android:usesCleartextTraffic="true">
<activity
android:name=".FeedbackActivity"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ChangePasswordActivity"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".NetworkTemplatePackageDetailsActivity"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".CustomizeEditTextActivity"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".SearchActivity"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<provider
android:name="androidx.core.content.FileProvider"

View File

@ -325,6 +325,7 @@ class CustomizeEditTextActivity : BaseActivity<ActivityCustomizeEditTextBinding>
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
showSaveDialogIfNeed()
return true
}
return super.onOptionsItemSelected(item)
}

View File

@ -265,7 +265,7 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
}
}
tab.view.setOnLongClickListener {
val popupMenu = PopupMenu(this@EditActivity, it)
val popupMenu = GlobalMethod.createPopMenu(it)
popupMenu.menu.add(R.string.open_directory_of_file)
if (viewModel.openedSourceFileListLiveData.value.size > 1) {
popupMenu.menu.add(R.string.close)
@ -514,7 +514,7 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
private fun initStartView() {
editStartBinding.fileList.layoutManager = LinearLayoutManager(this)
editStartBinding.fab.setOnClickListener {
val popupMenu = PopupMenu(this@EditActivity, editStartBinding.fab)
val popupMenu = GlobalMethod.createPopMenu(editStartBinding.fab)
if (fileAdapter != null) {
val selectPath = fileAdapter!!.selectPath
if (selectPath != null) {
@ -686,7 +686,7 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
if (file == null) {
return@setOnClickListener
}
val popupMenu = PopupMenu(this@EditActivity, it)
val popupMenu = GlobalMethod.createPopMenu(it)
val cutBoardMenu = popupMenu.menu.addSubMenu(R.string.cut_board_operation)
val fileMenu = popupMenu.menu.addSubMenu(R.string.file_operation)
val bookmarksMenu = popupMenu.menu.addSubMenu(R.string.mine_bookmarks)
@ -1272,9 +1272,9 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
R.id.display_source_code -> {
val file = File(viewModel.getNowOpenFilePath())
val code = FileOperator.readFile(file)
MaterialAlertDialogBuilder(this).setTitle(file.name).setMessage(code).setNegativeButton(R.string.dialog_ok){
i,i2->
}.setCancelable(false).show()
MaterialAlertDialogBuilder(this).setTitle(file.name).setMessage(code)
.setNegativeButton(R.string.dialog_ok) { i, i2 ->
}.setCancelable(false).show()
}
R.id.clear_code_cache -> {
Snackbar.make(
@ -1298,9 +1298,9 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
).show()
}
}
R.id.code_navigation -> {
// R.id.code_navigation -> {
// viewModel.executorService.submit {
// val labels = viewBinding.codeEditor.textAnalyzeResult.navigation
// val labels = viewBinding.codeEditor..navigation
// if (labels == null || labels.size == 0) {
// runOnUiThread {
// Snackbar.make(
@ -1342,7 +1342,7 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
// }
// }
// }
}
// }
R.id.save_text -> {
val openedSourceFile =
viewModel.openedSourceFileListLiveData.getOpenedSourceFile(viewBinding.tabLayout.selectedTabPosition)
@ -1395,7 +1395,7 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
viewBinding.searchLayout.isVisible = true
viewBinding.allButton.isVisible = false
viewBinding.replaceEditText.setText("")
viewBinding.replaceEditText.isVisible = false
viewBinding.replaceLayout.isVisible = false
viewBinding.findEditText.setText("")
}
}
@ -1413,31 +1413,48 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
}
viewBinding.nextButton.setOnClickListener {
val find = viewBinding.findEditText.text.toString()
viewBinding.codeEditor.searcher.search(find, EditorSearcher.SearchOptions(false, false))
viewBinding.codeEditor.searcher.gotoNext()
if (find.isNotBlank()) {
viewBinding.codeEditor.searcher.search(
find,
EditorSearcher.SearchOptions(false, false)
)
viewBinding.codeEditor.searcher.gotoNext()
}
}
viewBinding.lastButton.setOnClickListener {
val find = viewBinding.findEditText.text.toString()
viewBinding.codeEditor.searcher.search(find, EditorSearcher.SearchOptions(false, false))
viewBinding.codeEditor.searcher.gotoPrevious()
if (find.isNotBlank()) {
viewBinding.codeEditor.searcher.search(
find,
EditorSearcher.SearchOptions(false, false)
)
viewBinding.codeEditor.searcher.gotoPrevious()
}
}
viewBinding.allButton.setOnClickListener {
val find = viewBinding.findEditText.text.toString()
val re = viewBinding.replaceEditText.text.toString()
viewBinding.codeEditor.searcher.search(find, EditorSearcher.SearchOptions(false, false))
viewBinding.codeEditor.searcher.replaceAll(re)
if (find.isNotBlank() && re.isNotBlank()) {
viewBinding.codeEditor.searcher.search(
find,
EditorSearcher.SearchOptions(false, false)
)
viewBinding.codeEditor.searcher.replaceAll(re)
}
}
viewBinding.replaceButton.setOnClickListener {
val isVisible = viewBinding.replaceLayout.isVisible
if (isVisible) {
val find = viewBinding.findEditText.text.toString()
val re = viewBinding.replaceEditText.text.toString()
viewBinding.codeEditor.searcher.search(
find,
EditorSearcher.SearchOptions(false, false)
)
viewBinding.codeEditor.searcher.replaceThis(re)
if (find.isNotBlank() && re.isNotBlank()) {
viewBinding.codeEditor.searcher.search(
find,
EditorSearcher.SearchOptions(false, false)
)
viewBinding.codeEditor.searcher.replaceThis(re)
viewBinding.codeEditor.searcher.gotoNext()
}
} else {
viewBinding.replaceLayout.isVisible = true
viewBinding.allButton.isVisible = true

View File

@ -262,7 +262,7 @@ class EditModInfoActivity : BaseActivity<ActivityEditModInfoBinding>() {
}
viewBinding.iconView.setOnClickListener {
val popupMenu = PopupMenu(this@EditModInfoActivity, viewBinding.iconView)
val popupMenu = GlobalMethod.createPopMenu(it)
if (mNeedIcon) {
popupMenu.menu.add(R.string.change_image)
popupMenu.menu.add(R.string.del_image)

View File

@ -149,7 +149,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
})
viewBinding.iconView.setOnClickListener {
val popupMenu = PopupMenu(this, viewBinding.iconView)
val popupMenu = GlobalMethod.createPopMenu(it)
popupMenu.menu.add(R.string.from_url)
if (needIcon) {
popupMenu.menu.add(R.string.change_image)
@ -168,18 +168,18 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
startIntent.putExtra("data", fileBundle)
startActivityForResult(startIntent, 1)
} else if (title == getString(R.string.from_url)) {
InputDialog(this).setTitle(R.string.from_url).setMessage(R.string.from_url_tip).setErrorTip { s, textInputLayout ->
if (s.matches(Regex("^http://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$|^https://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$"))) {
textInputLayout.error = getString(R.string.from_url_tip)
} else {
textInputLayout.isErrorEnabled = false
}
}.setPositiveButton(R.string.dialog_ok){
input->
InputDialog(this).setTitle(R.string.from_url).setMessage(R.string.from_url_tip)
.setErrorTip { s, textInputLayout ->
if (s.matches(Regex("^http://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$|^https://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$"))) {
textInputLayout.error = getString(R.string.from_url_tip)
} else {
textInputLayout.isErrorEnabled = false
}
}.setPositiveButton(R.string.dialog_ok) { input ->
needCleanCache = true
loadIcon(input)
true
}.setNegativeButton(R.string.dialog_close){
}.setNegativeButton(R.string.dialog_close) {
}.show()
} else {
@ -195,7 +195,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
}
viewBinding.coverView.setOnClickListener {
val popupMenu = PopupMenu(this, viewBinding.coverView)
val popupMenu = GlobalMethod.createPopMenu(it)
popupMenu.menu.add(R.string.from_url)
if (needCover) {
popupMenu.menu.add(R.string.change_image)
@ -214,18 +214,18 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
startIntent.putExtra("data", fileBundle)
startActivityForResult(startIntent, 2)
} else if (title == getString(R.string.from_url)) {
InputDialog(this).setTitle(R.string.from_url).setMessage(R.string.from_url_tip).setErrorTip { s, textInputLayout ->
if (s.matches(Regex("^http://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$|^https://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$"))) {
textInputLayout.error = getString(R.string.from_url_tip)
} else {
textInputLayout.isErrorEnabled = false
}
}.setPositiveButton(R.string.dialog_ok){
input->
InputDialog(this).setTitle(R.string.from_url).setMessage(R.string.from_url_tip)
.setErrorTip { s, textInputLayout ->
if (s.matches(Regex("^http://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$|^https://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$"))) {
textInputLayout.error = getString(R.string.from_url_tip)
} else {
textInputLayout.isErrorEnabled = false
}
}.setPositiveButton(R.string.dialog_ok) { input ->
needCleanCache = true
loadCover(input)
true
}.setNegativeButton(R.string.dialog_close){
}.setNegativeButton(R.string.dialog_close) {
}.show()
@ -341,6 +341,14 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
val type = FileOperator.getFileType(newIconFile)
if (type == "png" || type == "jpg") {
val bitmap = BitmapFactory.decodeFile(newIconFile.absolutePath)
if (bitmap == null) {
Snackbar.make(
viewBinding.button,
getString(R.string.parsing_picture_error),
Snackbar.LENGTH_SHORT
).show()
return
}
if (bitmap.height == bitmap.width) {
needCleanCache = true
loadIcon(filePath)

View File

@ -28,7 +28,7 @@ class ErrorInfoActivity : BaseActivity<ActivityErrorInfoBinding>() {
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) {
viewBinding.toolbar.title = getText(R.string.see_error_info)
setTitle(R.string.see_error_info)
setReturnButton()
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
val path = AppSettings.dataRootDirectory + "/carsh/"

View File

@ -18,6 +18,7 @@ import android.widget.*
import android.widget.Toast.makeText
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import com.bumptech.glide.Glide
@ -189,6 +190,7 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
} else super.onKeyDown(keyCode, event)
}
@RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1)
fun initAction() {
viewBinding.fab.setOnClickListener {
val intent = Intent()
@ -222,7 +224,7 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
//
// }
FileManagerViewModel.StartType.DEFAULT, FileManagerViewModel.StartType.SELECT_FILE, FileManagerViewModel.StartType.SELECT_DIRECTORY -> {
val popupMenu = PopupMenu(this@FileManagerActivity, viewBinding.fab)
var popupMenu = GlobalMethod.createPopMenu(viewBinding.fab)
if (adapter != null) {
val selectPath = adapter!!.selectPath
if (selectPath != null) {
@ -738,7 +740,7 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
return@setOnClickListener
}
val finalFile = file
val popupMenu = PopupMenu(this, fileItemBinding.more)
val popupMenu = GlobalMethod.createPopMenu(fileItemBinding.more)
popupMenu.inflate(R.menu.menu_files_actions)
val bookAction = popupMenu.menu.findItem(R.id.bookmarkAction)
bookAction.title = if (viewModel.getBookmarkManager().contains(finalFile)) {
@ -858,7 +860,7 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
val nowLength = it.length
val path = if (rootLength < nowLength) {
root + it.substring(rootLength)
}else{
} else {
it
}
val lineParser = LineParser(path)

View File

@ -70,7 +70,7 @@ class OrderListActivity : BaseActivity<ActivityOrderListBinding>() {
if (canLoadAll) {
//如果可以加载全部用户资料(是管理员模式)
val popupMenu =
PopupMenu(this@OrderListActivity, itemOrderBinding.root)
GlobalMethod.createPopMenu(itemOrderBinding.root)
popupMenu.menu.add("设置订单")
popupMenu.menu.add("查看用户资料")
popupMenu.show()

View File

@ -13,6 +13,7 @@ import androidx.core.view.isVisible
import com.coldmint.rust.core.tool.FileOperator
import com.coldmint.rust.pro.adapters.FileAdapter
import com.coldmint.rust.pro.databinding.ActivityRecyclingStationBinding
import com.coldmint.rust.pro.tool.GlobalMethod
import java.io.File
import java.util.ArrayList
@ -70,7 +71,7 @@ class RecyclingStationActivity : BaseActivity<ActivityRecyclingStationBinding>()
return@setOnClickListener
}
val popupMenu =
PopupMenu(this@RecyclingStationActivity, fileItemBinding.more)
GlobalMethod.createPopMenu(fileItemBinding.more)
popupMenu.menu.add(R.string.recovery_file)
popupMenu.menu.add(R.string.delete_title)
popupMenu.setOnMenuItemClickListener(PopupMenu.OnMenuItemClickListener { item ->

View File

@ -452,7 +452,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
private fun initIconView() {
viewBinding.iconView.setOnClickListener {
val popupMenu = PopupMenu(this, viewBinding.iconView)
val popupMenu = GlobalMethod.createPopMenu(it)
popupMenu.menu.add(R.string.from_url)
if (needIcon) {
popupMenu.menu.add(R.string.change_image)

View File

@ -70,10 +70,7 @@ class WorkManagementActivity : BaseActivity<ActivityWorkmangementBinding>() {
WebModAllInfoAdapter(this@WorkManagementActivity, data)
adapter.setItemEvent { i, itemWebmodAllInfoBinding, viewHolder, data ->
itemWebmodAllInfoBinding.more.setOnClickListener {
val popupMenu = PopupMenu(
this@WorkManagementActivity,
itemWebmodAllInfoBinding.more
)
val popupMenu = GlobalMethod.createPopMenu(it)
when (data.hidden) {
0 -> {
popupMenu.menu.add(R.string.sold_out_mod)

View File

@ -73,7 +73,7 @@ class ApplicationListAdapter(
viewBinding.appVersionView.text = data.versionName
viewBinding.packageNameView.text = data.packageName
viewBinding.root.setOnClickListener {
val popupMenu = PopupMenu(context, viewBinding.root)
val popupMenu = GlobalMethod.createPopMenu(viewBinding.root)
popupMenu.menu.add(R.string.set_game_pack)
popupMenu.menu.add(R.string.exportApk)
popupMenu.menu.add(R.string.application_information)

View File

@ -63,7 +63,7 @@ class DynamicAdapter(context: Context, dataList: MutableList<DynamicItemDataBean
TextStyleMaker.instance.clickEvent(context, type, data)
}
viewBinding.textview.setOnLongClickListener { view ->
val menu = PopupMenu(context, view)
val menu = GlobalMethod.createPopMenu(view)
menu.menu.add(R.string.copy)
menu.menu.add(R.string.delete_title)
menu.setOnMenuItemClickListener {

View File

@ -13,6 +13,7 @@ import com.afollestad.materialdialogs.input.input
import com.coldmint.rust.core.tool.FileOperator
import com.coldmint.rust.pro.base.BaseAdapter
import com.coldmint.rust.pro.databinding.MapAndMusicItemBinding
import com.coldmint.rust.pro.tool.GlobalMethod
import java.io.File
import java.util.ArrayList
@ -28,7 +29,7 @@ class MapAndMusicAdapter(context: Context, dataList: ArrayList<File>, val isMusi
) {
val fileType = FileOperator.getFileType(targetFile)
var fileName = FileOperator.getPrefixName(targetFile)
val popupMenu = PopupMenu(context, viewBinding.root)
val popupMenu = GlobalMethod.createPopMenu(viewBinding.root)
if (isMusic) {
if (fileName.startsWith(prefixName)) {
popupMenu.menu.add(R.string.enable_loop)

View File

@ -9,6 +9,7 @@ import androidx.core.view.isVisible
import com.bumptech.glide.Glide
import com.coldmint.rust.core.dataBean.user.SearchResultDataBean
import com.coldmint.rust.core.web.ServerConfiguration
import com.coldmint.rust.pro.R
import com.coldmint.rust.pro.UserHomePageActivity
import com.coldmint.rust.pro.WebModInfoActivity
import com.coldmint.rust.pro.base.BaseAdapter
@ -46,8 +47,8 @@ class SearchResultAdapter(
position: Int
) {
val finalIcon = data.icon
viewBinding.imageView.isVisible = true
if (finalIcon != null && finalIcon.isNotBlank()) {
viewBinding.imageView.isVisible = true
if (data.type == "user") {
Glide.with(context).load(ServerConfiguration.getRealLink(finalIcon))
.apply(GlobalMethod.getRequestOptions(true)).into(viewBinding.imageView)
@ -56,7 +57,13 @@ class SearchResultAdapter(
.into(viewBinding.imageView)
}
} else {
viewBinding.imageView.isVisible = false
if (data.type == "user"){
viewBinding.imageView.setImageResource(R.drawable.head_icon)
}else if (data.type == "mod"){
viewBinding.imageView.setImageResource(R.drawable.image)
}else{
viewBinding.imageView.isVisible = false
}
}
viewBinding.titleView.text = data.title
val index = data.content.indexOf('\n')

View File

@ -31,24 +31,7 @@ class WebModAdapter( context: Context, dataList: MutableList<WebModListData.Dat
position: Int
) {
viewBinding.modNameView.text = data.name
val text = data.describe
val index = text.indexOf('\n')
if (index > -1) {
val show = text.subSequence(0, index)
if (show.length > WebMod.maxDescribeLength) {
viewBinding.modIntroductionView.text =
show.subSequence(0, WebMod.maxDescribeLength).toString() + "..."
} else {
viewBinding.modIntroductionView.text = show
}
} else {
if (text.length > WebMod.maxDescribeLength) {
viewBinding.modIntroductionView.text =
text.subSequence(0, WebMod.maxDescribeLength).toString() + "..."
} else {
viewBinding.modIntroductionView.text = text
}
}
viewBinding.modIntroductionView.text = data.describe
viewBinding.modInfo.text = String.format(
context.getString(R.string.web_mod_info),
data.updateTime,

View File

@ -12,6 +12,7 @@ import androidx.core.app.ActivityCompat.startActivityForResult
import com.coldmint.dialog.BaseAppDialog
import com.coldmint.rust.pro.FileManagerActivity
import com.coldmint.rust.pro.databinding.EditBookmarkBinding
import com.google.android.material.textfield.TextInputLayout
class BookmarkDialog(context: Context) : BaseAppDialog<BookmarkDialog>(context) {
@ -55,8 +56,10 @@ class BookmarkDialog(context: Context) : BaseAppDialog<BookmarkDialog>(context)
* @param func Function1<[@kotlin.ParameterName] EditBookmarkBinding, Unit>
*/
fun setButtonAction(func: ((editBookmarkBinding: EditBookmarkBinding) -> Unit)) {
editBookmarkBinding.button.setOnClickListener {
func.invoke(editBookmarkBinding)
editBookmarkBinding.pathInputLayout.setEndIconOnClickListener {
func.invoke(
editBookmarkBinding
)
}
}

View File

@ -184,22 +184,24 @@ class AllUnitsFragment(
viewBinding.swipeRefreshLayout.isVisible = true
viewBinding.progressBar.isVisible = false
viewBinding.unitError.isVisible = false
val adapter = UnitAdapter(requireContext(), dataList, "")
adapter.setItemEvent { i, unitItemBinding, viewHolder, sourceFileClass ->
unitItemBinding.root.setOnClickListener {
openEditActivity(sourceFileClass)
if (isAdded) {
val adapter = UnitAdapter(requireContext(), dataList, "")
adapter.setItemEvent { i, unitItemBinding, viewHolder, sourceFileClass ->
unitItemBinding.root.setOnClickListener {
openEditActivity(sourceFileClass)
}
}
}
adapter.setItemChangeEvent { changeType, i, sourceFileClass, i2 ->
whenNumberChanged?.invoke(i2)
if (i2 == 0) {
loadFiles()
adapter.setItemChangeEvent { changeType, i, sourceFileClass, i2 ->
whenNumberChanged?.invoke(i2)
if (i2 == 0) {
loadFiles()
}
}
FastScrollerBuilder(viewBinding.unitList).useMd2Style()
.setPopupTextProvider(adapter).build()
viewBinding.unitList.adapter = adapter
whenNumberChanged?.invoke(dataList.size)
}
FastScrollerBuilder(viewBinding.unitList).useMd2Style()
.setPopupTextProvider(adapter).build()
viewBinding.unitList.adapter = adapter
whenNumberChanged?.invoke(dataList.size)
}
}
}

View File

@ -201,19 +201,23 @@ class RecommendedFragment : BaseFragment<FragmentRecommendedBinding>() {
}
fun createAdapter(dataList: MutableList<WebModListData.Data>): WebModAdapter {
val adapter = WebModAdapter(context = requireContext(), dataList = dataList)
adapter.setItemEvent { i, webModItemBinding, viewHolder, data ->
webModItemBinding.root.setOnClickListener {
val bundle = Bundle()
bundle.putString("modId", data.id)
bundle.putString("modName", data.name)
val intent = Intent(requireContext(), WebModInfoActivity::class.java)
intent.putExtra("data", bundle)
requireContext().startActivity(intent)
fun createAdapter(dataList: MutableList<WebModListData.Data>): WebModAdapter? {
if (isAdded) {
val adapter = WebModAdapter(context = requireContext(), dataList = dataList)
adapter.setItemEvent { i, webModItemBinding, viewHolder, data ->
webModItemBinding.root.setOnClickListener {
val bundle = Bundle()
bundle.putString("modId", data.id)
bundle.putString("modName", data.name)
val intent = Intent(requireContext(), WebModInfoActivity::class.java)
intent.putExtra("data", bundle)
requireContext().startActivity(intent)
}
}
return adapter
} else {
return null
}
return adapter
}
override fun onResume() {

View File

@ -7,6 +7,7 @@ import com.coldmint.rust.core.dataBean.user.SearchResultDataBean
import com.coldmint.rust.pro.adapters.SearchResultAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentSearchResultBinding
import com.google.android.material.divider.MaterialDividerItemDecoration
/**
* 搜索结果碎片
@ -24,6 +25,11 @@ class SearchResultFragment(
val adapter = SearchResultAdapter(requireContext(), keyword, filterList())
viewBinding.recyclerView.adapter = adapter
val divider = MaterialDividerItemDecoration(
requireContext(),
MaterialDividerItemDecoration.VERTICAL
)
viewBinding.recyclerView.addItemDecoration(divider)
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
}

View File

@ -22,23 +22,25 @@ class WarehouseFragment : BaseFragment<FragmentWarehouseBinding>() {
private fun loadTab() {
val mainActivity = activity as MainActivity
val tableLayout = mainActivity.tabLayout
if (tableLayout == null) {
viewBinding.pager.postDelayed({ loadTab() }, MainActivity.linkInterval)
} else {
tableLayout.isVisible = true
TabLayoutMediator(tableLayout, viewBinding.pager)
{ tab, position ->
when (position) {
0 -> {
tab.text = getText(R.string.mod_title)
if (isAdded) {
val mainActivity = activity as MainActivity
val tableLayout = mainActivity.tabLayout
if (tableLayout == null) {
viewBinding.pager.postDelayed({ loadTab() }, MainActivity.linkInterval)
} else {
tableLayout.isVisible = true
TabLayoutMediator(tableLayout, viewBinding.pager)
{ tab, position ->
when (position) {
0 -> {
tab.text = getText(R.string.mod_title)
}
1 -> {
tab.text = getText(R.string.map)
}
}
1 -> {
tab.text = getText(R.string.map)
}
}
}.attach()
}.attach()
}
}
}

View File

@ -12,7 +12,9 @@ import android.graphics.Paint
import android.graphics.drawable.Drawable
import android.os.Build
import android.util.TypedValue
import android.view.Gravity
import android.view.View
import android.widget.PopupMenu
import android.widget.TextView
import android.widget.Toast
import androidx.core.graphics.drawable.DrawableCompat
@ -118,6 +120,23 @@ object GlobalMethod {
}
/**
* 创建PopMenu
*/
fun createPopMenu(view: View): PopupMenu {
val context = view.context;
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
PopupMenu(
context,
view,
Gravity.NO_GRAVITY,
0, R.style.Widget_Material3_PopupMenu
)
} else {
PopupMenu(context, view)
}
}
/**
* int颜色值转String
* @param color Int

View File

@ -252,15 +252,15 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio
AppSettings.Setting.DynamicColor,
DynamicColors.isDynamicColorAvailable()
)
AppSettings.initSetting(AppSettings.Setting.KeywordColor, "#FF0031C2")
AppSettings.initSetting(AppSettings.Setting.SectionColor, "#FFE10000")
AppSettings.initSetting(AppSettings.Setting.TextColor, "#FF000000")
AppSettings.initSetting(AppSettings.Setting.AnnotationColor, "#FF00AF2C")
AppSettings.initSetting(AppSettings.Setting.KeywordColor, "#2196f3")
AppSettings.initSetting(AppSettings.Setting.SectionColor, "#e91e63")
AppSettings.initSetting(AppSettings.Setting.TextColor, "#212121")
AppSettings.initSetting(AppSettings.Setting.AnnotationColor, "#4caf50")
AppSettings.initSetting(AppSettings.Setting.KeywordColorDark, "#FF5D5DFF")
AppSettings.initSetting(AppSettings.Setting.SectionColorDark, "#FFA7002A")
AppSettings.initSetting(AppSettings.Setting.TextColorDark, "#FFE2E2E2")
AppSettings.initSetting(AppSettings.Setting.AnnotationColorDark, "#FF00B500")
AppSettings.initSetting(AppSettings.Setting.KeywordColorDark, "#2196f3")
AppSettings.initSetting(AppSettings.Setting.SectionColorDark, "#e91e63")
AppSettings.initSetting(AppSettings.Setting.TextColorDark, "#eeeeee")
AppSettings.initSetting(AppSettings.Setting.AnnotationColorDark, "#4caf50")
AppSettings.initSetting(AppSettings.Setting.CodeEditBackGroundEnable, false)
AppSettings.initSetting(AppSettings.Setting.BlurTransformationValue, 1)
AppSettings.initSetting(AppSettings.Setting.CodeEditBackGroundPath, "")

View File

@ -63,11 +63,12 @@
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:animateLayoutChanges="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:animateLayoutChanges="true"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
@ -84,11 +85,11 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/replaceLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/replaceLayout"
android:visibility="gone"
android:layout_marginTop="8dp"
android:visibility="gone"
android:hint="@string/replace">
<com.google.android.material.textfield.TextInputEditText
@ -129,13 +130,13 @@
<Button
android:visibility="gone"
android:id="@+id/allButton"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/all" />
android:text="@string/all"
android:visibility="gone" />
<Button
android:id="@+id/closeButton"

View File

@ -21,15 +21,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="全部" />
<!-- <com.google.android.material.tabs.TabItem-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="全部" />-->
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="最近" />
<!-- <com.google.android.material.tabs.TabItem-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="最近" />-->
</com.google.android.material.tabs.TabLayout>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@ -13,9 +14,9 @@
android:text="@string/title" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/nameInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/nameInputLayout"
android:layout_marginTop="24dp"
android:hint="@string/name">
@ -29,40 +30,24 @@
</com.google.android.material.textfield.TextInputLayout>
<RelativeLayout
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/pathInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
android:layout_marginTop="8dp"
android:hint="@string/path"
app:endIconDrawable="@drawable/ic_outline_edit_24"
app:endIconMode="custom">
<com.google.android.material.textfield.TextInputLayout
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/pathEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pathInputLayout"
android:layout_centerVertical="true"
android:layout_toStartOf="@id/button"
android:hint="@string/path">
android:imeOptions="actionDone"
android:inputType="textMultiLine" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/pathEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="8dp"
android:text="@string/select_directents" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/buttonContainer"

View File

@ -24,6 +24,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:paddingVertical="4dp"
android:gravity="center_vertical"
android:orientation="vertical">

View File

@ -19,6 +19,7 @@
app:showAsAction="always" />
<item
android:visible="false"
android:id="@+id/code_navigation"
android:title="@string/code_navigation" />

View File

@ -286,6 +286,7 @@
<string name="create_new_section">创建节</string>
<string name="subtitle">你好,世界!|新的开始,新的体验。|2.0重置版|给薄荷打钱~</string>
<string name="web_link">网页链接</string>
<string name="parsing_picture_error">解析图片出错。</string>
<!-- Preference Titles -->
<string name="sync_header">开发者选项</string>

View File

@ -33,7 +33,12 @@ class ModConfigurationManager(file: File) {
return if (code == null) {
null
} else {
gson.fromJson(code, ModConfigurationData::class.java)
try {
gson.fromJson(code, ModConfigurationData::class.java)
} catch (e: Exception) {
e.printStackTrace()
null
}
}
}

View File

@ -65,11 +65,11 @@ class TurretManager(val sourceFile: SourceFile) {
var x = 0
var y = 0
val xData = sourceFile.readValueFromSection("x", it)
if (xData != null) {
if (xData != null && xData.isNotBlank()) {
x = xData.toFloat().toInt()
}
val yData = sourceFile.readValueFromSection("y", it)
if (yData != null) {
if (yData != null&& yData.isNotBlank()) {
y = yData.toFloat().toInt()
}
val turretData = TurretData(name, CoordinateData(x, y))

View File

@ -26,7 +26,7 @@ class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null)
* @param size Float
* @return Bitmap
*/
fun scaleBitmap(bitmap: Bitmap, size: Float): Bitmap {
fun scaleBitmap(bitmap: Bitmap, size: Float): Bitmap? {
//创建新的图像背景
val matrix = Matrix()
matrix.setScale(size, size)
@ -253,8 +253,10 @@ class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null)
private fun drawImage(canvas: Canvas, bitmap: Bitmap) {
val paint = Paint()
val temBitmap = scaleBitmap(bitmap, cellSize.toFloat())
canvas.drawBitmap(temBitmap, startX.toFloat(), startY.toFloat(), paint)
temBitmap.recycle()
if (temBitmap != null) {
canvas.drawBitmap(temBitmap, startX.toFloat(), startY.toFloat(), paint)
temBitmap.recycle()
}
}
override fun onDraw(canvas: Canvas?) {

View File

@ -158,24 +158,25 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) :
if (bitmap == null) {
LogCat.e(debugKey, "无法加载炮塔图像。")
return
}
if (turretData.scaleValue != 1f) {
bitmap = TurretSketchpadView.scaleBitmap(
bitmap, turretData.scaleValue
} else {
if (turretData.scaleValue != 1f) {
bitmap = TurretSketchpadView.scaleBitmap(
bitmap, turretData.scaleValue
)
}
val androidCoordinate =
turretSketchpadView!!.toAndroidCoordinate(turretData.gameCoordinateData)
bitmapW = bitmap!!.width
bitmapH = bitmap!!.height
canvas?.drawBitmap(
bitmap,
(androidCoordinate.x - bitmapW / 2).toFloat(),
(androidCoordinate.y - bitmapH / 2).toFloat(),
paint
)
}
val androidCoordinate =
turretSketchpadView!!.toAndroidCoordinate(turretData.gameCoordinateData)
bitmapW = bitmap.width
bitmapH = bitmap.height
canvas?.drawBitmap(
bitmap,
(androidCoordinate.x - bitmapW / 2).toFloat(),
(androidCoordinate.y - bitmapH / 2).toFloat(),
paint
)
if (!bitmap.isRecycled) {
bitmap.recycle()
if (!bitmap.isRecycled) {
bitmap.recycle()
}
}
} else {
LogCat.e(debugKey, "未设置炮塔数据,停止绘制。")