Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: '17'
cache: gradle

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v4

- name: Build
run: ./gradlew build
33 changes: 33 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish Release

on:
push:
tags:
- '*'

env:
RELEASE_SIGNING_ENABLED: true

jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'Commit451/Easel'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: '17'
cache: gradle

- name: Release to Maven Central
run: ./gradlew publishAndReleaseToMavenCentral -PVERSION_NAME="${GITHUB_REF_NAME}" --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
# Easel
Tint and color Android views with ease

[![Build Status](https://travis-ci.org/Commit451/Easel.svg?branch=master)](https://travis-ci.org/Commit451/Easel) [![](https://jitpack.io/v/Commit451/Easel.svg)](https://jitpack.io/#Commit451/Easel)
[![Build](https://github.com/Commit451/Easel/actions/workflows/ci.yml/badge.svg)](https://github.com/Commit451/Easel/actions/workflows/ci.yml) [![Maven Central](https://img.shields.io/maven-central/v/com.commit451/easel.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.commit451/easel)

# Gradle Dependency
Add the jitpack url to the project:
```groovy
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```
then, in your app `build.gradle`
```groovy
Add the library to your app `build.gradle`:
```gradle
dependencies {
implementation "com.github.Commit451:Easel:latest.version.here"
implementation("com.commit451:easel:latest.version.here")
}
```

Expand Down
32 changes: 0 additions & 32 deletions app/build.gradle

This file was deleted.

42 changes: 42 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id("com.android.application")
}

android {
namespace = "com.commit451.easel.sample"
compileSdk = 35

defaultConfig {
applicationId = "com.commit451.easel.sample"
minSdk = 21
targetSdk = 35
versionCode = 1
versionName = "1.0"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

lint {
abortOnError = false
}
}


dependencies {
implementation("androidx.appcompat:appcompat:1.7.1")

implementation(project(":easel"))
}
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.commit451.easel.sample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand All @@ -9,6 +8,7 @@
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden">
<intent-filter>
Expand All @@ -17,7 +17,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".KotlinActivity"/>
<activity android:name=".KotlinActivity" />
</application>

</manifest>
</manifest>
29 changes: 0 additions & 29 deletions build.gradle

This file was deleted.

9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("com.android.application") version "9.1.0" apply false
id("com.android.library") version "9.1.0" apply false
id("com.vanniktech.maven.publish") version "0.30.0" apply false
}

tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
31 changes: 0 additions & 31 deletions easel/build.gradle

This file was deleted.

58 changes: 58 additions & 0 deletions easel/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("com.android.library")
id("com.vanniktech.maven.publish")
}

group = findProperty("GROUP") as String
version = findProperty("VERSION_NAME") as String

android {
namespace = "com.commit451.easel"
compileSdk = 35

defaultConfig {
minSdk = 14
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

lint {
abortOnError = false
}
}


dependencies {
api("androidx.appcompat:appcompat:1.7.1")
}

mavenPublishing {
configure(
AndroidSingleVariantLibrary(
variant = "release",
sourcesJar = true,
publishJavadocJar = true,
)
)
coordinates("com.commit451", "easel", version.toString())
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
if (System.getenv("RELEASE_SIGNING_ENABLED") == "true") {
signAllPublications()
}
}
6 changes: 1 addition & 5 deletions easel/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<manifest package="com.commit451.easel">

<application />

</manifest>
<manifest />
8 changes: 4 additions & 4 deletions easel/src/main/java/com/commit451/easel/Easel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ object Easel {
val colors = IntArray(3)
var i = 0
states[i] = intArrayOf(-android.R.attr.state_enabled)
colors[i] = getThemeAttrColor(context, R.attr.colorControlNormal)
colors[i] = getThemeAttrColor(context, androidx.appcompat.R.attr.colorControlNormal)
i++
states[i] = intArrayOf(-android.R.attr.state_pressed, -android.R.attr.state_focused)
colors[i] = getThemeAttrColor(context, R.attr.colorControlNormal)
colors[i] = getThemeAttrColor(context, androidx.appcompat.R.attr.colorControlNormal)
i++
states[i] = intArrayOf()
colors[i] = color
Expand All @@ -90,7 +90,7 @@ object Easel {

// Disabled state
states[i] = intArrayOf(-android.R.attr.state_enabled)
colors[i] = adjustAlpha(getThemeAttrColor(context, R.attr.colorControlNormal), 0.1f)
colors[i] = adjustAlpha(getThemeAttrColor(context, androidx.appcompat.R.attr.colorControlNormal), 0.1f)
i++

states[i] = intArrayOf(android.R.attr.state_checked)
Expand All @@ -99,7 +99,7 @@ object Easel {

// Default enabled state
states[i] = IntArray(0)
colors[i] = adjustAlpha(getThemeAttrColor(context, R.attr.colorControlNormal), 0.5f)
colors[i] = adjustAlpha(getThemeAttrColor(context, androidx.appcompat.R.attr.colorControlNormal), 0.5f)

return ColorStateList(states, colors)
}
Expand Down
4 changes: 2 additions & 2 deletions easel/src/main/java/com/commit451/easel/checkbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import com.commit451.easel.Easel.getThemeAttrColor

fun CheckBox.tint(@ColorInt color: Int) {
val disabledColor = Easel.getDisabledColor(context)
val sl = ColorStateList(arrayOf(intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked), intArrayOf(-android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(-android.R.attr.state_enabled, android.R.attr.state_checked)), intArrayOf(getThemeAttrColor(getContext(), R.attr.colorControlNormal), color, disabledColor, disabledColor))
val sl = ColorStateList(arrayOf(intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked), intArrayOf(-android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(-android.R.attr.state_enabled, android.R.attr.state_checked)), intArrayOf(getThemeAttrColor(getContext(), androidx.appcompat.R.attr.colorControlNormal), color, disabledColor, disabledColor))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
buttonTintList = sl
} else {
val checkDrawable = ContextCompat.getDrawable(context, R.drawable.abc_btn_check_material)!!
val checkDrawable = ContextCompat.getDrawable(context, androidx.appcompat.R.drawable.abc_btn_check_material)!!
val drawable = DrawableCompat.wrap(checkDrawable)
DrawableCompat.setTintList(drawable, sl)
buttonDrawable = drawable
Expand Down
4 changes: 2 additions & 2 deletions easel/src/main/java/com/commit451/easel/radiobutton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import com.commit451.easel.Easel.getThemeAttrColor
*/
fun RadioButton.tint(@ColorInt color: Int) {
val disabledColor = Easel.getDisabledColor(context)
val sl = ColorStateList(arrayOf(intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked), intArrayOf(-android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(-android.R.attr.state_enabled, android.R.attr.state_checked)), intArrayOf(getThemeAttrColor(context, R.attr.colorControlNormal), color, disabledColor, disabledColor))
val sl = ColorStateList(arrayOf(intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked), intArrayOf(-android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(-android.R.attr.state_enabled, android.R.attr.state_checked)), intArrayOf(getThemeAttrColor(context, androidx.appcompat.R.attr.colorControlNormal), color, disabledColor, disabledColor))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
buttonTintList = sl
} else {
val radioDrawable = ContextCompat.getDrawable(context, R.drawable.abc_btn_radio_material)!!
val radioDrawable = ContextCompat.getDrawable(context, androidx.appcompat.R.drawable.abc_btn_radio_material)!!
val d = DrawableCompat.wrap(radioDrawable)
DrawableCompat.setTintList(d, sl)
buttonDrawable = d
Expand Down
2 changes: 1 addition & 1 deletion easel/src/main/java/com/commit451/easel/switchcompat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.core.graphics.drawable.DrawableCompat
import androidx.appcompat.widget.SwitchCompat
import com.commit451.easel.Easel.getThemeAttrColor

fun SwitchCompat.tint(@ColorInt color: Int, @ColorInt unpressedColor: Int = getThemeAttrColor(context, R.attr.colorSwitchThumbNormal)) {
fun SwitchCompat.tint(@ColorInt color: Int, @ColorInt unpressedColor: Int = getThemeAttrColor(context, androidx.appcompat.R.attr.colorSwitchThumbNormal)) {
val sl = ColorStateList(arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)), intArrayOf(unpressedColor, color))
DrawableCompat.setTintList(thumbDrawable, sl)
DrawableCompat.setTintList(trackDrawable, Easel.createSwitchTrackColorStateList(context, color))
Expand Down
Loading