crop the image on pressing Save
This commit is contained in:
parent
1e4c1206cc
commit
5a7d5ac2e7
9 changed files with 60 additions and 22 deletions
|
@ -4,16 +4,18 @@ import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
|
import com.simplemobiletools.gallery.extensions.toast
|
||||||
import com.theartofdev.edmodo.cropper.CropImageView
|
import com.theartofdev.edmodo.cropper.CropImageView
|
||||||
import kotlinx.android.synthetic.main.activity_edit.*
|
import kotlinx.android.synthetic.main.activity_edit.*
|
||||||
|
|
||||||
class EditActivity : SimpleActivity() {
|
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_edit)
|
setContentView(R.layout.activity_edit)
|
||||||
|
|
||||||
crop_image_view.apply {
|
crop_image_view.apply {
|
||||||
guidelines = CropImageView.Guidelines.OFF
|
guidelines = CropImageView.Guidelines.OFF
|
||||||
|
setOnCropImageCompleteListener(this@EditActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +27,7 @@ class EditActivity : SimpleActivity() {
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.save -> {
|
R.id.save -> {
|
||||||
|
crop_image_view.getCroppedImageAsync()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.rotate -> {
|
R.id.rotate -> {
|
||||||
|
@ -34,4 +37,12 @@ class EditActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item)
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
|
||||||
|
if (result.error == null) {
|
||||||
|
val bitmap = result.bitmap
|
||||||
|
} else {
|
||||||
|
toast("${getString(R.string.image_croping_failed)} ${result.error.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.simplemobiletools.gallery.extensions
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.widget.Toast
|
||||||
|
|
||||||
|
fun Context.toast(msg: String, duration: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, msg, duration).show()
|
|
@ -31,9 +31,6 @@
|
||||||
<string name="cancel">Abbrechen</string>
|
<string name="cancel">Abbrechen</string>
|
||||||
<string name="set_as_wallpaper">Als Hintergrundbild setzen</string>
|
<string name="set_as_wallpaper">Als Hintergrundbild setzen</string>
|
||||||
<string name="set_as_wallpaper_failed">Setzen des Hintergrundbildes fehlgeschlagen</string>
|
<string name="set_as_wallpaper_failed">Setzen des Hintergrundbildes fehlgeschlagen</string>
|
||||||
<string name="editor">Editor</string>
|
|
||||||
<string name="save">Save</string>
|
|
||||||
<string name="rotate">Rotate</string>
|
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 Ordner gelöscht</item>
|
<item quantity="one">1 Ordner gelöscht</item>
|
||||||
|
@ -45,6 +42,12 @@
|
||||||
<item quantity="other">%1$d Dateien gelöscht</item>
|
<item quantity="other">%1$d Dateien gelöscht</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Editor -->
|
||||||
|
<string name="editor">Editor</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="rotate">Rotate</string>
|
||||||
|
<string name="image_croping_failed">Image croping failed:</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Über</string>
|
<string name="about">Über</string>
|
||||||
<string name="website">Weitere einfache Apps und Quellcode findest du auf:\nhttp://simplemobiletools.com</string>
|
<string name="website">Weitere einfache Apps und Quellcode findest du auf:\nhttp://simplemobiletools.com</string>
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
<string name="cancel">Cancelar</string>
|
<string name="cancel">Cancelar</string>
|
||||||
<string name="set_as_wallpaper">Establecer como fondo de pantalla</string>
|
<string name="set_as_wallpaper">Establecer como fondo de pantalla</string>
|
||||||
<string name="set_as_wallpaper_failed">Error al establecer fondo de pantalla</string>
|
<string name="set_as_wallpaper_failed">Error al establecer fondo de pantalla</string>
|
||||||
<string name="editor">Editor</string>
|
|
||||||
<string name="save">Save</string>
|
|
||||||
<string name="rotate">Rotate</string>
|
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 carpeta eliminada</item>
|
<item quantity="one">1 carpeta eliminada</item>
|
||||||
|
@ -45,6 +42,12 @@
|
||||||
<item quantity="other">%1$d archivos eliminados</item>
|
<item quantity="other">%1$d archivos eliminados</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Editor -->
|
||||||
|
<string name="editor">Editor</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="rotate">Rotate</string>
|
||||||
|
<string name="image_croping_failed">Image croping failed:</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Acerca de</string>
|
<string name="about">Acerca de</string>
|
||||||
<string name="website">Más aplicaciones sencillas y código fuente en:\nhttp://simplemobiletools.com</string>
|
<string name="website">Más aplicaciones sencillas y código fuente en:\nhttp://simplemobiletools.com</string>
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
||||||
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
||||||
<string name="editor">Editor</string>
|
|
||||||
<string name="save">Save</string>
|
|
||||||
<string name="rotate">Rotate</string>
|
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 cartella eliminata</item>
|
<item quantity="one">1 cartella eliminata</item>
|
||||||
|
@ -45,6 +42,12 @@
|
||||||
<item quantity="other">%1$d file eliminati</item>
|
<item quantity="other">%1$d file eliminati</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Editor -->
|
||||||
|
<string name="editor">Editor</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="rotate">Rotate</string>
|
||||||
|
<string name="image_croping_failed">Image croping failed:</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Informazioni</string>
|
<string name="about">Informazioni</string>
|
||||||
<string name="website">Altre semplici app e codici sorgenti in:\nhttp://simplemobiletools.com</string>
|
<string name="website">Altre semplici app e codici sorgenti in:\nhttp://simplemobiletools.com</string>
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
||||||
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
||||||
<string name="editor">Editor</string>
|
|
||||||
<string name="save">Save</string>
|
|
||||||
<string name="rotate">Rotate</string>
|
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 フォルダーを削除しました</item>
|
<item quantity="one">1 フォルダーを削除しました</item>
|
||||||
|
@ -45,6 +42,12 @@
|
||||||
<item quantity="other">%1$d ファイルを削除しました</item>
|
<item quantity="other">%1$d ファイルを削除しました</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Editor -->
|
||||||
|
<string name="editor">Editor</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="rotate">Rotate</string>
|
||||||
|
<string name="image_croping_failed">Image croping failed:</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">アプリについて</string>
|
<string name="about">アプリについて</string>
|
||||||
<string name="website">もっとシンプルなアプリとソースコードは:\nhttp://simplemobiletools.com</string>
|
<string name="website">もっとシンプルなアプリとソースコードは:\nhttp://simplemobiletools.com</string>
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
<string name="cancel">Cancelar</string>
|
<string name="cancel">Cancelar</string>
|
||||||
<string name="set_as_wallpaper">Definir como fundo de ecrã</string>
|
<string name="set_as_wallpaper">Definir como fundo de ecrã</string>
|
||||||
<string name="set_as_wallpaper_failed">Falha ao definir como fundo de ecrã</string>
|
<string name="set_as_wallpaper_failed">Falha ao definir como fundo de ecrã</string>
|
||||||
<string name="editor">Editor</string>
|
|
||||||
<string name="save">Save</string>
|
|
||||||
<string name="rotate">Rotate</string>
|
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 pasta eliminada</item>
|
<item quantity="one">1 pasta eliminada</item>
|
||||||
|
@ -45,6 +42,12 @@
|
||||||
<item quantity="other">%1$d ficheiros eliminados</item>
|
<item quantity="other">%1$d ficheiros eliminados</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Editor -->
|
||||||
|
<string name="editor">Editor</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="rotate">Rotate</string>
|
||||||
|
<string name="image_croping_failed">Image croping failed:</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Sobre</string>
|
<string name="about">Sobre</string>
|
||||||
<string name="website">Mais aplicações simples e código de fonte em:\nhttp://simplemobiletools.com</string>
|
<string name="website">Mais aplicações simples e código de fonte em:\nhttp://simplemobiletools.com</string>
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
||||||
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
||||||
<string name="editor">Editor</string>
|
|
||||||
<string name="save">Save</string>
|
|
||||||
<string name="rotate">Rotate</string>
|
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 mapp borttagen</item>
|
<item quantity="one">1 mapp borttagen</item>
|
||||||
|
@ -45,6 +42,12 @@
|
||||||
<item quantity="other">%1$d filer borttagna</item>
|
<item quantity="other">%1$d filer borttagna</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Editor -->
|
||||||
|
<string name="editor">Editor</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="rotate">Rotate</string>
|
||||||
|
<string name="image_croping_failed">Image croping failed:</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Om</string>
|
<string name="about">Om</string>
|
||||||
<string name="website">Fler enkla appar och källkod här:\nhttp://simplemobiletools.com</string>
|
<string name="website">Fler enkla appar och källkod här:\nhttp://simplemobiletools.com</string>
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
||||||
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
||||||
<string name="editor">Editor</string>
|
|
||||||
<string name="save">Save</string>
|
|
||||||
<string name="rotate">Rotate</string>
|
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 folder deleted</item>
|
<item quantity="one">1 folder deleted</item>
|
||||||
|
@ -45,6 +42,12 @@
|
||||||
<item quantity="other">%1$d files deleted</item>
|
<item quantity="other">%1$d files deleted</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Editor -->
|
||||||
|
<string name="editor">Editor</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="rotate">Rotate</string>
|
||||||
|
<string name="image_croping_failed">Image croping failed:</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
<string name="website">More simple apps and source code at:\nhttp://simplemobiletools.com</string>
|
<string name="website">More simple apps and source code at:\nhttp://simplemobiletools.com</string>
|
||||||
|
|
Loading…
Reference in a new issue