mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
parent
98e1168b25
commit
49fe0a691b
@ -83,7 +83,7 @@ import javax.inject.Inject
|
|||||||
class ConversationInfoController(args: Bundle) : BaseController(args) {
|
class ConversationInfoController(args: Bundle) : BaseController(args) {
|
||||||
|
|
||||||
@BindView(R.id.notification_settings)
|
@BindView(R.id.notification_settings)
|
||||||
lateinit var materialPreferenceScreen: MaterialPreferenceScreen
|
lateinit var notificationsPreferenceScreen: MaterialPreferenceScreen
|
||||||
@BindView(R.id.progressBar)
|
@BindView(R.id.progressBar)
|
||||||
lateinit var progressBar: ProgressBar
|
lateinit var progressBar: ProgressBar
|
||||||
@BindView(R.id.conversation_info_message_notifications)
|
@BindView(R.id.conversation_info_message_notifications)
|
||||||
@ -124,6 +124,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args) {
|
|||||||
private var roomDisposable: Disposable? = null
|
private var roomDisposable: Disposable? = null
|
||||||
private var participantsDisposable: Disposable? = null
|
private var participantsDisposable: Disposable? = null
|
||||||
|
|
||||||
|
private var databaseStorageModule: DatabaseStorageModule? = null
|
||||||
private var conversation: Conversation? = null
|
private var conversation: Conversation? = null
|
||||||
|
|
||||||
private var adapter: FlexibleAdapter<AbstractFlexibleItem<*>>? = null
|
private var adapter: FlexibleAdapter<AbstractFlexibleItem<*>>? = null
|
||||||
@ -165,6 +166,16 @@ class ConversationInfoController(args: Bundle) : BaseController(args) {
|
|||||||
return inflater.inflate(R.layout.controller_conversation_info, container, false)
|
return inflater.inflate(R.layout.controller_conversation_info, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onAttach(view: View) {
|
||||||
|
super.onAttach(view)
|
||||||
|
if (databaseStorageModule == null) {
|
||||||
|
databaseStorageModule = DatabaseStorageModule(conversationUser!!, conversationToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
notificationsPreferenceScreen.setStorageModule(databaseStorageModule)
|
||||||
|
conversationInfoWebinar.setStorageModule(databaseStorageModule)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onViewBound(view: View) {
|
override fun onViewBound(view: View) {
|
||||||
super.onViewBound(view)
|
super.onViewBound(view)
|
||||||
|
|
||||||
@ -172,17 +183,11 @@ class ConversationInfoController(args: Bundle) : BaseController(args) {
|
|||||||
saveStateHandler = LovelySaveStateHandler()
|
saveStateHandler = LovelySaveStateHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
val databaseStorageModule = DatabaseStorageModule(conversationUser!!,
|
|
||||||
conversationToken)
|
|
||||||
|
|
||||||
materialPreferenceScreen.setStorageModule(databaseStorageModule)
|
|
||||||
conversationInfoWebinar.setStorageModule(databaseStorageModule)
|
|
||||||
|
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
fetchRoomInfo()
|
fetchRoomInfo()
|
||||||
} else {
|
} else {
|
||||||
loadConversationAvatar()
|
loadConversationAvatar()
|
||||||
materialPreferenceScreen.visibility = View.VISIBLE
|
notificationsPreferenceScreen.visibility = View.VISIBLE
|
||||||
nameCategoryView.visibility = View.VISIBLE
|
nameCategoryView.visibility = View.VISIBLE
|
||||||
participantsListCategory.visibility = View.VISIBLE
|
participantsListCategory.visibility = View.VISIBLE
|
||||||
progressBar.visibility = View.GONE
|
progressBar.visibility = View.GONE
|
||||||
@ -368,7 +373,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getListOfParticipants() {
|
private fun getListOfParticipants() {
|
||||||
ncApi!!.getPeersForCall(credentials, ApiUtils.getUrlForParticipants(conversationUser!!.baseUrl, conversationToken))
|
ncApi.getPeersForCall(credentials, ApiUtils.getUrlForParticipants(conversationUser!!.baseUrl, conversationToken))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : Observer<ParticipantsOverall> {
|
.subscribe(object : Observer<ParticipantsOverall> {
|
||||||
@ -464,30 +469,9 @@ class ConversationInfoController(args: Bundle) : BaseController(args) {
|
|||||||
|
|
||||||
|
|
||||||
loadConversationAvatar()
|
loadConversationAvatar()
|
||||||
|
adjustNotificationLevelUI()
|
||||||
|
|
||||||
if (conversationUser.hasSpreedFeatureCapability("notification-levels")) {
|
notificationsPreferenceScreen.visibility = View.VISIBLE
|
||||||
messageNotificationLevel.isEnabled = true
|
|
||||||
messageNotificationLevel.alpha = 1.0f
|
|
||||||
|
|
||||||
if (conversation!!.notificationLevel != Conversation.NotificationLevel.DEFAULT) {
|
|
||||||
val stringValue: String = when (EnumNotificationLevelConverter().convertToInt(conversation!!.notificationLevel)) {
|
|
||||||
1 -> "always"
|
|
||||||
2 -> "mention"
|
|
||||||
3 -> "never"
|
|
||||||
else -> "mention"
|
|
||||||
}
|
|
||||||
|
|
||||||
messageNotificationLevel.value = stringValue
|
|
||||||
} else {
|
|
||||||
setProperNotificationValue(conversation)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
messageNotificationLevel.isEnabled = false
|
|
||||||
messageNotificationLevel.alpha = 0.38f
|
|
||||||
setProperNotificationValue(conversation)
|
|
||||||
}
|
|
||||||
|
|
||||||
materialPreferenceScreen.visibility = View.VISIBLE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,6 +485,32 @@ class ConversationInfoController(args: Bundle) : BaseController(args) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun adjustNotificationLevelUI() {
|
||||||
|
if (conversation != null) {
|
||||||
|
if (conversationUser != null && conversationUser.hasSpreedFeatureCapability("notification-levels")) {
|
||||||
|
messageNotificationLevel.isEnabled = true
|
||||||
|
messageNotificationLevel.alpha = 1.0f
|
||||||
|
|
||||||
|
if (conversation!!.notificationLevel != Conversation.NotificationLevel.DEFAULT) {
|
||||||
|
val stringValue: String = when (EnumNotificationLevelConverter().convertToInt(conversation!!.notificationLevel)) {
|
||||||
|
1 -> "always"
|
||||||
|
2 -> "mention"
|
||||||
|
3 -> "never"
|
||||||
|
else -> "mention"
|
||||||
|
}
|
||||||
|
|
||||||
|
messageNotificationLevel.value = stringValue
|
||||||
|
} else {
|
||||||
|
setProperNotificationValue(conversation)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
messageNotificationLevel.isEnabled = false
|
||||||
|
messageNotificationLevel.alpha = 0.38f
|
||||||
|
setProperNotificationValue(conversation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setProperNotificationValue(conversation: Conversation?) {
|
private fun setProperNotificationValue(conversation: Conversation?) {
|
||||||
if (conversation!!.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
|
if (conversation!!.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
|
||||||
// hack to see if we get mentioned always or just on mention
|
// hack to see if we get mentioned always or just on mention
|
||||||
|
Loading…
Reference in New Issue
Block a user