creating the resize dialog

This commit is contained in:
tibbi 2016-12-06 20:15:33 +01:00
parent 463992a80d
commit 6d32e55bf4
13 changed files with 111 additions and 15 deletions

View file

@ -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,8 +76,12 @@ 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) {
if (result.error == null) {

View file

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

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rename_directory_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rename_directory_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
<TextView
android:id="@+id/image_width_label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/width"/>
<EditText
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:inputType="number"
android:maxLength="6"
android:maxLines="1"/>
<TextView
android:id="@+id/image_height_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginStart="50dp"
android:layout_toRightOf="@+id/image_width_label"
android:text="@string/height"/>
<EditText
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:inputType="number"
android:maxLength="6"
android:maxLines="1"/>
<CheckBox
android:id="@+id/keep_aspect_ratio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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:text="@string/keep_aspect_ratio"/>
</RelativeLayout>

View file

@ -62,7 +62,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>

View file

@ -62,7 +62,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>

View file

@ -62,7 +62,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>

View file

@ -62,7 +62,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>

View file

@ -62,7 +62,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>

View file

@ -63,7 +63,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>

View file

@ -62,7 +62,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>

View file

@ -63,7 +63,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>

View file

@ -62,7 +62,7 @@
<!-- Resizing -->
<string name="resize">Resize</string>
<string name="resize_final_image">Resize final image</string>
<string name="resize_and_save">Resize selection and save</string>
<string name="width">Width</string>
<string name="height">Height</string>
<string name="keep_aspect_ratio">Keep aspect ratio</string>