Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrimaeon committed Aug 9, 2020
2 parents ee6bfca + 961d90d commit 56f6f5c
Show file tree
Hide file tree
Showing 47 changed files with 690 additions and 293 deletions.
74 changes: 66 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: 2.1

executors:
app-rater-android-executor:
android-executor:
docker:
- image: circleci/android:api-29
working_directory: ~/app-rater
environment:
JAVA_TOOL_OPTIONS: "-Xmx1536m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2"
JAVA_TOOL_OPTIONS: "-Xmx2G"
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.parallel=false -Dorg.gradle.workers.max=2 -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false"
TERM: dumb

commands:
Expand All @@ -27,23 +27,81 @@ commands:
steps:
- store_test_results:
path: <<parameters.test-result-path>>
restore-gradle-wrapper:
description: "Restores Gradle Wrapper from cache"
steps:
- restore_cache:
key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
save-gradle-wrapper:
description: "Save Gradle Wrapper to cache"
steps:
- save_cache:
paths:
- ~/.gradle/wrapper
key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}

jobs:
build:
executor: app-rater-android-executor
build-test:
executor: android-executor
steps:
- checkout
- restore-gradle-wrapper
- run:
name: Download Dependencies
command: ./gradlew dependencies
command: ./gradlew androidDependencies
- run:
name: Run JVM Tests & Lint
command: ./gradlew check
command: ./gradlew :library:check :library-ktx:check
- run:
name: Gather Lint & Test results
command: python ./scripts/copy_results
- store-app-rater-artifacts:
artifact-path: ci_results/lint
- store-app-rater-test-results:
test-result-path: ci_results/test

- save-gradle-wrapper
- persist_to_workspace:
root: .
paths:
- build
- ./**/build
deploy:
executor: android-executor
steps:
- checkout
- attach_workspace:
at: .
- restore-gradle-wrapper
- run:
name: Deploy to Bintray
command: ./gradlew bintrayUpload
workflows:
version: 2
build-and-test:
jobs:
- build-test:
filters:
tags:
only: /.*/
branches:
only:
- develop
- master
- /release\/.*/
- hold:
type: approval
requires:
- build-test
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- deploy:
requires:
- hold
filters:
tags:
only: /.*/
branches:
ignore: /.*/
11 changes: 8 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[*]
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.{kt, kts}]
indent_size = 4
disabled_rules = import-ordering
kotlin_imports_layout = idea

[*.{yaml, yml}]
indent_size = 2
6 changes: 3 additions & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/copyright/CMG_Apps.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
# Android&trade; App Rater Dialog
# Android&trade; App Rater Dialog [![CircleCI](https://circleci.com/gh/chrimaeon/app-rater.svg?style=svg)](https://circleci.com/gh/chrimaeon/app-rater)

[![License](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg?style=for-the-badge&logo=apache)](http://www.apache.org/licenses/LICENSE-2.0)
[![Bintray](https://www.cmgapps.com/badge/chrimaeon/maven/com.cmgapps.android:app-rater/badge.svg)](https://jcenter.bintray.com/com/cmgapps/android/cmgUtilities/)
[![CircleCI](https://circleci.com/gh/chrimaeon/app-rater.svg?style=svg)](https://circleci.com/gh/chrimaeon/app-rater)

This is a App Rater Dialog to encourage user to rate the app on the Google Play Store&trade;

It is used in my Android&trade; Projects:

* [Bierdeckel][1]
* [Numerals Converter][4]
* [PhoNews][2]
* [PhoNews Pro][3]
__This is a App Rater Dialog to encourage user to rate the app__

## Usage

Add the following dependency to your `build.gradle`.

```groovy
dependencies {
implementation 'com.cmgapps.android:app-rater:<version>'
implementation 'com.cmgapps.android:app-rater:3.0.0'
}
```

Expand Down Expand Up @@ -53,7 +45,7 @@ class AppLifecycleListener(private val appRater: AppRater) : LifecycleObserver {
```
and in your main `Activity#onCreate` check if requirements for rating are met and show the dialog

```koltin
```kotlin
override fun onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Expand All @@ -63,13 +55,34 @@ override fun onCreate(savedInstanceState: Bundle) {
mAppRater.show(this)
}
}
```
```

### Kotlin Extension
Add the following dependency to your `build.gradle`.

```groovy
dependencies {
implementation 'com.cmgapps.android:app-rater-ktx:3.0.0'
}
```

You can now configure and create the App Rater using a DSL

```kotlin
override fun onCreate() {
super.onCreate()
val appRater = appRater(this) {
daysUntilPrompt(3)
launchesUntilPrompt(10)
}
}
```

## License

```text
Copyright 2016-2019 Christian Grach
Copyright 2016-2020 Christian Grach
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
Expand Down
55 changes: 12 additions & 43 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask

/*
* Copyright (c) 2019. Christian Grach <christian.grach@cmgapps.com>
*
Expand All @@ -16,21 +14,24 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
* limitations under the License.
*/

import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.gradle.api.tasks.wrapper.Wrapper.DistributionType

buildscript {
repositories {
jcenter()
google()
jcenter()
mavenCentral()

}
dependencies {
classpath("com.android.tools.build:gradle:3.5.1")
classpath("com.android.tools.build:gradle:4.0.1")
classpath(kotlin("gradle-plugin", version = Deps.Versions.KOTLIN))
}
}

plugins {
id("com.github.ben-manes.versions") version "0.25.0"
id("com.github.ben-manes.versions") version "0.29.0"
}

allprojects {
Expand All @@ -41,48 +42,11 @@ allprojects {
}
}


subprojects {
val ktlint by configurations.creating

tasks {
val ktlint by registering(JavaExec::class) {
group = "Verification"
description = "Check Kotlin code style."
main = "com.pinterest.ktlint.Main"
classpath = ktlint
args = listOf(
"src/**/*.kt",
"--reporter=plain",
"--reporter=checkstyle,output=${buildDir}/reports/ktlint.xml"
)

}

afterEvaluate {
named("check") {
dependsOn(ktlint)
}
}

withType<Test> {
testLogging {
events("passed", "skipped", "failed")
}
}
}

dependencies {
ktlint("com.pinterest:ktlint:0.34.2")
}

}

tasks {
withType<DependencyUpdatesTask> {
revision = "release"
rejectVersionIf {
listOf("alpha", "beta", "rc", "cr", "m", "preview", "b", "ea").any { qualifier ->
listOf("alpha", "beta", "rc", "cr", "m", "preview", "b", "ea", "dev").any { qualifier ->
candidate.version.matches(Regex("(?i).*[.-]$qualifier[.\\d-+]*"))
}
}
Expand All @@ -91,6 +55,11 @@ tasks {
register<Delete>("clean") {
delete(rootProject.buildDir)
}

named<Wrapper>("wrapper") {
distributionType = DistributionType.ALL
gradleVersion = "6.5.1"
}
}


7 changes: 2 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ plugins {
}

repositories {
google()
jcenter()
}

dependencies {
implementation(kotlin("stdlib-jdk8", "1.3.50"))
implementation("com.android.tools.build:gradle:3.5.1")
implementation("digital.wup:android-maven-publish:3.6.2")
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
implementation(kotlin("stdlib-jdk8", "1.3.72"))
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
}
2 changes: 2 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

rootProject.name = "App-Rater buildSrc"
34 changes: 34 additions & 0 deletions buildSrc/src/main/kotlin/CredentialsDelegate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2020. Christian Grach <christian.grach@cmgapps.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

import org.gradle.api.Project
import java.io.File
import java.util.Locale
import java.util.Properties
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty

class CredentialsDelegate(propertiesFile: File) : ReadOnlyProperty<Any?, String?> {

private val properties: Properties? = if (propertiesFile.exists()) {
Properties().apply {
load(propertiesFile.inputStream())
}
} else {
null
}

override operator fun getValue(thisRef: Any?, property: KProperty<*>): String? {

if (properties != null) {
return properties.getProperty(property.name)
}

return System.getenv("BINTRAY_${property.name.toUpperCase(Locale.ROOT)}")
}
}

fun Project.credentials() = CredentialsDelegate(rootProject.file("credentials.properties"))
Loading

0 comments on commit 56f6f5c

Please sign in to comment.