From b8715fd42937dcc742d9022eed7910ff7cf81ca2 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Fri, 20 Oct 2017 21:06:54 -0700 Subject: [PATCH] Structured Android components (and some refactorings) (#111) * 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 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 --- .../build.gradle | 56 +++++++++++++ .../consumer-proguard-rules.txt | 1 + .../gradle.properties | 19 +++++ .../src/main/AndroidManifest.xml | 17 ++++ .../lifecycle/autodisposeAndroidLifecycle.kt | 54 +++++++++++++ .../build.gradle | 56 +++++++++++++ .../consumer-proguard-rules.txt | 1 + .../gradle.properties | 19 +++++ .../src/main/AndroidManifest.xml | 17 ++++ .../test/autodisposeAndroidLifecycleTest.kt | 28 +++++++ .../build.gradle | 10 +-- .../consumer-proguard-rules.txt | 1 + .../gradle.properties | 19 +++++ .../src/main/AndroidManifest.xml | 17 ++++ .../lifecycle/test/TestLifecycleOwner.java | 37 +++------ .../build.gradle | 78 +++++++++++++++++++ .../consumer-proguard-rules.txt | 2 + .../gradle.properties | 0 .../lint.xml | 22 ++++++ .../AndroidLifecycleScopeProviderTest.java | 63 ++++++++------- .../src/main/AndroidManifest.xml | 0 .../AndroidLifecycleScopeProvider.java | 31 +++++--- .../lifecycle/LifecycleEventsObservable.java | 0 .../android/lifecycle/package-info.java | 0 .../autodispose-android-kotlin/build.gradle | 56 +++++++++++++ .../consumer-proguard-rules.txt | 1 + .../gradle.properties | 19 +++++ .../src/main/AndroidManifest.xml | 17 ++++ .../autodispose/android/autodisposeAndroid.kt | 29 +++++++ .../autodispose-android}/build.gradle | 1 + .../consumer-proguard-rules.txt | 1 + .../autodispose-android}/gradle.properties | 0 .../src/androidTest/AndroidManifest.xml | 0 .../android/AutoDisposeTestActivity.java | 0 .../android/ViewScopeProviderTest.java | 0 .../src/main/AndroidManifest.xml | 0 .../android/ViewAttachEventsObservable.java | 0 .../android/ViewLifecycleEvent.java | 0 .../android/ViewScopeProvider.java | 0 .../internal/AutoDisposeAndroidUtil.java | 0 .../autodispose/android/package-info.java | 0 autodispose-kotlin/build.gradle | 2 +- build.gradle | 2 +- gradle/dependencies.gradle | 9 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- sample/build.gradle | 4 +- settings.gradle | 8 +- 47 files changed, 617 insertions(+), 82 deletions(-) create mode 100644 android/autodispose-android-archcomponents-kotlin/build.gradle create mode 100644 android/autodispose-android-archcomponents-kotlin/consumer-proguard-rules.txt create mode 100755 android/autodispose-android-archcomponents-kotlin/gradle.properties create mode 100755 android/autodispose-android-archcomponents-kotlin/src/main/AndroidManifest.xml create mode 100644 android/autodispose-android-archcomponents-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/autodisposeAndroidLifecycle.kt create mode 100644 android/autodispose-android-archcomponents-test-kotlin/build.gradle create mode 100644 android/autodispose-android-archcomponents-test-kotlin/consumer-proguard-rules.txt create mode 100755 android/autodispose-android-archcomponents-test-kotlin/gradle.properties create mode 100755 android/autodispose-android-archcomponents-test-kotlin/src/main/AndroidManifest.xml create mode 100644 android/autodispose-android-archcomponents-test-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/test/autodisposeAndroidLifecycleTest.kt rename {autodispose-android-archcomponents => android/autodispose-android-archcomponents-test}/build.gradle (85%) create mode 100644 android/autodispose-android-archcomponents-test/consumer-proguard-rules.txt create mode 100755 android/autodispose-android-archcomponents-test/gradle.properties create mode 100755 android/autodispose-android-archcomponents-test/src/main/AndroidManifest.xml rename autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/TestAndroidLifecycleScopeProvider.java => android/autodispose-android-archcomponents-test/src/main/java/com/uber/autodispose/android/lifecycle/test/TestLifecycleOwner.java (61%) create mode 100644 android/autodispose-android-archcomponents/build.gradle create mode 100644 android/autodispose-android-archcomponents/consumer-proguard-rules.txt rename {autodispose-android-archcomponents => android/autodispose-android-archcomponents}/gradle.properties (100%) create mode 100644 android/autodispose-android-archcomponents/lint.xml rename {autodispose-android-archcomponents => android/autodispose-android-archcomponents}/src/androidTest/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProviderTest.java (90%) rename {autodispose-android-archcomponents => android/autodispose-android-archcomponents}/src/main/AndroidManifest.xml (100%) rename {autodispose-android-archcomponents => android/autodispose-android-archcomponents}/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java (82%) rename {autodispose-android-archcomponents => android/autodispose-android-archcomponents}/src/main/java/com/uber/autodispose/android/lifecycle/LifecycleEventsObservable.java (100%) rename {autodispose-android-archcomponents => android/autodispose-android-archcomponents}/src/main/java/com/uber/autodispose/android/lifecycle/package-info.java (100%) create mode 100644 android/autodispose-android-kotlin/build.gradle create mode 100644 android/autodispose-android-kotlin/consumer-proguard-rules.txt create mode 100755 android/autodispose-android-kotlin/gradle.properties create mode 100755 android/autodispose-android-kotlin/src/main/AndroidManifest.xml create mode 100644 android/autodispose-android-kotlin/src/main/kotlin/com/uber/autodispose/android/autodisposeAndroid.kt rename {autodispose-android => android/autodispose-android}/build.gradle (97%) create mode 100644 android/autodispose-android/consumer-proguard-rules.txt rename {autodispose-android => android/autodispose-android}/gradle.properties (100%) rename {autodispose-android => android/autodispose-android}/src/androidTest/AndroidManifest.xml (100%) rename {autodispose-android => android/autodispose-android}/src/androidTest/java/com/uber/autodispose/android/AutoDisposeTestActivity.java (100%) rename {autodispose-android => android/autodispose-android}/src/androidTest/java/com/uber/autodispose/android/ViewScopeProviderTest.java (100%) rename {autodispose-android => android/autodispose-android}/src/main/AndroidManifest.xml (100%) rename {autodispose-android => android/autodispose-android}/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java (100%) rename {autodispose-android => android/autodispose-android}/src/main/java/com/uber/autodispose/android/ViewLifecycleEvent.java (100%) rename {autodispose-android => android/autodispose-android}/src/main/java/com/uber/autodispose/android/ViewScopeProvider.java (100%) rename {autodispose-android => android/autodispose-android}/src/main/java/com/uber/autodispose/android/internal/AutoDisposeAndroidUtil.java (100%) rename {autodispose-android => android/autodispose-android}/src/main/java/com/uber/autodispose/android/package-info.java (100%) diff --git a/android/autodispose-android-archcomponents-kotlin/build.gradle b/android/autodispose-android-archcomponents-kotlin/build.gradle new file mode 100644 index 000000000..a8b0dbbd1 --- /dev/null +++ b/android/autodispose-android-archcomponents-kotlin/build.gradle @@ -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') diff --git a/android/autodispose-android-archcomponents-kotlin/consumer-proguard-rules.txt b/android/autodispose-android-archcomponents-kotlin/consumer-proguard-rules.txt new file mode 100644 index 000000000..405893e1b --- /dev/null +++ b/android/autodispose-android-archcomponents-kotlin/consumer-proguard-rules.txt @@ -0,0 +1 @@ +-dontwarn com.uber.javaxextras.** diff --git a/android/autodispose-android-archcomponents-kotlin/gradle.properties b/android/autodispose-android-archcomponents-kotlin/gradle.properties new file mode 100755 index 000000000..a82855164 --- /dev/null +++ b/android/autodispose-android-archcomponents-kotlin/gradle.properties @@ -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 diff --git a/android/autodispose-android-archcomponents-kotlin/src/main/AndroidManifest.xml b/android/autodispose-android-archcomponents-kotlin/src/main/AndroidManifest.xml new file mode 100755 index 000000000..40990fa1a --- /dev/null +++ b/android/autodispose-android-archcomponents-kotlin/src/main/AndroidManifest.xml @@ -0,0 +1,17 @@ + + + diff --git a/android/autodispose-android-archcomponents-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/autodisposeAndroidLifecycle.kt b/android/autodispose-android-archcomponents-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/autodisposeAndroidLifecycle.kt new file mode 100644 index 000000000..d9e5f7bcc --- /dev/null +++ b/android/autodispose-android-archcomponents-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/autodisposeAndroidLifecycle.kt @@ -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) diff --git a/android/autodispose-android-archcomponents-test-kotlin/build.gradle b/android/autodispose-android-archcomponents-test-kotlin/build.gradle new file mode 100644 index 000000000..f9dd5aeef --- /dev/null +++ b/android/autodispose-android-archcomponents-test-kotlin/build.gradle @@ -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') diff --git a/android/autodispose-android-archcomponents-test-kotlin/consumer-proguard-rules.txt b/android/autodispose-android-archcomponents-test-kotlin/consumer-proguard-rules.txt new file mode 100644 index 000000000..405893e1b --- /dev/null +++ b/android/autodispose-android-archcomponents-test-kotlin/consumer-proguard-rules.txt @@ -0,0 +1 @@ +-dontwarn com.uber.javaxextras.** diff --git a/android/autodispose-android-archcomponents-test-kotlin/gradle.properties b/android/autodispose-android-archcomponents-test-kotlin/gradle.properties new file mode 100755 index 000000000..4c73e7bf6 --- /dev/null +++ b/android/autodispose-android-archcomponents-test-kotlin/gradle.properties @@ -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 diff --git a/android/autodispose-android-archcomponents-test-kotlin/src/main/AndroidManifest.xml b/android/autodispose-android-archcomponents-test-kotlin/src/main/AndroidManifest.xml new file mode 100755 index 000000000..5360c6cce --- /dev/null +++ b/android/autodispose-android-archcomponents-test-kotlin/src/main/AndroidManifest.xml @@ -0,0 +1,17 @@ + + + diff --git a/android/autodispose-android-archcomponents-test-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/test/autodisposeAndroidLifecycleTest.kt b/android/autodispose-android-archcomponents-test-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/test/autodisposeAndroidLifecycleTest.kt new file mode 100644 index 000000000..0fab73d0a --- /dev/null +++ b/android/autodispose-android-archcomponents-test-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/test/autodisposeAndroidLifecycleTest.kt @@ -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) diff --git a/autodispose-android-archcomponents/build.gradle b/android/autodispose-android-archcomponents-test/build.gradle similarity index 85% rename from autodispose-android-archcomponents/build.gradle rename to android/autodispose-android-archcomponents-test/build.gradle index 3cfb9aba2..eee787691 100644 --- a/autodispose-android-archcomponents/build.gradle +++ b/android/autodispose-android-archcomponents-test/build.gradle @@ -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 @@ -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 @@ -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) { diff --git a/android/autodispose-android-archcomponents-test/consumer-proguard-rules.txt b/android/autodispose-android-archcomponents-test/consumer-proguard-rules.txt new file mode 100644 index 000000000..405893e1b --- /dev/null +++ b/android/autodispose-android-archcomponents-test/consumer-proguard-rules.txt @@ -0,0 +1 @@ +-dontwarn com.uber.javaxextras.** diff --git a/android/autodispose-android-archcomponents-test/gradle.properties b/android/autodispose-android-archcomponents-test/gradle.properties new file mode 100755 index 000000000..c23c23b9f --- /dev/null +++ b/android/autodispose-android-archcomponents-test/gradle.properties @@ -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 diff --git a/android/autodispose-android-archcomponents-test/src/main/AndroidManifest.xml b/android/autodispose-android-archcomponents-test/src/main/AndroidManifest.xml new file mode 100755 index 000000000..b0a57bd8f --- /dev/null +++ b/android/autodispose-android-archcomponents-test/src/main/AndroidManifest.xml @@ -0,0 +1,17 @@ + + + diff --git a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/TestAndroidLifecycleScopeProvider.java b/android/autodispose-android-archcomponents-test/src/main/java/com/uber/autodispose/android/lifecycle/test/TestLifecycleOwner.java similarity index 61% rename from autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/TestAndroidLifecycleScopeProvider.java rename to android/autodispose-android-archcomponents-test/src/main/java/com/uber/autodispose/android/lifecycle/test/TestLifecycleOwner.java index 2ca1e1fbf..f2380d39e 100644 --- a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/TestAndroidLifecycleScopeProvider.java +++ b/android/autodispose-android-archcomponents-test/src/main/java/com/uber/autodispose/android/lifecycle/test/TestLifecycleOwner.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.uber.autodispose.android.lifecycle; +package com.uber.autodispose.android.lifecycle.test; import android.arch.lifecycle.Lifecycle; import android.arch.lifecycle.LifecycleOwner; @@ -25,25 +25,29 @@ import static android.support.annotation.RestrictTo.Scope.TESTS; /** - * {@link AndroidLifecycleScopeProvider} implementation for testing. You can either back it with + * A test {@link LifecycleOwner} implementation for testing. You can either back it with * your own instance or just stub it in place and use its public emit() API. */ -@RestrictTo(TESTS) public final class TestAndroidLifecycleScopeProvider implements LifecycleOwner { +@RestrictTo(TESTS) public final class TestLifecycleOwner implements LifecycleOwner { private final LifecycleRegistry registry; /** - * Default constructor, creates and maintains its own {@link LifecycleRegistry} under the hood. + * Default creator. Creates and maintains its own {@link LifecycleRegistry} under the hood. */ - public TestAndroidLifecycleScopeProvider() { - this(null); + public static TestLifecycleOwner create() { + return new TestLifecycleOwner(null); } /** * @param registry an optional custom {@link LifecycleRegistry} if you want to provide one. If * {@code null}, a default implementation will be created and maintained under the hood. */ - public TestAndroidLifecycleScopeProvider(@Nullable LifecycleRegistry registry) { + public static TestLifecycleOwner create(LifecycleRegistry registry) { + return new TestLifecycleOwner(registry); + } + + private TestLifecycleOwner(@Nullable LifecycleRegistry registry) { this.registry = registry == null ? new LifecycleRegistry(this) : registry; } @@ -59,24 +63,5 @@ public TestAndroidLifecycleScopeProvider(@Nullable LifecycleRegistry registry) { */ public void emit(Lifecycle.Event event) { registry.handleLifecycleEvent(event); - switch (event) { - case ON_CREATE: - registry.markState(Lifecycle.State.CREATED); - break; - case ON_START: - registry.markState(Lifecycle.State.STARTED); - break; - case ON_RESUME: - registry.markState(Lifecycle.State.RESUMED); - break; - case ON_PAUSE: - case ON_STOP: - case ON_DESTROY: - registry.markState(Lifecycle.State.DESTROYED); - break; - case ON_ANY: - throw new IllegalArgumentException("Event#ON_ANY is not a valid event to the emit() " - + "method."); - } } } diff --git a/android/autodispose-android-archcomponents/build.gradle b/android/autodispose-android-archcomponents/build.gradle new file mode 100644 index 000000000..abd6b48e8 --- /dev/null +++ b/android/autodispose-android-archcomponents/build.gradle @@ -0,0 +1,78 @@ +/* + * 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() + maven { url deps.build.repositories.plugins } + } + + dependencies { + classpath deps.build.gradlePlugins.android + classpath deps.build.gradlePlugins.errorProne + } +} + +apply plugin: 'com.android.library' +apply plugin: "net.ltgt.errorprone" + +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" + testApplicationId "com.uber.autodispose.android.lifecycle.androidTest" + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + lintOptions { + lintConfig file('lint.xml') + } +} + +dependencies { + annotationProcessor deps.build.nullAway + testAnnotationProcessor deps.build.nullAway + annotationProcessor deps.support.arch.lifecycle.compiler + + compile project(':android:autodispose-android') + compile deps.support.arch.lifecycle.common + compile deps.support.arch.lifecycle.runtime + + provided deps.misc.errorProneAnnotations + provided deps.misc.javaxExtras + + errorprone deps.build.checkerFramework + errorprone deps.build.errorProne + + androidTestCompile project(':android:autodispose-android-archcomponents-test') + androidTestCompile project(':test-utils') + androidTestCompile deps.test.androidRunner + androidTestCompile deps.test.androidRules +} + +tasks.withType(JavaCompile) { + options.compilerArgs += ["-Xep:NullAway:ERROR", + "-XepOpt:NullAway:AnnotatedPackages=com.uber"] +} + +apply from: rootProject.file('gradle/gradle-mvn-push.gradle') diff --git a/android/autodispose-android-archcomponents/consumer-proguard-rules.txt b/android/autodispose-android-archcomponents/consumer-proguard-rules.txt new file mode 100644 index 000000000..7076bdd82 --- /dev/null +++ b/android/autodispose-android-archcomponents/consumer-proguard-rules.txt @@ -0,0 +1,2 @@ +-dontwarn com.uber.javaxextras.** +-keep class * implements android.arch.lifecycle.GeneratedAdapter {(...);} diff --git a/autodispose-android-archcomponents/gradle.properties b/android/autodispose-android-archcomponents/gradle.properties similarity index 100% rename from autodispose-android-archcomponents/gradle.properties rename to android/autodispose-android-archcomponents/gradle.properties diff --git a/android/autodispose-android-archcomponents/lint.xml b/android/autodispose-android-archcomponents/lint.xml new file mode 100644 index 000000000..42d0afee1 --- /dev/null +++ b/android/autodispose-android-archcomponents/lint.xml @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProviderTest.java b/android/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProviderTest.java similarity index 90% rename from autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProviderTest.java rename to android/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProviderTest.java index f0f44a84f..51d65e2a4 100644 --- a/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProviderTest.java +++ b/android/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProviderTest.java @@ -23,12 +23,13 @@ import android.util.Log; import com.uber.autodispose.AutoDispose; import com.uber.autodispose.LifecycleEndedException; +import com.uber.autodispose.android.lifecycle.test.TestLifecycleOwner; import com.uber.autodispose.test.RecordingObserver; +import io.reactivex.disposables.Disposable; +import io.reactivex.subjects.PublishSubject; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import io.reactivex.disposables.Disposable; -import io.reactivex.subjects.PublishSubject; import static com.google.common.truth.Truth.assertThat; @@ -47,7 +48,7 @@ final PublishSubject subject = PublishSubject.create(); // Spin it up - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); subject.to(AutoDispose.with(AndroidLifecycleScopeProvider.from(lifecycle)) .forObservable()) .subscribe(o); @@ -77,7 +78,7 @@ final PublishSubject subject = PublishSubject.create(); // Spin it up - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); lifecycle.emit(Lifecycle.Event.ON_CREATE); subject.to(AutoDispose.with(AndroidLifecycleScopeProvider.from(lifecycle)) .forObservable()) @@ -107,7 +108,7 @@ final PublishSubject subject = PublishSubject.create(); // Spin it up - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); subject.to(AutoDispose.with(AndroidLifecycleScopeProvider.from(lifecycle)) @@ -139,7 +140,7 @@ final PublishSubject subject = PublishSubject.create(); // Spin it up - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); lifecycle.emit(Lifecycle.Event.ON_RESUME); @@ -170,7 +171,7 @@ final PublishSubject subject = PublishSubject.create(); // Spin it up - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); lifecycle.emit(Lifecycle.Event.ON_CREATE); subject.to(AutoDispose.with(AndroidLifecycleScopeProvider .from(lifecycle, Lifecycle.Event.ON_PAUSE)) @@ -202,7 +203,7 @@ final PublishSubject subject = PublishSubject.create(); // Spin it up - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); lifecycle.emit(Lifecycle.Event.ON_RESUME); @@ -232,59 +233,67 @@ o.assertNoMoreEvents(); } - @Test public void observable_offMainThread_shouldFail() { - RecordingObserver o = new RecordingObserver<>(LOGGER); - PublishSubject subject = PublishSubject.create(); + @Test @UiThreadTest public void observable_offAfterPause_shouldStopOnStop() { + final RecordingObserver o = new RecordingObserver<>(LOGGER); + final PublishSubject subject = PublishSubject.create(); - // Spin it up - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); lifecycle.emit(Lifecycle.Event.ON_RESUME); + lifecycle.emit(Lifecycle.Event.ON_PAUSE); subject.to(AutoDispose.with(AndroidLifecycleScopeProvider.from(lifecycle)) .forObservable()) .subscribe(o); Disposable d = o.takeSubscribe(); - Throwable t = o.takeError(); - assertThat(t).isInstanceOf(IllegalStateException.class); - assertThat(t.getMessage()).contains("main thread"); + + subject.onNext(2); + assertThat(o.takeNext()).isEqualTo(2); + + // We could resume again + lifecycle.emit(Lifecycle.Event.ON_RESUME); + subject.onNext(3); + assertThat(o.takeNext()).isEqualTo(3); + + // We should stop here + lifecycle.emit(Lifecycle.Event.ON_STOP); + subject.onNext(3); o.assertNoMoreEvents(); - assertThat(d.isDisposed()).isTrue(); } - @Test @UiThreadTest public void observable_offAfterDestroy_shouldFail() { - final RecordingObserver o = new RecordingObserver<>(LOGGER); - final PublishSubject subject = PublishSubject.create(); + @Test public void observable_offMainThread_shouldFail() { + RecordingObserver o = new RecordingObserver<>(LOGGER); + PublishSubject subject = PublishSubject.create(); - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + // Spin it up + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); lifecycle.emit(Lifecycle.Event.ON_RESUME); - lifecycle.emit(Lifecycle.Event.ON_PAUSE); - lifecycle.emit(Lifecycle.Event.ON_STOP); - lifecycle.emit(Lifecycle.Event.ON_DESTROY); subject.to(AutoDispose.with(AndroidLifecycleScopeProvider.from(lifecycle)) .forObservable()) .subscribe(o); Disposable d = o.takeSubscribe(); Throwable t = o.takeError(); - assertThat(t).isInstanceOf(LifecycleEndedException.class); + assertThat(t).isInstanceOf(IllegalStateException.class); + assertThat(t.getMessage()).contains("main thread"); o.assertNoMoreEvents(); assertThat(d.isDisposed()).isTrue(); } - @Test @UiThreadTest public void observable_offAfterStop_shouldFail() { + @Test @UiThreadTest public void observable_offAfterDestroy_shouldFail() { final RecordingObserver o = new RecordingObserver<>(LOGGER); final PublishSubject subject = PublishSubject.create(); - TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); + TestLifecycleOwner lifecycle = TestLifecycleOwner.create(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); lifecycle.emit(Lifecycle.Event.ON_RESUME); lifecycle.emit(Lifecycle.Event.ON_PAUSE); lifecycle.emit(Lifecycle.Event.ON_STOP); + lifecycle.emit(Lifecycle.Event.ON_DESTROY); subject.to(AutoDispose.with(AndroidLifecycleScopeProvider.from(lifecycle)) .forObservable()) .subscribe(o); diff --git a/autodispose-android-archcomponents/src/main/AndroidManifest.xml b/android/autodispose-android-archcomponents/src/main/AndroidManifest.xml similarity index 100% rename from autodispose-android-archcomponents/src/main/AndroidManifest.xml rename to android/autodispose-android-archcomponents/src/main/AndroidManifest.xml diff --git a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java b/android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java similarity index 82% rename from autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java rename to android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java index aca5f735e..6091cc922 100644 --- a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java +++ b/android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java @@ -54,7 +54,7 @@ public final class AndroidLifecycleScopeProvider } }; - private final Function correspondingEvents; + private final Function boundaryResolver; /** * Creates a {@link AndroidLifecycleScopeProvider} for Android LifecycleOwners. @@ -86,7 +86,7 @@ public static AndroidLifecycleScopeProvider from( * @return a {@link AndroidLifecycleScopeProvider} against this lifecycle. */ public static AndroidLifecycleScopeProvider from(Lifecycle lifecycle) { - return new AndroidLifecycleScopeProvider(lifecycle); + return from(lifecycle, DEFAULT_CORRESPONDING_EVENTS); } /** @@ -99,19 +99,28 @@ public static AndroidLifecycleScopeProvider from(Lifecycle lifecycle) { public static AndroidLifecycleScopeProvider from( Lifecycle lifecycle, Lifecycle.Event untilEvent) { - return new AndroidLifecycleScopeProvider(lifecycle, untilEvent); + return from(lifecycle, new UntilEventFunction(untilEvent)); } - private final LifecycleEventsObservable lifecycleObservable; - - private AndroidLifecycleScopeProvider(Lifecycle lifecycle) { - this.lifecycleObservable = new LifecycleEventsObservable(lifecycle); - this.correspondingEvents = DEFAULT_CORRESPONDING_EVENTS; + /** + * Creates a {@link AndroidLifecycleScopeProvider} for Android Lifecycles. + * + * @param lifecycle the lifecycle to scope for. + * @param boundaryResolver function that resolves the event boundary. + * @return a {@link AndroidLifecycleScopeProvider} against this lifecycle. + */ + public static AndroidLifecycleScopeProvider from( + Lifecycle lifecycle, + Function boundaryResolver) { + return new AndroidLifecycleScopeProvider(lifecycle, boundaryResolver); } - private AndroidLifecycleScopeProvider(Lifecycle lifecycle, Lifecycle.Event untilEvent) { + private final LifecycleEventsObservable lifecycleObservable; + + private AndroidLifecycleScopeProvider(Lifecycle lifecycle, + Function boundaryResolver) { this.lifecycleObservable = new LifecycleEventsObservable(lifecycle); - this.correspondingEvents = new UntilEventFunction(untilEvent); + this.boundaryResolver = boundaryResolver; } @Override public Observable lifecycle() { @@ -119,7 +128,7 @@ private AndroidLifecycleScopeProvider(Lifecycle lifecycle, Lifecycle.Event until } @Override public Function correspondingEvents() { - return correspondingEvents; + return boundaryResolver; } @Override public Lifecycle.Event peekLifecycle() { diff --git a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/LifecycleEventsObservable.java b/android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/LifecycleEventsObservable.java similarity index 100% rename from autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/LifecycleEventsObservable.java rename to android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/LifecycleEventsObservable.java diff --git a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/package-info.java b/android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/package-info.java similarity index 100% rename from autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/package-info.java rename to android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/package-info.java diff --git a/android/autodispose-android-kotlin/build.gradle b/android/autodispose-android-kotlin/build.gradle new file mode 100644 index 000000000..d33ef1318 --- /dev/null +++ b/android/autodispose-android-kotlin/build.gradle @@ -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') + androidTestCompile project(':test-utils') +} + +apply from: rootProject.file('gradle/gradle-mvn-push.gradle') diff --git a/android/autodispose-android-kotlin/consumer-proguard-rules.txt b/android/autodispose-android-kotlin/consumer-proguard-rules.txt new file mode 100644 index 000000000..405893e1b --- /dev/null +++ b/android/autodispose-android-kotlin/consumer-proguard-rules.txt @@ -0,0 +1 @@ +-dontwarn com.uber.javaxextras.** diff --git a/android/autodispose-android-kotlin/gradle.properties b/android/autodispose-android-kotlin/gradle.properties new file mode 100755 index 000000000..e48ed5c83 --- /dev/null +++ b/android/autodispose-android-kotlin/gradle.properties @@ -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 Kotlin Extensions) +POM_ARTIFACT_ID=autodispose-android-kotlin +POM_PACKAGING=aar diff --git a/android/autodispose-android-kotlin/src/main/AndroidManifest.xml b/android/autodispose-android-kotlin/src/main/AndroidManifest.xml new file mode 100755 index 000000000..a77961c32 --- /dev/null +++ b/android/autodispose-android-kotlin/src/main/AndroidManifest.xml @@ -0,0 +1,17 @@ + + + diff --git a/android/autodispose-android-kotlin/src/main/kotlin/com/uber/autodispose/android/autodisposeAndroid.kt b/android/autodispose-android-kotlin/src/main/kotlin/com/uber/autodispose/android/autodisposeAndroid.kt new file mode 100644 index 000000000..1bda979ed --- /dev/null +++ b/android/autodispose-android-kotlin/src/main/kotlin/com/uber/autodispose/android/autodisposeAndroid.kt @@ -0,0 +1,29 @@ +/* + * 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 + +import android.view.View +import com.uber.autodispose.LifecycleScopeProvider +import io.reactivex.annotations.CheckReturnValue + +/** + * Extension that returns a [LifecycleScopeProvider] for this [View]. + */ +@CheckReturnValue +inline fun View.scope(): LifecycleScopeProvider<*> = ViewScopeProvider.from(this) diff --git a/autodispose-android/build.gradle b/android/autodispose-android/build.gradle similarity index 97% rename from autodispose-android/build.gradle rename to android/autodispose-android/build.gradle index 5014e2459..69e934bd3 100755 --- a/autodispose-android/build.gradle +++ b/android/autodispose-android/build.gradle @@ -36,6 +36,7 @@ android { defaultConfig { minSdkVersion deps.build.minSdkVersion targetSdkVersion deps.build.targetSdkVersion + consumerProguardFiles 'consumer-proguard-rules.txt' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } compileOptions { diff --git a/android/autodispose-android/consumer-proguard-rules.txt b/android/autodispose-android/consumer-proguard-rules.txt new file mode 100644 index 000000000..405893e1b --- /dev/null +++ b/android/autodispose-android/consumer-proguard-rules.txt @@ -0,0 +1 @@ +-dontwarn com.uber.javaxextras.** diff --git a/autodispose-android/gradle.properties b/android/autodispose-android/gradle.properties similarity index 100% rename from autodispose-android/gradle.properties rename to android/autodispose-android/gradle.properties diff --git a/autodispose-android/src/androidTest/AndroidManifest.xml b/android/autodispose-android/src/androidTest/AndroidManifest.xml similarity index 100% rename from autodispose-android/src/androidTest/AndroidManifest.xml rename to android/autodispose-android/src/androidTest/AndroidManifest.xml diff --git a/autodispose-android/src/androidTest/java/com/uber/autodispose/android/AutoDisposeTestActivity.java b/android/autodispose-android/src/androidTest/java/com/uber/autodispose/android/AutoDisposeTestActivity.java similarity index 100% rename from autodispose-android/src/androidTest/java/com/uber/autodispose/android/AutoDisposeTestActivity.java rename to android/autodispose-android/src/androidTest/java/com/uber/autodispose/android/AutoDisposeTestActivity.java diff --git a/autodispose-android/src/androidTest/java/com/uber/autodispose/android/ViewScopeProviderTest.java b/android/autodispose-android/src/androidTest/java/com/uber/autodispose/android/ViewScopeProviderTest.java similarity index 100% rename from autodispose-android/src/androidTest/java/com/uber/autodispose/android/ViewScopeProviderTest.java rename to android/autodispose-android/src/androidTest/java/com/uber/autodispose/android/ViewScopeProviderTest.java diff --git a/autodispose-android/src/main/AndroidManifest.xml b/android/autodispose-android/src/main/AndroidManifest.xml similarity index 100% rename from autodispose-android/src/main/AndroidManifest.xml rename to android/autodispose-android/src/main/AndroidManifest.xml diff --git a/autodispose-android/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java b/android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java similarity index 100% rename from autodispose-android/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java rename to android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java diff --git a/autodispose-android/src/main/java/com/uber/autodispose/android/ViewLifecycleEvent.java b/android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewLifecycleEvent.java similarity index 100% rename from autodispose-android/src/main/java/com/uber/autodispose/android/ViewLifecycleEvent.java rename to android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewLifecycleEvent.java diff --git a/autodispose-android/src/main/java/com/uber/autodispose/android/ViewScopeProvider.java b/android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewScopeProvider.java similarity index 100% rename from autodispose-android/src/main/java/com/uber/autodispose/android/ViewScopeProvider.java rename to android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewScopeProvider.java diff --git a/autodispose-android/src/main/java/com/uber/autodispose/android/internal/AutoDisposeAndroidUtil.java b/android/autodispose-android/src/main/java/com/uber/autodispose/android/internal/AutoDisposeAndroidUtil.java similarity index 100% rename from autodispose-android/src/main/java/com/uber/autodispose/android/internal/AutoDisposeAndroidUtil.java rename to android/autodispose-android/src/main/java/com/uber/autodispose/android/internal/AutoDisposeAndroidUtil.java diff --git a/autodispose-android/src/main/java/com/uber/autodispose/android/package-info.java b/android/autodispose-android/src/main/java/com/uber/autodispose/android/package-info.java similarity index 100% rename from autodispose-android/src/main/java/com/uber/autodispose/android/package-info.java rename to android/autodispose-android/src/main/java/com/uber/autodispose/android/package-info.java diff --git a/autodispose-kotlin/build.gradle b/autodispose-kotlin/build.gradle index 6c1414d49..b3409147a 100644 --- a/autodispose-kotlin/build.gradle +++ b/autodispose-kotlin/build.gradle @@ -4,7 +4,7 @@ buildscript { } } -apply plugin: 'kotlin' +apply plugin: 'org.jetbrains.kotlin.jvm' dependencies { compile deps.kotlin.stdlib diff --git a/build.gradle b/build.gradle index be81402c3..a58df0f5e 100755 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ subprojects { } task wrapper(type: Wrapper) { - gradleVersion = '4.1' + gradleVersion = '4.2.1' distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 1def7e739..297904b20 100755 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -16,14 +16,14 @@ def versions = [ androidTest: '0.5', - archComponents: '1.0.0-beta1', + archComponents: '1.0.0-rc1', errorProne: '2.1.1', kotlin: '1.1.50', support: '26.1.0' ] def build = [ - buildToolsVersion: '26.0.1', + buildToolsVersion: '26.0.2', compileSdkVersion: 26, ci: 'true' == System.getenv('CI'), minSdkVersion: 14, @@ -64,9 +64,10 @@ def support = [ annotations: "com.android.support:support-annotations:${versions.support}", arch: [ lifecycle: [ - common: "android.arch.lifecycle:common:${versions.archComponents}", + common: "android.arch.lifecycle:common:1.0.3", compiler: "android.arch.lifecycle:compiler:${versions.archComponents}", - extensions: "android.arch.lifecycle:extensions:${versions.archComponents}" + extensions: "android.arch.lifecycle:extensions:${versions.archComponents}", + runtime: "android.arch.lifecycle:runtime:1.0.0" ] ] ] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bf1b63c34..c583957d2 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip diff --git a/sample/build.gradle b/sample/build.gradle index 168974fd4..6c0e08812 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -49,9 +49,9 @@ android { dependencies { provided deps.misc.javaxExtras + compile project(':android:autodispose-android') + compile project(':android:autodispose-android-archcomponents') compile project(':autodispose') - compile project(':autodispose-android') - compile project(':autodispose-android-archcomponents') compile project(':autodispose-kotlin') compile 'com.android.support:appcompat-v7:26.1.0' compile 'com.android.support.constraint:constraint-layout:1.1.0-beta1' diff --git a/settings.gradle b/settings.gradle index 0bdc14ced..b2f57264d 100755 --- a/settings.gradle +++ b/settings.gradle @@ -15,9 +15,13 @@ */ rootProject.name = 'autodispose-root' +include ':android:autodispose-android' +include ':android:autodispose-android-kotlin' +include ':android:autodispose-android-archcomponents' +include ':android:autodispose-android-archcomponents-kotlin' +include ':android:autodispose-android-archcomponents-test' +include ':android:autodispose-android-archcomponents-test-kotlin' include ':autodispose' -include ':autodispose-android' -include ':autodispose-android-archcomponents' include ':autodispose-kotlin' include ':sample' include ':test-utils'