diff --git a/.gradle/7.3.3/checksums/checksums.lock b/.gradle/7.3.3/checksums/checksums.lock index 6fd303d..1aa4629 100644 Binary files a/.gradle/7.3.3/checksums/checksums.lock and b/.gradle/7.3.3/checksums/checksums.lock differ diff --git a/.gradle/7.3.3/checksums/md5-checksums.bin b/.gradle/7.3.3/checksums/md5-checksums.bin index 237c42c..dc3ae77 100644 Binary files a/.gradle/7.3.3/checksums/md5-checksums.bin and b/.gradle/7.3.3/checksums/md5-checksums.bin differ diff --git a/.gradle/7.3.3/checksums/sha1-checksums.bin b/.gradle/7.3.3/checksums/sha1-checksums.bin index dc2b25e..ed4d561 100644 Binary files a/.gradle/7.3.3/checksums/sha1-checksums.bin and b/.gradle/7.3.3/checksums/sha1-checksums.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index e59365f..6747845 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.bin and b/.gradle/7.3.3/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.lock b/.gradle/7.3.3/executionHistory/executionHistory.lock index ec7aa76..1cb3e56 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.lock and b/.gradle/7.3.3/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.bin b/.gradle/7.3.3/fileHashes/fileHashes.bin index 43b8ad8..f12f6aa 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.bin and b/.gradle/7.3.3/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.lock b/.gradle/7.3.3/fileHashes/fileHashes.lock index b57c3af..2e013d7 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.lock and b/.gradle/7.3.3/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin index 7d5e9c7..7e8042a 100644 Binary files a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin and b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index e801e84..5461586 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 6018074..2ae40f9 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 848b22b..6b58ff1 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index abffbe1..cff6de4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,19 +26,24 @@ android:usesCleartextTraffic="true"> + android:exported="false" + android:screenOrientation="portrait" /> + android:exported="false" + android:screenOrientation="portrait" /> + android:exported="false" + android:screenOrientation="portrait" /> + android:exported="false" + android:screenOrientation="portrait" /> + android:exported="false" + android:screenOrientation="portrait" /> override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == android.R.id.home) { showSaveDialogIfNeed() + return true } return super.onOptionsItemSelected(item) } diff --git a/app/src/main/java/com/coldmint/rust/pro/EditActivity.kt b/app/src/main/java/com/coldmint/rust/pro/EditActivity.kt index 4c45c91..6d31838 100644 --- a/app/src/main/java/com/coldmint/rust/pro/EditActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/EditActivity.kt @@ -265,7 +265,7 @@ class EditActivity : BaseActivity() { } } 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() { 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() { 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() { 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() { ).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() { // } // } // } - } +// } R.id.save_text -> { val openedSourceFile = viewModel.openedSourceFileListLiveData.getOpenedSourceFile(viewBinding.tabLayout.selectedTabPosition) @@ -1395,7 +1395,7 @@ class EditActivity : BaseActivity() { 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() { } 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 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 b7e6ff9..508affd 100644 --- a/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt @@ -262,7 +262,7 @@ class EditModInfoActivity : BaseActivity() { } 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) diff --git a/app/src/main/java/com/coldmint/rust/pro/EditUserInfoActivity.kt b/app/src/main/java/com/coldmint/rust/pro/EditUserInfoActivity.kt index ce50093..cab4690 100644 --- a/app/src/main/java/com/coldmint/rust/pro/EditUserInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/EditUserInfoActivity.kt @@ -149,7 +149,7 @@ class EditUserInfoActivity : BaseActivity() { }) 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() { 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() { } 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() { 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() { 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) diff --git a/app/src/main/java/com/coldmint/rust/pro/ErrorInfoActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ErrorInfoActivity.kt index e12694e..43e44b4 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ErrorInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ErrorInfoActivity.kt @@ -28,7 +28,7 @@ class ErrorInfoActivity : BaseActivity() { 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/" diff --git a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt index c9b6c12..0593ae5 100644 --- a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt @@ -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() { } 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() { // // } 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() { 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() { val nowLength = it.length val path = if (rootLength < nowLength) { root + it.substring(rootLength) - }else{ + } else { it } val lineParser = LineParser(path) diff --git a/app/src/main/java/com/coldmint/rust/pro/OrderListActivity.kt b/app/src/main/java/com/coldmint/rust/pro/OrderListActivity.kt index 486d7cc..7734a50 100644 --- a/app/src/main/java/com/coldmint/rust/pro/OrderListActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/OrderListActivity.kt @@ -70,7 +70,7 @@ class OrderListActivity : BaseActivity() { if (canLoadAll) { //如果可以加载全部用户资料(是管理员模式) val popupMenu = - PopupMenu(this@OrderListActivity, itemOrderBinding.root) + GlobalMethod.createPopMenu(itemOrderBinding.root) popupMenu.menu.add("设置订单") popupMenu.menu.add("查看用户资料") popupMenu.show() diff --git a/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt b/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt index f66037f..c24d229 100644 --- a/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt @@ -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() 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 -> diff --git a/app/src/main/java/com/coldmint/rust/pro/ReleaseModActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ReleaseModActivity.kt index 6f9cf35..9e9466e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ReleaseModActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ReleaseModActivity.kt @@ -452,7 +452,7 @@ class ReleaseModActivity : BaseActivity() { 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) diff --git a/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt b/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt index f60c472..76562f0 100644 --- a/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt @@ -70,10 +70,7 @@ class WorkManagementActivity : BaseActivity() { 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) diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/ApplicationListAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/ApplicationListAdapter.kt index 89988c4..295f809 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/ApplicationListAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/ApplicationListAdapter.kt @@ -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) 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 b94068f..cd04566 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 @@ -63,7 +63,7 @@ class DynamicAdapter(context: Context, dataList: MutableList - 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 { diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/MapAndMusicAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/MapAndMusicAdapter.kt index caf2a73..54a904f 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/MapAndMusicAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/MapAndMusicAdapter.kt @@ -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, 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) diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/SearchResultAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/SearchResultAdapter.kt index 9c58a9b..9296c1e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/SearchResultAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/SearchResultAdapter.kt @@ -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') diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/WebModAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/WebModAdapter.kt index c9203e5..dc26e8b 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/WebModAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/WebModAdapter.kt @@ -31,24 +31,7 @@ class WebModAdapter( context: Context, dataList: MutableList -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, diff --git a/app/src/main/java/com/coldmint/rust/pro/dialog/BookmarkDialog.kt b/app/src/main/java/com/coldmint/rust/pro/dialog/BookmarkDialog.kt index 3c4531d..21afe4c 100644 --- a/app/src/main/java/com/coldmint/rust/pro/dialog/BookmarkDialog.kt +++ b/app/src/main/java/com/coldmint/rust/pro/dialog/BookmarkDialog.kt @@ -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(context) { @@ -55,8 +56,10 @@ class BookmarkDialog(context: Context) : BaseAppDialog(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 + ) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/AllUnitsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/AllUnitsFragment.kt index 18d92e4..1a13423 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/AllUnitsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/AllUnitsFragment.kt @@ -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) } } } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt index 8a65f9d..b5a4976 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt @@ -201,19 +201,23 @@ class RecommendedFragment : BaseFragment() { } - fun createAdapter(dataList: MutableList): 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): 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() { diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/SearchResultFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/SearchResultFragment.kt index cf06823..1cbe145 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/SearchResultFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/SearchResultFragment.kt @@ -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()) } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/WarehouseFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/WarehouseFragment.kt index 2f9cd6c..881fa43 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/WarehouseFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/WarehouseFragment.kt @@ -22,23 +22,25 @@ class WarehouseFragment : BaseFragment() { 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() + } } } diff --git a/app/src/main/java/com/coldmint/rust/pro/tool/GlobalMethod.kt b/app/src/main/java/com/coldmint/rust/pro/tool/GlobalMethod.kt index fd9e06a..de90af9 100644 --- a/app/src/main/java/com/coldmint/rust/pro/tool/GlobalMethod.kt +++ b/app/src/main/java/com/coldmint/rust/pro/tool/GlobalMethod.kt @@ -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 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 bb59abd..6ee7df2 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 @@ -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, "") diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml index 13ec0ad..7076cac 100644 --- a/app/src/main/res/layout/activity_edit.xml +++ b/app/src/main/res/layout/activity_edit.xml @@ -63,11 +63,12 @@ android:orientation="vertical" android:visibility="gone"> + + android:text="@string/all" + android:visibility="gone" />