From d53000b6677d409afba757142c9e2a3a05aa1157 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Dec 2016 22:00:22 +0100 Subject: [PATCH] validate the inserted resolution --- .../simplemobiletools/gallery/dialogs/ResizeDialog.kt | 9 +++++++++ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/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-pt-rPT/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 10 files changed, 18 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt index 950c4c2e4..64f32b4af 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt @@ -7,6 +7,7 @@ import android.text.TextWatcher import android.view.LayoutInflater import android.view.WindowManager import android.widget.EditText +import com.simplemobiletools.filepicker.extensions.toast import com.simplemobiletools.filepicker.extensions.value import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity @@ -77,8 +78,16 @@ class ResizeDialog(val activity: SimpleActivity, val size: Point, val callback: setCanceledOnTouchOutside(true) show() getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ + val width = getViewValue(widthView) + val height = getViewValue(heightView) + if (width <= 0 || height <= 0) { + activity.toast(R.string.invalid_values) + return@setOnClickListener + } + val newSize = Point(getViewValue(widthView), getViewValue(heightView)) callback.invoke(newSize) + dismiss() }) } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index b98ef5868..f2154b366 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -66,6 +66,7 @@ Width Height Keep aspect ratio + Please enter a valid resolution Datei umbenennen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 56c5dc8a4..21d859f9f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -66,6 +66,7 @@ Width Height Keep aspect ratio + Please enter a valid resolution Renombrar archivo diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index e1e3c4c92..e7bb7661d 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -66,6 +66,7 @@ Width Height Keep aspect ratio + Please enter a valid resolution Rinomina file diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 4e96584d9..5726bd372 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -66,6 +66,7 @@ Width Height Keep aspect ratio + Please enter a valid resolution ファイルの名前を変更 diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 3fb9fdbf0..14f5cb9c1 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -66,6 +66,7 @@ Width Height Keep aspect ratio + Please enter a valid resolution Renomear ficheiro diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index ff12b9f21..318ce824f 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -67,6 +67,7 @@ Ширина Высота Сохранить соотношение сторон + Please enter a valid resolution Изменение имени файла diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 14ffcd2dd..1bb236c43 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -66,6 +66,7 @@ Width Height Keep aspect ratio + Please enter a valid resolution Döp om fil diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index c853c8946..138bdd6b3 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -67,6 +67,7 @@ Width Height Keep aspect ratio + Please enter a valid resolution 重命名文件 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e69208a7b..8e022c503 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -66,6 +66,7 @@ Width Height Keep aspect ratio + Please enter a valid resolution Rename file