-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add extraction support for - "tar.bz2", "tar.gz", "tar.lz4", "tar.lzm…
…a", "tar.sz", "tar.xz", "tar.z", "tar.zstd"
- Loading branch information
1 parent
f0564d9
commit 6ffed44
Showing
9 changed files
with
354 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/src/main/java/com/wirelessalien/zipxtract/CreateZipFragment.kt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
app/src/main/java/com/wirelessalien/zipxtract/adapter/FilePathAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2023 WirelessAlien <https://github.com/WirelessAlien> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.wirelessalien.zipxtract.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Button | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.wirelessalien.zipxtract.R | ||
import java.io.File | ||
|
||
class FilePathAdapter(private val filePaths: MutableList<String>, private val onDeleteClick: (String) -> Unit) : | ||
RecyclerView.Adapter<FilePathAdapter.ViewHolder>() { | ||
|
||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
val filePathText: TextView = itemView.findViewById(R.id.textFileName) | ||
val deleteButton: Button = itemView.findViewById(R.id.deleteBtn) | ||
|
||
init { | ||
deleteButton.setOnClickListener { | ||
val position = adapterPosition | ||
if (position != RecyclerView.NO_POSITION) { | ||
val filePath = filePaths[position] | ||
onDeleteClick(filePath) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.list_item_file, parent, false) | ||
return ViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
val filePath = filePaths[position] | ||
holder.filePathText.text = filePath | ||
|
||
val file = File(filePath) | ||
if (file.isDirectory) { | ||
holder.deleteButton.visibility = View.GONE | ||
} else { | ||
holder.deleteButton.visibility = View.VISIBLE | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return filePaths.size | ||
} | ||
|
||
fun removeFilePath(filePath: String) { | ||
val position = filePaths.indexOf(filePath) | ||
if (position != -1) { | ||
filePaths.removeAt(position) | ||
notifyItemRemoved(position) | ||
notifyItemRangeChanged(position, filePaths.size) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.