From f2cdb92858339620904190dd24038e94710c5e3a Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 2 Jul 2025 16:18:08 +0200 Subject: [PATCH] Reworked LIME algo settings as you can set multiple and order matters --- .../fragment/AccountSettingsFragment.kt | 28 ------------- .../viewmodel/AccountSettingsViewModel.kt | 26 +++++-------- .../res/layout/account_advanced_settings.xml | 39 ++++++------------- app/src/main/res/values-fr/strings.xml | 3 +- app/src/main/res/values/strings.xml | 3 +- 5 files changed, 25 insertions(+), 74 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/main/settings/fragment/AccountSettingsFragment.kt b/app/src/main/java/org/linphone/ui/main/settings/fragment/AccountSettingsFragment.kt index 15745cb45..9279438f0 100644 --- a/app/src/main/java/org/linphone/ui/main/settings/fragment/AccountSettingsFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/settings/fragment/AccountSettingsFragment.kt @@ -70,17 +70,6 @@ class AccountSettingsFragment : GenericMainFragment() { } } - private val limeAlgorithmDropdownListener = object : AdapterView.OnItemSelectedListener { - override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { - val limeAlgorithm = viewModel.availableLimeAlgorithms[position] - Log.i("$TAG Selected LIME algorithm is now [$limeAlgorithm]") - viewModel.selectedLimeAlgorithm.value = limeAlgorithm - } - - override fun onNothingSelected(parent: AdapterView<*>?) { - } - } - override fun goBack(): Boolean { try { return findNavController().popBackStack() @@ -128,7 +117,6 @@ class AccountSettingsFragment : GenericMainFragment() { startPostponedEnterTransition() setupTransportDropdown() - setupLimeAlgorithmDropdown() } } else { Log.e( @@ -187,20 +175,4 @@ class AccountSettingsFragment : GenericMainFragment() { ) binding.accountAdvancedSettings.transportSpinner.onItemSelectedListener = transportDropdownListener } - - private fun setupLimeAlgorithmDropdown() { - val adapter = ArrayAdapter( - requireContext(), - R.layout.drop_down_item, - viewModel.availableLimeAlgorithms - ) - adapter.setDropDownViewResource(R.layout.generic_dropdown_cell) - val currentLimeAlgo = viewModel.selectedLimeAlgorithm.value - - binding.accountAdvancedSettings.limeAlgoSpinner.adapter = adapter - binding.accountAdvancedSettings.limeAlgoSpinner.setSelection( - viewModel.availableLimeAlgorithms.indexOf(currentLimeAlgo) - ) - binding.accountAdvancedSettings.limeAlgoSpinner.onItemSelectedListener = limeAlgorithmDropdownListener - } } diff --git a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountSettingsViewModel.kt b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountSettingsViewModel.kt index fbc8c0bc3..57590fbd9 100644 --- a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountSettingsViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountSettingsViewModel.kt @@ -102,9 +102,7 @@ class AccountSettingsViewModel val showDeveloperSettings = MutableLiveData() - val availableLimeAlgorithms = arrayListOf() - - val selectedLimeAlgorithm = MutableLiveData() + val limeAlgorithms = MutableLiveData() private lateinit var account: Account private lateinit var natPolicy: NatPolicy @@ -127,12 +125,6 @@ class AccountSettingsViewModel } showDeveloperSettings.postValue(corePreferences.showDeveloperSettings) - - availableLimeAlgorithms.add("c25519") - availableLimeAlgorithms.add("c448") - availableLimeAlgorithms.add("c25519k512") - availableLimeAlgorithms.add("c25519mlk512") - availableLimeAlgorithms.add("c448mlk1024") } @UiThread @@ -206,7 +198,7 @@ class AccountSettingsViewModel limeServerUrl.postValue(params.limeServerUrl) - selectedLimeAlgorithm.postValue(params.limeAlgo) + limeAlgorithms.postValue(params.limeAlgo) accountFoundEvent.postValue(Event(true)) } else { @@ -240,11 +232,11 @@ class AccountSettingsViewModel if (::natPolicy.isInitialized) { Log.i("$TAG Also applying changes to NAT policy") - natPolicy.stunServer = stunServer.value + natPolicy.stunServer = stunServer.value.orEmpty().trim() natPolicy.isStunEnabled = stunServer.value.orEmpty().isNotEmpty() natPolicy.isIceEnabled = iceEnabled.value == true natPolicy.isTurnEnabled = turnEnabled.value == true - val stunTurnUsername = turnUsername.value.orEmpty() + val stunTurnUsername = turnUsername.value.orEmpty().trim() natPolicy.stunServerUsername = stunTurnUsername newParams.natPolicy = natPolicy @@ -279,7 +271,7 @@ class AccountSettingsViewModel newParams.isCpimInBasicChatRoomEnabled = cpimInBasicChatRooms.value == true - val mwi = mwiUri.value.orEmpty() + val mwi = mwiUri.value.orEmpty().trim() if (mwi.isNotEmpty()) { val mwiAddress = core.interpretUrl(mwi, false) newParams.mwiServerAddress = mwiAddress @@ -287,7 +279,7 @@ class AccountSettingsViewModel newParams.mwiServerAddress = null } - val voicemail = voicemailUri.value.orEmpty() + val voicemail = voicemailUri.value.orEmpty().trim() if (voicemail.isNotEmpty()) { val voicemailAddress = core.interpretUrl(voicemail, false) newParams.voicemailAddress = voicemailAddress @@ -327,9 +319,9 @@ class AccountSettingsViewModel newParams.audioVideoConferenceFactoryAddress = null } - newParams.ccmpServerUrl = ccmpServerUrl.value - newParams.limeServerUrl = limeServerUrl.value - newParams.limeAlgo = selectedLimeAlgorithm.value + newParams.ccmpServerUrl = ccmpServerUrl.value.orEmpty().trim() + newParams.limeServerUrl = limeServerUrl.value.orEmpty().trim() + newParams.limeAlgo = limeAlgorithms.value.orEmpty().trim() newParams.useInternationalPrefixForCallsAndChats = applyPrefix.value == true newParams.isDialEscapePlusEnabled = replacePlusBy00.value == true diff --git a/app/src/main/res/layout/account_advanced_settings.xml b/app/src/main/res/layout/account_advanced_settings.xml index f323e65ea..0d3064b15 100644 --- a/app/src/main/res/layout/account_advanced_settings.xml +++ b/app/src/main/res/layout/account_advanced_settings.xml @@ -395,45 +395,30 @@ android:ellipsize="end" android:visibility="@{viewModel.showDeveloperSettings ? View.VISIBLE : View.GONE, default=gone}" app:layout_constraintTop_toBottomOf="@id/lime_server" - app:layout_constraintBottom_toTopOf="@id/lime_algo_spinner" + app:layout_constraintBottom_toTopOf="@id/lime_algo_list" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/> - - - + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent"/> diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 10beca87b..2e830ab34 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -119,7 +119,8 @@ Créez un compte avec votre email ici : Vous avez déjà un compte ? Transport - Algorithme LIME + Algorithme(s) LIME (séparés par des virgules) + Les valeurs autorisées sont : c25519, c448, c25519k512, c25519mlk512 and c448mlk1024 Certaines fonctionnalités telles que les conversations de groupe, les vidéo-conférences, etc… nécessitent un compte &appName;.\n\nCes fonctionnalités seront masquées si vous utilisez un compte SIP tiers.\n\nPour les activer dans un projet commercial, merci de nous contacter. Je préfère créer un compte &appName; J\'ai compris diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6d35dfe25..eb07b448a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -160,7 +160,8 @@ Create an account with your email on: Already have an account? Transport - LIME algorithm + LIME algorithm(s) (comma separated) + Allowed values are: c25519, c448, c25519k512, c25519mlk512 and c448mlk1024 Some features require a &appName; account, such as group messaging, video conferences…\n\nThese features are hidden when you register with a third party SIP account.\n\nTo enable it in a commercial project, please contact us. I prefer to create a &appName; account I understand