mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Product flavors to allow switching between the production and the beta-cluster Wikimedia servers.
This commit is contained in:
parent
b1c13efcd6
commit
ca4b99a1cc
8 changed files with 34 additions and 16 deletions
|
|
@ -47,12 +47,6 @@ import timber.log.Timber;
|
|||
public class CommonsApplication extends Application {
|
||||
|
||||
private Account currentAccount = null; // Unlike a savings account...
|
||||
public static final String API_URL = "https://commons.wikimedia.org/w/api.php";
|
||||
public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/commons";
|
||||
public static final String HOME_URL = "https://commons.wikimedia.org/wiki/";
|
||||
public static final String MOBILE_HOME_URL = "https://commons.m.wikimedia.org/wiki/";
|
||||
public static final String EVENTLOG_URL = "https://www.wikimedia.org/beacon/event";
|
||||
public static final String EVENTLOG_WIKI = "commonswiki";
|
||||
|
||||
public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5334329L};
|
||||
public static final Object[] EVENT_LOGIN_ATTEMPT = {"MobileAppLoginAttempts", 5257721L};
|
||||
|
|
@ -88,7 +82,7 @@ public class CommonsApplication extends Application {
|
|||
|
||||
public MediaWikiApi getMWApi() {
|
||||
if (api == null) {
|
||||
api = new ApacheHttpClientMediaWikiApi(API_URL);
|
||||
api = new ApacheHttpClientMediaWikiApi(BuildConfig.WIKIMEDIA_API_HOST);
|
||||
}
|
||||
return api;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class PageTitle {
|
|||
*/
|
||||
@NonNull
|
||||
public Uri getCanonicalUri() {
|
||||
String uriStr = CommonsApplication.HOME_URL + Uri.encode(getPrefixedText(), ":/");
|
||||
String uriStr = BuildConfig.HOME_URL + Uri.encode(getPrefixedText(), ":/");
|
||||
return Uri.parse(uriStr);
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ public class PageTitle {
|
|||
*/
|
||||
@NonNull
|
||||
public Uri getMobileUri() {
|
||||
String uriStr = CommonsApplication.MOBILE_HOME_URL + Uri.encode(getPrefixedText(), ":/");
|
||||
String uriStr = BuildConfig.MOBILE_HOME_URL + Uri.encode(getPrefixedText(), ":/");
|
||||
return Uri.parse(uriStr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import javax.xml.transform.stream.StreamResult;
|
|||
import fr.free.nrw.commons.settings.Prefs;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
public class Utils {
|
||||
|
||||
// Get SHA1 of file from input stream
|
||||
|
|
@ -80,10 +79,12 @@ public class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
/** Fix Html.fromHtml is deprecated problem
|
||||
/**
|
||||
* Fix Html.fromHtml is deprecated problem
|
||||
*
|
||||
* @param source provided Html string
|
||||
* @return returned Spanned of appropriate method according to version check
|
||||
* */
|
||||
*/
|
||||
public static Spanned fromHtml(String source) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
|
||||
|
|
@ -127,7 +128,7 @@ public class Utils {
|
|||
public static String makeThumbBaseUrl(String filename) {
|
||||
String name = new PageTitle(filename).getPrefixedText();
|
||||
String sha = new String(Hex.encodeHex(DigestUtils.md5(name)));
|
||||
return String.format("%s/%s/%s/%s", CommonsApplication.IMAGE_URL_BASE, sha.substring(0, 1), sha.substring(0, 2), urlEncode(name));
|
||||
return String.format("%s/%s/%s/%s", BuildConfig.IMAGE_URL_BASE, sha.substring(0, 1), sha.substring(0, 2), urlEncode(name));
|
||||
}
|
||||
|
||||
public static String getStringFromDOM(Node dom) {
|
||||
|
|
@ -277,6 +278,6 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static boolean isDarkTheme(Context context) {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("theme",false);
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("theme", false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ public class LogBuilder {
|
|||
try {
|
||||
fullData.put("schema", schema);
|
||||
fullData.put("revision", rev);
|
||||
fullData.put("wiki", CommonsApplication.EVENTLOG_WIKI);
|
||||
fullData.put("wiki", BuildConfig.EVENTLOG_WIKI);
|
||||
data.put("device", EventLog.DEVICE);
|
||||
data.put("platform", "Android/" + Build.VERSION.RELEASE);
|
||||
data.put("appversion", "Android/" + BuildConfig.VERSION_NAME);
|
||||
fullData.put("event", data);
|
||||
return new URL(CommonsApplication.EVENTLOG_URL + "?" + Utils.urlEncode(fullData.toString()) + ";");
|
||||
return new URL(BuildConfig.EVENTLOG_URL + "?" + Utils.urlEncode(fullData.toString()) + ";");
|
||||
} catch (MalformedURLException | JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue