Add 4th case for onResults

This commit is contained in:
misaochan 2016-07-15 00:01:08 +12:00
parent fb831c9222
commit 604fc3d5fe

View file

@ -81,6 +81,11 @@ public class ShareActivity
super(WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE);
}
/**
* Called when user taps the submit button
* @param title
* @param description
*/
public void uploadActionInitiated(String title, String description) {
this.title = title;
@ -88,7 +93,7 @@ public class ShareActivity
//Check for Storage permission that is required for upload. Do not allow user to proceed without permission, otherwise will crash
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
} else {
uploadBegins();
}
@ -293,14 +298,10 @@ public class ShareActivity
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
// 1 = Storage
// 1 = Storage (from snackbar)
case 1: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//Uploading only begins if storage permission granted
uploadBegins();
snackbar.dismiss();
getFileMetadata();
}
return;
@ -324,6 +325,20 @@ public class ShareActivity
getLocationData();
}
}
// 4 = Storage (from submit button) - this needs to be separate from (1) because only the
// submit button should bring user to next screen
case 4: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//It is OK to call this at both (1) and (4) because if perm had been granted at
//snackbar, user should not be prompted at submit button
getFileMetadata();
//Uploading only begins if storage permission granted from arrow icon
uploadBegins();
snackbar.dismiss();
}
}
}
}