Reworked LIME algo settings as you can set multiple and order matters

This commit is contained in:
Sylvain Berfini 2025-07-02 16:18:08 +02:00
parent aa0255bcfd
commit f2cdb92858
5 changed files with 25 additions and 74 deletions

View file

@ -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
}
}

View file

@ -102,9 +102,7 @@ class AccountSettingsViewModel
val showDeveloperSettings = MutableLiveData<Boolean>()
val availableLimeAlgorithms = arrayListOf<String>()
val selectedLimeAlgorithm = MutableLiveData<String>()
val limeAlgorithms = MutableLiveData<String>()
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

View file

@ -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"/>
<androidx.appcompat.widget.AppCompatSpinner
<androidx.appcompat.widget.AppCompatEditText
style="@style/default_text_style"
android:id="@+id/lime_algo_spinner"
android:id="@+id/lime_algo_list"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:background="@drawable/edit_text_background"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:textSize="14sp"
android:textColor="@color/gray_main2_600"
android:gravity="center_vertical"
android:overlapAnchor="false"
android:dropDownVerticalOffset="25dp"
android:spinnerMode="dropdown"
android:popupBackground="@drawable/shape_squircle_white_background"
android:background="@drawable/edit_text_background"
android:text="@={viewModel.limeAlgorithms}"
android:inputType="text|textNoSuggestions"
android:hint="@string/assistant_sip_account_lime_algorithm_hint"
android:visibility="@{viewModel.showDeveloperSettings ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_max="@dimen/text_input_max_width"
app:layout_constraintTop_toBottomOf="@id/lime_algo_title"
app:layout_constraintBottom_toTopOf="@id/update_password"
app:layout_constraintStart_toStartOf="@id/lime_algo_title"
app:layout_constraintEnd_toEndOf="@id/lime_algo_title" />
<ImageView
android:id="@+id/lime_algo_spinner_caret"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spinner_caret_end_margin"
android:src="@drawable/caret_down"
android:contentDescription="@null"
android:visibility="@{viewModel.showDeveloperSettings ? View.VISIBLE : View.GONE, default=gone}"
app:tint="?attr/color_main2_600"
app:layout_constraintTop_toTopOf="@id/lime_algo_spinner"
app:layout_constraintBottom_toBottomOf="@id/lime_algo_spinner"
app:layout_constraintEnd_toEndOf="@id/transport_spinner"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
@ -454,7 +439,7 @@
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/lime_algo_spinner"
app:layout_constraintTop_toBottomOf="@id/lime_algo_list"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -119,7 +119,8 @@
<string name="assistant_create_account_using_email_on_our_web_platform">Créez un compte avec votre email ici :</string>
<string name="assistant_already_have_an_account">Vous avez déjà un compte ?</string>
<string name="assistant_sip_account_transport_protocol">Transport</string>
<string name="assistant_sip_account_lime_algorithm">Algorithme LIME</string>
<string name="assistant_sip_account_lime_algorithm">Algorithme(s) LIME (séparés par des virgules)</string>
<string name="assistant_sip_account_lime_algorithm_hint">Les valeurs autorisées sont : c25519, c448, c25519k512, c25519mlk512 and c448mlk1024</string>
<string name="assistant_third_party_sip_account_warning_explanation">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.</string>
<string name="assistant_third_party_sip_account_create_linphone_account">Je préfère créer un compte &appName;</string>
<string name="assistant_third_party_sip_account_warning_ok">J\'ai compris</string>

View file

@ -160,7 +160,8 @@
<string name="assistant_create_account_using_email_on_our_web_platform">Create an account with your email on:</string>
<string name="assistant_already_have_an_account">Already have an account?</string>
<string name="assistant_sip_account_transport_protocol">Transport</string>
<string name="assistant_sip_account_lime_algorithm">LIME algorithm</string>
<string name="assistant_sip_account_lime_algorithm">LIME algorithm(s) (comma separated)</string>
<string name="assistant_sip_account_lime_algorithm_hint">Allowed values are: c25519, c448, c25519k512, c25519mlk512 and c448mlk1024</string>
<string name="assistant_third_party_sip_account_warning_explanation">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.</string>
<string name="assistant_third_party_sip_account_create_linphone_account">I prefer to create a &appName; account</string>
<string name="assistant_third_party_sip_account_warning_ok">I understand</string>