mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* refactor: replace unused exception variable with underscore * refactor: code style fix * fix: remove unnecessary latLng variable and return null directly * fix: use explicit true/false instead of isFABsExpanded * refactor: simplify marker update logic by reducing redundant conditions * refactor: use data object instead of object * fix: check placeBindings for null instead of checking each destructured value * fix: check placeBindings for null instead of checking each destructured value * docs: fix KDoc for contentUri property by removing incorrect @param tag * docs: correct @see link in KDoc for showBadgesWithCount * docs: fix KDoc tag from @property to @param for context in BottomSheetAdapter * docs: comment out KDoc for disabled method to avoid unresolved @param warning * docs: fix KDoc for onLongPress by removing invalid @param imageUri * docs: clean up invalid KDoc tags on property and add docs to isEmpty * docs: remove invalid @param originalImageCoordinates from findOtherImages KDoc * docs: fix incorrect @param tag in checkDuplicateImage KDoc * docs: fix incorrect @param in onLongPress KDoc * docs: fix invalid @param and @return tags on author property * docs: fix incorrect @param in provideWikidataMediaInterface KDoc * docs: fix incorrect @param name in getWikiText KDoc * docs: escape wikilinks with [[ ]] to avoid KDoc resolution warnings * docs: fix KDoc by adding missing param descriptions to startActivityWithFlags * docs: fix KDoc by replacing @param with @property for contentUri * docs: fix malformed KDoc in startYourself, remove invalid @param line * docs: remove invalid @param tag in createDialogsAndHandleLocationPermissions * docs: remove invalid @param tags to @property * @docs: remove invalid @property tags * docs: clean up KDoc by removing invalid @param and @return tags * docs: fix incorrect @param name in removeBlocklisted KDoc * docs: fix incorrect @param name in checkDuplicateImage KDoc * docs: fix incorrect @param tag --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
ed1485ca22
commit
cfc2cfcca1
29 changed files with 153 additions and 150 deletions
|
|
@ -49,7 +49,7 @@ class UploadCancelledTest {
|
||||||
fun setup() {
|
fun setup() {
|
||||||
try {
|
try {
|
||||||
Intents.init()
|
Intents.init()
|
||||||
} catch (ex: IllegalStateException) {
|
} catch (_: IllegalStateException) {
|
||||||
}
|
}
|
||||||
device.unfreezeRotation()
|
device.unfreezeRotation()
|
||||||
device.setOrientationNatural()
|
device.setOrientationNatural()
|
||||||
|
|
@ -65,7 +65,7 @@ class UploadCancelledTest {
|
||||||
fun teardown() {
|
fun teardown() {
|
||||||
try {
|
try {
|
||||||
Intents.release()
|
Intents.release()
|
||||||
} catch (ex: IllegalStateException) {
|
} catch (_: IllegalStateException) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class UploadTest {
|
||||||
fun setup() {
|
fun setup() {
|
||||||
try {
|
try {
|
||||||
Intents.init()
|
Intents.init()
|
||||||
} catch (ex: IllegalStateException) {
|
} catch (_: IllegalStateException) {
|
||||||
}
|
}
|
||||||
UITestHelper.loginUser()
|
UITestHelper.loginUser()
|
||||||
UITestHelper.skipWelcome()
|
UITestHelper.skipWelcome()
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,7 @@ class Media constructor(
|
||||||
*/
|
*/
|
||||||
var filename: String? = null,
|
var filename: String? = null,
|
||||||
/**
|
/**
|
||||||
* Gets or sets the file description.
|
* The fallback description of the file, used if no other description is provided.
|
||||||
* @return file description as a string
|
|
||||||
* @param fallbackDescription the new description of the file
|
|
||||||
*/
|
*/
|
||||||
var fallbackDescription: String? = null,
|
var fallbackDescription: String? = null,
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,19 +38,24 @@ class Media constructor(
|
||||||
*/
|
*/
|
||||||
var dateUploaded: Date? = null,
|
var dateUploaded: Date? = null,
|
||||||
/**
|
/**
|
||||||
* Gets or sets the license name of the file.
|
* The license name of the file.
|
||||||
* @return license as a String
|
|
||||||
* @param license license name as a String
|
|
||||||
*/
|
*/
|
||||||
var license: String? = null,
|
var license: String? = null,
|
||||||
|
/**
|
||||||
|
* The URL corresponding to the license.
|
||||||
|
*/
|
||||||
var licenseUrl: String? = null,
|
var licenseUrl: String? = null,
|
||||||
/**
|
/**
|
||||||
* Gets or sets the name of the creator of the file.
|
* The name of the creator of the file.
|
||||||
* @return author name as a String
|
|
||||||
* @param author creator name as a string
|
|
||||||
*/
|
*/
|
||||||
var author: String? = null,
|
var author: String? = null,
|
||||||
|
/**
|
||||||
|
* The username of the uploader.
|
||||||
|
*/
|
||||||
var user: String? = null,
|
var user: String? = null,
|
||||||
|
/**
|
||||||
|
* The full name of the file's creator, if different from username.
|
||||||
|
*/
|
||||||
var creatorName: String? = null,
|
var creatorName: String? = null,
|
||||||
/**
|
/**
|
||||||
* Gets the categories the file falls under.
|
* Gets the categories the file falls under.
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,10 @@ interface PageEditInterface {
|
||||||
): Observable<Entities>
|
): Observable<Entities>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get wiki text for provided file names
|
* Gets the wiki text for the provided file name.
|
||||||
* @param titles : Name of the file
|
*
|
||||||
* @return Single<MwQueryResult>
|
* @param title The title (name) of the file to fetch wiki text for.
|
||||||
|
* @return A Single emitting the wiki query response.
|
||||||
*/
|
*/
|
||||||
@GET(MW_API_PREFIX + "action=query&prop=revisions&rvprop=content|timestamp&rvlimit=1&converttitles=")
|
@GET(MW_API_PREFIX + "action=query&prop=revisions&rvprop=content|timestamp&rvlimit=1&converttitles=")
|
||||||
fun getWikiText(
|
fun getWikiText(
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class Bookmark(
|
||||||
/**
|
/**
|
||||||
* Gets or Sets the content URI - marking this bookmark as already saved in the database
|
* Gets or Sets the content URI - marking this bookmark as already saved in the database
|
||||||
* @return content URI
|
* @return content URI
|
||||||
* @param contentUri the content URI
|
* contentUri the content URI
|
||||||
*/
|
*/
|
||||||
var contentUri: Uri?,
|
var contentUri: Uri?,
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ class ExceptionAwareThreadPoolExecutor(
|
||||||
if (r.isDone) {
|
if (r.isDone) {
|
||||||
r.get()
|
r.get()
|
||||||
}
|
}
|
||||||
} catch (e: CancellationException) {
|
} catch (_: CancellationException) {
|
||||||
// ignore
|
// ignore
|
||||||
} catch (e: InterruptedException) {
|
} catch (_: InterruptedException) {
|
||||||
// ignore
|
// ignore
|
||||||
} catch (e: ExecutionException) {
|
} catch (e: ExecutionException) {
|
||||||
throwable = e.cause ?: e
|
throwable = e.cause ?: e
|
||||||
|
|
|
||||||
|
|
@ -808,10 +808,11 @@ class ContributionsFragment : CommonsDaggerSupportFragment(), FragmentManager.On
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Temporarily disabled, see issue [https://github.com/commons-app/apps-android-commons/issues/5847]
|
// * Temporarily disabled. See issue [#5847](https://github.com/commons-app/apps-android-commons/issues/5847)
|
||||||
* @param count The number of pending uploads.
|
// * @param count The number of pending uploads.
|
||||||
*/
|
// */
|
||||||
|
// public void updateUploadIcon(int count) {
|
||||||
// public void updateUploadIcon(int count) {
|
// public void updateUploadIcon(int count) {
|
||||||
// if (pendingUploadsImageView != null) {
|
// if (pendingUploadsImageView != null) {
|
||||||
// if (count != 0) {
|
// if (count != 0) {
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,11 @@ interface ImageSelectListener {
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onLongPress
|
* Called when the user performs a long press on an image.
|
||||||
* @param imageUri : uri of image
|
*
|
||||||
|
* @param position The index of the pressed image in the list.
|
||||||
|
* @param images The list of all available images.
|
||||||
|
* @param selectedImages The currently selected images.
|
||||||
*/
|
*/
|
||||||
fun onLongPress(
|
fun onLongPress(
|
||||||
position: Int,
|
position: Int,
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,15 @@ sealed class CallbackStatus {
|
||||||
/**
|
/**
|
||||||
IDLE : The callback is idle , doing nothing.
|
IDLE : The callback is idle , doing nothing.
|
||||||
*/
|
*/
|
||||||
object IDLE : CallbackStatus()
|
data object IDLE : CallbackStatus()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
FETCHING : Fetching images.
|
FETCHING : Fetching images.
|
||||||
*/
|
*/
|
||||||
object FETCHING : CallbackStatus()
|
data object FETCHING : CallbackStatus()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
SUCCESS : Success fetching images.
|
SUCCESS : Success fetching images.
|
||||||
*/
|
*/
|
||||||
object SUCCESS : CallbackStatus()
|
data object SUCCESS : CallbackStatus()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -610,8 +610,11 @@ class CustomSelectorActivity :
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onLongPress
|
* Triggered when the user performs a long press on an image.
|
||||||
* @param imageUri : uri of image
|
*
|
||||||
|
* @param position The index of the selected image.
|
||||||
|
* @param images The list of all available images.
|
||||||
|
* @param selectedImages The list of images currently selected.
|
||||||
*/
|
*/
|
||||||
override fun onLongPress(
|
override fun onLongPress(
|
||||||
position: Int,
|
position: Int,
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ class ImageFileLoader(
|
||||||
if (file != null && file.exists() && name != null && path != null && bucketName != null) {
|
if (file != null && file.exists() && name != null && path != null && bucketName != null) {
|
||||||
val extension = path.substringAfterLast(".", "")
|
val extension = path.substringAfterLast(".", "")
|
||||||
// Check if the extension is one of the allowed types
|
// Check if the extension is one of the allowed types
|
||||||
if (extension.lowercase(Locale.ROOT) !in arrayOf("jpg", "jpeg", "png", "svg", "gif", "tiff", "webp", "xcf")) {
|
if (extension.lowercase(Locale.ROOT) !in arrayOf("jpg", "jpeg", "png", "svg",
|
||||||
|
"gif", "tiff", "webp", "xcf")) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -238,10 +238,10 @@ class NetworkingModule {
|
||||||
factory.create(BuildConfig.COMMONS_URL)
|
factory.create(BuildConfig.COMMONS_URL)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add provider for WikidataMediaInterface
|
* Provides a Retrofit service for accessing the commons wiki site via [WikidataMediaInterface].
|
||||||
* It creates a retrofit service for the commons wiki site
|
*
|
||||||
* @param commonsWikiSite commonsWikiSite
|
* @param factory The CommonsServiceFactory used to create the Retrofit service.
|
||||||
* @return WikidataMediaInterface
|
* @return An instance of [WikidataMediaInterface].
|
||||||
*/
|
*/
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ import java.util.Date
|
||||||
*/
|
*/
|
||||||
class RecentSearch(
|
class RecentSearch(
|
||||||
/**
|
/**
|
||||||
* Modifies the content URI - marking this query as already saved in the database
|
* The content URI that marks this query as already saved in the database.
|
||||||
*
|
*
|
||||||
* @param contentUri the content URI
|
* @property contentUri the content URI
|
||||||
*/
|
*/
|
||||||
var contentUri: Uri?,
|
var contentUri: Uri?,
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -531,40 +531,38 @@ ${"wd:" + place.wikiDataEntityId}"""
|
||||||
)
|
)
|
||||||
if (placeBindings != null) {
|
if (placeBindings != null) {
|
||||||
for ((item1, label, location, clas) in placeBindings) {
|
for ((item1, label, location, clas) in placeBindings) {
|
||||||
if (item1 != null && label != null && clas != null) {
|
val input = location.value
|
||||||
val input = location.value
|
val pattern = Pattern.compile(
|
||||||
val pattern = Pattern.compile(
|
"Point\\(([-+]?[0-9]*\\.?[0-9]+) ([-+]?[0-9]*\\.?[0-9]+)\\)"
|
||||||
"Point\\(([-+]?[0-9]*\\.?[0-9]+) ([-+]?[0-9]*\\.?[0-9]+)\\)"
|
)
|
||||||
)
|
val matcher = pattern.matcher(input)
|
||||||
val matcher = pattern.matcher(input)
|
|
||||||
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
val longStr = matcher.group(1)
|
val longStr = matcher.group(1)
|
||||||
val latStr = matcher.group(2)
|
val latStr = matcher.group(2)
|
||||||
val itemUrl = item1.value
|
val itemUrl = item1.value
|
||||||
val itemName = label.value.replace("&", "&")
|
val itemName = label.value.replace("&", "&")
|
||||||
val itemLatitude = latStr
|
val itemLatitude = latStr
|
||||||
val itemLongitude = longStr
|
val itemLongitude = longStr
|
||||||
val itemClass = clas.value
|
val itemClass = clas.value
|
||||||
|
|
||||||
val formattedItemName =
|
val formattedItemName =
|
||||||
if (!itemClass.isEmpty())
|
if (!itemClass.isEmpty())
|
||||||
"$itemName ($itemClass)"
|
"$itemName ($itemClass)"
|
||||||
else
|
else
|
||||||
itemName
|
itemName
|
||||||
|
|
||||||
val kmlEntry = ("""
|
val kmlEntry = ("""
|
||||||
<Placemark>
|
<Placemark>
|
||||||
<name>$formattedItemName</name>
|
<name>$formattedItemName</name>
|
||||||
<description>$itemUrl</description>
|
<description>$itemUrl</description>
|
||||||
<Point>
|
<Point>
|
||||||
<coordinates>$itemLongitude,$itemLatitude</coordinates>
|
<coordinates>$itemLongitude,$itemLatitude</coordinates>
|
||||||
</Point>
|
</Point>
|
||||||
</Placemark>""")
|
</Placemark>""")
|
||||||
kmlString = kmlString + kmlEntry
|
kmlString = kmlString + kmlEntry
|
||||||
} else {
|
} else {
|
||||||
Timber.e("No match found")
|
Timber.e("No match found")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -589,37 +587,35 @@ ${"wd:" + place.wikiDataEntityId}"""
|
||||||
val placeBindings = runQuery(leftLatLng, rightLatLng)
|
val placeBindings = runQuery(leftLatLng, rightLatLng)
|
||||||
if (placeBindings != null) {
|
if (placeBindings != null) {
|
||||||
for ((item1, label, location, clas) in placeBindings) {
|
for ((item1, label, location, clas) in placeBindings) {
|
||||||
if (item1 != null && label != null && clas != null) {
|
val input = location.value
|
||||||
val input = location.value
|
val pattern = Pattern.compile(
|
||||||
val pattern = Pattern.compile(
|
"Point\\(([-+]?[0-9]*\\.?[0-9]+) ([-+]?[0-9]*\\.?[0-9]+)\\)"
|
||||||
"Point\\(([-+]?[0-9]*\\.?[0-9]+) ([-+]?[0-9]*\\.?[0-9]+)\\)"
|
)
|
||||||
)
|
val matcher = pattern.matcher(input)
|
||||||
val matcher = pattern.matcher(input)
|
|
||||||
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
val longStr = matcher.group(1)
|
val longStr = matcher.group(1)
|
||||||
val latStr = matcher.group(2)
|
val latStr = matcher.group(2)
|
||||||
val itemUrl = item1.value
|
val itemUrl = item1.value
|
||||||
val itemName = label.value.replace("&", "&")
|
val itemName = label.value.replace("&", "&")
|
||||||
val itemLatitude = latStr
|
val itemLatitude = latStr
|
||||||
val itemLongitude = longStr
|
val itemLongitude = longStr
|
||||||
val itemClass = clas.value
|
val itemClass = clas.value
|
||||||
|
|
||||||
val formattedItemName = if (!itemClass.isEmpty())
|
val formattedItemName = if (!itemClass.isEmpty())
|
||||||
"$itemName ($itemClass)"
|
"$itemName ($itemClass)"
|
||||||
else
|
else
|
||||||
itemName
|
itemName
|
||||||
|
|
||||||
val gpxEntry =
|
val gpxEntry =
|
||||||
("""
|
("""
|
||||||
<wpt lat="$itemLatitude" lon="$itemLongitude">
|
<wpt lat="$itemLatitude" lon="$itemLongitude">
|
||||||
<name>$itemName</name>
|
<name>$itemName</name>
|
||||||
<url>$itemUrl</url>
|
<url>$itemUrl</url>
|
||||||
</wpt>""")
|
</wpt>""")
|
||||||
gpxString = gpxString + gpxEntry
|
gpxString = gpxString + gpxEntry
|
||||||
} else {
|
} else {
|
||||||
Timber.e("No match found")
|
Timber.e("No match found")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import fr.free.nrw.commons.nearby.model.BottomSheetItem
|
||||||
/**
|
/**
|
||||||
* RecyclerView Adapter for displaying items in a bottom sheet.
|
* RecyclerView Adapter for displaying items in a bottom sheet.
|
||||||
*
|
*
|
||||||
* @property context The context used for inflating layout resources.
|
* @param context The context used for inflating layout resources.
|
||||||
* @property itemList The list of BottomSheetItem objects to display.
|
* @property itemList The list of BottomSheetItem objects to display.
|
||||||
* @constructor Creates an instance of BottomSheetAdapter.
|
* @constructor Creates an instance of BottomSheetAdapter.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao
|
||||||
import fr.free.nrw.commons.contributions.ContributionController
|
import fr.free.nrw.commons.contributions.ContributionController
|
||||||
import fr.free.nrw.commons.contributions.MainActivity
|
import fr.free.nrw.commons.contributions.MainActivity
|
||||||
import fr.free.nrw.commons.contributions.MainActivity.ActiveFragment
|
import fr.free.nrw.commons.contributions.MainActivity.ActiveFragment
|
||||||
|
import fr.free.nrw.commons.customselector.ui.selector.ImageLoader
|
||||||
import fr.free.nrw.commons.databinding.FragmentNearbyParentBinding
|
import fr.free.nrw.commons.databinding.FragmentNearbyParentBinding
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment
|
||||||
import fr.free.nrw.commons.filepicker.FilePicker
|
import fr.free.nrw.commons.filepicker.FilePicker
|
||||||
|
|
@ -1756,9 +1757,9 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
|
||||||
override fun animateFABs() {
|
override fun animateFABs() {
|
||||||
if (binding!!.fabPlus.isShown) {
|
if (binding!!.fabPlus.isShown) {
|
||||||
if (isFABsExpanded) {
|
if (isFABsExpanded) {
|
||||||
collapseFABs(isFABsExpanded)
|
collapseFABs(true)
|
||||||
} else {
|
} else {
|
||||||
expandFABs(isFABsExpanded)
|
expandFABs(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2013,17 +2014,17 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
|
||||||
if (place.exists && place.pic.trim { it <= ' ' }.isEmpty()) {
|
if (place.exists && place.pic.trim { it <= ' ' }.isEmpty()) {
|
||||||
shouldUpdateMarker = true
|
shouldUpdateMarker = true
|
||||||
}
|
}
|
||||||
} else if (displayExists && !displayNeedsPhoto) {
|
} else if (displayExists) {
|
||||||
// Exists and all included needs and doesn't needs photo
|
// Exists and all included needs and doesn't needs photo
|
||||||
if (place.exists) {
|
if (place.exists) {
|
||||||
shouldUpdateMarker = true
|
shouldUpdateMarker = true
|
||||||
}
|
}
|
||||||
} else if (!displayExists && displayNeedsPhoto) {
|
} else if (displayNeedsPhoto) {
|
||||||
// All and only needs photo
|
// All and only needs photo
|
||||||
if (place.pic.trim { it <= ' ' }.isEmpty()) {
|
if (place.pic.trim { it <= ' ' }.isEmpty()) {
|
||||||
shouldUpdateMarker = true
|
shouldUpdateMarker = true
|
||||||
}
|
}
|
||||||
} else if (!displayExists && !displayNeedsPhoto) {
|
} else {
|
||||||
// all
|
// all
|
||||||
shouldUpdateMarker = true
|
shouldUpdateMarker = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -389,7 +389,7 @@ class AchievementsFragment : CommonsDaggerSupportFragment(){
|
||||||
* @param badgeTextColor The badge text color. Default is R.attr.colorPrimary
|
* @param badgeTextColor The badge text color. Default is R.attr.colorPrimary
|
||||||
* @param badgeGravity The position of the badge [TOP_END,TOP_START,BOTTOM_END,BOTTOM_START]. Default is TOP_END
|
* @param badgeGravity The position of the badge [TOP_END,TOP_START,BOTTOM_END,BOTTOM_START]. Default is TOP_END
|
||||||
* @return if the number is 0, then it will not create badge for it and hide the view
|
* @return if the number is 0, then it will not create badge for it and hide the view
|
||||||
* @see https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable
|
* @see <a href="https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable">BadgeDrawable (Android Developer)</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private fun showBadgesWithCount(
|
private fun showBadgesWithCount(
|
||||||
|
|
|
||||||
|
|
@ -93,10 +93,11 @@ class QuizResultActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to call intent to an activity
|
* Starts an activity using the provided context, target class, and intent flags.
|
||||||
* @param context
|
*
|
||||||
* @param cls
|
* @param context The context used to start the activity.
|
||||||
* @param flags
|
* @param cls The target activity class.
|
||||||
|
* @param flags A variable number of intent flags to apply to the Intent.
|
||||||
*/
|
*/
|
||||||
companion object {
|
companion object {
|
||||||
fun <T> startActivityWithFlags(context: Context, cls: Class<T>, vararg flags: Int) {
|
fun <T> startActivityWithFlags(context: Context, cls: Class<T>, vararg flags: Int) {
|
||||||
|
|
|
||||||
|
|
@ -199,10 +199,11 @@ class UploadRepository @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query the RemoteDataSource for image duplicity check
|
* Queries the RemoteDataSource to check if the image is a duplicate.
|
||||||
*
|
*
|
||||||
* @param filePath file to be checked
|
* @param originalFilePath The original file to be checked.
|
||||||
* @return IMAGE_DUPLICATE or IMAGE_OK
|
* @param modifiedFilePath The modified version of the file (if any).
|
||||||
|
* @return IMAGE_DUPLICATE if the image already exists, otherwise IMAGE_OK.
|
||||||
*/
|
*/
|
||||||
fun checkDuplicateImage(originalFilePath: Uri?, modifiedFilePath: Uri?): Single<Int> {
|
fun checkDuplicateImage(originalFilePath: Uri?, modifiedFilePath: Uri?): Single<Int> {
|
||||||
return uploadModel.checkDuplicateImage(originalFilePath, modifiedFilePath)
|
return uploadModel.checkDuplicateImage(originalFilePath, modifiedFilePath)
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,10 @@ class ReviewActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumers should be simply using this method to use this activity.
|
* Starts the ReviewActivity.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context The context used to start the activity.
|
||||||
* @param title Page title
|
* @param title The page title (currently unused).
|
||||||
*/
|
*/
|
||||||
companion object {
|
companion object {
|
||||||
fun startYourself(context: Context, title: String) {
|
fun startYourself(context: Context, title: String) {
|
||||||
|
|
|
||||||
|
|
@ -276,9 +276,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks users to provide location access
|
* Asks users to provide location access.
|
||||||
*
|
|
||||||
* @param activity
|
|
||||||
*/
|
*/
|
||||||
private fun createDialogsAndHandleLocationPermissions() {
|
private fun createDialogsAndHandleLocationPermissions() {
|
||||||
inAppCameraLocationPermissionLauncher.launch(arrayOf(permission.ACCESS_FINE_LOCATION))
|
inAppCameraLocationPermissionLauncher.launch(arrayOf(permission.ACCESS_FINE_LOCATION))
|
||||||
|
|
|
||||||
|
|
@ -6,29 +6,29 @@ package fr.free.nrw.commons.upload
|
||||||
class Description {
|
class Description {
|
||||||
/**
|
/**
|
||||||
* The language code, e.g., "en" or "fr".
|
* The language code, e.g., "en" or "fr".
|
||||||
* @param languageCode The language code.
|
* @property languageCode The language code.
|
||||||
*/
|
*/
|
||||||
var languageCode: String? = null
|
var languageCode: String? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description text for the item being uploaded.
|
* The description text for the item being uploaded.
|
||||||
* @param descriptionText The description text.
|
* @property descriptionText The description text.
|
||||||
*/
|
*/
|
||||||
var descriptionText: String? = null
|
var descriptionText: String? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index of the language selected in a spinner with [SpinnerLanguagesAdapter].
|
* The index of the language selected in a spinner with [SpinnerLanguagesAdapter].
|
||||||
* @param selectedLanguageIndex The index of the selected language.
|
* @property selectedLanguageIndex The index of the selected language.
|
||||||
*/
|
*/
|
||||||
var selectedLanguageIndex = -1
|
var selectedLanguageIndex = -1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the description was added manually (by the user or programmatically).
|
* Indicates if the description was added manually (by the user or programmatically).
|
||||||
* @param manuallyAdded Sets to true if the description was manually added by the user.
|
|
||||||
* @return True if the description was manually added.
|
|
||||||
*/
|
*/
|
||||||
var isManuallyAdded = false
|
var isManuallyAdded = false
|
||||||
|
/**
|
||||||
|
* Returns true if the description text is null or empty.
|
||||||
|
*/
|
||||||
val isEmpty: Boolean
|
val isEmpty: Boolean
|
||||||
get() = descriptionText == null || descriptionText!!.isEmpty()
|
get() = descriptionText == null || descriptionText!!.isEmpty()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,13 +137,12 @@ class FileProcessor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find other images around the same location that were taken within the last 20 sec
|
* Finds other images around the same location that were taken within a ±120 sec window.
|
||||||
*
|
*
|
||||||
* @param originalImageCoordinates
|
* @param fileBeingProcessed The file currently being checked.
|
||||||
* @param fileBeingProcessed
|
* @param similarImageInterface Callback to display similar images if any are found.
|
||||||
* @param similarImageInterface
|
*/
|
||||||
*/
|
|
||||||
private fun findOtherImages(
|
private fun findOtherImages(
|
||||||
fileBeingProcessed: File,
|
fileBeingProcessed: File,
|
||||||
similarImageInterface: SimilarImageInterface?,
|
similarImageInterface: SimilarImageInterface?,
|
||||||
|
|
|
||||||
|
|
@ -138,10 +138,10 @@ class ImageProcessingService @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for duplicate image
|
* Checks for duplicate image by calculating its SHA1 hash and querying the media client.
|
||||||
*
|
*
|
||||||
* @param filePath file to be checked
|
* @param inputStream The input stream of the file to check.
|
||||||
* @return IMAGE_DUPLICATE or IMAGE_OK
|
* @return IMAGE_DUPLICATE if the file exists, or IMAGE_OK otherwise.
|
||||||
*/
|
*/
|
||||||
private fun checkDuplicateImage(inputStream: InputStream): Single<Int> {
|
private fun checkDuplicateImage(inputStream: InputStream): Single<Int> {
|
||||||
return Single.fromCallable { fileUtilsWrapper.getSHA1(inputStream) }
|
return Single.fromCallable { fileUtilsWrapper.getSHA1(inputStream) }
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,15 @@ import kotlinx.parcelize.Parcelize
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class UploadMediaDetail(
|
data class UploadMediaDetail(
|
||||||
/**
|
/**
|
||||||
* The language code ie. "en" or "fr".
|
* The language code, e.g., "en" or "fr".
|
||||||
* @param languageCode The language code ie. "en" or "fr".
|
|
||||||
*/
|
*/
|
||||||
var languageCode: String? = null,
|
var languageCode: String? = null,
|
||||||
/**
|
/**
|
||||||
* The description text for the item being uploaded.
|
* The description text for the item being uploaded.
|
||||||
* @param descriptionText The description text.
|
|
||||||
*/
|
*/
|
||||||
var descriptionText: String? = "",
|
var descriptionText: String? = "",
|
||||||
/**
|
/**
|
||||||
* The caption text for the item being uploaded.
|
* The caption text for the item being uploaded.
|
||||||
* @param captionText The caption text.
|
|
||||||
*/
|
*/
|
||||||
var captionText: String = "",
|
var captionText: String = "",
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
@ -35,15 +32,11 @@ data class UploadMediaDetail(
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index of the language selected in a spinner with [SpinnerLanguagesAdapter].
|
* The index of the language selected in a spinner with [SpinnerLanguagesAdapter].
|
||||||
* @return The index of the selected language.
|
|
||||||
* @param selectedLanguageIndex The index of the language selected.
|
|
||||||
*/
|
*/
|
||||||
var selectedLanguageIndex: Int = -1
|
var selectedLanguageIndex: Int = -1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the description was added manually (by the user, or programmatically).
|
* Indicates whether the description was added manually (by the user or programmatically).
|
||||||
* @return True if the description was manually added.
|
|
||||||
* @param manuallyAdded Sets to true if the description was manually added.
|
|
||||||
*/
|
*/
|
||||||
var isManuallyAdded: Boolean = false
|
var isManuallyAdded: Boolean = false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,10 @@ class UploadMediaDetailInputFilter : InputFilter {
|
||||||
patterns.any { it.matcher(source).find() }
|
patterns.any { it.matcher(source).find() }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes any blocklisted characters from the source text.
|
* Removes any blocklisted characters from the input text.
|
||||||
* @param source input text
|
*
|
||||||
* @return a cleaned character sequence
|
* @param input The input text to be cleaned.
|
||||||
|
* @return A cleaned character sequence with blocklisted patterns removed.
|
||||||
*/
|
*/
|
||||||
private fun removeBlocklisted(input: CharSequence): CharSequence {
|
private fun removeBlocklisted(input: CharSequence): CharSequence {
|
||||||
var source = input
|
var source = input
|
||||||
|
|
|
||||||
|
|
@ -98,10 +98,11 @@ class UploadModel @Inject internal constructor(
|
||||||
imageProcessingService.validateImage(uploadItem, inAppPictureLocation)
|
imageProcessingService.validateImage(uploadItem, inAppPictureLocation)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls checkDuplicateImage() of ImageProcessingService to check if image is duplicate
|
* Calls checkDuplicateImage() of ImageProcessingService to check if the image is a duplicate.
|
||||||
*
|
*
|
||||||
* @param filePath file to be checked
|
* @param originalFilePath The original file URI.
|
||||||
* @return IMAGE_DUPLICATE or IMAGE_OK
|
* @param modifiedFilePath The modified file URI.
|
||||||
|
* @return IMAGE_DUPLICATE if the file already exists, IMAGE_OK otherwise.
|
||||||
*/
|
*/
|
||||||
fun checkDuplicateImage(originalFilePath: Uri?, modifiedFilePath: Uri?): Single<Int> =
|
fun checkDuplicateImage(originalFilePath: Uri?, modifiedFilePath: Uri?): Single<Int> =
|
||||||
imageProcessingService.checkIfFileAlreadyExists(
|
imageProcessingService.checkIfFileAlreadyExists(
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ object LocationUtils {
|
||||||
val indexOfPrefix = customQuery.indexOf("Point(")
|
val indexOfPrefix = customQuery.indexOf("Point(")
|
||||||
if (indexOfPrefix == -1) {
|
if (indexOfPrefix == -1) {
|
||||||
Timber.e("Invalid prefix index - Seems like user has entered an invalid query")
|
Timber.e("Invalid prefix index - Seems like user has entered an invalid query")
|
||||||
return latLng
|
return null
|
||||||
}
|
}
|
||||||
val indexOfSuffix = customQuery.indexOf(")\"", indexOfPrefix)
|
val indexOfSuffix = customQuery.indexOf(")\"", indexOfPrefix)
|
||||||
if (indexOfSuffix == -1) {
|
if (indexOfSuffix == -1) {
|
||||||
Timber.e("Invalid suffix index - Seems like user has entered an invalid query")
|
Timber.e("Invalid suffix index - Seems like user has entered an invalid query")
|
||||||
return latLng
|
return null
|
||||||
}
|
}
|
||||||
val latLngString = customQuery.substring(indexOfPrefix + "Point(".length, indexOfSuffix)
|
val latLngString = customQuery.substring(indexOfPrefix + "Point(".length, indexOfSuffix)
|
||||||
if (latLngString.isEmpty()) {
|
if (latLngString.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ class PageTitle : Parcelable {
|
||||||
* looking at.
|
* looking at.
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* * [[Manchester]] on enwiki will have a namespace of null
|
* * \[\[Manchester\]\] on enwiki will have a namespace of null
|
||||||
* * [[Deutschland]] on dewiki will have a namespace of null
|
* * \[\[Deutschland\]\] on dewiki will have a namespace of null
|
||||||
* * [[User:Deskana]] on enwiki will have a namespace of "User"
|
* * [[User:Deskana]] on enwiki will have a namespace of "User"
|
||||||
* * [[Utilisateur:Deskana]] on frwiki will have a namespace of "Utilisateur", even if you got
|
* * [[Utilisateur:Deskana]] on frwiki will have a namespace of "Utilisateur", even if you got
|
||||||
* to the page by going to [[User:Deskana]] and having MediaWiki automatically redirect you.
|
* to the page by going to [[User:Deskana]] and having MediaWiki automatically redirect you.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue