From 1d04e60dff44d012647fe56b63f3d0b14770cce7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 18 Jun 2017 19:56:45 +0200 Subject: [PATCH] allow opening the image with a different editor from our editor --- .../gallery/activities/EditActivity.kt | 7 +++++++ .../gallery/activities/PhotoVideoActivity.kt | 2 +- .../gallery/activities/ViewPagerActivity.kt | 2 +- .../gallery/adapters/MediaAdapter.kt | 2 +- .../simplemobiletools/gallery/extensions/activity.kt | 12 ++++++++---- app/src/main/res/menu/menu_editor.xml | 4 ++++ app/src/main/res/values-cs/strings.xml | 1 + app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hu/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sk/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 23 files changed, 39 insertions(+), 7 deletions(-) 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 d69eb1393..8ce60f1f5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -18,6 +18,7 @@ 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.simplemobiletools.gallery.extensions.openEditor import com.theartofdev.edmodo.cropper.CropImageView import kotlinx.android.synthetic.main.view_crop_image.* import java.io.* @@ -75,6 +76,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener R.id.resize -> resizeImage() R.id.flip_horizontally -> flipImage(true) R.id.flip_vertically -> flipImage(false) + R.id.edit -> editWith() else -> return super.onOptionsItemSelected(item) } return true @@ -189,6 +191,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener crop_image_view.flipImageVertically() } + private fun editWith() { + openEditor(uri, true) + finish() + } + private fun scanFinalPath(path: String) { scanPath(path) { setResult(Activity.RESULT_OK, intent) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 8898e84fc..0aa50ac78 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -143,7 +143,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList R.id.menu_set_as -> trySetAs(File(mMedium!!.path)) R.id.menu_open_with -> openWith(File(mMedium!!.path)) R.id.menu_share -> shareUri(mMedium!!, mUri) - R.id.menu_edit -> openEditor(File(mMedium!!.path)) + R.id.menu_edit -> openFileEditor(File(mMedium!!.path)) else -> return super.onOptionsItemSelected(item) } return true diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 28f0bc57b..7ac0c413a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -208,7 +208,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View R.id.menu_share -> shareMedium(getCurrentMedium()!!) R.id.menu_delete -> askConfirmDelete() R.id.menu_rename -> renameFile() - R.id.menu_edit -> openEditor(getCurrentFile()) + R.id.menu_edit -> openFileEditor(getCurrentFile()) R.id.menu_properties -> showProperties() R.id.menu_save_as -> saveImageAs() R.id.show_on_map -> showOnMap() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 7d4968bda..caa3358cd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -172,7 +172,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } private fun editFile() { - activity.openEditor(getCurrentFile()) + activity.openFileEditor(getCurrentFile()) actMode?.finish() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index 0d98d0802..40c91d4cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -130,9 +130,9 @@ fun Activity.openWith(file: File, forceChooser: Boolean = true) { action = Intent.ACTION_VIEW setDataAndType(uri, file.getMimeType()) addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - val chooser = Intent.createChooser(this, getString(R.string.open_with)) if (resolveActivity(packageManager) != null) { + val chooser = Intent.createChooser(this, getString(R.string.open_with)) startActivity(if (forceChooser) chooser else this) } else { toast(R.string.no_app_found) @@ -140,15 +140,19 @@ fun Activity.openWith(file: File, forceChooser: Boolean = true) { } } -fun Activity.openEditor(file: File) { - val uri = Uri.fromFile(file) +fun Activity.openFileEditor(file: File) { + openEditor(Uri.fromFile(file)) +} + +fun Activity.openEditor(uri: Uri, forceChooser: Boolean = false) { Intent().apply { action = Intent.ACTION_EDIT setDataAndType(uri, "image/*") addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) if (resolveActivity(packageManager) != null) { - startActivityForResult(this, REQUEST_EDIT_IMAGE) + val chooser = Intent.createChooser(this, getString(R.string.edit_image_with)) + startActivityForResult(if (forceChooser) chooser else this, REQUEST_EDIT_IMAGE) } else { toast(R.string.no_editor_found) } diff --git a/app/src/main/res/menu/menu_editor.xml b/app/src/main/res/menu/menu_editor.xml index eeeb84d73..01aad0437 100644 --- a/app/src/main/res/menu/menu_editor.xml +++ b/app/src/main/res/menu/menu_editor.xml @@ -30,4 +30,8 @@ android:title="@string/flip_vertically"/> + diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 47ba2b8ba..eab90b817 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -68,6 +68,7 @@ Překlopit vodorovně Překlopit svisle Zařízení nemá dostatek paměti + Edit with Jednoduchá tapeta diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 542b403e2..949a72095 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -68,6 +68,7 @@ Horizontal spiegeln Vertikal spiegeln Fehler: Zuwenig Speicher + Edit with Schlichter Hintergrund diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9b326b8f2..b5694df3c 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -68,6 +68,7 @@ Horizontalmente Verticalmente Error: sin memoria + Edit with Fondos de pantalla Simple Gallery diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 470971c4e..4f32096b2 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -68,6 +68,7 @@ Retourner horizontalement Retourner verticallement Erreur excès de mémoire + Edit with Simple fond d\'écran diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index f1692241a..d0120b7d9 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -68,6 +68,7 @@ Flip horizontally Flip vertically Out of memory error + Edit with Simple Wallpaper diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index e85869135..fa274c077 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -68,6 +68,7 @@ Capovolgi orizzontalmente Capovolgi verticalmente Errore memoria esaurita + Edit with Sfondo semplice diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 2ce8f8489..67eed51b2 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -68,6 +68,7 @@ Flip horizontally Flip vertically Out of memory error + Edit with シンプル壁紙 diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 02410dc9d..b8fafa6ff 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -68,6 +68,7 @@ Flip poziomo Flip pionowo Błąd pamięci + Edit with Tapeta diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 08a35a87a..9c09d69f6 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -68,6 +68,7 @@ Horizontalmente Verticalmente Memória insuficiente + Edit with Simple Wallpaper diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index b9add0c44..07d1e99fa 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -68,6 +68,7 @@ Horizontalmente Verticalmente Memória insuficiente + Edit with Simple Wallpaper diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 3a1f00272..fd09fae47 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -68,6 +68,7 @@ По горизонтали По вертикали Память переполнена + Edit with Простые обои diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 52b19f1e9..68beaf6cc 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -68,6 +68,7 @@ Preklopiť vodorovne Preklopiť zvisle Došlo k chybe s nedostatkom pamäte + Upraviť s Jednoduchá tapeta diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index a46dd4c16..7e3133464 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -68,6 +68,7 @@ Flip horizontally Flip vertically Out of memory error + Edit with Bakgrundsbild diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 409d5a350..80f72abb2 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -68,6 +68,7 @@ Yatay Dikey Yetersiz bellek hatası + Edit with Basit Duvar Kağıdı diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 6dace54b6..66e2d9d7f 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -68,6 +68,7 @@ 水平翻转 垂直翻转 内存不足 + Edit with Simple Wallpaper diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index d8d5ac078..fdd1155a7 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -68,6 +68,7 @@ Flip horizontally Flip vertically Out of memory error + Edit with 簡易桌布 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f98362003..26b9fc2f8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -68,6 +68,7 @@ Flip horizontally Flip vertically Out of memory error + Edit with Simple Wallpaper