From e78db7fa0828bfc826bea1a677b9c0255042728a Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Sat, 11 Oct 2025 00:58:19 -0400 Subject: [PATCH 1/5] Remove the unused message "statistics" (#6478) Its usage was removed from the file app/src/main/res/layout/fragment_achievements.xml in a8387f0, but the message remained in the strings file. Resolves #6456. --- app/src/main/res/values-qq/strings.xml | 1 - app/src/main/res/values/strings.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/app/src/main/res/values-qq/strings.xml b/app/src/main/res/values-qq/strings.xml index e1b7a0e1b..bc4869a83 100644 --- a/app/src/main/res/values-qq/strings.xml +++ b/app/src/main/res/values-qq/strings.xml @@ -374,7 +374,6 @@ Menu item. Menu item. Title on Profile page. - Seems to be unused. Title on Profile page. To see the correct translation for your language, please go to https://commons.wikimedia.org/wiki/Commons:Featured_pictures and select your language in \"This project page in other languages\". Item in statistics. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6cf6cef75..45519a370 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -384,7 +384,6 @@ Achievements Profile Badges - Statistics Thanks Received Featured Images Images via \"Nearby Places\" From 0a4b179db5253451d100ec32d0f3070676a00625 Mon Sep 17 00:00:00 2001 From: Jason-Whitmore Date: Fri, 10 Oct 2025 22:12:19 -0700 Subject: [PATCH 2/5] Fixes Issue 6436: getString(...) must not be null (#6474) * DatabaseUtils.kt: change getString() to allow null returns Before this change, a call to getString() would assume that the specified column name actually exists. A bad String input would cause a null value to be returned to getString(), which would then throw a NPE because getString() can only return non null Strings. This change expands the getString() method to check if the column name exists. If it does exist, the String is retrieved normally. Else, a null value is returned. The method signature is changed to allow null return values. * *Dao.kt: change some usages of getString() Before this change, the getString() method in DatabaseUtils.kt was changed to allow returning a null value upon method failure. All usages of getString() were not changed. This change updates all usages of getString() which require non null return values. If null is returned, an empty string is used instead. --------- Co-authored-by: Nicolas Raoul --- .../bookmarks/items/BookmarkItemsDao.kt | 14 ++++++++++++-- .../bookmarks/pictures/BookmarkPicturesDao.kt | 5 ++++- .../recentsearches/RecentSearchesDao.kt | 18 +++++++++++++----- .../fr/free/nrw/commons/utils/DatabaseUtils.kt | 15 +++++++++++++-- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/bookmarks/items/BookmarkItemsDao.kt b/app/src/main/java/fr/free/nrw/commons/bookmarks/items/BookmarkItemsDao.kt index d64ab16b3..bfb3ec764 100644 --- a/app/src/main/java/fr/free/nrw/commons/bookmarks/items/BookmarkItemsDao.kt +++ b/app/src/main/java/fr/free/nrw/commons/bookmarks/items/BookmarkItemsDao.kt @@ -144,8 +144,18 @@ class BookmarkItemsDao @Inject constructor( */ @SuppressLint("Range") fun fromCursor(cursor: Cursor) = with(cursor) { + var name = getString(COLUMN_NAME) + if (name == null) { + name = "" + } + + var id = getString(COLUMN_ID) + if (id == null) { + id = "" + } + DepictedItem( - getString(COLUMN_NAME), + name, getString(COLUMN_DESCRIPTION), getString(COLUMN_IMAGE), getStringArray(COLUMN_INSTANCE_LIST), @@ -155,7 +165,7 @@ class BookmarkItemsDao @Inject constructor( getStringArray(COLUMN_CATEGORIES_THUMBNAIL_LIST) ), getString(COLUMN_IS_SELECTED).toBoolean(), - getString(COLUMN_ID) + id ) } diff --git a/app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesDao.kt b/app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesDao.kt index e30b3160d..00c8e3228 100644 --- a/app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesDao.kt +++ b/app/src/main/java/fr/free/nrw/commons/bookmarks/pictures/BookmarkPicturesDao.kt @@ -128,7 +128,10 @@ class BookmarkPicturesDao @Inject constructor( } fun fromCursor(cursor: Cursor): Bookmark { - val fileName = cursor.getString(COLUMN_MEDIA_NAME) + var fileName = cursor.getString(COLUMN_MEDIA_NAME) + if (fileName == null) { + fileName = "" + } return Bookmark( fileName, cursor.getString(COLUMN_CREATOR), uriForName(fileName) ) diff --git a/app/src/main/java/fr/free/nrw/commons/explore/recentsearches/RecentSearchesDao.kt b/app/src/main/java/fr/free/nrw/commons/explore/recentsearches/RecentSearchesDao.kt index e1d0740de..d16d250dd 100644 --- a/app/src/main/java/fr/free/nrw/commons/explore/recentsearches/RecentSearchesDao.kt +++ b/app/src/main/java/fr/free/nrw/commons/explore/recentsearches/RecentSearchesDao.kt @@ -163,11 +163,19 @@ class RecentSearchesDao @Inject constructor( * @param cursor * @return RecentSearch object */ - fun fromCursor(cursor: Cursor): RecentSearch = RecentSearch( - uriForId(cursor.getInt(COLUMN_ID)), - cursor.getString(COLUMN_NAME), - Date(cursor.getLong(COLUMN_LAST_USED)) - ) + fun fromCursor(cursor: Cursor): RecentSearch { + var query = cursor.getString(COLUMN_NAME) + + if (query == null) { + query = "" + } + + return RecentSearch( + uriForId(cursor.getInt(COLUMN_ID)), + query, + Date(cursor.getLong(COLUMN_LAST_USED)) + ) + } /** * This class contains the database table architechture for recent searches, diff --git a/app/src/main/java/fr/free/nrw/commons/utils/DatabaseUtils.kt b/app/src/main/java/fr/free/nrw/commons/utils/DatabaseUtils.kt index 1fd99bcee..737f34614 100644 --- a/app/src/main/java/fr/free/nrw/commons/utils/DatabaseUtils.kt +++ b/app/src/main/java/fr/free/nrw/commons/utils/DatabaseUtils.kt @@ -6,9 +6,20 @@ import android.database.Cursor fun Cursor.getStringArray(name: String): List = stringToArray(getString(name)) +/** + * Gets the String at the current row and specified column. + * + * @param name The name of the column to get the String from. + * @return The String if the column exists. Else, null is returned. + */ @SuppressLint("Range") -fun Cursor.getString(name: String): String = - getString(getColumnIndex(name)) +fun Cursor.getString(name: String): String? { + val index = getColumnIndex(name) + if (index == -1) { + return null + } + return getString(index) +} @SuppressLint("Range") fun Cursor.getInt(name: String): Int = From adb6181e9f4a0d44130e75c8f5cbeda124e56d07 Mon Sep 17 00:00:00 2001 From: VoidRaven Date: Sat, 11 Oct 2025 11:08:07 +0530 Subject: [PATCH 3/5] fix: map crash (fixes #6432) (#6479) * fix: map crash (fixes #6432) * Fix typos in comments in ExploreMapFragment.kt --------- Co-authored-by: Nicolas Raoul --- .../nrw/commons/explore/map/ExploreMapFragment.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapFragment.kt b/app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapFragment.kt index 82ec6a540..0fc95dd17 100644 --- a/app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapFragment.kt +++ b/app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapFragment.kt @@ -963,13 +963,17 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi if (geoPoint != null) { binding!!.mapView.controller.setCenter(geoPoint) val overlays = binding!!.mapView.overlays + // collects the indices of items to remove + val indicesToRemove = mutableListOf() for (i in overlays.indices) { - if (overlays[i] is Marker) { - binding!!.mapView.overlays.removeAt(i) - } else if (overlays[i] is ScaleDiskOverlay) { - binding!!.mapView.overlays.removeAt(i) + if (overlays[i] is Marker || overlays[i] is ScaleDiskOverlay) { + indicesToRemove.add(i) } } + // removes the items in reverse order to avoid index shifting + indicesToRemove.sortedDescending().forEach { index -> + binding!!.mapView.overlays.removeAt(index) + } val diskOverlay = ScaleDiskOverlay( requireContext(), geoPoint, 2000, GeoConstants.UnitOfMeasure.foot @@ -979,7 +983,6 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi this.style = Paint.Style.STROKE this.strokeWidth = 2f }) - setCirclePaint1(Paint().apply { setColor(Color.argb(40, 128, 128, 128)) this.style = Paint.Style.FILL_AND_STROKE @@ -988,7 +991,6 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi setDisplaySizeMax(1700) } binding!!.mapView.overlays.add(diskOverlay) - val startMarker = Marker( binding!!.mapView ).apply { From dd1814c7933fbbb3a09334407be8c7a475d07540 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Sat, 11 Oct 2025 01:53:57 -0400 Subject: [PATCH 4/5] Change filename to username in toasts about sending thanks (#6467) This fixes #6466. Also fix the messages themselves a bit: * Removed "successfully" from the success message. This word is usually redundant, because the message already says that it was done. (In MediaWiki, there's a specific convention about it: https://www.mediawiki.org/wiki/Help:System_message#Avoid_jargon_and_slanghttps://www.mediawiki.org/wiki/Help:System_message#Avoid_jargon_and_slang ) * Added a missing preposition to the failure message. Co-authored-by: Nicolas Raoul --- .../java/fr/free/nrw/commons/media/MediaDetailFragment.kt | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt index dc1e86137..41e65ae4e 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt @@ -1027,12 +1027,12 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C val message: String = if (result) { context.getString( R.string.send_thank_success_message, - media!!.displayTitle + media!!.user ) } else { context.getString( R.string.send_thank_failure_message, - media!!.displayTitle + media!!.user ) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 45519a370..084e33b88 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -493,8 +493,8 @@ Upload your first media by tapping on the add button. Requesting category check for %1$s Done Sending Thanks: Success - Successfully sent thanks to %1$s - Failed to send thanks %1$s + Sent thanks to %1$s + Failed to send thanks to %1$s Sending Thanks: Failure Sending Thanks for %1$s From b8d340fbe8472c9d4bd75d4ff95f257312abdb23 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Sat, 11 Oct 2025 01:54:40 -0400 Subject: [PATCH 5/5] Rephrase the string copy_image_caption_description (#6472) I was going over all the strings and documenting them (see #6457), and I had a very hard time understand what this message does. I read the code and finally figured it out. I added qq documentation for it so now it's clearer, but I also think that the English message can be clearer: * "subsequent" changed to "the next" - shorter, easier word. * "media" changed to "item" - "media" could mean a lot of things, and "item" is clearer in this context. --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 084e33b88..0c0ae3a14 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -532,7 +532,7 @@ Upload your first media by tapping on the add button. Featured pictures are images from highly skilled photographers and illustrators that the Wikimedia Commons community has chosen as some of the highest quality on the site. Images Uploaded via Nearby places are the images which are uploaded by discovering places on the map. This feature allows editors to send a Thank you notification to users who make useful edits – by using a small thank link on the history page or diff page. - Copy to subsequent media + Copy to the next items Copied Examples of good images to upload to Commons Examples of images not to upload