Fixes: #3278: Add java docs to methods which have it missing (#3351)

* achievements/: add Javadocs

* actions/: add Javadocs

* WikiAccountAuthenticator: add Javadocs

* ReasonBuilder: add Javadocs

* di: Add javadocs to DI files

* bookmarks: add Javadocs to bookmarks files

* di: Added more Javadocs

* file: add Javadocs for file picker

* actions: add proper decription to the classes
This commit is contained in:
Kshitij Bhardwaj 2020-01-29 00:15:15 +05:30 committed by Vivek Maskara
parent 803bed43d7
commit 0affe71745
25 changed files with 269 additions and 5 deletions

View file

@ -3,6 +3,9 @@ package fr.free.nrw.commons.filepicker;
public interface Constants {
String DEFAULT_FOLDER_NAME = "CommonsContributions";
/**
* Provides the request codes utilised by the FilePicker
*/
interface RequestCodes {
int FILE_PICKER_IMAGE_IDENTIFICATOR = 0b1101101100; //876
int SOURCE_CHOOSER = 1 << 15;
@ -13,6 +16,9 @@ public interface Constants {
int CAPTURE_VIDEO = FILE_PICKER_IMAGE_IDENTIFICATOR + (1 << 14);
}
/**
* Provides locations as string for corresponding operations
*/
interface BundleKeys {
String FOLDER_NAME = "fr.free.nrw.commons.folder_name";
String ALLOW_MULTIPLE = "fr.free.nrw.commons.allow_multiple";

View file

@ -1,5 +1,9 @@
package fr.free.nrw.commons.filepicker;
/**
* Provides abstract methods which are overridden while handling Contribution Results
* inside the ContributionsController
*/
public abstract class DefaultCallback implements FilePicker.Callbacks {
@Override

View file

@ -31,6 +31,9 @@ public class FilePicker implements Constants {
private static final String KEY_LAST_CAMERA_VIDEO = "last_video";
private static final String KEY_TYPE = "type";
/**
* Returns the uri of the clicked image so that it can be put in MediaStore
*/
private static Uri createCameraPictureFile(@NonNull Context context) throws IOException {
File imagePath = PickedFiles.getCameraPicturesLocation(context);
Uri uri = PickedFiles.getUriToFile(context, imagePath);
@ -42,6 +45,7 @@ public class FilePicker implements Constants {
}
private static Intent createGalleryIntent(@NonNull Context context, int type) {
// storing picked image type to shared preferences
storeType(context, type);
return plainGalleryPickerIntent()
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, configuration(context).allowsMultiplePickingInGallery());
@ -93,6 +97,9 @@ public class FilePicker implements Constants {
activity.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_GALLERY);
}
/**
* Opens the camera app to pick image clicked by user
*/
public static void openCameraForImage(Activity activity, int type) {
Intent intent = createCameraForImageIntent(activity, type);
activity.startActivityForResult(intent, RequestCodes.TAKE_PICTURE);
@ -118,6 +125,9 @@ public class FilePicker implements Constants {
}
}
/**
* Any activity can use this method to attach their callback to the file picker
*/
public static void handleActivityResult(int requestCode, int resultCode, Intent data, Activity activity, @NonNull FilePicker.Callbacks callbacks) {
boolean isHandledPickedFile = (requestCode & RequestCodes.FILE_PICKER_IMAGE_IDENTIFICATOR) > 0;
if (isHandledPickedFile) {