From 2f7f44205e4500c7f53a6a29318e8c95626c24b0 Mon Sep 17 00:00:00 2001 From: "Corrado, Christopher [ITSUS]" Date: Sun, 7 Apr 2019 14:00:14 -0400 Subject: [PATCH 1/2] Updated to Use Androidx. Added maven upload support. Configure travis. --- .travis.yml | 34 ++++--- CHANGELOG.md | 23 +++++ README.md | 1 + app/build.gradle | 21 +++-- .../prestonsample/ExampleInstrumentedTest.kt | 4 +- .../ccorrads/prestonsample/SampleActivity.kt | 4 +- .../mediacards/MediaViewHolder.kt | 2 +- .../mediacards/SampleRVAdapter.kt | 2 +- app/src/main/res/layout/activity_sample.xml | 6 +- app/src/main/res/layout/card_media_item.xml | 8 +- build.gradle | 12 ++- gradle.properties | 2 + rxPreston/build.gradle | 27 ++++-- rxPreston/maven.gradle | 89 +++++++++++++++++++ .../preston/media/MediaPlaybackService.kt | 2 +- .../preston/media/MediaPlayerObserver.kt | 4 +- 16 files changed, 189 insertions(+), 52 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 rxPreston/maven.gradle diff --git a/.travis.yml b/.travis.yml index 61c572e..5dadcea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,23 +2,33 @@ language: android sudo: required jdk: oraclejdk8 +stages: +- build +- deploy + before_cache: - -rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - -rm -fr $HOME/.gradle/caches/*/plugin-resolution/ + -rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + -rm -fr $HOME/.gradle/caches/*/plugin-resolution/ cache: - directories: - -$HOME/.gradle/caches/ - -$HOME/.gradle/wrapper/ + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ before_install: - - yes | sdkmanager "platforms;android-27" +- yes | sdkmanager "platforms;android-27" before_script: - - chmod +x gradlew - -script: - - "./gradlew clean assembleDebug jacocoTestReport -PdisablePreDex" +- chmod +x gradlew -after_script: -- "java -jar ./codacy-coverage-reporter-4.0.5-assembly.jar report -l Kotlin -r ./rxPreston/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" +jobs: + include: + - stage: 'build' + name: 'Build Stage' + script: "./gradlew clean lint assembleDebug jacocoTestReport -PdisablePreDex" + after_script: "java -jar ./codacy-coverage-reporter-4.0.5-assembly.jar report -l Kotlin -r ./rxPreston/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" + - stage: 'deploy' + skip_cleanup: true + name: 'Deploy Stage' + if: branch = develop + script: "./gradlew install bintrayUpload" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..373e463 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +* No changes since last release + +## [v1.1.0] Initial Maven Release + +### Added +* Added support for maven uploading + +### Modified +* Use Androidx rather than support libraries. +* Made `MediaPlayerObserver.kt` an open class to allow for override. +* Updated dependencies to the latest + +[Unreleased]: https://github.com/CCorrado/Preston/tree/develop +[README]: https://github.com/CCorrado/Preston/tree/master +[v1.1.0]: https://github.com/CCorrado/Preston/tree/1.1.0 \ No newline at end of file diff --git a/README.md b/README.md index b0678bc..04b6585 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Preston is a helpful wrapper around Android's MediaPlayer using RxJava. [![Codacy Badge](https://api.codacy.com/project/badge/Grade/fbf616092167410e95612c6f831f76e4)](https://www.codacy.com/app/CCorrado/Preston?utm_source=github.com&utm_medium=referral&utm_content=CCorrado/Preston&utm_campaign=Badge_Grade) [![Build Status](https://travis-ci.org/CCorrado/Preston.svg?branch=master)](https://travis-ci.org/CCorrado/Preston) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/fbf616092167410e95612c6f831f76e4)](https://www.codacy.com/app/CCorrado/Preston?utm_source=github.com&utm_medium=referral&utm_content=CCorrado/Preston&utm_campaign=Badge_Coverage) +[ ![Download](https://api.bintray.com/packages/ccorrado/ccorrads/preston/images/download.svg) ](https://bintray.com/ccorrado/ccorrads/preston/_latestVersion) ### Why Preston? Android's Media Player is a pain point for a lot of Android Developers. There is a lot to consider. The state diagram of Media Player is tough to follow and hard to handle gracefully. https://developer.android.com/reference/android/media/MediaPlayer.html diff --git a/app/build.gradle b/app/build.gradle index f53cc73..d629ba1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,13 +4,13 @@ apply plugin: 'kotlin-android-extensions' apply from: './jacoco.gradle' android { - compileSdkVersion 28 + compileSdkVersion rootProject.ext.targetSdk defaultConfig { applicationId "com.ccorrads.prestonsample" - minSdkVersion 17 - targetSdkVersion 28 - versionCode 3 - versionName "1.1.0" + minSdkVersion rootProject.ext.minSdk + targetSdkVersion rootProject.ext.targetSdk + versionCode rootProject.ext.versionCode + versionName rootProject.ext.versionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -31,14 +31,13 @@ dependencies { androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "com.android.support:appcompat-v7:$appCompatVersion" - implementation "com.android.support:appcompat-v7:$appCompatVersion" - implementation "com.android.support:design:$appCompatVersion" - implementation "com.android.support:cardview-v7:$appCompatVersion" - implementation "com.android.support:recyclerview-v7:$appCompatVersion" + implementation "androidx.appcompat:appcompat:1.0.2" + implementation "com.google.android.material:material:1.0.0" + implementation "androidx.cardview:cardview:1.0.0" + implementation "androidx.recyclerview:recyclerview:1.0.0" - implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2' //RxJava implementation "io.reactivex.rxjava2:rxandroid:$rxAndroid_version" diff --git a/app/src/androidTest/java/com/ccorrads/prestonsample/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/ccorrads/prestonsample/ExampleInstrumentedTest.kt index e6179b6..f4e97e5 100644 --- a/app/src/androidTest/java/com/ccorrads/prestonsample/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/com/ccorrads/prestonsample/ExampleInstrumentedTest.kt @@ -1,7 +1,7 @@ package com.ccorrads.prestonsample -import android.support.test.InstrumentationRegistry -import android.support.test.runner.AndroidJUnit4 +import androidx.test.InstrumentationRegistry +import androidx.test.runner.AndroidJUnit4 import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/main/java/com/ccorrads/prestonsample/SampleActivity.kt b/app/src/main/java/com/ccorrads/prestonsample/SampleActivity.kt index 4bc44e3..eba0d32 100644 --- a/app/src/main/java/com/ccorrads/prestonsample/SampleActivity.kt +++ b/app/src/main/java/com/ccorrads/prestonsample/SampleActivity.kt @@ -1,8 +1,8 @@ package com.ccorrads.prestonsample import android.os.Bundle -import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.LinearLayoutManager +import androidx.appcompat.app.AppCompatActivity +import androidx.recyclerview.widget.LinearLayoutManager import com.ccorrads.prestonsample.mediacards.MediaItem import com.ccorrads.prestonsample.mediacards.SampleRVAdapter import kotlinx.android.synthetic.main.activity_sample.* diff --git a/app/src/main/java/com/ccorrads/prestonsample/mediacards/MediaViewHolder.kt b/app/src/main/java/com/ccorrads/prestonsample/mediacards/MediaViewHolder.kt index df43cdf..a0c72e6 100644 --- a/app/src/main/java/com/ccorrads/prestonsample/mediacards/MediaViewHolder.kt +++ b/app/src/main/java/com/ccorrads/prestonsample/mediacards/MediaViewHolder.kt @@ -1,6 +1,6 @@ package com.ccorrads.prestonsample.mediacards -import android.support.v7.widget.RecyclerView import android.view.View +import androidx.recyclerview.widget.RecyclerView class MediaViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) \ No newline at end of file diff --git a/app/src/main/java/com/ccorrads/prestonsample/mediacards/SampleRVAdapter.kt b/app/src/main/java/com/ccorrads/prestonsample/mediacards/SampleRVAdapter.kt index 4a558c4..da276e3 100644 --- a/app/src/main/java/com/ccorrads/prestonsample/mediacards/SampleRVAdapter.kt +++ b/app/src/main/java/com/ccorrads/prestonsample/mediacards/SampleRVAdapter.kt @@ -1,9 +1,9 @@ package com.ccorrads.prestonsample.mediacards import android.content.Context -import android.support.v7.widget.RecyclerView import android.view.LayoutInflater import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView import com.ccorrads.preston.media.MediaPlaybackService import com.ccorrads.preston.media.MediaPlayerObserver import com.ccorrads.prestonsample.R diff --git a/app/src/main/res/layout/activity_sample.xml b/app/src/main/res/layout/activity_sample.xml index e2e283a..2a81a32 100644 --- a/app/src/main/res/layout/activity_sample.xml +++ b/app/src/main/res/layout/activity_sample.xml @@ -1,14 +1,14 @@ - - - + diff --git a/app/src/main/res/layout/card_media_item.xml b/app/src/main/res/layout/card_media_item.xml index f4e81e7..7b7a868 100644 --- a/app/src/main/res/layout/card_media_item.xml +++ b/app/src/main/res/layout/card_media_item.xml @@ -1,10 +1,10 @@ - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index ac93d72..b8fec62 100644 --- a/build.gradle +++ b/build.gradle @@ -7,9 +7,10 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.1' + classpath 'com.android.tools.build:gradle:3.3.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -19,12 +20,15 @@ allprojects { repositories { google() jcenter() + mavenCentral() } ext { - appCompatVersion = "28.0.0" minSdk = 17 + targetSdk = 28 + versionCode = 3 + versionName = "1.1.0" gson_version = "2.8.0" - rxJava_version = "2.1.3" + rxJava_version = "2.2.8" rxAndroid_version = "2.1.1" okhttp_version = "3.7.0" joda_version = "2.9.9" diff --git a/gradle.properties b/gradle.properties index 743d692..dc251f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,3 +11,5 @@ org.gradle.jvmargs=-Xmx1536m # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file diff --git a/rxPreston/build.gradle b/rxPreston/build.gradle index 11b36a3..2cc270f 100644 --- a/rxPreston/build.gradle +++ b/rxPreston/build.gradle @@ -1,15 +1,18 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' +apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'com.jfrog.bintray' apply from: './jacoco.gradle' +apply from: './maven.gradle' android { - compileSdkVersion 28 + compileSdkVersion rootProject.ext.targetSdk defaultConfig { - minSdkVersion 17 - targetSdkVersion 28 - versionCode 3 - versionName "1.1.0" + minSdkVersion rootProject.ext.minSdk + targetSdkVersion rootProject.ext.targetSdk + versionCode rootProject.ext.versionCode + versionName rootProject.ext.versionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } @@ -33,7 +36,6 @@ android { includeAndroidResources = true } } - } dependencies { @@ -42,11 +44,18 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "com.android.support:appcompat-v7:${appCompatVersion}" + implementation "androidx.appcompat:appcompat:1.0.2" + //RxJava implementation "io.reactivex.rxjava2:rxandroid:$rxAndroid_version" implementation "io.reactivex.rxjava2:rxjava:$rxJava_version" } -repositories { - mavenCentral() + +task sourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs } + +artifacts { + archives sourcesJar +} \ No newline at end of file diff --git a/rxPreston/maven.gradle b/rxPreston/maven.gradle new file mode 100644 index 0000000..3f3b588 --- /dev/null +++ b/rxPreston/maven.gradle @@ -0,0 +1,89 @@ +ext { + bintrayRepo = 'ccorrads' + bintrayName = 'preston' + + publishedGroupId = 'com.ccorrads' + libraryName = 'preston' + artifact = 'rxPreston' + + libraryDescription = 'Preston is a helpful wrapper around Android\'s MediaPlayer using RxJava.' + + siteUrl = 'https://github.com/CCorrado/Preston' + gitUrl = 'https://github.com/CCorrado/Preston.git' + + libraryVersion = rootProject.ext.versionName + + developerId = 'ccorrado' + developerName = 'Chris Corrado' + developerEmail = 'ccorrads@gmail.com' + + licenseName = 'The Apache Software License, Version 2.0' + licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + allLicenses = ["Apache-2.0"] +} + +bintray { + def ENV = System.getenv() + Properties properties = new Properties() + try { + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + } catch (err) { + //no-op + } + + user = ENV["BINTRAY_USER"] ?: properties.getProperty("bintray.user") + key = ENV["BINTRAY_KEY"] ?: properties.getProperty("bintray.apikey") + + configurations = ['archives'] + pkg { + repo = bintrayRepo + name = bintrayName + desc = libraryDescription + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = allLicenses + dryRun = false + publish = true + override = false + publicDownloadNumbers = true + version { + desc = libraryDescription + } + } +} + +group = publishedGroupId +version = libraryVersion + +install { + repositories.mavenInstaller { + pom.project { + packaging 'aar' + groupId publishedGroupId + artifactId artifact + + name libraryName + description libraryDescription + url siteUrl + + licenses { + license { + name licenseName + url licenseUrl + } + } + developers { + developer { + id developerId + name developerName + email developerEmail + } + } + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + } + } + } +} diff --git a/rxPreston/src/main/java/com/ccorrads/preston/media/MediaPlaybackService.kt b/rxPreston/src/main/java/com/ccorrads/preston/media/MediaPlaybackService.kt index e4cf744..81c9ae1 100644 --- a/rxPreston/src/main/java/com/ccorrads/preston/media/MediaPlaybackService.kt +++ b/rxPreston/src/main/java/com/ccorrads/preston/media/MediaPlaybackService.kt @@ -2,7 +2,7 @@ package com.ccorrads.preston.media import android.content.Context import android.media.MediaPlayer -import android.support.annotation.VisibleForTesting +import androidx.annotation.VisibleForTesting import com.ccorrads.preston.models.MediaPlayerState import io.reactivex.Observable import io.reactivex.ObservableEmitter diff --git a/rxPreston/src/main/java/com/ccorrads/preston/media/MediaPlayerObserver.kt b/rxPreston/src/main/java/com/ccorrads/preston/media/MediaPlayerObserver.kt index 824c893..58ad9a8 100644 --- a/rxPreston/src/main/java/com/ccorrads/preston/media/MediaPlayerObserver.kt +++ b/rxPreston/src/main/java/com/ccorrads/preston/media/MediaPlayerObserver.kt @@ -10,9 +10,9 @@ import android.media.AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK import android.media.AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK import android.media.MediaPlayer import android.os.Build -import android.support.annotation.VisibleForTesting import android.text.TextUtils import android.util.Log +import androidx.annotation.VisibleForTesting import com.ccorrads.preston.models.MediaPlayerState import io.reactivex.Observer import io.reactivex.disposables.Disposable @@ -22,7 +22,7 @@ import java.io.Serializable /** * Observer to subscribe to when needing to play a media file. */ -class MediaPlayerObserver : Observer, Serializable { +open class MediaPlayerObserver : Observer, Serializable { @Transient @VisibleForTesting From a11efe5f059bb3156a743fe9c9c428dc4d7d3c30 Mon Sep 17 00:00:00 2001 From: "Corrado, Christopher [ITSUS]" Date: Mon, 8 Apr 2019 14:22:49 -0400 Subject: [PATCH 2/2] Fix javadoc --- rxPreston/build.gradle | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rxPreston/build.gradle b/rxPreston/build.gradle index 2cc270f..eebdc89 100644 --- a/rxPreston/build.gradle +++ b/rxPreston/build.gradle @@ -51,11 +51,26 @@ dependencies { implementation "io.reactivex.rxjava2:rxjava:$rxJava_version" } +tasks.withType(Javadoc).all { + enabled = false +} + task sourcesJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + artifacts { + archives javadocJar archives sourcesJar } \ No newline at end of file