Skip to content

Commit 3661a4d

Browse files
committed
add compression types method signatures
1 parent 8ee16de commit 3661a4d

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/CompressionFormat.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ package com.simplemobiletools.filemanager.pro.helpers
33
enum class CompressionFormat(val extension: String) {
44
ZIP(".zip"),
55
SEVEN_ZIP(".7z"),
6+
TAR_DEFLATE(".tar.deflate"),
67
TAR_GZ(".tar.gz"),
8+
TAR_SZ(".tar.sz"),
79
TAR_XZ(".tar.xz");
810

911
companion object {
1012
fun fromExtension(extension: String): CompressionFormat {
1113
return when (extension.lowercase()) {
1214
ZIP.extension -> ZIP
1315
SEVEN_ZIP.extension -> SEVEN_ZIP
16+
TAR_DEFLATE.extension -> TAR_DEFLATE
1417
TAR_GZ.extension -> TAR_GZ
18+
TAR_SZ.extension -> TAR_SZ
1519
TAR_XZ.extension -> TAR_XZ
1620
else -> ZIP
1721
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/CompressionHelper.kt

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.simplemobiletools.filemanager.pro.helpers
22

3-
import android.annotation.SuppressLint
43
import com.simplemobiletools.commons.activities.BaseSimpleActivity
54
import com.simplemobiletools.commons.extensions.*
65
import net.lingala.zip4j.io.outputstream.ZipOutputStream
@@ -13,13 +12,28 @@ import java.util.LinkedList
1312
class CompressionHelper {
1413

1514
companion object {
16-
@SuppressLint("NewApi")
1715
fun compressPaths(
1816
activity: BaseSimpleActivity,
1917
sourcePaths: List<String>,
2018
targetPath: String,
2119
compressionFormat: CompressionFormat,
2220
password: String? = null
21+
): Boolean {
22+
return when (compressionFormat) {
23+
CompressionFormat.ZIP -> compressToZip(activity, sourcePaths, targetPath, password)
24+
CompressionFormat.SEVEN_ZIP -> compressToSevenZip(activity, sourcePaths, targetPath, password)
25+
CompressionFormat.TAR_DEFLATE -> compressToTarDeflate(activity, sourcePaths, targetPath, password)
26+
CompressionFormat.TAR_GZ -> compressToTarGz(activity, sourcePaths, targetPath, password)
27+
CompressionFormat.TAR_SZ -> compressToTarSz(activity, sourcePaths, targetPath, password)
28+
CompressionFormat.TAR_XZ -> compressToTarXz(activity, sourcePaths, targetPath, password)
29+
}
30+
}
31+
32+
private fun compressToZip(
33+
activity: BaseSimpleActivity,
34+
sourcePaths: List<String>,
35+
targetPath: String,
36+
password: String? = null
2337
): Boolean {
2438
val queue = LinkedList<String>()
2539
val fos = activity.getFileOutputStreamSync(targetPath, "application/zip") ?: return false
@@ -101,5 +115,50 @@ class CompressionHelper {
101115
}
102116
return true
103117
}
118+
119+
private fun compressToSevenZip(
120+
activity: BaseSimpleActivity,
121+
sourcePaths: List<String>,
122+
targetPath: String,
123+
password: String? = null
124+
): Boolean {
125+
return false
126+
}
127+
128+
private fun compressToTarDeflate(
129+
activity: BaseSimpleActivity,
130+
sourcePaths: List<String>,
131+
targetPath: String,
132+
password: String? = null
133+
): Boolean {
134+
return false
135+
}
136+
137+
private fun compressToTarGz(
138+
activity: BaseSimpleActivity,
139+
sourcePaths: List<String>,
140+
targetPath: String,
141+
password: String? = null
142+
): Boolean {
143+
return false
144+
}
145+
146+
private fun compressToTarSz(
147+
activity: BaseSimpleActivity,
148+
sourcePaths: List<String>,
149+
targetPath: String,
150+
password: String? = null
151+
): Boolean {
152+
return false
153+
}
154+
155+
private fun compressToTarXz(
156+
activity: BaseSimpleActivity,
157+
sourcePaths: List<String>,
158+
targetPath: String,
159+
password: String? = null
160+
): Boolean {
161+
return false
162+
}
104163
}
105164
}

0 commit comments

Comments
 (0)