mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Merge branch 'master' into dependency-injection
This commit is contained in:
commit
2d91e81121
19 changed files with 288 additions and 168 deletions
|
|
@ -49,13 +49,6 @@ public class CommonsApplication extends DaggerApplication {
|
|||
@Inject SessionManager sessionManager;
|
||||
@Inject DBOpenHelper dbOpenHelper;
|
||||
|
||||
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};
|
||||
public static final Object[] EVENT_SHARE_ATTEMPT = {"MobileAppShareAttempts", 5346170L};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import fr.free.nrw.commons.settings.Prefs;
|
||||
|
||||
|
||||
public class Utils {
|
||||
|
||||
/**
|
||||
|
|
@ -32,7 +33,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 urlEncode(String url) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import javax.inject.Singleton;
|
|||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.auth.AccountUtil;
|
||||
import fr.free.nrw.commons.auth.SessionManager;
|
||||
|
|
@ -37,7 +38,7 @@ public class CommonsApplicationModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
public MediaWikiApi provideMediaWikiApi() {
|
||||
return new ApacheHttpClientMediaWikiApi(CommonsApplication.API_URL);
|
||||
return new ApacheHttpClientMediaWikiApi(BuildConfig.WIKIMEDIA_API_HOST);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
|||
|
|
@ -47,12 +47,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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import android.preference.PreferenceManager;
|
|||
import dagger.android.support.DaggerAppCompatActivity;
|
||||
import fr.free.nrw.commons.R;
|
||||
|
||||
public class BaseActivity extends DaggerAppCompatActivity {
|
||||
public abstract class BaseActivity extends DaggerAppCompatActivity {
|
||||
boolean currentTheme;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue