mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add 4th case for onResults
This commit is contained in:
parent
fb831c9222
commit
604fc3d5fe
1 changed files with 21 additions and 6 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue