validate the inserted resolution

This commit is contained in:
tibbi 2016-12-06 22:00:22 +01:00
parent 7147ed3b7b
commit d53000b667
10 changed files with 18 additions and 0 deletions

View file

@ -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()
})
}
}

View file

@ -66,6 +66,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">Datei umbenennen</string>

View file

@ -66,6 +66,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">Renombrar archivo</string>

View file

@ -66,6 +66,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">Rinomina file</string>

View file

@ -66,6 +66,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">ファイルの名前を変更</string>

View file

@ -66,6 +66,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">Renomear ficheiro</string>

View file

@ -67,6 +67,7 @@
<string name="width">Ширина</string>
<string name="height">Высота</string>
<string name="keep_aspect_ratio">Сохранить соотношение сторон</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">Изменение имени файла</string>

View file

@ -66,6 +66,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">Döp om fil</string>

View file

@ -67,6 +67,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">重命名文件</string>

View file

@ -66,6 +66,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>
<string name="invalid_values">Please enter a valid resolution</string>
<!-- Renaming -->
<string name="rename_file">Rename file</string>