mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Add Javadocs to ShareActivity.java
This commit is contained in:
parent
f8cb469b48
commit
7f58b21fa0
1 changed files with 10 additions and 6 deletions
|
|
@ -148,9 +148,9 @@ public class ShareActivity
|
||||||
private FloatingActionButton mainFab;
|
private FloatingActionButton mainFab;
|
||||||
private boolean isFABOpen = false;
|
private boolean isFABOpen = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when user taps the submit button.
|
* Called when user taps the submit button.
|
||||||
|
* Requests Storage permission, if needed.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void uploadActionInitiated(String title, String description) {
|
public void uploadActionInitiated(String title, String description) {
|
||||||
|
|
@ -159,8 +159,6 @@ public class ShareActivity
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|
||||||
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.
|
|
||||||
// Do not allow user to proceed without permission, otherwise will crash
|
|
||||||
if (needsToRequestStoragePermission()) {
|
if (needsToRequestStoragePermission()) {
|
||||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||||
REQUEST_PERM_ON_SUBMIT_STORAGE);
|
REQUEST_PERM_ON_SUBMIT_STORAGE);
|
||||||
|
|
@ -172,16 +170,22 @@ public class ShareActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether storage permissions need to be requested.
|
||||||
|
* Permissions are needed if the file is not owned by this application, (e.g. shared from the Gallery)
|
||||||
|
* @return true if file is not owned by this application and permission hasn't been granted beforehand
|
||||||
|
*/
|
||||||
@RequiresApi(16)
|
@RequiresApi(16)
|
||||||
private boolean needsToRequestStoragePermission() {
|
private boolean needsToRequestStoragePermission() {
|
||||||
// We need to ask storage permission when
|
|
||||||
// the file is not owned by this application, (e.g. shared from the Gallery)
|
|
||||||
// and permission is not obtained.
|
|
||||||
return !FileUtils.isSelfOwned(getApplicationContext(), mediaUri)
|
return !FileUtils.isSelfOwned(getApplicationContext(), mediaUri)
|
||||||
&& (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
&& (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||||
!= PackageManager.PERMISSION_GRANTED);
|
!= PackageManager.PERMISSION_GRANTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after permission checks are done.
|
||||||
|
* Gets file metadata for category suggestions, displays toast, caches categories found, calls uploadController
|
||||||
|
*/
|
||||||
private void uploadBegins() {
|
private void uploadBegins() {
|
||||||
getFileMetadata(locationPermitted);
|
getFileMetadata(locationPermitted);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue