diff --git a/.gitreview b/.gitreview deleted file mode 100644 index 2dd0b4bb2..000000000 --- a/.gitreview +++ /dev/null @@ -1,6 +0,0 @@ -[gerrit] -host=gerrit.wikimedia.org -port=29418 -project=apps/android/commons.git -defaultbranch=master -defaultrebase=0 diff --git a/.travis.yml b/.travis.yml index 5e76e09d9..d9abeedbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,19 +12,16 @@ env: - ADB_INSTALL_TIMEOUT=12 # in minutes jdk: - # - openjdk8 # not yet available - oraclejdk8 android: components: - tools - platform-tools - - build-tools-27.0.0 + - build-tools-27.0.3 - extra-google-m2repository - extra-android-m2repository - - ${ANDROID_TARGET} - - android-25 - - android-26 + - android-22 - android-27 - sys-img-${ANDROID_ABI}-${ANDROID_TARGET} licenses: diff --git a/app/build.gradle b/app/build.gradle index 994710fda..33d9f4a2f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'jacoco-android' apply from: 'quality.gradle' -apply plugin: 'com.getkeepsafe.dexcount' dependencies { implementation 'com.prof.rssparser:rssparser:1.1' @@ -16,12 +15,12 @@ dependencies { implementation 'org.mediawiki:api:1.3' implementation 'commons-codec:commons-codec:1.10' implementation 'com.github.pedrovgs:renderers:3.3.3' - implementation 'com.google.code.gson:gson:2.8.1' - implementation 'com.jakewharton.timber:timber:4.5.1' + implementation 'com.google.code.gson:gson:2.8.5' + implementation 'com.jakewharton.timber:timber:4.6.0' implementation 'info.debatty:java-string-similarity:0.24' implementation 'com.borjabravo:readmoretextview:2.1.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0@aar') { transitive = true } @@ -34,35 +33,35 @@ dependencies { implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VERSION" implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION" kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION" - implementation 'com.squareup.okhttp3:okhttp:3.9.1' - implementation 'com.squareup.okio:okio:1.13.0' - implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' + implementation 'com.squareup.okhttp3:okhttp:3.10.0' + implementation 'com.squareup.okio:okio:1.14.0' + implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' // Because RxAndroid releases are few and far between, it is recommended you also // explicitly depend on RxJava's latest version for bug fixes and new features. - implementation 'io.reactivex.rxjava2:rxjava:2.1.2' - implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0' - implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0' - implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0' - implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0' + implementation 'io.reactivex.rxjava2:rxjava:2.2.0' + implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1' + implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.1.1' + implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.1.1' + implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.1.1' implementation 'org.jsoup:jsoup:1.11.3' - implementation 'com.facebook.fresco:fresco:1.5.0' + implementation 'com.facebook.fresco:fresco:1.10.0' implementation 'com.facebook.stetho:stetho:1.5.0' implementation "com.google.dagger:dagger:$DAGGER_VERSION" implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION" kapt "com.google.dagger:dagger-android-processor:$DAGGER_VERSION" kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION" - testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" testImplementation 'junit:junit:4.12' testImplementation 'org.robolectric:robolectric:3.7.1' testImplementation 'com.nhaarman:mockito-kotlin:1.5.0' - testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1' + testImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0' implementation 'com.dinuscxj:circleprogressbar:1.1.1' implementation 'com.tspoon.traceur:traceur:1.0.1' - androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" - androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1' + androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0' androidTestImplementation "com.android.support:support-annotations:$SUPPORT_LIB_VERSION" androidTestImplementation 'com.android.support.test:rules:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2' @@ -81,16 +80,14 @@ android { compileSdkVersion project.compileSdkVersion buildToolsVersion project.buildToolsVersion - useLibrary 'org.apache.http.legacy' - defaultConfig { applicationId 'fr.free.nrw.commons' versionCode 90 versionName '2.8.3' setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName()) - minSdkVersion project.minSdkVersion - targetSdkVersion project.targetSdkVersion + minSdkVersion 15 + targetSdkVersion 27 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true } @@ -112,11 +109,15 @@ android { buildTypes { release { - minifyEnabled false // See https://stackoverflow.com/questions/40232404/google-play-apk-and-android-studio-apk-usb-debug-behaving-differently - proguard.cfg modification alone insufficient. + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + testProguardFile 'test-proguard-rules.txt' } debug { + minifyEnabled true testCoverageEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + testProguardFile 'test-proguard-rules.txt' versionNameSuffix "-debug-" + getBranchName() + "~" + getBuildVersion() } } @@ -189,11 +190,5 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - //FIXME: Temporary fix for https://github.com/commons-app/apps-android-commons/issues/709 - configurations.all { - resolutionStrategy.force 'com.android.support:support-annotations:25.2.0' - exclude module: 'httpclient' - exclude module: 'commons-logging' - } buildToolsVersion buildToolsVersion } diff --git a/app/libs/java-json.jar b/app/libs/java-json.jar deleted file mode 100644 index 2f211e366..000000000 Binary files a/app/libs/java-json.jar and /dev/null differ diff --git a/app/proguard-rules.txt b/app/proguard-rules.txt index 39b618718..12550f3fa 100644 --- a/app/proguard-rules.txt +++ b/app/proguard-rules.txt @@ -1,4 +1,58 @@ -dontobfuscate +-ignorewarnings + -keep class org.apache.http.** { *; } -dontwarn org.apache.http.** --keep class android.support.v7.widget.ShareActionProvider { *; } \ No newline at end of file +-keep class android.support.v7.widget.ShareActionProvider { *; } + +# --- Butter Knife --- +# Finder.castParam() is stripped when not needed and ProGuard notes it +# unnecessarily. When castParam() is needed, it's not stripped. e.g.: +# +# @OnItemSelected(value = R.id.history_entry_list) +# void foo(ListView bar) { +# L.d("baz"); +# } + +-dontnote butterknife.internal.** +# --- /Butter Knife --- + +# --- Retrofit2 --- +# Platform calls Class.forName on types which do not exist on Android to determine platform. +-dontnote retrofit2.Platform +# Platform used when running on Java 8 VMs. Will not be used at runtime. +-dontwarn retrofit2.Platform$Java8 +# Retain generic type information for use by reflection by converters and adapters. +-keepattributes Signature +# Retain declared checked exceptions for use by a Proxy instance. +-keepattributes Exceptions +# --- /Retrofit --- + +# --- OkHttp + Okio --- +-dontwarn okhttp3.** +-dontwarn okio.** +# --- /OkHttp + Okio --- + +# --- Gson --- +# https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg + +# Gson uses generic type information stored in a class file when working with fields. Proguard +# removes such information by default, so configure it to keep all of it. +-keepattributes Signature + +# For using GSON @Expose annotation +-keepattributes *Annotation* + +# Gson specific classes +-dontwarn sun.misc.** +#-keep class com.google.gson.stream.** { *; } + +# Application classes that will be serialized/deserialized over Gson +-keep class com.google.gson.examples.android.model.** { *; } + +# Prevent proguard from stripping interface information from TypeAdapterFactory, +# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) +-keep class * implements com.google.gson.TypeAdapterFactory +-keep class * implements com.google.gson.JsonSerializer +-keep class * implements com.google.gson.JsonDeserializer +# --- /Gson --- diff --git a/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java b/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java index e2c7f367b..09b39c6e1 100644 --- a/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java +++ b/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java @@ -97,19 +97,25 @@ public class CommonsApplication extends Application { .getInstance(this) .getCommonsApplicationComponent() .inject(this); + + Timber.plant(new Timber.DebugTree()); + // Set DownsampleEnabled to True to downsample the image in case it's heavy ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this) .setDownsampleEnabled(true) .build(); - Fresco.initialize(this,config); + try { + Fresco.initialize(this, config); + } catch (Exception e) { + Timber.e(e); + // TODO: Remove when we're able to initialize Fresco in test builds. + } if (setupLeakCanary() == RefWatcher.DISABLED) { return; } // Empty temp directory in case some temp files are created and never removed. ContributionUtils.emptyTemporaryDirectory(); - Timber.plant(new Timber.DebugTree()); - if (!BuildConfig.DEBUG) { ACRA.init(this); } else { diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyController.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyController.java index 4f777aeb4..39deee7ad 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyController.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyController.java @@ -2,6 +2,7 @@ package fr.free.nrw.commons.nearby; import android.content.Context; import android.content.SharedPreferences; +import android.content.res.Resources; import android.graphics.Bitmap; import android.support.graphics.drawable.VectorDrawableCompat; @@ -135,9 +136,14 @@ public class NearbyController { placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS)); - VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create( - context.getResources(), R.drawable.ic_custom_map_marker, context.getTheme() - ); + VectorDrawableCompat vectorDrawable = null; + try { + vectorDrawable = VectorDrawableCompat.create( + context.getResources(), R.drawable.ic_custom_map_marker, context.getTheme() + ); + } catch (Resources.NotFoundException e) { + // ignore when running tests. + } if (vectorDrawable != null) { Bitmap icon = UiUtils.getBitmap(vectorDrawable); diff --git a/app/src/test/kotlin/fr/free/nrw/commons/NearbyControllerTest.kt b/app/src/test/kotlin/fr/free/nrw/commons/NearbyControllerTest.kt index fc0be84d0..755473dc8 100644 --- a/app/src/test/kotlin/fr/free/nrw/commons/NearbyControllerTest.kt +++ b/app/src/test/kotlin/fr/free/nrw/commons/NearbyControllerTest.kt @@ -10,7 +10,7 @@ import org.robolectric.RuntimeEnvironment import org.robolectric.annotation.Config @RunWith(RobolectricTestRunner::class) -@Config(constants = BuildConfig::class, sdk = intArrayOf(21), application = TestCommonsApplication::class) +@Config(constants = BuildConfig::class, sdk = [21], application = TestCommonsApplication::class) class NearbyControllerTest { @Test diff --git a/app/test-proguard-rules.txt b/app/test-proguard-rules.txt new file mode 100644 index 000000000..3b560b25a --- /dev/null +++ b/app/test-proguard-rules.txt @@ -0,0 +1,4 @@ +-dontobfuscate +-dontoptimize +-dontshrink +-ignorewarnings diff --git a/build.gradle b/build.gradle index 42dfeec75..c1677b2ff 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.31' + ext.kotlin_version = '1.2.60' repositories { jcenter() mavenCentral() google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' - classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' - classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.1' + classpath 'com.android.tools.build:gradle:3.1.4' + classpath 'com.dicedmelon.gradle:jacoco-android:0.1.3' + classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/gradle.properties b/gradle.properties index 05aa34949..1757a16bb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,18 +15,11 @@ #Thu Mar 01 15:28:48 IST 2018 systemProp.http.proxyPort=0 compileSdkVersion=android-27 -android.useDeprecatedNdk=true -BUTTERKNIFE_VERSION=8.6.0 +BUTTERKNIFE_VERSION=8.8.1 org.gradle.jvmargs=-Xmx1536M -buildToolsVersion=27.0.0 -targetSdkVersion=27 +buildToolsVersion=27.0.3 -#TODO: Temporary disabled. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#aapt2 -#Refer to PR: https://github.com/commons-app/apps-android-commons/pull/932 -android.enableAapt2=false SUPPORT_LIB_VERSION=27.1.1 -minSdkVersion=15 systemProp.http.proxyHost= LEAK_CANARY=1.5.4 -DAGGER_VERSION=2.13 -gradleVersion=3.0.0 +DAGGER_VERSION=2.15 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c25f3eb11..001321773 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Mar 03 13:58:47 IST 2018 +#Sat Aug 25 23:38:03 EDT 2018 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.4-all.zip