8
8
import android .content .Context ;
9
9
import android .content .SharedPreferences ;
10
10
import android .content .pm .PackageManager ;
11
- import android .os .Build ;
12
11
import android .database .sqlite .SQLiteDatabase ;
13
12
import android .preference .PreferenceManager ;
14
13
import android .support .v4 .util .LruCache ;
15
14
16
15
import com .facebook .drawee .backends .pipeline .Fresco ;
17
16
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
-
27
17
import com .squareup .leakcanary .LeakCanary ;
28
18
29
19
import org .acra .ACRA ;
30
20
import org .acra .ReportingInteractionMode ;
31
21
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 ;
42
22
43
23
import java .io .File ;
44
24
import java .io .IOException ;
45
25
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 ;
46
35
import fr .free .nrw .commons .utils .FileUtils ;
47
36
import timber .log .Timber ;
48
37
@@ -76,9 +65,8 @@ public class CommonsApplication extends Application {
76
65
public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback" ;
77
66
78
67
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 );
82
70
private CacheController cacheData = null ;
83
71
private DBOpenHelper dbOpenHelper = null ;
84
72
private NearbyPlaces nearbyPlaces = null ;
@@ -98,35 +86,13 @@ public static CommonsApplication getInstance() {
98
86
return instance ;
99
87
}
100
88
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 () {
120
90
if (api == null ) {
121
- api = newMWApi ( );
91
+ api = new ApacheHttpClientMediaWikiApi ( API_URL );
122
92
}
123
93
return api ;
124
94
}
125
95
126
- private MWApi newMWApi () {
127
- return new MWApi (API_URL , getHttpClient ());
128
- }
129
-
130
96
public CacheController getCacheData () {
131
97
if (cacheData == null ) {
132
98
cacheData = new CacheController ();
@@ -174,9 +140,6 @@ public void onCreate() {
174
140
175
141
Fresco .initialize (this );
176
142
177
- // Initialize EventLogging
178
- EventLog .setApp (this );
179
-
180
143
//For caching area -> categories
181
144
cacheData = new CacheController ();
182
145
}
0 commit comments