diff --git a/app/src/main/java/com/wirelessalien/zipxtract/activity/MainActivity.kt b/app/src/main/java/com/wirelessalien/zipxtract/activity/MainActivity.kt
index 1e9ca55..8443c27 100644
--- a/app/src/main/java/com/wirelessalien/zipxtract/activity/MainActivity.kt
+++ b/app/src/main/java/com/wirelessalien/zipxtract/activity/MainActivity.kt
@@ -597,12 +597,12 @@ class MainActivity : AppCompatActivity(), FileAdapter.OnItemClickListener, FileA
private fun initRecyclerView() {
// Initialize RecyclerView and adapter as before
- recyclerView = findViewById(R.id.recyclerView)
- recyclerView.layoutManager = LinearLayoutManager(this)
+ binding.recyclerView.layoutManager = LinearLayoutManager(this)
+ binding.recyclerView.isNestedScrollingEnabled = false
adapter = FileAdapter(this, this, ArrayList())
adapter.setOnItemClickListener(this)
adapter.setOnFileLongClickListener(this)
- recyclerView.adapter = adapter
+ binding.recyclerView.adapter = adapter
// Update the adapter with the initial file list
updateAdapterWithFullList()
}
diff --git a/app/src/main/java/com/wirelessalien/zipxtract/constant/BroadcastConstants.kt b/app/src/main/java/com/wirelessalien/zipxtract/constant/BroadcastConstants.kt
index f924a71..626a581 100644
--- a/app/src/main/java/com/wirelessalien/zipxtract/constant/BroadcastConstants.kt
+++ b/app/src/main/java/com/wirelessalien/zipxtract/constant/BroadcastConstants.kt
@@ -24,6 +24,7 @@ object BroadcastConstants {
const val ACTION_MULTI_ZIP_EXTRACTION_CANCEL = "ACTION_ZIP_EXTRACTION_CANCEL"
const val ACTION_ARCHIVE_7Z_CANCEL = "ACTION_7Z_ARCHIVE_CANCEL"
const val ACTION_ARCHIVE_ZIP_CANCEL = "ACTION_ZIP_ARCHIVE_CANCEL"
+ const val ACTION_ARCHIVE_TAR_CANCEL = "ACTION_TAR_ARCHIVE_CANCEL"
const val ACTION_ARCHIVE_SPLIT_ZIP_CANCEL = "ACTION_SPLIT_ZIP_ARCHIVE_CANCEL"
const val ACTION_ARCHIVE_COMPLETE = "ACTION_ARCHIVE_COMPLETE"
const val ACTION_ARCHIVE_ERROR = "ACTION_ARCHIVE_ERROR"
diff --git a/app/src/main/java/com/wirelessalien/zipxtract/service/Archive7zService.kt b/app/src/main/java/com/wirelessalien/zipxtract/service/Archive7zService.kt
index bf9da0e..c6356dd 100644
--- a/app/src/main/java/com/wirelessalien/zipxtract/service/Archive7zService.kt
+++ b/app/src/main/java/com/wirelessalien/zipxtract/service/Archive7zService.kt
@@ -31,6 +31,8 @@ import com.wirelessalien.zipxtract.R
import com.wirelessalien.zipxtract.constant.BroadcastConstants
import com.wirelessalien.zipxtract.constant.BroadcastConstants.ACTION_ARCHIVE_COMPLETE
import com.wirelessalien.zipxtract.constant.BroadcastConstants.ACTION_ARCHIVE_ERROR
+import com.wirelessalien.zipxtract.constant.BroadcastConstants.ARCHIVE_NOTIFICATION_CHANNEL_ID
+import com.wirelessalien.zipxtract.constant.BroadcastConstants.EXTRA_PROGRESS
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@@ -53,7 +55,6 @@ class Archive7zService : Service() {
companion object {
const val NOTIFICATION_ID = 808
- const val CHANNEL_ID = "archive_service_channel"
const val EXTRA_ARCHIVE_NAME = "archiveName"
const val EXTRA_PASSWORD = "password"
const val EXTRA_COMPRESSION_LEVEL = "compressionLevel"
@@ -109,8 +110,8 @@ class Archive7zService : Service() {
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
- CHANNEL_ID,
- "Archive Service",
+ ARCHIVE_NOTIFICATION_CHANNEL_ID,
+ getString(R.string.compress_archive_notification_name),
NotificationManager.IMPORTANCE_LOW
)
val notificationManager = getSystemService(NotificationManager::class.java)
@@ -119,11 +120,11 @@ class Archive7zService : Service() {
}
private fun createNotification(progress: Int): Notification {
- val builder = NotificationCompat.Builder(this, CHANNEL_ID)
- .setContentTitle("Creating Archive")
+ val builder = NotificationCompat.Builder(this, ARCHIVE_NOTIFICATION_CHANNEL_ID)
+ .setContentTitle(getString(R.string.archive_ongoing))
.setSmallIcon(R.drawable.ic_notification_icon)
.setProgress(100, progress, progress == 0)
- .addAction(R.drawable.ic_round_cancel, "Cancel", createCancelIntent())
+ .addAction(R.drawable.ic_round_cancel, getString(R.string.cancel), createCancelIntent())
.setOngoing(true)
return builder.build()
@@ -180,7 +181,7 @@ class Archive7zService : Service() {
}
override fun getStream(i: Int): ISequentialInStream {
- if (archiveJob?.isCancelled == true) throw SevenZipException("Extraction cancelled")
+ if (archiveJob?.isCancelled == true) throw SevenZipException(getString(R.string.operation_cancelled))
return RandomAccessFileInStream(RandomAccessFile(filesToArchive[i], "r"))
}
@@ -196,16 +197,16 @@ class Archive7zService : Service() {
}
} catch (e: SevenZipException) {
e.printStackTrace()
- showErrorNotification("Archive creation failed: ${e.message}")
- sendLocalBroadcast(Intent(ACTION_ARCHIVE_ERROR).putExtra("error_message", "Archive creation failed: ${e.message}"))
+ showErrorNotification(": ${e.message}")
+ sendLocalBroadcast(Intent(ACTION_ARCHIVE_ERROR).putExtra(EXTRA_PROGRESS, ": ${e.message}"))
} catch (e: IOException) {
e.printStackTrace()
- showErrorNotification("Archive creation failed: ${e.message}")
- sendLocalBroadcast(Intent(ACTION_ARCHIVE_ERROR).putExtra("error_message", "Archive creation failed: ${e.message}"))
+ showErrorNotification(": ${e.message}")
+ sendLocalBroadcast(Intent(ACTION_ARCHIVE_ERROR).putExtra(EXTRA_PROGRESS, ": ${e.message}"))
} catch (e: OutOfMemoryError) {
e.printStackTrace()
- showErrorNotification("Archive creation failed: ${e.message}")
- sendLocalBroadcast(Intent(ACTION_ARCHIVE_ERROR).putExtra("error_message", "Archive creation failed: ${e.message}"))
+ showErrorNotification(": ${e.message}")
+ sendLocalBroadcast(Intent(ACTION_ARCHIVE_ERROR).putExtra(EXTRA_PROGRESS, ": ${e.message}"))
}
}
@@ -215,13 +216,13 @@ class Archive7zService : Service() {
notificationManager.notify(NOTIFICATION_ID, notification)
sendLocalBroadcast(Intent(BroadcastConstants.ACTION_ARCHIVE_PROGRESS).putExtra(
- BroadcastConstants.EXTRA_PROGRESS, progress))
+ EXTRA_PROGRESS, progress))
}
private fun showErrorNotification(error: String) {
stopForegroundService()
- val notification = NotificationCompat.Builder(this, CHANNEL_ID)
- .setContentTitle("Archive Creation Failed")
+ val notification = NotificationCompat.Builder(this, ARCHIVE_NOTIFICATION_CHANNEL_ID)
+ .setContentTitle(getString(R.string.sevenz_creation_failed))
.setContentText(error)
.setSmallIcon(R.drawable.ic_notification_icon)
.setAutoCancel(true)
diff --git a/app/src/main/java/com/wirelessalien/zipxtract/service/ArchiveSplitZipService.kt b/app/src/main/java/com/wirelessalien/zipxtract/service/ArchiveSplitZipService.kt
index cff1d46..b615959 100644
--- a/app/src/main/java/com/wirelessalien/zipxtract/service/ArchiveSplitZipService.kt
+++ b/app/src/main/java/com/wirelessalien/zipxtract/service/ArchiveSplitZipService.kt
@@ -31,6 +31,7 @@ import com.wirelessalien.zipxtract.R
import com.wirelessalien.zipxtract.constant.BroadcastConstants
import com.wirelessalien.zipxtract.constant.BroadcastConstants.ACTION_ARCHIVE_COMPLETE
import com.wirelessalien.zipxtract.constant.BroadcastConstants.ACTION_ARCHIVE_ERROR
+import com.wirelessalien.zipxtract.constant.BroadcastConstants.ARCHIVE_NOTIFICATION_CHANNEL_ID
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@@ -51,7 +52,6 @@ class ArchiveSplitZipService : Service() {
companion object {
const val NOTIFICATION_ID = 754
- const val CHANNEL_ID = "split_zip_service_channel"
const val EXTRA_ARCHIVE_NAME = "archiveName"
const val EXTRA_PASSWORD = "password"
const val EXTRA_COMPRESSION_METHOD = "compressionMethod"
@@ -113,8 +113,8 @@ class ArchiveSplitZipService : Service() {
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
- CHANNEL_ID,
- "Split Zip Service",
+ ARCHIVE_NOTIFICATION_CHANNEL_ID,
+ getString(R.string.compress_archive_notification_name),
NotificationManager.IMPORTANCE_LOW
)
val notificationManager = getSystemService(NotificationManager::class.java)
@@ -123,11 +123,11 @@ class ArchiveSplitZipService : Service() {
}
private fun createNotification(progress: Int): Notification {
- val builder = NotificationCompat.Builder(this, CHANNEL_ID)
- .setContentTitle("Creating Split Zip Archive")
+ val builder = NotificationCompat.Builder(this, ARCHIVE_NOTIFICATION_CHANNEL_ID)
+ .setContentTitle(getString(R.string.archive_ongoing))
.setSmallIcon(R.drawable.ic_notification_icon)
.setProgress(100, progress, progress == 0)
- .addAction(R.drawable.ic_round_cancel, "Cancel", createCancelIntent())
+ .addAction(R.drawable.ic_round_cancel, getString(R.string.cancel), createCancelIntent())
.setOngoing(true)
return builder.build()
@@ -209,7 +209,7 @@ class ArchiveSplitZipService : Service() {
showCompletionNotification("$archiveName.zip created successfully")
sendLocalBroadcast(Intent(ACTION_ARCHIVE_COMPLETE))
} else {
- showErrorNotification("Archive creation failed")
+ showErrorNotification(getString(R.string.zip_creation_failed))
sendLocalBroadcast(Intent(ACTION_ARCHIVE_ERROR).putExtra("error_message", "Archive creation failed: ${progressMonitor.result}"))
}
@@ -241,7 +241,7 @@ class ArchiveSplitZipService : Service() {
private fun showErrorNotification(error: String) {
stopForegroundService()
- val notification = NotificationCompat.Builder(this, CHANNEL_ID)
+ val notification = NotificationCompat.Builder(this, ARCHIVE_NOTIFICATION_CHANNEL_ID)
.setContentTitle("Archive Creation Failed")
.setContentText(error)
.setSmallIcon(R.drawable.ic_folder_zip)
@@ -255,7 +255,7 @@ class ArchiveSplitZipService : Service() {
private fun showCompletionNotification(message: String) {
stopForegroundService()
- val notification = NotificationCompat.Builder(this, CHANNEL_ID)
+ val notification = NotificationCompat.Builder(this, ARCHIVE_NOTIFICATION_CHANNEL_ID)
.setContentTitle("Archive Creation Complete")
.setContentText(message)
.setSmallIcon(R.drawable.ic_notification_icon)
diff --git a/app/src/main/java/com/wirelessalien/zipxtract/service/ExtractCsArchiveService.kt b/app/src/main/java/com/wirelessalien/zipxtract/service/ExtractCsArchiveService.kt
index 74c6781..81e4c59 100644
--- a/app/src/main/java/com/wirelessalien/zipxtract/service/ExtractCsArchiveService.kt
+++ b/app/src/main/java/com/wirelessalien/zipxtract/service/ExtractCsArchiveService.kt
@@ -28,12 +28,13 @@ import android.os.IBinder
import androidx.core.app.NotificationCompat
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.wirelessalien.zipxtract.R
-import com.wirelessalien.zipxtract.constant.BroadcastConstants
import com.wirelessalien.zipxtract.constant.BroadcastConstants.ACTION_EXTRACTION_COMPLETE
import com.wirelessalien.zipxtract.constant.BroadcastConstants.ACTION_EXTRACTION_ERROR
+import com.wirelessalien.zipxtract.constant.BroadcastConstants.ACTION_EXTRACTION_PROGRESS
import com.wirelessalien.zipxtract.constant.BroadcastConstants.ACTION_EXTRACT_CANCEL
import com.wirelessalien.zipxtract.constant.BroadcastConstants.EXTRACTION_NOTIFICATION_CHANNEL_ID
import com.wirelessalien.zipxtract.constant.BroadcastConstants.EXTRA_ERROR_MESSAGE
+import com.wirelessalien.zipxtract.constant.BroadcastConstants.EXTRA_PROGRESS
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@@ -106,7 +107,7 @@ class ExtractCsArchiveService : Service() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
EXTRACTION_NOTIFICATION_CHANNEL_ID,
- "Extraction Service",
+ getString(R.string.extract_archive_notification_name),
NotificationManager.IMPORTANCE_LOW
)
val notificationManager = getSystemService(NotificationManager::class.java)
@@ -189,16 +190,17 @@ class ExtractCsArchiveService : Service() {
e.printStackTrace()
showErrorNotification(e.message ?: getString(R.string.extraction_failed))
sendLocalBroadcast(Intent(ACTION_EXTRACTION_ERROR).putExtra(EXTRA_ERROR_MESSAGE, e.message ?: getString(R.string.extraction_failed)))
+ } finally {
+ stopForegroundService()
}
}
private fun updateProgress(progress: Int) {
val notification = createNotification(progress)
val notificationManager = getSystemService(NotificationManager::class.java)
- notificationManager.notify(ExtractArchiveService.NOTIFICATION_ID, notification)
+ notificationManager.notify(NOTIFICATION_ID, notification)
- sendLocalBroadcast(Intent(BroadcastConstants.ACTION_EXTRACTION_PROGRESS).putExtra(
- BroadcastConstants.EXTRA_PROGRESS, progress))
+ sendLocalBroadcast(Intent(ACTION_EXTRACTION_PROGRESS).putExtra(EXTRA_PROGRESS, progress))
}
private fun showCompletionNotification() {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d556031..6ea1303 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -103,4 +103,9 @@
Extension
Unsupported compression format
Extracting file
+ Archiving file
+ Operation cancelled
+ Compress Archive
+ Extract Archive
+ Tar creation failed
\ No newline at end of file