Skip to content

Commit 9070599

Browse files
committed
Fixes crash when uploading image via share without logging in
1 parent 05def52 commit 9070599

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626
transitive = true
2727
}
2828
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
29+
//noinspection GradleCompatible
2930
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
3031
implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
3132
implementation "com.android.support:design:$SUPPORT_LIB_VERSION"

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ public void uploadActionInitiated(String title, String description) {
152152
this.title = title;
153153
this.description = description;
154154

155-
156-
if(sessionManager.getCurrentAccount()!=null) {
155+
156+
if (sessionManager.getCurrentAccount() != null) {
157157
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
158158
// Check for Storage permission that is required for upload.
159159
// Do not allow user to proceed without permission, otherwise will crash
@@ -167,11 +167,10 @@ public void uploadActionInitiated(String title, String description) {
167167
uploadBegins();
168168
}
169169
}
170-
171170
else //Send user to login activity
172171
{
173172
Toast.makeText(this, "You need to login first!", Toast.LENGTH_SHORT).show();
174-
Intent loginIntent=new Intent(ShareActivity.this, LoginActivity.class);
173+
Intent loginIntent = new Intent(ShareActivity.this, LoginActivity.class);
175174
startActivity(loginIntent);
176175
}
177176
}
@@ -207,20 +206,13 @@ private void uploadBegins() {
207206
Timber.d("Cache the categories found");
208207
}
209208

210-
uploadController.startUpload(title, mediaUri, description, mimeType, source, decimalCoords, c -> {
211-
ShareActivity.this.contribution = c;
212-
showPostUpload();
213-
});
214-
215-
}
216-
209+
uploadController.startUpload(title,mediaUri,description,mimeType,source,decimalCoords,wikiDataEntityId,c ->
217210

218-
219-
uploadController.startUpload(title, mediaUri, description, mimeType, source, decimalCoords, wikiDataEntityId, c -> {
220-
ShareActivity.this.contribution = c;
221-
showPostUpload();
222-
});
223-
}
211+
{
212+
ShareActivity.this.contribution = c;
213+
showPostUpload();
214+
});
215+
}
224216

225217
/**
226218
* Starts CategorizationFragment after uploadBegins.
@@ -679,3 +671,4 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
679671

680672
}
681673
}
674+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ public void cleanup() {
8383

8484
/**
8585
* Starts a new upload task.
86-
*
8786
* @param title the title of the contribution
8887
* @param mediaUri the media URI of the contribution
8988
* @param description the description of the contribution
9089
* @param mimeType the MIME type of the contribution
9190
* @param source the source of the contribution
9291
* @param decimalCoords the coordinates in decimal. (e.g. "37.51136|-77.602615")
92+
* @param wikiDataEntityId
9393
* @param onComplete the progress tracker
9494
*/
9595
public void startUpload(String title, Uri mediaUri, String description, String mimeType, String source, String decimalCoords, String wikiDataEntityId, ContributionUploadProgress onComplete) {

0 commit comments

Comments
 (0)