Skip to content
Snippets Groups Projects
Commit 66de288f authored by Adrien Béraud's avatar Adrien Béraud
Browse files

settings: split Jami/SIP and allow to change name server

Change-Id: Ied4bbb9edc1ef83a9d175c17d32e76623301392d
parent 409f7dab
No related branches found
No related tags found
No related merge requests found
......@@ -48,9 +48,6 @@ class AdvancedAccountFragment : BasePreferenceFragment<AdvancedAccountPresenter>
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
super.onCreatePreferences(savedInstanceState, rootKey)
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.account_advanced_prefs)
presenter.init(requireArguments().getString(AccountEditionFragment.ACCOUNT_ID_KEY)!!)
}
......@@ -63,7 +60,7 @@ class AdvancedAccountFragment : BasePreferenceFragment<AdvancedAccountPresenter>
when (preference) {
is EditTextIntegerPreference -> {
val f = EditTextPreferenceDialog.newInstance(
preference.getKey(),
preference.key,
EditorInfo.TYPE_CLASS_NUMBER
)
f.setTargetFragment(this, 0)
......@@ -72,7 +69,7 @@ class AdvancedAccountFragment : BasePreferenceFragment<AdvancedAccountPresenter>
is PasswordPreference -> {
val f = EditTextPreferenceDialog.newInstance(
preference.getKey(),
preference.key,
EditorInfo.TYPE_CLASS_TEXT or EditorInfo.TYPE_TEXT_VARIATION_PASSWORD
)
f.setTargetFragment(this, 0)
......@@ -85,6 +82,13 @@ class AdvancedAccountFragment : BasePreferenceFragment<AdvancedAccountPresenter>
}
override fun initView(config: AccountConfig, networkInterfaces: ArrayList<CharSequence>) {
val isJamiAccount = config[ConfigKey.ACCOUNT_TYPE] == AccountConfig.ACCOUNT_TYPE_JAMI
if (isJamiAccount)
addPreferencesFromResource(R.xml.account_advanced_prefs)
else
addPreferencesFromResource(R.xml.account_sip_prefs)
for (confKey in config.keys) {
val pref = findPreference<Preference>(confKey.key)
if (pref != null) {
......@@ -98,7 +102,10 @@ class AdvancedAccountFragment : BasePreferenceFragment<AdvancedAccountPresenter>
listPref.summary = value
listPref.value = value
} else if (!confKey.isBool) {
val value = config[confKey]
var value = config[confKey]
if (confKey == ConfigKey.RINGNS_HOST && value.isEmpty()) {
value = getString(R.string.default_value)
}
pref.summary = value
if (pref is EditTextPreference) {
pref.text = value
......@@ -108,7 +115,6 @@ class AdvancedAccountFragment : BasePreferenceFragment<AdvancedAccountPresenter>
}
}
}
val isJamiAccount = config[ConfigKey.ACCOUNT_TYPE] == AccountConfig.ACCOUNT_TYPE_JAMI
val bootstrap = findPreference<Preference>(ConfigKey.ACCOUNT_HOSTNAME.key)
bootstrap?.isVisible = isJamiAccount
val sipLocalPort = findPreference<Preference>(ConfigKey.LOCAL_PORT.key)
......
......@@ -86,6 +86,7 @@ along with this program; if not, write to the Free Software
<string name="account_alias_label">Account name</string>
<string name="account_hostname_label">Hostname</string>
<string name="account_bootstrap_label">Bootstrap</string>
<string name="account_name_server_label">Name server</string>
<string name="account_username_label">Username</string>
<string name="account_password_label">Password</string>
<string name="account_optionnal_category">Optional Settings</string>
......@@ -140,9 +141,12 @@ along with this program; if not, write to the Free Software
<string name="account_published_same_as_local_label">Published same as local</string>
<string name="account_published_port_label">Published Port</string>
<string name="account_published_address_label">Published Address</string>
<string name="account_connectivity_label">Peer-to-peer connectivity</string>
<string name="disabled">Disabled</string>
<string name="enabled">Enabled</string>
<string name="default_value">Default</string>
<string name="account_dht_label" translatable="false">OpenDHT</string>
<string name="account_proxy_label">DHT proxy</string>
<string name="account_proxy_enable_label">Use DHT proxy</string>
<string name="account_proxy_list_enable_label">Use DHT proxy list</string>
......
......@@ -16,36 +16,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/account_name_server_label">
<EditTextPreference
android:key="Account.hostname"
android:key="RingNS.uri"
android:persistent="false"
android:summary=""
android:title="@string/account_bootstrap_label" />
<cx.ring.views.EditTextIntegerPreference
android:defaultValue="60"
android:key="Account.registrationExpire"
android:persistent="false"
android:title="@string/account_registration_exp_label" />
<ListPreference
android:key="Account.localInterface"
android:persistent="false"
android:title="@string/account_local_interface_label" />
<cx.ring.views.EditTextIntegerPreference
android:defaultValue="5060"
android:key="Account.localPort"
android:persistent="false"
android:title="@string/account_local_port_label" />
android:title="@string/account_name_server_label" />
</PreferenceCategory>
<SwitchPreferenceCompat
android:key="Account.upnpEnabled"
<PreferenceCategory android:title="@string/account_dht_label">
<EditTextPreference
android:key="Account.hostname"
android:persistent="false"
android:title="@string/account_upnp_label" />
android:summary=""
android:title="@string/account_bootstrap_label" />
<PreferenceCategory android:title="@string/account_proxy_label">
<SwitchPreferenceCompat
android:icon="@drawable/baseline_cloud_24"
android:key="Account.proxyEnabled"
......@@ -78,10 +64,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:persistent="false"
android:summary=""
android:title="@string/account_proxy_server_list_label"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_peer_discovery_label">
<SwitchPreferenceCompat
android:icon="@drawable/baseline_grain_24"
android:key="Account.peerDiscovery"
......@@ -91,22 +73,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_published_address_label">
<PreferenceCategory android:title="@string/account_connectivity_label">
<SwitchPreferenceCompat
android:key="STUN.enable"
android:persistent="false"
android:summaryOff="@string/disabled"
android:summaryOn="@string/enabled"
android:title="@string/account_stun_enable_label" />
<EditTextPreference
android:defaultValue=""
android:dependency="STUN.enable"
android:key="STUN.server"
android:key="Account.upnpEnabled"
android:persistent="false"
android:summary=""
android:title="@string/account_stun_server_label" />
android:title="@string/account_upnp_label" />
<SwitchPreferenceCompat
android:key="TURN.enable"
......@@ -139,24 +111,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:summary=""
android:title="@string/account_turn_password_label" />
<CheckBoxPreference
android:disableDependentsState="true"
android:key="Account.publishedSameAsLocal"
android:persistent="false"
android:title="@string/account_published_same_as_local_label" />
<cx.ring.views.EditTextIntegerPreference
android:defaultValue="5060"
android:dependency="Account.publishedSameAsLocal"
android:key="Account.publishedPort"
android:persistent="false"
android:title="@string/account_published_port_label" />
<EditTextPreference
android:dependency="Account.publishedSameAsLocal"
android:key="Account.publishedAddress"
android:persistent="false"
android:title="@string/account_published_address_label" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_rtp_port_range">
......
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2004-2024 Savoir-faire Linux Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<cx.ring.views.EditTextIntegerPreference
android:defaultValue="60"
android:key="Account.registrationExpire"
android:persistent="false"
android:title="@string/account_registration_exp_label" />
<EditTextPreference
android:key="Account.hostname"
android:persistent="false"
android:summary=""
android:title="@string/account_bootstrap_label" />
<PreferenceCategory android:title="@string/account_published_address_label">
<SwitchPreferenceCompat
android:key="Account.upnpEnabled"
android:persistent="false"
android:title="@string/account_upnp_label" />
<ListPreference
android:key="Account.localInterface"
android:persistent="false"
android:title="@string/account_local_interface_label" />
<cx.ring.views.EditTextIntegerPreference
android:defaultValue="5060"
android:key="Account.localPort"
android:persistent="false"
android:title="@string/account_local_port_label" />
<SwitchPreferenceCompat
android:key="STUN.enable"
android:persistent="false"
android:summaryOff="@string/disabled"
android:summaryOn="@string/enabled"
android:title="@string/account_stun_enable_label" />
<EditTextPreference
android:defaultValue=""
android:dependency="STUN.enable"
android:key="STUN.server"
android:persistent="false"
android:summary=""
android:title="@string/account_stun_server_label" />
<SwitchPreferenceCompat
android:key="TURN.enable"
android:persistent="false"
android:summaryOff="@string/disabled"
android:summaryOn="@string/enabled"
android:title="@string/account_turn_enable_label" />
<EditTextPreference
android:defaultValue=""
android:dependency="TURN.enable"
android:key="TURN.server"
android:persistent="false"
android:summary=""
android:title="@string/account_turn_server_label" />
<EditTextPreference
android:defaultValue=""
android:dependency="TURN.enable"
android:key="TURN.username"
android:persistent="false"
android:summary=""
android:title="@string/account_turn_username_label" />
<cx.ring.views.PasswordPreference
android:defaultValue=""
android:dependency="TURN.enable"
android:key="TURN.password"
android:persistent="false"
android:summary=""
android:title="@string/account_turn_password_label" />
<CheckBoxPreference
android:disableDependentsState="true"
android:key="Account.publishedSameAsLocal"
android:persistent="false"
android:title="@string/account_published_same_as_local_label" />
<cx.ring.views.EditTextIntegerPreference
android:defaultValue="5060"
android:dependency="Account.publishedSameAsLocal"
android:key="Account.publishedPort"
android:persistent="false"
android:title="@string/account_published_port_label" />
<EditTextPreference
android:dependency="Account.publishedSameAsLocal"
android:key="Account.publishedAddress"
android:persistent="false"
android:title="@string/account_published_address_label" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_rtp_port_range">
<cx.ring.views.EditTextIntegerPreference
android:defaultValue="0"
android:key="Account.audioPortMin"
android:persistent="false"
android:title="@string/account_rtp_min_port" />
<cx.ring.views.EditTextIntegerPreference
android:defaultValue="65535"
android:key="Account.audioPortMax"
android:persistent="false"
android:title="@string/account_rtp_max_port" />
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment