Commit 8d07f279 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add Jitsi public settings.

(check if Jitsi is enabled before showing the respective icons)
parent 68587727
......@@ -19,6 +19,9 @@ import chat.rocket.android.chatdetails.presentation.ChatDetailsView
import chat.rocket.android.chatdetails.viewmodel.ChatDetailsViewModel
import chat.rocket.android.chatdetails.viewmodel.ChatDetailsViewModelFactory
import chat.rocket.android.chatroom.ui.ChatRoomActivity
import chat.rocket.android.server.domain.CurrentServerRepository
import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.PublicSettings
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
......@@ -62,6 +65,10 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
lateinit var presenter: ChatDetailsPresenter
@Inject
lateinit var factory: ChatDetailsViewModelFactory
@Inject
lateinit var serverUrl: CurrentServerRepository
@Inject
lateinit var settings: GetSettingsInteractor
private var adapter: ChatDetailsAdapter? = null
private lateinit var viewModel: ChatDetailsViewModel
......
......@@ -3,14 +3,19 @@ package chat.rocket.android.chatdetails.ui
import android.view.Menu
import android.view.MenuItem
import chat.rocket.android.R
import chat.rocket.android.server.domain.isJitsiEnabled
internal fun ChatDetailsFragment.setupMenu(menu: Menu) {
menu.add(
Menu.NONE,
MENU_ACTION_VIDEO_CALL,
Menu.NONE,
R.string.msg_video_call
).setIcon(R.drawable.ic_video_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
serverUrl.get()?.let {
if (settings.get(it).isJitsiEnabled()) {
menu.add(
Menu.NONE,
MENU_ACTION_VIDEO_CALL,
Menu.NONE,
R.string.msg_video_call
).setIcon(R.drawable.ic_video_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
}
}
if (isFavorite) {
menu.add(
......
......@@ -21,7 +21,6 @@ class RefreshSettingsInteractor @Inject constructor(
LDAP_ENABLE,
CAS_ENABLE,
CAS_LOGIN_URL,
ACCOUNT_REGISTRATION,
ACCOUNT_LOGIN_FORM,
ACCOUNT_PASSWORD_RESET,
......@@ -37,6 +36,12 @@ class RefreshSettingsInteractor @Inject constructor(
ACCOUNT_WORDPRESS,
ACCOUNT_WORDPRESS_URL,
JITSI_ENABLED,
JISTI_ENABLE_CHANNELS,
JITSI_SSL,
JITSI_DOMAIN,
JITSI_URL_ROOM_PREFIX,
SITE_URL,
SITE_NAME,
FAVICON_512,
......
......@@ -5,7 +5,7 @@ import chat.rocket.core.model.Value
typealias PublicSettings = Map<String, Value<Any>>
// Authentication methods.
// Authentication methods
const val LDAP_ENABLE = "LDAP_Enable"
const val CAS_ENABLE = "CAS_enabled"
const val CAS_LOGIN_URL = "CAS_login_url"
......@@ -24,6 +24,13 @@ const val ACCOUNT_GITLAB_URL = "API_Gitlab_URL"
const val ACCOUNT_WORDPRESS = "Accounts_OAuth_Wordpress"
const val ACCOUNT_WORDPRESS_URL = "API_Wordpress_URL"
// Video call
const val JITSI_ENABLED = "Jitsi_Enabled"
const val JISTI_ENABLE_CHANNELS = "Jisti_Enable_Channels"
const val JITSI_SSL = "Jitsi_SSL"
const val JITSI_DOMAIN = "Jitsi_Domain"
const val JITSI_URL_ROOM_PREFIX = "Jitsi_URL_Room_Prefix"
const val SITE_URL = "Site_Url"
const val SITE_NAME = "Site_Name"
const val FAVICON_196 = "Assets_favicon_192"
......@@ -54,10 +61,11 @@ const val MESSAGE_READ_RECEIPT_STORE_USERS = "Message_Read_Receipt_Store_Users"
* Extension functions for Public Settings.
*
* If you need to access a Setting, add a const val key above, add it to the filter on
* ServerPresenter.kt and a extension function to access it
* RefreshSettingsInteractor.kt and a extension function to access it.
*/
fun PublicSettings.isLdapAuthenticationEnabled(): Boolean = this[LDAP_ENABLE]?.value == true
// Authentication
fun PublicSettings.isLdapAuthenticationEnabled(): Boolean = this[LDAP_ENABLE]?.value == true
fun PublicSettings.isCasAuthenticationEnabled(): Boolean = this[CAS_ENABLE]?.value == true
fun PublicSettings.casLoginUrl(): String = this[CAS_LOGIN_URL]?.value.toString()
fun PublicSettings.isRegistrationEnabledForNewUsers(): Boolean = this[ACCOUNT_REGISTRATION]?.value == "Public"
......@@ -74,6 +82,13 @@ fun PublicSettings.gitlabUrl(): String? = this[ACCOUNT_GITLAB_URL]?.value as Str
fun PublicSettings.isWordpressAuthenticationEnabled(): Boolean = this[ACCOUNT_WORDPRESS]?.value == true
fun PublicSettings.wordpressUrl(): String? = this[ACCOUNT_WORDPRESS_URL]?.value as String?
// Video call
fun PublicSettings.isJitsiEnabled(): Boolean = this[JITSI_ENABLED]?.value == true
fun PublicSettings.isJitsiEnabledForChannels(): Boolean = this[JISTI_ENABLE_CHANNELS]?.value == true
fun PublicSettings.isJitsiSSL(): Boolean = this[JITSI_SSL]?.value == true
fun PublicSettings.jitsiDomain(): String? = this[JITSI_DOMAIN]?.value as String?
fun PublicSettings.jitsiPrefix(): String? = this[JITSI_URL_ROOM_PREFIX]?.value as String?
fun PublicSettings.useRealName(): Boolean = this[USE_REALNAME]?.value == true
fun PublicSettings.useSpecialCharsOnRoom(): Boolean = this[ALLOW_ROOM_NAME_SPECIAL_CHARS]?.value == true
fun PublicSettings.faviconLarge(): String? = this[FAVICON_512]?.value as String?
......
......@@ -6,7 +6,9 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.db.model.ChatRoomEntity
import chat.rocket.android.db.model.UserEntity
import chat.rocket.android.server.domain.GetConnectingServerInteractor
import chat.rocket.android.server.domain.CurrentServerRepository
import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.isJitsiEnabled
import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.avatarUrl
......@@ -24,13 +26,15 @@ class UserDetailsPresenter @Inject constructor(
private val dbManager: DatabaseManager,
private val strategy: CancelStrategy,
private val navigator: ChatRoomNavigator,
serverInteractor: GetConnectingServerInteractor,
settingsInteractor: GetSettingsInteractor,
serverInteractor: CurrentServerRepository,
factory: ConnectionManagerFactory
) {
private var currentServer = serverInteractor.get()!!
private val manager = factory.create(currentServer)
private val client = manager.client
private val interactor = FetchChatRoomsInteractor(client, dbManager)
private val settings = settingsInteractor.get(currentServer)
private lateinit var userEntity: UserEntity
fun loadUserDetails(userId: String) {
......@@ -47,12 +51,13 @@ class UserDetailsPresenter @Inject constructor(
userEntity.utcOffset // TODO Convert UTC and display like the mockup
if (avatarUrl != null && username != null && name != null && utcOffset != null) {
view.showUserDetails(
view.showUserDetailsAndActions(
avatarUrl = avatarUrl,
name = name,
username = username,
status = userEntity.status,
utcOffset = utcOffset.toString()
utcOffset = utcOffset.toString(),
isVideoCallAllowed = settings.isJitsiEnabled()
)
} else {
throw Exception()
......
......@@ -13,12 +13,14 @@ interface UserDetailsView : LoadingView, MessageView {
* @param username The user's username.
* @param status The user's status.
* @param utcOffset The user's UTC offset.
* @param isVideoCallAllowed True if the video call is allowed, false otherwise.
*/
fun showUserDetails(
fun showUserDetailsAndActions(
avatarUrl: String,
name: String,
username: String,
status: String,
utcOffset: String
utcOffset: String,
isVideoCallAllowed: Boolean
)
}
......@@ -81,12 +81,13 @@ class UserDetailsFragment : Fragment(), UserDetailsView {
super.onDestroyView()
}
override fun showUserDetails(
override fun showUserDetailsAndActions(
avatarUrl: String,
name: String,
username: String,
status: String,
utcOffset: String
utcOffset: String,
isVideoCallAllowed: Boolean
) {
val requestBuilder = Glide.with(this).load(avatarUrl)
......@@ -105,7 +106,12 @@ class UserDetailsFragment : Fragment(), UserDetailsView {
// We should also setup the user details listeners.
text_message.setOnClickListener { presenter.createDirectMessage(username) }
text_video_call.setOnClickListener { presenter.startVideoCall() }
if (isVideoCallAllowed) {
text_video_call.isVisible = true
text_video_call.setOnClickListener { presenter.startVideoCall() }
} else {
text_video_call.isVisible = false
}
}
override fun showLoading() {
......
......@@ -79,9 +79,11 @@
android:layout_marginTop="24dp"
android:drawableTop="@drawable/ic_video_24dp"
android:text="@string/msg_video_call"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/text_message"
app:layout_constraintTop_toBottomOf="@+id/text_username" />
app:layout_constraintTop_toBottomOf="@+id/text_username"
tools:visibility="visible" />
<TextView
android:id="@+id/text_title_status"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment