diff --git a/app/src/main/java/fr/free/nrw/commons/achievements/AchievementsActivity.java b/app/src/main/java/fr/free/nrw/commons/achievements/AchievementsActivity.java index 7db31ead0..93a93e348 100644 --- a/app/src/main/java/fr/free/nrw/commons/achievements/AchievementsActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/achievements/AchievementsActivity.java @@ -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 + */ @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), diff --git a/app/src/main/java/fr/free/nrw/commons/achievements/FeaturedImages.kt b/app/src/main/java/fr/free/nrw/commons/achievements/FeaturedImages.kt index c1c615491..4f5351e3c 100644 --- a/app/src/main/java/fr/free/nrw/commons/achievements/FeaturedImages.kt +++ b/app/src/main/java/fr/free/nrw/commons/achievements/FeaturedImages.kt @@ -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) \ No newline at end of file +/** +* 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 +) \ No newline at end of file diff --git a/app/src/main/java/fr/free/nrw/commons/achievements/FeedbackResponse.kt b/app/src/main/java/fr/free/nrw/commons/achievements/FeedbackResponse.kt index 4c37e9d60..8d5d8b7bd 100644 --- a/app/src/main/java/fr/free/nrw/commons/achievements/FeedbackResponse.kt +++ b/app/src/main/java/fr/free/nrw/commons/achievements/FeedbackResponse.kt @@ -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, diff --git a/app/src/main/java/fr/free/nrw/commons/actions/PageEditClient.java b/app/src/main/java/fr/free/nrw/commons/actions/PageEditClient.java index 64c14e3be..46005d006 100644 --- a/app/src/main/java/fr/free/nrw/commons/actions/PageEditClient.java +++ b/app/src/main/java/fr/free/nrw/commons/actions/PageEditClient.java @@ -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 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 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 prependEdit(String pageTitle, String prependText, String summary) { try { return pageEditInterface.postPrependEdit(pageTitle, summary, prependText, csrfTokenClient.getTokenBlocking()) diff --git a/app/src/main/java/fr/free/nrw/commons/actions/PageEditInterface.java b/app/src/main/java/fr/free/nrw/commons/actions/PageEditInterface.java index 537ec4d4f..8f4faf01f 100644 --- a/app/src/main/java/fr/free/nrw/commons/actions/PageEditInterface.java +++ b/app/src/main/java/fr/free/nrw/commons/actions/PageEditInterface.java @@ -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 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") diff --git a/app/src/main/java/fr/free/nrw/commons/actions/ThanksClient.java b/app/src/main/java/fr/free/nrw/commons/actions/ThanksClient.java index c4f96e7eb..aa606a93a 100644 --- a/app/src/main/java/fr/free/nrw/commons/actions/ThanksClient.java +++ b/app/src/main/java/fr/free/nrw/commons/actions/ThanksClient.java @@ -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 thank(long revisionId) { try { return service.thank(String.valueOf(revisionId), null, diff --git a/app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticator.java b/app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticator.java index cd95e5e31..643725604 100644 --- a/app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticator.java +++ b/app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticator.java @@ -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); diff --git a/app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticatorService.java b/app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticatorService.java index f176b2d26..bb41f27aa 100644 --- a/app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticatorService.java +++ b/app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticatorService.java @@ -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 diff --git a/app/src/main/java/fr/free/nrw/commons/bookmarks/locations/BookmarkLocationsContentProvider.java b/app/src/main/java/fr/free/nrw/commons/bookmarks/locations/BookmarkLocationsContentProvider.java index 34c17e806..8c9b559d4 100644 --- a/app/src/main/java/fr/free/nrw/commons/bookmarks/locations/BookmarkLocationsContentProvider.java +++ b/app/src/main/java/fr/free/nrw/commons/bookmarks/locations/BookmarkLocationsContentProvider.java @@ -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) { diff --git a/app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesContentProvider.java b/app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesContentProvider.java index 294b98978..2aac07902 100644 --- a/app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesContentProvider.java +++ b/app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesContentProvider.java @@ -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) { diff --git a/app/src/main/java/fr/free/nrw/commons/category/CategoriesRenderer.java b/app/src/main/java/fr/free/nrw/commons/category/CategoriesRenderer.java index e585f247f..7fc8f9d68 100644 --- a/app/src/main/java/fr/free/nrw/commons/category/CategoriesRenderer.java +++ b/app/src/main/java/fr/free/nrw/commons/category/CategoriesRenderer.java @@ -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 { @BindView(R.id.tvName) CheckedTextView checkedView; private final CategoryClickedListener listener; diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListAdapter.java b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListAdapter.java index 7bad3c8de..274c8a585 100644 --- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListAdapter.java +++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListAdapter.java @@ -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 { private Callback callback; @@ -17,6 +20,10 @@ public class ContributionsListAdapter extends RecyclerView.Adapter 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; } diff --git a/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.java b/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.java index c6b2c7b97..e6416c4d1 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.java +++ b/app/src/main/java/fr/free/nrw/commons/di/ActivityBuilderModule.java @@ -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 { diff --git a/app/src/main/java/fr/free/nrw/commons/di/ApplicationlessInjection.java b/app/src/main/java/fr/free/nrw/commons/di/ApplicationlessInjection.java index b1da8fd5d..b4f4e5db8 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/ApplicationlessInjection.java +++ b/app/src/main/java/fr/free/nrw/commons/di/ApplicationlessInjection.java @@ -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, diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java index 242f889df..114b0e326 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java +++ b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java @@ -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, diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationModule.java b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationModule.java index f1a2ef539..02ff94afd 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationModule.java +++ b/app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationModule.java @@ -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(){ diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerAppCompatActivity.java b/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerAppCompatActivity.java index d7e033974..003b3649c 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerAppCompatActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerAppCompatActivity.java @@ -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()); diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerBroadcastReceiver.java b/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerBroadcastReceiver.java index 10fa74a9b..0b89003b5 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerBroadcastReceiver.java +++ b/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerBroadcastReceiver.java @@ -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() { diff --git a/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.java b/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.java index 10c0cfcb1..bf21b4e97 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.java +++ b/app/src/main/java/fr/free/nrw/commons/di/ContentProviderBuilderModule.java @@ -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 { diff --git a/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.java b/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.java index e6991acae..15b8e6026 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.java +++ b/app/src/main/java/fr/free/nrw/commons/di/FragmentBuilderModule.java @@ -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 { diff --git a/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.java b/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.java index 2d4072d15..89e65e1d8 100644 --- a/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.java +++ b/app/src/main/java/fr/free/nrw/commons/di/ServiceBuilderModule.java @@ -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 { diff --git a/app/src/main/java/fr/free/nrw/commons/filepicker/Constants.java b/app/src/main/java/fr/free/nrw/commons/filepicker/Constants.java index fefb50311..83d838bc2 100644 --- a/app/src/main/java/fr/free/nrw/commons/filepicker/Constants.java +++ b/app/src/main/java/fr/free/nrw/commons/filepicker/Constants.java @@ -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"; diff --git a/app/src/main/java/fr/free/nrw/commons/filepicker/DefaultCallback.java b/app/src/main/java/fr/free/nrw/commons/filepicker/DefaultCallback.java index 4448adb5f..e8373dc6f 100644 --- a/app/src/main/java/fr/free/nrw/commons/filepicker/DefaultCallback.java +++ b/app/src/main/java/fr/free/nrw/commons/filepicker/DefaultCallback.java @@ -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 diff --git a/app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java b/app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java index 3e04ba070..4a90016ee 100644 --- a/app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java +++ b/app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java @@ -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) {