mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
take the file uri scheme into account when editing and saving files
This commit is contained in:
parent
b2cea47c8d
commit
ca65ead9a7
8 changed files with 41 additions and 17 deletions
|
@ -18,6 +18,7 @@ import java.io.IOException
|
|||
|
||||
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
||||
val TAG: String = EditActivity::class.java.simpleName
|
||||
lateinit var uri: Uri
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -29,6 +30,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
|||
return
|
||||
}
|
||||
|
||||
uri = intent.data
|
||||
if (uri.scheme != "file" && uri.scheme != "content") {
|
||||
toast(R.string.unknown_file_location)
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
crop_image_view.apply {
|
||||
guidelines = CropImageView.Guidelines.OFF
|
||||
setOnCropImageCompleteListener(this@EditActivity)
|
||||
|
@ -57,7 +65,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
|||
|
||||
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
|
||||
if (result.error == null) {
|
||||
val path = intent.data.path
|
||||
if (uri.scheme == "file") {
|
||||
val path = uri.path
|
||||
val file = File(path)
|
||||
var out: FileOutputStream? = null
|
||||
try {
|
||||
|
@ -67,6 +76,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
|||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Crop compressing failed $e")
|
||||
toast(R.string.image_editing_failed)
|
||||
finish()
|
||||
} finally {
|
||||
try {
|
||||
out?.close()
|
||||
|
@ -76,8 +86,15 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
|||
}
|
||||
|
||||
MediaScannerConnection.scanFile(applicationContext, arrayOf(path), null, { path: String, uri: Uri ->
|
||||
setResult(Activity.RESULT_OK, intent)
|
||||
finish()
|
||||
})
|
||||
} else if (uri.scheme == "content") {
|
||||
|
||||
} else {
|
||||
toast(R.string.unknown_file_location)
|
||||
finish()
|
||||
}
|
||||
} else {
|
||||
toast("${getString(R.string.image_croping_failed)} ${result.error.message}")
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<string name="image_editing_failed">Image editing failed</string>
|
||||
<string name="edit_image_with">Edit image with:</string>
|
||||
<string name="no_editor_found">No image editor found</string>
|
||||
<string name="unknown_file_location">Unknown file location</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">Über</string>
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<string name="image_editing_failed">Image editing failed</string>
|
||||
<string name="edit_image_with">Edit image with:</string>
|
||||
<string name="no_editor_found">No image editor found</string>
|
||||
<string name="unknown_file_location">Unknown file location</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">Acerca de</string>
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<string name="image_editing_failed">Image editing failed</string>
|
||||
<string name="edit_image_with">Edit image with:</string>
|
||||
<string name="no_editor_found">No image editor found</string>
|
||||
<string name="unknown_file_location">Unknown file location</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">Informazioni</string>
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<string name="image_editing_failed">Image editing failed</string>
|
||||
<string name="edit_image_with">Edit image with:</string>
|
||||
<string name="no_editor_found">No image editor found</string>
|
||||
<string name="unknown_file_location">Unknown file location</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">アプリについて</string>
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<string name="image_editing_failed">Image editing failed</string>
|
||||
<string name="edit_image_with">Edit image with:</string>
|
||||
<string name="no_editor_found">No image editor found</string>
|
||||
<string name="unknown_file_location">Unknown file location</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">Sobre</string>
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<string name="image_editing_failed">Image editing failed</string>
|
||||
<string name="edit_image_with">Edit image with:</string>
|
||||
<string name="no_editor_found">No image editor found</string>
|
||||
<string name="unknown_file_location">Unknown file location</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">Om</string>
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<string name="image_editing_failed">Image editing failed</string>
|
||||
<string name="edit_image_with">Edit image with:</string>
|
||||
<string name="no_editor_found">No image editor found</string>
|
||||
<string name="unknown_file_location">Unknown file location</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">About</string>
|
||||
|
|
Loading…
Reference in a new issue