Skip to content

Commit fc87d6e

Browse files
committed
fix
1 parent 9699a4e commit fc87d6e

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

app/src/main/java/com/wirelessalien/zipxtract/activity/OpenWithActivity.kt

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ import android.view.View
3030
import android.widget.Toast
3131
import androidx.appcompat.app.AppCompatActivity
3232
import androidx.core.content.ContextCompat
33+
import com.google.android.material.chip.Chip
3334
import com.google.android.material.dialog.MaterialAlertDialogBuilder
3435
import com.wirelessalien.zipxtract.R
36+
import com.wirelessalien.zipxtract.databinding.DialogArchiveTypeBinding
3537
import com.wirelessalien.zipxtract.databinding.DialogCrashLogBinding
3638
import com.wirelessalien.zipxtract.databinding.PasswordInputOpenWithBinding
3739
import com.wirelessalien.zipxtract.service.ExtractArchiveService
@@ -172,7 +174,7 @@ class OpenWithActivity : AppCompatActivity() {
172174
if (filePaths.isNotEmpty()) {
173175
showArchiveTypeDialog(filePaths)
174176
} else {
175-
Toast.makeText(this@OpenWithActivity, getString(R.string.no_file_selected), Toast.LENGTH_SHORT).show() // Assuming new string
177+
Toast.makeText(this@OpenWithActivity, getString(R.string.no_file_selected), Toast.LENGTH_SHORT).show()
176178
finish()
177179
}
178180
}
@@ -186,18 +188,36 @@ class OpenWithActivity : AppCompatActivity() {
186188
finish()
187189
return
188190
}
191+
val binding = DialogArchiveTypeBinding.inflate(layoutInflater)
192+
val chipGroup = binding.chipGroupArchiveTypes
193+
189194
val archiveTypes = arrayOf("ZIP", "7Z", "TAR")
195+
archiveTypes.forEach { type ->
196+
val chip = Chip(this).apply {
197+
text = type
198+
isCheckable = true
199+
}
200+
chipGroup.addView(chip)
201+
}
202+
190203
MaterialAlertDialogBuilder(this, R.style.MaterialDialog)
191204
.setTitle(getString(R.string.select_archive_type_title))
192-
.setItems(archiveTypes) { _, which ->
193-
val selectedType = archiveTypes[which]
194-
val mainActivityIntent = Intent(this, MainActivity::class.java).apply {
195-
action = MainActivity.ACTION_CREATE_ARCHIVE
196-
putStringArrayListExtra(MainActivity.EXTRA_FILE_PATHS, ArrayList(filePaths))
197-
putExtra(MainActivity.EXTRA_ARCHIVE_TYPE, selectedType)
205+
.setView(binding.root)
206+
.setPositiveButton(getString(R.string.ok)) { _, _ ->
207+
val selectedChipId = chipGroup.checkedChipId
208+
if (selectedChipId != View.NO_ID) {
209+
val selectedChip = chipGroup.findViewById<Chip>(selectedChipId)
210+
val selectedType = selectedChip.text.toString()
211+
val mainActivityIntent = Intent(this, MainActivity::class.java).apply {
212+
action = MainActivity.ACTION_CREATE_ARCHIVE
213+
putStringArrayListExtra(MainActivity.EXTRA_FILE_PATHS, ArrayList(filePaths))
214+
putExtra(MainActivity.EXTRA_ARCHIVE_TYPE, selectedType)
215+
}
216+
startActivity(mainActivityIntent)
217+
finish()
218+
} else {
219+
Toast.makeText(this, getString(R.string.general_error_msg), Toast.LENGTH_SHORT).show()
198220
}
199-
startActivity(mainActivityIntent)
200-
finish()
201221
}
202222
.setOnCancelListener {
203223
finish()

app/src/main/java/com/wirelessalien/zipxtract/fragment/MainFragment.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,9 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
494494
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
495495

496496
val newFragment = when (archiveType) {
497-
"Zip" -> ZipOptionDialogFragment.newInstance(validFilePaths)
498-
"7z" -> SevenZOptionDialogFragment.newInstance(validFilePaths)
499-
"Tar" -> TarOptionsDialogFragment.newInstance(validFilePaths)
497+
"ZIP" -> ZipOptionDialogFragment.newInstance(validFilePaths)
498+
"7Z" -> SevenZOptionDialogFragment.newInstance(validFilePaths)
499+
"TAR" -> TarOptionsDialogFragment.newInstance(validFilePaths)
500500
else -> null
501501
}
502502

app/src/main/res/layout/dialog_archive_type.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
1919
android:layout_width="match_parent"
2020
android:layout_height="wrap_content"
21+
xmlns:app="http://schemas.android.com/apk/res-auto"
2122
android:orientation="vertical"
2223
android:padding="16dp">
2324

24-
<com.google.android.material.progressindicator.LinearProgressIndicator
25-
android:id="@+id/progressIndicator"
26-
android:layout_width="wrap_content"
25+
<com.google.android.material.chip.ChipGroup
26+
android:id="@+id/chipGroupArchiveTypes"
27+
android:layout_width="match_parent"
2728
android:layout_height="wrap_content"
28-
android:layout_gravity="center"
29-
android:visibility="gone" />
29+
app:singleSelection="true"
30+
app:chipSpacingHorizontal="8dp"
31+
app:chipSpacingVertical="8dp"/>
3032
</LinearLayout>

0 commit comments

Comments
 (0)