Code Monkey home page Code Monkey logo

gradle-android-appiconoverlay's Introduction

gradle-android-appiconoverlay

Plugin for Android Gradle to automatically overlay the app icon with information about the current build: git branch name and commit SHA1.

Example

Example: app icon with overlay

Usage

  1. This plugin is published on JCenter. Add dependency in your Android project's top-level build.gradle file:

    buildscript {
        dependencies {
            classpath 'com.github.splatte:gradle-android-appiconoverlay:1.3'
        }
    }
  2. Apply the plugin in your app module's build.gradle file:

    apply plugin: 'app-icon-overlay'
    appiconoverlay {
        /* then see below for configuration options */
    }
    
    android {
        /* project config */
    }
  3. You will need convert from the ImageMagick project to do the image processing. You can install it using a command along the lines of:

    # debian/ubuntu
    sudo apt-get install imagemagick
    
    # osx
    sudo port install imagemagick
    sudo brew install imagemagick
    
    # required on osx otherwise imagemagick (silently) goes into an infinite loop complaining about missing fonts
    sudo brew install ghostscript

The plugin will hook into your build process automatically and overwrite the target app icon files for debug builds. It will not mess with any files in your repository.

Customization

The plugin offers some options for customizing the appearance of the generated icon. Simply add a block to your app module's build.gradle:

appiconoverlay {
    textColor '#FFF'                  /* #rrggbbaa format */
    backgroundColor "#0008"           /* #rrggbbaa format */
    format '$build->$branch\n$commit' /* GString */
    imageMagick 'convert'             /* command to run ImageMagick */
}
Option Description
textColor Text color in #rrggbbaa format.
backgroundColor Background color for overlay in #rrggbbaa format.
format Format string to be used to create the text in the overlay.
Note: Use single quotes, it's a GString.
The following variables are available:
  • $branch name of git branch
  • $commit short SHA1 of latest commit in current branch
  • $build the name of the build variant ex. Debug
imageMagick Command to run ImageMagick's "convert".

Building locally

If you want to make changes to the plugin, here's how you can build it locally and test it with an Android app:

  1. Check out the project using git.
  2. In the root directory, run gradle jar.
  3. Find the generated .jar file in ./build/libs/.
  4. To reference your local .jar file in your Android project, declare the dependency as follows in the project's top-level build.gradle file:
    buildscript {
        dependencies {
            classpath files('/path/to/gradle-android-appiconoverlay/build/libs/gradle-android-appiconoverlay-1.3.jar')
        }
    }

Credits

Idea based on the IconOverlaying project by Krzysztof Zabłocki, which implements a similar feature for iOS builds.

gradle-android-appiconoverlay's People

Contributors

splatte avatar rocket0423 avatar molexx avatar

Watchers

Lukasz Cisek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.