Bottom nav bar & corePreferences changes

This commit is contained in:
Sylvain Berfini 2023-09-27 10:41:30 +02:00
parent 845fd7ee03
commit 1c72196943
8 changed files with 43 additions and 15 deletions

View file

@ -91,6 +91,11 @@ class CorePreferences @UiThread constructor(private val context: Context) {
val disableChat: Boolean
get() = config.getBool("app", "disable_chat_feature", false) // TODO FIXME: set it to true for first "release" without chat
// Will disable meetings feature completely
@get:WorkerThread
val disableMeetings: Boolean
get() = config.getBool("app", "disable_meetings_feature", false) // TODO FIXME: set it to true for first "release" without meetings
@get:WorkerThread
val defaultDomain: String
get() = config.getString("app", "default_domain", "sip.linphone.org")!!

View file

@ -101,8 +101,6 @@ abstract class AbstractNewTransferCallFragment : GenericCallFragment() {
viewModel.title.value = title
binding.viewModel = viewModel
binding.hideGroupChatButton = true
binding.setBackClickListener {
findNavController().popBackStack()
}

View file

@ -39,6 +39,7 @@ import org.linphone.ui.main.history.model.ContactOrSuggestionModel
import org.linphone.ui.main.history.model.NumpadModel
import org.linphone.ui.main.model.isInSecureMode
import org.linphone.utils.Event
import org.linphone.utils.LinphoneUtils
class StartCallViewModel @UiThread constructor() : ViewModel() {
companion object {
@ -53,6 +54,8 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
val numpadModel: NumpadModel
val hideGroupCallButton = MutableLiveData<Boolean>()
val isNumpadVisible = MutableLiveData<Boolean>()
val appendDigitToSearchBarEvent: MutableLiveData<Event<String>> by lazy {
@ -128,6 +131,11 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
val defaultAccount = core.defaultAccount
limitSearchToLinphoneAccounts = defaultAccount?.isInSecureMode() ?: false
val hideGroupCall = corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(
core
)
hideGroupCallButton.postValue(hideGroupCall)
coreContext.contactsManager.addListener(contactsListener)
magicSearch = core.createMagicSearch()
magicSearch.limitedSearch = false

View file

@ -68,10 +68,14 @@ class BottomNavBarViewModel @UiThread constructor() : ViewModel() {
coreContext.postOnCoreThread { core ->
core.addListener(coreListener)
updateMissedCallsCount()
}
hideConversations.value = corePreferences.disableChat || true // TODO: chat feature
hideMeetings.value = true // TODO: meetings feature
hideConversations.postValue(corePreferences.disableChat)
val hideGroupCall = corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(
core
)
hideMeetings.postValue(hideGroupCall)
}
}
@UiThread

View file

@ -39,6 +39,7 @@ import org.linphone.core.Call
import org.linphone.core.Call.Dir
import org.linphone.core.Call.Status
import org.linphone.core.ChatRoom
import org.linphone.core.Core
import org.linphone.core.tools.Log
class LinphoneUtils {
@ -142,6 +143,23 @@ class LinphoneUtils {
}
}
@WorkerThread
fun isEndToEndEncryptedChatAvailable(core: Core): Boolean {
return core.isLimeX3DhEnabled &&
core.defaultAccount?.params?.limeServerUrl != null &&
core.defaultAccount?.params?.conferenceFactoryUri != null
}
@WorkerThread
fun isGroupChatAvailable(core: Core): Boolean {
return core.defaultAccount?.params?.conferenceFactoryUri != null
}
@WorkerThread
fun isRemoteConferencingAvailable(core: Core): Boolean {
return core.defaultAccount?.params?.audioVideoConferenceFactoryAddress != null
}
@AnyThread
@IntegerRes
fun getIconResId(callStatus: Status, callDir: Dir): Int {

View file

@ -78,7 +78,7 @@
<androidx.appcompat.widget.AppCompatTextView
style="@style/bottom_nav_bar_label_style"
android:id="@+id/conversations"
android:visibility="@{viewModel.hideConversations ? View.GONE : View.VISIBLE, default=gone}"
android:visibility="@{viewModel.hideConversations ? View.GONE : View.VISIBLE}"
android:enabled="false"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -97,7 +97,7 @@
style="@style/bottom_nav_bar_label_style"
android:onClick="@{onMeetingsClicked}"
android:id="@+id/meetings"
android:visibility="@{viewModel.hideMeetings ? View.GONE : View.VISIBLE, default=gone}"
android:visibility="@{viewModel.hideMeetings ? View.GONE : View.VISIBLE}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/users_three"

View file

@ -86,7 +86,7 @@
<androidx.appcompat.widget.AppCompatTextView
style="@style/bottom_nav_bar_label_style"
android:onClick="@{onConversationsClicked}"
android:visibility="@{viewModel.hideConversations ? View.GONE : View.VISIBLE, default=gone}"
android:visibility="@{viewModel.hideConversations ? View.GONE : View.VISIBLE}"
android:enabled="false"
android:id="@+id/conversations"
android:layout_width="0dp"
@ -108,7 +108,7 @@
style="@style/bottom_nav_bar_label_style"
android:onClick="@{onMeetingsClicked}"
android:id="@+id/meetings"
android:visibility="@{viewModel.hideMeetings ? View.GONE : View.VISIBLE, default=gone}"
android:visibility="@{viewModel.hideMeetings ? View.GONE : View.VISIBLE}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"

View file

@ -11,9 +11,6 @@
<variable
name="hideNumpadClickListener"
type="View.OnClickListener" />
<variable
name="hideGroupChatButton"
type="Boolean" />
<variable
name="title"
type="String" />
@ -122,7 +119,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="group_call_icon, gradient_background, group_call_label"
android:visibility="@{hideGroupChatButton ? View.GONE : View.VISIBLE}" />
android:visibility="@{viewModel.hideGroupCallButton || viewModel.searchFilter.length() > 0 ? View.GONE : View.VISIBLE}" />
<!-- margin start must be half the size of the group_call_icon below -->
<View
@ -145,7 +142,6 @@
android:background="@drawable/shape_orange_round"
android:padding="10dp"
android:src="@drawable/users_three"
android:visibility="@{viewModel.searchFilter.length() > 0 ? View.GONE : View.VISIBLE}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/search_bar"
app:tint="@color/white" />
@ -162,7 +158,6 @@
android:text="@string/history_call_start_create_group_call"
android:textColor="@color/black"
android:textSize="16sp"
android:visibility="@{viewModel.searchFilter.length() > 0 ? View.GONE : View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="@id/group_call_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/group_call_icon"