diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5db12d6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.gradle +local.properties +.idea +.DS_Store +build/ +reports/ +gradle.properties +*.iml \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d19429a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Changelog for easylauncher plugin + +## v0.5.0 2018/01/12 + +* Simplify DSL +* Add support for adaptive launcher icons +* Add support for variant-specific configuration +* Add ribbon to debuggable type by default + +## v0.4.0 2018/01/06 + +* Add capability to disable plugin +* Give priority to flavor over buildType + +## v0.3.0 2018/01/06 + +* Initial internal release \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..675ea46 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +check: + ./gradlew clean check bintrayUpload + +publish: check + ./gradlew releng + ./gradlew -PdryRun=false --info plugin:bintrayUpload + +update-examples: + ./gradlew easylauncher + cp ./example-simple/build/generated/easylauncher/res/debug/mipmap-xxhdpi/ic_launcher.png ic-debug.png + cp ./example-custom/build/generated/easylauncher/res/localBeta/mipmap-xxhdpi/ic_launcher.png ic-beta.png diff --git a/README.md b/README.md new file mode 100644 index 0000000..b05419a --- /dev/null +++ b/README.md @@ -0,0 +1,134 @@ +# Easylauncher gradle plugin for Android + +This gradle plugin will add a different ribbon to each of your (debuggable) Android app variants. You can of course configure it as you will. + +![](icons/ic_launcher_debug.png) ![](ic_launcher_beta.png) +// TODO more icons + +## Usage + +```groovy +// in build.gradle +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.akaita.android:easylauncher:0.5.0' + } +} +``` + +```groovy +// in app/build.gradle +apply plugin: 'com.akaita.android.easylauncher' + +android { + buildTypes { + debug { + //Debuggable, will get a default ribbon in the launcher icon + } + beta { + //Debuggable, will get a default ribbon in the launcher icon + debuggable true + } + canary { + //Non-debuggable, will not get any default ribbon + debuggable false + } + release { + //Non-debuggable, will not get any default ribbon + } + } + productFlavors { + local {} + qa {} + staging {} + production {} + } +} +``` + + +Optionally, customize the plugin's behaviour +```groovy +easylauncher { + // "manifest application[android:icon]" is automatically added to the list + iconNames "@mipmap/ic_launcher_foreground" // Traditional launcher icon + foregroundIconNames "@mipmap/ic_launcher_foreground" // Foreground of adaptive launcher icon + + productFlavors { + local {} + qa { + // Add one more filter to all `qa` variants + filters = redRibbonFilter() + } + staging {} + production {} + } + + buildTypes { + beta { + // Add two more filters to all `beta` variants + filters = [ + customColorRibbonFilter("#0000FF"), + overlayFilter(new File("example-custom/launcherOverlay/beta.png")) + ] + } + canary { + // Remove ALL filters to `canary` variants + enable false + } + release {} + } + + variants { + productionDebug { + // OVERRIDE all previous filters defined for `productionDebug` variant + filters = orangeRibbonFilter() + } + } +} +``` + + +## Available filters + +| Filter | Result | +| - | - | +| `grayRibbonFilter()` | ![](icons/grayRibbon.png) | +| `greenRibbonFilter()` | ![](icons/greenRibbon.png) | +| `yellowRibbonFilter()` | ![](icons/yellowRibbon.png) | +| `orangeRibbonFilter()` | ![](icons/orangeRibbon.png) | +| `redRibbonFilter()` | ![](icons/redRibbon.png) | +| `blueRibbonFilter()` | ![](icons/blueRibbon.png) | +| `grayscaleFilter()` | ![](icons/grayscale.png) | +| `customColorRibbonFilter("#6600CC")` | ![](icons/customColorRibbon.png) | +| `overlayFilter(new File("example-custom/launcherOverlay/beta.png"))` | ![](icons/overlay.png) | + + + +## Project Structure + +``` +plugin/ - Gradle plugin +example-simple/ - Example Android application using easylauncher with the default behaviour +example-custom/ - Example Android application using easylauncher with the custom configuration +buildSrc/ - Helper module to use this plugin in example modules +icons/ - Examples of icons generated by this plugin +``` + + +## Contributing + +You can already see my plans for the plugin in the project's Issues section. + +Still, I'm open to feature-requests and suggestions. +Of course, a PR is the best way to get something you want into the plugin ;) + + +## Credits + +Easylauncher started as an extension of [Fuji Goro's `ribbonizer` plugin](https://github.com/maskarade/gradle-android-ribbonizer-plugin). +As it evolved, I decided it changed enough to be worth releasing as a separate plugin. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..8d911b0 --- /dev/null +++ b/build.gradle @@ -0,0 +1,26 @@ +apply from: './versioning.gradle' +apply from: './metadata.gradle' + +ext { + metadata.version = versionName +} + +buildscript { + repositories { + jcenter() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.novoda:bintray-release:0.8.0' // https://github.com/novoda/bintray-release + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.21" + classpath "org.jetbrains.kotlin:kotlin-android-extensions:1.2.21" + } +} + +allprojects { + repositories { + jcenter() + google() + } +} diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..9b9e9c2 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,9 @@ +System.setProperty("java.awt.headless", "true") + +repositories { + jcenter() +} + +dependencies { + compile project(':plugin') +} diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle new file mode 100644 index 0000000..adade62 --- /dev/null +++ b/buildSrc/settings.gradle @@ -0,0 +1,2 @@ +include ':plugin' +project(':plugin').projectDir = new File('../plugin') diff --git a/example-custom/build.gradle b/example-custom/build.gradle new file mode 100644 index 0000000..f1284de --- /dev/null +++ b/example-custom/build.gradle @@ -0,0 +1,87 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +apply plugin: 'com.akaita.android.easylauncher' + +android { + compileSdkVersion 27 + buildToolsVersion '27.0.3' + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 27 + versionCode 1 + versionName "1.0" + } + + lintOptions { + abortOnError false + } + + buildTypes { + debug { + //Debuggable, will get a default ribbon in the launcher icon + } + beta { + //Debuggable, will get a default ribbon in the launcher icon + debuggable true + } + canary { + //Non-debuggable, will not get any default ribbon + debuggable false + } + release { + //Non-debuggable, will not get any default ribbon + } + } + + productFlavors { + local {} + qa {} + staging {} + production {} + } +} + +easylauncher { + iconNames "@mipmap/ic_launcher_foreground" // Traditional launcher icon + foregroundIconNames "@mipmap/ic_launcher_foreground" // Foreground of adaptive launcher icon + + productFlavors { + local {} + qa { + // Add one more filter to all `qa` variants + filters = redRibbonFilter() + } + staging {} + production {} + } + + buildTypes { + beta { + // Add two more filters to all `beta` variants + filters = [ + customColorRibbonFilter("#0000FF"), + overlayFilter(new File("example-custom/launcherOverlay/beta.png")) + ] + } + canary { + // Remove ALL filters to `canary` variants + enable false + } + release {} + } + + variants { + productionDebug { + // OVERRIDE all previous filters defined for `productionDebug` variant + filters = orangeRibbonFilter() + } + } +} + +dependencies { + compile 'com.android.support:appcompat-v7:27.0.2' + compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.21" +} diff --git a/example-custom/launcherOverlay/beta.png b/example-custom/launcherOverlay/beta.png new file mode 100644 index 0000000..9b7a525 Binary files /dev/null and b/example-custom/launcherOverlay/beta.png differ diff --git a/example-custom/src/main/AndroidManifest.xml b/example-custom/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7ab97cd --- /dev/null +++ b/example-custom/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/example-custom/src/main/ic_launcher-web.png b/example-custom/src/main/ic_launcher-web.png new file mode 100644 index 0000000..ab63c32 Binary files /dev/null and b/example-custom/src/main/ic_launcher-web.png differ diff --git a/example-custom/src/main/java/com/akaita/android/easylauncher/example/MainActivity.kt b/example-custom/src/main/java/com/akaita/android/easylauncher/example/MainActivity.kt new file mode 100644 index 0000000..d04a2ae --- /dev/null +++ b/example-custom/src/main/java/com/akaita/android/easylauncher/example/MainActivity.kt @@ -0,0 +1,22 @@ +package com.akaita.android.easylauncher.example + +import android.app.Activity +import android.app.AlertDialog +import android.os.Bundle +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : Activity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + button.setOnClickListener { + AlertDialog.Builder(this) + .setTitle("Hello, Android!") + .setMessage("This is an example app.") + .setPositiveButton("OK", null) + .show() + } + } +} diff --git a/example-custom/src/main/res/layout/activity_main.xml b/example-custom/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..daed97d --- /dev/null +++ b/example-custom/src/main/res/layout/activity_main.xml @@ -0,0 +1,28 @@ + + + + +