redesigning the resizing dialogs
This commit is contained in:
parent
84dd596c58
commit
e0b2a34372
|
@ -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) {
|
class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callback: (newSize: Point) -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_resize_image, null)
|
val view = activity.layoutInflater.inflate(R.layout.dialog_resize_image, null)
|
||||||
val widthView = view.image_width
|
val widthView = view.resize_image_width
|
||||||
val heightView = view.image_height
|
val heightView = view.resize_image_height
|
||||||
|
|
||||||
widthView.setText(size.x.toString())
|
widthView.setText(size.x.toString())
|
||||||
heightView.setText(size.y.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)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.resize_and_save) { alertDialog ->
|
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 {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val width = getViewValue(widthView)
|
val width = getViewValue(widthView)
|
||||||
val height = getViewValue(heightView)
|
val height = getViewValue(heightView)
|
||||||
|
|
|
@ -15,7 +15,7 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va
|
||||||
init {
|
init {
|
||||||
var realPath = path.getParentPath()
|
var realPath = path.getParentPath()
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_resize_image_with_path, null).apply {
|
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 fullName = path.getFilenameFromPath()
|
||||||
val dotAt = fullName.lastIndexOf(".")
|
val dotAt = fullName.lastIndexOf(".")
|
||||||
|
@ -24,20 +24,20 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va
|
||||||
if (dotAt > 0) {
|
if (dotAt > 0) {
|
||||||
name = fullName.substring(0, dotAt)
|
name = fullName.substring(0, dotAt)
|
||||||
val extension = fullName.substring(dotAt + 1)
|
val extension = fullName.substring(dotAt + 1)
|
||||||
image_extension.setText(extension)
|
extension_value.setText(extension)
|
||||||
}
|
}
|
||||||
|
|
||||||
image_name.setText(name)
|
filename_value.setText(name)
|
||||||
image_path.setOnClickListener {
|
folder.setOnClickListener {
|
||||||
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true) {
|
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true) {
|
||||||
image_path.text = activity.humanizePath(it)
|
folder.setText(activity.humanizePath(it))
|
||||||
realPath = it
|
realPath = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val widthView = view.image_width
|
val widthView = view.resize_image_width
|
||||||
val heightView = view.image_height
|
val heightView = view.resize_image_height
|
||||||
|
|
||||||
widthView.setText(size.x.toString())
|
widthView.setText(size.x.toString())
|
||||||
heightView.setText(size.y.toString())
|
heightView.setText(size.y.toString())
|
||||||
|
@ -73,7 +73,7 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.image_width)
|
alertDialog.showKeyboard(view.resize_image_width)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val width = getViewValue(widthView)
|
val width = getViewValue(widthView)
|
||||||
val height = getViewValue(heightView)
|
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 newSize = Point(getViewValue(widthView), getViewValue(heightView))
|
||||||
|
|
||||||
val filename = view.image_name.value
|
val filename = view.filename_value.value
|
||||||
val extension = view.image_extension.value
|
val extension = view.extension_value.value
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(R.string.filename_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
|
|
|
@ -8,52 +8,64 @@
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/activity_margin"
|
||||||
android:paddingRight="@dimen/activity_margin">
|
android:paddingRight="@dimen/activity_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextInputLayout
|
||||||
android:id="@+id/image_width_label"
|
android:id="@+id/resize_image_width_hint"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="@dimen/tiny_margin"
|
|
||||||
android:text="@string/width" />
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
|
||||||
android:id="@+id/image_width"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/image_width_label"
|
|
||||||
android:layout_marginBottom="@dimen/activity_margin"
|
android:layout_marginBottom="@dimen/activity_margin"
|
||||||
android:inputType="number"
|
android:hint="@string/width">
|
||||||
android:maxLength="6"
|
|
||||||
android:maxLines="1"
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:textCursorDrawable="@null"
|
android:id="@+id/resize_image_width"
|
||||||
android:textSize="@dimen/normal_text_size" />
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLength="6"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textSize="@dimen/bigger_text_size" />
|
||||||
|
|
||||||
|
</com.simplemobiletools.commons.views.MyTextInputLayout>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/image_height_label"
|
android:id="@+id/resize_image_colon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="50dp"
|
android:layout_alignTop="@+id/resize_image_width_hint"
|
||||||
android:layout_toEndOf="@+id/image_width_label"
|
android:layout_alignBottom="@+id/resize_image_width_hint"
|
||||||
android:paddingStart="@dimen/tiny_margin"
|
android:layout_marginStart="20dp"
|
||||||
android:text="@string/height" />
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_toEndOf="@+id/resize_image_width_hint"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text=":"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
<com.simplemobiletools.commons.views.MyTextInputLayout
|
||||||
android:id="@+id/image_height"
|
android:id="@+id/resize_image_height_hint"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/image_width_label"
|
android:layout_alignTop="@+id/resize_image_width_hint"
|
||||||
android:layout_alignStart="@+id/image_height_label"
|
android:layout_alignBottom="@+id/resize_image_width_hint"
|
||||||
android:inputType="number"
|
android:layout_toEndOf="@+id/resize_image_colon"
|
||||||
android:maxLength="6"
|
android:hint="@string/height">
|
||||||
android:maxLines="1"
|
|
||||||
android:textCursorDrawable="@null"
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:textSize="@dimen/normal_text_size" />
|
android:id="@+id/resize_image_height"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLength="6"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textSize="@dimen/bigger_text_size" />
|
||||||
|
|
||||||
|
</com.simplemobiletools.commons.views.MyTextInputLayout>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
android:id="@+id/keep_aspect_ratio"
|
android:id="@+id/keep_aspect_ratio"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/image_height"
|
android:layout_below="@+id/resize_image_width_hint"
|
||||||
android:layout_marginTop="@dimen/activity_margin"
|
|
||||||
android:checked="true"
|
android:checked="true"
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/activity_margin"
|
||||||
android:paddingBottom="@dimen/activity_margin"
|
android:paddingBottom="@dimen/activity_margin"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/resize_image_with_path_holder"
|
android:id="@+id/resize_image_with_path_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -9,96 +8,109 @@
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/activity_margin"
|
||||||
android:paddingRight="@dimen/activity_margin">
|
android:paddingRight="@dimen/activity_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextInputLayout
|
||||||
android:id="@+id/image_width_label"
|
android:id="@+id/resize_image_width_hint"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="@dimen/tiny_margin"
|
android:layout_marginBottom="@dimen/activity_margin"
|
||||||
android:text="@string/width"
|
android:hint="@string/width">
|
||||||
android:textSize="@dimen/normal_text_size" />
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/image_width"
|
android:id="@+id/resize_image_width"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLength="6"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textSize="@dimen/bigger_text_size" />
|
||||||
|
|
||||||
|
</com.simplemobiletools.commons.views.MyTextInputLayout>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/resize_image_colon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextInputLayout
|
||||||
|
android:id="@+id/resize_image_height_hint"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/image_width_label"
|
android:layout_alignTop="@+id/resize_image_width_hint"
|
||||||
android:inputType="number"
|
android:layout_alignBottom="@+id/resize_image_width_hint"
|
||||||
android:maxLength="6"
|
android:layout_toEndOf="@+id/resize_image_colon"
|
||||||
android:maxLines="1"
|
android:hint="@string/height">
|
||||||
android:textCursorDrawable="@null"
|
|
||||||
android:textSize="@dimen/normal_text_size" />
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/image_height_label"
|
android:id="@+id/resize_image_height"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="50dp"
|
android:inputType="number"
|
||||||
android:layout_toEndOf="@+id/image_width_label"
|
android:maxLength="6"
|
||||||
android:paddingStart="@dimen/tiny_margin"
|
android:maxLines="1"
|
||||||
android:text="@string/height"
|
android:textCursorDrawable="@null"
|
||||||
android:textSize="@dimen/normal_text_size" />
|
android:textSize="@dimen/bigger_text_size" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
</com.simplemobiletools.commons.views.MyTextInputLayout>
|
||||||
android:id="@+id/image_height"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/image_width_label"
|
|
||||||
android:layout_alignStart="@+id/image_height_label"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLength="6"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:textCursorDrawable="@null"
|
|
||||||
android:textSize="@dimen/normal_text_size" />
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextInputLayout
|
||||||
android:id="@+id/image_path_label"
|
android:id="@+id/folder_hint"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/image_height"
|
|
||||||
android:layout_marginStart="@dimen/tiny_margin"
|
|
||||||
android:layout_marginTop="@dimen/activity_margin"
|
|
||||||
android:text="@string/path"
|
|
||||||
android:textSize="@dimen/normal_text_size" />
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
|
||||||
android:id="@+id/image_path"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/image_path_label"
|
android:layout_below="@+id/resize_image_width_hint"
|
||||||
android:layout_marginStart="@dimen/tiny_margin"
|
|
||||||
android:layout_marginBottom="@dimen/activity_margin"
|
android:layout_marginBottom="@dimen/activity_margin"
|
||||||
android:paddingTop="@dimen/small_margin"
|
android:hint="@string/folder">
|
||||||
android:paddingEnd="@dimen/small_margin"
|
|
||||||
android:textSize="@dimen/normal_text_size"
|
|
||||||
tools:text="@string/internal" />
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/image_name"
|
android:id="@+id/folder"
|
||||||
|
style="@style/UnclickableEditText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</com.simplemobiletools.commons.views.MyTextInputLayout>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextInputLayout
|
||||||
|
android:id="@+id/filename_hint"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/image_path"
|
android:layout_below="@+id/folder_hint"
|
||||||
android:layout_marginBottom="@dimen/activity_margin"
|
android:layout_marginBottom="@dimen/activity_margin"
|
||||||
android:singleLine="true"
|
android:hint="@string/filename">
|
||||||
android:textCursorDrawable="@null"
|
|
||||||
android:textSize="@dimen/normal_text_size" />
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/image_extension_label"
|
android:id="@+id/filename_value"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/image_name"
|
android:inputType="textCapSentences"
|
||||||
android:layout_marginStart="@dimen/tiny_margin"
|
android:singleLine="true"
|
||||||
android:text="@string/extension"
|
android:textCursorDrawable="@null"
|
||||||
android:textSize="@dimen/normal_text_size" />
|
android:textSize="@dimen/bigger_text_size" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
</com.simplemobiletools.commons.views.MyTextInputLayout>
|
||||||
android:id="@+id/image_extension"
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextInputLayout
|
||||||
|
android:id="@+id/extension_hint"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/image_extension_label"
|
android:layout_below="@+id/filename_hint"
|
||||||
android:layout_marginBottom="@dimen/activity_margin"
|
android:hint="@string/extension">
|
||||||
android:singleLine="true"
|
|
||||||
android:textCursorDrawable="@null"
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:textSize="@dimen/normal_text_size" />
|
android:id="@+id/extension_value"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textSize="@dimen/bigger_text_size" />
|
||||||
|
|
||||||
|
</com.simplemobiletools.commons.views.MyTextInputLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in New Issue