From 1321ccae662fffb5929c8fd49646d091343ce8f7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 25 Oct 2018 13:38:27 +0200 Subject: [PATCH] update commons to 5.2.8 --- app/build.gradle | 2 +- .../gallery/dialogs/ResizeDialog.kt | 65 +++++++------------ app/src/main/res/layout/resize_image.xml | 12 ++-- 3 files changed, 30 insertions(+), 49 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 643479e83..0fc90d3d4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,7 +48,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.2.6' + implementation 'com.simplemobiletools:commons:5.2.8' implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0' implementation 'androidx.multidex:multidex:2.0.0' implementation 'it.sephiroth.android.exif:library:1.0.1' 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 378d8a524..e34ead6c6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt @@ -1,15 +1,10 @@ package com.simplemobiletools.gallery.dialogs import android.graphics.Point -import androidx.appcompat.app.AlertDialog -import android.text.Editable -import android.text.TextWatcher import android.widget.EditText +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.activities.BaseSimpleActivity -import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.commons.extensions.showKeyboard -import com.simplemobiletools.commons.extensions.toast -import com.simplemobiletools.commons.extensions.value +import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.R import kotlinx.android.synthetic.main.resize_image.view.* @@ -24,49 +19,33 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba val ratio = size.x / size.y.toFloat() - widthView.addTextChangedListener(object : TextWatcher { - override fun afterTextChanged(s: Editable?) { - if (widthView.hasFocus()) { - var width = getViewValue(widthView) - if (width > size.x) { - widthView.setText(size.x.toString()) - width = size.x - } + widthView.onTextChangeListener { + if (widthView.hasFocus()) { + var width = getViewValue(widthView) + if (width > size.x) { + widthView.setText(size.x.toString()) + width = size.x + } - if (view.keep_aspect_ratio.isChecked) { - heightView.setText((width / ratio).toInt().toString()) - } + if (view.keep_aspect_ratio.isChecked) { + heightView.setText((width / ratio).toInt().toString()) } } + } - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { - } + heightView.onTextChangeListener { + if (heightView.hasFocus()) { + var height = getViewValue(heightView) + if (height > size.y) { + heightView.setText(size.y.toString()) + height = size.y + } - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - } - }) - - heightView.addTextChangedListener(object : TextWatcher { - override fun afterTextChanged(s: Editable?) { - if (heightView.hasFocus()) { - var height = getViewValue(heightView) - if (height > size.y) { - heightView.setText(size.y.toString()) - height = size.y - } - - if (view.keep_aspect_ratio.isChecked) { - widthView.setText((height * ratio).toInt().toString()) - } + if (view.keep_aspect_ratio.isChecked) { + widthView.setText((height * ratio).toInt().toString()) } } - - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { - } - - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - } - }) + } AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) diff --git a/app/src/main/res/layout/resize_image.xml b/app/src/main/res/layout/resize_image.xml index 13a3d5d1a..a6071a333 100644 --- a/app/src/main/res/layout/resize_image.xml +++ b/app/src/main/res/layout/resize_image.xml @@ -5,7 +5,9 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:padding="@dimen/activity_margin"> + android:paddingLeft="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin" + android:paddingRight="@dimen/activity_margin"> @@ -38,9 +40,9 @@ android:id="@+id/image_height" android:layout_width="100dp" android:layout_height="wrap_content" - android:layout_alignLeft="@+id/image_height_label" - android:layout_alignStart="@+id/image_height_label" android:layout_below="@+id/image_width_label" + android:layout_alignStart="@+id/image_height_label" + android:layout_alignLeft="@+id/image_height_label" android:inputType="number" android:maxLength="6" android:maxLines="1" @@ -54,8 +56,8 @@ android:layout_below="@+id/image_height" android:layout_marginTop="@dimen/activity_margin" android:checked="true" - android:paddingBottom="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin" + android:paddingBottom="@dimen/activity_margin" android:text="@string/keep_aspect_ratio"/>