artectrex's blog - PixelDroid & Android Media Editor library

Some news about PixelDroid and the Android Media Editor Library

đź“… 27 Mar 2024

Well, it seems like I’m not much of a regular blogger. Maybe I’ll change that? No promises :D

PixelDroid: List of some changes and improvements

  1. Removed the dependency on an old & abandoned filter library: we completely reworked the code for adding filters and changing brightness/contrast/saturation.
    • Previously, the implementation was based on a library that uses native code for the image processing. While better than doing it in the JVM, this was still a bit slow especially on older devices because it looped on the whole image pixel by pixel.
    • Another issue with this library is that it was abandoned and hosted on the JCenter repository (which was shut down).
    • Now, we implemented the filters & brightness/contrast/saturation sliders using OpenGL. This makes the sliders feel much more responsive. It should also use less battery. The way this was implemented gives us very powerful tools to make fun filters. As of today, we just tried to have feature-parity, but I aim to add a very cool feature that lets you make your own filters later this week.
  2. A lot of bugfixes, non-exhaustive list in no particular order:
    • Album indicator not hiding in full screen (#384)
    • AlbumActivity: full screen doesn’t hide statusbar (#323)
    • Fix profile description link clicks (#318)
    • Crash on some Android versions & devices due to unknown windowLayoutInDisplayCutoutMode (#374 and #371)
    • Permissions issues on Android 13+ (#369)
    • Video encode “Encode success” message shows when it shouldn’t (#372)
    • Different file permission issues on Android 13+ (#359)
    • Timeline sort bug causing older posts to not load (part pixelfed server, part PixelDroid bug) (#366)
    • Cropping not prompting save before exit dialog (#344)
    • Crash when server is offline and returning non-pixelfed error page (#357)
    • Account info not updated in rest of app after editing profile (#377)
    • Lack of permission pop-up should be less aggressive/persistent (#364)
    • Can’t upload a video (#362)
    • Keep state (which photo is being looked at) on rotation in album (MR !558)
    • i18n, because not everyone speaks English (this bug affects my native language 🤦): Fix comment string being both verb and noun (MR !565)
  3. and small QoL improvements, non-exhaustive list in no particular order
    • Setting to enable NSFW by default (#351)
    • Split APKs into architectures, making them much smaller, from 100MB to about 25MB for most people! (Release of beta 33)
    • Add profile picture editing (MR !569)
  4. Stories! You can now:
    • Create Stories
    • Look at other people’s Stories
    • Look at your Stories
    • Comment on Stories

I think the implementation of Stories is pretty nice, and it doesn’t get in the way if you don’t use it.

Android Media Editor library

Many of the changes mentioned above in the PixelDroid section are actually implemented within the “Android Media Editor” library (it was a temporary name but I can’t figure out a better one please help me I’m so bad at naming things).

This library is aiming to provide the easiest way to add image and/or video editing to your Android app. Just add the gradle dependency, send off your photo or video in an Intent to an Activity provided by the library, and get back the modified image.

For instance, the new OpenGL backend for the image filters, and also several of the bug fixes concerned the library’s code rather than PixelDroid directly.

The OpenGL backend required quite some work to get it to be compatible with all phones and OpenGL ES support levels. I know (knew) nothing of OpenGL, so this was quite a journey for me and I had some help from more knowledgeable people to write the shaders.

Another big area of work in the library was to modularize it: let library consumers pick and choose what they want.

What does that mean? For example if you don’t need the video edit functionality, it can be good to omit it because it can get quite big - especially if you don’t split the APKs as was implemented in PixelDroid recently (Release of beta 33).

You can now do this:

def ME-version = "2.0"
implementation 'org.pixeldroid.pixeldroid.android-media-editor:common:ME-version'
implementation 'org.pixeldroid.pixeldroid.android-media-editor:photoEdit:ME-version'
// OR
implementation 'org.pixeldroid.pixeldroid.android-media-editor:videoEdit:ME-version'

Now that the infrastructure for this is present, future big features can easily also be made optional.

Now, what’s next?

In the coming days I will release a very simple app that uses the Android Media Editor library, basically a dumb wrapper around it: file in, file out. I’ll try to use F-Droid’s reproducible builds for it now that I have some experience in that after helping publish FoCal, a very cool photo diary app a friend of mine made (available on F-Droid). Let’s see how it goes.

I will also add the very cool custom filter feature I mentioned earlier: since we are using OpenGL shaders, you will be able to plug in your own OpenGL shaders and do all sorts of cool stuff with your pictures. I’m so curious to what people will come up with!

Expect a new blog post within the week after the release of these two features (if I miss this self-imposed deadline you can make me learn JavaScript, worse punishment is beyond my imagination).