apps-android-commons/data-client
Madhur Gupta baee56e392
[GSoC] Added Click to open user profile for leaderboard (#3887)
* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* #3749 Improve MediaClient UnitTests  (#3846)

* #3468 Switch from RvRenderer to AdapterDelegates - replace SearchDepictionsRenderer

* #3468 Switch from RvRenderer to AdapterDelegates - replace UploadCategoryDepictionsRenderer

* #3468 Switch from RvRenderer to AdapterDelegates - update BaseAdapter to be easier to use

* #3468 Switch from RvRenderer to AdapterDelegates - replace SearchImagesRenderer

* #3468 Switch from RvRenderer to AdapterDelegates - replace SearchCategoriesRenderer

* #3468 Switch from RvRenderer to AdapterDelegates - replace NotificationRenderer

* #3468 Switch from RvRenderer to AdapterDelegates - replace UploadDepictsRenderer

* #3468 Switch from RvRenderer to AdapterDelegates - replace PlaceRenderer

* #3756 Convert SearchDepictionsFragment to use Pagination - convert SearchDepictionsFragment

* #3756 Convert SearchDepictionsFragment to use Pagination - fix presenter unit tests now that view is not nullable - fix Category prefix imports

* #3756 Convert SearchDepictionsFragment to use Pagination - test DataSource related classes

* #3756 Convert SearchDepictionsFragment to use Pagination - reset rx scheduler - ignore failing test

* #3760 Convert SearchCategoriesFragment to use Pagination - extract functionality of pagination to base classes - add category pagination

* #3772 Convert SearchImagesFragment to use Pagination  - convert SearchImagesFragment - tidy up showing the empty view - make search fragments show snackbar with appropriate text

* #3772 Convert SearchImagesFragment to use Pagination  - allow viewpager to load more data

* #3760 remove test that got re-added by merge

* #3760 remove duplicate dependency

* #3772 fix compilation

* #3780 Create media using a combination of Entities & MwQueryResult - construct media with an entity - move fields from media down to contribution - move dynamic fields outside of media - remove unused constructors - remove all unnecessary fetching of captions/descriptions - bump database version

* #3808 Construct media objects that depict an item id correctly - use generator to construct media for DepictedImages

* #3810 Convert DepictedImagesFragment to use Pagination - extract common media paging methods - convert to DepictedImages to use pagination

* #3810 Convert DepictedImagesFragment to use Pagination - rename base classes to better reflect usage

* #3810 Convert DepictedImagesFragment to use Pagination - map to empty result with no pages

* #3810 Convert DepictedImagesFragment to use Pagination - align test with returned values

* #3780 Create media using a combination of Entities & MwQueryResult - update wikicode to align with expected behaviour

* #3780 Create media using a combination of Entities & MwQueryResult - replace old site of thumbnail title with most relevant caption

* #3818 Convert SubDepictionListFragment to use Pagination - replace SubDepictionList with Child and Parent Fragments - replace contracts with simple presenter declarations - move classes to appropriate packages - delete unused network models - delete duplicated paging classes

* #3820 Convert CategoryImagesListFragment to use Pagination - replace CategoryImagesListFragment with CategoriesMediaFragment - disallow the construction of media objects without imageinfo

* #3822 Convert SubCategoryImagesListFragment to use Pagination - convert subcategories - add continuation support in category client - rely on interfaces for callbacks of PageableMediaFragments

* #3822 Convert SubCategoryImagesListFragment to use Pagination - convert parent categories - delete list fragment - creat base class to support continuation requests in clients

* #3822 Convert SubCategoryImagesListFragment to use Pagination - add tests for ParentCategoriesDataSource

* #3822 Convert SubCategoryImagesListFragment to use Pagination - remove no longer applicable test

* #3749 Improve MediaClient UnitTests - test rewrite

* #3749 Improve MediaClient UnitTests - align with buildConfig property

* With pause and resume for uploads (#3858)

* With pause and resume for uploads

* Dispose current upload

* Make pause and resume work

* Check stash validity

* With java docs

* minor

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Add nearby presenter unit tests  (#3615)

* init the test file

* Add tests to check if searchthisarea button action and checkbox actions are added after initialize test

* Add tests to locked unlocked nearby cases

* Add tests for null cases in updateMapAndList method

* Add test to check which locations are used to populate places, depending to LocationChangeType

* Add tests to test users position is not followed if blue dot (current location marker) is not visible

* Add tests to decide search this area method visibility on camera move

* Add tests for multi filteirng of placetypes

* add tests for single place type selection too

* Add tests to tests search view focus gain and bottom sheet visibilities

* Add tests for SearchCloseToCurrentLocation

* Remove two unneeded getter and setter for isNearbyLocked, use @VisibleForTesting annotation instead

* Add VisibleForTesting annotation to initializeNearbyOperations method so that it will be private by default

* Add missing tests

* Add tests for map updated case and add missing lines those are being tested

* Add some missind method verifications

* Create real latlang objects isntead of spying them

* Use a real presenter object instead of a spy

* Revert nonneeded @VisibleForTest annotations, instead reach via lockUnlock method

* Reduce code repetitions

* Do not call a test from another test method

* Add some more tests

* Fix minor issues

* Hidden categories are not showed in suggested categories (#3853)

* Localisation updates from https://translatewiki.net.

* Clarify that the caption would also be used as the image title (#3876)

The app uses the fist caption as the file title. This should also
be communicated to the user via the info box as they would not be
aware of it otherwise.

* Localisation updates from https://translatewiki.net.

* Added Click event for leaderboard, Fixed #3886

* Fixed Travis

Co-authored-by: translatewiki.net <l10n-bot@translatewiki.net>
Co-authored-by: Seán Mac Gillicuddy <seantheappdev@gmail.com>
Co-authored-by: Vivek Maskara <maskaravivek@gmail.com>
Co-authored-by: neslihanturan <tur.neslihan@gmail.com>
Co-authored-by: Paulina <63326136+PaulinaQuintero@users.noreply.github.com>
Co-authored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
2020-08-09 23:59:54 +09:00
..
gradle/wrapper With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
scripts With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
src [GSoC] Added Click to open user profile for leaderboard (#3887) 2020-08-09 23:59:54 +09:00
.gitignore With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
.travis.yml With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
build.gradle #3676 Update Gradle Plugin - bump version (#3677) 2020-04-20 13:39:04 +03:00
gradle.properties With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
gradlew With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
gradlew.bat With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
LICENSE With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
proguard-rules.pro With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00
README.md With data-client added as library module (#3656) 2020-04-15 11:00:13 +01:00

Wikimedia Android data client

An Android library for communicating with Wikimedia projects, with Rx bindings and other utilities.

Motivation and philosophy

Here are the purposes for creating this library:

  • Encapsulate the various model structures that are returned by MediaWiki APIs, as well as by REST APIs provided by Wikimedia services.

  • Provide high-level bindings for Retrofit and RxJava for executing calls to MediaWiki APIs to further simplify client integration, while also allowing customization and extension.

  • Provide numerous common utility methods, so that they don't need to be duplicated.

Integration with your app

Add the dependency to your Gradle file as usual:

implementation "com.dmitrybrant:wikimedia-android-data-client:0.0.18"

The only nontrivial point of integration with the library is the AppAdapter class: You need to create a class that inherits from AppAdapter and implement its methods. The methods are mostly self-explanatory, and deal with user account management, cookie storage, and a few other customizations.

Once you create this class (suppose it's called MyAppAdapter), you should pass it into the AppAdapter singleton when your app starts:

@Override
public void onCreate() {
    ...
    AppAdapter.set(new MyAppAdapter());
    ...
}

Making calls to APIs

Notice that there is an interface called Service that contains a number of API definitions for talking with a MediaWiki server. To use any of the functions in the interface, you should use the ServiceFactory class. For example:

WikiSite wiki = new WikiSite("en.wikipedia.org");

Observable observable = ServiceFactory.get(wiki).fullTextSearch("foo");

That's it! Notice that most of the API calls return an Observable response which you can feed into an Rx subscription.

Note: the ServiceFactory class contains automatic caching logic, so that multiple calls to get() the service for the same WikiSite will be very efficient.

Custom API calls

The ServiceFactory class also allows you to provide a service interface with custom API functions. Suppose you create your own service interface that looks like this:

public interface MyInterface {

    @GET("action=myawesomeaction")
    Observable<MyAwesomeResponse> myAwesomeApiCall(@Query("parameter1") parameter);

}

You can then use it with ServiceFactory this way:

WikiSite wiki = new WikiSite("my.awesome.wiki");

Observable observable = ServiceFactory.get(wiki, "https://my.awesome.wiki/", MyInterface.class)
        .myAwesomeApiCall("foo");

Utility methods

The library contains a potpourri of utility methods found under the util package. Feel free to browse through them and use them as necessary.

License

Copyright 2019 Wikimedia Foundation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.