From e0b2a34372556d68066b78fb6297e10753a29995 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 28 Jul 2022 16:40:33 +0200 Subject: [PATCH] redesigning the resizing dialogs --- .../gallery/pro/dialogs/ResizeDialog.kt | 6 +- .../pro/dialogs/ResizeWithPathDialog.kt | 20 +-- .../main/res/layout/dialog_resize_image.xml | 74 ++++---- .../layout/dialog_resize_image_with_path.xml | 158 ++++++++++-------- 4 files changed, 141 insertions(+), 117 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeDialog.kt index f6caebfac..37bb3a1bd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeDialog.kt @@ -11,8 +11,8 @@ import kotlinx.android.synthetic.main.dialog_resize_image.view.* class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callback: (newSize: Point) -> Unit) { init { val view = activity.layoutInflater.inflate(R.layout.dialog_resize_image, null) - val widthView = view.image_width - val heightView = view.image_height + val widthView = view.resize_image_width + val heightView = view.resize_image_height widthView.setText(size.x.toString()) heightView.setText(size.y.toString()) @@ -52,7 +52,7 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba .setNegativeButton(R.string.cancel, null) .apply { activity.setupDialogStuff(view, this, R.string.resize_and_save) { alertDialog -> - alertDialog.showKeyboard(view.image_width) + alertDialog.showKeyboard(view.resize_image_width) alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val width = getViewValue(widthView) val height = getViewValue(heightView) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeWithPathDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeWithPathDialog.kt index 134e21e3b..610082978 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeWithPathDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeWithPathDialog.kt @@ -15,7 +15,7 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va init { var realPath = path.getParentPath() val view = activity.layoutInflater.inflate(R.layout.dialog_resize_image_with_path, null).apply { - image_path.text = "${activity.humanizePath(realPath).trimEnd('/')}/" + folder.setText("${activity.humanizePath(realPath).trimEnd('/')}/") val fullName = path.getFilenameFromPath() val dotAt = fullName.lastIndexOf(".") @@ -24,20 +24,20 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va if (dotAt > 0) { name = fullName.substring(0, dotAt) val extension = fullName.substring(dotAt + 1) - image_extension.setText(extension) + extension_value.setText(extension) } - image_name.setText(name) - image_path.setOnClickListener { + filename_value.setText(name) + folder.setOnClickListener { FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true) { - image_path.text = activity.humanizePath(it) + folder.setText(activity.humanizePath(it)) realPath = it } } } - val widthView = view.image_width - val heightView = view.image_height + val widthView = view.resize_image_width + val heightView = view.resize_image_height widthView.setText(size.x.toString()) heightView.setText(size.y.toString()) @@ -73,7 +73,7 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va .setNegativeButton(R.string.cancel, null) .apply { activity.setupDialogStuff(view, this) { alertDialog -> - alertDialog.showKeyboard(view.image_width) + alertDialog.showKeyboard(view.resize_image_width) alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val width = getViewValue(widthView) val height = getViewValue(heightView) @@ -84,8 +84,8 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va val newSize = Point(getViewValue(widthView), getViewValue(heightView)) - val filename = view.image_name.value - val extension = view.image_extension.value + val filename = view.filename_value.value + val extension = view.extension_value.value if (filename.isEmpty()) { activity.toast(R.string.filename_cannot_be_empty) return@setOnClickListener diff --git a/app/src/main/res/layout/dialog_resize_image.xml b/app/src/main/res/layout/dialog_resize_image.xml index 767ad91c9..1060a86e0 100644 --- a/app/src/main/res/layout/dialog_resize_image.xml +++ b/app/src/main/res/layout/dialog_resize_image.xml @@ -8,52 +8,64 @@ android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/activity_margin"> - - - + android:hint="@string/width"> + + + + + android:layout_alignTop="@+id/resize_image_width_hint" + android:layout_alignBottom="@+id/resize_image_width_hint" + android:layout_marginStart="20dp" + android:layout_marginEnd="20dp" + android:layout_toEndOf="@+id/resize_image_width_hint" + android:gravity="center" + android:text=":" + android:textStyle="bold" /> - + android:layout_alignTop="@+id/resize_image_width_hint" + android:layout_alignBottom="@+id/resize_image_width_hint" + android:layout_toEndOf="@+id/resize_image_colon" + android:hint="@string/height"> + + + + - + android:layout_marginBottom="@dimen/activity_margin" + android:hint="@string/width"> - + + + + + + + android:layout_alignTop="@+id/resize_image_width_hint" + android:layout_alignBottom="@+id/resize_image_width_hint" + android:layout_toEndOf="@+id/resize_image_colon" + android:hint="@string/height"> - + - + - - - + android:hint="@string/folder"> - + + + + + android:hint="@string/filename"> - + - + + + android:layout_below="@+id/filename_hint" + android:hint="@string/extension"> + + + +