Skip to content

Commit a083373

Browse files
authored
Merge branch 'master' into master
2 parents 9070599 + 568f19c commit a083373

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+304
-239
lines changed

ISSUE_TEMPLATE.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1-
_Before creating an issue, please search the existing issues to see if a similar one has already been created. You can search issues by specific labels (e.g. `label:nearby `) or just by typing keywords into the search filter._
2-
31
**Summary:**
42

53
Summarize your issue in one sentence (what goes wrong, what did you expect to happen)
64

5+
_Before creating an issue, please search the existing issues to see if a similar one has already been created. You can search issues by specific labels (e.g. `label:nearby `) or just by typing keywords into the search filter._
6+
77
**Steps to reproduce:**
88

9-
How can we reproduce the issue?
9+
How can we reproduce the issue?
10+
What did you expect the app to do, and what did you see instead?
1011

1112
**Add System logs:**
1213

1314
Add logcat files here (if possible).
1415

15-
**Expected behavior:**
16-
17-
What did you expect the App to do?
18-
19-
**Observed behavior:**
20-
21-
What did you see instead? Describe your issue in detail here.
22-
2316
**Device and Android version:**
2417

2518
What make and model device (e.g., Samsung J7) did you encounter this on? What Android
@@ -28,7 +21,7 @@ version (e.g., Android 4.0 Ice Cream Sandwich or Android 6.0 Marshmallow) are yo
2821

2922
**Commons app version:**
3023

31-
You can find this information by going to the navigation drawer in the app and tapping 'About'
24+
You can find this information by going to the navigation drawer in the app and tapping 'About'. If you are building from our codebase instead of downloading the app, please also mention the branch and build variant (e.g. master and prodDebug).
3225

3326
**Screen-shots:**
3427

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dependencies {
2121
implementation 'com.jakewharton.timber:timber:4.5.1'
2222
implementation 'info.debatty:java-string-similarity:0.24'
2323
implementation 'com.borjabravo:readmoretextview:2.1.0'
24-
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
24+
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
2525
implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0@aar') {
2626
transitive = true
2727
}

app/src/main/java/fr/free/nrw/commons/auth/SessionManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import android.content.Context;
66
import android.content.SharedPreferences;
77

8+
import javax.annotation.Nullable;
9+
810
import fr.free.nrw.commons.mwapi.MediaWikiApi;
911
import io.reactivex.Completable;
1012
import io.reactivex.Observable;
@@ -31,6 +33,7 @@ public SessionManager(Context context, MediaWikiApi mediaWikiApi, SharedPreferen
3133
/**
3234
* @return Account|null
3335
*/
36+
@Nullable
3437
public Account getCurrentAccount() {
3538
if (currentAccount == null) {
3639
AccountManager accountManager = AccountManager.get(context);

app/src/main/java/fr/free/nrw/commons/contributions/ContributionController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static fr.free.nrw.commons.contributions.Contribution.SOURCE_CAMERA;
2525
import static fr.free.nrw.commons.contributions.Contribution.SOURCE_GALLERY;
2626
import static fr.free.nrw.commons.upload.UploadService.EXTRA_SOURCE;
27+
import static fr.free.nrw.commons.wikidata.WikidataConstants.WIKIDATA_ENTITY_ID_PREF;
2728

2829
public class ContributionController {
2930

@@ -91,6 +92,7 @@ public void startGalleryPick() {
9192
}
9293

9394
public void handleImagePicked(int requestCode, Intent data, boolean isDirectUpload, String wikiDataEntityId) {
95+
Timber.d("Is direct upload %s and the Wikidata entity ID is %s", isDirectUpload, wikiDataEntityId);
9496
FragmentActivity activity = fragment.getActivity();
9597
Timber.d("handleImagePicked() called with onActivityResult()");
9698
Intent shareIntent = new Intent(activity, ShareActivity.class);
@@ -119,7 +121,7 @@ public void handleImagePicked(int requestCode, Intent data, boolean isDirectUplo
119121
try {
120122
shareIntent.putExtra("isDirectUpload", isDirectUpload);
121123
if (wikiDataEntityId != null && !wikiDataEntityId.equals("")) {
122-
shareIntent.putExtra("wikiDataEntityId", wikiDataEntityId);
124+
shareIntent.putExtra(WIKIDATA_ENTITY_ID_PREF, wikiDataEntityId);
123125
}
124126
activity.startActivity(shareIntent);
125127
} catch (SecurityException e) {

app/src/main/java/fr/free/nrw/commons/nearby/NearbyListFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
import static android.app.Activity.RESULT_OK;
3737
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
38+
import static fr.free.nrw.commons.wikidata.WikidataConstants.WIKIDATA_ENTITY_ID_PREF;
3839

3940
public class NearbyListFragment extends DaggerFragment {
4041
private Bundle bundleForUpdates; // Carry information from activity about changed nearby places and current location
@@ -146,7 +147,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
146147
if (resultCode == RESULT_OK) {
147148
Timber.d("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
148149
requestCode, resultCode, data);
149-
controller.handleImagePicked(requestCode, data, true, directPrefs.getString("WikiDataEntityId", null));
150+
controller.handleImagePicked(requestCode, data, true, directPrefs.getString(WIKIDATA_ENTITY_ID_PREF, null));
150151
} else {
151152
Timber.e("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
152153
requestCode, resultCode, data);

app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363

6464
import static android.app.Activity.RESULT_OK;
6565
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
66+
import static fr.free.nrw.commons.wikidata.WikidataConstants.WIKIDATA_ENTITY_ID_PREF;
6667

6768
public class NearbyMapFragment extends DaggerFragment {
6869

@@ -711,15 +712,15 @@ private void passInfoToSheet(Place place) {
711712

712713
fabCamera.setOnClickListener(view -> {
713714
if (fabCamera.isShown()) {
714-
Timber.d("Camera button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
715+
Timber.d("Camera button tapped. Place: %s", place.toString());
715716
storeSharedPrefs();
716717
directUpload.initiateCameraUpload();
717718
}
718719
});
719720

720721
fabGallery.setOnClickListener(view -> {
721722
if (fabGallery.isShown()) {
722-
Timber.d("Gallery button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
723+
Timber.d("Gallery button tapped. Place: %s", place.toString());
723724
storeSharedPrefs();
724725
directUpload.initiateGalleryUpload();
725726
}
@@ -731,7 +732,7 @@ void storeSharedPrefs() {
731732
editor.putString("Title", place.getName());
732733
editor.putString("Desc", place.getLongDescription());
733734
editor.putString("Category", place.getCategory());
734-
editor.putString("WikiDataEntityId", place.getWikiDataEntityId());
735+
editor.putString(WIKIDATA_ENTITY_ID_PREF, place.getWikiDataEntityId());
735736
editor.apply();
736737
}
737738

@@ -767,7 +768,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
767768
if (resultCode == RESULT_OK) {
768769
Timber.d("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
769770
requestCode, resultCode, data);
770-
controller.handleImagePicked(requestCode, data, true, directPrefs.getString("WikiDataEntityId", null));
771+
controller.handleImagePicked(requestCode, data, true, directPrefs.getString(WIKIDATA_ENTITY_ID_PREF, null));
771772
} else {
772773
Timber.e("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
773774
requestCode, resultCode, data);

app/src/main/java/fr/free/nrw/commons/nearby/Place.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import fr.free.nrw.commons.R;
1212
import fr.free.nrw.commons.location.LatLng;
13+
import timber.log.Timber;
1314

1415
public class Place {
1516

@@ -58,10 +59,12 @@ public void setDistance(String distance) {
5859
@Nullable
5960
public String getWikiDataEntityId() {
6061
if (!hasWikidataLink()) {
62+
Timber.d("Wikidata entity ID is null for place with sitelink %s", siteLinks.toString());
6163
return null;
6264
}
6365

6466
String wikiDataLink = siteLinks.getWikidataLink().toString();
67+
Timber.d("Wikidata entity is %s", wikiDataLink);
6568
return wikiDataLink.replace("http://www.wikidata.org/entity/", "");
6669
}
6770

@@ -94,7 +97,18 @@ public int hashCode() {
9497

9598
@Override
9699
public String toString() {
97-
return String.format("Place(%s@%s)", name, location);
100+
return "Place{" +
101+
"name='" + name + '\'' +
102+
", label='" + label + '\'' +
103+
", longDescription='" + longDescription + '\'' +
104+
", secondaryImageUrl='" + secondaryImageUrl + '\'' +
105+
", location='" + location + '\'' +
106+
", category='" + category + '\'' +
107+
", image='" + image + '\'' +
108+
", secondaryImage=" + secondaryImage +
109+
", distance='" + distance + '\'' +
110+
", siteLinks='" + siteLinks.toString() + '\'' +
111+
'}';
98112
}
99113

100114
/**

app/src/main/java/fr/free/nrw/commons/nearby/Sitelinks.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ private static Uri sanitiseString(String stringUrl) {
5858
return Uri.parse(sanitisedStringUrl);
5959
}
6060

61+
@Override
62+
public String toString() {
63+
return "Sitelinks{" +
64+
"wikipediaLink='" + wikipediaLink + '\'' +
65+
", commonsLink='" + commonsLink + '\'' +
66+
", wikidataLink='" + wikidataLink + '\'' +
67+
'}';
68+
}
69+
6170
private Sitelinks(Sitelinks.Builder builder) {
6271
this.wikidataLink = builder.wikidataLink;
6372
this.wikipediaLink = builder.wikipediaLink;

app/src/main/java/fr/free/nrw/commons/upload/FileProcessor.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,20 @@ GPSExtractor processFileCoordinates(boolean gpsEnabled) {
106106
ParcelFileDescriptor descriptor = contentResolver.openFileDescriptor(mediaUri, "r");
107107
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
108108
if (descriptor != null) {
109-
imageObj = new GPSExtractor(descriptor.getFileDescriptor(), context, prefs);
109+
imageObj = new GPSExtractor(descriptor.getFileDescriptor());
110110
}
111111
} else {
112112
String filePath = getPathOfMediaOrCopy();
113113
if (filePath != null) {
114-
imageObj = new GPSExtractor(filePath, context, prefs);
114+
imageObj = new GPSExtractor(filePath);
115115
}
116116
}
117117

118-
decimalCoords = imageObj.getCoords(gpsEnabled);
118+
decimalCoords = imageObj.getCoords();
119119
if (decimalCoords == null || !imageObj.imageCoordsExists) {
120120
//Find other photos taken around the same time which has gps coordinates
121121
if (!haveCheckedForOtherImages)
122-
findOtherImages(gpsEnabled);// Do not do repeat the process
122+
findOtherImages();// Do not do repeat the process
123123
} else {
124124
useImageCoords();
125125
}
@@ -137,9 +137,8 @@ String getDecimalCoords() {
137137
/**
138138
* Find other images around the same location that were taken within the last 20 sec
139139
*
140-
* @param gpsEnabled True if GPS is enabled
141140
*/
142-
private void findOtherImages(boolean gpsEnabled) {
141+
private void findOtherImages() {
143142
Timber.d("filePath" + getPathOfMediaOrCopy());
144143

145144
long timeOfCreation = new File(filePath).lastModified();//Time when the original image was created
@@ -161,17 +160,17 @@ private void findOtherImages(boolean gpsEnabled) {
161160
}
162161
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
163162
if (descriptor != null) {
164-
tempImageObj = new GPSExtractor(descriptor.getFileDescriptor(), context, prefs);
163+
tempImageObj = new GPSExtractor(descriptor.getFileDescriptor());
165164
}
166165
} else {
167166
if (filePath != null) {
168-
tempImageObj = new GPSExtractor(file.getAbsolutePath(), context, prefs);
167+
tempImageObj = new GPSExtractor(file.getAbsolutePath());
169168
}
170169
}
171170

172171
if (tempImageObj != null) {
173-
Timber.d("not null fild EXIF" + tempImageObj.imageCoordsExists + " coords" + tempImageObj.getCoords(gpsEnabled));
174-
if (tempImageObj.getCoords(gpsEnabled) != null && tempImageObj.imageCoordsExists) {
172+
Timber.d("not null fild EXIF" + tempImageObj.imageCoordsExists + " coords" + tempImageObj.getCoords());
173+
if (tempImageObj.getCoords() != null && tempImageObj.imageCoordsExists) {
175174
// Current image has gps coordinates and it's not current gps locaiton
176175
Timber.d("This file has image coords:" + file.getAbsolutePath());
177176
SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment();
@@ -250,7 +249,7 @@ void detectUnwantedPictures() {
250249
@Override
251250
public void onPositiveResponse() {
252251
imageObj = tempImageObj;
253-
decimalCoords = imageObj.getCoords(false);// Not necessary to use gps as image already ha EXIF data
252+
decimalCoords = imageObj.getCoords();// Not necessary to use gps as image already ha EXIF data
254253
Timber.d("EXIF from tempImageObj");
255254
useImageCoords();
256255
}

0 commit comments

Comments
 (0)