From 6d32e55bf4013a71a2aa988fa757cfc8d168daaa Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Dec 2016 20:15:33 +0100 Subject: [PATCH] creating the resize dialog --- .../gallery/activities/EditActivity.kt | 6 ++ .../gallery/dialogs/ResizeDialog.kt | 32 +++++++++++ app/src/main/res/layout/rename_directory.xml | 13 +++-- app/src/main/res/layout/resize_image.xml | 57 +++++++++++++++++++ app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 2 +- app/src/main/res/values-pt-rPT/strings.xml | 2 +- app/src/main/res/values-ru/strings.xml | 2 +- app/src/main/res/values-sv/strings.xml | 2 +- app/src/main/res/values-zh/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 13 files changed, 111 insertions(+), 15 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt create mode 100644 app/src/main/res/layout/resize_image.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index 578b337f2..dc3d32b38 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.activities import android.app.Activity import android.graphics.Bitmap +import android.graphics.Point import android.net.Uri import android.os.Bundle import android.util.Log @@ -12,6 +13,7 @@ import com.simplemobiletools.filepicker.extensions.needsStupidWritePermissions import com.simplemobiletools.filepicker.extensions.scanPath import com.simplemobiletools.filepicker.extensions.toast import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.dialogs.ResizeDialog import com.simplemobiletools.gallery.dialogs.SaveAsDialog import com.simplemobiletools.gallery.extensions.getRealPathFromURI import com.theartofdev.edmodo.cropper.CropImageView @@ -74,7 +76,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun resizeImage() { + val rect = crop_image_view.cropRect + val croppedSize = Point(rect.width(), rect.height()) + ResizeDialog(this, croppedSize) { + } } override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt new file mode 100644 index 000000000..ce4d75ec1 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt @@ -0,0 +1,32 @@ +package com.simplemobiletools.gallery.dialogs + +import android.app.AlertDialog +import android.graphics.Point +import android.util.Size +import android.view.LayoutInflater +import android.view.WindowManager +import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.activities.SimpleActivity +import kotlinx.android.synthetic.main.resize_image.view.* + +class ResizeDialog(val activity: SimpleActivity, val size: Point, val callback: (size: Size) -> Unit) { + init { + val view = LayoutInflater.from(activity).inflate(R.layout.resize_image, null) + view.image_width.setText(size.x.toString()) + view.image_height.setText(size.y.toString()) + + AlertDialog.Builder(activity) + .setTitle(activity.resources.getString(R.string.resize_and_save)) + .setView(view) + .setPositiveButton(R.string.ok, null) + .setNegativeButton(R.string.cancel, null) + .create().apply { + window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) + setCanceledOnTouchOutside(true) + show() + getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ + + }) + } + } +} diff --git a/app/src/main/res/layout/rename_directory.xml b/app/src/main/res/layout/rename_directory.xml index c39ae088b..4711c9b23 100644 --- a/app/src/main/res/layout/rename_directory.xml +++ b/app/src/main/res/layout/rename_directory.xml @@ -1,10 +1,11 @@ - + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index b5e248e75..b98ef5868 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -62,7 +62,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 39e4cc6f9..56c5dc8a4 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -62,7 +62,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 45bbafa39..e1e3c4c92 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -62,7 +62,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index fd602eca6..4e96584d9 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -62,7 +62,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index d4f2c8c4e..3fb9fdbf0 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -62,7 +62,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index aebacf7af..14b3865f4 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -63,7 +63,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 6fb109fd4..14ffcd2dd 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -62,7 +62,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 5c26d1ace..c853c8946 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -63,7 +63,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8bd34ac97..e69208a7b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -62,7 +62,7 @@ Resize - Resize final image + Resize selection and save Width Height Keep aspect ratio