forked from commons-app/apps-android-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Show where file is being used on Commons & Other wikis (comm…
…ons-app#6006) * add url to build config Signed-off-by: parneet-guraya <[email protected]> * add network call functions Signed-off-by: parneet-guraya <[email protected]> * return response asynchronously Signed-off-by: parneet-guraya <[email protected]> * inject page size in the request Signed-off-by: parneet-guraya <[email protected]> * rename from Commons..Response.kt to ..Response.kt Signed-off-by: parneet-guraya <[email protected]> * convert to .kt Signed-off-by: parneet-guraya <[email protected]> * ui setup working Signed-off-by: parneet-guraya <[email protected]> * fix merge conflict Signed-off-by: parneet-guraya <[email protected]> * cleanup Signed-off-by: parneet-guraya <[email protected]> * fix CI Signed-off-by: parneet-guraya <[email protected]> * use suspend function for network calls Signed-off-by: parneet-guraya <[email protected]> * doc * doc * doc * doc * doc --------- Signed-off-by: parneet-guraya <[email protected]> Co-authored-by: Nicolas Raoul <[email protected]>
- Loading branch information
1 parent
04a07ed
commit 85d9aef
Showing
13 changed files
with
2,587 additions
and
1,499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/src/main/java/fr/free/nrw/commons/fileusages/FileUsagesResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package fr.free.nrw.commons.fileusages | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
/** | ||
* Show where file is being used on Commons and oher wikis. | ||
*/ | ||
data class FileUsagesResponse( | ||
@SerializedName("continue") val continueResponse: CommonsContinue?, | ||
@SerializedName("batchcomplete") val batchComplete: Boolean, | ||
@SerializedName("query") val query: Query, | ||
) | ||
|
||
data class CommonsContinue( | ||
@SerializedName("fucontinue") val fuContinue: String, | ||
@SerializedName("continue") val continueKey: String | ||
) | ||
|
||
data class Query( | ||
@SerializedName("pages") val pages: List<Page> | ||
) | ||
|
||
data class Page( | ||
@SerializedName("pageid") val pageId: Int, | ||
@SerializedName("ns") val nameSpace: Int, | ||
@SerializedName("title") val title: String, | ||
@SerializedName("fileusage") val fileUsage: List<FileUsage> | ||
) | ||
|
||
data class FileUsage( | ||
@SerializedName("pageid") val pageId: Int, | ||
@SerializedName("ns") val nameSpace: Int, | ||
@SerializedName("title") val title: String, | ||
@SerializedName("redirect") val redirect: Boolean | ||
) |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/fr/free/nrw/commons/fileusages/FileUsagesUiModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package fr.free.nrw.commons.fileusages | ||
|
||
/** | ||
* Show where file is being used on Commons and oher wikis. | ||
*/ | ||
data class FileUsagesUiModel( | ||
val title: String, | ||
val link: String? | ||
) | ||
|
||
fun FileUsage.toUiModel(): FileUsagesUiModel { | ||
return FileUsagesUiModel(title = title, link = "https://commons.wikimedia.org/wiki/$title") | ||
} | ||
|
||
fun GlobalFileUsage.toUiModel(): FileUsagesUiModel { | ||
// link is associated with sub items under wiki group (which is not used ATM) | ||
return FileUsagesUiModel(title = wiki, link = null) | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/fr/free/nrw/commons/fileusages/GlobalFileUsagesResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package fr.free.nrw.commons.fileusages | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
/** | ||
* Show where file is being used on Commons and oher wikis. | ||
*/ | ||
data class GlobalFileUsagesResponse( | ||
@SerializedName("continue") val continueResponse: GlobalContinue?, | ||
@SerializedName("batchcomplete") val batchComplete: Boolean, | ||
@SerializedName("query") val query: GlobalQuery, | ||
) | ||
|
||
data class GlobalContinue( | ||
@SerializedName("gucontinue") val guContinue: String, | ||
@SerializedName("continue") val continueKey: String | ||
) | ||
|
||
data class GlobalQuery( | ||
@SerializedName("pages") val pages: List<GlobalPage> | ||
) | ||
|
||
data class GlobalPage( | ||
@SerializedName("pageid") val pageId: Int, | ||
@SerializedName("ns") val nameSpace: Int, | ||
@SerializedName("title") val title: String, | ||
@SerializedName("globalusage") val fileUsage: List<GlobalFileUsage> | ||
) | ||
|
||
data class GlobalFileUsage( | ||
@SerializedName("title") val title: String, | ||
@SerializedName("wiki") val wiki: String, | ||
@SerializedName("url") val url: String | ||
) |
Oops, something went wrong.