diff --git a/app/src/main/java/com/ux/video/file/filerecovery/recovery/RecoveryActivity.kt b/app/src/main/java/com/ux/video/file/filerecovery/recovery/RecoveryActivity.kt index 738a14f..f6f2ae6 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/recovery/RecoveryActivity.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/recovery/RecoveryActivity.kt @@ -1,6 +1,7 @@ package com.ux.video.file.filerecovery.recovery import android.view.LayoutInflater +import androidx.activity.viewModels import androidx.lifecycle.lifecycleScope import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout.OnTabSelectedListener @@ -11,33 +12,54 @@ import com.ux.video.file.filerecovery.databinding.ActivityRecoveryBinding import com.ux.video.file.filerecovery.db.ObjectBoxManager import com.ux.video.file.filerecovery.recovery.ui.MyViewPage2Adapter import com.ux.video.file.filerecovery.recovery.ui.recoveryphoto.RecoveryPhotoFragment +import com.ux.video.file.filerecovery.recovery.ui.recoveryphoto.RecoveryPhotoViewModel +import com.ux.video.file.filerecovery.utils.Common import com.ux.video.file.filerecovery.utils.CustomTextView import kotlinx.coroutines.launch class RecoveryActivity : BaseActivity() { - override fun inflateBinding(inflater: LayoutInflater): ActivityRecoveryBinding = ActivityRecoveryBinding.inflate(inflater) + val sharedViewModel: RecoveryPhotoViewModel by viewModels() + override fun inflateBinding(inflater: LayoutInflater): ActivityRecoveryBinding = + ActivityRecoveryBinding.inflate(inflater) override fun initView() { super.initView() binding.run { - - viewPage2.adapter = MyViewPage2Adapter(this@RecoveryActivity,listOf(RecoveryPhotoFragment(),RecoveryPhotoFragment(),RecoveryPhotoFragment(),RecoveryPhotoFragment())) - TabLayoutMediator(tabLayout,viewPage2){tab,position-> - val tabView = LayoutInflater.from(this@RecoveryActivity).inflate(R.layout.tab_layout_item, null) + val fragments = listOf( + RecoveryPhotoFragment.newInstance(Common.FILE_TYPE_PHOTO), + RecoveryPhotoFragment.newInstance(Common.FILE_TYPE_VIDEO), + RecoveryPhotoFragment.newInstance(Common.FILE_TYPE_AUDIO), + RecoveryPhotoFragment.newInstance(Common.FILE_TYPE_DOCUMENTS) + ) + viewPage2.adapter = MyViewPage2Adapter(this@RecoveryActivity, fragments) + TabLayoutMediator(tabLayout, viewPage2) { tab, position -> + val tabView = LayoutInflater.from(this@RecoveryActivity) + .inflate(R.layout.tab_layout_item, null) val tvTitle = tabView.findViewById(R.id.tab_item_title) val tvCount = tabView.findViewById(R.id.tab_item_count) tvCount.text = getString(R.string.text_counts, 0) - when(position){ - 0->{tvTitle.text = getString(R.string.text_photos)} - 1->{tvTitle.text = getString(R.string.text_videos)} - 2->{tvTitle.text = getString(R.string.text_audios)} - 3->{tvTitle.text = getString(R.string.text_documents)} + when (position) { + 0 -> { + tvTitle.text = getString(R.string.text_photos) + } + + 1 -> { + tvTitle.text = getString(R.string.text_videos) + } + + 2 -> { + tvTitle.text = getString(R.string.text_audios) + } + + 3 -> { + tvTitle.text = getString(R.string.text_documents) + } } tab.customView = tabView }.attach() - tabLayout.addOnTabSelectedListener(object :OnTabSelectedListener{ + tabLayout.addOnTabSelectedListener(object : OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab?) { } @@ -57,16 +79,28 @@ class RecoveryActivity : BaseActivity() { override fun initData() { super.initData() - lifecycleScope.launch{ - val recoveryFilePhoto = ObjectBoxManager.queryRecoveryFileAsync(0) - val recoveryFileVideo = ObjectBoxManager.queryRecoveryFileAsync(1) - val recoveryFileAudio = ObjectBoxManager.queryRecoveryFileAsync(2) - val recoveryFileDocuments = ObjectBoxManager.queryRecoveryFileAsync(3) + binding.imageBack.setOnClickListener { + finish() + } + lifecycleScope.launch { + val recoveryFilePhoto = ObjectBoxManager.queryRecoveryFileAsync(Common.FILE_TYPE_PHOTO) + sharedViewModel.setPhotosRecoveredFiles(recoveryFilePhoto) + val recoveryFileVideo = ObjectBoxManager.queryRecoveryFileAsync(Common.FILE_TYPE_VIDEO) + sharedViewModel.setVideosRecoveredFiles(recoveryFileVideo) + val recoveryFileAudio = ObjectBoxManager.queryRecoveryFileAsync(Common.FILE_TYPE_AUDIO) + sharedViewModel.setAudiosRecoveredFiles(recoveryFileAudio) + val recoveryFileDocuments = + ObjectBoxManager.queryRecoveryFileAsync(Common.FILE_TYPE_DOCUMENTS) + sharedViewModel.setDocumentsRecoveredFiles(recoveryFileDocuments) binding.tabLayout.run { - getTabAt(0)?.customView?.findViewById(R.id.tab_item_count)?.text = getString(R.string.text_counts,recoveryFilePhoto.size) - getTabAt(1)?.customView?.findViewById(R.id.tab_item_count)?.text = getString(R.string.text_counts,recoveryFileVideo.size) - getTabAt(2)?.customView?.findViewById(R.id.tab_item_count)?.text = getString(R.string.text_counts,recoveryFileAudio.size) - getTabAt(3)?.customView?.findViewById(R.id.tab_item_count)?.text = getString(R.string.text_counts,recoveryFileDocuments.size) + getTabAt(0)?.customView?.findViewById(R.id.tab_item_count)?.text = + getString(R.string.text_counts, recoveryFilePhoto.size) + getTabAt(1)?.customView?.findViewById(R.id.tab_item_count)?.text = + getString(R.string.text_counts, recoveryFileVideo.size) + getTabAt(2)?.customView?.findViewById(R.id.tab_item_count)?.text = + getString(R.string.text_counts, recoveryFileAudio.size) + getTabAt(3)?.customView?.findViewById(R.id.tab_item_count)?.text = + getString(R.string.text_counts, recoveryFileDocuments.size) } } } diff --git a/app/src/main/java/com/ux/video/file/filerecovery/recovery/ui/recoveryphoto/RecoveryPhotoFragment.kt b/app/src/main/java/com/ux/video/file/filerecovery/recovery/ui/recoveryphoto/RecoveryPhotoFragment.kt index c1bb2c8..1bc7b75 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/recovery/ui/recoveryphoto/RecoveryPhotoFragment.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/recovery/ui/recoveryphoto/RecoveryPhotoFragment.kt @@ -1,32 +1,192 @@ package com.ux.video.file.filerecovery.recovery.ui.recoveryphoto -import androidx.fragment.app.viewModels import android.os.Bundle -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible +import androidx.fragment.app.activityViewModels +import androidx.fragment.app.viewModels +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import com.ux.video.file.filerecovery.R import com.ux.video.file.filerecovery.base.BaseFragment import com.ux.video.file.filerecovery.databinding.FragmentRecoveryPhotoBinding +import com.ux.video.file.filerecovery.db.ResultDataFiles +import com.ux.video.file.filerecovery.sort.PhotoDisplayDateAdapter +import com.ux.video.file.filerecovery.sort.PhotoDisplayDateChildAdapter +import com.ux.video.file.filerecovery.utils.Common +import com.ux.video.file.filerecovery.utils.ExtendFunctions.dpToPx class RecoveryPhotoFragment : BaseFragment() { companion object { - fun newInstance() = RecoveryPhotoFragment() + private const val ARG_FILE_TYPE = "arg_file_type" + + fun newInstance(fileType: Int): RecoveryPhotoFragment { + val fragment = RecoveryPhotoFragment() + val args = Bundle().apply { + putInt(ARG_FILE_TYPE, fileType) + } + fragment.arguments = args + return fragment + } } - private val viewModel: RecoveryPhotoViewModel by viewModels() + // 0-3 photo\video\audio\documents + private var fileType: Int = Common.FILE_TYPE_PHOTO - override fun initBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRecoveryPhotoBinding = + private lateinit var mAdapter: PhotoDisplayDateChildAdapter + private var selectedList: List? = null + + + private val sharedViewModel: RecoveryPhotoViewModel by activityViewModels() + + override fun initBinding( + inflater: LayoutInflater, + container: ViewGroup? + ): FragmentRecoveryPhotoBinding = FragmentRecoveryPhotoBinding.inflate(inflater, container, false) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + fileType = arguments?.getInt(ARG_FILE_TYPE) ?: Common.FILE_TYPE_PHOTO + binding.run { + when (fileType) { + Common.FILE_TYPE_PHOTO -> { + layoutEmpty.tvScan.text = getString(R.string.scan_photos) + sharedViewModel.photoFiles.observe(viewLifecycleOwner) { + initViewVisible(it) + setRecoveredData(it, Common.VALUE_SCAN_TYPE_photo) + + } + } + + Common.FILE_TYPE_VIDEO -> { + layoutEmpty.tvScan.text = getString(R.string.scan_videos) + sharedViewModel.videoFiles.observe(viewLifecycleOwner) { + initViewVisible(it) + setRecoveredData(it, Common.VALUE_SCAN_TYPE_video) + } + } + + Common.FILE_TYPE_AUDIO -> { + layoutEmpty.tvScan.text = getString(R.string.scan_audios) + sharedViewModel.audioFiles.observe(viewLifecycleOwner) { + initViewVisible(it) + setRecoveredData(it, Common.VALUE_SCAN_TYPE_audio) + } + } + + Common.FILE_TYPE_DOCUMENTS -> { + layoutEmpty.tvScan.text = getString(R.string.scan_documents) + sharedViewModel.documentsFiles.observe(viewLifecycleOwner) { + initViewVisible(it) + setRecoveredData(it, Common.VALUE_SCAN_TYPE_documents) + } + } + + } + } + sharedViewModel.selectedLiveData.observe(viewLifecycleOwner) { displaySet -> + selectedList = displaySet.toList() + Common.showLog("当前显示筛选数据 选中状态更新: ${displaySet.size}") + selectedList?.let { + updateSelectStatus(it.size) + } + + } + + initClick() + } + private fun initViewVisible(list: List) { + binding.run { + recyclerView.isVisible = list.isNotEmpty() + layoutEmpty.relativeEmptyMain.isVisible = !list.isNotEmpty() + layoutBottom.run { + bottomMainLayout.isVisible = list.isNotEmpty() +// tvRight.text = getString(R.string.share) + } + tvAllSelect.isVisible = list.isNotEmpty() + } + } + + private fun updateSelectStatus(selectedCounts: Int) { + binding.run { + selectedCounts.let { + tvAllSelect.isSelected = it == mAdapter.itemCount + if (it <= 0) { + layoutBottom.tvLeft.isEnabled = false + layoutBottom.tvRight.isEnabled = false + } else { + layoutBottom.tvLeft.isEnabled = true + layoutBottom.tvRight.isEnabled = true + } + layoutBottom.tvLeft.text = getString(R.string.delete_placeholder, it) + layoutBottom.tvRight.text = getString(R.string.share_placeholder, it) + + } + } + + } + + private fun setRecoveredData(list: List, scanTye: Int) { + + mAdapter = PhotoDisplayDateChildAdapter( + mContext = requireContext(), + scanType = scanTye, + mColumns = 2, + viewModel = sharedViewModel, + onSelectedUpdate = { resultPhotosFiles, isAdd, allSelected -> + sharedViewModel.toggleSelection(isAdd, resultPhotosFiles) + + }, + hideThumbnailsUpdate = { hide -> + + }) { item -> + + }.apply { + setData(list) + } + updateSelectStatus(0) + binding.recyclerView.run { + adapter = mAdapter + when (scanTye) { + Common.VALUE_SCAN_TYPE_photo, Common.VALUE_SCAN_TYPE_video -> { + layoutManager = GridLayoutManager(requireContext(), 2) + val bPx = 6.dpToPx(context) + val aPx = 16.dpToPx(context) + val bottom = 75.dpToPx(context) + setPadding(aPx, 0, bPx, bottom) + } + + + Common.VALUE_SCAN_TYPE_audio, Common.VALUE_SCAN_TYPE_documents -> { + layoutManager = LinearLayoutManager(requireContext()) + val bPx = 6.dpToPx(context) + val aPx = 16.dpToPx(context) + val bottom = 75.dpToPx(context) + setPadding(aPx, 0, bPx, bottom) + } + + } + + } + + } + + private fun initClick() { + binding.tvAllSelect.setOnClickListener { + it.isSelected = !it.isSelected + mAdapter.setAllSelected(it.isSelected) + + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/ux/video/file/filerecovery/recovery/ui/recoveryphoto/RecoveryPhotoViewModel.kt b/app/src/main/java/com/ux/video/file/filerecovery/recovery/ui/recoveryphoto/RecoveryPhotoViewModel.kt index 8c76495..f1a18a6 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/recovery/ui/recoveryphoto/RecoveryPhotoViewModel.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/recovery/ui/recoveryphoto/RecoveryPhotoViewModel.kt @@ -1,7 +1,54 @@ package com.ux.video.file.filerecovery.recovery.ui.recoveryphoto +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import com.ux.video.file.filerecovery.db.ResultDataFiles +import com.ux.video.file.filerecovery.utils.Common class RecoveryPhotoViewModel : ViewModel() { + private val _photoFiles = MutableLiveData< List>(emptyList()) + val photoFiles: LiveData> = _photoFiles + private val _videoFiles = MutableLiveData< List>(emptyList()) + val videoFiles: LiveData< List> = _videoFiles + + private val _audioFiles = MutableLiveData< List>(emptyList()) + val audioFiles: LiveData< List> = _audioFiles + + private val _documentsFiles = MutableLiveData< List>(emptyList()) + val documentsFiles: LiveData< List> = _documentsFiles + + private val _selectedLiveData = MutableLiveData>(emptySet()) + val selectedLiveData: LiveData> = _selectedLiveData + + fun setPhotosRecoveredFiles(photos:List){ + _photoFiles.value = photos + } + fun setVideosRecoveredFiles(videos:List){ + _videoFiles.value = videos + } + fun setAudiosRecoveredFiles(audios:List){ + _audioFiles.value = audios + } + fun setDocumentsRecoveredFiles(documents:List){ + _documentsFiles.value = documents + } + + fun toggleSelection(isAdd: Boolean, resultDataFiles: ResultDataFiles) { + val current = _selectedLiveData.value?.toMutableSet() ?: mutableSetOf() + resultDataFiles.let { + if (isAdd) { + current.add(it) + } else { + current.remove(it) + } + } + _selectedLiveData.value = current.toSet() + } + + fun checkIsSelect(resultDataFiles: ResultDataFiles): Boolean { + val current = _selectedLiveData.value + return current?.contains(resultDataFiles) == true + } } \ No newline at end of file diff --git a/app/src/main/java/com/ux/video/file/filerecovery/sort/PhotoDisplayDateChildAdapter.kt b/app/src/main/java/com/ux/video/file/filerecovery/sort/PhotoDisplayDateChildAdapter.kt index bf3b4fe..0ca2ebc 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/sort/PhotoDisplayDateChildAdapter.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/sort/PhotoDisplayDateChildAdapter.kt @@ -7,6 +7,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.RelativeLayout +import androidx.lifecycle.ViewModel import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.bumptech.glide.load.DataSource @@ -24,6 +25,7 @@ import com.ux.video.file.filerecovery.databinding.FileSpanCountTwoAdapterBinding import com.ux.video.file.filerecovery.databinding.OneAudioItemBinding import com.ux.video.file.filerecovery.databinding.OneDocumentsItemBinding import com.ux.video.file.filerecovery.db.ResultDataFiles +import com.ux.video.file.filerecovery.recovery.ui.recoveryphoto.RecoveryPhotoViewModel import com.ux.video.file.filerecovery.utils.Common import com.ux.video.file.filerecovery.utils.CustomTextView import com.ux.video.file.filerecovery.utils.ExtendFunctions.dpToPx @@ -34,7 +36,7 @@ class PhotoDisplayDateChildAdapter( mContext: Context, var scanType: Int, var mColumns: Int, - var viewModel: ScanRepository, + var viewModel: ViewModel? = null, /** * 通知外层某天全选的按钮更新状态 * @param updatePath 当前点击的item @@ -173,7 +175,7 @@ class PhotoDisplayDateChildAdapter( it.textDuration.text = Common.formatDuration(duration) it.textSize.text = sizeString - initAudioDocuments(it.imageSelect,this) + initAudioDocuments(it.imageSelect, this) // viewModel.checkIsSelect(this).let { isSelected -> // it.imageSelect.isSelected = isSelected // addOrRemove(this, isSelected) @@ -198,11 +200,11 @@ class PhotoDisplayDateChildAdapter( it.textName.text = name it.textDate.text = Common.getItemMonthDay(lastModified) it.textSize.text = sizeString - targetFile?.let { file-> + targetFile?.let { file -> it.imageIcon.setImageResource(Common.getFileIconRes(file)) } - initAudioDocuments(it.imageSelect,this) + initAudioDocuments(it.imageSelect, this) it.constraintLayout.setOnClickListener { clickItem(this) @@ -230,11 +232,21 @@ class PhotoDisplayDateChildAdapter( RecyclerView.ViewHolder(vb.root) - private fun initAudioDocuments(imageSelect: ImageView,item: ResultDataFiles){ - viewModel.checkIsSelect(item).let { isSelected -> - imageSelect.isSelected = isSelected - addOrRemove(item, isSelected) + private fun initAudioDocuments(imageSelect: ImageView, item: ResultDataFiles) { + + viewModel?.let { + if (it is ScanRepository) { + it.checkIsSelect(item) + } else { + it as RecoveryPhotoViewModel + it.checkIsSelect(item) + }.let { isSelected -> + imageSelect.isSelected = isSelected == true + addOrRemove(item, isSelected == true) + + } } + imageSelect.setOnClickListener { it.isSelected = !it.isSelected it.isSelected.let { newStatus -> @@ -242,6 +254,7 @@ class PhotoDisplayDateChildAdapter( } } } + private fun initDateView( rootLayout: RelativeLayout, imageSelectStatus: ImageView, @@ -251,7 +264,7 @@ class PhotoDisplayDateChildAdapter( imageType: ImageView ) { item.run { - initAudioDocuments(imageSelectStatus,this) + initAudioDocuments(imageSelectStatus, this) // viewModel.checkIsSelect(this).let { // imageSelectStatus.isSelected = it // addOrRemove(this, it) diff --git a/app/src/main/java/com/ux/video/file/filerecovery/sort/PhotoSortingActivity.kt b/app/src/main/java/com/ux/video/file/filerecovery/sort/PhotoSortingActivity.kt index 60eee68..43c0539 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/sort/PhotoSortingActivity.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/sort/PhotoSortingActivity.kt @@ -131,7 +131,7 @@ class PhotoSortingActivity : BaseActivity() { mItemDecoration = GridSpacingItemDecoration(columns, Common.itemSpacing, Common.horizontalSpacing) updateButtonCounts(0) - viewModel = ViewModelProvider(this).get(ScanRepository::class.java) + viewModel = ViewModelProvider(this)[ScanRepository::class.java] viewModel.selectedLiveData.observe(this) { selectedSet -> allSelectedSetList = selectedSet diff --git a/app/src/main/java/com/ux/video/file/filerecovery/sort/RecoverOrDeleteManager.kt b/app/src/main/java/com/ux/video/file/filerecovery/sort/RecoverOrDeleteManager.kt index b1873cf..954af7c 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/sort/RecoverOrDeleteManager.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/sort/RecoverOrDeleteManager.kt @@ -112,7 +112,7 @@ object RecoverOrDeleteManager { if (success){ ScanManager.showLog("--------删除图片 ", "----------${currentCounts} ${path}") dialogDeleting?.updateProgress(currentCounts) - ObjectBoxManager.deleteRecoveryFile(data) + } }) { counts -> diff --git a/app/src/main/java/com/ux/video/file/filerecovery/utils/Common.kt b/app/src/main/java/com/ux/video/file/filerecovery/utils/Common.kt index 80ea31a..cdd95ee 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/utils/Common.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/utils/Common.kt @@ -35,6 +35,12 @@ object Common { val VALUE_SCAN_TYPE_documents = 6 val VALUE_SCAN_TYPE_deleted_documents = 7 + val FILE_TYPE_PHOTO = 0 + val FILE_TYPE_VIDEO = 1 + val FILE_TYPE_AUDIO = 2 + val FILE_TYPE_DOCUMENTS = 3 + + val rootDir = Environment.getExternalStorageDirectory() val dateFormat = SimpleDateFormat("MMMM d,yyyy", Locale.ENGLISH) diff --git a/app/src/main/java/com/ux/video/file/filerecovery/utils/ScanManager.kt b/app/src/main/java/com/ux/video/file/filerecovery/utils/ScanManager.kt index bd4c1f9..85dbd0c 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/utils/ScanManager.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/utils/ScanManager.kt @@ -114,8 +114,8 @@ object ScanManager { file.length() ), lastModified = file.lastModified(), - resolution = getResolution(type,file), - fileType = getFileType(type) + resolution = getResolution(type, file), + fileType = getFileType(type) ) } ResultData(dir, ArrayList(resultDataFilesList)) @@ -220,8 +220,8 @@ object ScanManager { file.length() ), lastModified = file.lastModified(), - resolution = getResolution(type,file), - fileType = getFileType(type) + resolution = getResolution(type, file), + fileType = getFileType(type) ) } @@ -233,15 +233,16 @@ object ScanManager { private fun getFileType(scanType: Int): Int { return when (scanType) { - VALUE_SCAN_TYPE_deleted_photo -> 0 + VALUE_SCAN_TYPE_photo, VALUE_SCAN_TYPE_deleted_photo -> 0 - VALUE_SCAN_TYPE_deleted_video -> 1 - - VALUE_SCAN_TYPE_deleted_audio -> 2 + VALUE_SCAN_TYPE_video, VALUE_SCAN_TYPE_deleted_video -> 1 + VALUE_SCAN_TYPE_audio, VALUE_SCAN_TYPE_deleted_audio -> 2 + VALUE_SCAN_TYPE_documents, VALUE_SCAN_TYPE_deleted_documents -> 3 else -> 3 } } + private fun getFileSizeByMediaStore(context: Context, file: File): Long { val uri = Uri.fromFile(file) context.contentResolver.query(uri, arrayOf(OpenableColumns.SIZE), null, null, null) @@ -254,8 +255,8 @@ object ScanManager { return file.length() // fallback } - private fun getResolution(type: Int,file: File): String { - return when (type) { + private fun getResolution(type: Int, file: File): String { + return when (type) { VALUE_SCAN_TYPE_photo, VALUE_SCAN_TYPE_deleted_photo -> { getImageSize(file).run { "$first*$second" @@ -303,7 +304,7 @@ object ScanManager { selectedSet: Set, rootDir: File = Common.rootDir, folder: String, - onProgress: (currentCounts: Int, data:ResultDataFiles,fileName: String, success: Boolean) -> Unit, + onProgress: (currentCounts: Int, data: ResultDataFiles, fileName: String, success: Boolean) -> Unit, onComplete: (currentCounts: Int) -> Unit ) { launch(Dispatchers.IO) { @@ -324,7 +325,7 @@ object ScanManager { success = true recoveryCount++ withContext(Dispatchers.Main) { - onProgress(index + 1,resultPhotosFiles, srcFile.name, success) + onProgress(index + 1, resultPhotosFiles, srcFile.name, success) } } catch (e: Exception) { e.printStackTrace() @@ -346,7 +347,7 @@ object ScanManager { */ fun CoroutineScope.deleteFilesAsync( selectedSet: Set, - onProgress: (currentCounts: Int, data:ResultDataFiles,fileName: String, success: Boolean) -> Unit, + onProgress: (currentCounts: Int, data: ResultDataFiles, fileName: String, success: Boolean) -> Unit, onComplete: (currentCounts: Int) -> Unit ) { launch(Dispatchers.IO) { @@ -358,10 +359,10 @@ object ScanManager { deletedCount++ } withContext(Dispatchers.Main) { - onProgress(index + 1, resultPhotosFiles,file.name, true) + onProgress(index + 1, resultPhotosFiles, file.name, true) } } catch (e: Exception) { - onProgress(index + 1,resultPhotosFiles, resultPhotosFiles.path!!, false) + onProgress(index + 1, resultPhotosFiles, resultPhotosFiles.path!!, false) } } withContext(Dispatchers.Main) { @@ -372,6 +373,4 @@ object ScanManager { } - - } diff --git a/app/src/main/java/com/ux/video/file/filerecovery/utils/ScanRepository.kt b/app/src/main/java/com/ux/video/file/filerecovery/utils/ScanRepository.kt index d333fd2..67ede9b 100644 --- a/app/src/main/java/com/ux/video/file/filerecovery/utils/ScanRepository.kt +++ b/app/src/main/java/com/ux/video/file/filerecovery/utils/ScanRepository.kt @@ -56,7 +56,7 @@ class ScanRepository : ViewModel() { /** - * 删除操作完成过后,对选中集合进行更新 + * 删除操作完成过后,对选中集合进行更新(批量删除) */ fun afterDeleted(){ val selected = _selectedLiveData.value.orEmpty().toMutableSet() @@ -69,7 +69,7 @@ class ScanRepository : ViewModel() { } /** - * 详情页删除完毕,移除删除掉的数据 + * 详情页删除完毕,移除删除掉的数据(单个删除) */ fun afterSingleDeleted(deletedItem:ResultDataFiles){ val selected = _selectedLiveData.value.orEmpty().toMutableSet() diff --git a/app/src/main/res/drawable/icon_checkmark_24dp.xml b/app/src/main/res/drawable/icon_checkmark_24dp.xml new file mode 100644 index 0000000..3b2b23c --- /dev/null +++ b/app/src/main/res/drawable/icon_checkmark_24dp.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/app/src/main/res/drawable/icon_unselected_16dp.xml b/app/src/main/res/drawable/icon_unselected_16dp.xml index 72cbe0c..1600cfb 100644 --- a/app/src/main/res/drawable/icon_unselected_16dp.xml +++ b/app/src/main/res/drawable/icon_unselected_16dp.xml @@ -5,5 +5,5 @@ android:viewportHeight="1024"> + android:fillColor="@color/white"/> diff --git a/app/src/main/res/drawable/icon_unselected_24dp.xml b/app/src/main/res/drawable/icon_unselected_24dp.xml new file mode 100644 index 0000000..0c40e66 --- /dev/null +++ b/app/src/main/res/drawable/icon_unselected_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/icon_unselected_28dp.xml b/app/src/main/res/drawable/icon_unselected_28dp.xml index bb50f4a..591fae9 100644 --- a/app/src/main/res/drawable/icon_unselected_28dp.xml +++ b/app/src/main/res/drawable/icon_unselected_28dp.xml @@ -5,5 +5,5 @@ android:viewportHeight="1024"> + android:fillColor="@color/white"/> diff --git a/app/src/main/res/drawable/icon_unselected_black_16dp.xml b/app/src/main/res/drawable/icon_unselected_black_16dp.xml new file mode 100644 index 0000000..72cbe0c --- /dev/null +++ b/app/src/main/res/drawable/icon_unselected_black_16dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/icon_unselected_black_24dp.xml b/app/src/main/res/drawable/icon_unselected_black_24dp.xml new file mode 100644 index 0000000..5690b95 --- /dev/null +++ b/app/src/main/res/drawable/icon_unselected_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/icon_warining.png b/app/src/main/res/drawable/icon_warining.png new file mode 100644 index 0000000..513bc75 Binary files /dev/null and b/app/src/main/res/drawable/icon_warining.png differ diff --git a/app/src/main/res/drawable/image_empty_recovered_files.png b/app/src/main/res/drawable/image_empty_recovered_files.png new file mode 100644 index 0000000..fd831dc Binary files /dev/null and b/app/src/main/res/drawable/image_empty_recovered_files.png differ diff --git a/app/src/main/res/drawable/selector_icon_checkmark_24dp_9696a2.xml b/app/src/main/res/drawable/selector_icon_checkmark_24dp_9696a2.xml new file mode 100644 index 0000000..3ac5be6 --- /dev/null +++ b/app/src/main/res/drawable/selector_icon_checkmark_24dp_9696a2.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_icon_select_black_16.xml b/app/src/main/res/drawable/selector_icon_select_black_16.xml new file mode 100644 index 0000000..c64e2da --- /dev/null +++ b/app/src/main/res/drawable/selector_icon_select_black_16.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_icon_select_black_24.xml b/app/src/main/res/drawable/selector_icon_select_black_24.xml new file mode 100644 index 0000000..03103a2 --- /dev/null +++ b/app/src/main/res/drawable/selector_icon_select_black_24.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/tab_indicator.xml b/app/src/main/res/drawable/tab_indicator.xml new file mode 100644 index 0000000..4663360 --- /dev/null +++ b/app/src/main/res/drawable/tab_indicator.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_recovery.xml b/app/src/main/res/layout/activity_recovery.xml index ec3e632..9a3b404 100644 --- a/app/src/main/res/layout/activity_recovery.xml +++ b/app/src/main/res/layout/activity_recovery.xml @@ -2,7 +2,7 @@ - - + android:layout_height="match_parent" + android:background="@color/color_bg" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/common_bottom_btn.xml b/app/src/main/res/layout/common_bottom_btn.xml index 352620b..fd0731e 100644 --- a/app/src/main/res/layout/common_bottom_btn.xml +++ b/app/src/main/res/layout/common_bottom_btn.xml @@ -2,6 +2,7 @@ - + android:layout_height="match_parent"> - + - \ No newline at end of file + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_empty_recovered_files.xml b/app/src/main/res/layout/layout_empty_recovered_files.xml new file mode 100644 index 0000000..cee79c0 --- /dev/null +++ b/app/src/main/res/layout/layout_empty_recovered_files.xml @@ -0,0 +1,41 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/one_audio_item.xml b/app/src/main/res/layout/one_audio_item.xml index 0c1dd72..517b273 100644 --- a/app/src/main/res/layout/one_audio_item.xml +++ b/app/src/main/res/layout/one_audio_item.xml @@ -11,7 +11,7 @@ android:layout_width="24dp" android:layout_height="24dp" app:layout_constraintLeft_toLeftOf="parent" - android:src="@drawable/selector_icon_checkmark_28dp" + android:src="@drawable/selector_icon_checkmark_24dp_9696a2" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent" /> diff --git a/app/src/main/res/layout/one_documents_item.xml b/app/src/main/res/layout/one_documents_item.xml index 8ff3843..426f171 100644 --- a/app/src/main/res/layout/one_documents_item.xml +++ b/app/src/main/res/layout/one_documents_item.xml @@ -10,7 +10,7 @@ android:id="@+id/image_select" android:layout_width="24dp" android:layout_height="24dp" - android:src="@drawable/selector_icon_checkmark_28dp" + android:src="@drawable/selector_icon_checkmark_24dp_9696a2" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" /> diff --git a/app/src/main/res/layout/photo_display_date_adapter.xml b/app/src/main/res/layout/photo_display_date_adapter.xml index f2604d7..e805b48 100644 --- a/app/src/main/res/layout/photo_display_date_adapter.xml +++ b/app/src/main/res/layout/photo_display_date_adapter.xml @@ -33,7 +33,7 @@ android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_marginEnd="16dp" - android:drawableStart="@drawable/selector_icon_select_16" + android:drawableStart="@drawable/selector_icon_select_black_16" android:drawablePadding="4dp" android:paddingTop="21dp" android:text="@string/select" diff --git a/app/src/main/res/layout/tab_layout_item.xml b/app/src/main/res/layout/tab_layout_item.xml index 97a87ce..501ba0d 100644 --- a/app/src/main/res/layout/tab_layout_item.xml +++ b/app/src/main/res/layout/tab_layout_item.xml @@ -1,7 +1,7 @@ @@ -11,7 +11,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/selector_recovery_file_tab_layout_title" - android:textSize="16sp" + android:textSize="15sp" + android:gravity="center" app:fontType="bold" /> Search Recovered files (%d) + Please do not uninstall the File Recovery - +All Recovery to avoid file loss. + No files have been recovered yet~ + Scan photos + Scan videos + Scan audios + Scan documents + Share (%d) +