mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 14:24:05 +01:00
fetch poll to set subtitle in message
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
ae80a4e2ad
commit
81666829b5
@ -26,6 +26,7 @@ import android.graphics.drawable.Drawable
|
|||||||
import android.graphics.drawable.LayerDrawable
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
@ -40,11 +41,16 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
|
|||||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||||
import com.nextcloud.talk.databinding.ItemCustomIncomingPollMessageBinding
|
import com.nextcloud.talk.databinding.ItemCustomIncomingPollMessageBinding
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
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.polls.ui.PollMainDialogFragment
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||||
import com.stfalcon.chatkit.messages.MessageHolders
|
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
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication::class)
|
@AutoInjector(NextcloudTalkApplication::class)
|
||||||
@ -129,17 +135,39 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : MessageH
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO get poll from api
|
val credentials = ApiUtils.getCredentials(message.activeUser?.username, message.activeUser?.token)
|
||||||
// wait for https://github.com/nextcloud/spreed/pull/7306#issuecomment-1145819317
|
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
|
||||||
|
}
|
||||||
|
|
||||||
// val credentials = ApiUtils.getCredentials(message.activeUser?.username, message.activeUser?.token)
|
override fun onNext(pollOverall: PollOverall) {
|
||||||
// ncApi!!.getPoll(
|
if (pollOverall.ocs!!.data!!.status == 0) {
|
||||||
// credentials,
|
binding.messagePollSubtitle.text =
|
||||||
// ApiUtils.getUrlForPoll(
|
context?.resources?.getString(R.string.message_poll_tap_to_vote)
|
||||||
// message.activeUser?.baseUrl,
|
} 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
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:gravity="center_vertical"
|
||||||
android:gravity="center_vertical">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/message_poll_icon"
|
android:id="@+id/message_poll_icon"
|
||||||
@ -74,7 +74,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:src="@drawable/ic_baseline_bar_chart_24"
|
android:src="@drawable/ic_baseline_bar_chart_24"
|
||||||
app:tint="@color/high_emphasis_menu_icon"></ImageView>
|
app:tint="@color/high_emphasis_menu_icon" />
|
||||||
|
|
||||||
<androidx.emoji.widget.EmojiTextView
|
<androidx.emoji.widget.EmojiTextView
|
||||||
android:id="@+id/message_poll_title"
|
android:id="@+id/message_poll_title"
|
||||||
@ -87,10 +87,11 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/message_poll_subtitle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/double_margin_between_elements"
|
android:layout_marginTop="@dimen/double_margin_between_elements"
|
||||||
android:text="@string/message_poll_tap_to_vote"></TextView>
|
android:text="@string/message_poll_tap_to_vote" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@id/messageTime"
|
android:id="@id/messageTime"
|
||||||
|
Loading…
Reference in New Issue
Block a user