Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
prepare to releaae
  • Loading branch information
WirelessAlien committed Feb 19, 2025
1 parent d88e73a commit c3a815f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ class FileAdapter(private val context: Context, private val mainFragment: MainFr
}
}

fun clearSelection() {
selectedItems.clear()
notifyDataSetChanged()
}

fun updateFilesAndFilter(newFiles: ArrayList<File>, query: String? = null) {
files.clear()
files.addAll(newFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
handler.removeCallbacks(updateProgressRunnable)
val dirPath = intent.getStringExtra(EXTRA_DIR_PATH)
if (dirPath != null) {
Snackbar.make(binding.root, getString(R.string.archive_success), Snackbar.LENGTH_LONG)
.setAction(getString(R.string.open_folder)) {
Snackbar.make(binding.root, getString(R.string.open_folder), Snackbar.LENGTH_LONG)
.setAction(getString(R.string.ok)) {
navigateToParentDir(File(dirPath))
}
.show()
Expand Down Expand Up @@ -276,13 +276,10 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
}

private fun unselectAllFiles() {
for (i in 0 until adapter.itemCount) {
if (selectedFiles.contains(adapter.files[i])) {
adapter.toggleSelection(i)
}
}
selectedFiles.clear()
adapter.clearSelection()
updateActionModeTitle()
actionMode?.finish()
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -394,8 +391,11 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
if (selectedFiles.isNotEmpty()) {
unselectAllFiles()
} else {
isEnabled = false
requireActivity().onBackPressed()
if (parentFragmentManager.backStackEntryCount > 0) {
parentFragmentManager.popBackStack()
} else {
requireActivity().finish()
}
}
}
})
Expand Down Expand Up @@ -743,6 +743,21 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
true
}

R.id.m_archive_tar -> {
val fragmentManager = parentFragmentManager
val newFragment = TarOptionsDialogFragment.newInstance(adapter)

// Show the fragment fullscreen.
val transaction = fragmentManager.beginTransaction()
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
transaction.add(android.R.id.content, newFragment)
.addToBackStack(null)
.commit()

actionMode?.finish() // Destroy the action mode
true
}

R.id.menu_action_unselect_all -> {
unselectAllFiles()
actionMode?.finish() // Destroy the action mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ class ArchiveSplitZipService : Service() {
} else {
parentDir = File(selectedFiles.first()).parentFile ?: Environment.getExternalStorageDirectory()
}
val outputFile = File(parentDir, "$archiveName.zip")
var outputFile = File(parentDir, "$archiveName.zip")
var counter = 1

while (outputFile.exists()) {
outputFile = File(parentDir, "$archiveName ($counter).zip")
counter++
}
val zipFile = ZipFile(outputFile)
if (isEncrypted) {
zipFile.setPassword(password?.toCharArray())
Expand Down Expand Up @@ -249,7 +255,7 @@ class ArchiveSplitZipService : Service() {

if (progressMonitor.result == ProgressMonitor.Result.SUCCESS) {
showCompletionNotification()
sendLocalBroadcast(Intent(ACTION_ARCHIVE_COMPLETE).putExtra(EXTRA_DIR_PATH, outputFile.absolutePath))
sendLocalBroadcast(Intent(ACTION_ARCHIVE_COMPLETE).putExtra(EXTRA_DIR_PATH, parentDir))
} else {
showErrorNotification(getString(R.string.zip_creation_failed))
sendLocalBroadcast(Intent(ACTION_ARCHIVE_ERROR).putExtra(EXTRA_ERROR_MESSAGE, progressMonitor.result))
Expand Down

0 comments on commit c3a815f

Please sign in to comment.