diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 63d7807..7b46144 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -7,7 +7,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index ad98096..74a25a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId "com.wirelessalien.zipxtract" minSdk 23 targetSdk 33 - versionCode 2 - versionName "2.0" + versionCode 3 + versionName "2.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -28,25 +28,28 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '11' } } dependencies { - implementation 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.9.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + //Kotlin Coroutines + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' - implementation 'org.apache.commons:commons-compress:1.21' + implementation 'org.apache.commons:commons-compress:1.23.0' implementation 'org.tukaani:xz:1.9' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b7b872a..eeef553 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,11 +9,11 @@ android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" - android:icon="@drawable/app_icon" + android:icon="@mipmap/ic_launcher" + android:name=".App" android:label="@string/app_name" - android:roundIcon="@drawable/app_icon" android:supportsRtl="true" - android:theme="@style/Theme.UnZip" + android:theme="@style/AppTheme" tools:targetApi="31" > (R.id.pickFileButton) extractButton = findViewById(R.id.extractButton) + progressBar = findViewById(R.id.progressBar) directoryTextView = findViewById(R.id.directoryTextView) // Assign the TextView from the layout sharedPreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE) + progressBar.visibility = View.GONE pickFileButton.setOnClickListener { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT) @@ -86,6 +95,7 @@ class MainActivity : AppCompatActivity() { extractButton.setOnClickListener { if (archiveFileUri != null) { + progressBar.visibility = View.VISIBLE extractArchiveFile(archiveFileUri!!) } else { Toast.makeText(this, "Please pick a file to extract", Toast.LENGTH_SHORT).show() @@ -306,35 +316,59 @@ class MainActivity : AppCompatActivity() { gzipInputStream.close() showExtractionCompletedSnackbar(outputDirectory) } + private suspend fun createTemp7zFileInBackground(bufferedInputStream: BufferedInputStream): File = withContext(Dispatchers.IO) { + return@withContext File.createTempFile("temp_", ".7z", cacheDir).apply { + FileOutputStream(this).use { outputStream -> + val buffer = ByteArray(4096) + var count: Int + while (bufferedInputStream.read(buffer).also { count = it } != -1) { + outputStream.write(buffer, 0, count) + } + } + } + } + private fun extract7z(bufferedInputStream: BufferedInputStream, outputDirectory: DocumentFile?) { - val byteChannel = SeekableInMemoryByteChannel(bufferedInputStream.readBytes()) - SevenZFile(byteChannel).use { sevenZFile -> - var entry: SevenZArchiveEntry? = sevenZFile.nextEntry - while (entry != null) { - val outputFile = outputDirectory?.createFile("application/octet-stream", entry.name) - if (entry.isDirectory) { - outputFile?.createDirectory("Un7z") - } else { - outputFile?.uri?.let { uri -> - contentResolver.openOutputStream(uri)?.use { outputStream -> - val buffer = ByteArray(8192) - try { - var count: Int - while (sevenZFile.read(buffer).also { count = it } != -1) { - outputStream.write(buffer, 0, count) + val tempFileJob = CoroutineScope(Dispatchers.Default).launch { + val tempFile = createTemp7zFileInBackground(bufferedInputStream) + + // Continue with the rest of your extraction logic using the tempFile + SevenZFile(tempFile).use { sevenZFile -> + var entry: SevenZArchiveEntry? = sevenZFile.nextEntry + while (entry != null) { + val outputFile = outputDirectory?.createFile("application/octet-stream", entry.name) + if (entry.isDirectory) { + outputFile?.createDirectory("Un7z") + } else { + outputFile?.uri?.let { uri -> + contentResolver.openOutputStream(uri)?.use { outputStream -> + val buffer = ByteArray(4096) + try { + var count: Int + while (sevenZFile.read(buffer).also { count = it } != -1) { + outputStream.write(buffer, 0, count) + } + } catch (e: Exception) { + showToast("Extraction failed: ${e.message}") + sevenZFile.close() } - } catch (e: Exception) { - showToast("Extraction failed: ${e.message}") - return } } } + entry = sevenZFile.nextEntry } - entry = sevenZFile.nextEntry + } + // Show a completion message after extraction is done + withContext(Dispatchers.Main) { + showExtractionCompletedSnackbar(outputDirectory) } } - showExtractionCompletedSnackbar(outputDirectory) + tempFileJob.invokeOnCompletion { throwable -> + if (throwable != null) { + showToast("Temp file creation failed: ${throwable.message}") + } + } } private fun extractXz(bufferedInputStream: BufferedInputStream, outputDirectory: DocumentFile?) { @@ -364,6 +398,7 @@ class MainActivity : AppCompatActivity() { private fun showExtractionCompletedSnackbar(outputDirectory: DocumentFile?) { + progressBar.visibility = View.GONE val rootView = findViewById(android.R.id.content) val snackbar = Snackbar.make(rootView, "Extraction completed successfully", Snackbar.LENGTH_LONG) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index eabd427..7a2e831 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -3,7 +3,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:padding="16dp" - android:theme="@style/Theme.Material3.DayNight.NoActionBar" tools:context=".MainActivity"> - - - + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index eca70cf..345888d 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,6 @@ - - + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cf..0000000 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..1092320 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp deleted file mode 100644 index c209e78..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_background.png b/app/src/main/res/mipmap-hdpi/ic_launcher_background.png new file mode 100644 index 0000000..5e8ee17 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_background.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..eebe974 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png b/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..53a6f3d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp deleted file mode 100644 index b2dfe3d..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..a41a0f5 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp deleted file mode 100644 index 4f0f1d6..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_background.png b/app/src/main/res/mipmap-mdpi/ic_launcher_background.png new file mode 100644 index 0000000..775e94b Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_background.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..5ef38b3 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png b/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..c74cefd Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp deleted file mode 100644 index 62b611d..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..c3a27c7 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp deleted file mode 100644 index 948a307..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png new file mode 100644 index 0000000..3e3c3ce Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..c0f7ea6 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..b0de61c Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp deleted file mode 100644 index 1b9a695..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..c96ef14 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp deleted file mode 100644 index 28d4b77..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png new file mode 100644 index 0000000..78c24ce Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..4cad710 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..e0ad75c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp deleted file mode 100644 index 9287f50..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..630bbd7 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp deleted file mode 100644 index aa7d642..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png new file mode 100644 index 0000000..eb9f8dc Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7b16069 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png new file mode 100644 index 0000000..74eff87 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp deleted file mode 100644 index 9126ae3..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 54fcfe1..c817c91 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,16 +1,31 @@ - - - - \ No newline at end of file + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 82da7fa..952bb39 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,10 +1,64 @@ - + - #00BCD4 - #03A9F4 - #2196F3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file + #2b7bff + #0058C8 + #FFFFFF + #D9E2FF + #001944 + #575E71 + #FFFFFF + #DBE2F9 + #141B2C + #96490A + #FFFFFF + #FFDBC8 + #321300 + #BA1A1A + #FFDAD6 + #FFFFFF + #410002 + #FEFBFF + #1B1B1F + #FEFBFF + #1B1B1F + #E1E2EC + #44464F + #757780 + #F2F0F4 + #303034 + #AFC6FF + #000000 + #0058C8 + #C5C6D0 + #000000 + #AFC6FF + #002D6D + #00429A + #D9E2FF + #BFC6DC + #293042 + #404659 + #DBE2F9 + #FFB68A + #522300 + #743500 + #FFDBC8 + #FFB4AB + #93000A + #690005 + #FFDAD6 + #1B1B1F + #E3E2E6 + #1B1B1F + #E3E2E6 + #44464F + #C5C6D0 + #8F9099 + #1B1B1F + #E3E2E6 + #0058C8 + #000000 + #AFC6FF + #44464F + #000000 + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 11d2021..99866d1 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,16 +1,31 @@ - - - - \ No newline at end of file +