diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index 4b93a99..4de22ca 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 971f9ae..ffcffc9 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 6540ece..91882ca 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 7127f86..5893057 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 6dfd8ff..3b96819 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 6e3819b..74208df 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 5937df8..f06d52b 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 942cf27..00dc328 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/app/build.gradle b/app/build.gradle index 5a3e9d5..b0a9fc7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -68,7 +68,7 @@ android { dependencies { - implementation 'com.luolc:emoji-rain:0.1.1' +// implementation 'com.luolc:emoji-rain:0.1.1' implementation 'me.zhanghai.android.fastscroll:library:1.1.8' // 语种切换框架:https://github.com/getActivity/MultiLanguages implementation 'com.github.getActivity:MultiLanguages:8.0' 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 509bd12..c736e16 100644 --- a/app/src/main/java/com/coldmint/rust/pro/EditUserInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/EditUserInfoActivity.kt @@ -111,29 +111,29 @@ class EditUserInfoActivity : BaseActivity() { } private fun initAction() { - viewBinding.changeColorButton.setOnClickListener { - ColorPickerDialogBuilder - .with(this) - .setTitle(getString(R.string.choose_color)) - .initialColor(Color.WHITE) - .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER) - .density(12) - .setOnColorSelectedListener { - //toast("onColorSelected: 0x" + Integer.toHexString(selectedColor)); - } - .setPositiveButton(R.string.dialog_ok) { dialog, selectedColor, allColors -> - GlobalMethod.temColor = selectedColor - if (iconLink != null) { - Glide.with(this@EditUserInfoActivity) - .load(iconLink) - .apply(GlobalMethod.getRequestOptions(true, !GlobalMethod.isActive)) - .into(viewBinding.iconView) - } - } - .setNegativeButton(R.string.dialog_cancel) { dialog, which -> } - .build() - .show() - } +// viewBinding.changeColorButton.setOnClickListener { +// ColorPickerDialogBuilder +// .with(this) +// .setTitle(getString(R.string.choose_color)) +// .initialColor(Color.WHITE) +// .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER) +// .density(12) +// .setOnColorSelectedListener { +// //toast("onColorSelected: 0x" + Integer.toHexString(selectedColor)); +// } +// .setPositiveButton(R.string.dialog_ok) { dialog, selectedColor, allColors -> +// GlobalMethod.temColor = selectedColor +// if (iconLink != null) { +// Glide.with(this@EditUserInfoActivity) +// .load(iconLink) +// .apply(GlobalMethod.getRequestOptions(true, !GlobalMethod.isActive)) +// .into(viewBinding.iconView) +// } +// } +// .setNegativeButton(R.string.dialog_cancel) { dialog, which -> } +// .build() +// .show() +// } viewBinding.userNameView.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { 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 aaa4a77..ecaf593 100644 --- a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt @@ -27,6 +27,7 @@ import com.coldmint.rust.core.tool.FileOperator import com.coldmint.rust.pro.adapters.FileAdapter import com.coldmint.rust.pro.databinding.ActivityFileBinding import com.coldmint.rust.pro.interfaces.BookmarkListener +import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.viewmodel.FileManagerViewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import me.zhanghai.android.fastscroll.FastScrollerBuilder @@ -899,6 +900,7 @@ class FileManagerActivity : BaseActivity() { viewBinding.swipeRefreshLayout.isRefreshing = false } viewModel.loadFiles() + viewModel.loadSortType(this) } else { val bundle = intent.getBundleExtra("data") if (bundle == null) { @@ -917,9 +919,14 @@ class FileManagerActivity : BaseActivity() { override fun onCreateOptionsMenu(menu: Menu): Boolean { menuBinding = MenuBinding.inflate(menu, menuInflater) + val value = viewModel.sortTypeLiveData.value + if (value != null) { + setSortType(value) + } return true } + /** * 加载观察者 */ @@ -930,6 +937,9 @@ class FileManagerActivity : BaseActivity() { viewBinding.fileError.isVisible = it viewBinding.progressBar.isVisible = it } + viewModel.sortTypeLiveData.observe(this) { + setSortType(it) + } viewModel.fileListLiveData.observe(this) { if (adapter == null) { //创建实例(设置适配器) @@ -957,6 +967,34 @@ class FileManagerActivity : BaseActivity() { } } + /** + * 设置排序方式 + * @param sortType SortType + */ + fun setSortType(sortType: FileManagerViewModel.SortType) { + if (this::menuBinding.isInitialized) { + when (sortType) { + FileManagerViewModel.SortType.BY_NAME -> { + menuBinding.actionSortByName.isChecked = true + } + FileManagerViewModel.SortType.BY_SIZE -> { + menuBinding.actionSortBySize.isChecked = true + } + FileManagerViewModel.SortType.BY_LAST_MODIFIED -> { + menuBinding.actionSortByLastModified.isChecked = true + } + FileManagerViewModel.SortType.BY_TYPE -> { + menuBinding.actionSortByType.isChecked = true + } + else -> { + menuBinding.actionSortByName.isChecked = true + } + } + adapter?.setSort(sortType) + viewModel.loadFiles(viewModel.getCurrentPath()) + } + } + /** * 加载页面标题 */ @@ -980,7 +1018,10 @@ class FileManagerActivity : BaseActivity() { val menu: Menu, val reloadFileItem: MenuItem, val photoAlbumItem: MenuItem, - val systemFileManagerItem: MenuItem + val systemFileManagerItem: MenuItem, + val actionSortByName: MenuItem, + val actionSortByType: MenuItem, + val actionSortBySize: MenuItem, val actionSortByLastModified: MenuItem ) { companion object { //填充 @@ -990,7 +1031,11 @@ class FileManagerActivity : BaseActivity() { menu, menu.findItem(R.id.reloadFile), menu.findItem(R.id.photo_album), - menu.findItem(R.id.system_file_manager) + menu.findItem(R.id.system_file_manager), + menu.findItem(R.id.action_sort_by_name), + menu.findItem(R.id.action_sort_by_type), + menu.findItem(R.id.action_sort_by_size), + menu.findItem(R.id.action_sort_by_last_modified) ) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt index 114588c..ca48dd4 100644 --- a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt @@ -90,10 +90,10 @@ class UserHomePageActivity : BaseActivity() { // } // viewBinding.bubbleView.setDrawableList(dlist) // viewBinding.bubbleView.startAnimation(5000, 5000,30) - viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_1_3) - viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_2_3) - viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_3_3) - viewBinding.emojiRainLayout.startDropping() +// viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_1_3) +// viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_2_3) +// viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_3_3) +// viewBinding.emojiRainLayout.startDropping() } diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/FileAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/FileAdapter.kt index 821f782..856b054 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/FileAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/FileAdapter.kt @@ -12,8 +12,10 @@ import android.view.View import androidx.core.view.isVisible import com.bumptech.glide.Glide import com.coldmint.rust.core.tool.FileOperator +import com.coldmint.rust.core.web.ServerConfiguration import com.coldmint.rust.pro.base.BaseAdapter import com.coldmint.rust.pro.databinding.FileItemBinding +import com.coldmint.rust.pro.viewmodel.FileManagerViewModel import com.github.promeg.pinyinhelper.Pinyin import com.google.android.material.dialog.MaterialAlertDialogBuilder import me.zhanghai.android.fastscroll.PopupTextProvider @@ -42,6 +44,8 @@ class FileAdapter(private val context: Context, dataList: MutableList) : private set + private var sortType: FileManagerViewModel.SortType = FileManagerViewModel.SortType.BY_NAME + /** * 清除选中目录 */ @@ -76,10 +80,50 @@ class FileAdapter(private val context: Context, dataList: MutableList) : // } // } + /** + * 设置排序方式 + * @param sortType SortType + */ + fun setSort(sortType: FileManagerViewModel.SortType) { + this.sortType = sortType + } + override fun setNewDataList(dataList: MutableList) { - dataList.sortBy { - val name = it?.name ?: "#" - getInitial(name) + when (sortType) { + FileManagerViewModel.SortType.BY_NAME -> { + dataList.sortBy { + val name = it?.name ?: "#" + getInitial(name) + } + } + FileManagerViewModel.SortType.BY_SIZE -> { + dataList.sortBy { + val size = it?.length() ?: 0.toLong() + size + } + } + FileManagerViewModel.SortType.BY_TYPE -> { + dataList.sortBy { + val type = if (it != null) { + FileOperator.getFileType(it) + } else { + "#" + } + type + } + } + FileManagerViewModel.SortType.BY_LAST_MODIFIED -> { + dataList.sortBy { + val lastModified = it?.lastModified() ?: 0.toLong() + lastModified + } + } + else -> { + dataList.sortBy { + val name = it?.name ?: "#" + getInitial(name) + } + } } super.setNewDataList(dataList) } @@ -161,7 +205,32 @@ class FileAdapter(private val context: Context, dataList: MutableList) : override fun getPopupText(position: Int): String { val file = dataList[position] - val name = file?.name ?: "#" - return getInitial(name).toString() + val data = when (sortType) { + FileManagerViewModel.SortType.BY_NAME -> { + val name = file?.name ?: "#" + getInitial(name) + } + FileManagerViewModel.SortType.BY_SIZE -> { + val size = file?.length() ?: 0.toLong() + size + } + FileManagerViewModel.SortType.BY_TYPE -> { + val type = if (file != null) { + FileOperator.getFileType(file) + } else { + "#" + } + type + } + FileManagerViewModel.SortType.BY_LAST_MODIFIED -> { + val lastModified = file?.lastModified() ?: 0.toLong() + ServerConfiguration.toStringTime(lastModified) + } + else -> { + val name = file?.name ?: "#" + getInitial(name) + } + }.toString() + return data } } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/tool/AppSettings.kt b/app/src/main/java/com/coldmint/rust/pro/tool/AppSettings.kt index e0dad45..3f11971 100644 --- a/app/src/main/java/com/coldmint/rust/pro/tool/AppSettings.kt +++ b/app/src/main/java/com/coldmint/rust/pro/tool/AppSettings.kt @@ -44,7 +44,7 @@ class AppSettings private constructor(val mContext: Context) { private val editor: SharedPreferences.Editor = sharedPreferences.edit() enum class Setting { - DatabaseDirectory, DatabasePath, TemplateDirectory, AppLanguage, DeveloperMode, CustomSymbol, AutoCreateNomedia, OnlyLoadConantLanguageTemple, NightMode, GamePackage, KeepRwmodFile, EnableRecoveryStation, RecoveryStationFileSaveDays, RecoveryStationFolder, IndependentFolder, SetGameStorage, PackDirectory, IdentifiersPromptNumber, UserName, UseJetBrainsMonoFont, AppID, Account, PassWord, ExpirationTime, CheckBetaUpdate, UpdateData, ShareTip, AgreePolicy, EnglishEditingMode, NightModeFollowSystem, UseMobileNetwork, MapFolder, ModFolder, UseTheCommunityAsTheLaunchPage, AutoSave, ServerAddress, Token, LoginStatus, DynamicColor, ExperiencePlan + DatabaseDirectory, DatabasePath, TemplateDirectory, AppLanguage, DeveloperMode, CustomSymbol, AutoCreateNomedia, OnlyLoadConantLanguageTemple, NightMode, GamePackage, KeepRwmodFile, EnableRecoveryStation, RecoveryStationFileSaveDays, RecoveryStationFolder, IndependentFolder, SetGameStorage, PackDirectory, IdentifiersPromptNumber, UserName, UseJetBrainsMonoFont, AppID, Account, PassWord, ExpirationTime, CheckBetaUpdate, UpdateData, ShareTip, AgreePolicy, EnglishEditingMode, NightModeFollowSystem, UseMobileNetwork, MapFolder, ModFolder, UseTheCommunityAsTheLaunchPage, AutoSave, ServerAddress, Token, LoginStatus, DynamicColor, ExperiencePlan, FileSortType } @@ -289,7 +289,8 @@ class AppSettings private constructor(val mContext: Context) { map[Setting.AutoSave] = mContext.getString(R.string.setting_auto_save) map[Setting.ServerAddress] = mContext.getString(R.string.setting_server_address) map[Setting.DynamicColor] = mContext.getString(R.string.setting_dynamic_color) - map[Setting.ExperiencePlan] = mContext.getString(R.string.experience_the_plan) + map[Setting.ExperiencePlan] = mContext.getString(R.string.setting_experience_the_plan) + map[Setting.FileSortType] = mContext.getString(R.string.setting_file_sort_type) //仅保存不可显示 map[Setting.SetGameStorage] = "SetGameStorage" map[Setting.AppID] = "AppId" 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 374a8e4..b9a4bc9 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 @@ -42,7 +42,6 @@ object GlobalMethod { const val DEFAULT_GAME_PACKAGE = "com.corrodinggames.rts" const val DEBUG_SIGN = "963dfd616924b27f9247a35e45bc130a" const val RELEASE_SIGN = "5320b24894fe7ed449842a81a2dfceda" - var temColor = Color.RED /** @@ -53,7 +52,7 @@ object GlobalMethod { //变换列表 val transformations = ArrayList() if (circleCrop) { - transformations.add(CropCircleWithBorderTransformation(Utils.toDp(4), temColor)) + transformations.add(CropCircleTransformation()) } if (grayscale) { transformations.add(GrayscaleTransformation()) diff --git a/app/src/main/java/com/coldmint/rust/pro/viewmodel/FileManagerViewModel.kt b/app/src/main/java/com/coldmint/rust/pro/viewmodel/FileManagerViewModel.kt index 93380e2..064ccdd 100644 --- a/app/src/main/java/com/coldmint/rust/pro/viewmodel/FileManagerViewModel.kt +++ b/app/src/main/java/com/coldmint/rust/pro/viewmodel/FileManagerViewModel.kt @@ -1,11 +1,15 @@ package com.coldmint.rust.pro.viewmodel +import android.content.Context import android.os.Environment import android.util.Log import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope +import com.coldmint.rust.core.tool.AppOperator import com.coldmint.rust.core.tool.FileOperator +import com.coldmint.rust.pro.R import com.coldmint.rust.pro.base.BaseViewModel +import com.coldmint.rust.pro.tool.AppSettings import kotlinx.coroutines.launch import java.io.File @@ -19,6 +23,13 @@ class FileManagerViewModel : BaseViewModel() { DEFAULT, SELECT_DIRECTORY, EXPORT_FILE, SELECT_FILE } + /** + * 文件排序方式 + */ + enum class SortType { + BY_NAME, BY_SIZE, BY_TYPE, BY_LAST_MODIFIED + } + private var directs = Environment.getExternalStorageDirectory().absolutePath //根目录 @@ -31,6 +42,41 @@ class FileManagerViewModel : BaseViewModel() { MutableLiveData(rootPath) } + /** + * 文件排序方式 + */ + val sortTypeLiveData: MutableLiveData by lazy { + MutableLiveData(SortType.BY_NAME) + } + + /** + * 从设置中读取排序方式 + */ + fun loadSortType(context: Context) { + val appSettings = AppSettings.getInstance(context) + //从设置中读取排序方式 + val sortType = appSettings.getValue( + AppSettings.Setting.FileSortType, + context.getString(R.string.setting_file_list_action_sort_by_name) + ) + when (sortType) { + context.getString(R.string.setting_file_list_action_sort_by_name) -> { + sortTypeLiveData.value = SortType.BY_NAME + } + context.getString(R.string.setting_file_list_action_sort_by_last_modified) -> { + sortTypeLiveData.value = SortType.BY_LAST_MODIFIED + } + context.getString(R.string.setting_file_list_action_sort_by_size) -> { + sortTypeLiveData.value = SortType.BY_SIZE + } + context.getString(R.string.setting_file_list_action_sort_by_type) -> { + sortTypeLiveData.value = SortType.BY_TYPE + } + else -> { + sortTypeLiveData.value = SortType.BY_NAME + } + } + } /** * 获取当前打开的目录 @@ -40,6 +86,7 @@ class FileManagerViewModel : BaseViewModel() { return currentPathLiveData.value ?: rootPath } + /** * 加载状态 */ 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 31f8605..0ba0c9e 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 @@ -241,6 +241,7 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio appSettings.initSetting(AppSettings.Setting.AutoSave, true) appSettings.initSetting(AppSettings.Setting.AgreePolicy, false) appSettings.initSetting(AppSettings.Setting.LoginStatus, false) + appSettings.initSetting(AppSettings.Setting.FileSortType,context.getString(R.string.setting_file_list_action_sort_by_name)) //如果启用动态颜色 appSettings.initSetting( AppSettings.Setting.DynamicColor, diff --git a/app/src/main/res/layout/activity_edit_user_info.xml b/app/src/main/res/layout/activity_edit_user_info.xml index 86b37eb..aaa410d 100644 --- a/app/src/main/res/layout/activity_edit_user_info.xml +++ b/app/src/main/res/layout/activity_edit_user_info.xml @@ -139,26 +139,26 @@ - + + + + - + + + + + -