Skip to content

Commit 2d91e81

Browse files
committed
Merge branch 'master' into dependency-injection
2 parents a208c9f + ffc7c80 commit 2d91e81

File tree

19 files changed

+288
-168
lines changed

19 files changed

+288
-168
lines changed

app/build.gradle

+23
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,29 @@ android {
8484
}
8585
}
8686

87+
productFlavors {
88+
prod {
89+
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.org/w/api.php\""
90+
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
91+
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.wikimedia.org/wikipedia/commons\""
92+
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.org/wiki/\""
93+
buildConfigField "String", "MOBILE_HOME_URL", "\"https://commons.m.wikimedia.org/wiki/\""
94+
buildConfigField "String", "EVENTLOG_URL", "\"https://www.wikimedia.org/beacon/event\""
95+
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
96+
}
97+
98+
beta {
99+
// What values do we need to hit the BETA versions of the site / api ?
100+
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.beta.wmflabs.org/w/api.php\""
101+
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
102+
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.beta.wmflabs.org/wikipedia/commons\""
103+
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.beta.wmflabs.org/wiki/\""
104+
buildConfigField "String", "MOBILE_HOME_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/wiki/\""
105+
buildConfigField "String", "EVENTLOG_URL", "\"https://commons.wikimedia.beta.wmflabs.org/beacon/event\""
106+
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
107+
}
108+
}
109+
87110
lintOptions {
88111
disable 'MissingTranslation'
89112
disable 'ExtraTranslation'

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

-23
This file was deleted.

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

-57
This file was deleted.

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

-61
This file was deleted.
Loading
Loading
Loading

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

-7
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ public class CommonsApplication extends DaggerApplication {
4949
@Inject SessionManager sessionManager;
5050
@Inject DBOpenHelper dbOpenHelper;
5151

52-
public static final String API_URL = "https://commons.wikimedia.org/w/api.php";
53-
public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/commons";
54-
public static final String HOME_URL = "https://commons.wikimedia.org/wiki/";
55-
public static final String MOBILE_HOME_URL = "https://commons.m.wikimedia.org/wiki/";
56-
public static final String EVENTLOG_URL = "https://www.wikimedia.org/beacon/event";
57-
public static final String EVENTLOG_WIKI = "commonswiki";
58-
5952
public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5334329L};
6053
public static final Object[] EVENT_LOGIN_ATTEMPT = {"MobileAppLoginAttempts", 5257721L};
6154
public static final Object[] EVENT_SHARE_ATTEMPT = {"MobileAppShareAttempts", 5346170L};

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public String getDisplayText() {
5858
*/
5959
@NonNull
6060
public Uri getCanonicalUri() {
61-
String uriStr = CommonsApplication.HOME_URL + Uri.encode(getPrefixedText(), ":/");
61+
String uriStr = BuildConfig.HOME_URL + Uri.encode(getPrefixedText(), ":/");
6262
return Uri.parse(uriStr);
6363
}
6464

@@ -71,7 +71,7 @@ public Uri getCanonicalUri() {
7171
*/
7272
@NonNull
7373
public Uri getMobileUri() {
74-
String uriStr = CommonsApplication.MOBILE_HOME_URL + Uri.encode(getPrefixedText(), ":/");
74+
String uriStr = BuildConfig.MOBILE_HOME_URL + Uri.encode(getPrefixedText(), ":/");
7575
return Uri.parse(uriStr);
7676
}
7777

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import fr.free.nrw.commons.settings.Prefs;
1313

14+
1415
public class Utils {
1516

1617
/**
@@ -32,7 +33,7 @@ public static String stripLocalizedString(String s) {
3233
public static String makeThumbBaseUrl(String filename) {
3334
String name = new PageTitle(filename).getPrefixedText();
3435
String sha = new String(Hex.encodeHex(DigestUtils.md5(name)));
35-
return String.format("%s/%s/%s/%s", CommonsApplication.IMAGE_URL_BASE, sha.substring(0, 1), sha.substring(0, 2), urlEncode(name));
36+
return String.format("%s/%s/%s/%s", BuildConfig.IMAGE_URL_BASE, sha.substring(0, 1), sha.substring(0, 2), urlEncode(name));
3637
}
3738

3839
public static String urlEncode(String url) {

app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationModule.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import dagger.Module;
88
import dagger.Provides;
9+
import fr.free.nrw.commons.BuildConfig;
910
import fr.free.nrw.commons.CommonsApplication;
1011
import fr.free.nrw.commons.auth.AccountUtil;
1112
import fr.free.nrw.commons.auth.SessionManager;
@@ -37,7 +38,7 @@ public SessionManager providesSessionManager(MediaWikiApi mediaWikiApi) {
3738
@Provides
3839
@Singleton
3940
public MediaWikiApi provideMediaWikiApi() {
40-
return new ApacheHttpClientMediaWikiApi(CommonsApplication.API_URL);
41+
return new ApacheHttpClientMediaWikiApi(BuildConfig.WIKIMEDIA_API_HOST);
4142
}
4243

4344
@Provides

app/src/main/java/fr/free/nrw/commons/mwapi/LogBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ URL toUrl() {
4747
try {
4848
fullData.put("schema", schema);
4949
fullData.put("revision", rev);
50-
fullData.put("wiki", CommonsApplication.EVENTLOG_WIKI);
50+
fullData.put("wiki", BuildConfig.EVENTLOG_WIKI);
5151
data.put("device", EventLog.DEVICE);
5252
data.put("platform", "Android/" + Build.VERSION.RELEASE);
5353
data.put("appversion", "Android/" + BuildConfig.VERSION_NAME);
5454
fullData.put("event", data);
55-
return new URL(CommonsApplication.EVENTLOG_URL + "?" + Utils.urlEncode(fullData.toString()) + ";");
55+
return new URL(BuildConfig.EVENTLOG_URL + "?" + Utils.urlEncode(fullData.toString()) + ";");
5656
} catch (MalformedURLException | JSONException e) {
5757
throw new RuntimeException(e);
5858
}

app/src/main/java/fr/free/nrw/commons/theme/BaseActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import dagger.android.support.DaggerAppCompatActivity;
88
import fr.free.nrw.commons.R;
99

10-
public class BaseActivity extends DaggerAppCompatActivity {
10+
public abstract class BaseActivity extends DaggerAppCompatActivity {
1111
boolean currentTheme;
1212

1313
@Override

0 commit comments

Comments
 (0)