Skip to content

Commit 032c787

Browse files
authored
Merge pull request #1 from commons-app/master
Merge upstream master
2 parents 7b34717 + f856e75 commit 032c787

File tree

67 files changed

+1238
-675
lines changed

Some content is hidden

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

67 files changed

+1238
-675
lines changed

app/build.gradle

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'jacoco-android'
33
apply from: 'quality.gradle'
4+
apply plugin: 'com.getkeepsafe.dexcount'
45

56
dependencies {
67
compile 'com.github.nicolas-raoul:Quadtree:ac16ea8035bf07'
@@ -13,11 +14,13 @@ dependencies {
1314
compile "com.android.support:support-v4:${project.supportLibVersion}"
1415
compile "com.android.support:appcompat-v7:${project.supportLibVersion}"
1516
compile "com.android.support:design:${project.supportLibVersion}"
16-
compile 'com.google.code.gson:gson:2.7'
17+
compile 'com.google.code.gson:gson:2.8.0'
1718
compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
1819
compile 'com.github.pedrovgs:renderers:3.3.0'
1920
annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
2021
compile 'com.jakewharton.timber:timber:4.5.1'
22+
compile 'com.squareup.okhttp3:okhttp:3.8.1'
23+
compile 'com.squareup.okio:okio:1.13.0'
2124
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0@aar'){
2225
transitive=true
2326
}
@@ -29,6 +32,9 @@ dependencies {
2932
testCompile ('org.robolectric:robolectric:3.3.2') {
3033
exclude module: 'guava'
3134
}
35+
36+
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
37+
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
3238
androidTestCompile "com.android.support:support-annotations:${project.supportLibVersion}"
3339
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
3440

app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java

+8-20
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
import android.support.test.filters.LargeTest;
1010
import android.support.test.rule.ActivityTestRule;
1111
import android.support.test.runner.AndroidJUnit4;
12-
import android.view.View;
1312

14-
import org.hamcrest.Matcher;
13+
import org.hamcrest.Matchers;
1514
import org.junit.Rule;
1615
import org.junit.Test;
1716
import org.junit.runner.RunWith;
@@ -20,9 +19,6 @@
2019

2120
import fr.free.nrw.commons.settings.SettingsActivity;
2221

23-
import static org.hamcrest.Matchers.allOf;
24-
import static org.hamcrest.Matchers.anything;
25-
2622
@LargeTest
2723
@RunWith(AndroidJUnit4.class)
2824
public class SettingsActivityTest {
@@ -65,8 +61,8 @@ protected void afterActivityFinished() {
6561
@Test
6662
public void oneLicenseIsChecked() {
6763
// click "License" (the first item)
68-
Espresso.onData(anything())
69-
.inAdapterView(findPreferenceList())
64+
Espresso.onData(Matchers.anything())
65+
.inAdapterView(ViewMatchers.withId(android.R.id.list))
7066
.atPosition(0)
7167
.perform(ViewActions.click());
7268

@@ -78,8 +74,8 @@ public void oneLicenseIsChecked() {
7874
@Test
7975
public void afterClickingCcby4ItWillStay() {
8076
// click "License" (the first item)
81-
Espresso.onData(anything())
82-
.inAdapterView(findPreferenceList())
77+
Espresso.onData(Matchers.anything())
78+
.inAdapterView(ViewMatchers.withId(android.R.id.list))
8379
.atPosition(0)
8480
.perform(ViewActions.click());
8581

@@ -89,8 +85,8 @@ public void afterClickingCcby4ItWillStay() {
8985
).perform(ViewActions.click());
9086

9187
// click "License" (the first item)
92-
Espresso.onData(anything())
93-
.inAdapterView(findPreferenceList())
88+
Espresso.onData(Matchers.anything())
89+
.inAdapterView(ViewMatchers.withId(android.R.id.list))
9490
.atPosition(0)
9591
.perform(ViewActions.click());
9692

@@ -100,12 +96,4 @@ public void afterClickingCcby4ItWillStay() {
10096
ViewMatchers.withText(R.string.license_name_cc_by_four)
10197
));
10298
}
103-
104-
private static Matcher<View> findPreferenceList() {
105-
return allOf(
106-
ViewMatchers.isDescendantOfA(ViewMatchers.withId(R.id.settingsFragment)),
107-
ViewMatchers.withResourceName("list"),
108-
ViewMatchers.hasFocus()
109-
);
110-
}
111-
}
99+
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import butterknife.BindView;
99
import butterknife.ButterKnife;
1010
import fr.free.nrw.commons.theme.NavigationBaseActivity;
11+
import fr.free.nrw.commons.ui.widget.HtmlTextView;
1112

1213
public class AboutActivity extends NavigationBaseActivity {
1314
@BindView(R.id.about_version) TextView versionText;
15+
@BindView(R.id.about_license) HtmlTextView aboutLicenseText;
1416

1517
@Override
1618
public void onCreate(Bundle savedInstanceState) {
@@ -19,6 +21,9 @@ public void onCreate(Bundle savedInstanceState) {
1921

2022
ButterKnife.bind(this);
2123

24+
String aboutText = getString(R.string.about_license, getString(R.string.trademarked_name));
25+
aboutLicenseText.setHtmlText(aboutText);
26+
2227
versionText.setText(BuildConfig.VERSION_NAME);
2328
initDrawer();
2429
}

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

+13-50
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,30 @@
88
import android.content.Context;
99
import android.content.SharedPreferences;
1010
import android.content.pm.PackageManager;
11-
import android.os.Build;
1211
import android.database.sqlite.SQLiteDatabase;
1312
import android.preference.PreferenceManager;
1413
import android.support.v4.util.LruCache;
1514

1615
import com.facebook.drawee.backends.pipeline.Fresco;
1716
import com.facebook.stetho.Stetho;
18-
19-
import fr.free.nrw.commons.caching.CacheController;
20-
import fr.free.nrw.commons.category.Category;
21-
import fr.free.nrw.commons.contributions.Contribution;
22-
import fr.free.nrw.commons.data.DBOpenHelper;
23-
import fr.free.nrw.commons.modifications.ModifierSequence;
24-
import fr.free.nrw.commons.auth.AccountUtil;
25-
import fr.free.nrw.commons.nearby.NearbyPlaces;
26-
2717
import com.squareup.leakcanary.LeakCanary;
2818

2919
import org.acra.ACRA;
3020
import org.acra.ReportingInteractionMode;
3121
import org.acra.annotation.ReportsCrashes;
32-
import org.apache.http.conn.ClientConnectionManager;
33-
import org.apache.http.conn.scheme.PlainSocketFactory;
34-
import org.apache.http.conn.scheme.Scheme;
35-
import org.apache.http.conn.scheme.SchemeRegistry;
36-
import org.apache.http.conn.ssl.SSLSocketFactory;
37-
import org.apache.http.impl.client.AbstractHttpClient;
38-
import org.apache.http.impl.client.DefaultHttpClient;
39-
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
40-
import org.apache.http.params.BasicHttpParams;
41-
import org.apache.http.params.CoreProtocolPNames;
4222

4323
import java.io.File;
4424
import java.io.IOException;
4525

26+
import fr.free.nrw.commons.auth.AccountUtil;
27+
import fr.free.nrw.commons.caching.CacheController;
28+
import fr.free.nrw.commons.category.Category;
29+
import fr.free.nrw.commons.contributions.Contribution;
30+
import fr.free.nrw.commons.data.DBOpenHelper;
31+
import fr.free.nrw.commons.modifications.ModifierSequence;
32+
import fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApi;
33+
import fr.free.nrw.commons.mwapi.MediaWikiApi;
34+
import fr.free.nrw.commons.nearby.NearbyPlaces;
4635
import fr.free.nrw.commons.utils.FileUtils;
4736
import timber.log.Timber;
4837

@@ -76,9 +65,8 @@ public class CommonsApplication extends Application {
7665
public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback";
7766

7867
private static CommonsApplication instance = null;
79-
private AbstractHttpClient httpClient = null;
80-
private MWApi api = null;
81-
LruCache<String, String> thumbnailUrlCache = new LruCache<>(1024);
68+
private MediaWikiApi api = null;
69+
private LruCache<String, String> thumbnailUrlCache = new LruCache<>(1024);
8270
private CacheController cacheData = null;
8371
private DBOpenHelper dbOpenHelper = null;
8472
private NearbyPlaces nearbyPlaces = null;
@@ -98,35 +86,13 @@ public static CommonsApplication getInstance() {
9886
return instance;
9987
}
10088

101-
public AbstractHttpClient getHttpClient() {
102-
if (httpClient == null) {
103-
httpClient = newHttpClient();
104-
}
105-
return httpClient;
106-
}
107-
108-
private AbstractHttpClient newHttpClient() {
109-
BasicHttpParams params = new BasicHttpParams();
110-
SchemeRegistry schemeRegistry = new SchemeRegistry();
111-
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
112-
final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
113-
schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
114-
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
115-
params.setParameter(CoreProtocolPNames.USER_AGENT, "Commons/" + BuildConfig.VERSION_NAME + " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE);
116-
return new DefaultHttpClient(cm, params);
117-
}
118-
119-
public MWApi getMWApi() {
89+
public MediaWikiApi getMWApi() {
12090
if (api == null) {
121-
api = newMWApi();
91+
api = new ApacheHttpClientMediaWikiApi(API_URL);
12292
}
12393
return api;
12494
}
12595

126-
private MWApi newMWApi() {
127-
return new MWApi(API_URL, getHttpClient());
128-
}
129-
13096
public CacheController getCacheData() {
13197
if (cacheData == null) {
13298
cacheData = new CacheController();
@@ -174,9 +140,6 @@ public void onCreate() {
174140

175141
Fresco.initialize(this);
176142

177-
// Initialize EventLogging
178-
EventLog.setApp(this);
179-
180143
//For caching area -> categories
181144
cacheData = new CacheController();
182145
}

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

-130
This file was deleted.

0 commit comments

Comments
 (0)