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 bfb3ec764..d64ab16b3 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,18 +144,8 @@ 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( - name, + getString(COLUMN_NAME), getString(COLUMN_DESCRIPTION), getString(COLUMN_IMAGE), getStringArray(COLUMN_INSTANCE_LIST), @@ -165,7 +155,7 @@ class BookmarkItemsDao @Inject constructor( getStringArray(COLUMN_CATEGORIES_THUMBNAIL_LIST) ), getString(COLUMN_IS_SELECTED).toBoolean(), - id + getString(COLUMN_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 00c8e3228..e30b3160d 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,10 +128,7 @@ class BookmarkPicturesDao @Inject constructor( } fun fromCursor(cursor: Cursor): Bookmark { - var fileName = cursor.getString(COLUMN_MEDIA_NAME) - if (fileName == null) { - fileName = "" - } + val fileName = cursor.getString(COLUMN_MEDIA_NAME) return Bookmark( fileName, cursor.getString(COLUMN_CREATOR), uriForName(fileName) ) 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 0fc95dd17..82ec6a540 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,17 +963,13 @@ 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 || overlays[i] is ScaleDiskOverlay) { - indicesToRemove.add(i) + if (overlays[i] is Marker) { + binding!!.mapView.overlays.removeAt(i) + } else if (overlays[i] is ScaleDiskOverlay) { + binding!!.mapView.overlays.removeAt(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 @@ -983,6 +979,7 @@ 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 @@ -991,6 +988,7 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi setDisplaySizeMax(1700) } binding!!.mapView.overlays.add(diskOverlay) + val startMarker = Marker( binding!!.mapView ).apply { 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 d16d250dd..e1d0740de 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,19 +163,11 @@ class RecentSearchesDao @Inject constructor( * @param cursor * @return RecentSearch object */ - 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)) - ) - } + fun fromCursor(cursor: Cursor): RecentSearch = RecentSearch( + uriForId(cursor.getInt(COLUMN_ID)), + cursor.getString(COLUMN_NAME), + 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/media/MediaDetailFragment.kt b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt index 41e65ae4e..dc1e86137 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!!.user + media!!.displayTitle ) } else { context.getString( R.string.send_thank_failure_message, - media!!.user + media!!.displayTitle ) } 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 737f34614..1fd99bcee 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,20 +6,9 @@ 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? { - val index = getColumnIndex(name) - if (index == -1) { - return null - } - return getString(index) -} +fun Cursor.getString(name: String): String = + getString(getColumnIndex(name)) @SuppressLint("Range") fun Cursor.getInt(name: String): Int = diff --git a/app/src/main/res/values-qq/strings.xml b/app/src/main/res/values-qq/strings.xml index bc4869a83..e1b7a0e1b 100644 --- a/app/src/main/res/values-qq/strings.xml +++ b/app/src/main/res/values-qq/strings.xml @@ -374,6 +374,7 @@ 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 0c0ae3a14..6cf6cef75 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -384,6 +384,7 @@ Achievements Profile Badges + Statistics Thanks Received Featured Images Images via \"Nearby Places\" @@ -493,8 +494,8 @@ Upload your first media by tapping on the add button. Requesting category check for %1$s Done Sending Thanks: Success - Sent thanks to %1$s - Failed to send thanks to %1$s + Successfully sent thanks to %1$s + Failed to send thanks %1$s Sending Thanks: Failure Sending Thanks for %1$s @@ -532,7 +533,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 the next items + Copy to subsequent media Copied Examples of good images to upload to Commons Examples of images not to upload