Skip to content

Commit

Permalink
Structured Android components (and some refactorings) (#111)
Browse files Browse the repository at this point in the history
* Move android components to /android directory

* Opportunistic update to Gradle 4.2.1

* Extract TestAndroidLifecycleScopeProvider to own module, rename

This renames TestAndroidLifecycleScopeProvider to the more appropriate TestLifecycleOwner. Amongst other things, this makes the extensions/common dependencies only part of that artifact and not a part of the mainline artifact

* Opportunistic update kotlin plugin name to newer qualified one

* Switch to static creators for TestLifecycleOwner

* Add autodispose-android-kotlin artifact

* Add autodispose-android-archcomponents-kotlin artifact

* Add autodispose-android-archcomponents-test-kotlin artifact

* arch components rc1

* Build tools 26.0.2

* Add consumer proguard rules for javaxextras

Resolves #112

* Common 1.0.3 + include in archcomponents

This is apparently necessary for generated code

* Make the test use something other than .test for name to avoid conflicts

* Remove manifest, set in defaultConfig instead

* Ignore restricted API warning in generated adapter code

* Add generated adapter to proguard rules in case

* Add convenience Function<Lifecycle.Event, Lifecycle.Event> resolver API

This also simplifies the multiple constructors we had going on

* Update stop check to match slinky behavior

Due to a behavior change, stop events just mean it falls back to "created", which presumably could restart. To match this, I've changed the test to measure this such that if the last even was pause, we don't assume destroy, and actually just stop in onStop like normal

* Remove backfilling from TestLifecycleOwner, as registry handles it now
  • Loading branch information
ZacSweers authored Oct 21, 2017
1 parent 5e00b57 commit b8715fd
Show file tree
Hide file tree
Showing 47 changed files with 617 additions and 82 deletions.
56 changes: 56 additions & 0 deletions android/autodispose-android-archcomponents-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2017. Uber Technologies
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

buildscript {
repositories {
jcenter()
}

dependencies {
classpath deps.build.gradlePlugins.android
classpath deps.build.gradlePlugins.kotlin
}
}

apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android'

android {
compileSdkVersion deps.build.compileSdkVersion
buildToolsVersion deps.build.buildToolsVersion

defaultConfig {
minSdkVersion deps.build.minSdkVersion
targetSdkVersion deps.build.targetSdkVersion
consumerProguardFiles 'consumer-proguard-rules.txt'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}

dependencies {
compile deps.kotlin.stdlib
compile project(':android:autodispose-android-archcomponents')
androidTestCompile project(':test-utils')
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-dontwarn com.uber.javaxextras.**
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (c) 2017. Uber Technologies
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

POM_NAME=AutoDispose (Android Architecture Components Kotlin Extensions)
POM_ARTIFACT_ID=autodispose-android-archcomponents-kotlin
POM_PACKAGING=aar
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
~ Copyright (c) 2017. Uber Technologies
~
~ 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
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<manifest package="com.uber.autodispose.android.lifecycle.kotlin"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2017. Uber Technologies
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress("NOTHING_TO_INLINE")

package com.uber.autodispose.android.lifecycle

import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleOwner
import com.uber.autodispose.LifecycleScopeProvider
import io.reactivex.annotations.CheckReturnValue

/**
* Extension that returns a [LifecycleScopeProvider] for this [LifecycleOwner].
*/
@CheckReturnValue
inline fun LifecycleOwner.scope(): LifecycleScopeProvider<*> = AndroidLifecycleScopeProvider.from(this)

/**
* Extension that returns a [LifecycleScopeProvider] for this [LifecycleOwner].
*
* @param untilEvent the event until the scope is valid.
*/
@CheckReturnValue
inline fun LifecycleOwner.scope(untilEvent: Lifecycle.Event): LifecycleScopeProvider<*>
= AndroidLifecycleScopeProvider.from(this, untilEvent)

/**
* Extension that returns a [LifecycleScopeProvider] for this [Lifecycle].
*/
@CheckReturnValue
inline fun Lifecycle.scope(): LifecycleScopeProvider<*> = AndroidLifecycleScopeProvider.from(this)

/**
* Extension that returns a [LifecycleScopeProvider] for this [Lifecycle].
*
* @param untilEvent the event until the scope is valid.
*/
@CheckReturnValue
inline fun Lifecycle.scope(untilEvent: Lifecycle.Event): LifecycleScopeProvider<*>
= AndroidLifecycleScopeProvider.from(this, untilEvent)
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2017. Uber Technologies
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

buildscript {
repositories {
jcenter()
}

dependencies {
classpath deps.build.gradlePlugins.android
classpath deps.build.gradlePlugins.kotlin
}
}

apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android'

android {
compileSdkVersion deps.build.compileSdkVersion
buildToolsVersion deps.build.buildToolsVersion

defaultConfig {
minSdkVersion deps.build.minSdkVersion
targetSdkVersion deps.build.targetSdkVersion
consumerProguardFiles 'consumer-proguard-rules.txt'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}

dependencies {
compile deps.kotlin.stdlib
compile project(':android:autodispose-android-archcomponents-test')
androidTestCompile project(':test-utils')
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-dontwarn com.uber.javaxextras.**
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (c) 2017. Uber Technologies
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

POM_NAME=AutoDispose (Android Architecture Components Test Kotlin Extensions)
POM_ARTIFACT_ID=autodispose-android-archcomponents-test-kotlin
POM_PACKAGING=aar
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
~ Copyright (c) 2017. Uber Technologies
~
~ 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
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<manifest package="com.uber.autodispose.android.lifecycle.test.kotlin"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2017. Uber Technologies
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress("NOTHING_TO_INLINE")

package com.uber.autodispose.android.lifecycle.test

import android.arch.lifecycle.LifecycleRegistry
import io.reactivex.annotations.CheckReturnValue

/**
* Extension that returns a [TestLifecycleOwner] for this [LifecycleRegistry].
*/
@CheckReturnValue
inline fun LifecycleRegistry.test(): TestLifecycleOwner = TestLifecycleOwner.create(this)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
defaultConfig {
minSdkVersion deps.build.minSdkVersion
targetSdkVersion deps.build.targetSdkVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-proguard-rules.txt'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
Expand All @@ -47,9 +47,9 @@ android {
dependencies {
annotationProcessor deps.build.nullAway
testAnnotationProcessor deps.build.nullAway
annotationProcessor deps.support.arch.lifecycle.compiler

compile project(':autodispose-android')
compile project(':autodispose')
compile deps.support.arch.lifecycle.runtime
compile deps.support.arch.lifecycle.common
compile deps.support.arch.lifecycle.extensions

Expand All @@ -58,10 +58,6 @@ dependencies {

errorprone deps.build.checkerFramework
errorprone deps.build.errorProne

androidTestCompile project(':test-utils')
androidTestCompile deps.test.androidRunner
androidTestCompile deps.test.androidRules
}

tasks.withType(JavaCompile) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-dontwarn com.uber.javaxextras.**
19 changes: 19 additions & 0 deletions android/autodispose-android-archcomponents-test/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (c) 2017. Uber Technologies
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

POM_NAME=AutoDispose (Android Architecture Components Test Extensions)
POM_ARTIFACT_ID=autodispose-android-archcomponents-test
POM_PACKAGING=aar
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
~ Copyright (c) 2017. Uber Technologies
~
~ 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
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<manifest package="com.uber.autodispose.android.lifecycle.test"/>
Loading

0 comments on commit b8715fd

Please sign in to comment.