mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Explore nearby pictures (#4910)
* Add map fragment for explore and search * Create structure of explore map by defining view and user action interfaces to presenter * Add methods to map start, bottom sheet and permission * Make the simple map visible * Imitate methods from nearby map for permission needed and non needed map initialisation operations, however, needs to be tested and reactor * a level of abstraction * update media params to include coordinates * Implement pageable presenter to explore * Create Root fragment for map and media * Iplement two presenter one for map operations, the other for pageable operations * Construct general structure for both explore with search query and just by location * fix injection issue * Make default explore work with zoom level * increase offscreen page limit with newly added fragment * Make two distinct api calls for search with and without query * Before trying to use same presenter for both search with and without query * Add notes for Madhur * Add Madhur's fixes for binding * Call serch with and without query from the same spot * partially solve zoom issue * Make tab view unswipble while map is being used on search activity * make viewpager unswipable while map is being used * Code cleanup and reverting unnecessry edits * Add search this area methods * Implement search this area button functionality * Fix search this area button, current location FAB and bottom attribution UI elements * Add marker click action * Solve bookmarkdao injection issue * Make display bottom sheet details on marker click * remove label and set bottom sheet behavior * Remove irrelevan buttons like wikidata and article buttons * Cancel bookmark feature for commons images for know, needs to be thought * Add search this area button * Add location off dialog * Implement back button for explore map fragment while not on search activity * Make thumbnails visible, they need some styling though * Make gridle views even more beautiful * Remove classes added to support query * Remove query related code from Reach Activity * Solve two progressbar issue * Remove query related ekstra codes * Remove not needed anymore callback * Make medai details work * Remove all old removed code dependencies * Solve initial load takes too long issue * Solve current position track * Add placeholder for possible load issues * Add red stroke to bitmap * Add borders to rectangles * Change media details text to details * Fix file name extension anf File: prefix * Fix some code style issues * Fix some style issues * Fix style issues * Fix build issue * Fix test about etMediaListFromSearch * Fix test issue with Seacrh Activity * Fix conflict mark
This commit is contained in:
parent
7655562272
commit
ee1bf4b5b6
28 changed files with 2172 additions and 59 deletions
|
|
@ -15,6 +15,8 @@ import javax.inject.Singleton
|
|||
|
||||
const val PAGE_ID_PREFIX = "M"
|
||||
const val CATEGORY_CONTINUATION_PREFIX = "category_"
|
||||
const val LIMIT = 30
|
||||
const val RADIUS = 10000
|
||||
|
||||
/**
|
||||
* Media Client to handle custom calls to Commons MediaWiki APIs
|
||||
|
|
@ -90,6 +92,16 @@ class MediaClient @Inject constructor(
|
|||
fun getMediaListFromSearch(keyword: String?, limit: Int, offset: Int) =
|
||||
responseMapper(mediaInterface.getMediaListFromSearch(keyword, limit, offset))
|
||||
|
||||
/**
|
||||
* This method takes coordinate as input and returns a list of Media objects.
|
||||
* It uses the generator query API to get the images searched using a query.
|
||||
*
|
||||
* @param coordinate coordinate
|
||||
* @return
|
||||
*/
|
||||
fun getMediaListFromGeoSearch(coordinate: String?) =
|
||||
responseMapper(mediaInterface.getMediaListFromGeoSearch(coordinate, LIMIT, RADIUS))
|
||||
|
||||
/**
|
||||
* @return list of images for a particular depict entity
|
||||
*/
|
||||
|
|
@ -179,9 +191,9 @@ class MediaClient @Inject constructor(
|
|||
}
|
||||
|
||||
private fun mediaFromPageAndEntity(pages: List<MwQueryPage>): Single<List<Media>> {
|
||||
return if (pages.isEmpty())
|
||||
return if (pages.isEmpty()) {
|
||||
Single.just(emptyList())
|
||||
else
|
||||
} else {
|
||||
getEntities(pages.map { "$PAGE_ID_PREFIX${it.pageId()}" })
|
||||
.map {
|
||||
pages.zip(it.entities().values)
|
||||
|
|
@ -191,5 +203,7 @@ class MediaClient @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import retrofit2.http.QueryMap;
|
|||
* Interface for interacting with Commons media related APIs
|
||||
*/
|
||||
public interface MediaInterface {
|
||||
String MEDIA_PARAMS="&prop=imageinfo&iiprop=url|extmetadata|user&&iiurlwidth=640" +
|
||||
String MEDIA_PARAMS="&prop=imageinfo|coordinates&iiprop=url|extmetadata|user&&iiurlwidth=640" +
|
||||
"&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal" +
|
||||
"|Artist|LicenseShortName|LicenseUrl";
|
||||
|
||||
|
|
@ -78,7 +78,20 @@ public interface MediaInterface {
|
|||
@GET("w/api.php?action=query&format=json&formatversion=2" + //Basic parameters
|
||||
"&generator=search&gsrwhat=text&gsrnamespace=6" + //Search parameters
|
||||
MEDIA_PARAMS)
|
||||
Single<MwQueryResponse> getMediaListFromSearch(@Query("gsrsearch") String keyword, @Query("gsrlimit") int itemLimit, @Query("gsroffset") int offset);
|
||||
Single<MwQueryResponse> getMediaListFromSearch(@Query("gsrsearch") String keyword,
|
||||
@Query("gsrlimit") int itemLimit, @Query("gsroffset") int offset);
|
||||
|
||||
/**
|
||||
* This method retrieves a list of Media objects filtered using list geosearch query. Example: https://commons.wikimedia.org/w/api.php?action=query&format=json&formatversion=2&generator=geosearch&ggsnamespace=6&prop=imageinfo|coordinates&iiprop=url|extmetadata|user&&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl&ggscoord=37.45579%7C-122.31369&ggslimit=30&ggsradius=10000
|
||||
*
|
||||
* @param location the search location
|
||||
* @param itemLimit how many images are returned
|
||||
* @return
|
||||
*/
|
||||
@GET("w/api.php?action=query&format=json&formatversion=2" + //Basic parameters
|
||||
"&generator=geosearch&ggsnamespace=6" + //Search parameters
|
||||
MEDIA_PARAMS)
|
||||
Single<MwQueryResponse> getMediaListFromGeoSearch(@Query("ggscoord") String location, @Query("ggslimit") int itemLimit, @Query("ggsradius") int radius);
|
||||
|
||||
/**
|
||||
* Fetches Media object from the imageInfo API
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue