mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Fix Failing Tests in DescriptionEditActivityUnitTest (#5685)
* initial commit * Fix No Precise Message After Clicking Review Buttons * Fix For ThanksClient * Fix For Depictions * Fix For Categories * Fix For Description & Coordinates * Fix For Description & Coordinates * Fix For Description & Coordinates * Fix For Mark as Read notifications * resolve conflicts * fix merge conflicts * fix tests * fix tests * fix tests * fix tests
This commit is contained in:
parent
a595500921
commit
2d29fbe885
3 changed files with 62 additions and 30 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package fr.free.nrw.commons.description
|
||||
|
||||
|
||||
import android.app.ProgressDialog
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
|
|
@ -8,8 +9,11 @@ import android.speech.RecognizerIntent
|
|||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import fr.free.nrw.commons.CommonsApplication
|
||||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.auth.csrf.InvalidLoginTokenException
|
||||
import fr.free.nrw.commons.databinding.ActivityDescriptionEditBinding
|
||||
import fr.free.nrw.commons.description.EditDescriptionConstants.LIST_OF_DESCRIPTION_AND_CAPTION
|
||||
import fr.free.nrw.commons.description.EditDescriptionConstants.WIKITEXT
|
||||
|
|
@ -25,6 +29,7 @@ import io.reactivex.schedulers.Schedulers
|
|||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
/**
|
||||
* Activity for populating and editing existing description and caption
|
||||
*/
|
||||
|
|
@ -71,6 +76,9 @@ class DescriptionEditActivity : BaseActivity(), UploadMediaDetailAdapter.EventLi
|
|||
|
||||
@Inject lateinit var descriptionEditHelper: DescriptionEditHelper
|
||||
|
||||
@Inject lateinit var sessionManager: SessionManager
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
|
@ -196,32 +204,64 @@ class DescriptionEditActivity : BaseActivity(), UploadMediaDetailAdapter.EventLi
|
|||
* @param uploadMediaDetails descriptions and captions
|
||||
*/
|
||||
private fun editDescription(media : Media, updatedWikiText : String, uploadMediaDetails : ArrayList<UploadMediaDetail>){
|
||||
descriptionEditHelper?.addDescription(
|
||||
applicationContext, media,
|
||||
updatedWikiText
|
||||
)
|
||||
?.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe(Consumer<Boolean> { s: Boolean? -> Timber.d("Descriptions are added.") })?.let {
|
||||
compositeDisposable.add(
|
||||
it
|
||||
|
||||
try {
|
||||
descriptionEditHelper?.addDescription(
|
||||
applicationContext, media,
|
||||
updatedWikiText
|
||||
)
|
||||
?.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe(Consumer<Boolean> { s: Boolean? -> Timber.d("Descriptions are added.") })?.let {
|
||||
compositeDisposable.add(
|
||||
it
|
||||
)
|
||||
}
|
||||
} catch (e : InvalidLoginTokenException) {
|
||||
val username: String? = sessionManager?.userName
|
||||
val logoutListener = CommonsApplication.BaseLogoutListener(
|
||||
this,
|
||||
getString(R.string.invalid_login_message),
|
||||
username
|
||||
)
|
||||
|
||||
val commonsApplication = CommonsApplication.getInstance()
|
||||
if (commonsApplication != null ){
|
||||
commonsApplication.clearApplicationData(this,logoutListener)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val updatedCaptions = LinkedHashMap<String, String>()
|
||||
for (mediaDetail in uploadMediaDetails) {
|
||||
compositeDisposable.add(
|
||||
descriptionEditHelper!!.addCaption(
|
||||
applicationContext, media,
|
||||
mediaDetail.languageCode, mediaDetail.captionText
|
||||
try {
|
||||
compositeDisposable.add(
|
||||
descriptionEditHelper!!.addCaption(
|
||||
applicationContext, media,
|
||||
mediaDetail.languageCode, mediaDetail.captionText
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { s: Boolean? ->
|
||||
updatedCaptions[mediaDetail.languageCode!!] = mediaDetail.captionText
|
||||
media.captions = updatedCaptions
|
||||
Timber.d("Caption is added.")
|
||||
})
|
||||
}
|
||||
catch (e : InvalidLoginTokenException) {
|
||||
val username = sessionManager.userName
|
||||
val logoutListener = CommonsApplication.BaseLogoutListener(
|
||||
this,
|
||||
getString(R.string.invalid_login_message),
|
||||
username
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { s: Boolean? ->
|
||||
updatedCaptions[mediaDetail.languageCode!!] = mediaDetail.captionText
|
||||
media.captions = updatedCaptions
|
||||
Timber.d("Caption is added.")
|
||||
})
|
||||
|
||||
val commonsApplication = CommonsApplication.getInstance()
|
||||
if (commonsApplication != null ){
|
||||
commonsApplication.clearApplicationData(this,logoutListener)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Authors:
|
||||
* Winston Sung
|
||||
-->
|
||||
<resources>
|
||||
<string name="crash_dialog_title">同享壞咗</string>
|
||||
<string name="crash_dialog_text">哎呀。出咗錯!</string>
|
||||
<string name="crash_dialog_ok_toast">多謝你!</string>
|
||||
</resources>
|
||||
Loading…
Add table
Add a link
Reference in a new issue