issue 2931 progress

Signed-off-by: Julius Linus <juliuslinus1@gmail.com>

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
rapterjet2004 2023-05-15 09:50:18 -05:00 committed by Andy Scherzinger
parent 0168be395a
commit 9e9c6e81b9
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -2,14 +2,23 @@ package com.nextcloud.talk.translate
import android.graphics.drawable.ColorDrawable import android.graphics.drawable.ColorDrawable
import android.os.Bundle import android.os.Bundle
import android.text.method.ScrollingMovementMethod import android.text.method.ScrollingMovementMethod
import android.util.Log
import android.view.View
import autodagger.AutoInjector import autodagger.AutoInjector
import com.nextcloud.talk.R import com.nextcloud.talk.R
import com.nextcloud.talk.activities.BaseActivity import com.nextcloud.talk.activities.BaseActivity
import com.nextcloud.talk.api.NcApi import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ActivityTranslateBinding import com.nextcloud.talk.databinding.ActivityTranslateBinding
import com.nextcloud.talk.models.json.translations.TranslationsOverall
import com.nextcloud.talk.users.UserManager import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.bundle.BundleKeys import com.nextcloud.talk.utils.bundle.BundleKeys
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import javax.inject.Inject import javax.inject.Inject
@ -28,9 +37,7 @@ class TranslateActivity : BaseActivity()
@Inject @Inject
lateinit var userManager: UserManager lateinit var userManager: UserManager
// lateinit var currentUser: User lateinit var currentUser : User
// val url : String? = currentUser.baseUrl + "/translation"
var text : String? = null var text : String? = null
@ -41,15 +48,12 @@ class TranslateActivity : BaseActivity()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivityTranslateBinding.inflate(layoutInflater) binding = ActivityTranslateBinding.inflate(layoutInflater)
val bundle = intent.extras currentUser = userManager.currentUser.blockingGet()
binding.originalMessageTextview.text = bundle?.getString(BundleKeys.KEY_TRANSLATE_MESSAGE)
text = binding.originalMessageTextview.text as String?
setupTextViews() setupTextViews()
setupActionBar() setupActionBar()
setupSpinners() setupSpinners()
setContentView(binding.root) setContentView(binding.root)
// translate() translate()
} }
private fun setupActionBar() { private fun setupActionBar() {
@ -71,6 +75,10 @@ class TranslateActivity : BaseActivity()
original.movementMethod = ScrollingMovementMethod() original.movementMethod = ScrollingMovementMethod()
translation.movementMethod = ScrollingMovementMethod() translation.movementMethod = ScrollingMovementMethod()
val bundle = intent.extras
binding.originalMessageTextview.text = bundle?.getString(BundleKeys.KEY_TRANSLATE_MESSAGE)
text = binding.originalMessageTextview.text as String?
} }
@ -82,40 +90,39 @@ class TranslateActivity : BaseActivity()
} }
// TODO get this function working // TODO get this function working
// private fun translate() { private fun translate() {
// val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token) val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token)
// val translateURL = currentUser.baseUrl + "/translation" + "/translate"
// val translateURL = url + "/translate"
//
//
// ncApi.translateMessage(credentials, translateURL, text, fromLanguage, toLanguage)
// ncApi.translateMessage(credentials, translateURL, text, fromLanguage, toLanguage) ?.subscribeOn(Schedulers.io())
// ?.subscribeOn(Schedulers.io()) ?.observeOn(AndroidSchedulers.mainThread())
// ?.observeOn(AndroidSchedulers.mainThread()) ?.subscribe(object : Observer<TranslationsOverall> {
// ?.subscribe(object : Observer<TranslationsOverall> { override fun onSubscribe(d: Disposable) {
// override fun onSubscribe(d: Disposable) { // TODO set progress bar to show
// // TODO set progress bar to show binding.translatedMessageTextview.visibility = View.GONE
// binding.translatedMessageTextview.visibility = View.GONE binding.progressBar.visibility = View.VISIBLE
// binding.progressBar.visibility = View.VISIBLE }
// }
// override fun onNext(translationOverall: TranslationsOverall) {
// override fun onNext(translationOverall: TranslationsOverall) { // TODO hide progress bar
// // TODO hide progress bar binding.progressBar.visibility = View.GONE
// binding.progressBar.visibility = View.GONE binding.translatedMessageTextview.visibility = View.VISIBLE
// binding.translatedMessageTextview.visibility = View.VISIBLE binding.translatedMessageTextview.text = translationOverall.ocs?.data?.text
// binding.translatedMessageTextview.text = translationOverall.ocs?.data?.text }
// }
// override fun onError(e: Throwable) {
// override fun onError(e: Throwable) { Log.e("TranslateActivity", "Error")
// Log.e("TranslateActivity", "Error") }
// }
// override fun onComplete() {
// override fun onComplete() { // not needed?
// // not needed? }
// } })
// })
// }
// }
private fun setupSpinners() { private fun setupSpinners() {
// TODO set spinner options to use array from getLanguageOptions() // TODO set spinner options to use array from getLanguageOptions()