Skip to content

Commit 02b5b9b

Browse files
committed
Merge branch 'master' into dependency-injection
2 parents f134d23 + 7a9ff8c commit 02b5b9b

File tree

148 files changed

+1160
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+1160
-355
lines changed

.travis.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ jdk:
1717

1818
android:
1919
components:
20-
- platform-tools
2120
- tools
22-
- build-tools-26.0.1
21+
- platform-tools
22+
- build-tools-26.0.2
2323
- extra-google-m2repository
2424
- extra-android-m2repository
2525
- ${ANDROID_TARGET}
2626
- android-25
27+
- android-26
2728
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
29+
licenses:
30+
- 'android-sdk-license-.+'
2831

2932
before_script:
3033
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
@@ -38,8 +41,10 @@ after_success:
3841
- bash <(curl -s https://codecov.io/bash)
3942

4043
after_failure:
41-
- echo '*** Connected Test Rsults ***'
42-
- w3m -dump ${TRAVIS_BUILD_DIR}/app/build/reports/androidTests/connected/*Test.html
44+
- echo '*** Debug Unit Test Results ***'
45+
- w3m -dump ${TRAVIS_BUILD_DIR}/app/build/reports/tests/*/classes/*Test.html
46+
- echo '*** Connected Test Results ***'
47+
- w3m -dump ${TRAVIS_BUILD_DIR}/app/build/reports/androidTests/connected/flavors/*/*Test.html
4348

4449
before_cache:
4550
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

CREDITS

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ their contribution to the product.
2929
* Jan Piotrowski
3030
* Bruke Mekuria Mulugeta
3131
* Paul Hawke
32+
* Vishan Seru
3233

3334
3rd party open source libraries used:
3435
* Butterknife

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
The Wikimedia Commons Android app allows users to upload pictures from their Android phone/tablet to Wikimedia Commons. Download the app [here][1], or view our [website][2].
44

5-
Initially started by the Wikimedia Foundation, this app is now maintained by volunteers. Anyone is welcome to improve it, just choose among the [open issues][3] and send us a pull request :-)
6-
7-
We are currently applying for an [IEG renewal][10] to work on the app for the next 6 months. Feedback is very much welcomed.
5+
Initially started by the Wikimedia Foundation, this app is now maintained by grantees and volunteers of the Wikimedia community. Anyone is welcome to improve it, just choose among the [open issues][3] and send us a pull request :-)
86

97
<a href="https://f-droid.org/repository/browse/?fdid=fr.free.nrw.commons" target="_blank">
108
<img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="90"/></a>

app/build.gradle

+65-45
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,75 @@
1+
apply from: '../gitutils.gradle'
12
apply plugin: 'com.android.application'
2-
apply plugin: 'me.tatarka.retrolambda'
3+
apply plugin: 'kotlin-android'
4+
apply plugin: 'kotlin-kapt'
35
apply plugin: 'jacoco-android'
46
apply from: 'quality.gradle'
57
apply plugin: 'com.getkeepsafe.dexcount'
68

79
dependencies {
8-
compile 'com.github.nicolas-raoul:Quadtree:ac16ea8035bf07'
9-
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
10-
compile 'in.yuvi:http.fluent:1.3'
11-
compile 'com.android.volley:volley:1.0.0'
12-
compile 'ch.acra:acra:4.7.0'
13-
compile 'org.mediawiki:api:1.3'
14-
compile 'commons-codec:commons-codec:1.10'
15-
compile 'com.github.pedrovgs:renderers:3.3.3'
16-
compile 'com.google.code.gson:gson:2.8.1'
17-
compile 'com.jakewharton.timber:timber:4.5.1'
18-
compile 'info.debatty:java-string-similarity:0.24'
19-
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0@aar'){
10+
implementation 'com.github.nicolas-raoul:Quadtree:ac16ea8035bf07'
11+
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
12+
implementation 'in.yuvi:http.fluent:1.3'
13+
implementation 'com.android.volley:volley:1.0.0'
14+
implementation 'ch.acra:acra:4.7.0'
15+
implementation 'org.mediawiki:api:1.3'
16+
implementation 'commons-codec:commons-codec:1.10'
17+
implementation 'com.github.pedrovgs:renderers:3.3.3'
18+
implementation 'com.google.code.gson:gson:2.8.1'
19+
implementation 'com.jakewharton.timber:timber:4.5.1'
20+
implementation 'info.debatty:java-string-similarity:0.24'
21+
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0@aar'){
2022
transitive=true
2123
}
2224

23-
compile "com.android.support:support-v4:${project.supportLibVersion}"
24-
compile "com.android.support:appcompat-v7:${project.supportLibVersion}"
25-
compile "com.android.support:design:${project.supportLibVersion}"
2625

27-
compile "com.android.support:cardview-v7:${project.supportLibVersion}"
26+
implementation "com.android.support:support-v4:${project.supportLibVersion}"
27+
implementation "com.android.support:appcompat-v7:${project.supportLibVersion}"
28+
implementation "com.android.support:design:${project.supportLibVersion}"
2829

29-
compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
30-
annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
30+
implementation "com.android.support:cardview-v7:${project.supportLibVersion}"
3131

32-
compile 'com.squareup.okhttp3:okhttp:3.8.1'
33-
compile 'com.squareup.okio:okio:1.13.0'
32+
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
33+
kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
3434

35-
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
35+
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
36+
implementation 'com.squareup.okio:okio:1.13.0'
37+
38+
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
3639
// Because RxAndroid releases are few and far between, it is recommended you also
3740
// explicitly depend on RxJava's latest version for bug fixes and new features.
38-
compile 'io.reactivex.rxjava2:rxjava:2.1.2'
39-
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
40-
compile 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
41-
compile 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
42-
compile 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
43-
44-
compile 'com.facebook.fresco:fresco:1.3.0'
45-
compile 'com.facebook.stetho:stetho:1.5.0'
46-
47-
testCompile 'junit:junit:4.12'
48-
testCompile 'org.robolectric:robolectric:3.4'
49-
50-
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
51-
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
52-
androidTestCompile "com.android.support:support-annotations:${project.supportLibVersion}"
53-
androidTestCompile ('com.android.support.test.espresso:espresso-core:3.0.1'){
54-
exclude group: 'com.google.code.findbugs'
55-
}
41+
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
42+
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
43+
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
44+
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
45+
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
46+
47+
implementation 'com.facebook.fresco:fresco:1.3.0'
48+
implementation 'com.facebook.stetho:stetho:1.5.0'
49+
50+
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
51+
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
52+
53+
kapt "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
54+
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
5655

57-
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
58-
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
59-
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
56+
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
57+
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
6058

61-
compile 'com.google.dagger:dagger:2.11'
62-
compile 'com.google.dagger:dagger-android-support:2.11'
59+
testImplementation 'junit:junit:4.12'
60+
testImplementation 'org.robolectric:robolectric:3.4'
61+
62+
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
63+
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
64+
androidTestImplementation "com.android.support:support-annotations:${project.supportLibVersion}"
65+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
66+
67+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1'
68+
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
69+
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
70+
71+
implementation 'com.google.dagger:dagger:2.11'
72+
implementation 'com.google.dagger:dagger-android-support:2.11'
6373
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
6474
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
6575
}
@@ -74,22 +84,29 @@ android {
7484
applicationId 'fr.free.nrw.commons'
7585
versionCode 74
7686
versionName '2.5.0'
87+
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
7788
minSdkVersion project.minSdkVersion
7889
targetSdkVersion project.targetSdkVersion
7990
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
8091
vectorDrawables.useSupportLibrary = true
8192
}
8293

94+
sourceSets {
95+
test.java.srcDirs += 'src/test/kotlin'
96+
}
97+
8398
buildTypes {
8499
release {
85100
minifyEnabled false // See https://stackoverflow.com/questions/40232404/google-play-apk-and-android-studio-apk-usb-debug-behaving-differently - proguard.cfg modification alone insufficient.
86101
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
87102
}
88103
debug {
89104
testCoverageEnabled true
105+
versionNameSuffix "-debug-" + getBranchName() + "~" + getBuildVersion()
90106
}
91107
}
92108

109+
flavorDimensions 'tier'
93110
productFlavors {
94111
prod {
95112
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.org/w/api.php\""
@@ -101,6 +118,7 @@ android {
101118
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
102119
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
103120
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes\""
121+
dimension 'tier'
104122
}
105123

106124
beta {
@@ -114,6 +132,7 @@ android {
114132
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
115133
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
116134
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Main_Page&welcome=yes\""
135+
dimension 'tier'
117136
}
118137
}
119138

@@ -132,4 +151,5 @@ android {
132151
configurations.all {
133152
resolutionStrategy.force 'com.android.support:support-annotations:25.2.0'
134153
}
154+
buildToolsVersion buildToolsVersion
135155
}

app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
1515
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
1616
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
17+
<uses-permission android:name="android.permission.READ_LOGS"/>
1718

1819
<application
1920
android:name=".CommonsApplication"

app/src/main/java/fr/free/nrw/commons/AboutActivity.java

-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package fr.free.nrw.commons;
22

3-
import android.content.Context;
4-
import android.content.Intent;
53
import android.os.Bundle;
64
import android.widget.TextView;
75

@@ -27,9 +25,4 @@ public void onCreate(Bundle savedInstanceState) {
2725
versionText.setText(BuildConfig.VERSION_NAME);
2826
initDrawer();
2927
}
30-
31-
public static void startYourself(Context context) {
32-
Intent settingsIntent = new Intent(context, AboutActivity.class);
33-
context.startActivity(settingsIntent);
34-
}
3528
}

app/src/main/java/fr/free/nrw/commons/CommonsApplication.java

+15-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.facebook.drawee.backends.pipeline.Fresco;
88
import com.facebook.stetho.Stetho;
99
import com.squareup.leakcanary.LeakCanary;
10+
import com.squareup.leakcanary.RefWatcher;
1011

1112
import org.acra.ACRA;
1213
import org.acra.ReportingInteractionMode;
@@ -60,17 +61,15 @@ public class CommonsApplication extends DaggerApplication {
6061
public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback";
6162

6263
private CommonsApplicationComponent component;
64+
private RefWatcher refWatcher;
6365

6466
@Override
6567
public void onCreate() {
6668
super.onCreate();
6769

68-
if (LeakCanary.isInAnalyzerProcess(this)) {
69-
// This process is dedicated to LeakCanary for heap analysis.
70-
// You should not init your app in this process.
70+
if (setupLeakCanary() == RefWatcher.DISABLED) {
7171
return;
7272
}
73-
LeakCanary.install(this);
7473

7574
Timber.plant(new Timber.DebugTree());
7675

@@ -86,6 +85,18 @@ public void onCreate() {
8685
Fresco.initialize(this);
8786
}
8887

88+
protected RefWatcher setupLeakCanary() {
89+
if (LeakCanary.isInAnalyzerProcess(this)) {
90+
return RefWatcher.DISABLED;
91+
}
92+
return LeakCanary.install(this);
93+
}
94+
95+
public static RefWatcher getRefWatcher(Context context) {
96+
CommonsApplication application = (CommonsApplication) context.getApplicationContext();
97+
return application.refWatcher;
98+
}
99+
89100
@Override
90101
protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
91102
return injector();

app/src/main/java/fr/free/nrw/commons/Media.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ public Uri getLocalUri() {
120120
return localUri;
121121
}
122122

123+
@Nullable
123124
public String getImageUrl() {
124-
if (imageUrl == null) {
125+
if (imageUrl == null && this.getFilename() != null) {
125126
imageUrl = Utils.makeThumbBaseUrl(this.getFilename());
126127
}
127128
return imageUrl;

app/src/main/java/fr/free/nrw/commons/MediaDataExtractor.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.io.ByteArrayInputStream;
1212
import java.io.IOException;
1313
import java.util.ArrayList;
14-
import java.util.Date;
1514
import java.util.HashMap;
1615
import java.util.Map;
1716
import java.util.regex.Matcher;
@@ -39,7 +38,6 @@ public class MediaDataExtractor {
3938
private String filename;
4039
private ArrayList<String> categories;
4140
private Map<String, String> descriptions;
42-
private Date date;
4341
private String license;
4442
private @Nullable LatLng coordinates;
4543
private LicenseList licenseList;
@@ -155,7 +153,7 @@ private void processWikiParseTree(String source) throws IOException {
155153
}
156154

157155
private Node findTemplate(Element parentNode, String title_) throws IOException {
158-
String title= new PageTitle(title_).getDisplayText();
156+
String title = new PageTitle(title_).getDisplayText();
159157
NodeList nodes = parentNode.getChildNodes();
160158
for (int i = 0, length = nodes.getLength(); i < length; i++) {
161159
Node node = nodes.item(i);
@@ -181,7 +179,7 @@ private String getTemplateTitle(Node templateNode) throws IOException {
181179
}
182180

183181
private static abstract class TemplateChildNodeComparator {
184-
abstract public boolean match(Node node);
182+
public abstract boolean match(Node node);
185183
}
186184

187185
private Node findTemplateParameter(Node templateNode, String name) throws IOException {

app/src/main/java/fr/free/nrw/commons/MediaWikiImageView.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void setMedia(Media media) {
4242
if (currentThumbnailTask != null) {
4343
currentThumbnailTask.cancel(true);
4444
}
45-
if(media == null) {
45+
if (media == null) {
4646
return;
4747
}
4848

0 commit comments

Comments
 (0)