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 {
|
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
||||||
val TAG: String = EditActivity::class.java.simpleName
|
val TAG: String = EditActivity::class.java.simpleName
|
||||||
|
lateinit var uri: Uri
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -29,6 +30,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uri = intent.data
|
||||||
|
if (uri.scheme != "file" && uri.scheme != "content") {
|
||||||
|
toast(R.string.unknown_file_location)
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
crop_image_view.apply {
|
crop_image_view.apply {
|
||||||
guidelines = CropImageView.Guidelines.OFF
|
guidelines = CropImageView.Guidelines.OFF
|
||||||
setOnCropImageCompleteListener(this@EditActivity)
|
setOnCropImageCompleteListener(this@EditActivity)
|
||||||
|
@ -57,7 +65,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
|
|
||||||
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
|
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
|
||||||
if (result.error == null) {
|
if (result.error == null) {
|
||||||
val path = intent.data.path
|
if (uri.scheme == "file") {
|
||||||
|
val path = uri.path
|
||||||
val file = File(path)
|
val file = File(path)
|
||||||
var out: FileOutputStream? = null
|
var out: FileOutputStream? = null
|
||||||
try {
|
try {
|
||||||
|
@ -67,6 +76,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Crop compressing failed $e")
|
Log.e(TAG, "Crop compressing failed $e")
|
||||||
toast(R.string.image_editing_failed)
|
toast(R.string.image_editing_failed)
|
||||||
|
finish()
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
out?.close()
|
out?.close()
|
||||||
|
@ -76,8 +86,15 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaScannerConnection.scanFile(applicationContext, arrayOf(path), null, { path: String, uri: Uri ->
|
MediaScannerConnection.scanFile(applicationContext, arrayOf(path), null, { path: String, uri: Uri ->
|
||||||
|
setResult(Activity.RESULT_OK, intent)
|
||||||
finish()
|
finish()
|
||||||
})
|
})
|
||||||
|
} else if (uri.scheme == "content") {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
toast(R.string.unknown_file_location)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast("${getString(R.string.image_croping_failed)} ${result.error.message}")
|
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="image_editing_failed">Image editing failed</string>
|
||||||
<string name="edit_image_with">Edit image with:</string>
|
<string name="edit_image_with">Edit image with:</string>
|
||||||
<string name="no_editor_found">No image editor found</string>
|
<string name="no_editor_found">No image editor found</string>
|
||||||
|
<string name="unknown_file_location">Unknown file location</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Über</string>
|
<string name="about">Über</string>
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<string name="image_editing_failed">Image editing failed</string>
|
<string name="image_editing_failed">Image editing failed</string>
|
||||||
<string name="edit_image_with">Edit image with:</string>
|
<string name="edit_image_with">Edit image with:</string>
|
||||||
<string name="no_editor_found">No image editor found</string>
|
<string name="no_editor_found">No image editor found</string>
|
||||||
|
<string name="unknown_file_location">Unknown file location</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Acerca de</string>
|
<string name="about">Acerca de</string>
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<string name="image_editing_failed">Image editing failed</string>
|
<string name="image_editing_failed">Image editing failed</string>
|
||||||
<string name="edit_image_with">Edit image with:</string>
|
<string name="edit_image_with">Edit image with:</string>
|
||||||
<string name="no_editor_found">No image editor found</string>
|
<string name="no_editor_found">No image editor found</string>
|
||||||
|
<string name="unknown_file_location">Unknown file location</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Informazioni</string>
|
<string name="about">Informazioni</string>
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<string name="image_editing_failed">Image editing failed</string>
|
<string name="image_editing_failed">Image editing failed</string>
|
||||||
<string name="edit_image_with">Edit image with:</string>
|
<string name="edit_image_with">Edit image with:</string>
|
||||||
<string name="no_editor_found">No image editor found</string>
|
<string name="no_editor_found">No image editor found</string>
|
||||||
|
<string name="unknown_file_location">Unknown file location</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">アプリについて</string>
|
<string name="about">アプリについて</string>
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<string name="image_editing_failed">Image editing failed</string>
|
<string name="image_editing_failed">Image editing failed</string>
|
||||||
<string name="edit_image_with">Edit image with:</string>
|
<string name="edit_image_with">Edit image with:</string>
|
||||||
<string name="no_editor_found">No image editor found</string>
|
<string name="no_editor_found">No image editor found</string>
|
||||||
|
<string name="unknown_file_location">Unknown file location</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Sobre</string>
|
<string name="about">Sobre</string>
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<string name="image_editing_failed">Image editing failed</string>
|
<string name="image_editing_failed">Image editing failed</string>
|
||||||
<string name="edit_image_with">Edit image with:</string>
|
<string name="edit_image_with">Edit image with:</string>
|
||||||
<string name="no_editor_found">No image editor found</string>
|
<string name="no_editor_found">No image editor found</string>
|
||||||
|
<string name="unknown_file_location">Unknown file location</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">Om</string>
|
<string name="about">Om</string>
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<string name="image_editing_failed">Image editing failed</string>
|
<string name="image_editing_failed">Image editing failed</string>
|
||||||
<string name="edit_image_with">Edit image with:</string>
|
<string name="edit_image_with">Edit image with:</string>
|
||||||
<string name="no_editor_found">No image editor found</string>
|
<string name="no_editor_found">No image editor found</string>
|
||||||
|
<string name="unknown_file_location">Unknown file location</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
|
Loading…
Reference in a new issue