Skip to content

Commit

Permalink
Merge pull request #106 from marcauberer/dev
Browse files Browse the repository at this point in the history
Release of version 1.2.0
  • Loading branch information
marcauberer committed Feb 20, 2021
2 parents 71a795b + 50d8b04 commit 0fe4ea7
Show file tree
Hide file tree
Showing 12 changed files with 311 additions and 193 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
uses: actions/checkout@v2
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Prepare publishing environment
run: mkdir ~/.gradle && echo "$ARTIFACTORY_CREDENTIALS" > ./simplesettings/gradle.properties
env:
ARTIFACTORY_CREDENTIALS: ${{ secrets.ARTIFACTORY_CREDENTIALS }}
- name: Android Build
uses: vgaidarji/android-github-actions-build@v1.0.1
with:
args: './gradlew assembleDebug'
run: ./gradlew assembleDebug
18 changes: 13 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Workflow for Android CI release

name: Publish to Bintray
name: Publish to Artifactory

on:
release:
Expand All @@ -11,6 +11,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Get version name
id: get_version
uses: battila7/get-version-action@v2
- name: Checkout code
uses: actions/checkout@v2
with:
Expand All @@ -21,11 +24,16 @@ jobs:
java-version: 1.8
- name: Make gradlew executable
run: chmod +x gradlew
- name: Publish library
- name: Prepare publishing environment
run: mkdir ~/.gradle && echo "$ARTIFACTORY_CREDENTIALS" > ./simplesettings/gradle.properties
env:
bintrayUser: ${{ secrets.BINTRAY_USERNAME }}
bintrayApiKey: ${{ secrets.BINTRAY_API_KEY }}
run: ./gradlew clean build bintrayUpload dokkaHtml
ARTIFACTORY_CREDENTIALS: ${{ secrets.ARTIFACTORY_CREDENTIALS }}
- name: Publish Dev
if: ${{ contains(steps.get_version.outputs.version, 'alpha') }}
run: ./gradlew simplesettings:assemble
- name: Publish
if: ${{ !contains(steps.get_version.outputs.version, 'alpha') }}
run: ./gradlew simplesettings:assemble -PparamEnv=RELEASE
- name: Deploy Documentation
uses: JamesIves/github-pages-deploy-action@3.6.2
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
/build
/captures
.externalNativeBuild
.cxx
.cxx
simplesettings/gradle.properties
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Simple Settings Library for Android
[![Download](https://api.bintray.com/packages/marcauberer/simplesettings/com.chillibits%3Asimplesettings/images/download.svg)](https://bintray.com/marcauberer/simplesettings/com.chillibits%3Asimplesettings/_latestVersion)
![GitHub release](https://img.shields.io/github/v/release/marcauberer/simple-settings?include_prereleases)
![Android CI](https://github.com/marcauberer/simple-settings/workflows/Android%20CI/badge.svg)
[![API](https://img.shields.io/badge/API-21%2B-red.svg?style=flat)](https://android-arsenal.com/api?level=21)
[![Article on Medium](https://aleen42.github.io/badges/src/medium.svg)](https://medium.com/swlh/simple-settings-library-build-a-settings-screen-in-seconds-5b6394fbd2fc)
Expand All @@ -15,8 +15,20 @@ If you want to test the library, please visit the sample app on [Google Play](ht

## Usage
The first step for using this library is, to add it to the dependency section in your project:

Add repository to build.gradle file on project level:
```gradle
allprojects {
repositories {
...
maven { url "https://repo.chillibits.com/artifactory/android" }
}
}
```

Add dependencies to build.gradle file on module level (e.g. app/build.gradle):
```gradle
implementation 'com.chillibits:simplesettings:1.1.1'
implementation 'com.chillibits:simplesettings:1.2.0'
// Required dependencies
implementation 'com.google.android.material:material:<latest-version>'
Expand Down Expand Up @@ -217,12 +229,12 @@ As you can see, this works for the types `String`, `Int`, `Boolean`, `Float`, `L
### Retrieval as LiveData
Furthermore, the library offers a feature to observe preference values as LiveData as follows:
```kotlin
getPrefObserver( "listpreference", Observer<String> { value ->
getPrefObserver(this@MainActivity, "listpreference", Observer<String> { value ->
textField.text = value
})
```
Like above, this works for the types `String`, `Int`, `Boolean`, `Float`, `Long`, `StringSet`.<br>
*Note: This extension functions are only available for the `AppCompatActivity` class, because there is a LifecycleOwner required to create Observables.*
*Note: This extension functions are only available for the classes, which implement `LifecycleOwner`.*

## Library customization
The library offers a few customization options. For applying those options, you have to pass an object of `SimpleSettingsConfig` to the constructor of your `SimpleSettings` instance.
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

// Test dependencies
testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class MainActivity : AppCompatActivity(), SimpleSettingsConfig.OptionsItemSelect
}

private fun subscribeToPreferenceValues() {
getPrefObserver( "inputpreference", Observer<String> {
getPrefObserver( this, "inputpreference", Observer<String> {
inputPreferenceValue.text = getString(R.string.value_input_preference_, it)
})
}
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/

buildscript {
ext.library_version = '1.1.1'
ext.library_version_code = 1101
ext.library_version = '1.2.0'
ext.library_version_code = 1200
ext.kotlin_version = '1.4.30'
repositories {
google()
Expand All @@ -13,7 +13,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.20.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.20'
}
Expand Down
189 changes: 74 additions & 115 deletions simplesettings/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
* Copyright © Marc Auberer 2020-2021. All rights reserved
*/

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
apply plugin: 'android-maven'
apply plugin: 'org.jetbrains.dokka'
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'com.jfrog.artifactory'
id 'maven-publish'
id 'android-maven'
id 'org.jetbrains.dokka'
}

android {
compileSdkVersion 30
Expand Down Expand Up @@ -53,7 +55,7 @@ dependencies {
api 'com.github.skydoves:colorpickerpreference:2.0.5'

// Test dependencies
testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Expand All @@ -62,123 +64,80 @@ dokkaHtml.configure {
dokkaSourceSets {}
}

ext {
bintrayRepo = 'simplesettings'

// Name which will be visible on bintray
bintrayName = 'SimpleSettingsLibrary'

// Library Details
publishedGroupId = 'com.chillibits'
libraryName = 'Simple Settings'
artifact = 'simplesettings'
libraryDescription = 'Simple to use, lightweight solution to create a settings screen without any boilerplate code.'
libraryVersion = library_version

// Repository Links
siteUrl = 'https://github.com/marcauberer/simple-settings'
gitUrl = 'https://github.com/marcauberer/simple-settings.git'
githubRepository= 'marcauberer/simple-settings'

// Developer Details
developerId = 'marcauberer'
developerName = 'Marc Auberer'
developerEmail = 'marc.auberer@chillibits.com'

// License Details
licenseName = 'The MIT License'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier = "sources"
}

group = publishedGroupId

install {
repositories.mavenInstaller {
// Generate pom.xml with proper parameters
pom {
project {
packaging 'aar'

groupId publishedGroupId
artifactId = artifact
name libraryName
description = libraryDescription
url siteUrl

licenses {
license {
name licenseName
url licenseUrl
}
publishing {
publications {
android.libraryVariants.all { variant ->
def filename = "${archivesBaseName}-${variant.baseName}"
"${variant.name}"(MavenPublication) {
groupId 'com.chillibits'
artifactId = "simplesettings"
if (project.hasProperty('paramEnv') && project.property('paramEnv') != 'RELEASE' || variant.name != "release") {
groupId "com.chillibits.${variant.name}"
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
version = "${android.defaultConfig.versionName}"
if (variant.buildType.name == "debug") {
artifact(sourcesJar)
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
artifact file("$buildDir/outputs/aar/${filename}.aar")
pom.withXml {
// for dependencies and exclusions
def dependenciesNode = asNode().appendNode('dependencies')
def configurationNames = ["implementation", "api", "runtimeOnly"]
configurationNames.each { confName ->
configurations[confName].allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
if (it.excludeRules.size() > 0) {
def exclusionsNode = dependencyNode.appendNode('exclusions')
it.excludeRules.each { rule ->
def exclusionNode = exclusionsNode.appendNode('exclusion')
exclusionNode.appendNode('groupId', rule.group)
exclusionNode.appendNode('artifactId', rule.module)
}
}
}
}
}
}
}
}
}

// Avoid Kotlin docs error
tasks.withType(Javadoc) {
enabled = false
}

// Remove javadoc related tasks
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}

// https://github.com/bintray/gradle-bintray-plugin
bintray {
user = System.getenv("bintrayUser")
key = System.getenv("bintrayApiKey")

configurations = ['archives']
pkg {
repo = bintrayRepo
name = "$publishedGroupId:$artifact"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
publish = true
publicDownloadNumbers = true
version {
name = libraryVersion
desc = libraryDescription
released = new Date()
vcsTag = libraryVersion
attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
assemble.finalizedBy(artifactoryPublish)
artifactory {
contextUrl = "${artifactory_context_url}"
publish {
repository {
repoKey = "${artifactory_dev_repo_key}"
if (project.hasProperty('paramEnv') && project.property('paramEnv') == 'RELEASE') {
repoKey = "${artifactory_rel_repo_key}"
}
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
if (project.hasProperty('paramEnv') && project.property('paramEnv') == 'RELEASE') {
publications('release')
} else {
publications('debug', 'release')
}
publishArtifacts = true
publishPom = true
}
}
filesSpec {
from 'simplesettings/build/outputs/aar/simplesettings-release.aar'
into '.'
version libraryVersion
resolve {
repository {
repoKey = "${artifactory_rel_repo_key}"
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}

0 comments on commit 0fe4ea7

Please sign in to comment.