Added kdoc and javadoc

This commit is contained in:
Kanahia 2024-07-07 08:28:05 +05:30
parent ade49d20dc
commit c0b2fc7a5c
8 changed files with 180 additions and 68 deletions

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
@ -14,62 +13,66 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
<queries>
<!-- Browser -->
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
<!-- Google Maps -->
<package android:name="com.google.android.apps.maps" />
</queries> <!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->
</queries>
<!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->
<uses-feature android:name="android.hardware.location.gps" />
<application
android:name=".CommonsApplication"
android:appComponentFactory="commons"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/LightAppTheme"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:appComponentFactory">
android:largeHeap="true"
android:supportsRtl="true"
tools:replace="android:appComponentFactory"
android:appComponentFactory="commons"
android:requestLegacyExternalStorage = "true"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".nearby.WikidataFeedback"
android:exported="false" />
<activity
android:theme="@style/EditActivityTheme"
android:name=".description.DescriptionEditActivity"
android:exported="true"
android:theme="@style/EditActivityTheme" />
android:exported="true" />
<activity
android:name=".edit.EditActivity"
android:exported="false" />
<activity
android:name="org.acra.dialog.CrashReportDialog"
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true"
<activity android:name="org.acra.dialog.CrashReportDialog"
android:process=":acra"
android:launchMode="singleInstance"
android:process=":acra" />
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true" />
<activity
android:name=".media.ZoomableActivity"
android:configChanges="screenSize|keyboard|orientation"
android:label="Zoomable Activity"
android:configChanges="screenSize|keyboard|orientation"
android:parentActivityName=".customselector.ui.selector.CustomSelectorActivity" />
<activity
android:name=".auth.LoginActivity"
<activity android:name=".auth.LoginActivity"
android:exported="true">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
@ -77,19 +80,21 @@
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity android:name=".WelcomeActivity" />
<activity
android:name=".upload.UploadActivity"
android:configChanges="orientation|screenSize|keyboard"
android:exported="true"
android:hardwareAccelerated="false"
android:name=".upload.UploadActivity"
android:exported="true"
android:configChanges="orientation|screenSize|keyboard"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
>
<intent-filter android:label="@string/intent_share_upload_label">
<action android:name="android.intent.action.SEND" />
@ -109,9 +114,9 @@
</activity>
<activity
android:name=".contributions.MainActivity"
android:configChanges="screenSize|keyboard|orientation"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" />
android:label="@string/app_name"
android:configChanges="screenSize|keyboard|orientation" />
<activity
android:name=".settings.SettingsActivity"
android:label="@string/title_activity_settings" />
@ -119,47 +124,57 @@
android:name=".AboutActivity"
android:label="@string/title_activity_about"
android:parentActivityName=".contributions.MainActivity" />
<activity
android:name=".auth.SignupActivity"
android:configChanges="orientation|screenLayout|screenSize"
android:label="@string/title_activity_signup" />
<activity
android:name=".notification.NotificationActivity"
android:label="@string/navigation_item_notification" />
<activity
android:name=".quiz.QuizActivity"
android:label="@string/quiz" />
<activity
android:name=".quiz.QuizResultActivity"
android:label="@string/result" />
<activity android:name=".quiz.QuizActivity"
android:label="@string/quiz"/>
<activity android:name=".quiz.QuizResultActivity"
android:label="@string/result"/>
<activity
android:name=".customselector.ui.selector.CustomSelectorActivity"
android:configChanges="screenSize|keyboard|orientation"
android:label="@string/title_activity_custom_selector"
android:configChanges="screenSize|keyboard|orientation"
android:parentActivityName=".contributions.MainActivity" />
<activity
android:name=".category.CategoryDetailsActivity"
android:configChanges="screenSize|keyboard|orientation"
android:label="@string/title_activity_featured_images"
android:configChanges="screenSize|keyboard|orientation"
android:parentActivityName=".contributions.MainActivity" />
<activity
android:name=".explore.depictions.WikidataItemDetailsActivity"
android:configChanges="screenSize|keyboard|orientation"
android:label="@string/title_activity_featured_images"
android:configChanges="screenSize|keyboard|orientation"
android:parentActivityName=".contributions.MainActivity" />
<activity
android:name=".explore.SearchActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_search"
android:launchMode="singleTop"
android:parentActivityName=".contributions.MainActivity" />
android:configChanges="orientation|keyboardHidden|screenSize"
android:parentActivityName=".contributions.MainActivity"
/>
<activity
android:name=".profile.ProfileActivity"
android:configChanges="orientation|screenSize|keyboard"
android:label="@string/Profile" />
<activity
android:name=".review.ReviewActivity"
android:label="@string/title_activity_review" />
<activity
android:name=".LocationPicker.LocationPickerActivity"
android:label="Location Picker" />
@ -171,11 +186,11 @@
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<service
android:name="org.acra.sender.SenderService"
android:exported="false"
@ -190,36 +205,42 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<provider
android:name=".category.CategoryContentProvider"
android:authorities="${applicationId}.categories.contentprovider"
android:exported="false"
android:label="@string/provider_categories"
android:syncable="false" />
<provider
android:name=".explore.recentsearches.RecentSearchesContentProvider"
android:authorities="${applicationId}.explore.recentsearches.contentprovider"
android:exported="false"
android:label="@string/provider_searches"
android:syncable="false" />
<provider
android:name=".recentlanguages.RecentLanguagesContentProvider"
android:authorities="${applicationId}.recentlanguages.contentprovider"
android:exported="false"
android:label="@string/provider_recent_languages"
android:syncable="false" />
<provider
android:name=".bookmarks.pictures.BookmarkPicturesContentProvider"
android:authorities="${applicationId}.bookmarks.contentprovider"
android:exported="false"
android:label="@string/provider_bookmarks"
android:syncable="false" />
<provider
android:name=".bookmarks.locations.BookmarkLocationsContentProvider"
android:authorities="${applicationId}.bookmarks.locations.contentprovider"
android:exported="false"
android:label="@string/provider_bookmarks_location"
android:syncable="false" />
<provider
android:name=".bookmarks.items.BookmarkItemsContentProvider"
android:authorities="${applicationId}.bookmarks.items.contentprovider"
@ -227,8 +248,7 @@
android:label="@string/provider_bookmarks_location"
android:syncable="false" />
<receiver
android:name=".widget.PicOfDayAppWidget"
<receiver android:name=".widget.PicOfDayAppWidget"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
@ -239,9 +259,8 @@
android:resource="@xml/pic_of_day_app_widget_info" />
</receiver>
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>
</manifest>

View file

@ -40,6 +40,15 @@ class PageEditClient(
}
}
/**
* Creates a new page with the given title, text, and summary.
*
* @param pageTitle The title of the page to be created.
* @param text The content of the page in wikitext format.
* @param summary The edit summary for the page creation.
* @return An observable that emits true if the page creation succeeded, false otherwise.
* @throws InvalidLoginTokenException If an invalid login token is encountered during the process.
*/
fun postCreate(pageTitle: String, text: String, summary: String): Observable<Boolean> {
return try {
pageEditInterface.postCreate(

View file

@ -133,6 +133,15 @@ public class NetworkingModule {
return new CsrfTokenClient(sessionManager, tokenInterface, loginClient, logoutClient);
}
/**
* Provides a singleton instance of CsrfTokenClient for Wikidata.
*
* @param sessionManager The session manager to manage user sessions.
* @param tokenInterface The interface for obtaining CSRF tokens.
* @param loginClient The client for handling login operations.
* @param logoutClient The client for handling logout operations.
* @return A singleton instance of CsrfTokenClient.
*/
@Named(NAMED_WIKI_CSRF)
@Provides
@Singleton
@ -141,6 +150,12 @@ public class NetworkingModule {
return new CsrfTokenClient(sessionManager, tokenInterface, loginClient, logoutClient);
}
/**
* Provides a singleton instance of CsrfTokenInterface for Wikidata.
*
* @param serviceFactory The factory used to create service interfaces.
* @return A singleton instance of CsrfTokenInterface for Wikidata.
*/
@Named("wikidata-csrf-interface")
@Provides
@Singleton
@ -247,6 +262,13 @@ public class NetworkingModule {
return new PageEditClient(csrfTokenClient, pageEditInterface);
}
/**
* Provides a singleton instance of PageEditClient for Wikidata.
*
* @param csrfTokenClient The client used to manage CSRF tokens.
* @param pageEditInterface The interface for page edit operations.
* @return A singleton instance of PageEditClient for Wikidata.
*/
@Named("wikidata-page-edit")
@Provides
@Singleton

View file

@ -13,7 +13,13 @@ import androidx.recyclerview.widget.RecyclerView
import fr.free.nrw.commons.R
import fr.free.nrw.commons.nearby.model.BottomSheetItem
/**
* RecyclerView Adapter for displaying items in a bottom sheet.
*
* @property context The context used for inflating layout resources.
* @property itemList The list of BottomSheetItem objects to display.
* @constructor Creates an instance of BottomSheetAdapter.
*/
class BottomSheetAdapter(context: Context?, private val itemList: List<BottomSheetItem>) :
RecyclerView.Adapter<BottomSheetAdapter.ViewHolder>() {
private val layoutInflater: LayoutInflater = LayoutInflater.from(context)
@ -36,10 +42,20 @@ class BottomSheetAdapter(context: Context?, private val itemList: List<BottomShe
holder.title.setText(item.title)
}
/**
* Returns the total number of items in the data set held by the adapter.
*
* @return The total number of items in this adapter.
*/
override fun getItemCount(): Int {
return itemList.size
}
/**
* Updates the icon for bookmark item.
*
* @param icon The resource ID of the new icon to set.
*/
fun updateBookmarkIcon(icon: Int) {
itemList.forEachIndexed { index, item ->
if (item.imageResourceId == R.drawable.ic_round_star_filled_24px || item.imageResourceId == R.drawable.ic_round_star_border_24px) {

View file

@ -22,7 +22,13 @@ import javax.inject.Singleton;
import timber.log.Timber;
/**
* Refactored async task to Rx
* Singleton class for making edits to wiki pages asynchronously using RxJava.
*
* @property notificationHelper A helper class for displaying notifications.
* @property pageEditClient A client for making page edit requests.
* @property viewUtil A utility class for common view operations.
* @property username The username used for page edits.
* @constructor Initializes the PageEditHelper with required dependencies.
*/
@Singleton
public class PageEditHelper {
@ -46,18 +52,23 @@ public class PageEditHelper {
}
/**
* Public interface to nominate a particular media file for deletion
* Public interface to make a page edit request asynchronously.
*
* @param context
* @param title
* @return
* @param context The context for displaying messages.
* @param title The title of the page to edit.
* @param preText The existing content of the page.
* @param description The description of the issue to be fixed.
* @param details Additional details about the issue.
* @param lat The latitude of the location related to the page.
* @param lng The longitude of the location related to the page.
* @return A Single emitting true if the edit was successful, false otherwise.
*/
public Single<Boolean> makePageEdit(Context context, String title, String preText,
String description,
String details, Double lat, Double lng) {
viewUtil.showShortToast(context, "Trying to edit " + title);
return create(title, preText, description, details, lat, lng)
return editPage(title, preText, description, details, lat, lng)
.flatMapSingle(result -> Single.just(showNotification(context, title, result)))
.firstOrError()
.onErrorResumeNext(throwable -> {
@ -69,12 +80,17 @@ public class PageEditHelper {
}
/**
* Makes several API calls to nominate the file for deletion
* Creates the text content for the page edit based on provided parameters.
*
* @param title
* @return
* @param title The title of the page to edit.
* @param preText The existing content of the page.
* @param description The description of the issue to be fixed.
* @param details Additional details about the issue.
* @param lat The latitude of the location related to the page.
* @param lng The longitude of the location related to the page.
* @return An Observable emitting true if the edit was successful, false otherwise.
*/
private Observable<Boolean> create(String title, String preText, String description,
private Observable<Boolean> editPage(String title, String preText, String description,
String details, Double lat, Double lng) {
Timber.d("thread is edit %s", Thread.currentThread().getName());
String summary = "Please fix this item";
@ -107,6 +123,14 @@ public class PageEditHelper {
return pageEditClient.postCreate(title, text, summary);
}
/**
* Displays a notification based on the result of the page edit.
*
* @param context The context for displaying the notification.
* @param title The title of the page edited.
* @param result The result of the edit operation.
* @return true if the edit was successful, false otherwise.
*/
private boolean showNotification(Context context, String title, boolean result) {
String message;

View file

@ -15,7 +15,9 @@ import timber.log.Timber
import java.util.concurrent.Callable
import javax.inject.Inject
/**
* Activity for providing feedback about Wikidata items.
*/
class WikidataFeedback : BaseActivity() {
private lateinit var binding: ActivityWikidataFeedbackBinding
var place: String = ""
@ -40,13 +42,21 @@ class WikidataFeedback : BaseActivity() {
lng = intent.getDoubleExtra("lng", 0.0)
place = intent.getStringExtra("place") ?: ""
wikidataQId = intent.getStringExtra("qid") ?: ""
pageTitle = "Talk:" + wikidataQId
pageTitle = getString(R.string.talk) + ":" + wikidataQId
binding.toolbarBinding.toolbar.title = pageTitle
binding.textHeader.text =
"Write something about the " + "'$place'" + " item. It will be publicly visible."
binding.radioButton1.setText("'$place' does not exist anymore, no picture can ever be taken of it.")
binding.radioButton2.setText("'$place' is at a different place (please specify the correct place below, if possible tell us the correct latitude/longitude).")
binding.radioButton3.setText("Other problem or information (please explain below).")
getString(R.string.write_something_about_the) + "'$place'" + getString(R.string.item_it_will_be_publicly_visible)
binding.radioButton1.setText(
getString(
R.string.does_not_exist_anymore_no_picture_can_ever_be_taken_of_it,
place
))
binding.radioButton2.setText(
getString(
R.string.is_at_a_different_place_please_specify_the_correct_place_below_if_possible_tell_us_the_correct_latitude_longitude,
place
))
binding.radioButton3.setText(getString(R.string.other_problem_or_information_please_explain_below))
setSupportActionBar(binding.toolbarBinding.toolbar)
supportActionBar!!.setDisplayHomeAsUpEnabled(true)

View file

@ -681,6 +681,12 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
}
/**
* Determines the number of spans (columns) in the RecyclerView based on device orientation
* and adapter item count.
*
* @return The number of spans to be used in the RecyclerView.
*/
private int getSpanCount() {
int orientation = getResources().getConfiguration().orientation;
if (bottomSheetAdapter != null) {

View file

@ -818,6 +818,12 @@ Upload your first media by tapping on the add button.</string>
</plurals>
<string name="multiple_files_depiction">Please remember that all images in a multi-upload get the same categories and depictions. If the images do not share depictions and categories, please perform several separate uploads.</string>
<string name="multiple_files_depiction_header">Note about multi-uploads</string>
<string name="nearby_wikitalk">wikitalk</string>
<string name="nearby_wikitalk">Report a problem about this item to Wikidata</string>
<string name="please_enter_some_comments">Please enter some comments</string>
<string name="talk">Talk</string>
<string name="write_something_about_the">"Write something about the "</string>
<string name="item_it_will_be_publicly_visible">" item. It will be publicly visible."</string>
<string name="does_not_exist_anymore_no_picture_can_ever_be_taken_of_it">\'%1$s\' does not exist anymore, no picture can ever be taken of it.</string>
<string name="is_at_a_different_place_please_specify_the_correct_place_below_if_possible_tell_us_the_correct_latitude_longitude">\'%1$s\' is at a different place (please specify the correct place below, if possible tell us the correct latitude/longitude).</string>
<string name="other_problem_or_information_please_explain_below">Other problem or information (please explain below).</string>
</resources>