Skip to content

Commit 0affe71

Browse files
kbhardwaj123maskaravivek
authored andcommitted
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
1 parent 803bed4 commit 0affe71

25 files changed

+269
-5
lines changed

app/src/main/java/fr/free/nrw/commons/achievements/AchievementsActivity.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,13 @@ public boolean onCreateOptionsMenu(Menu menu) {
169169
return true;
170170
}
171171

172+
/**
173+
* To receive the id of selected item and handle further logic for that selected item
174+
*/
172175
@Override
173176
public boolean onOptionsItemSelected(MenuItem item) {
174177
int id = item.getItemId();
178+
// take screenshot in form of bitmap and show it in Alert Dialog
175179
if (id == R.id.share_app_icon) {
176180
View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
177181
Bitmap screenShot = Utils.getScreenShot(rootView);
@@ -241,20 +245,29 @@ private void setAchievements() {
241245
}
242246
}
243247

248+
/**
249+
* To call the API to fetch the count of wiki data edits
250+
* in the form of JavaRx Single object<JSONobject>
251+
*/
244252
@SuppressLint("CheckResult")
245253
private void setWikidataEditCount() {
246254
String userName = sessionManager.getUserName();
247255
if (StringUtils.isBlank(userName)) {
248256
return;
249257
}
250-
compositeDisposable.add(okHttpJsonApiClient.getWikidataEdits(userName)
258+
compositeDisposable.add(okHttpJsonApiClient
259+
.getWikidataEdits(userName)
251260
.subscribeOn(Schedulers.io())
252261
.observeOn(AndroidSchedulers.mainThread())
253262
.subscribe(edits -> wikidataEditsText.setText(String.valueOf(edits)), e -> {
254263
Timber.e("Error:" + e);
255264
}));
256265
}
257266

267+
/**
268+
* Shows a snack bar which has an action button which on click dismisses the snackbar and invokes the
269+
* listener passed
270+
*/
258271
private void showSnackBarWithRetry() {
259272
progressBar.setVisibility(View.GONE);
260273
ViewUtil.showDismissibleSnackBar(findViewById(android.R.id.content),

app/src/main/java/fr/free/nrw/commons/achievements/FeaturedImages.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@ package fr.free.nrw.commons.achievements
22

33
import com.google.gson.annotations.SerializedName
44

5-
class FeaturedImages(@field:SerializedName("Quality_images") val qualityImages: Int, @field:SerializedName("Featured_pictures_on_Wikimedia_Commons") val featuredPicturesOnWikimediaCommons: Int)
5+
/**
6+
* Represents Featured Images on WikiMedia Commons platform
7+
* Used by Achievements and FeedbackResponse (objects) of the user
8+
*/
9+
class FeaturedImages(
10+
@field:SerializedName("Quality_images") val qualityImages: Int,
11+
@field:SerializedName("Featured_pictures_on_Wikimedia_Commons") val featuredPicturesOnWikimediaCommons: Int
12+
)

app/src/main/java/fr/free/nrw/commons/achievements/FeedbackResponse.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package fr.free.nrw.commons.achievements
22

3+
/**
4+
* Represent the Feedback Response of the user
5+
*/
36
data class FeedbackResponse(val uniqueUsedImages: Int,
47
val articlesUsingImages: Int,
58
val deletedUploads: Int,

app/src/main/java/fr/free/nrw/commons/actions/PageEditClient.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55

66
import io.reactivex.Observable;
77

8+
/**
9+
* This class acts as a Client to facilitate wiki page editing
10+
* services to various dependency providing modules such as the Network module, the Review Controller ,etc
11+
*
12+
* The methods provided by this class will post to the Media wiki api
13+
* documented at: https://commons.wikimedia.org/w/api.php?action=help&modules=edit
14+
*/
815
public class PageEditClient {
916

1017
private final CsrfTokenClient csrfTokenClient;
@@ -19,6 +26,12 @@ public PageEditClient(CsrfTokenClient csrfTokenClient,
1926
this.service = service;
2027
}
2128

29+
/**
30+
* This method is used when the content of the page is to be replaced by new content received
31+
* @param pagetitle Title of the page to edit
32+
* @param text Holds the page content
33+
* @param summary Edit summary
34+
*/
2235
public Observable<Boolean> edit(String pageTitle, String text, String summary) {
2336
try {
2437
return pageEditInterface.postEdit(pageTitle, summary, text, csrfTokenClient.getTokenBlocking())
@@ -28,6 +41,12 @@ public Observable<Boolean> edit(String pageTitle, String text, String summary) {
2841
}
2942
}
3043

44+
/**
45+
* This method is used when we need to append something to the end of wiki page content
46+
* @param pagetitle Title of the page to edit
47+
* @param appendText The received page content is added to beginning of the page
48+
* @param summary Edit summary
49+
*/
3150
public Observable<Boolean> appendEdit(String pageTitle, String appendText, String summary) {
3251
try {
3352
return pageEditInterface.postAppendEdit(pageTitle, summary, appendText, csrfTokenClient.getTokenBlocking())
@@ -37,6 +56,12 @@ public Observable<Boolean> appendEdit(String pageTitle, String appendText, Strin
3756
}
3857
}
3958

59+
/**
60+
* This method is used when we need to add something to the starting of the page
61+
* @param pagetitle Title of the page to edit
62+
* @param prependText The received page content is added to beginning of the page
63+
* @param summary Edit summary
64+
*/
4065
public Observable<Boolean> prependEdit(String pageTitle, String prependText, String summary) {
4166
try {
4267
return pageEditInterface.postPrependEdit(pageTitle, summary, prependText, csrfTokenClient.getTokenBlocking())

app/src/main/java/fr/free/nrw/commons/actions/PageEditInterface.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,43 @@
1212

1313
import static org.wikipedia.dataclient.Service.MW_API_PREFIX;
1414

15+
/**
16+
* This interface facilitates wiki commons page editing services to the Networking module
17+
* which provides all network related services used by the app.
18+
*
19+
* This interface posts a form encoded request to the wikimedia API
20+
* with editing action as argument to edit a particular page
21+
*/
1522
public interface PageEditInterface {
1623

24+
/**
25+
* This method posts such that the Content which the page
26+
* has will be completely replaced by the value being passed to the
27+
* "text" field of the encoded form data
28+
* @param title Title of the page to edit. Cannot be used together with pageid.
29+
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
30+
* @param text Holds the page content
31+
* @param token A "csrf" token
32+
*/
1733
@FormUrlEncoded
1834
@Headers("Cache-Control: no-cache")
1935
@POST(MW_API_PREFIX + "action=edit")
2036
@NonNull
2137
Observable<Edit> postEdit(@NonNull @Field("title") String title,
2238
@NonNull @Field("summary") String summary,
2339
@NonNull @Field("text") String text,
40+
// NOTE: This csrf shold always be sent as the last field of form data
2441
@NonNull @Field("token") String token);
2542

43+
/**
44+
* This method posts such that the Content which the page
45+
* has will be completely replaced by the value being passed to the
46+
* "text" field of the encoded form data
47+
* @param title Title of the page to edit. Cannot be used together with pageid.
48+
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
49+
* @param text The received page content is added to beginning of the page
50+
* @param token A "csrf" token
51+
*/
2652
@FormUrlEncoded
2753
@Headers("Cache-Control: no-cache")
2854
@POST(MW_API_PREFIX + "action=edit")
@@ -31,6 +57,15 @@ Observable<Edit> postEdit(@NonNull @Field("title") String title,
3157
@NonNull @Field("appendtext") String text,
3258
@NonNull @Field("token") String token);
3359

60+
/**
61+
* This method posts such that the Content which the page
62+
* has will be completely replaced by the value being passed to the
63+
* "text" field of the encoded form data
64+
* @param title Title of the page to edit. Cannot be used together with pageid.
65+
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
66+
* @param text The received page content is added to beginning of the page
67+
* @param token A "csrf" token
68+
*/
3469
@FormUrlEncoded
3570
@Headers("Cache-Control: no-cache")
3671
@POST(MW_API_PREFIX + "action=edit")

app/src/main/java/fr/free/nrw/commons/actions/ThanksClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
import fr.free.nrw.commons.CommonsApplication;
1111
import io.reactivex.Observable;
1212

13+
/**
14+
* Facilitates the Wkikimedia Thanks api extention, as described in the
15+
* api documentation: "The Thanks extension includes an API for sending thanks"
16+
*
17+
* In simple terms this class is used by a user to thank someone for adding
18+
* contribution to the commons platform
19+
*/
1320
@Singleton
1421
public class ThanksClient {
1522

@@ -23,6 +30,11 @@ public ThanksClient(@Named("commons-csrf") CsrfTokenClient csrfTokenClient,
2330
this.service = service;
2431
}
2532

33+
/**
34+
* Handles the Thanking logic
35+
* @param revesionID The revision ID you would like to thank someone for
36+
* @return if thanks was successfully sent to intended recepient, returned as a boolean observable
37+
*/
2638
public Observable<Boolean> thank(long revisionId) {
2739
try {
2840
return service.thank(String.valueOf(revisionId), null,

app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticator.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
import static fr.free.nrw.commons.auth.AccountUtil.AUTH_TOKEN_TYPE;
1919

20+
/**
21+
* Handles WikiMedia commons account Authentication
22+
*/
2023
public class WikiAccountAuthenticator extends AbstractAccountAuthenticator {
2124
private static final String[] SYNC_AUTHORITIES = {BuildConfig.CONTRIBUTION_AUTHORITY, BuildConfig.MODIFICATION_AUTHORITY};
2225

@@ -28,6 +31,9 @@ public WikiAccountAuthenticator(@NonNull Context context) {
2831
this.context = context;
2932
}
3033

34+
/**
35+
* Provides Bundle with edited Account Properties
36+
*/
3137
@Override
3238
public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
3339
Bundle bundle = new Bundle();
@@ -40,7 +46,7 @@ public Bundle addAccount(@NonNull AccountAuthenticatorResponse response,
4046
@NonNull String accountType, @Nullable String authTokenType,
4147
@Nullable String[] requiredFeatures, @Nullable Bundle options)
4248
throws NetworkErrorException {
43-
49+
// account type not supported returns bundle without loginActivity Intent, it just contains "test" key
4450
if (!supportedAccountType(accountType)) {
4551
Bundle bundle = new Bundle();
4652
bundle.putString("test", "addAccount");
@@ -100,6 +106,10 @@ private boolean supportedAccountType(@Nullable String type) {
100106
return BuildConfig.ACCOUNT_TYPE.equals(type);
101107
}
102108

109+
/**
110+
* Provides a bundle containing a Parcel
111+
* the Parcel packs an Intent with LoginActivity and Authenticator response (requires valid account type)
112+
*/
103113
private Bundle addAccount(AccountAuthenticatorResponse response) {
104114
Intent intent = new Intent(context, LoginActivity.class);
105115
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);

app/src/main/java/fr/free/nrw/commons/auth/WikiAccountAuthenticatorService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import fr.free.nrw.commons.di.CommonsDaggerService;
1010

11+
/**
12+
* Handles the Auth service of the App, see AndroidManifests for details
13+
* (Uses Dagger 2 as injector)
14+
*/
1115
public class WikiAccountAuthenticatorService extends CommonsDaggerService {
1216

1317
@Nullable

app/src/main/java/fr/free/nrw/commons/bookmarks/locations/BookmarkLocationsContentProvider.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.database.Cursor;
55
import android.database.sqlite.SQLiteDatabase;
66
import android.database.sqlite.SQLiteQueryBuilder;
7+
// We can get uri using java.Net.Uri, but andoid implimentation is faster (but it's forgiving with handling exceptions though)
78
import android.net.Uri;
89
import android.text.TextUtils;
910

@@ -19,11 +20,17 @@
1920
import static fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao.Table.COLUMN_NAME;
2021
import static fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao.Table.TABLE_NAME;
2122

23+
/**
24+
* Handles private storage for Bookmark locations
25+
*/
2226
public class BookmarkLocationsContentProvider extends CommonsDaggerContentProvider {
2327

2428
private static final String BASE_PATH = "bookmarksLocations";
2529
public static final Uri BASE_URI = Uri.parse("content://" + BuildConfig.BOOKMARK_LOCATIONS_AUTHORITY + "/" + BASE_PATH);
2630

31+
/**
32+
* Append bookmark locations name to the base uri
33+
*/
2734
public static Uri uriForName(String name) {
2835
return Uri.parse(BASE_URI.toString() + "/" + name);
2936
}
@@ -35,6 +42,14 @@ public String getType(@NonNull Uri uri) {
3542
return null;
3643
}
3744

45+
/**
46+
* Queries the SQLite database for the bookmark locations
47+
* @param uri : contains the uri for bookmark locations
48+
* @param projection
49+
* @param selection : handles Where
50+
* @param selectionArgs : the condition of Where clause
51+
* @param sortOrder : ascending or descending
52+
*/
3853
@SuppressWarnings("ConstantConditions")
3954
@Override
4055
public Cursor query(@NonNull Uri uri, String[] projection, String selection,
@@ -49,6 +64,13 @@ public Cursor query(@NonNull Uri uri, String[] projection, String selection,
4964
return cursor;
5065
}
5166

67+
/**
68+
* Handles the update query of local SQLite Database
69+
* @param uri : contains the uri for bookmark locations
70+
* @param contentValues : new values to be entered to db
71+
* @param selection : handles Where
72+
* @param selectionArgs : the condition of Where clause
73+
*/
5274
@SuppressWarnings("ConstantConditions")
5375
@Override
5476
public int update(@NonNull Uri uri, ContentValues contentValues, String selection,
@@ -69,6 +91,9 @@ public int update(@NonNull Uri uri, ContentValues contentValues, String selectio
6991
return rowsUpdated;
7092
}
7193

94+
/**
95+
* Handles the insertion of new bookmark locations record to local SQLite Database
96+
*/
7297
@SuppressWarnings("ConstantConditions")
7398
@Override
7499
public Uri insert(@NonNull Uri uri, ContentValues contentValues) {

app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesContentProvider.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.database.Cursor;
55
import android.database.sqlite.SQLiteDatabase;
66
import android.database.sqlite.SQLiteQueryBuilder;
7+
// We can get uri using java.Net.Uri, but andoid implimentation is faster (but it's forgiving with handling exceptions though)
78
import android.net.Uri;
89
import android.text.TextUtils;
910

@@ -19,11 +20,17 @@
1920
import static fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao.Table.COLUMN_MEDIA_NAME;
2021
import static fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao.Table.TABLE_NAME;
2122

23+
/**
24+
* Handles private storage for Bookmark pictures
25+
*/
2226
public class BookmarkPicturesContentProvider extends CommonsDaggerContentProvider {
2327

2428
private static final String BASE_PATH = "bookmarks";
2529
public static final Uri BASE_URI = Uri.parse("content://" + BuildConfig.BOOKMARK_AUTHORITY + "/" + BASE_PATH);
2630

31+
/**
32+
* Append bookmark pictures name to the base uri
33+
*/
2734
public static Uri uriForName(String name) {
2835
return Uri.parse(BASE_URI.toString() + "/" + name);
2936
}
@@ -36,6 +43,14 @@ public String getType(@NonNull Uri uri) {
3643
return null;
3744
}
3845

46+
/**
47+
* Queries the SQLite database for the bookmark pictures
48+
* @param uri : contains the uri for bookmark pictures
49+
* @param projection
50+
* @param selection : handles Where
51+
* @param selectionArgs : the condition of Where clause
52+
* @param sortOrder : ascending or descending
53+
*/
3954
@SuppressWarnings("ConstantConditions")
4055
@Override
4156
public Cursor query(@NonNull Uri uri, String[] projection, String selection,
@@ -50,6 +65,13 @@ public Cursor query(@NonNull Uri uri, String[] projection, String selection,
5065
return cursor;
5166
}
5267

68+
/**
69+
* Handles the update query of local SQLite Database
70+
* @param uri : contains the uri for bookmark pictures
71+
* @param contentValues : new values to be entered to db
72+
* @param selection : handles Where
73+
* @param selectionArgs : the condition of Where clause
74+
*/
5375
@SuppressWarnings("ConstantConditions")
5476
@Override
5577
public int update(@NonNull Uri uri, ContentValues contentValues, String selection,
@@ -70,6 +92,9 @@ public int update(@NonNull Uri uri, ContentValues contentValues, String selectio
7092
return rowsUpdated;
7193
}
7294

95+
/**
96+
* Handles the insertion of new bookmark pictures record to local SQLite Database
97+
*/
7398
@SuppressWarnings("ConstantConditions")
7499
@Override
75100
public Uri insert(@NonNull Uri uri, ContentValues contentValues) {

app/src/main/java/fr/free/nrw/commons/category/CategoriesRenderer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import fr.free.nrw.commons.R;
1313
import timber.log.Timber;
1414

15+
/**
16+
* Renders the Categories view
17+
*/
1518
public class CategoriesRenderer extends Renderer<CategoryItem> {
1619
@BindView(R.id.tvName) CheckedTextView checkedView;
1720
private final CategoryClickedListener listener;

0 commit comments

Comments
 (0)