Repository: gfx/gradle-android-ribbonizer-plugin
Branch: master
Commit: fab8dae9a298
Files: 54
Total size: 55.3 KB
Directory structure:
gitextract_x6z246hr/
├── .gitignore
├── CHANGES.md
├── LICENSE
├── Makefile
├── README.md
├── VERSION
├── build.gradle
├── buildSrc/
│ ├── build.gradle
│ └── settings.gradle
├── circle.yml
├── example-custom/
│ ├── build.gradle
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── github/
│ │ └── gfx/
│ │ └── ribbonizer/
│ │ └── example/
│ │ └── MainActivity.java
│ └── res/
│ ├── layout/
│ │ └── activity_main.xml
│ ├── mipmap-anydpi-v26/
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ ├── values/
│ │ ├── dimens.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── values-v26/
│ │ └── colors.xml
│ └── values-w820dp/
│ └── dimens.xml
├── example-simple/
│ ├── build.gradle
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── github/
│ │ └── gfx/
│ │ └── ribbonizer/
│ │ └── example/
│ │ └── MainActivity.java
│ └── res/
│ ├── layout/
│ │ └── activity_main.xml
│ ├── values/
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── values-w820dp/
│ └── dimens.xml
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties.sample
├── gradlew
├── gradlew.bat
├── metadata.gradle
├── plugin/
│ ├── build.gradle
│ └── src/
│ ├── main/
│ │ ├── groovy/
│ │ │ └── com/
│ │ │ └── github/
│ │ │ └── gfx/
│ │ │ └── ribbonizer/
│ │ │ ├── CustomColorRibbonBuilder.java
│ │ │ ├── FilterBuilder.java
│ │ │ ├── GrayRibbonBuilder.java
│ │ │ ├── GrayScaleBuilder.java
│ │ │ ├── GreenRibbonBuilder.java
│ │ │ ├── YellowRibbonBuilder.java
│ │ │ ├── filter/
│ │ │ │ ├── ColorRibbonFilter.java
│ │ │ │ └── GrayScaleFilter.java
│ │ │ └── plugin/
│ │ │ ├── Resources.java
│ │ │ ├── Ribbonizer.java
│ │ │ ├── RibbonizerExtension.java
│ │ │ ├── RibbonizerPlugin.groovy
│ │ │ └── RibbonizerTask.groovy
│ │ └── resources/
│ │ └── META-INF/
│ │ └── gradle-plugins/
│ │ └── com.github.gfx.ribbonizer.properties
│ └── test/
│ └── groovy/
│ └── com/
│ └── github/
│ └── gfx/
│ └── ribbonizer/
│ └── test/
│ └── ResourcesTest.groovy
├── settings.gradle
└── versioning.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.gradle
local.properties
.idea
.DS_Store
build/
reports/
gradle.properties
*.iml
================================================
FILE: CHANGES.md
================================================
# The revision history of android-ribbonizer-plugin
## v2.1.0 2017/08/19
* Allow null values for filters and ribbon labels
* Added `largeRibbon` option to increase visibility in launcher icon foreground assets
## v2.0.0 2017/07/21
No code change from v1.1.0; the reason of bumping the version is that v1.1.0 has breaking changes in the artifact id (`s/plugin/ribbonizer-plugin/`).
## v1.1.0 2017/07/21
https://github.com/gfx/gradle-android-ribbonizer-plugin/compare/v1.0.0...v1.1.0
* Change the artifact id from `plugin` to `ribbonizer-plugin`
* [#16](https://github.com/gfx/gradle-android-ribbonizer-plugin/pull/16) Support for android:roundIcon launcher images
* [#19](https://github.com/gfx/gradle-android-ribbonizer-plugin/pull/19) Exclude XML resources
## v1.0.0 2016/11/16
* Add `customColorRibbonFilter(variant, iconFile, color)` (#13)
## v0.6.0 - 2016-06-16
* Add `forcedVariantsNames` (#11)
## v0.5.0 - 2015-11-19
* Build with Android Gradle plugin v1.5.0
## v0.4.0 - 2015-06-05
* [Add RibbonizerExtension#grayScaleFilter by kazy1991 · Pull Request #4 · gfx/gradle-android-ribbonizer-plugin](https://github.com/gfx/gradle-android-ribbonizer-plugin/pull/4)
* Add ways to add icon names (see `example-custom/build.gradle` for example)
## v0.3.0 - 2015-04-15
* Fix "AndroidManifest.xml not found" errors
## v0.2.0 - 2015-04-12
* Add `example-custom` to show how to use the `ribbonizer` extension block
## v0.1.1 - 2015-04-03
* Fix a crash caused by an Android Studio issue
## v0.1.0 - 2015-03-29
* Initial Release
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015 FUJI Goro (gfx) <gfuji@cpan.org>.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: Makefile
================================================
check:
./gradlew clean check bintrayUpload
publish: check
./gradlew releng
./gradlew -PdryRun=false --info plugin:bintrayUpload
update-examples:
./gradlew ribbonize
cp ./example-simple/build/generated/ribbonizer/res/debug/mipmap-xxhdpi/ic_launcher.png ic-debug.png
cp ./example-custom/build/generated/ribbonizer/res/localBeta/mipmap-xxhdpi/ic_launcher.png ic-beta.png
================================================
FILE: README.md
================================================
# DEPRECATED
No longer actively maintained, I recommend [Mikel's easylauncher-gradle-plugin](https://github.com/akaita/easylauncher-gradle-plugin) which might not have seen much love lately either, but seems to still work since the JFrog shutdown.
# Ribbonizer plugin for Android
[](https://circleci.com/gh/gfx/gradle-android-ribbonizer-plugin) [](https://bintray.com/gfx/maven/ribbonizer-plugin/_latestVersion)
This is a ribbonizer as a Gradle plugin for Android, which adds a ribbon to launcher icons.
 
## Usage
```groovy
// in build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.github.gfx.ribbonizer:ribbonizer-plugin:2.1.0'
}
}
```
```groovy
// in app/build.gradle
apply plugin: 'com.github.gfx.ribbonizer'
android {
// ...
buildTypes {
debug {/*debuggable build, which will ribbonized automatically*/}
beta {
//debuggable build which will automatically ribbonized.
debuggable true
}
canary {
//non-debuggable build which will no automatically ribbonized.
//But, we force one of its flavors. See `ribbonizer` for how-to
debuggable false
}
release {/*non-debuggable build. Will not be rebbonized automatically*/}
}
productFlavors {
local {}
qa {}
staging {}
production {}
}
}
ribbonizer {
// "manifest application[android:icon]" is automatically added to the list
iconNames "@drawable/ic_notification", "@drawable/widget_preview"
builder { variant, iconFile ->
// change ribbon colors by product flavors
if (variant.flavorName == "local") {
return grayRibbonFilter(variant, iconFile)
} else if (variant.flavorName == "qa") {
// customColorRibbonFilter allows setting any color code
def filter = customColorRibbonFilter(variant, iconFile, "#00C89C")
// Finer control of the label text can be achieved by setting it manually, or set to
// null for an unlabelled ribbon. The default is to use the flavor name.
filter.label = "QA" + variant.versionCode
return filter
} else if (variant.flavorName == "staging") {
return yellowRibbonFilter(variant, iconFile)
} else if (variant.buildType.name == "debug") {
if (variant.flavorName == "production") {
// Particular configurations can be skipped by returning no filters
return null
}
else {
// Other filters can be applied, as long as they implement Consumer<BufferedImage>
return grayScaleFilter(variant, iconFile)
}
} else {
return greenRibbonFilter(variant, iconFile)
}
}
//Although `canary` build-type is marked as `non-debuggable`
//we can still force specific variants to be ribbonized:
forcedVariantsNames "localCanary"
}
```
## Project Structure
```
plugin/ - The main module of a Gradle plugin
example/ - An example android application that uses this plugin
buildSrc/ - A helper module to use this plugin in example modules
```
You can test this project with `./gradlew check`.
## Release Engineering
```console
./gradlew bumpMinor # or bumpMajor, bumpPatch
make publish # upload artifacts to bintray jcenter
```
## Author And License
The MIT License (MIT)
Copyright (c) 2015 FUJI Goro (gfx) <gfuji@cpan.org>.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: VERSION
================================================
2.1.0
================================================
FILE: build.gradle
================================================
apply from: './versioning.gradle'
apply from: './metadata.gradle'
ext {
metadata.version = versionName
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.novoda:bintray-release:0.5.0' // https://github.com/novoda/bintray-release
}
}
allprojects {
repositories {
jcenter()
}
}
================================================
FILE: buildSrc/build.gradle
================================================
System.setProperty("java.awt.headless", "true")
repositories {
jcenter()
}
dependencies {
compile project(':plugin')
}
================================================
FILE: buildSrc/settings.gradle
================================================
include ':plugin'
project(':plugin').projectDir = new File('../plugin')
================================================
FILE: circle.yml
================================================
machine:
java:
version: oraclejdk8
environment:
TERM: dumb
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError" -Dorg.gradle.daemon=false'
dependencies:
pre:
- echo y | android -s update sdk -u -a -t "tools" # update Android SDK that includes sdkmanager(1)
- mkdir -p "$ANDROID_HOME"/licenses
- echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME"/licenses/android-sdk-license
- $ANDROID_HOME/tools/bin/sdkmanager "platform-tools" "extras;android;m2repository"
test:
override:
- TERM=dumb ./gradlew check
- TERM=dumb ./gradlew ribbonize
================================================
FILE: example-custom/build.gradle
================================================
import com.android.build.gradle.api.ApplicationVariant
apply plugin: 'com.android.application'
apply plugin: 'com.github.gfx.ribbonizer'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
buildTypes {
debug {}
beta {
debuggable true
}
canary {
debuggable false
}
release {}
}
productFlavors {
local {}
qa {}
staging {}
production {}
}
}
ribbonizer {
iconNames "@drawable/abc_btn_check_to_on_mtrl_000", "@drawable/abc_btn_radio_to_on_mtrl_000", "@mipmap/ic_launcher_foreground"
builder { ApplicationVariant variant, File iconFile ->
if (variant.flavorName == "local") {
return grayRibbonFilter(variant, iconFile)
} else if (variant.flavorName == "qa") {
def filter = customColorRibbonFilter(variant, iconFile, "#00C89C")
filter.label = null//"QA" + variant.versionCode
filter.largeRibbon = (iconFile.name == "ic_launcher_foreground.png")
return filter
} else if (variant.buildType.name == "debug") {
if (variant.flavorName == "production") {
return null
}
return customColorRibbonFilter(variant, iconFile, "#0000FF")
} else {
return greenRibbonFilter(variant, iconFile)
}
}
forcedVariantsNames "localCanary"
}
dependencies {
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.android.support:appcompat-v7:25.0.0'
}
================================================
FILE: example-custom/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.gfx.ribbonizer.example">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.github.gfx.ribbonizer.example.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: example-custom/src/main/java/com/github/gfx/ribbonizer/example/MainActivity.java
================================================
package com.github.gfx.ribbonizer.example;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
public class MainActivity extends Activity {
@InjectView(R.id.text)
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
}
@OnClick(R.id.button)
void onButtonClick() {
new AlertDialog.Builder(this)
.setTitle("Hello, Android!")
.setMessage("This is an example app.")
.setPositiveButton("OK", null)
.show();
}
}
================================================
FILE: example-custom/src/main/res/layout/activity_main.xml
================================================
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.github.gfx.ribbonizer.example.MainActivity">
<TextView
android:id="@+id/text"
android:layout_gravity="center_horizontal"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:layout_margin="22dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button"
android:id="@+id/button"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
================================================
FILE: example-custom/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
================================================
FILE: example-custom/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
================================================
FILE: example-custom/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: example-custom/src/main/res/values/ic_launcher_background.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#00C89C</color>
</resources>
================================================
FILE: example-custom/src/main/res/values/strings.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">App Icon Demo</string>
<string name="hello_world">Hello, world!</string>
<string name="action_settings">Settings</string>
<string name="button">button</string>
</resources>
================================================
FILE: example-custom/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light">
<!-- Customize your theme here. -->
</style>
</resources>
================================================
FILE: example-custom/src/main/res/values-v26/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#1c7917</color>
</resources>
================================================
FILE: example-custom/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: example-simple/build.gradle
================================================
apply plugin: 'com.android.application'
apply plugin: 'com.github.gfx.ribbonizer'
android {
compileSdkVersion 25
buildToolsVersion '25'
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.jakewharton:butterknife:6.1.0'
}
================================================
FILE: example-simple/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.gfx.ribbonizer.example">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.github.gfx.ribbonizer.example.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: example-simple/src/main/java/com/github/gfx/ribbonizer/example/MainActivity.java
================================================
package com.github.gfx.ribbonizer.example;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
public class MainActivity extends Activity {
@InjectView(R.id.text)
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
}
@OnClick(R.id.button)
void onButtonClick() {
new AlertDialog.Builder(this)
.setTitle("Hello, Android!")
.setMessage("This is an example app.")
.setPositiveButton("OK", null)
.show();
}
}
================================================
FILE: example-simple/src/main/res/layout/activity_main.xml
================================================
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.github.gfx.ribbonizer.example.MainActivity">
<TextView
android:id="@+id/text"
android:layout_gravity="center_horizontal"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:layout_margin="22dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button"
android:id="@+id/button"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
================================================
FILE: example-simple/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: example-simple/src/main/res/values/strings.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">App Icon Demo</string>
<string name="hello_world">Hello, world!</string>
<string name="action_settings">Settings</string>
<string name="button">button</string>
</resources>
================================================
FILE: example-simple/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light">
<!-- Customize your theme here. -->
</style>
</resources>
================================================
FILE: example-simple/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Thu Dec 11 08:17:04 JST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
================================================
FILE: gradle.properties.sample
================================================
# configuration for bintray and signing
bintrayUser=YOUR_USERNAME
bintrayKey=YOUR_KEY
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: metadata.gradle
================================================
ext {
metadata = [
userOrg : 'ribbonizer',
groupId : 'com.github.gfx.ribbonizer',
website : 'https://github.com/maskarade/gradle-android-ribbonizer-plugin',
repository: 'https://github.com/maskarade/gradle-android-ribbonizer-plugin.git',
licences : ['Apache-2.0']
]
}
================================================
FILE: plugin/build.gradle
================================================
repositories {
jcenter()
}
apply plugin: 'groovy'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:2.3.3'
testCompile('org.spockframework:spock-core:1.0-groovy-2.4') {
exclude group:'org.codehaus.groovy'
}
}
if (rootProject.hasProperty('versionName') && rootProject.hasProperty('bintrayUser')) {
jar {
manifest {
attributes(
"Implementation-Version": project.file("../VERSION").text.trim(),
)
}
}
apply plugin: 'com.novoda.bintray-release'
publish {
artifactId = 'ribbonizer-plugin'
desc = 'Gradle plugin to modifiy Android launcher icons'
def metadata = rootProject.ext.metadata
userOrg = metadata.userOrg
groupId = metadata.groupId
publishVersion = metadata.version
website = metadata.website
repository = metadata.repository
licences = metadata.licences
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/CustomColorRibbonBuilder.java
================================================
package com.github.gfx.ribbonizer;
import com.android.build.gradle.api.ApplicationVariant;
import com.github.gfx.ribbonizer.filter.ColorRibbonFilter;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.function.Consumer;
public class CustomColorRibbonBuilder implements FilterBuilder {
private String nm;
public CustomColorRibbonBuilder(String nm) {
this.nm = nm;
}
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
return new ColorRibbonFilter(variant.getBuildType().getName(), Color.decode(nm));
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/FilterBuilder.java
================================================
package com.github.gfx.ribbonizer;
import com.android.build.gradle.api.ApplicationVariant;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.function.BiFunction;
import java.util.function.Consumer;
public interface FilterBuilder extends BiFunction<ApplicationVariant, File, Consumer<BufferedImage>> {
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/GrayRibbonBuilder.java
================================================
package com.github.gfx.ribbonizer;
import com.android.build.gradle.api.ApplicationVariant;
import com.github.gfx.ribbonizer.filter.ColorRibbonFilter;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.function.Consumer;
public class GrayRibbonBuilder implements FilterBuilder {
public static final Color COLOR = new Color(0x60, 0x60, 0x60, 0x99);
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/GrayScaleBuilder.java
================================================
package com.github.gfx.ribbonizer;
import com.android.build.gradle.api.ApplicationVariant;
import com.github.gfx.ribbonizer.filter.GrayScaleFilter;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.function.Consumer;
public class GrayScaleBuilder implements FilterBuilder {
@Override
public Consumer<BufferedImage> apply(ApplicationVariant applicationVariant, File iconFile) {
return new GrayScaleFilter();
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/GreenRibbonBuilder.java
================================================
package com.github.gfx.ribbonizer;
import com.android.build.gradle.api.ApplicationVariant;
import com.github.gfx.ribbonizer.filter.ColorRibbonFilter;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.function.Consumer;
public class GreenRibbonBuilder implements FilterBuilder {
public static Color COLOR = new Color(0, 0x72, 0, 0x99);
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/YellowRibbonBuilder.java
================================================
package com.github.gfx.ribbonizer;
import com.android.build.gradle.api.ApplicationVariant;
import com.github.gfx.ribbonizer.filter.ColorRibbonFilter;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.function.Consumer;
public class YellowRibbonBuilder implements FilterBuilder {
public static final Color COLOR = new Color(0xff, 0x76, 0, 0x99);
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/filter/ColorRibbonFilter.java
================================================
package com.github.gfx.ribbonizer.filter;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.function.Consumer;
public class ColorRibbonFilter implements Consumer<BufferedImage> {
static final boolean debug = Boolean.parseBoolean(System.getenv("RIBBONIZER_DEBUG"));
final Color ribbonColor;
final Color labelColor;
String label;
String fontName = "Default";
int fontStyle = Font.PLAIN;
boolean largeRibbon = false;
public ColorRibbonFilter(String label, Color ribbonColor, Color labelColor) {
this.label = label;
this.ribbonColor = ribbonColor;
this.labelColor = labelColor;
}
public ColorRibbonFilter(String label, Color ribbonColor) {
this(label, ribbonColor, Color.WHITE);
}
static int calculateMaxLabelWidth(int y) {
return (int) Math.sqrt(Math.pow(y, 2) * 2);
}
static void drawString(Graphics2D g, String str, int x, int y) {
g.drawString(str, x, y);
if (debug) {
FontMetrics fm = g.getFontMetrics();
Rectangle2D bounds = g.getFont().getStringBounds(str,
new FontRenderContext(g.getTransform(), true, true));
g.drawRect(x, y - fm.getAscent(), (int) bounds.getWidth(), fm.getAscent());
}
}
@Override
public void accept(BufferedImage image) {
int width = image.getWidth();
int height = image.getHeight();
Graphics2D g = (Graphics2D) image.getGraphics();
g.setTransform(AffineTransform.getRotateInstance(Math.toRadians(-45)));
int y = height / (largeRibbon ? 2 : 4);
// calculate the rectangle where the label is rendered
FontRenderContext frc = new FontRenderContext(g.getTransform(), true, true);
int maxLabelWidth = calculateMaxLabelWidth(y);
g.setFont(getFont(maxLabelWidth, frc));
Rectangle2D labelBounds = g.getFont().getStringBounds(label == null ? "" : label, frc);
// draw the ribbon
g.setColor(ribbonColor);
g.fillRect(-width, y, width * 2, (int) (labelBounds.getHeight()));
if (label != null) {
// draw the label
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(labelColor);
FontMetrics fm = g.getFontMetrics();
drawString(g, label,
(int) -labelBounds.getWidth() / 2,
y + fm.getAscent());
}
g.dispose();
}
Font getFont(int maxLabelWidth, FontRenderContext frc) {
int max = 32;
if (label == null) {
return new Font(fontName, fontStyle, max / 2);
}
int min = 0;
int x = max;
for (int i = 0; i < 10; i++) {
int m = ((max + min) / 2);
if (m == x) {
break;
}
Font font = new Font(fontName, fontStyle, m);
Rectangle2D labelBounds = font.getStringBounds(label, frc);
int px = (int) labelBounds.getWidth();
if (px > maxLabelWidth) {
max = m;
} else {
min = m;
}
x = m;
}
return new Font(fontName, fontStyle, x);
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/filter/GrayScaleFilter.java
================================================
package com.github.gfx.ribbonizer.filter;
import java.awt.image.BufferedImage;
import java.util.function.Consumer;
public class GrayScaleFilter implements Consumer<BufferedImage> {
static int toGray(int color) {
int a = (color & 0xFF000000);
int r = (color & 0x00FF0000) >> 16;
int g = (color & 0x0000FF00) >> 8;
int b = (color & 0x000000FF);
int c = (int) ((2.0 * r + 4.0 * g + b) / 7.0);
return a | (c << 16) | (c << 8) | c;
}
@Override
public void accept(BufferedImage image) {
int width = image.getWidth();
int height = image.getHeight();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int color = image.getRGB(x, y);
image.setRGB(x, y, toGray(color));
}
}
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/Resources.java
================================================
package com.github.gfx.ribbonizer.plugin;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import groovy.util.XmlSlurper;
import groovy.util.slurpersupport.GPathResult;
import static java.util.Collections.unmodifiableList;
public class Resources {
public static String resourceFilePattern(String name) {
if (name.startsWith("@")) {
String[] pair = name.substring(1).split("/", 2);
String baseResType = pair[0];
String fileName = pair[1];
if (fileName == null) {
throw new IllegalArgumentException(
"Icon names does include resource types (e.g. drawable/ic_launcher): "
+ name);
}
return baseResType + "*/" + fileName + ".*";
} else {
return name;
}
}
public static List<String> getLauncherIcons(File manifestFile)
throws SAXException, ParserConfigurationException, IOException {
GPathResult manifestXml = new XmlSlurper().parse(manifestFile);
GPathResult applicationNode = (GPathResult) manifestXml.getProperty("application");
String icon = String.valueOf(applicationNode.getProperty("@android:icon"));
String roundIcon = String.valueOf(applicationNode.getProperty("@android:roundIcon"));
List<String> icons = new ArrayList<>(2);
if (!icon.isEmpty()) {
icons.add(icon);
}
if (!roundIcon.isEmpty()) {
icons.add(roundIcon);
}
return unmodifiableList(icons);
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/Ribbonizer.java
================================================
package com.github.gfx.ribbonizer.plugin;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.function.Consumer;
import java.util.stream.Stream;
import javax.imageio.ImageIO;
public class Ribbonizer {
final File inputFile;
final File outputFile;
final BufferedImage image;
public Ribbonizer(File inputFile, File outputFile) throws IOException {
this.inputFile = inputFile;
this.outputFile = outputFile;
image = ImageIO.read(inputFile);
}
public void save() throws IOException {
outputFile.getParentFile().mkdirs();
ImageIO.write(image, "png", outputFile);
}
public void process(Stream<Consumer<BufferedImage>> filters) {
filters.forEach(new Consumer<Consumer<BufferedImage>>() {
@Override
public void accept(Consumer<BufferedImage> filter) {
if (filter != null) {
filter.accept(image);
}
}
});
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/RibbonizerExtension.java
================================================
package com.github.gfx.ribbonizer.plugin;
import com.android.build.gradle.api.ApplicationVariant;
import com.github.gfx.ribbonizer.CustomColorRibbonBuilder;
import com.github.gfx.ribbonizer.FilterBuilder;
import com.github.gfx.ribbonizer.GrayScaleBuilder;
import com.github.gfx.ribbonizer.GrayRibbonBuilder;
import com.github.gfx.ribbonizer.GreenRibbonBuilder;
import com.github.gfx.ribbonizer.YellowRibbonBuilder;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
class RibbonizerExtension {
public static String NAME = "ribbonizer";
Set<String> forcedVariantsNames = new HashSet<>();
Set<String> iconNames = new HashSet<>();
List<FilterBuilder> filterBuilders = new ArrayList<>();
public RibbonizerExtension() {
}
public Set<String> getIconNames() {
return iconNames;
}
/**
* @param resNames Names of icons. For example "@drawable/ic_launcher", "@mipmap/icon"
*/
public void setIconNames(Collection<String> resNames) {
iconNames = new HashSet<>(resNames);
}
/**
* @param resNames Names of icons. For example "@drawable/ic_launcher", "@mipmap/icon"
*/
public void iconNames(Collection<String> resNames) {
setIconNames(resNames);
}
/**
* @param resNames Names of icons. For example "@drawable/ic_launcher", "@mipmap/icon"
*/
public void iconNames(String... resNames) {
setIconNames(Arrays.asList(resNames));
}
/**
* @param resName A name of icons. For example "@drawable/ic_launcher", "@mipmap/icon"
*/
public void iconName(String resName) {
iconNames.add(resName);
}
public Set<String> getForcedVariantsNames() {
return forcedVariantsNames;
}
public void forcedVariantsNames(String... variantsNames) {
forcedVariantsNames = new HashSet<>(Arrays.asList(variantsNames));
}
public List<FilterBuilder> getFilterBuilders() {
return filterBuilders;
}
public void setFilterBuilders(Collection<FilterBuilder> filterBuilders) {
this.filterBuilders = new ArrayList<>(filterBuilders);
}
public void builder(FilterBuilder filterBuilder)
throws IllegalAccessException, InstantiationException {
this.filterBuilders.clear();
this.filterBuilders.add(filterBuilder);
}
// utilities
public Consumer<BufferedImage> grayScaleFilter(ApplicationVariant variant, File iconFile) {
return new GrayScaleBuilder().apply(variant, iconFile);
}
public Consumer<BufferedImage> grayRibbonFilter(ApplicationVariant variant, File iconFile) {
return new GrayRibbonBuilder().apply(variant, iconFile);
}
public Consumer<BufferedImage> yellowRibbonFilter(ApplicationVariant variant, File iconFile) {
return new YellowRibbonBuilder().apply(variant, iconFile);
}
public Consumer<BufferedImage> greenRibbonFilter(ApplicationVariant variant, File iconFile) {
return new GreenRibbonBuilder().apply(variant, iconFile);
}
public Consumer<BufferedImage> customColorRibbonFilter(ApplicationVariant variant, File iconFile, String nm) {
return new CustomColorRibbonBuilder(nm).apply(variant, iconFile);
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/RibbonizerPlugin.groovy
================================================
package com.github.gfx.ribbonizer.plugin
import com.android.build.gradle.AppExtension
import com.android.build.gradle.api.ApplicationVariant
import com.github.gfx.ribbonizer.FilterBuilder
import com.github.gfx.ribbonizer.GreenRibbonBuilder
import groovy.transform.CompileStatic
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
// see http://www.gradle.org/docs/current/userguide/custom_plugins.html
@CompileStatic
public class RibbonizerPlugin implements Plugin<Project> {
static {
System.setProperty("java.awt.headless", "true")
// workaround for an Android Studio issue
try {
Class.forName(System.getProperty("java.awt.graphicsenv"))
} catch (ClassNotFoundException e) {
System.err.println("[WARN] java.awt.graphicsenv: " + e)
System.setProperty("java.awt.graphicsenv", "sun.awt.CGraphicsEnvironment")
}
try {
Class.forName(System.getProperty("awt.toolkit"))
} catch (ClassNotFoundException e) {
System.err.println("[WARN] awt.toolkit: " + e)
System.setProperty("awt.toolkit", "sun.lwawt.macosx.LWCToolkit")
}
}
@Override
void apply(Project project) {
project.extensions.add(RibbonizerExtension.NAME, RibbonizerExtension)
project.afterEvaluate {
def android = project.extensions.findByType(AppExtension)
if (!android) {
throw new Exception(
"Not an Android application; you forget `apply plugin: 'com.android.application`?")
}
def extension = project.extensions.findByType(RibbonizerExtension)
def tasks = new ArrayList<Task>();
android.applicationVariants.all { ApplicationVariant variant ->
if ((!variant.buildType.debuggable) && (!extension.forcedVariantsNames.contains(variant.name))) {
project.logger.info("[ribbonizer] skip ${variant.name} because it is not debuggable and not forced.")
return;
}
List<FilterBuilder> filterBuilders = extension.filterBuilders
if (filterBuilders.size() == 0) {
filterBuilders = [new GreenRibbonBuilder() as FilterBuilder]
}
def generatedResDir = getGeneratedResDir(project, variant)
android.sourceSets.findByName(variant.name).res.srcDir(generatedResDir)
def name = "${RibbonizerTask.NAME}${capitalize(variant.name)}"
def task = project.task(name, type: RibbonizerTask) as RibbonizerTask
task.variant = variant
task.outputDir = generatedResDir
task.iconNames = new HashSet<String>(extension.iconNames)
task.filterBuilders = filterBuilders
tasks.add(task)
def generateResources = project.
getTasksByName("generate${capitalize(variant.name)}Resources", false)
generateResources.forEach { Task t ->
t.dependsOn(task)
}
}
project.task(RibbonizerTask.NAME, dependsOn: tasks);
}
}
static String capitalize(String str) {
return str.substring(0, 1).toUpperCase() + str.substring(1);
}
static File getGeneratedResDir(Project project, ApplicationVariant variant) {
return new File(project.buildDir,
"generated/ribbonizer/res/${variant.name}")
}
}
================================================
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/RibbonizerTask.groovy
================================================
package com.github.gfx.ribbonizer.plugin
import com.android.build.gradle.AppExtension
import com.android.build.gradle.api.ApplicationVariant
import com.android.builder.model.SourceProvider
import com.github.gfx.ribbonizer.FilterBuilder
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import java.awt.image.BufferedImage
import java.util.function.Consumer
import java.util.function.Function
import java.util.stream.Stream
class RibbonizerTask extends DefaultTask {
static final String NAME = "ribbonize"
ApplicationVariant variant
//@OutputDirectory
File outputDir
// `iconNames` includes: "@drawable/icon", "@mipmap/ic_launcher", etc.
Set<String> iconNames
List<FilterBuilder> filterBuilders = []
@TaskAction
public void run() {
if (filterBuilders.size() == 0) {
return;
}
def t0 = System.currentTimeMillis()
def names = new HashSet<String>(iconNames)
names.addAll(launcherIconNames)
variant.sourceSets.stream()
.flatMap(new Function<SourceProvider, Stream>() {
@Override
Stream apply(SourceProvider sourceProvider) {
return sourceProvider.resDirectories.stream()
}
}).forEach { File resDir ->
if (resDir == outputDir) {
return
}
names.forEach { String name ->
project.fileTree(
dir: resDir,
include: Resources.resourceFilePattern(name),
exclude: "**/*.xml",
).forEach { File inputFile ->
info "process $inputFile"
def basename = inputFile.name
def resType = inputFile.parentFile.name
def outputFile = new File(outputDir, "${resType}/${basename}")
outputFile.parentFile.mkdirs()
def ribbonizer = new Ribbonizer(inputFile, outputFile)
ribbonizer.process(filterBuilders.stream()
.map(new Function<FilterBuilder, Consumer<BufferedImage>>() {
@Override
Consumer<BufferedImage> apply(FilterBuilder filterBuilder) {
return filterBuilder.apply(variant, inputFile)
}
}))
ribbonizer.save()
}
}
}
info("task finished in ${System.currentTimeMillis() - t0}ms")
}
void info(String message) {
//System.out.println("[$name] $message")
project.logger.info("[$name] $message")
}
Set<String> getLauncherIconNames() {
def names = new HashSet<String>()
androidManifestFiles.forEach { File manifestFile ->
names.addAll(Resources.getLauncherIcons(manifestFile))
}
return names
}
Stream<File> getAndroidManifestFiles() {
AppExtension android = project.extensions.findByType(AppExtension)
return ["main", variant.name, variant.buildType.name, variant.flavorName].stream()
.filter({ name -> !name.empty })
.distinct()
.map({ name -> project.file(android.sourceSets[name].manifest.srcFile) })
.filter({ manifestFile -> manifestFile.exists() })
}
}
================================================
FILE: plugin/src/main/resources/META-INF/gradle-plugins/com.github.gfx.ribbonizer.properties
================================================
implementation-class=com.github.gfx.ribbonizer.plugin.RibbonizerPlugin
================================================
FILE: plugin/src/test/groovy/com/github/gfx/ribbonizer/test/ResourcesTest.groovy
================================================
package com.github.gfx.ribbonizer.test
import com.github.gfx.ribbonizer.plugin.Resources
import spock.lang.Specification
public class ResourcesTest extends Specification {
def "resourceFilePattern"() {
expect:
Resources.resourceFilePattern(resName) == pattern
where:
resName | pattern
"@drawable/ic_launcher" | "drawable*/ic_launcher.*"
"@mipmap/icon" | "mipmap*/icon.*"
}
def "getLauncherIcon without android:roundIcon"() {
setup:
def file = File.createTempFile("AndroidManifest", ".xml")
file.deleteOnExit()
file.write('''
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.gfx.ribbonizer.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
</manifest>
'''.trim())
expect:
Resources.getLauncherIcons(file).containsAll(["@drawable/ic_launcher"])
}
def "getLauncherIcon without android:icon"() {
setup:
def file = File.createTempFile("AndroidManifest", ".xml")
file.deleteOnExit()
file.write('''
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.gfx.ribbonizer.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:roundIcon="@drawable/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
</manifest>
'''.trim())
expect:
Resources.getLauncherIcons(file).containsAll(["@drawable/ic_launcher_round"])
}
def "getLauncherIcon with both android:icon and android:roundIcon"() {
setup:
def file = File.createTempFile("AndroidManifest", ".xml")
file.deleteOnExit()
file.write('''
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.gfx.ribbonizer.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:roundIcon="@drawable/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
</manifest>
'''.trim())
expect:
Resources.getLauncherIcons(file).containsAll(["@drawable/ic_launcher", "@drawable/ic_launcher_round"])
}
}
================================================
FILE: settings.gradle
================================================
include ':plugin'
include ':example-simple'
include ':example-custom'
================================================
FILE: versioning.gradle
================================================
/*
* Copyright (c) 2015 FUJI Goro (gfx).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.regex.Pattern
static int parseVersionName(String versionName) {
final versionParts = versionName.split(/\D/)
final major = versionParts[0].toInteger()
final minor = versionParts[1].toInteger()
final patchLevel = versionParts[2].toInteger()
return major * (1000 * 1000) + minor * 1000 + patchLevel;
}
void updateReadme(String oldVersion, String newVersion) {
def template = rootProject.file('README.md').text
def result = template.replaceAll(Pattern.quote(oldVersion), newVersion)
rootProject.file("README.md").withWriter { it << result }
}
rootProject.ext {
versionFile = rootProject.file("VERSION")
versionName = versionFile.readLines()[0].trim()
versionCode = parseVersionName(versionName)
}
task bumpMajor {
doLast {
def oldVersion = rootProject.ext.versionName
def versionParts = oldVersion.split(/\./)
versionParts[0] = (versionParts[0] as int) + 1
def newVersion = "${versionParts[0]}.0.0"
versionFile.write(newVersion + "\n")
updateReadme(oldVersion, newVersion)
rootProject.ext.versionName = newVersion
tasks.version.execute()
}
}
task bumpMinor {
doLast {
def oldVersion = rootProject.ext.versionName
def versionParts = oldVersion.split(/\./)
versionParts[1] = (versionParts[1] as int) + 1
def newVersion = "${versionParts[0]}.${versionParts[1]}.0"
versionFile.write(newVersion + "\n")
updateReadme(oldVersion, newVersion)
rootProject.ext.versionName = newVersion
tasks.version.execute()
}
}
task bumpPatch {
doLast {
def oldVersion = rootProject.ext.versionName
def versionParts = oldVersion.split(/\./)
versionParts[2] = (versionParts[2].split(/\D/)[0] as int) + 1
def newVersion = "${versionParts[0]}.${versionParts[1]}.${versionParts[2]}"
versionFile.write(newVersion + "\n")
updateReadme(oldVersion, newVersion)
rootProject.ext.versionName = newVersion
tasks.version.execute()
}
}
task version {
doLast {
println "v" + rootProject.ext.versionName
}
}
String shell(String command) {
def proc = ["sh", "-c", "cd ${rootProject.rootDir} ; ${command}"].execute()
if (proc.waitFor() != 0) {
throw new RuntimeException("Failed to run: ${command}\n${proc.err.text}")
} else {
def err = proc.err.text
if (err) {
System.err.println(err)
}
}
return proc.in.text;
}
task releng {
doLast {
def currentBranch = shell("git symbolic-ref --short HEAD")
def tag = "v" + rootProject.ext.versionName
println "Release engineering for ${tag} (branch=${currentBranch})"
def changes = shell("git status -s")
if (changes.trim()) {
throw new RuntimeException("There are changes not commited yet.\n${changes}")
}
println "> git tag ${tag}"
shell "git tag ${tag}"
println "> git push origin ${tag}"
shell "git push origin ${tag}"
println "> git push origin ${tag}"
shell "git push origin ${currentBranch}"
}
}
gitextract_x6z246hr/ ├── .gitignore ├── CHANGES.md ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── build.gradle ├── buildSrc/ │ ├── build.gradle │ └── settings.gradle ├── circle.yml ├── example-custom/ │ ├── build.gradle │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gfx/ │ │ └── ribbonizer/ │ │ └── example/ │ │ └── MainActivity.java │ └── res/ │ ├── layout/ │ │ └── activity_main.xml │ ├── mipmap-anydpi-v26/ │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ ├── values/ │ │ ├── dimens.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── values-v26/ │ │ └── colors.xml │ └── values-w820dp/ │ └── dimens.xml ├── example-simple/ │ ├── build.gradle │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gfx/ │ │ └── ribbonizer/ │ │ └── example/ │ │ └── MainActivity.java │ └── res/ │ ├── layout/ │ │ └── activity_main.xml │ ├── values/ │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── values-w820dp/ │ └── dimens.xml ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties.sample ├── gradlew ├── gradlew.bat ├── metadata.gradle ├── plugin/ │ ├── build.gradle │ └── src/ │ ├── main/ │ │ ├── groovy/ │ │ │ └── com/ │ │ │ └── github/ │ │ │ └── gfx/ │ │ │ └── ribbonizer/ │ │ │ ├── CustomColorRibbonBuilder.java │ │ │ ├── FilterBuilder.java │ │ │ ├── GrayRibbonBuilder.java │ │ │ ├── GrayScaleBuilder.java │ │ │ ├── GreenRibbonBuilder.java │ │ │ ├── YellowRibbonBuilder.java │ │ │ ├── filter/ │ │ │ │ ├── ColorRibbonFilter.java │ │ │ │ └── GrayScaleFilter.java │ │ │ └── plugin/ │ │ │ ├── Resources.java │ │ │ ├── Ribbonizer.java │ │ │ ├── RibbonizerExtension.java │ │ │ ├── RibbonizerPlugin.groovy │ │ │ └── RibbonizerTask.groovy │ │ └── resources/ │ │ └── META-INF/ │ │ └── gradle-plugins/ │ │ └── com.github.gfx.ribbonizer.properties │ └── test/ │ └── groovy/ │ └── com/ │ └── github/ │ └── gfx/ │ └── ribbonizer/ │ └── test/ │ └── ResourcesTest.groovy ├── settings.gradle └── versioning.gradle
SYMBOL INDEX (52 symbols across 13 files)
FILE: example-custom/src/main/java/com/github/gfx/ribbonizer/example/MainActivity.java
class MainActivity (line 12) | public class MainActivity extends Activity {
method onCreate (line 17) | @Override
method onButtonClick (line 25) | @OnClick(R.id.button)
FILE: example-simple/src/main/java/com/github/gfx/ribbonizer/example/MainActivity.java
class MainActivity (line 12) | public class MainActivity extends Activity {
method onCreate (line 17) | @Override
method onButtonClick (line 25) | @OnClick(R.id.button)
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/CustomColorRibbonBuilder.java
class CustomColorRibbonBuilder (line 11) | public class CustomColorRibbonBuilder implements FilterBuilder {
method CustomColorRibbonBuilder (line 15) | public CustomColorRibbonBuilder(String nm) {
method apply (line 19) | @Override
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/FilterBuilder.java
type FilterBuilder (line 10) | public interface FilterBuilder extends BiFunction<ApplicationVariant, Fi...
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/GrayRibbonBuilder.java
class GrayRibbonBuilder (line 11) | public class GrayRibbonBuilder implements FilterBuilder {
method apply (line 15) | @Override
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/GrayScaleBuilder.java
class GrayScaleBuilder (line 10) | public class GrayScaleBuilder implements FilterBuilder {
method apply (line 12) | @Override
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/GreenRibbonBuilder.java
class GreenRibbonBuilder (line 11) | public class GreenRibbonBuilder implements FilterBuilder {
method apply (line 15) | @Override
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/YellowRibbonBuilder.java
class YellowRibbonBuilder (line 11) | public class YellowRibbonBuilder implements FilterBuilder {
method apply (line 15) | @Override
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/filter/ColorRibbonFilter.java
class ColorRibbonFilter (line 10) | public class ColorRibbonFilter implements Consumer<BufferedImage> {
method ColorRibbonFilter (line 26) | public ColorRibbonFilter(String label, Color ribbonColor, Color labelC...
method ColorRibbonFilter (line 32) | public ColorRibbonFilter(String label, Color ribbonColor) {
method calculateMaxLabelWidth (line 36) | static int calculateMaxLabelWidth(int y) {
method drawString (line 40) | static void drawString(Graphics2D g, String str, int x, int y) {
method accept (line 52) | @Override
method getFont (line 88) | Font getFont(int maxLabelWidth, FontRenderContext frc) {
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/filter/GrayScaleFilter.java
class GrayScaleFilter (line 6) | public class GrayScaleFilter implements Consumer<BufferedImage> {
method toGray (line 8) | static int toGray(int color) {
method accept (line 18) | @Override
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/Resources.java
class Resources (line 17) | public class Resources {
method resourceFilePattern (line 19) | public static String resourceFilePattern(String name) {
method getLauncherIcons (line 35) | public static List<String> getLauncherIcons(File manifestFile)
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/Ribbonizer.java
class Ribbonizer (line 11) | public class Ribbonizer {
method Ribbonizer (line 19) | public Ribbonizer(File inputFile, File outputFile) throws IOException {
method save (line 26) | public void save() throws IOException {
method process (line 31) | public void process(Stream<Consumer<BufferedImage>> filters) {
FILE: plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/RibbonizerExtension.java
class RibbonizerExtension (line 21) | class RibbonizerExtension {
method RibbonizerExtension (line 31) | public RibbonizerExtension() {
method getIconNames (line 34) | public Set<String> getIconNames() {
method setIconNames (line 41) | public void setIconNames(Collection<String> resNames) {
method iconNames (line 48) | public void iconNames(Collection<String> resNames) {
method iconNames (line 55) | public void iconNames(String... resNames) {
method iconName (line 62) | public void iconName(String resName) {
method getForcedVariantsNames (line 66) | public Set<String> getForcedVariantsNames() {
method forcedVariantsNames (line 70) | public void forcedVariantsNames(String... variantsNames) {
method getFilterBuilders (line 74) | public List<FilterBuilder> getFilterBuilders() {
method setFilterBuilders (line 78) | public void setFilterBuilders(Collection<FilterBuilder> filterBuilders) {
method builder (line 82) | public void builder(FilterBuilder filterBuilder)
method grayScaleFilter (line 90) | public Consumer<BufferedImage> grayScaleFilter(ApplicationVariant vari...
method grayRibbonFilter (line 94) | public Consumer<BufferedImage> grayRibbonFilter(ApplicationVariant var...
method yellowRibbonFilter (line 98) | public Consumer<BufferedImage> yellowRibbonFilter(ApplicationVariant v...
method greenRibbonFilter (line 102) | public Consumer<BufferedImage> greenRibbonFilter(ApplicationVariant va...
method customColorRibbonFilter (line 106) | public Consumer<BufferedImage> customColorRibbonFilter(ApplicationVari...
Condensed preview — 54 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (63K chars).
[
{
"path": ".gitignore",
"chars": 80,
"preview": ".gradle\nlocal.properties\n.idea\n.DS_Store\nbuild/\nreports/\ngradle.properties\n*.iml"
},
{
"path": "CHANGES.md",
"chars": 1543,
"preview": "# The revision history of android-ribbonizer-plugin\n\n## v2.1.0 2017/08/19\n\n* Allow null values for filters and ribbon la"
},
{
"path": "LICENSE",
"chars": 1099,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2015 FUJI Goro (gfx) <gfuji@cpan.org>.\n\nPermission is hereby granted, free of charg"
},
{
"path": "Makefile",
"chars": 376,
"preview": "check:\n\t./gradlew clean check bintrayUpload\n\npublish: check\n\t./gradlew releng\n\t./gradlew -PdryRun=false --info plugin:bi"
},
{
"path": "README.md",
"chars": 4830,
"preview": "# DEPRECATED\nNo longer actively maintained, I recommend [Mikel's easylauncher-gradle-plugin](https://github.com/akaita/e"
},
{
"path": "VERSION",
"chars": 6,
"preview": "2.1.0\n"
},
{
"path": "build.gradle",
"chars": 410,
"preview": "apply from: './versioning.gradle'\napply from: './metadata.gradle'\n\next {\n metadata.version = versionName\n}\n\nbuildscri"
},
{
"path": "buildSrc/build.gradle",
"chars": 129,
"preview": "System.setProperty(\"java.awt.headless\", \"true\")\n\nrepositories {\n jcenter()\n}\n\ndependencies {\n compile project(':pl"
},
{
"path": "buildSrc/settings.gradle",
"chars": 72,
"preview": "include ':plugin'\nproject(':plugin').projectDir = new File('../plugin')\n"
},
{
"path": "circle.yml",
"chars": 620,
"preview": "machine:\n java:\n version: oraclejdk8\n environment:\n TERM: dumb\n GRADLE_OPTS: '-Dorg.gradle.jvmargs=\"-Xmx1024m"
},
{
"path": "example-custom/build.gradle",
"chars": 1862,
"preview": "import com.android.build.gradle.api.ApplicationVariant\n\napply plugin: 'com.android.application'\napply plugin: 'com.githu"
},
{
"path": "example-custom/src/main/AndroidManifest.xml",
"chars": 785,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "example-custom/src/main/java/com/github/gfx/ribbonizer/example/MainActivity.java",
"chars": 829,
"preview": "package com.github.gfx.ribbonizer.example;\n\nimport android.app.Activity;\nimport android.app.AlertDialog;\nimport android."
},
{
"path": "example-custom/src/main/res/layout/activity_main.xml",
"chars": 1145,
"preview": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/too"
},
{
"path": "example-custom/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
"chars": 265,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <b"
},
{
"path": "example-custom/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
"chars": 265,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <b"
},
{
"path": "example-custom/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "example-custom/src/main/res/values/ic_launcher_background.xml",
"chars": 118,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"ic_launcher_background\">#00C89C</color>\n</resources>"
},
{
"path": "example-custom/src/main/res/values/strings.xml",
"chars": 266,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <string name=\"app_name\">App Icon Demo</string>\n <string name="
},
{
"path": "example-custom/src/main/res/values/styles.xml",
"chars": 183,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"android:Theme.Holo.Light\">\n "
},
{
"path": "example-custom/src/main/res/values-v26/colors.xml",
"chars": 121,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"ic_launcher_background\">#1c7917</color>\n</resources>"
},
{
"path": "example-custom/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "example-simple/build.gradle",
"chars": 525,
"preview": "apply plugin: 'com.android.application'\napply plugin: 'com.github.gfx.ribbonizer'\n\nandroid {\n compileSdkVersion 25\n "
},
{
"path": "example-simple/src/main/AndroidManifest.xml",
"chars": 733,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "example-simple/src/main/java/com/github/gfx/ribbonizer/example/MainActivity.java",
"chars": 829,
"preview": "package com.github.gfx.ribbonizer.example;\n\nimport android.app.Activity;\nimport android.app.AlertDialog;\nimport android."
},
{
"path": "example-simple/src/main/res/layout/activity_main.xml",
"chars": 1145,
"preview": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/too"
},
{
"path": "example-simple/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "example-simple/src/main/res/values/strings.xml",
"chars": 266,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <string name=\"app_name\">App Icon Demo</string>\n <string name="
},
{
"path": "example-simple/src/main/res/values/styles.xml",
"chars": 183,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"android:Theme.Holo.Light\">\n "
},
{
"path": "example-simple/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Thu Dec 11 08:17:04 JST 2014\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties.sample",
"chars": 87,
"preview": "# configuration for bintray and signing\n\nbintrayUser=YOUR_USERNAME\nbintrayKey=YOUR_KEY\n"
},
{
"path": "gradlew",
"chars": 5080,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2404,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@r"
},
{
"path": "metadata.gradle",
"chars": 343,
"preview": "ext {\n metadata = [\n userOrg : 'ribbonizer',\n groupId : 'com.github.gfx.ribbonizer',\n "
},
{
"path": "plugin/build.gradle",
"chars": 1094,
"preview": "repositories {\n jcenter()\n}\n\napply plugin: 'groovy'\n\n\nsourceCompatibility = JavaVersion.VERSION_1_8\ntargetCompatibili"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/CustomColorRibbonBuilder.java",
"chars": 636,
"preview": "package com.github.gfx.ribbonizer;\n\nimport com.android.build.gradle.api.ApplicationVariant;\nimport com.github.gfx.ribbon"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/FilterBuilder.java",
"chars": 332,
"preview": "package com.github.gfx.ribbonizer;\n\nimport com.android.build.gradle.api.ApplicationVariant;\n\nimport java.awt.image.Buffe"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/GrayRibbonBuilder.java",
"chars": 586,
"preview": "package com.github.gfx.ribbonizer;\n\nimport com.android.build.gradle.api.ApplicationVariant;\nimport com.github.gfx.ribbon"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/GrayScaleBuilder.java",
"chars": 460,
"preview": "package com.github.gfx.ribbonizer;\n\nimport com.android.build.gradle.api.ApplicationVariant;\nimport com.github.gfx.ribbon"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/GreenRibbonBuilder.java",
"chars": 575,
"preview": "package com.github.gfx.ribbonizer;\n\nimport com.android.build.gradle.api.ApplicationVariant;\nimport com.github.gfx.ribbon"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/YellowRibbonBuilder.java",
"chars": 585,
"preview": "package com.github.gfx.ribbonizer;\n\nimport com.android.build.gradle.api.ApplicationVariant;\nimport com.github.gfx.ribbon"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/filter/ColorRibbonFilter.java",
"chars": 3425,
"preview": "package com.github.gfx.ribbonizer.filter;\n\nimport java.awt.*;\nimport java.awt.font.FontRenderContext;\nimport java.awt.ge"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/filter/GrayScaleFilter.java",
"chars": 850,
"preview": "package com.github.gfx.ribbonizer.filter;\n\nimport java.awt.image.BufferedImage;\nimport java.util.function.Consumer;\n\npub"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/Resources.java",
"chars": 1723,
"preview": "package com.github.gfx.ribbonizer.plugin;\n\nimport org.xml.sax.SAXException;\n\nimport java.io.File;\nimport java.io.IOExcep"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/Ribbonizer.java",
"chars": 1038,
"preview": "package com.github.gfx.ribbonizer.plugin;\n\nimport java.awt.image.BufferedImage;\nimport java.io.File;\nimport java.io.IOEx"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/RibbonizerExtension.java",
"chars": 3424,
"preview": "package com.github.gfx.ribbonizer.plugin;\n\nimport com.android.build.gradle.api.ApplicationVariant;\nimport com.github.gfx"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/RibbonizerPlugin.groovy",
"chars": 3570,
"preview": "package com.github.gfx.ribbonizer.plugin\n\nimport com.android.build.gradle.AppExtension\nimport com.android.build.gradle.a"
},
{
"path": "plugin/src/main/groovy/com/github/gfx/ribbonizer/plugin/RibbonizerTask.groovy",
"chars": 3416,
"preview": "package com.github.gfx.ribbonizer.plugin\n\nimport com.android.build.gradle.AppExtension\nimport com.android.build.gradle.a"
},
{
"path": "plugin/src/main/resources/META-INF/gradle-plugins/com.github.gfx.ribbonizer.properties",
"chars": 70,
"preview": "implementation-class=com.github.gfx.ribbonizer.plugin.RibbonizerPlugin"
},
{
"path": "plugin/src/test/groovy/com/github/gfx/ribbonizer/test/ResourcesTest.groovy",
"chars": 3040,
"preview": "package com.github.gfx.ribbonizer.test\n\nimport com.github.gfx.ribbonizer.plugin.Resources\nimport spock.lang.Specificatio"
},
{
"path": "settings.gradle",
"chars": 70,
"preview": "include ':plugin'\ninclude ':example-simple'\ninclude ':example-custom'\n"
},
{
"path": "versioning.gradle",
"chars": 3785,
"preview": "/*\n * Copyright (c) 2015 FUJI Goro (gfx).\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the gfx/gradle-android-ribbonizer-plugin GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 54 files (55.3 KB), approximately 15.3k tokens, and a symbol index with 52 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.