Fixes crash when uploading image via share without logging in

This commit is contained in:
Shridhar Goel 2018-06-28 19:57:11 +05:30
parent 05def522af
commit 90705996a8
3 changed files with 12 additions and 18 deletions

View file

@ -26,6 +26,7 @@ dependencies {
transitive = true transitive = true
} }
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0' implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
//noinspection GradleCompatible
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION" implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION" implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
implementation "com.android.support:design:$SUPPORT_LIB_VERSION" implementation "com.android.support:design:$SUPPORT_LIB_VERSION"

View file

@ -152,8 +152,8 @@ public class ShareActivity
this.title = title; this.title = title;
this.description = description; this.description = description;
if(sessionManager.getCurrentAccount()!=null) { if (sessionManager.getCurrentAccount() != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Check for Storage permission that is required for upload. // Check for Storage permission that is required for upload.
// Do not allow user to proceed without permission, otherwise will crash // Do not allow user to proceed without permission, otherwise will crash
@ -167,11 +167,10 @@ public class ShareActivity
uploadBegins(); uploadBegins();
} }
} }
else //Send user to login activity else //Send user to login activity
{ {
Toast.makeText(this, "You need to login first!", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "You need to login first!", Toast.LENGTH_SHORT).show();
Intent loginIntent=new Intent(ShareActivity.this, LoginActivity.class); Intent loginIntent = new Intent(ShareActivity.this, LoginActivity.class);
startActivity(loginIntent); startActivity(loginIntent);
} }
} }
@ -207,20 +206,13 @@ public class ShareActivity
Timber.d("Cache the categories found"); Timber.d("Cache the categories found");
} }
uploadController.startUpload(title, mediaUri, description, mimeType, source, decimalCoords, c -> { uploadController.startUpload(title,mediaUri,description,mimeType,source,decimalCoords,wikiDataEntityId,c ->
ShareActivity.this.contribution = c;
showPostUpload();
});
} {
ShareActivity.this.contribution = c;
showPostUpload();
});
uploadController.startUpload(title, mediaUri, description, mimeType, source, decimalCoords, wikiDataEntityId, c -> { }
ShareActivity.this.contribution = c;
showPostUpload();
});
}
/** /**
* Starts CategorizationFragment after uploadBegins. * Starts CategorizationFragment after uploadBegins.
@ -679,3 +671,4 @@ public class ShareActivity
} }
} }

View file

@ -83,13 +83,13 @@ public class UploadController {
/** /**
* Starts a new upload task. * Starts a new upload task.
*
* @param title the title of the contribution * @param title the title of the contribution
* @param mediaUri the media URI of the contribution * @param mediaUri the media URI of the contribution
* @param description the description of the contribution * @param description the description of the contribution
* @param mimeType the MIME type of the contribution * @param mimeType the MIME type of the contribution
* @param source the source of the contribution * @param source the source of the contribution
* @param decimalCoords the coordinates in decimal. (e.g. "37.51136|-77.602615") * @param decimalCoords the coordinates in decimal. (e.g. "37.51136|-77.602615")
* @param wikiDataEntityId
* @param onComplete the progress tracker * @param onComplete the progress tracker
*/ */
public void startUpload(String title, Uri mediaUri, String description, String mimeType, String source, String decimalCoords, String wikiDataEntityId, ContributionUploadProgress onComplete) { public void startUpload(String title, Uri mediaUri, String description, String mimeType, String source, String decimalCoords, String wikiDataEntityId, ContributionUploadProgress onComplete) {