Saturday, 23 January 2016

uCrop - Image Cropping Library for Android

uCrop - Image Cropping Library for Android

This project aims to provide an ultimate and flexible image cropping experience.

alt text


  1. Include the library as local library project.
    compile 'com.yalantis:ucrop:1.0.1'
  2. Add UCropActivity into your AndroidManifest.xml
  3. The uCrop configuration is created using the builder pattern.
    UCrop.of(sourceUri, destinationUri)
        .withAspectRatio(16, 9)
        .withMaxResultSize(maxWidth, maxHeight)
  4. Override onActivityResult method and handle uCrop result.
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
            final Uri resultUri = UCrop.getOutput(data);
        } else if (resultCode == UCrop.RESULT_ERROR) {
            final Throwable cropError = UCrop.getError(data);


If you want to let your users choose crop ratio dynamically, just do not call withAspectRatio(x, y).
uCrop builder class has method withOptions(UCrop.Options option) which extends library configurations.
Currently you can change:
  • image compression format (e.g. PNG, JPEG, WEBP), compression
  • image compression quality [0 - 100]. PNG which is lossless, will ignore the quality setting.
  • whether all gestures are enabled simultaneously
  • maximum size for Bitmap that is decoded from source Uri and used within crop view. If you want to override default behaviour.
  • more coming... (e.g. color pallet)


  • Library - Android GINGERBREAD 2.3+
  • Sample - Android ICS 4.0+

Friday, 22 January 2016

Android Smart Login

What's in the box

  • A material designed login page
  • Implementation of Facebook and Google login
  • Easy way to implement custom login and sign up
  • Smart and easy way to apply the flow with SmartUser
  • Customizable login screen (more customization will be available in upcoming versions)


1. Get the library from here

Since it's in beta, decided not to put it in Maven Central. Will provide the gradle dependency from the first release. So for now please add the library as a module to your project.

2. Add the AAR as a module dependency to your app.

You can do this by clicking File -> New -> New Module... Then choose "Import .JAR/.AAR package" option and the add the downloaded aar file as a dependency. You need to compile this newly added module. This can be done by adding this line in your dependencies of your app/build.gradle
    compile project(':smartloginlibrary-v0.5beta')
Since we implemented Facebook and Google login for you, it is necessary to add the following dependencies in yourapp/build.gradle
    //Support libraries
    compile ''
    compile ''
    //Facebook SDK
    compile ''
    //Google Play Services
    compile ''
    //GSON library
    compile ''
We used
  • Support Library for maintaining compatibily of material design
  • Facebook SDK and Google Play Services are necessary as we implemented social logins
  • GSON library is must for now as we used it to set user sessions

3. Start the LoginActivity

First instantiate the SmartLoginBuilder and the using the created object build the Intent to invoke the login page.
    SmartLoginBuilder loginBuilder = new SmartLoginBuilder();
    Intent intent = loginBuilder.with(context)
    startActivityForResult(intent, SmartLoginConfig.LOGIN_REQUEST);
Don't forget to add the following in the manifest
    <uses-permission android:name="android.permission.INTERNET"/>
    <!-- Required for Google Login -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <!-- In application tag (Need to register the Login activity in your app) -->
            android:theme="@style/AppTheme" />
    <activity android:name="com.facebook.FacebookActivity"
            android:label="@string/app_name" />
  • APP_LOGO - Integer - Optional - Send your logo to display on the login page.
    Facebook Login setup
  • APP_ID - String - Needed if Facebook login is enabled - App ID of your app on facebook
  • PERMISSIONS - ArrayList - Needed if Facebook login is enabled (if not specified these Default Permissions are taken). Learn more about Facebook Login Permissions.
    Google Login setup
  • Just enable Google login by passing true to isGoogleLoginEnabled method
  • Before that, you need to configure your app in Google Developers Console and get the Configuration File. Learn more about Google sign in
  • Place the configuration file in the app/ directory and that's it.

4. Get back the logged in User

From the intent that you passed, Login Activity will be started. Based on user interaction, it will send back the result code along with SmartUser object(if login is successful). Hence you can catch the SmartUser object in onActivityResult method
For example
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        //Intent "data" contains the user object
        if(resultCode == SmartLoginConfig.FACEBOOK_LOGIN_REQUEST){
            SmartFacebookUser user;
            try {
                user = data.getParcelableExtra(SmartLoginConfig.USER);
                //use this user object as per your requirement
            }catch (Exception e){
                Log.e(getClass().getSimpleName(), e.getMessage());
        }else if(resultCode == SmartLoginConfig.GOOGLE_LOGIN_REQUEST){
            SmartGoogleUser user;
            try {
                user = data.getParcelableExtra(SmartLoginConfig.USER);
                //use this user object as per your requirement
            }catch (Exception e){
                Log.e(getClass().getSimpleName(), e.getMessage());
        }else if(resultCode == SmartLoginConfig.CUSTOM_LOGIN_REQUEST){
            SmartUser user = data.getParcelableExtra(SmartLoginConfig.USER);
            //use this user object as per your requirement
        }else if(resultCode == RESULT_CANCELED){
            //Login Failed
VoilĂ ! That's it. You now have the entire user login functionality in your app

5. Implementing custom user login and sign up

Get more out of the library by easily implementing your logic to login and sign up the users. For this, all you need to do is implement the following code:
        SmartCustomLoginListener loginListener = new SmartCustomLoginListener() {
            public boolean customSignin(SmartUser smartUser) {
                //do something with smartUser
                    return true;
                } else {
                    return false;

            public boolean customSignup(SmartUser smartUser) {
                //do something with smartUser
                    return true;
                } else {
                    return false;

            public boolean customUserSignout(SmartUser smartUser) {
                //do something with smartUser
                    return true;
                } else {
                    return false;
Next pass that loginListener into setSmartCustomLoginHelper method of loginBuilder
Intent intent = loginBuilder.with(context)
startActivityForResult(intent, SmartLoginConfig.LOGIN_REQUEST);

How it works


Other Features

Get the current logged in user at anytime from your application by just calling UserSessionManager.getCurrentUsermethod
SmartUser currentUser = UserSessionManager.getCurrentUser(context);
if(currentUser != null){
    //You have got what you need

Material Design Steppers

Material Design Steppers

Google Material Design Steppers Component 

compile ''
Steps to Add To your Project :
  1. Download the library (i have added to jcenter and waiting for approval) or add in your libs folder
  2. Extend your Activity -> from mobileStepperSimple Class
  3. Implement the Methods initApp and onStepperCompleted
  4. Basically Every Steps will be Fragments and will be handling UserInteraction,so create,Extend your fragments fromstepperFragment
  5. Implement the Method onNextButtonHandler which should return true/false to determine the Library to Move Ahead for next Step,So write your UI validations here and return appropriately.
  6. In your Activity create Objects for your fragments made with stepperFragment ,create as many fragments for your use
  7. Create List and add all the object of fragments.
  8. Inside your initApp overriden Method, just setFragments(PASS_LIST_OF_FRAGMENTS)
  9. >
  10. finally call init() method from your initApp() method
  11. Use onStepperCompleted() for taking actions after the Stepper fragments are completely done by the user
Note : with the given List size : step count will be Computed and Updated,Increasing and dynamic fragment feature will be added in future Commits, Scrollview have been adopted for fragment inbuilt to scroll,So no worries for small screens and large layout.


Included the Example Demo app in Example Medical App project,Download and Sync with
Screenshot :

demo screenshot 

Use of this Library :

  1. Payment Processing Steps for Checkouts
  2. Account verification and creation
  3. Survey Apps and Form fillup driven apps (Highly Recommended)
  4. Any Accomplishment apps and Task driven apps.

Android Percent Progress Bar

Android Percent ProgressBar

Inspired by NumberProgressBar, this is Android-PercentProgressBar, CircularProgressBar and LineProgressBar with progress percentage shown. 


It is very easy to use, to integrate and to customize PercentProgressBar. Demo is available here:
example0 example1example2example3

Thursday, 19 February 2015

Logan Square


The fastest JSON parsing and serializing library available for Android. Based on Jackson's streaming API, LoganSquare is able to consistently outperform GSON and Jackson's Databind library by 400% or more. By relying on compile-time annotation processing to generate code, you know that your JSON will parse and serialize faster than any other method available.
By using this library, you'll be able to utilize the power of Jackson's streaming API without having to code tedius, low-level code involving JsonParsers orJsonGenerators. Instead, just annotate your model objects as a @JsonObject and your fields as @JsonFields and we'll do the heavy lifting for you.
Don't believe it could improve upon Jackson Databind's or GSON's performance that much? Well, then check out the nifty graphs below for yourself. Not convinced? Feel free to build and run the BenchmarkDemo app included in this repository.


Note that Gradle is the only supported build configuration for LoganSquare. To add the library to your app's build.gradle file.
  apply plugin: ''

  dependencies {
    apt 'com.bluelinelabs:logansquare-compiler:1.0.3'
    compile 'com.bluelinelabs:logansquare:1.0.3'
For the curious, the first line adds the apt plugin, which is what allows us to do compile-time annotation processing. The first dependency is what tells Gradle to process your JSON annotations, and the second dependency is our tiny 19kb runtime library that interfaces with the generated code for you.


Using LoganSquare is about as easy as it gets. Here are a few docs to get you started:


Like all libraries that generate dynamic code, Proguard might think some classes are unused and remove them. To prevent this, the following lines can be added to your proguard config file.
-keep class com.bluelinelabs.logansquare.** { *; }
-keep class **$$JsonObjectMapper { *; }

Why LoganSquare?

We're BlueLine Labs, a mobile app development company based in Chicago. We love this city so much that we named our company after the blue line of the iconic 'L.' And what's one of the most popular stops on the blue line? Well, that would be Logan Square of course. Does it have anything to do with JSON? Nope, but we're okay with that.

Android Random Color

Android Random Color

Inspired by David Merfield's randomColor.js. And onevcat's RandomColorSwift It is a ported version to Android. You can use the library to generate attractive random colors on Android.
See the demo and site to know why does this exist.


dependencies {
    compile 'com.github.lzyzsd.randomcolor:library:1.0.0'


// Returns a random int color value

RandomColor randomColor = new RandomColor();
int color = randomColor.randomColor();

// Returns an array of 10 random color values

RandomColor randomColor = new RandomColor();
int[] color = randomColor.randomColor(10);

//This lib also predefine some colors, so than you can random color by these predefined colors

// Returns an array of ten green colors

randomColor.random(RandomColor.Color.GREEN, 10);

// Returns a random color use hue, saturation, luminosity
// saturation has two kinds of value: RANDOM, MONOCHROME
// luminosity has for kinds of value: BRIGHT, LIGHT, DARK, RANDOM

randomColor(int value, SaturationType saturationType, Luminosity luminosity)

Mini Equalizer Library for Android

Mini Equalizer Library for Android

This Android Library project is created to let you use a animated equalizer inside your music related apps.

How to use it

Add this to your dependencies:
compile 'com.github.claucookie.miniequalizer:library:1.0.0'




There is some custom attributes you can adjust from the xml:
  • foregroundColor : the equalizer bars color (default is black)
  • animDuration : (millisecs) the animation follows a pattern and the number of loops is infinite. To set the duration of each loop, use this attribute.


Initialization + animation

To start animating the equalizer you should add:
EqualizerView equalizer = (EqualizerView) findViewById(;
equalizer.animateBars(); // Whenever you want to tart the animation
equalizer.stopBars(); // When you want equalizer stops animating