Skip to content

Commit 49b8a59

Browse files
dbrantcoolteysharvaniharanSharvani Haran
authored
Patroller Tasks (feature branch) (#4124)
* Beginnings of Patroller task. * Patroller Tasks: main "List of edits" screen (#4153) * Initial commit * Update viewModel and some preferences * Add activity and waiting for the strings to be merged and updated * Fix lint * Update viewmodel with pagingsource * Fix errors * Set launchers * Fix error * Add suppress * Add menu item clicks * Add tags in list item * Fix references * Enchanced search functions * Update filter group * Fix error * Add comment for filter implementation * Use materialToolbar and use a proper icon * Fix lint * Replace the flag resource content * Show user popup menu in the patroller tasks recent edits (#4160) * Show user popup menu in the patroller tasks recent edits * Set up dialog layout * Set up dialog fragment and build viewModel for the dialog * Add DateDiff function for the user information * Update string format * Update button visibility * Update dialog wording and simplified the display * Remove unused strings * Update padding and text * Patroller Tasks: Filters screen for List of Edits (#4176) * Initial commit * Update viewModel and some preferences * Add activity and waiting for the strings to be merged and updated * Fix lint * Update viewmodel with pagingsource * Fix errors * Set launchers * Fix error * Add suppress * Add menu item clicks * Add tags in list item * Fix references * Enchanced search functions * Update filter group * Fix error * Add comment for filter implementation * Use materialToolbar and use a proper icon * Fix lint * Replace the flag resource content * Initial commit * Update item view and fix error * Rename resource name * Update filter layout * Update filter type * Adjust item layout padding and add checkbox logic back * Update filter * Update menu reset button visibility logic * Update reset button code * Add oresscore parameter to API call * Fix lint * Initial logic of filtering oresscores * Fix launcher issue * Fix lint * Remove cache logic * Filtering empty oresscore * Initial spike of userinfo * Add user experiences filter * Update user information API * Solified user experiences with user registration filter * Remove comment * Reduce redundant value * Add cached logic for user info * Simplified code * Use updated method * Fix lint * Diff screen for Patroller Tasks. (#4209) * Right. Change-Id: I8577053379ec5844f179501ea85fd6b711315a95 * Update for current fragment structure. Change-Id: Ia75b14b58123052cb6ac4bd101e887bca5ffdadf * Update to latest state. Change-Id: Idcea886de2bb869fe56916b521fbaf579ec2fe5f * Switch to using plain recentedits API. Change-Id: I41703258c375d1e48e2dd327f881cff5d24a7f2e * Remove feature flag. Change-Id: I3875a7f6f3352e20babd4abf57c9aa843d6f4bb6 * Finish proper merge. Change-Id: I04e0d4bf7e50c2e16e91fb0911924da2ad3a623d * Update. Change-Id: I50c720d06fbff0196135e36e183d05d984980460 * Tighten up design. Change-Id: I5461c0d55a307cffb39a7462d731e111dfed8e48 * Adapt to latest. * Actually do it. * Improve consistency of results. * Reset cache if language has changed. * Add service calls. * Refactor with ViewModel. * Refactor diff logic. * Use refactored diff logic. * Dial in a few more parameters. * Add overflow options. * Adapt. * Adapt. * Tweak. * Use proper icons and text for suggested edits task. * Begin adapting to current requirements. * Introduce bottom bar. * Transition undo button. * Integrate ores scores from revisions. * Begin re-molding the diff screen. * Break out bespoke activity that holds a default diff fragment. * Further adapt. * Scroll correctly. * Tweak. * Fix diffs. * Rearrange logic a bit. * Tighten up. * Init on resume. * More in line with designs. * Wire it up! * Add reporting. * Adapt. * Correctly show user popup. * Update style of Undo dialog. * Fix qq error * Design comments * Use correct language code * switch the thank visibility --------- Co-authored-by: cooltey <[email protected]> * Patroller tasks: build the screen for managing the warn templates (#4126) * Adding required strings for the feature * Add database and dao * Add required stuffs, update db version and rename strings * Fix lint * Update AndroidManifest * Fix error * Add empty state illustration * Add menu item * Update item icon color * Add new warn template xml and update resource name * Rename ids * Adding "add" activity for warn template * Update resource and package names * Remove license disclaimer * Remove unused class * Update TextInputDialog * Complete add template logic * Add request launcher to menu item * Update list view of talk templates * Update swappable class * Update visibility settings * Fix lint * Update manifest, update db creation, and add temp access to templates * Update illustration for empty state * Update insert issue * Complete drag behaviors * Add an additional input field for editing template message * Update edit dialog * Update the update process * Add a Input dialog for talk templates only * Revert changes to basic text input dialog * Rename function names * Fix error * Rename resource and add deletion process * Update theme dialog button styles * Tweaks to dialog text styles * Update loading behavior to prevent reloading on device rotation * Update list item * A proper way of saving states of saving/deleting item * Optimize views * Add a new uistate for save and delete * Update colors * Design review update * Fix lint * Update with new wikitext keyboard * Update dialog launcher * Do not support wikitext keyboard in dialog This reverts commit 1a8773d. * Update invokeSource * Update edittext string * Update on correct position of list * Add dismiss listener and add proper cancel action on AddTemplateActivity * Update dialog text * Add more logic of checking input field * Fix lint * Replace Quality with Damage and remove the inverted percentage (#4236) * Create Onboarding for Patroller Tasks (#4208) * Create Onboarding for Patroller Tasks * Fix lint * Fix issues and show the onboarding correctly * Update preference and main screen tag * Add sequential tooltips * Add strings * Add numbers for tooltips * Add comment of possible issue * Fix multiple tags issue * Add data preference screen * Add send data onboarding * Fix lint * Add feedback dialog layouts * Add feedback dialog views * Add comment for next step * Quality to damage * Update the timing of showing feedback form * Add tooltips and feedback form * Refine display logic * Show feedback form after snackbar dismissed * Set as non-cancelable * Remove extra logic * Update historyEntry constants * Add Patroller Tasks related Rollback and Undo edit tags (#4242) * Some code optimization * Fix: empty message should only show if the filter count > 0 (#4244) * Update snackbar messages and make the Undo button enabled by default (#4243) * Patroller Tasks: update TalkReply activity to handle saved templates (#4239) * Patroller Tasks: update TalkReply activity to handle saved templates * Connect talk replay activity with diff screen * Add checkbox and radio * Add radio and checkbox logic * Add percentage suffix for damage and intent * Adding mutiple livedata * Add the logic of handling template dialog * Update message * Update warn button listener * Add spinner to reply interface * Add onclick event * integrate with dialog * Solify logic of managing dialogs * Remove comment * Optimize stuff * Update logic of managing template * Remove testing button * Minor design update * Minor layout visibility update * lint * Make the dialog scrollable * Replace radios to checkbox and optimze logic * design comment * Update input text error stauts * Update the error text * Patroller Tasks: show the bottom navigation bar after fully loaded * Fix dialog checkbox end margin * Fix: incorrect behavior after changing device orientation in Patrol edit (#4247) * Fix: only inflate menu once in the ArticleeditDetailsFramgent * Change .add to .replace to avoid adding multiple fragment * Only commit fragment if there has no instance * Adding Indonesian translations for Patroller tasks feature (#4250) * Adding Indonesian translations for Patroller tasks feature * Complete translations --------- Co-authored-by: Sharvani Haran <[email protected]> * Fix: Patroller Tasks user experience update (#4252) * Fix: Patroller Tasks user experience update * Wording * Fix: Patroller Tasks input field error message (#4253) * Fix: get correct feedback input source for Patroller Tasks (#4254) * Data wiring: Patroller tasks (#4245) * Data wiring: Patroller tasks * Final wiring * Fix: Multiple streams usage (#4248) Co-authored-by: Sharvani Haran <[email protected]> * More event updates * Improvements to logging logic * Simplify wikiId by using preferences * Detect source for data events * CR comments addressed * Minor change * Lint fix and minor update * Minor change * Swipe event added --------- Co-authored-by: Sharvani Haran <[email protected]> * Follow-up: Patroller Tasks data wiring (#4256) * Data wiring for filter selection (#4255) * Data wiring: Patroller tasks * Final wiring * Fix: Multiple streams usage (#4248) Co-authored-by: Sharvani Haran <[email protected]> * More event updates * Improvements to logging logic * Simplify wikiId by using preferences * Detect source for data events * CR comments addressed * Minor change * Lint fix and minor update * Minor change * Swipe event added * Add data wiring to filter selection * Minor change --------- Co-authored-by: Sharvani Haran <[email protected]> * Re-used some `in` translations (#4257) Co-authored-by: Sharvani Haran <[email protected]> * Minor code change * Fix: set to default language code after updated in Patroller Tasks (#4258) filter --------- Co-authored-by: Cooltey Feng <[email protected]> Co-authored-by: cooltey <[email protected]> Co-authored-by: Sharvani Haran <[email protected]> Co-authored-by: Sharvani Haran <[email protected]>
1 parent 5b8d876 commit 49b8a59

File tree

103 files changed

+5559
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+5559
-346
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@
263263

264264
<activity android:name=".suggestededits.SuggestedEditsImageRecsOnboardingActivity" />
265265

266+
<activity android:name=".suggestededits.SuggestedEditsRecentEditsOnboardingActivity" />
267+
266268
<activity
267269
android:name=".watchlist.WatchlistActivity"
268270
android:label="@string/watchlist_title"
@@ -277,6 +279,14 @@
277279
android:name=".suggestededits.SuggestedEditsImageTagEditActivity"
278280
android:theme="@style/AppTheme.ActionBar" />
279281

282+
<activity
283+
android:name=".suggestededits.SuggestedEditsRecentEditsActivity"/>
284+
285+
<activity
286+
android:name=".suggestededits.SuggestedEditsRecentEditsFilterActivity"
287+
android:label="@string/patroller_tasks_filters_title"
288+
android:theme="@style/AppTheme.ActionBar"/>
289+
280290
<activity
281291
android:name=".commons.FilePageActivity"
282292
android:label=""
@@ -329,6 +339,14 @@
329339
android:label="@string/insert_media_title"
330340
android:configChanges="orientation|keyboardHidden|keyboard|screenSize" />
331341

342+
<activity
343+
android:name=".talk.template.TalkTemplatesActivity"
344+
android:theme="@style/AppTheme.ActionBar" />
345+
346+
<activity
347+
android:name=".talk.template.AddTemplateActivity"
348+
android:theme="@style/AppTheme" />
349+
332350
<provider
333351
android:name=".WikipediaFileProvider"
334352
android:authorities="${applicationId}.fileprovider"

app/src/main/java/org/wikipedia/Constants.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ object Constants {
9696
TALK_TOPICS_ACTIVITY("talkTopicsActivity"),
9797
TALK_TOPIC_ACTIVITY("talkTopicActivity"),
9898
TALK_REPLY_ACTIVITY("talkReplyActivity"),
99+
ADD_TEMPLATE_ACTIVITY("addTemplateActivity"),
99100
EDIT_ACTIVITY("editActivity"),
100101
TOOLBAR("toolbar"),
101102
VOICE("voice"),
@@ -104,6 +105,7 @@ object Constants {
104105
WIDGET("widget"),
105106
USER_CONTRIB_ACTIVITY("userContribActivity"),
106107
EDIT_ADD_IMAGE("editAddImage"),
108+
SUGGESTED_EDITS_RECENT_EDITS("suggestedEditsRecentEdits"),
107109
}
108110

109111
enum class ImageEditType(name: String) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.wikipedia.analytics.eventplatform
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Suppress("unused")
7+
@Serializable
8+
@SerialName("/analytics/mobile_apps/app_interaction/1.0.0")
9+
class AppInteractionEvent(
10+
private val action: String,
11+
private val active_interface: String,
12+
private val action_data: String,
13+
private val primary_language: String,
14+
private val wiki_id: String,
15+
private var platform: String,
16+
) : MobileAppsEvent(STREAM_NAME) {
17+
companion object {
18+
var STREAM_NAME = "app_donor_experience"
19+
}
20+
}

app/src/main/java/org/wikipedia/analytics/eventplatform/DonorExperienceEvent.kt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
package org.wikipedia.analytics.eventplatform
22

3-
import kotlinx.serialization.SerialName
4-
import kotlinx.serialization.Serializable
53
import org.wikipedia.WikipediaApp
64

7-
@Suppress("unused")
8-
@Serializable
9-
@SerialName("/analytics/mobile_apps/app_interaction/1.0.0")
10-
class DonorExperienceEvent(
11-
private val action: String,
12-
private val active_interface: String,
13-
private val action_data: String,
14-
private val primary_language: String,
15-
private val wiki_id: String,
16-
private var platform: String
17-
) : MobileAppsEvent(STREAM_NAME) {
5+
class DonorExperienceEvent {
186

197
companion object {
208
private const val STREAM_NAME = "app_donor_experience"
@@ -47,8 +35,9 @@ class DonorExperienceEvent(
4735
actionData: String,
4836
wikiId: String
4937
) {
38+
AppInteractionEvent.STREAM_NAME = STREAM_NAME
5039
EventPlatformClient.submit(
51-
DonorExperienceEvent(
40+
AppInteractionEvent(
5241
action,
5342
activeInterface,
5443
actionData,
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.wikipedia.analytics.eventplatform
2+
3+
import org.wikipedia.WikipediaApp
4+
import org.wikipedia.settings.Prefs
5+
6+
class PatrollerExperienceEvent {
7+
8+
companion object {
9+
private const val STREAM_NAME = "app_patroller_experience"
10+
11+
fun logImpression(activeInterface: String) {
12+
submitPatrollerActivityEvent("impression", activeInterface)
13+
}
14+
15+
fun logAction(action: String, activeInterface: String, actionData: String = "") {
16+
submitPatrollerActivityEvent(action, activeInterface, actionData)
17+
}
18+
19+
fun getActionDataString(
20+
revisionId: Long? = null,
21+
feedbackOption: String? = null,
22+
feedbackText: String? = null,
23+
messageType: String? = null,
24+
summaryText: String? = null,
25+
filterSelected: String? = null,
26+
filterWiki: String? = null,
27+
filtersList: String? = null,
28+
appLanguageCodeAdded: String? = null,
29+
appLanguageCodes: String? = null,
30+
): String {
31+
val revisionIdStr = revisionId?.let { "revision_id: $it, " }.orEmpty()
32+
val feedbackStr = feedbackOption?.let { "feedback: $it, " }.orEmpty()
33+
val feedbackTextStr = feedbackText?.let { "feedback_text: $it, " }.orEmpty()
34+
val savedMessageStr = messageType?.let { "saved_message: $it, " }.orEmpty()
35+
val summaryTextStr = summaryText?.let { "summary_text: $it, " }.orEmpty()
36+
val wasSummaryAddedStr = summaryText?.let { summaryText.isNotEmpty().toString() }.orEmpty()
37+
val filterSelectedStr = filterSelected?.let { "filter_selected: $it, " }.orEmpty()
38+
val filterWikiStr = filterWiki?.let { "filter_wiki_selected: $it, " }.orEmpty()
39+
val filtersListStr = filtersList?.let { "filters_list: $it, " }.orEmpty()
40+
val appLanguageCodeAddedStr = appLanguageCodeAdded?.let { "app_language_code_added: $it, " }.orEmpty()
41+
val appLanguageCodesStr = appLanguageCodes?.let { "app_language_codes: $it, " }.orEmpty()
42+
return revisionIdStr + feedbackStr + feedbackTextStr + savedMessageStr + summaryTextStr + wasSummaryAddedStr +
43+
filterSelectedStr + filterWikiStr + filtersListStr + appLanguageCodeAddedStr + appLanguageCodesStr
44+
}
45+
46+
private fun submitPatrollerActivityEvent(action: String, activeInterface: String, actionData: String = "") {
47+
AppInteractionEvent.STREAM_NAME = STREAM_NAME
48+
EventPlatformClient.submit(
49+
AppInteractionEvent(
50+
action,
51+
activeInterface,
52+
actionData,
53+
WikipediaApp.instance.languageState.appLanguageCode,
54+
Prefs.recentEditsWikiCode,
55+
"android"
56+
)
57+
)
58+
}
59+
}
60+
}

app/src/main/java/org/wikipedia/database/AppDatabase.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ import org.wikipedia.search.db.RecentSearchDao
2727
import org.wikipedia.staticdata.MainPageNameData
2828
import org.wikipedia.talk.db.TalkPageSeen
2929
import org.wikipedia.talk.db.TalkPageSeenDao
30+
import org.wikipedia.talk.db.TalkTemplate
31+
import org.wikipedia.talk.db.TalkTemplateDao
3032

3133
const val DATABASE_NAME = "wikipedia.db"
32-
const val DATABASE_VERSION = 24
34+
const val DATABASE_VERSION = 25
3335

3436
@Database(
3537
entities = [
@@ -41,7 +43,8 @@ const val DATABASE_VERSION = 24
4143
OfflineObject::class,
4244
ReadingList::class,
4345
ReadingListPage::class,
44-
Notification::class
46+
Notification::class,
47+
TalkTemplate::class
4548
],
4649
version = DATABASE_VERSION
4750
)
@@ -63,6 +66,7 @@ abstract class AppDatabase : RoomDatabase() {
6366
abstract fun readingListDao(): ReadingListDao
6467
abstract fun readingListPageDao(): ReadingListPageDao
6568
abstract fun notificationDao(): NotificationDao
69+
abstract fun talkTemplateDao(): TalkTemplateDao
6670

6771
companion object {
6872
val MIGRATION_19_20 = object : Migration(19, 20) {
@@ -170,10 +174,15 @@ abstract class AppDatabase : RoomDatabase() {
170174
database.execSQL("CREATE TABLE IF NOT EXISTS `Notification` (`id` INTEGER NOT NULL, `wiki` TEXT NOT NULL, `read` TEXT, `category` TEXT NOT NULL, `type` TEXT NOT NULL, `revid` INTEGER NOT NULL, `title` TEXT, `agent` TEXT, `timestamp` TEXT, `contents` TEXT, PRIMARY KEY(`id`, `wiki`))")
171175
}
172176
}
177+
private val MIGRATION_24_25 = object : Migration(24, 25) {
178+
override fun migrate(database: SupportSQLiteDatabase) {
179+
database.execSQL("CREATE TABLE IF NOT EXISTS `TalkTemplate` (`id` INTEGER NOT NULL, `type` INTEGER NOT NULL, `order` INTEGER NOT NULL, `title` TEXT NOT NULL, `subject` TEXT NOT NULL, `message` TEXT NOT NULL, PRIMARY KEY(`id`))")
180+
}
181+
}
173182

174183
val instance: AppDatabase by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
175184
Room.databaseBuilder(WikipediaApp.instance, AppDatabase::class.java, DATABASE_NAME)
176-
.addMigrations(MIGRATION_19_20, MIGRATION_20_21, MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24)
185+
.addMigrations(MIGRATION_19_20, MIGRATION_20_21, MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25)
177186
.allowMainThreadQueries() // TODO: remove after migration
178187
.fallbackToDestructiveMigration()
179188
.build()

app/src/main/java/org/wikipedia/dataclient/Service.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,13 @@ interface Service {
161161
val randomWithImageInfo: Observable<MwQueryResponse>
162162

163163
@Headers("Cache-Control: no-cache")
164-
@GET(MW_API_PREFIX + "action=query&list=recentchanges&rcprop=title|timestamp|ids|oresscores|sizes|tags|user|parsedcomment|comment|flags&rcnamespace=0&rctoponly=1&rctype=edit|new")
164+
@GET(MW_API_PREFIX + "action=query&list=recentchanges&rcprop=title|timestamp|ids|oresscores|sizes|tags|user|parsedcomment|comment|flags&rcnamespace=0&rctype=edit|new")
165165
suspend fun getRecentEdits(
166166
@Query("rclimit") count: Int,
167167
@Query("rcstart") startTimeStamp: String,
168-
@Query("rcshow") filters: String?
168+
@Query("rctoponly") latestRevisions: String?,
169+
@Query("rcshow") filters: String?,
170+
@Query("rccontinue") continueStr: String?
169171
): MwQueryResponse
170172

171173
@FormUrlEncoded
@@ -506,29 +508,36 @@ interface Service {
506508
@GET(MW_API_PREFIX + "action=query&prop=revisions&rvslots=main&rvprop=timestamp|user|ids|comment|tags")
507509
suspend fun getLastModified(@Query("titles") titles: String): MwQueryResponse
508510

509-
@GET(MW_API_PREFIX + "action=query&prop=info|revisions&rvslots=main&rvprop=ids|timestamp|size|flags|comment|parsedcomment|user&rvdir=newer")
511+
@GET(MW_API_PREFIX + "action=query&prop=info|revisions&rvslots=main&rvprop=ids|timestamp|size|flags|comment|parsedcomment|user|oresscores&rvdir=newer")
510512
suspend fun getRevisionDetailsAscending(
511513
@Query("titles") titles: String?,
512514
@Query("pageids") pageIds: String?,
513515
@Query("rvlimit") count: Int,
514516
@Query("rvstartid") revisionStartId: Long?
515517
): MwQueryResponse
516518

517-
@GET(MW_API_PREFIX + "action=query&prop=info|revisions&rvslots=main&rvprop=ids|timestamp|size|flags|comment|parsedcomment|user&rvdir=older")
519+
@GET(MW_API_PREFIX + "action=query&prop=info|revisions&rvslots=main&rvprop=ids|timestamp|size|flags|comment|parsedcomment|user|oresscores&rvdir=older")
518520
suspend fun getRevisionDetailsDescending(
519521
@Query("titles") titles: String,
520522
@Query("rvlimit") count: Int,
521523
@Query("rvstartid") revisionStartId: Long?,
522524
@Query("rvcontinue") continueStr: String?,
523525
): MwQueryResponse
524526

525-
@GET(MW_API_PREFIX + "action=query&prop=info|revisions&rvslots=main&rvprop=ids|timestamp|size|flags|comment|parsedcomment|user&rvdir=older")
527+
@GET(MW_API_PREFIX + "action=query&prop=info|revisions&rvslots=main&rvprop=ids|timestamp|size|flags|comment|parsedcomment|user|oresscores&rvdir=older")
526528
suspend fun getRevisionDetailsWithInfo(
527529
@Query("pageids") pageIds: String,
528530
@Query("rvlimit") count: Int,
529531
@Query("rvstartid") revisionStartId: Long
530532
): MwQueryResponse
531533

534+
@GET(MW_API_PREFIX + "action=query&prop=info|revisions&rvslots=main&rvprop=ids|timestamp|size|flags|comment|parsedcomment|user|oresscores&rvdir=older&inprop=watched&meta=userinfo&uiprop=rights")
535+
suspend fun getRevisionDetailsWithUserInfo(
536+
@Query("pageids") pageIds: String,
537+
@Query("rvlimit") count: Int,
538+
@Query("rvstartid") revisionStartId: Long
539+
): MwQueryResponse
540+
532541
@POST(MW_API_PREFIX + "action=thank")
533542
@FormUrlEncoded
534543
suspend fun postThanksToRevision(

app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryPage.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.wikipedia.dataclient.mwapi
22

33
import kotlinx.serialization.SerialName
44
import kotlinx.serialization.Serializable
5+
import kotlinx.serialization.json.JsonArray
56
import kotlinx.serialization.json.JsonElement
67
import kotlinx.serialization.json.JsonObject
78
import kotlinx.serialization.json.decodeFromJsonElement
@@ -98,6 +99,12 @@ class MwQueryPage {
9899
val comment: String = ""
99100
val parsedcomment: String = ""
100101

102+
private val oresscores: JsonElement? = null
103+
val ores: MwQueryResult.OresResult?
104+
get() = if (oresscores != null && oresscores !is JsonArray) {
105+
JsonUtil.json.decodeFromJsonElement<MwQueryResult.OresResult>(oresscores)
106+
} else null
107+
101108
val contentMain get() = getContentFromSlot("main")
102109

103110
var diffSize = 0

app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryResponse.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ open class MwQueryResponse : MwResponse() {
2020
val gpsoffset = 0
2121
@SerialName("continue") val continuation: String? = null
2222
@SerialName("uccontinue") val ucContinuation: String? = null
23+
@SerialName("rccontinue") val rcContinuation: String? = null
2324
@SerialName("rvcontinue") val rvContinuation: String? = null
2425
@SerialName("gcmcontinue") val gcmContinuation: String? = null
2526
}

app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryResult.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,27 @@ class MwQueryResult {
194194
private val type: String = ""
195195
private val ns = 0
196196
val title: String = ""
197-
private val pageid: Long = 0
197+
val pageid: Int = 0
198198
@SerialName("revid") val curRev: Long = 0
199199
@SerialName("old_revid") val revFrom: Long = 0
200-
private val rcid: Long = 0
200+
val rcid: Long = 0
201201
val user: String = ""
202202
val anon = false
203203
val bot = false
204204

205205
@SerialName("new") private val isNew = false
206206
private val minor = false
207-
private val oldlen = 0
208-
private val newlen = 0
207+
val oldlen = 0
208+
val newlen = 0
209209
private val timestamp: String = ""
210210

211-
val parsedcomment: String = ""
211+
@SerialName("parsedcomment") val parsedComment: String = ""
212212
private val tags: List<String>? = null
213213
private val oresscores: JsonElement? = null
214214

215+
val parsedDateTime by lazy { DateUtil.iso8601LocalDateTimeParse(timestamp) }
216+
val joinedTags by lazy { tags?.joinToString(separator = ", ").orEmpty() }
217+
215218
override fun toString(): String {
216219
return title
217220
}
@@ -231,6 +234,8 @@ class MwQueryResult {
231234
// TODO: draftquality
232235
val damagingProb: Float
233236
get() = damaging?.trueProb ?: 0f
237+
val goodfaithProb: Float
238+
get() = goodfaith?.trueProb ?: 0f
234239
}
235240

236241
@Serializable

0 commit comments

Comments
 (0)