Fix 4615: Option for editing caption and description (#4672)

* DescriptionEditHelper implemented

* Description extracted

* Description editable

* No description condition handled

* Code cleanup

* Added javadocs

* toolbar added

* API call done

* Caption edit available

* Progress dialog added

* Log

* Problem with ButterKnife

* Caption is editable

* Removed unused import

* Manifest file reverted

* Manifest file reverted

* Manifest file reverted

* View binding added

* Post operation test added

* Java docs added

* Java docs added

* MediaDetailFragment unit tests added

* Test added
This commit is contained in:
Ayan Sarkar 2021-12-07 01:20:54 +05:30 committed by GitHub
parent e910b1d14f
commit 0269894c64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 855 additions and 14 deletions

View file

@ -64,6 +64,24 @@ class PageEditClient(
}
}
/**
* Set new labels to Wikibase server of commons
* @param summary Edit summary
* @param title Title of the page to edit
* @param language Corresponding language of label
* @param value label
* @return 1 when the edit was successful
*/
fun setCaptions(summary: String, title: String,
language: String, value: String) : Observable<Int>{
return try {
pageEditInterface.postCaptions(summary, title, language,
value, csrfTokenClient.tokenBlocking).map { it.success }
} catch (throwable: Throwable) {
Observable.just(0)
}
}
/**
* Get whole WikiText of required file
* @param title : Name of the file

View file

@ -5,6 +5,7 @@ import io.reactivex.Single
import org.wikipedia.dataclient.Service
import org.wikipedia.dataclient.mwapi.MwQueryResponse
import org.wikipedia.edit.Edit
import org.wikipedia.wikidata.Entities
import retrofit2.http.*
/**
@ -73,6 +74,18 @@ interface PageEditInterface {
@Field("token") token: String
): Observable<Edit>
@FormUrlEncoded
@Headers("Cache-Control: no-cache")
@POST(Service.MW_API_PREFIX + "action=wbsetlabel&format=json&site=commonswiki&formatversion=2")
fun postCaptions(
@Field("summary") summary: String,
@Field("title") title: String,
@Field("language") language: String,
@Field("value") value: String,
@Field("token") token: String
): Observable<Entities>
/**
* Get wiki text for provided file names
* @param titles : Name of the file