From ec491b8ff248f3e3fc84a63baa8dcd1615a52c34 Mon Sep 17 00:00:00 2001 From: Karn Saheb Date: Sun, 24 Jun 2018 00:14:34 -0400 Subject: [PATCH] Dependency upgrade. (#17) --- README.md | 4 +- build.gradle | 55 +++++++++---------- gradle/configuration.gradle | 54 ++++++++++++++++++ library/build.gradle | 20 +++---- library/src/main/res/values/colors.xml | 4 -- .../karn/notify/NotificationInterlopTest.kt | 2 +- .../java/io/karn/notify/NotifyHeaderTest.kt | 12 +--- .../java/io/karn/notify/NotifyMetaTest.kt | 3 +- .../test/java/io/karn/notify/NotifyTest.kt | 16 +++--- sample/build.gradle | 17 +++--- sample/src/main/res/values/colors.xml | 2 + 11 files changed, 118 insertions(+), 71 deletions(-) create mode 100644 gradle/configuration.gradle delete mode 100644 library/src/main/res/values/colors.xml diff --git a/README.md b/README.md index 117a6a7..77a0c74 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ ## Notify Simplified notification delivery for Android. -[![Kotlin](https://img.shields.io/badge/Kotlin-1.2.21-blue.svg?style=flat-square)](http://kotlinlang.org) -[![RxJava](https://img.shields.io/badge/Support-27.1.0-6ab344.svg?style=flat-square)](https://github.com/ReactiveX/RxJava/releases/tag/v2.1.10) +[![Kotlin](https://img.shields.io/badge/Kotlin-1.2.41-blue.svg?style=flat-square)](http://kotlinlang.org) +[![RxJava](https://img.shields.io/badge/Support-27.1.1-6ab344.svg?style=flat-square)](https://github.com/ReactiveX/RxJava/releases/tag/v2.1.10) [![Build Status](https://img.shields.io/travis/Karn/notify.svg?style=flat-square)](https://travis-ci.org/Karn/notify) [![Codecov](https://img.shields.io/codecov/c/github/karn/notify.svg?style=flat-square)](https://codecov.io/gh/Karn/notify) [![GitHub (pre-)release](https://img.shields.io/github/release/karn/notify/all.svg?style=flat-square) diff --git a/build.gradle b/build.gradle index 3e678e4..99361be 100644 --- a/build.gradle +++ b/build.gradle @@ -2,42 +2,39 @@ group = 'io.karn' version = '0.0.1' -buildscript { - ext.kotlin_version = '1.2.21' - - ext { - kotlin_version = '1.2.21' - support_version = '27.1.1' - - dokka_version = '0.9.16' +subprojects { + apply from: rootProject.file('gradle/configuration.gradle') + + buildscript { + + repositories { + google() + jcenter() + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + } + + dependencies { + classpath config.build.gradle.androidPlugin + classpath config.build.gradle.kotlin + + // NOTE: Do not place your application configuration here; they belong + // in the individual module build.gradle files + classpath config.build.gradle.androidMaven + // Code coverage + classpath config.build.gradle.jacoco + // Library documentation + classpath config.build.gradle.dokka + } } repositories { google() jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:3.2.0-alpha17' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' - // Code coverage - classpath 'org.jacoco:org.jacoco.core:0.8.0' - // Library documentation - classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version" - } -} - -allprojects { - repositories { - google() - jcenter() + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } } task wrapper(type: Wrapper) { - gradleVersion = '4.6' + gradleVersion = '4.7' + distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } diff --git a/gradle/configuration.gradle b/gradle/configuration.gradle new file mode 100644 index 0000000..ce9245e --- /dev/null +++ b/gradle/configuration.gradle @@ -0,0 +1,54 @@ +/* + * Notify Configuration. + * + * Format adapted from Uber's AutoDispose library. + * https://github.com/uber/AutoDispose/blob/7ab7958914699a7a72e43bc1399dfa66ade227cb/gradle/dependencies.gradle + */ + + +def versions = [ + kotlin: '1.2.41', + support: '27.1.1', + + jacoco: '0.8.2-SNAPSHOT', + dokka: '0.9.17' +] + +def build = [ + compileSdk: 27, + targetSdk: 27, + minSdk: 19, + + jacocoAgentVersion: versions.jacoco, + + gradle: [ + androidPlugin: 'com.android.tools.build:gradle:3.2.0-alpha18', + androidMaven: 'com.github.dcendents:android-maven-gradle-plugin:2.0', + kotlin: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}", + jacoco: "org.jacoco:org.jacoco.core:${versions.jacoco}", + dokka: "org.jetbrains.dokka:dokka-android-gradle-plugin:${versions.dokka}" + ] +] + +def dependencies = [ + kotlin: [ + stdlib : "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}", + reflect: "org.jetbrains.kotlin:kotlin-reflect:${versions.kotlin}" + ], + support: [ + compat: "com.android.support:support-compat:${versions.support}", + appcompat: "com.android.support:appcompat-v7:${versions.support}" + ] +] + +def testDependencies = [ + instrumentationRunner: 'android.support.test.runner.AndroidJUnitRunner', + junit: 'junit:junit:4.12', + robolectric: 'org.robolectric:robolectric:3.8' +] + +ext.config = [ + "deps" : dependencies, + "testDeps": testDependencies, + "build" : build +] diff --git a/library/build.gradle b/library/build.gradle index c5b6ebf..737c222 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -7,15 +7,16 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'jacoco' android { - compileSdkVersion 27 + compileSdkVersion config.build.compileSdk defaultConfig { - minSdkVersion 19 - targetSdkVersion 27 + targetSdkVersion config.build.targetSdk + minSdkVersion config.build.minSdk + versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner config.testDeps.instrumentationRunner } buildTypes { @@ -52,20 +53,19 @@ allprojects { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + implementation config.deps.kotlin.stdlib - implementation "com.android.support:support-compat:$support_version" + implementation config.deps.support.compat // android.support.v4.media.app.NotificationCompat.MediaStyle() // implementation "com.android.support:support-media-compat:$support_version" - testImplementation 'junit:junit:4.12' - testImplementation "org.robolectric:robolectric:3.8" + testImplementation config.testDeps.junit + testImplementation config.testDeps.robolectric } jacoco { - toolVersion = '0.8.0' + toolVersion = config.build.jacocoAgentVersion } tasks.withType(Test) { diff --git a/library/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml deleted file mode 100644 index e073b04..0000000 --- a/library/src/main/res/values/colors.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #4A90E2 - diff --git a/library/src/test/java/io/karn/notify/NotificationInterlopTest.kt b/library/src/test/java/io/karn/notify/NotificationInterlopTest.kt index 8b50b6a..50f9415 100644 --- a/library/src/test/java/io/karn/notify/NotificationInterlopTest.kt +++ b/library/src/test/java/io/karn/notify/NotificationInterlopTest.kt @@ -3,8 +3,8 @@ package io.karn.notify import android.os.Build import android.support.v4.app.NotificationCompat import io.karn.notify.internal.NotificationInterop -import junit.framework.Assert import org.junit.After +import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner diff --git a/library/src/test/java/io/karn/notify/NotifyHeaderTest.kt b/library/src/test/java/io/karn/notify/NotifyHeaderTest.kt index 0725ece..b9f7483 100644 --- a/library/src/test/java/io/karn/notify/NotifyHeaderTest.kt +++ b/library/src/test/java/io/karn/notify/NotifyHeaderTest.kt @@ -1,8 +1,7 @@ package io.karn.notify import android.support.v4.app.NotificationCompat -import junit.framework.Assert -import org.junit.Ignore +import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -11,7 +10,6 @@ import org.robolectric.RobolectricTestRunner class NotifyHeaderTest : NotifyTestBase() { @Test - @Ignore fun defaultHeaderTest() { val notification = Notify.with(this.context) .content { @@ -23,9 +21,7 @@ class NotifyHeaderTest : NotifyTestBase() { Assert.assertEquals(context.resources.getDrawable(R.drawable.ic_app_icon, context.theme), notification.smallIcon.loadDrawable(context)) // Validating color is not reliable. The notification color is randomly returned as ##FFAAAAAA - Assert.assertEquals( - String.format("#%06X", context.resources.getColor(R.color.notification_header_color, context.theme)), - String.format("#%06X", 0xFFFFFFFF and notification.color.toLong())) + Assert.assertEquals(0x4A90E2, 0xFFFFFF and notification.color) Assert.assertEquals(null, notification.extras.getCharSequence(NotificationCompat.EXTRA_SUB_TEXT)) Assert.assertTrue(notification.extras.getBoolean(NotificationCompat.EXTRA_SHOW_WHEN)) } @@ -52,9 +48,7 @@ class NotifyHeaderTest : NotifyTestBase() { .build() Assert.assertEquals(context.resources.getDrawable(testIcon, context.theme), notification.smallIcon.loadDrawable(context)) - Assert.assertEquals( - String.format("#%06X", testColor), - String.format("#%06X", 0xFFFFFF and notification.color)) + Assert.assertEquals(testColor, 0xFFFFFF and notification.color) Assert.assertEquals(testHeaderText, notification.extras.getCharSequence(NotificationCompat.EXTRA_SUB_TEXT)) Assert.assertEquals(testShowTimestamp, notification.extras.getBoolean(NotificationCompat.EXTRA_SHOW_WHEN)) } diff --git a/library/src/test/java/io/karn/notify/NotifyMetaTest.kt b/library/src/test/java/io/karn/notify/NotifyMetaTest.kt index b398e16..11b4e11 100644 --- a/library/src/test/java/io/karn/notify/NotifyMetaTest.kt +++ b/library/src/test/java/io/karn/notify/NotifyMetaTest.kt @@ -60,6 +60,7 @@ class NotifyMetaTest : NotifyTestBase() { Assert.assertEquals(testCancelOnClick, (notification.flags and NotificationCompat.FLAG_AUTO_CANCEL) != 0) Assert.assertEquals(testCategory, notification.category) Assert.assertEquals(testTimeout, notification.timeoutAfter) - Assert.assertEquals(1, notification.extras.getStringArray(NotificationCompat.EXTRA_PEOPLE)?.size ?: 0) + Assert.assertEquals(1, notification.extras.getStringArray(NotificationCompat.EXTRA_PEOPLE)?.size + ?: 0) } } diff --git a/library/src/test/java/io/karn/notify/NotifyTest.kt b/library/src/test/java/io/karn/notify/NotifyTest.kt index e0d39ec..3565a8c 100644 --- a/library/src/test/java/io/karn/notify/NotifyTest.kt +++ b/library/src/test/java/io/karn/notify/NotifyTest.kt @@ -4,7 +4,7 @@ import android.graphics.Color import android.media.RingtoneManager import android.support.v4.app.NotificationCompat import io.karn.notify.internal.NotificationInterop -import junit.framework.Assert +import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -54,14 +54,14 @@ class NotifyTest : NotifyTestBase() { rawNotification.show() val shadowChannel = shadowNotificationManager.getNotificationChannel(testChannelKey) - org.junit.Assert.assertNotNull(shadowChannel) - org.junit.Assert.assertEquals(testVisibility, shadowChannel.lockscreenVisibility) - org.junit.Assert.assertEquals(testChannelName, shadowChannel.name) - org.junit.Assert.assertEquals(testChannelDescription, shadowChannel.description) - org.junit.Assert.assertEquals(testChannelImportance + 2, shadowChannel.importance) + Assert.assertNotNull(shadowChannel) + Assert.assertEquals(testVisibility, shadowChannel.lockscreenVisibility) + Assert.assertEquals(testChannelName, shadowChannel.name) + Assert.assertEquals(testChannelDescription, shadowChannel.description) + Assert.assertEquals(testChannelImportance + 2, shadowChannel.importance) // Assert.assertEquals(testLightColor, shadowChannel.lightColor) - org.junit.Assert.assertEquals(testVibrationPattern, shadowChannel.vibrationPattern.toList()) - org.junit.Assert.assertEquals(testSound, shadowChannel.sound) + Assert.assertEquals(testVibrationPattern, shadowChannel.vibrationPattern.toList()) + Assert.assertEquals(testSound, shadowChannel.sound) } @Test diff --git a/sample/build.gradle b/sample/build.gradle index 72d6a89..ff515c9 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -3,24 +3,27 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 27 + compileSdkVersion config.build.compileSdk defaultConfig { - applicationId "io.karn.notify.sample" + targetSdkVersion config.build.targetSdk minSdkVersion 21 - targetSdkVersion 27 + + applicationId "io.karn.notify.sample" versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner config.testDeps.instrumentationRunner } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" - implementation "com.android.support:appcompat-v7:$support_version" - implementation "com.android.support:support-compat:$support_version" + + implementation config.deps.kotlin.stdlib + + implementation config.deps.support.compat + implementation config.deps.support.appcompat implementation project(path: ':library') } diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml index 1f96610..2b6efee 100644 --- a/sample/src/main/res/values/colors.xml +++ b/sample/src/main/res/values/colors.xml @@ -3,4 +3,6 @@ #4A90E2 #326299 #F5A623 + + #F2F2F2