diff --git a/.travis.yml b/.travis.yml
index 20c5bfaee..5e76e09d9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,12 +19,13 @@ android:
components:
- tools
- platform-tools
- - build-tools-26.0.2
+ - build-tools-27.0.0
- extra-google-m2repository
- extra-android-m2repository
- ${ANDROID_TARGET}
- android-25
- android-26
+ - android-27
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
licenses:
- 'android-sdk-license-.+'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c77174cf..1688b3b02 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# Wikimedia Commons for Android
+## v2.7.2
+- Modified subtext for "automatically get current location" setting to emphasize that it will reveal user's location
+
## v2.7.1
- Fixed UI and permission issues with Nearby
- Fixed issue with My Recent Uploads being empty
diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
index 9d7150008..37e104d14 100644
--- a/PULL_REQUEST_TEMPLATE.md
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -1,3 +1,7 @@
+## Title (required)
+
+Fixes #{GitHub issue number and title (Please do not forget adding title) }
+
## Description (required)
Fixes #{GitHub issue number and title}
@@ -12,4 +16,4 @@ Tested on {API level & name of device/emulator}, with {build variant, e.g. ProdD
{Only for user interface changes, otherwise remove this section. See [how to take a screenshot](https://android.stackexchange.com/questions/1759/how-to-take-a-screenshot-with-an-android-device)}
-_Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request._
+_Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request._
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 5d37f8f54..bb0220b30 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,11 +7,12 @@ apply from: 'quality.gradle'
apply plugin: 'com.getkeepsafe.dexcount'
dependencies {
+ implementation 'com.squareup.picasso:picasso:2.71828'
+ implementation 'com.prof.rssparser:rssparser:1.1'
implementation 'com.github.nicolas-raoul:Quadtree:ac16ea8035bf07'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
implementation 'in.yuvi:http.fluent:1.3'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
- implementation 'com.android.volley:volley:1.0.0'
implementation 'ch.acra:acra:4.9.2'
implementation 'org.mediawiki:api:1.3'
implementation 'commons-codec:commons-codec:1.10'
@@ -21,47 +22,36 @@ dependencies {
implementation 'info.debatty:java-string-similarity:0.24'
implementation 'com.borjabravo:readmoretextview:2.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
- implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.4.1@aar'){
- transitive=true
+ implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0@aar') {
+ transitive = true
}
-
- implementation "com.github.deano2390:MaterialShowcaseView:1.2.0"
-
+ implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
implementation "com.android.support:design:$SUPPORT_LIB_VERSION"
implementation "com.android.support:customtabs:$SUPPORT_LIB_VERSION"
-
implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VERSION"
-
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
-
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.squareup.okio:okio:1.13.0'
-
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
implementation 'com.android.support:multidex:1.0.3'
-
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
-
implementation 'org.jsoup:jsoup:1.11.3'
-
implementation 'com.facebook.fresco:fresco:1.5.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
-
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
kapt "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
-
- testImplementation "org.robolectric:multidex:3.4.2"
+ testImplementation 'org.robolectric:multidex:3.4.2'
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation 'junit:junit:4.12'
@@ -69,10 +59,16 @@ dependencies {
testImplementation 'com.nhaarman:mockito-kotlin:1.5.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
+ implementation 'com.caverock:androidsvg:1.2.1'
+ implementation 'com.github.bumptech.glide:glide:4.7.1'
+ kapt 'com.github.bumptech.glide:compiler:4.7.1'
+
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
androidTestImplementation "com.android.support:support-annotations:$SUPPORT_LIB_VERSION"
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2-alpha1'
+ androidTestImplementation 'com.android.support.test:rules:1.0.2'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY"
@@ -87,8 +83,8 @@ android {
defaultConfig {
applicationId 'fr.free.nrw.commons'
- versionCode 84
- versionName '2.7.1'
+ versionCode 85
+ versionName '2.7.2'
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
minSdkVersion project.minSdkVersion
@@ -117,7 +113,7 @@ android {
buildTypes {
release {
minifyEnabled false // See https://stackoverflow.com/questions/40232404/google-play-apk-and-android-studio-apk-usb-debug-behaving-differently - proguard.cfg modification alone insufficient.
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-glide.txt'
}
debug {
applicationIdSuffix ".debug"
@@ -129,7 +125,9 @@ android {
flavorDimensions 'tier'
productFlavors {
prod {
+ buildConfigField "String", "WIKIMEDIA_API_POTD", "\"https://commons.wikimedia.org/w/api.php?action=featuredfeed&feed=potd&feedformat=rss&language=en\""
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.org/w/api.php\""
+ buildConfigField "String", "WIKIDATA_API_HOST", "\"https://www.wikidata.org/w/api.php\""
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.wikimedia.org/wikipedia/commons\""
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.org/wiki/\""
@@ -145,7 +143,9 @@ android {
beta {
// What values do we need to hit the BETA versions of the site / api ?
+ buildConfigField "String", "WIKIMEDIA_API_POTD", "\"https://commons.wikimedia.org/w/api.php?action=featuredfeed&feed=potd&feedformat=rss&language=en\""
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.beta.wmflabs.org/w/api.php\""
+ buildConfigField "String", "WIKIDATA_API_HOST", "\"https://www.wikidata.org/w/api.php\""
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.beta.wmflabs.org/wikipedia/commons\""
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.beta.wmflabs.org/wiki/\""
diff --git a/app/libs/java-json.jar b/app/libs/java-json.jar
new file mode 100644
index 000000000..2f211e366
Binary files /dev/null and b/app/libs/java-json.jar differ
diff --git a/app/proguard-glide.txt b/app/proguard-glide.txt
new file mode 100644
index 000000000..ef3437660
--- /dev/null
+++ b/app/proguard-glide.txt
@@ -0,0 +1,9 @@
+-keep public class * implements com.bumptech.glide.module.GlideModule
+-keep public class * extends com.bumptech.glide.module.AppGlideModule
+-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
+ **[] $VALUES;
+ public *;
+}
+
+# for DexGuard only
+-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
\ No newline at end of file
diff --git a/app/proguard-rules.txt b/app/proguard-rules.txt
index bbf3a3f0d..39b618718 100644
--- a/app/proguard-rules.txt
+++ b/app/proguard-rules.txt
@@ -1,5 +1,4 @@
-dontobfuscate
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
--keep class fr.free.nrw.commons.upload.MwVolleyApi$Page {*;}
-keep class android.support.v7.widget.ShareActionProvider { *; }
\ No newline at end of file
diff --git a/app/quality.gradle b/app/quality.gradle
index 7ea20916a..1afdf0d68 100644
--- a/app/quality.gradle
+++ b/app/quality.gradle
@@ -18,7 +18,7 @@ task checkstyle(type: Checkstyle) {
reports {
html {
enabled true
- destination "${project.buildDir}/reports/checkstyle/checkstyle.html"
+ destination file("${project.buildDir}/reports/checkstyle/checkstyle.html")
}
}
}
@@ -36,10 +36,10 @@ task pmd(type: Pmd) {
xml.enabled = false
html.enabled = true
xml {
- destination "${project.buildDir}/reports/pmd/pmd.xml"
+ destination file("${project.buildDir}/reports/pmd/pmd.xml")
}
html {
- destination "${project.buildDir}/reports/pmd/pmd.html"
+ destination file("${project.buildDir}/reports/pmd/pmd.html")
}
}
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 17f6770d2..38fc2e35a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -15,6 +15,7 @@
+
@@ -26,10 +27,10 @@
android:theme="@style/LightAppTheme"
android:supportsRtl="true" >
+ android:theme="@android:style/Theme.Dialog"
+ android:launchMode="singleInstance"
+ android:excludeFromRecents="true"
+ android:finishOnTaskLaunch="true" />
@@ -164,6 +165,16 @@
android:label="@string/provider_categories"
android:syncable="false" />
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java
index 65cba7531..c8941dcd8 100644
--- a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java
+++ b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java
@@ -9,9 +9,6 @@ import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.text.style.UnderlineSpan;
-import android.util.Log;
-import android.support.customtabs.CustomTabsIntent;
-import android.support.v4.content.ContextCompat;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -20,7 +17,6 @@ import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
-import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -28,8 +24,6 @@ import butterknife.OnClick;
import fr.free.nrw.commons.theme.NavigationBaseActivity;
import fr.free.nrw.commons.ui.widget.HtmlTextView;
-import static android.widget.Toast.LENGTH_SHORT;
-
/**
* Represents about screen of this app
*/
diff --git a/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java b/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
index 57cb5fad1..61eecee00 100644
--- a/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
+++ b/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
@@ -1,6 +1,5 @@
package fr.free.nrw.commons;
-import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
@@ -27,7 +26,7 @@ import fr.free.nrw.commons.contributions.ContributionDao;
import fr.free.nrw.commons.data.DBOpenHelper;
import fr.free.nrw.commons.di.ApplicationlessInjection;
import fr.free.nrw.commons.modifications.ModifierSequenceDao;
-import fr.free.nrw.commons.utils.FileUtils;
+import fr.free.nrw.commons.upload.FileUtils;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
diff --git a/app/src/main/java/fr/free/nrw/commons/Utils.java b/app/src/main/java/fr/free/nrw/commons/Utils.java
index 91c23ce26..9f89586c0 100644
--- a/app/src/main/java/fr/free/nrw/commons/Utils.java
+++ b/app/src/main/java/fr/free/nrw/commons/Utils.java
@@ -178,6 +178,7 @@ public class Utils {
}
public static void handleWebUrl(Context context, Uri url) {
+ Timber.d("Launching web url %s", url.toString());
Intent browserIntent = new Intent(Intent.ACTION_VIEW, url);
if (browserIntent.resolveActivity(context.getPackageManager()) == null) {
Toast toast = Toast.makeText(context, context.getString(R.string.no_web_browser), LENGTH_SHORT);
diff --git a/app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java b/app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java
index b19d70a4e..27a6f6899 100644
--- a/app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java
+++ b/app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java
@@ -4,8 +4,8 @@ import android.accounts.Account;
import android.accounts.AccountAuthenticatorActivity;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
-import android.app.Activity;
import android.app.ProgressDialog;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
@@ -23,7 +23,6 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
@@ -136,6 +135,11 @@ public class LoginActivity extends AccountAuthenticatorActivity {
}
}
+ public static void startYourself(Context context) {
+ Intent intent = new Intent(context, LoginActivity.class);
+ context.startActivity(intent);
+ }
+
private void forgotPassword() {
Utils.handleWebUrl(this, Uri.parse(BuildConfig.FORGOT_PASSWORD_URL));
}
diff --git a/app/src/main/java/fr/free/nrw/commons/auth/SessionManager.java b/app/src/main/java/fr/free/nrw/commons/auth/SessionManager.java
index ad9a0bda4..9ef6b7843 100644
--- a/app/src/main/java/fr/free/nrw/commons/auth/SessionManager.java
+++ b/app/src/main/java/fr/free/nrw/commons/auth/SessionManager.java
@@ -81,6 +81,12 @@ public class SessionManager {
return sharedPreferences.getBoolean("isUserLoggedIn", false);
}
+ public void forceLogin(Context context) {
+ if (context != null) {
+ LoginActivity.startYourself(context);
+ }
+ }
+
public Completable clearAllAccounts() {
AccountManager accountManager = AccountManager.get(context);
Account[] allAccounts = accountManager.getAccountsByType(ACCOUNT_TYPE);
diff --git a/app/src/main/java/fr/free/nrw/commons/caching/CacheController.java b/app/src/main/java/fr/free/nrw/commons/caching/CacheController.java
index ff6ceece4..72de0db70 100644
--- a/app/src/main/java/fr/free/nrw/commons/caching/CacheController.java
+++ b/app/src/main/java/fr/free/nrw/commons/caching/CacheController.java
@@ -7,18 +7,25 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import fr.free.nrw.commons.upload.MwVolleyApi;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import fr.free.nrw.commons.upload.GpsCategoryModel;
import timber.log.Timber;
+@Singleton
public class CacheController {
+ private final GpsCategoryModel gpsCategoryModel;
+ private final QuadTree> quadTree;
private double x, y;
- private QuadTree> quadTree;
private double xMinus, xPlus, yMinus, yPlus;
private static final int EARTH_RADIUS = 6378137;
- public CacheController() {
+ @Inject
+ CacheController(GpsCategoryModel gpsCategoryModel) {
+ this.gpsCategoryModel = gpsCategoryModel;
quadTree = new QuadTree<>(-180, -90, +180, +90);
}
@@ -31,8 +38,8 @@ public class CacheController {
public void cacheCategory() {
List pointCatList = new ArrayList<>();
- if (MwVolleyApi.GpsCatExists.getGpsCatExists()) {
- pointCatList.addAll(MwVolleyApi.getGpsCat());
+ if (gpsCategoryModel.getGpsCatExists()) {
+ pointCatList.addAll(gpsCategoryModel.getCategoryList());
Timber.d("Categories being cached: %s", pointCatList);
} else {
Timber.d("No categories found, so no categories cached");
@@ -65,7 +72,7 @@ public class CacheController {
}
//Based on algorithm at http://gis.stackexchange.com/questions/2951/algorithm-for-offsetting-a-latitude-longitude-by-some-amount-of-meters
- public void convertCoordRange() {
+ private void convertCoordRange() {
//Position, decimal degrees
double lat = y;
double lon = x;
diff --git a/app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java b/app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java
index e804189ab..93ddb60d5 100644
--- a/app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java
+++ b/app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java
@@ -39,7 +39,7 @@ import butterknife.ButterKnife;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
import fr.free.nrw.commons.mwapi.MediaWikiApi;
-import fr.free.nrw.commons.upload.MwVolleyApi;
+import fr.free.nrw.commons.upload.GpsCategoryModel;
import fr.free.nrw.commons.utils.StringSortingUtils;
import fr.free.nrw.commons.utils.ViewUtil;
import io.reactivex.Observable;
@@ -73,6 +73,7 @@ public class CategorizationFragment extends CommonsDaggerSupportFragment {
@Inject @Named("prefs") SharedPreferences prefsPrefs;
@Inject @Named("direct_nearby_upload_prefs") SharedPreferences directPrefs;
@Inject CategoryDao categoryDao;
+ @Inject GpsCategoryModel gpsCategoryModel;
private RVRendererAdapter categoriesAdapter;
private OnCategoriesSaveHandler onCategoriesSaveHandler;
@@ -253,7 +254,6 @@ public class CategorizationFragment extends CommonsDaggerSupportFragment {
}
private Observable defaultCategories() {
-
Observable directCat = directCategories();
if (hasDirectCategories) {
Timber.d("Image has direct Cat");
@@ -287,9 +287,7 @@ public class CategorizationFragment extends CommonsDaggerSupportFragment {
}
private Observable gpsCategories() {
- return Observable.fromIterable(
- MwVolleyApi.GpsCatExists.getGpsCatExists()
- ? MwVolleyApi.getGpsCat() : new ArrayList<>())
+ return Observable.fromIterable(gpsCategoryModel.getCategoryList())
.map(name -> new CategoryItem(name, false));
}
diff --git a/app/src/main/java/fr/free/nrw/commons/category/CategoryImagesActivity.java b/app/src/main/java/fr/free/nrw/commons/category/CategoryImagesActivity.java
index 1f385b258..17601151c 100644
--- a/app/src/main/java/fr/free/nrw/commons/category/CategoryImagesActivity.java
+++ b/app/src/main/java/fr/free/nrw/commons/category/CategoryImagesActivity.java
@@ -14,7 +14,6 @@ import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.auth.AuthenticatedActivity;
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
-import timber.log.Timber;
/**
* This activity displays pictures of a particular category
diff --git a/app/src/main/java/fr/free/nrw/commons/category/CategoryImagesListFragment.java b/app/src/main/java/fr/free/nrw/commons/category/CategoryImagesListFragment.java
index 3b6734edd..a44e19a29 100644
--- a/app/src/main/java/fr/free/nrw/commons/category/CategoryImagesListFragment.java
+++ b/app/src/main/java/fr/free/nrw/commons/category/CategoryImagesListFragment.java
@@ -224,4 +224,14 @@ public class CategoryImagesListFragment extends DaggerFragment {
public ListAdapter getAdapter() {
return gridView.getAdapter();
}
+
+ /**
+ * This method will be called on back pressed of CategoryImagesActivity.
+ * It initializes the grid view by setting adapter.
+ */
+ @Override
+ public void onResume() {
+ gridView.setAdapter(gridAdapter);
+ super.onResume();
+ }
}
diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/Contribution.java b/app/src/main/java/fr/free/nrw/commons/contributions/Contribution.java
index 7861f96de..99009c029 100644
--- a/app/src/main/java/fr/free/nrw/commons/contributions/Contribution.java
+++ b/app/src/main/java/fr/free/nrw/commons/contributions/Contribution.java
@@ -45,6 +45,7 @@ public class Contribution extends Media {
private long transferred;
private String decimalCoords;
private boolean isMultiple;
+ private String wikiDataEntityId;
public Contribution(Uri contentUri, String filename, Uri localUri, String imageUrl, Date timestamp,
int state, long dataLength, Date dateUploaded, long transferred,
@@ -222,4 +223,17 @@ public class Contribution extends Media {
throw new RuntimeException("Unrecognized license value: " + license);
}
+
+ public String getWikiDataEntityId() {
+ return wikiDataEntityId;
+ }
+
+ /**
+ * When the corresponding wikidata entity is known as in case of nearby uploads, it can be set
+ * using the setter method
+ * @param wikiDataEntityId
+ */
+ public void setWikiDataEntityId(String wikiDataEntityId) {
+ this.wikiDataEntityId = wikiDataEntityId;
+ }
}
diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionController.java b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionController.java
index 37b3d5377..ed6001f94 100644
--- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionController.java
+++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionController.java
@@ -90,7 +90,7 @@ public class ContributionController {
fragment.startActivityForResult(pickImageIntent, SELECT_FROM_GALLERY);
}
- public void handleImagePicked(int requestCode, Intent data, boolean isDirectUpload) {
+ public void handleImagePicked(int requestCode, Intent data, boolean isDirectUpload, String wikiDataEntityId) {
FragmentActivity activity = fragment.getActivity();
Timber.d("handleImagePicked() called with onActivityResult()");
Intent shareIntent = new Intent(activity, ShareActivity.class);
@@ -102,9 +102,6 @@ public class ContributionController {
shareIntent.setType(activity.getContentResolver().getType(imageData));
shareIntent.putExtra(EXTRA_STREAM, imageData);
shareIntent.putExtra(EXTRA_SOURCE, SOURCE_GALLERY);
- if (isDirectUpload) {
- shareIntent.putExtra("isDirectUpload", true);
- }
break;
case SELECT_FROM_CAMERA:
//FIXME: Find out appropriate mime type
@@ -113,9 +110,6 @@ public class ContributionController {
shareIntent.setType("image/jpeg");
shareIntent.putExtra(EXTRA_STREAM, lastGeneratedCaptureUri);
shareIntent.putExtra(EXTRA_SOURCE, SOURCE_CAMERA);
- if (isDirectUpload) {
- shareIntent.putExtra("isDirectUpload", true);
- }
break;
default:
@@ -123,6 +117,10 @@ public class ContributionController {
}
Timber.i("Image selected");
try {
+ shareIntent.putExtra("isDirectUpload", isDirectUpload);
+ if (wikiDataEntityId != null && !wikiDataEntityId.equals("")) {
+ shareIntent.putExtra("wikiDataEntityId", wikiDataEntityId);
+ }
activity.startActivity(shareIntent);
} catch (SecurityException e) {
Timber.e(e, "Security Exception");
diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionDao.java b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionDao.java
index 079cf6477..6d290b1a5 100644
--- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionDao.java
+++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionDao.java
@@ -8,7 +8,6 @@ import android.net.Uri;
import android.os.RemoteException;
import android.support.annotation.Nullable;
import android.text.TextUtils;
-import android.util.Log;
import java.util.Date;
diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsActivity.java b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsActivity.java
index ad6cff606..e5f6f53bb 100644
--- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsActivity.java
+++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsActivity.java
@@ -276,17 +276,25 @@ public class ContributionsActivity
.getUploadCount(sessionManager.getCurrentAccount().name)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
- .subscribe(
- uploadCount -> getSupportActionBar().setSubtitle(getResources()
- .getQuantityString(R.plurals.contributions_subtitle,
- uploadCount, uploadCount)),
+ .subscribe(this::displayUploadCount,
t -> Timber.e(t, "Fetching upload count failed")
));
}
- public void betaSetUploadCount(int betaUploadCount){
+ private void displayUploadCount(Integer uploadCount) {
+ if (isFinishing()
+ || getSupportActionBar() == null
+ || getResources() == null) {
+ return;
+ }
+
getSupportActionBar().setSubtitle(getResources()
- .getQuantityString(R.plurals.contributions_subtitle, betaUploadCount, betaUploadCount));
+ .getQuantityString(R.plurals.contributions_subtitle,
+ uploadCount, uploadCount));
+ }
+
+ public void betaSetUploadCount(int betaUploadCount) {
+ displayUploadCount(betaUploadCount);
}
diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java
index ff400a8dd..0b600c5d0 100644
--- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java
+++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java
@@ -117,7 +117,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment {
if (resultCode == RESULT_OK) {
Timber.d("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
requestCode, resultCode, data);
- controller.handleImagePicked(requestCode, data, false);
+ controller.handleImagePicked(requestCode, data, false, null);
} else {
Timber.e("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
requestCode, resultCode, data);
diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java
index 91f6d4ccb..43721a217 100644
--- a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java
+++ b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java
@@ -9,17 +9,18 @@ import dagger.android.support.AndroidSupportInjectionModule;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.MediaWikiImageView;
import fr.free.nrw.commons.auth.LoginActivity;
-import fr.free.nrw.commons.contributions.Contribution;
-import fr.free.nrw.commons.contributions.ContributionsActivity;
import fr.free.nrw.commons.contributions.ContributionsSyncAdapter;
import fr.free.nrw.commons.delete.DeleteTask;
import fr.free.nrw.commons.modifications.ModificationsSyncAdapter;
-import fr.free.nrw.commons.settings.SettingsFragment;
import fr.free.nrw.commons.nearby.PlaceRenderer;
+import fr.free.nrw.commons.upload.FileProcessor;
+import fr.free.nrw.commons.settings.SettingsFragment;
+
@Singleton
@Component(modules = {
CommonsApplicationModule.class,
+ NetworkingModule.class,
AndroidInjectionModule.class,
AndroidSupportInjectionModule.class,
ActivityBuilderModule.class,
@@ -47,6 +48,8 @@ public interface CommonsApplicationComponent extends AndroidInjector provideLruCache() {
return new LruCache<>(1024);
}
+
+ @Provides
+ @Singleton
+ public WikidataEditListener provideWikidataEditListener() {
+ return new WikidataEditListenerImpl();
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/fr/free/nrw/commons/di/NetworkingModule.java b/app/src/main/java/fr/free/nrw/commons/di/NetworkingModule.java
new file mode 100644
index 000000000..cd043e950
--- /dev/null
+++ b/app/src/main/java/fr/free/nrw/commons/di/NetworkingModule.java
@@ -0,0 +1,59 @@
+package fr.free.nrw.commons.di;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.support.annotation.NonNull;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+import fr.free.nrw.commons.BuildConfig;
+import fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApi;
+import fr.free.nrw.commons.mwapi.MediaWikiApi;
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+
+@Module
+@SuppressWarnings({"WeakerAccess", "unused"})
+public class NetworkingModule {
+ public static final long OK_HTTP_CACHE_SIZE = 10 * 1024 * 1024;
+
+ @Provides
+ @Singleton
+ public OkHttpClient provideOkHttpClient() {
+ return new OkHttpClient.Builder().build();
+ }
+
+ @Provides
+ @Singleton
+ public MediaWikiApi provideMediaWikiApi(Context context,
+ @Named("default_preferences") SharedPreferences defaultPreferences,
+ @Named("category_prefs") SharedPreferences categoryPrefs,
+ Gson gson) {
+ return new ApacheHttpClientMediaWikiApi(context, BuildConfig.WIKIMEDIA_API_HOST, BuildConfig.WIKIDATA_API_HOST, defaultPreferences, categoryPrefs, gson);
+ }
+
+ @Provides
+ @Named("commons_mediawiki_url")
+ @NonNull
+ @SuppressWarnings("ConstantConditions")
+ public HttpUrl provideMwUrl() {
+ return HttpUrl.parse(BuildConfig.COMMONS_URL);
+ }
+
+ /**
+ * Gson objects are very heavy. The app should ideally be using just one instance of it instead of creating new instances everywhere.
+ * @return returns a singleton Gson instance
+ */
+ @Provides
+ @Singleton
+ public Gson provideGson() {
+ return new GsonBuilder().create();
+ }
+
+}
diff --git a/app/src/main/java/fr/free/nrw/commons/glide/SvgDecoder.java b/app/src/main/java/fr/free/nrw/commons/glide/SvgDecoder.java
new file mode 100644
index 000000000..9087f9501
--- /dev/null
+++ b/app/src/main/java/fr/free/nrw/commons/glide/SvgDecoder.java
@@ -0,0 +1,36 @@
+package fr.free.nrw.commons.glide;
+
+import android.support.annotation.NonNull;
+
+import com.bumptech.glide.load.Options;
+import com.bumptech.glide.load.ResourceDecoder;
+import com.bumptech.glide.load.engine.Resource;
+import com.bumptech.glide.load.resource.SimpleResource;
+import com.caverock.androidsvg.SVG;
+import com.caverock.androidsvg.SVGParseException;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Decodes an SVG internal representation from an {@link InputStream}.
+ */
+public class SvgDecoder implements ResourceDecoder {
+
+ @Override
+ public boolean handles(@NonNull InputStream source, @NonNull Options options) {
+ // TODO: Can we tell?
+ return true;
+ }
+
+ public Resource