Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use latest and greatest tools and libraries #124

Merged
merged 2 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 45 additions & 40 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'me.tatarka:gradle-retrolambda:3.3.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retrolambda no longer needed with latest butter knife.

classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.10'
}
}

allprojects {
repositories {
mavenCentral()
jcenter()
}
ext {
minSdkVersion = 9
targetSdkVersion = 28
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
javaVersion = JavaVersion.VERSION_1_7
java8Version = JavaVersion.VERSION_1_8
butterknifeVersion = '10.1.0'
}

tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xlint:all', '-Xlint:-processing', '-Werror']
}
repositories {
mavenCentral()
google()
jcenter()
}

apply plugin: 'net.ltgt.errorprone'
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "com.jakewharton:butterknife-gradle-plugin:${butterknifeVersion}"
}
}

group = GROUP
version = VERSION_NAME
plugins {
id("net.ltgt.errorprone") version "0.7.1"
Copy link
Contributor Author

@kirillzh kirillzh Mar 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL you can do this in Gradle 5.2.1

}

ext {
minSdkVersion = 9
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = '25.0.2'
javaVersion = JavaVersion.VERSION_1_7
java8Version = JavaVersion.VERSION_1_8
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}

tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xlint:all', '-Xlint:-processing', '-Werror']
}

group = GROUP
version = VERSION_NAME
}

ext.deps = [
annotations: 'com.android.support:support-annotations:25.1.1',
rxjava: 'io.reactivex.rxjava2:rxjava:2.0.3',
rxandroid: 'io.reactivex.rxjava2:rxandroid:2.0.1',
rxbinding: 'com.jakewharton.rxbinding:rxbinding:0.3.0',
rxjava2interop: 'com.github.akarnokd:rxjava2-interop:0.4.0',
butterknife: 'com.jakewharton:butterknife:8.4.0',
butterknifeCompiler: 'com.jakewharton:butterknife-compiler:8.4.0',
junit: 'junit:junit:4.12',
assertj: 'org.assertj:assertj-core:1.7.0',
robolectric: 'org.robolectric:robolectric:3.0',
annotations : 'androidx.annotation:annotation:1.0.2',
rxjava2 : 'io.reactivex.rxjava2:rxjava:2.2.7',
rxandroid : 'io.reactivex.rxjava2:rxandroid:2.1.1',
rxbinding : 'com.jakewharton.rxbinding:rxbinding:1.0.1',
rxjava2interop : 'com.github.akarnokd:rxjava2-interop:0.13.5',
butterknife : "com.jakewharton:butterknife:${ext.butterknifeVersion}",
butterknifeCompiler: "com.jakewharton:butterknife-compiler:${ext.butterknifeVersion}",
junit : 'junit:junit:4.12',
assertj : 'org.assertj:assertj-core:3.12.2',
robolectric : 'org.robolectric:robolectric:4.2.1',
testcore : 'androidx.test:core:1.0.0'
]
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=f2prateek
POM_DEVELOPER_NAME=Prateek Srivastava
android.useAndroidX=true
android.enableJetifier=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Tue Mar 14 01:37:42 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋

zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
8 changes: 4 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -155,7 +155,7 @@ if $cygwin ; then
fi

# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
12 changes: 6 additions & 6 deletions rx-preferences-sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.butterknife'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand Down Expand Up @@ -30,11 +30,11 @@ android {
}

dependencies {
compile project(':rx-preferences')
compile deps.rxandroid
compile deps.rxbinding
compile deps.rxjava2interop
compile deps.butterknife
implementation project(':rx-preferences')
implementation deps.rxandroid
implementation deps.rxbinding
implementation deps.rxjava2interop
implementation deps.butterknife

annotationProcessor deps.butterknifeCompiler
}
11 changes: 6 additions & 5 deletions rx-preferences/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ android {
}

dependencies {
compile deps.annotations
compile deps.rxjava
implementation deps.annotations
api deps.rxjava2

testCompile deps.junit
testCompile deps.assertj
testCompile deps.robolectric
testImplementation deps.junit
testImplementation deps.assertj
testImplementation deps.testcore
testImplementation deps.robolectric
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
4 changes: 1 addition & 3 deletions rx-preferences/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<manifest package="com.f2prateek.rx.preferences2">
<application/>
</manifest>
<manifest package="com.f2prateek.rx.preferences2"/>
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.f2prateek.rx.preferences2;

import android.content.SharedPreferences;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

final class BooleanAdapter implements RealPreference.Adapter<Boolean> {
static final BooleanAdapter INSTANCE = new BooleanAdapter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.f2prateek.rx.preferences2;

import android.content.SharedPreferences;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

import static com.f2prateek.rx.preferences2.Preconditions.checkNotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.f2prateek.rx.preferences2;

import android.content.SharedPreferences;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

final class EnumAdapter<T extends Enum<T>> implements RealPreference.Adapter<T> {
private final Class<T> enumClass;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.f2prateek.rx.preferences2;

import android.content.SharedPreferences;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

final class FloatAdapter implements RealPreference.Adapter<Float> {
static final FloatAdapter INSTANCE = new FloatAdapter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.f2prateek.rx.preferences2;

import android.content.SharedPreferences;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

final class IntegerAdapter implements RealPreference.Adapter<Integer> {
static final IntegerAdapter INSTANCE = new IntegerAdapter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.f2prateek.rx.preferences2;

import android.content.SharedPreferences;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

final class LongAdapter implements RealPreference.Adapter<Long> {
static final LongAdapter INSTANCE = new LongAdapter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.f2prateek.rx.preferences2;

import android.content.SharedPreferences;
import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;

import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;

import io.reactivex.Observable;
import io.reactivex.functions.Consumer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.f2prateek.rx.preferences2;

import static com.f2prateek.rx.preferences2.Preconditions.checkNotNull;

import android.content.SharedPreferences;
import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;

import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;

import io.reactivex.Observable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;

import static com.f2prateek.rx.preferences2.Preconditions.checkNotNull;

final class RealPreference<T> implements Preference<T> {
/** Stores and retrieves instances of {@code T} in {@link SharedPreferences}. */
interface Adapter<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;

import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

import java.util.Collections;
import java.util.Set;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.functions.Cancellable;
import java.util.Collections;
import java.util.Set;

import static android.os.Build.VERSION_CODES.HONEYCOMB;
import static com.f2prateek.rx.preferences2.Preconditions.checkNotNull;
Expand All @@ -37,7 +39,7 @@ public static RxSharedPreferences create(@NonNull SharedPreferences preferences)
private RxSharedPreferences(final SharedPreferences preferences) {
this.preferences = preferences;
this.keyChanges = Observable.create(new ObservableOnSubscribe<String>() {
@Override public void subscribe(final ObservableEmitter<String> emitter) throws Exception {
@Override public void subscribe(final ObservableEmitter<String> emitter) {
final OnSharedPreferenceChangeListener listener = new OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
Expand All @@ -46,7 +48,7 @@ public void onSharedPreferenceChanged(SharedPreferences preferences, String key)
};

emitter.setCancellable(new Cancellable() {
@Override public void cancel() throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never actually throws.

@Override public void cancel() {
preferences.unregisterOnSharedPreferenceChangeListener(listener);
}
});
Expand Down Expand Up @@ -97,7 +99,6 @@ public Preference<Float> getFloat(@NonNull String key, @NonNull Float defaultVal
/** Create an integer preference for {@code key}. Default is {@code 0}. */
@CheckResult @NonNull
public Preference<Integer> getInteger(@NonNull String key) {
//noinspection UnnecessaryBoxing
return getInteger(key, DEFAULT_INTEGER);
}

Expand All @@ -112,7 +113,6 @@ public Preference<Integer> getInteger(@NonNull String key, @NonNull Integer defa
/** Create a long preference for {@code key}. Default is {@code 0}. */
@CheckResult @NonNull
public Preference<Long> getLong(@NonNull String key) {
//noinspection UnnecessaryBoxing
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These inspections are redundant.

return getLong(key, DEFAULT_LONG);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.f2prateek.rx.preferences2;

import android.content.SharedPreferences;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

final class StringAdapter implements RealPreference.Adapter<String> {
static final StringAdapter INSTANCE = new StringAdapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import android.annotation.TargetApi;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

import java.util.Collections;
import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.f2prateek.rx.preferences2;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

final class PointPreferenceConverter implements Preference.Converter<Point> {
@NonNull @Override public Point deserialize(@NonNull String serialized) {
Expand Down
Loading