Adding auto-zoom feature to Android-Image-Cropper

In this post I will describe the work I did to add auto-zoom functionality to Android-Image-Cropper library.
The goal is a smooth zoom-in/out experience affected by the size of the cropping window. When the user adjusts the crop window to cover less than 50% of the image current total visible sub-area, auto-zoom-in is triggered to zoom-in and center on the relevant cropping image zoomed sub-area so the crop window will cover 64% of it. Similarly, when the crop rectangle is above 65% auto-zoom-out is triggered so zoomed sub-area will be 51% covered.
 
Steps:

  1. Using matrix scale type for the cropping image in image view .
  2. Handle image rotation via matrix transformation.
  3. Adding auto-zoom-in/out to matrix transformation.
  4. Smoothing transitions using animations.
  5. Cropping using invert matrix transformation.

 

Result:

result.gif
Continue reading

Android Image Cropper async support and custom progress UI

It's embarrassing really, soon after creating my Android-Image-Cropper fork as I wrote about in my previous post, a GitHub user noted that I have a slowness issue caused by loading/decoding image URI on main thread potentially causing an ANR, really a newbie mistake.
Unfortunately starting a new startup I didn't have the time to fix it then, and no one come forward with a pull request. Fortunately the company is more mature now so I can commit a bit of my free time for the project.
 
What we will have here:

  • A few words on the implementation.
  • Using setImageUriAsync and getCroppedImageAsync.
  • Handling OnSetImageUriComplete and OnGetCroppedImageComplete listeners.
  • Overriding default progress bar UI using showProgressBar view attribute and listeners.

 
TL;DR See the gist.
Continue reading

Publish Android library to BinTray (JCenter), AAR vs. JAR and optional dependency

Working on Android open-source I needed to publish two libraries (Android-Image-Cropper and Android-Fast-Image-Loader) to JCenter.
 
What I will touch in this post:

  • Publishing AAR
  • "Sources not found" issue with AAR
  • AAR vs. JAR
  • Publishing JAR
  • Handling optional dependency in Gradle

 
TL;DR see the release gradle script.
 
clip_image001.png
Continue reading

Android cropping image from camera or gallery

Recently I needed to implement avatar image upload from an Android app, I didn't found a library that did all that I needed so I forked a pretty good one and made it better, check it out: Android Image Cropper.
 
See also the followup post: Android Image Cropper async support and custom progress UI.
 

Requirements:

  • Pick image from camera or gallery using single chooser.
  • Select circular crop window in the image for the avatar.
  • Limit output avatar image to 500×500 pixels.
  • Efficient memory usage.

Continue reading

HTML Renderer 1.5.0.0

A lot of things has changed in the past year and it seems more is going to change in the next, unfortunately those changes are not aligned with the work required for HTML Renderer. That's why it took so long for v1.5 release to finally be ready and the reason not all features I originally planned made it.
 
With a heavy heart I'm going to hold all significant work on HTML Renderer until either my career path brings me back to .NET, I have more free time to work on it or the project will get more attentions. In the meanwhile I will continue to support the library with small fixes and answering question on the discussions/issues pages.
Continue reading

Setting HTML/Text to Clipboard revisited

After getting feedback that my original clipboard code doesn't handle all scenarios, especially with Chrome, I went back to the code to get a better understand of what's going on and find the correct way to set plain text and HTML snippet to clipboard.

 
Highlights

  • Setting plain text and html data.
  • Unicode support for plain text.
  • Clipboard HTML format
    • Version.
    • Parts start/end offsets.
    • StartFragment/EndFragment comments.
    • <html> and <body> elements.
    • Unicode handling.

Continue reading