It is convenient to be able to perform simple edits, such as cropping and rotation, to an image you are posting to Mastodon without leaving the app. This is especially convenient when posting multiple attachments. Competing products such as the Twitter app, or Twidere (dualmode Twitter/Mastodon client) have this feature built in already.
I recently added a crop/rotate attachment feature to Tusky (the Android client I personally use for Mastodon) and if it is helpful I could contribute the same/similar code to the Mastodon official Android app. However I had a conversation with someone named Gregory that I think might work on the mastodon-android app and he suggested there might be special requirements for the official app, such as avoiding use of androidx (?), which might prevent the Tusky code from being easily used.
I can think of three ways to implement a crop feature; I'd be able to contribute a PR for the first or second options (probably sometime next week), but not the third option.
Use Android-Image-Cropper. This is a fairly pleasant third-party library that handles an entire crop screen by itself. This is what we use in Tusky for image cropping. This would also make it possible to quickly resolve issue #76. However I believe Android-Image-Cropper does make some use of androidx.
Use an implicit intent. In other words we ask Android to open an image editor. This has the advantage that the user can pick any editor they want, including editors with exotic features such as faceblurring and captioning, and in theory it can be trivially extended for video and audio editing as well. The disadvantage (which Gregory seemed concerned about) is that there is no guarantee an appropriate image editor is installed on the system. Modern Google Play Services includes Photos, but some unusual OEM builds might not include a photo editor or the included photo editor might not be properly registered for android.intent.action.EDIT. You would have to catch the "no intent available" error and present an error dialog directing the user to download a photo editor app. Also, I don't think (?) you could use this for #76 (I'm not aware of a way to force an aspect ratio when using the EDIT intent like Android-Image-Cropper has; though maybe it exists and I just didn't find it)
I have the code to do this just sitting around because I am trying to use this approach for video editing in Tusky. The Tusky patch is not finished because (1) we want to switch it to use androidx Contracts, and (2) I have not yet got it to work for video editing. However, this approach might work for you because (1) if you are trying to avoid androidx then the existing code would be better anyway (we do use android.webkit.MimeTypeMap, but this part is probably removable) and (2) the image-editing version works fine in testing.
Build your own crop UI screen from the ground up. This would give you full control (and allow you to include the "focal point" feature Mastodon web has) however, it might take more time and I would not be able to assist.
Please let me know if either PR described above would be welcome.
If I were to contribute this feature I would need one specific question answered: How should the editor be launched? We have a per-attachment menu in Tusky, but Mastodon-Android has individual buttons across the bottom of the attachment instead. My guess is you'd want to add a little red "edit" icon next to the trash can icon.
The only reason I use a third-party app (in my case Tusky) for Mastodon on Android instead of the "official" app or the PWA in mobile browser is because the web UI and the official app don't have a crop feature!
It is convenient to be able to perform simple edits, such as cropping and rotation, to an image you are posting to Mastodon without leaving the app. This is especially convenient when posting multiple attachments. Competing products such as the Twitter app, or Twidere (dualmode Twitter/Mastodon client) have this feature built in already.
I recently added a crop/rotate attachment feature to Tusky (the Android client I personally use for Mastodon) and if it is helpful I could contribute the same/similar code to the Mastodon official Android app. However I had a conversation with someone named Gregory that I think might work on the mastodon-android app and he suggested there might be special requirements for the official app, such as avoiding use of androidx (?), which might prevent the Tusky code from being easily used.
I can think of three ways to implement a crop feature; I'd be able to contribute a PR for the first or second options (probably sometime next week), but not the third option.
Use an implicit intent. In other words we ask Android to open an image editor. This has the advantage that the user can pick any editor they want, including editors with exotic features such as faceblurring and captioning, and in theory it can be trivially extended for video and audio editing as well. The disadvantage (which Gregory seemed concerned about) is that there is no guarantee an appropriate image editor is installed on the system. Modern Google Play Services includes Photos, but some unusual OEM builds might not include a photo editor or the included photo editor might not be properly registered for
android.intent.action.EDIT
. You would have to catch the "no intent available" error and present an error dialog directing the user to download a photo editor app. Also, I don't think (?) you could use this for #76 (I'm not aware of a way to force an aspect ratio when using the EDIT intent like Android-Image-Cropper has; though maybe it exists and I just didn't find it)I have the code to do this just sitting around because I am trying to use this approach for video editing in Tusky. The Tusky patch is not finished because (1) we want to switch it to use androidx Contracts, and (2) I have not yet got it to work for video editing. However, this approach might work for you because (1) if you are trying to avoid androidx then the existing code would be better anyway (we do use android.webkit.MimeTypeMap, but this part is probably removable) and (2) the image-editing version works fine in testing.
Please let me know if either PR described above would be welcome.
If I were to contribute this feature I would need one specific question answered: How should the editor be launched? We have a per-attachment menu in Tusky, but Mastodon-Android has individual buttons across the bottom of the attachment instead. My guess is you'd want to add a little red "edit" icon next to the trash can icon.