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

@ -169,9 +169,13 @@ public class AchievementsActivity extends NavigationBaseActivity {
return true;
}
/**
* To receive the id of selected item and handle further logic for that selected item
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
// take screenshot in form of bitmap and show it in Alert Dialog
if (id == R.id.share_app_icon) {
View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
Bitmap screenShot = Utils.getScreenShot(rootView);
@ -241,13 +245,18 @@ public class AchievementsActivity extends NavigationBaseActivity {
}
}
/**
* To call the API to fetch the count of wiki data edits
* in the form of JavaRx Single object<JSONobject>
*/
@SuppressLint("CheckResult")
private void setWikidataEditCount() {
String userName = sessionManager.getUserName();
if (StringUtils.isBlank(userName)) {
return;
}
compositeDisposable.add(okHttpJsonApiClient.getWikidataEdits(userName)
compositeDisposable.add(okHttpJsonApiClient
.getWikidataEdits(userName)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(edits -> wikidataEditsText.setText(String.valueOf(edits)), e -> {
@ -255,6 +264,10 @@ public class AchievementsActivity extends NavigationBaseActivity {
}));
}
/**
* Shows a snack bar which has an action button which on click dismisses the snackbar and invokes the
* listener passed
*/
private void showSnackBarWithRetry() {
progressBar.setVisibility(View.GONE);
ViewUtil.showDismissibleSnackBar(findViewById(android.R.id.content),

View file

@ -2,4 +2,11 @@ package fr.free.nrw.commons.achievements
import com.google.gson.annotations.SerializedName
class FeaturedImages(@field:SerializedName("Quality_images") val qualityImages: Int, @field:SerializedName("Featured_pictures_on_Wikimedia_Commons") val featuredPicturesOnWikimediaCommons: Int)
/**
* Represents Featured Images on WikiMedia Commons platform
* Used by Achievements and FeedbackResponse (objects) of the user
*/
class FeaturedImages(
@field:SerializedName("Quality_images") val qualityImages: Int,
@field:SerializedName("Featured_pictures_on_Wikimedia_Commons") val featuredPicturesOnWikimediaCommons: Int
)

View file

@ -1,5 +1,8 @@
package fr.free.nrw.commons.achievements
/**
* Represent the Feedback Response of the user
*/
data class FeedbackResponse(val uniqueUsedImages: Int,
val articlesUsingImages: Int,
val deletedUploads: Int,

View file

@ -5,6 +5,13 @@ import org.wikipedia.dataclient.Service;
import io.reactivex.Observable;
/**
* This class acts as a Client to facilitate wiki page editing
* services to various dependency providing modules such as the Network module, the Review Controller ,etc
*
* The methods provided by this class will post to the Media wiki api
* documented at: https://commons.wikimedia.org/w/api.php?action=help&modules=edit
*/
public class PageEditClient {
private final CsrfTokenClient csrfTokenClient;
@ -19,6 +26,12 @@ public class PageEditClient {
this.service = service;
}
/**
* This method is used when the content of the page is to be replaced by new content received
* @param pagetitle Title of the page to edit
* @param text Holds the page content
* @param summary Edit summary
*/
public Observable<Boolean> edit(String pageTitle, String text, String summary) {
try {
return pageEditInterface.postEdit(pageTitle, summary, text, csrfTokenClient.getTokenBlocking())
@ -28,6 +41,12 @@ public class PageEditClient {
}
}
/**
* This method is used when we need to append something to the end of wiki page content
* @param pagetitle Title of the page to edit
* @param appendText The received page content is added to beginning of the page
* @param summary Edit summary
*/
public Observable<Boolean> appendEdit(String pageTitle, String appendText, String summary) {
try {
return pageEditInterface.postAppendEdit(pageTitle, summary, appendText, csrfTokenClient.getTokenBlocking())
@ -37,6 +56,12 @@ public class PageEditClient {
}
}
/**
* This method is used when we need to add something to the starting of the page
* @param pagetitle Title of the page to edit
* @param prependText The received page content is added to beginning of the page
* @param summary Edit summary
*/
public Observable<Boolean> prependEdit(String pageTitle, String prependText, String summary) {
try {
return pageEditInterface.postPrependEdit(pageTitle, summary, prependText, csrfTokenClient.getTokenBlocking())

View file

@ -12,8 +12,24 @@ import retrofit2.http.POST;
import static org.wikipedia.dataclient.Service.MW_API_PREFIX;
/**
* This interface facilitates wiki commons page editing services to the Networking module
* which provides all network related services used by the app.
*
* This interface posts a form encoded request to the wikimedia API
* with editing action as argument to edit a particular page
*/
public interface PageEditInterface {
/**
* This method posts such that the Content which the page
* has will be completely replaced by the value being passed to the
* "text" field of the encoded form data
* @param title Title of the page to edit. Cannot be used together with pageid.
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
* @param text Holds the page content
* @param token A "csrf" token
*/
@FormUrlEncoded
@Headers("Cache-Control: no-cache")
@POST(MW_API_PREFIX + "action=edit")
@ -21,8 +37,18 @@ public interface PageEditInterface {
Observable<Edit> postEdit(@NonNull @Field("title") String title,
@NonNull @Field("summary") String summary,
@NonNull @Field("text") String text,
// NOTE: This csrf shold always be sent as the last field of form data
@NonNull @Field("token") String token);
/**
* This method posts such that the Content which the page
* has will be completely replaced by the value being passed to the
* "text" field of the encoded form data
* @param title Title of the page to edit. Cannot be used together with pageid.
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
* @param text The received page content is added to beginning of the page
* @param token A "csrf" token
*/
@FormUrlEncoded
@Headers("Cache-Control: no-cache")
@POST(MW_API_PREFIX + "action=edit")
@ -31,6 +57,15 @@ public interface PageEditInterface {
@NonNull @Field("appendtext") String text,
@NonNull @Field("token") String token);
/**
* This method posts such that the Content which the page
* has will be completely replaced by the value being passed to the
* "text" field of the encoded form data
* @param title Title of the page to edit. Cannot be used together with pageid.
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
* @param text The received page content is added to beginning of the page
* @param token A "csrf" token
*/
@FormUrlEncoded
@Headers("Cache-Control: no-cache")
@POST(MW_API_PREFIX + "action=edit")

View file

@ -10,6 +10,13 @@ import javax.inject.Singleton;
import fr.free.nrw.commons.CommonsApplication;
import io.reactivex.Observable;
/**
* Facilitates the Wkikimedia Thanks api extention, as described in the
* api documentation: "The Thanks extension includes an API for sending thanks"
*
* In simple terms this class is used by a user to thank someone for adding
* contribution to the commons platform
*/
@Singleton
public class ThanksClient {
@ -23,6 +30,11 @@ public class ThanksClient {
this.service = service;
}
/**
* Handles the Thanking logic
* @param revesionID The revision ID you would like to thank someone for
* @return if thanks was successfully sent to intended recepient, returned as a boolean observable
*/
public Observable<Boolean> thank(long revisionId) {
try {
return service.thank(String.valueOf(revisionId), null,

View file

@ -17,6 +17,9 @@ import fr.free.nrw.commons.BuildConfig;
import static fr.free.nrw.commons.auth.AccountUtil.AUTH_TOKEN_TYPE;
/**
* Handles WikiMedia commons account Authentication
*/
public class WikiAccountAuthenticator extends AbstractAccountAuthenticator {
private static final String[] SYNC_AUTHORITIES = {BuildConfig.CONTRIBUTION_AUTHORITY, BuildConfig.MODIFICATION_AUTHORITY};
@ -28,6 +31,9 @@ public class WikiAccountAuthenticator extends AbstractAccountAuthenticator {
this.context = context;
}
/**
* Provides Bundle with edited Account Properties
*/
@Override
public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
Bundle bundle = new Bundle();
@ -40,7 +46,7 @@ public class WikiAccountAuthenticator extends AbstractAccountAuthenticator {
@NonNull String accountType, @Nullable String authTokenType,
@Nullable String[] requiredFeatures, @Nullable Bundle options)
throws NetworkErrorException {
// account type not supported returns bundle without loginActivity Intent, it just contains "test" key
if (!supportedAccountType(accountType)) {
Bundle bundle = new Bundle();
bundle.putString("test", "addAccount");
@ -100,6 +106,10 @@ public class WikiAccountAuthenticator extends AbstractAccountAuthenticator {
return BuildConfig.ACCOUNT_TYPE.equals(type);
}
/**
* Provides a bundle containing a Parcel
* the Parcel packs an Intent with LoginActivity and Authenticator response (requires valid account type)
*/
private Bundle addAccount(AccountAuthenticatorResponse response) {
Intent intent = new Intent(context, LoginActivity.class);
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);

View file

@ -8,6 +8,10 @@ import androidx.annotation.Nullable;
import fr.free.nrw.commons.di.CommonsDaggerService;
/**
* Handles the Auth service of the App, see AndroidManifests for details
* (Uses Dagger 2 as injector)
*/
public class WikiAccountAuthenticatorService extends CommonsDaggerService {
@Nullable

View file

@ -4,6 +4,7 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
// We can get uri using java.Net.Uri, but andoid implimentation is faster (but it's forgiving with handling exceptions though)
import android.net.Uri;
import android.text.TextUtils;
@ -19,11 +20,17 @@ import timber.log.Timber;
import static fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao.Table.COLUMN_NAME;
import static fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao.Table.TABLE_NAME;
/**
* Handles private storage for Bookmark locations
*/
public class BookmarkLocationsContentProvider extends CommonsDaggerContentProvider {
private static final String BASE_PATH = "bookmarksLocations";
public static final Uri BASE_URI = Uri.parse("content://" + BuildConfig.BOOKMARK_LOCATIONS_AUTHORITY + "/" + BASE_PATH);
/**
* Append bookmark locations name to the base uri
*/
public static Uri uriForName(String name) {
return Uri.parse(BASE_URI.toString() + "/" + name);
}
@ -35,6 +42,14 @@ public class BookmarkLocationsContentProvider extends CommonsDaggerContentProvid
return null;
}
/**
* Queries the SQLite database for the bookmark locations
* @param uri : contains the uri for bookmark locations
* @param projection
* @param selection : handles Where
* @param selectionArgs : the condition of Where clause
* @param sortOrder : ascending or descending
*/
@SuppressWarnings("ConstantConditions")
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection,
@ -49,6 +64,13 @@ public class BookmarkLocationsContentProvider extends CommonsDaggerContentProvid
return cursor;
}
/**
* Handles the update query of local SQLite Database
* @param uri : contains the uri for bookmark locations
* @param contentValues : new values to be entered to db
* @param selection : handles Where
* @param selectionArgs : the condition of Where clause
*/
@SuppressWarnings("ConstantConditions")
@Override
public int update(@NonNull Uri uri, ContentValues contentValues, String selection,
@ -69,6 +91,9 @@ public class BookmarkLocationsContentProvider extends CommonsDaggerContentProvid
return rowsUpdated;
}
/**
* Handles the insertion of new bookmark locations record to local SQLite Database
*/
@SuppressWarnings("ConstantConditions")
@Override
public Uri insert(@NonNull Uri uri, ContentValues contentValues) {

View file

@ -4,6 +4,7 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
// We can get uri using java.Net.Uri, but andoid implimentation is faster (but it's forgiving with handling exceptions though)
import android.net.Uri;
import android.text.TextUtils;
@ -19,11 +20,17 @@ import timber.log.Timber;
import static fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao.Table.COLUMN_MEDIA_NAME;
import static fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao.Table.TABLE_NAME;
/**
* Handles private storage for Bookmark pictures
*/
public class BookmarkPicturesContentProvider extends CommonsDaggerContentProvider {
private static final String BASE_PATH = "bookmarks";
public static final Uri BASE_URI = Uri.parse("content://" + BuildConfig.BOOKMARK_AUTHORITY + "/" + BASE_PATH);
/**
* Append bookmark pictures name to the base uri
*/
public static Uri uriForName(String name) {
return Uri.parse(BASE_URI.toString() + "/" + name);
}
@ -36,6 +43,14 @@ public class BookmarkPicturesContentProvider extends CommonsDaggerContentProvide
return null;
}
/**
* Queries the SQLite database for the bookmark pictures
* @param uri : contains the uri for bookmark pictures
* @param projection
* @param selection : handles Where
* @param selectionArgs : the condition of Where clause
* @param sortOrder : ascending or descending
*/
@SuppressWarnings("ConstantConditions")
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection,
@ -50,6 +65,13 @@ public class BookmarkPicturesContentProvider extends CommonsDaggerContentProvide
return cursor;
}
/**
* Handles the update query of local SQLite Database
* @param uri : contains the uri for bookmark pictures
* @param contentValues : new values to be entered to db
* @param selection : handles Where
* @param selectionArgs : the condition of Where clause
*/
@SuppressWarnings("ConstantConditions")
@Override
public int update(@NonNull Uri uri, ContentValues contentValues, String selection,
@ -70,6 +92,9 @@ public class BookmarkPicturesContentProvider extends CommonsDaggerContentProvide
return rowsUpdated;
}
/**
* Handles the insertion of new bookmark pictures record to local SQLite Database
*/
@SuppressWarnings("ConstantConditions")
@Override
public Uri insert(@NonNull Uri uri, ContentValues contentValues) {

View file

@ -12,6 +12,9 @@ import butterknife.ButterKnife;
import fr.free.nrw.commons.R;
import timber.log.Timber;
/**
* Renders the Categories view
*/
public class CategoriesRenderer extends Renderer<CategoryItem> {
@BindView(R.id.tvName) CheckedTextView checkedView;
private final CategoryClickedListener listener;

View file

@ -9,6 +9,9 @@ import androidx.recyclerview.widget.RecyclerView;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.model.DisplayableContribution;
/**
* Represents The View Adapter for the List of Contributions
*/
public class ContributionsListAdapter extends RecyclerView.Adapter<ContributionViewHolder> {
private Callback callback;
@ -17,6 +20,10 @@ public class ContributionsListAdapter extends RecyclerView.Adapter<ContributionV
this.callback = callback;
}
/**
* Creates the new View Holder which will be used to display items(contributions)
* using the onBindViewHolder(viewHolder,position)
*/
@NonNull
@Override
public ContributionViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

View file

@ -19,6 +19,9 @@ import fr.free.nrw.commons.utils.ViewUtilWrapper;
import io.reactivex.Single;
import timber.log.Timber;
/**
* This class handles the reason for deleting a Media object
*/
@Singleton
public class ReasonBuilder {
@ -38,10 +41,19 @@ public class ReasonBuilder {
this.viewUtilWrapper = viewUtilWrapper;
}
/**
* To process the reason and append the media's upload date and uploaded_by_me string
* @param media
* @param reason
* @return
*/
public Single<String> getReason(Media media, String reason) {
return fetchArticleNumber(media, reason);
}
/**
* get upload date for the passed Media
*/
private String prettyUploadedDate(Media media) {
Date date = media.getDateUploaded();
if (date == null || date.toString() == null || date.toString().isEmpty()) {
@ -59,9 +71,16 @@ public class ReasonBuilder {
return Single.just("");
}
private String appendArticlesUsed(FeedbackResponse object, Media media, String reason) {
/**
* Takes the uploaded_by_me string, the upload date, name of articles using images
* and appends it to the received reason
* @param feedBack object
* @param media whose upload data is to be fetched
* @param reason
*/
private String appendArticlesUsed(FeedbackResponse feedBack, Media media, String reason) {
String reason1Template = context.getString(R.string.uploaded_by_myself);
reason += String.format(Locale.getDefault(), reason1Template, prettyUploadedDate(media), object.getArticlesUsingImages());
reason += String.format(Locale.getDefault(), reason1Template, prettyUploadedDate(media), feedBack.getArticlesUsingImages());
Timber.i("New Reason %s", reason);
return reason;
}

View file

@ -18,6 +18,11 @@ import fr.free.nrw.commons.review.ReviewActivity;
import fr.free.nrw.commons.settings.SettingsActivity;
import fr.free.nrw.commons.upload.UploadActivity;
/**
* This Class handles the dependency injection (using dagger)
* so, if a developer needs to add a new activity to the commons app
* then that must be mentioned here to inject the dependencies
*/
@Module
@SuppressWarnings({"WeakerAccess", "unused"})
public abstract class ActivityBuilderModule {

View file

@ -19,6 +19,10 @@ import dagger.android.HasFragmentInjector;
import dagger.android.HasServiceInjector;
import dagger.android.support.HasSupportFragmentInjector;
/**
* Provides injectors for all sorts of components
* Ex: Activities, Fragments, Services, ContentProviders
*/
public class ApplicationlessInjection
implements
HasActivityInjector,

View file

@ -19,6 +19,10 @@ import fr.free.nrw.commons.upload.UploadModule;
import fr.free.nrw.commons.widget.PicOfDayAppWidget;
/**
* Facilitates Injection from CommonsApplicationModule to all the
* classes seeking a dependency to be injected
*/
@Singleton
@Component(modules = {
CommonsApplicationModule.class,

View file

@ -40,6 +40,13 @@ import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* The Dependency Provider class for Commons Android.
*
* Provides all sorts of ContentProviderClients used by the app
* along with the Liscences, AccountUtility, UploadController, Logged User,
* Location manager etc
*/
@Module
@SuppressWarnings({"WeakerAccess", "unused"})
public class CommonsApplicationModule {
@ -90,6 +97,10 @@ public class CommonsApplicationModule {
return new AccountUtil();
}
/**
* Provides an instance of CategoryContentProviderClient i.e. the categories
* that are there in local storage
*/
@Provides
@Named("category")
public ContentProviderClient provideCategoryContentProviderClient(Context context) {
@ -132,6 +143,11 @@ public class CommonsApplicationModule {
return context.getContentResolver().acquireContentProviderClient(BuildConfig.BOOKMARK_LOCATIONS_AUTHORITY);
}
/**
* Provides a Json store instance(JsonKvStore) which keeps
* the provided Gson in it's instance
* @param gson stored inside the store instance
*/
@Provides
@Named("default_preferences")
public JsonKvStore providesDefaultKvStore(Context context, Gson gson) {
@ -182,6 +198,10 @@ public class CommonsApplicationModule {
return ConfigUtils.isBetaFlavour();
}
/**
* Provide JavaRx IO scheduler which manages IO operations
* across various Threads
*/
@Named(IO_THREAD)
@Provides
public Scheduler providesIoThread(){

View file

@ -29,6 +29,10 @@ public abstract class CommonsDaggerAppCompatActivity extends AppCompatActivity i
return supportFragmentInjector;
}
/**
* when this Activity is created it injects an instance of this class inside
* activityInjector method of ApplicationlessInjection
*/
private void inject() {
ApplicationlessInjection injection = ApplicationlessInjection.getInstance(getApplicationContext());

View file

@ -6,6 +6,10 @@ import android.content.Intent;
import dagger.android.AndroidInjector;
/**
* Receives broadcast then injects it's instance to the broadcastReceiverInjector method of
* ApplicationlessInjection class
*/
public abstract class CommonsDaggerBroadcastReceiver extends BroadcastReceiver {
public CommonsDaggerBroadcastReceiver() {

View file

@ -8,6 +8,11 @@ import fr.free.nrw.commons.category.CategoryContentProvider;
import fr.free.nrw.commons.contributions.ContributionsContentProvider;
import fr.free.nrw.commons.explore.recentsearches.RecentSearchesContentProvider;
/**
* This Class Represents the Module for dependency injection (using dagger)
* so, if a developer needs to add a new ContentProvider to the commons app
* then that must be mentioned here to inject the dependencies
*/
@Module
@SuppressWarnings({"WeakerAccess", "unused"})
public abstract class ContentProviderBuilderModule {

View file

@ -22,6 +22,11 @@ import fr.free.nrw.commons.upload.categories.UploadCategoriesFragment;
import fr.free.nrw.commons.upload.license.MediaLicenseFragment;
import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment;
/**
* This Class Represents the Module for dependency injection (using dagger)
* so, if a developer needs to add a new Fragment to the commons app
* then that must be mentioned here to inject the dependencies
*/
@Module
@SuppressWarnings({"WeakerAccess", "unused"})
public abstract class FragmentBuilderModule {

View file

@ -5,6 +5,11 @@ import dagger.android.ContributesAndroidInjector;
import fr.free.nrw.commons.auth.WikiAccountAuthenticatorService;
import fr.free.nrw.commons.upload.UploadService;
/**
* This Class Represents the Module for dependency injection (using dagger)
* so, if a developer needs to add a new Service to the commons app
* then that must be mentioned here to inject the dependencies
*/
@Module
@SuppressWarnings({"WeakerAccess", "unused"})
public abstract class ServiceBuilderModule {

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) {