From 1ef349384d37927726163e523284fbabf8fe546c Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 31 Aug 2017 10:43:01 +0200 Subject: [PATCH] add a dialog for setting the destination zip filename --- .../filemanager/adapters/ItemsAdapter.kt | 11 ++++--- .../filemanager/dialogs/CompressAsDialog.kt | 32 +++++++++++++++++++ .../dialogs/CreateNewItemDialog.kt | 3 +- .../main/res/layout/dialog_compress_as.xml | 32 +++++++++++++++++++ app/src/main/res/values-cs/strings.xml | 1 + app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hu/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-ko-rKR/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sk/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 20 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CompressAsDialog.kt create mode 100644 app/src/main/res/layout/dialog_compress_as.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index bbcdade4..e479091e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -26,6 +26,7 @@ import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.activities.SimpleActivity +import com.simplemobiletools.filemanager.dialogs.CompressAsDialog import com.simplemobiletools.filemanager.extensions.config import kotlinx.android.synthetic.main.list_item.view.* import java.io.* @@ -211,10 +212,12 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList Unit) { + private val view = activity.layoutInflater.inflate(R.layout.dialog_compress_as, null) + + init { + val filename = path.getFilenameFromPath() + val indexOfDot = if (filename.contains('.') && File(path).isFile) filename.lastIndexOf(".") else filename.length + val baseFilename = filename.substring(0, indexOfDot) + view.file_name.setText(baseFilename) + + AlertDialog.Builder(activity) + .setPositiveButton(R.string.ok, null) + .setNegativeButton(R.string.cancel, null) + .create().apply { + activity.setupDialogStuff(view, this, R.string.compress_as) + window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) + getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ + dismiss() + }) + } + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt index 636dca17..037f647b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt @@ -11,8 +11,9 @@ import java.io.File import java.io.IOException class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val callback: () -> Unit) { + private val view = activity.layoutInflater.inflate(R.layout.dialog_create_new, null) + init { - val view = activity.layoutInflater.inflate(R.layout.dialog_create_new, null) AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) diff --git a/app/src/main/res/layout/dialog_compress_as.xml b/app/src/main/res/layout/dialog_compress_as.xml new file mode 100644 index 00000000..dc064010 --- /dev/null +++ b/app/src/main/res/layout/dialog_compress_as.xml @@ -0,0 +1,32 @@ + + + + + + + + diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 72a7c0e7..b4601260 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index b45a443b..ec7cc623 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index b650c572..18a98b29 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index c1e354f5..528447bb 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index cee28af1..17f98772 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index e6e3ab1d..c189e4b9 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 72bba77d..50bec1f3 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-ko-rKR/strings.xml b/app/src/main/res/values-ko-rKR/strings.xml index 7a38fa9b..48af8379 100644 --- a/app/src/main/res/values-ko-rKR/strings.xml +++ b/app/src/main/res/values-ko-rKR/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 9c6949dd..c0f4f291 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index c9a34d5f..b21fe849 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index f58aec81..9b0a173b 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 44e501fb..d279e91e 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 09bd49b8..8528ed05 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -11,6 +11,7 @@ Komprimovať Dekomprimovať + Komprimovať ako Komprimuje sa… Dekomprimuje sa… Kompresia bola úspešná diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index abe34757..a67f090a 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 74e5e61d..b168e851 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ef113955..0b2d7fd7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,6 +11,7 @@ Compress Decompress + Compress as Compressing… Decompressing… Compression successful