mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
static text for poll messages
= remove api call. it was decided in talk team to remove this to avoid so many requests. downside is that it's not possible anymore to see if the poll is closed or not. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
8f3a18655e
commit
c1fd78d29a
@ -26,7 +26,6 @@ import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.os.Build
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
@ -41,16 +40,11 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
import com.nextcloud.talk.databinding.ItemCustomIncomingPollMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.polls.repositories.model.PollOverall
|
||||
import com.nextcloud.talk.polls.ui.PollMainDialogFragment
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||
import com.stfalcon.chatkit.messages.MessageHolders
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import javax.inject.Inject
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
@ -134,40 +128,6 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : MessageH
|
||||
TAG
|
||||
)
|
||||
}
|
||||
|
||||
val credentials = ApiUtils.getCredentials(message.activeUser?.username, message.activeUser?.token)
|
||||
ncApi.getPoll(
|
||||
credentials,
|
||||
ApiUtils.getUrlForPoll(
|
||||
message.activeUser?.baseUrl,
|
||||
roomToken,
|
||||
pollId
|
||||
)
|
||||
).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<PollOverall> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
// unused atm
|
||||
}
|
||||
|
||||
override fun onNext(pollOverall: PollOverall) {
|
||||
if (pollOverall.ocs!!.data!!.status == 0) {
|
||||
binding.messagePollSubtitle.text =
|
||||
context.resources?.getString(R.string.message_poll_tap_to_vote)
|
||||
} else {
|
||||
binding.messagePollSubtitle.text =
|
||||
context.resources?.getString(R.string.message_poll_tap_see_results)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "Error while fetching poll", e)
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
// unused atm
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ package com.nextcloud.talk.adapters.messages
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.view.ViewCompat
|
||||
@ -38,16 +37,11 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingPollMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.chat.ReadStatus
|
||||
import com.nextcloud.talk.polls.repositories.model.PollOverall
|
||||
import com.nextcloud.talk.polls.ui.PollMainDialogFragment
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||
import com.stfalcon.chatkit.messages.MessageHolders
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import javax.inject.Inject
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
@ -150,40 +144,6 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag
|
||||
TAG
|
||||
)
|
||||
}
|
||||
|
||||
val credentials = ApiUtils.getCredentials(message.activeUser?.username, message.activeUser?.token)
|
||||
ncApi.getPoll(
|
||||
credentials,
|
||||
ApiUtils.getUrlForPoll(
|
||||
message.activeUser?.baseUrl,
|
||||
roomToken,
|
||||
pollId
|
||||
)
|
||||
).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<PollOverall> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
// unused atm
|
||||
}
|
||||
|
||||
override fun onNext(pollOverall: PollOverall) {
|
||||
if (pollOverall.ocs!!.data!!.status == 0) {
|
||||
binding.messagePollSubtitle.text =
|
||||
context?.resources?.getString(R.string.message_poll_tap_to_vote)
|
||||
} else {
|
||||
binding.messagePollSubtitle.text =
|
||||
context?.resources?.getString(R.string.message_poll_tap_see_results)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "Error while fetching poll", e)
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
// unused atm
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/double_margin_between_elements"
|
||||
android:text="@string/message_poll_tap_to_vote" />
|
||||
android:text="@string/message_poll_tap_to_open" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/messageTime"
|
||||
|
@ -74,7 +74,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/double_margin_between_elements"
|
||||
android:text="@string/message_poll_tap_to_vote"
|
||||
android:text="@string/message_poll_tap_to_open"
|
||||
android:textColor="@color/nc_outcoming_text_default" />
|
||||
|
||||
<TextView
|
||||
|
@ -532,8 +532,7 @@
|
||||
<string name="message_search_begin_empty">No search results</string>
|
||||
|
||||
<!-- Polls -->
|
||||
<string name="message_poll_tap_to_vote">Tap to vote</string>
|
||||
<string name="message_poll_tap_see_results">Tap to see results</string>
|
||||
<string name="message_poll_tap_to_open">Tap to open poll</string>
|
||||
<string name="polls_amount_voters">%1$s votes</string>
|
||||
<string name="polls_add_option">Add option</string>
|
||||
<string name="polls_edit_vote">Edit vote</string>
|
||||
|
Loading…
Reference in New Issue
Block a user