Skip to content

Commit

Permalink
Merge pull request #18 from Karn/develop
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
Karn authored Jun 24, 2018
2 parents 13fdbbf + ec491b8 commit 31b99c7
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 76 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
55 changes: 26 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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-alpha14'
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"
}
54 changes: 54 additions & 0 deletions gradle/configuration.gradle
Original file line number Diff line number Diff line change
@@ -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
]
20 changes: 10 additions & 10 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions library/src/main/java/io/karn/notify/entities/Payload.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.graphics.Bitmap
import android.media.RingtoneManager
import android.net.Uri
import android.support.annotation.ColorInt
import android.support.annotation.ColorRes
import android.support.annotation.DrawableRes
import android.support.v4.app.NotificationCompat
import io.karn.notify.Notify
Expand Down Expand Up @@ -129,7 +128,7 @@ sealed class Payload {
/**
* The color of the notification items -- icon, appName, and expand indicator.
*/
@ColorRes var color: Int = R.color.notification_header_color,
@ColorInt var color: Int = 0x4A90E2,
/**
* The optional text that appears next to the appName of a notification.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ internal object NotificationInterop {
// Ensures that this notification is marked as a Notify notification.
.extend(NotifyExtender())
// The color of the RawNotification Icon, App_Name and the expanded chevron.
.setColor(notify.context.resources.getColor(payload.header.color))
.setColor(payload.header.color)
// The RawNotification icon.
.setSmallIcon(payload.header.icon)
// The text that is visible to the right of the app name in the notification header.
Expand Down
4 changes: 0 additions & 4 deletions library/src/main/res/values/colors.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 4 additions & 10 deletions library/src/test/java/io/karn/notify/NotifyHeaderTest.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +10,6 @@ import org.robolectric.RobolectricTestRunner
class NotifyHeaderTest : NotifyTestBase() {

@Test
@Ignore
fun defaultHeaderTest() {
val notification = Notify.with(this.context)
.content {
Expand All @@ -23,17 +21,15 @@ 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))
}

@Test
fun modifiedHeaderTest() {
val testIcon = R.drawable.ic_android_black
val testColor = android.R.color.holo_purple
val testColor = 0xAA66CC
val testHeaderText = "New Menu!"
val testShowTimestamp = false

Expand All @@ -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", context.resources.getColor(testColor, context.theme)),
String.format("#%06X", 0xFFFFFFFF and notification.color.toLong()))
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))
}
Expand Down
3 changes: 2 additions & 1 deletion library/src/test/java/io/karn/notify/NotifyMetaTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
16 changes: 8 additions & 8 deletions library/src/test/java/io/karn/notify/NotifyTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/java/presentation/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() {

Notify.defaultConfig {
header {
color = R.color.colorPrimaryDark
color = resources.getColor(R.color.colorPrimaryDark)
}
alerting(Notify.CHANNEL_DEFAULT_KEY) {
lightColor = Color.RED
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
<color name="colorPrimary">#4A90E2</color>
<color name="colorPrimaryDark">#326299</color>
<color name="colorAccent">#F5A623</color>

<color name="colorBorder">#F2F2F2</color>
</resources>

0 comments on commit 31b99c7

Please sign in to comment.