Added hidden developer settings

This commit is contained in:
Sylvain Berfini 2025-04-03 17:21:43 +02:00
parent 32e4a2dbd6
commit 99870eced2
12 changed files with 316 additions and 44 deletions

View file

@ -109,6 +109,13 @@ class CorePreferences
config.setString("app", "device", value.trim())
}
@get:WorkerThread @set:WorkerThread
var showDeveloperSettings: Boolean
get() = config.getBool("ui", "show_developer_settings", false)
set(value) {
config.setBool("ui", "show_developer_settings", value)
}
// Call settings
// This won't be done if bluetooth or wired headset is used
@ -306,6 +313,10 @@ class CorePreferences
val hideAccountSettings: Boolean
get() = config.getBool("ui", "hide_account_settings", false)
@get:WorkerThread
val hideAdvancedSettings: Boolean
get() = config.getBool("ui", "hide_advanced_settings", false)
@get:WorkerThread
val hideAssistantCreateAccount: Boolean
get() = config.getBool("ui", "assistant_hide_create_account", false)

View file

@ -63,6 +63,8 @@ class HelpViewModel
val logsUploadInProgress = MutableLiveData<Boolean>()
val versionClickCount = MutableLiveData<Int>()
val newVersionAvailableEvent: MutableLiveData<Event<Pair<String, String>>> by lazy {
MutableLiveData<Event<Pair<String, String>>>()
}
@ -137,6 +139,7 @@ class HelpViewModel
init {
val currentVersion = BuildConfig.VERSION_NAME
version.value = currentVersion
versionClickCount.value = 0
val versionCode = BuildConfig.VERSION_CODE
val appGitDescribe = AppUtils.getString(R.string.linphone_app_version)
@ -166,6 +169,24 @@ class HelpViewModel
}
}
@UiThread
fun versionClicked() {
if (corePreferences.showDeveloperSettings == true) {
showRedToast(R.string.settings_developer_already_enabled_toast, R.drawable.warning_circle)
return
}
versionClickCount.value = (versionClickCount.value ?: 0) + 1
if (versionClickCount.value == 7) {
coreContext.postOnCoreThread {
Log.w("$TAG Version was clicked seven times, enabling developer settings")
corePreferences.showDeveloperSettings = true
showGreenToast(R.string.settings_developer_enabled_toast, R.drawable.gear)
}
}
}
@UiThread
fun toggleLogcat() {
val newValue = logcat.value == false

View file

@ -0,0 +1,63 @@
/*
* Copyright (c) 2010-2025 Belledonne Communications SARL.
*
* This file is part of linphone-android
* (see https://www.linphone.org).
*
* 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/>.
*/
package org.linphone.ui.main.settings.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.UiThread
import androidx.lifecycle.ViewModelProvider
import org.linphone.databinding.SettingsDeveloperFragmentBinding
import org.linphone.ui.main.fragment.GenericMainFragment
import org.linphone.ui.main.settings.viewmodel.SettingsViewModel
@UiThread
class SettingsDeveloperFragment : GenericMainFragment() {
private lateinit var binding: SettingsDeveloperFragmentBinding
private lateinit var viewModel: SettingsViewModel
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = SettingsDeveloperFragmentBinding.inflate(layoutInflater)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
postponeEnterTransition()
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this)[SettingsViewModel::class.java]
binding.lifecycleOwner = viewLifecycleOwner
binding.viewModel = viewModel
observeToastEvents(viewModel)
binding.setBackClickListener {
goBack()
}
startPostponedEnterTransition()
}
}

View file

@ -90,7 +90,7 @@ class SettingsFragment : GenericMainFragment() {
val label = viewModel.availableColorsNames[position]
val value = viewModel.availableColorsValues[position]
Log.i("$TAG Selected color is now [$label] ($value)")
// Be carefull not to create an infinite loop
// Be careful not to create an infinite loop
if (value != viewModel.color.value.orEmpty()) {
viewModel.setColor(value)
requireActivity().recreate()
@ -140,6 +140,13 @@ class SettingsFragment : GenericMainFragment() {
}
}
binding.setDeveloperSettingsClickListener {
if (findNavController().currentDestination?.id == R.id.settingsFragment) {
val action = SettingsFragmentDirections.actionSettingsFragmentToSettingsDeveloperFragment()
findNavController().navigate(action)
}
}
viewModel.recreateActivityEvent.observe(viewLifecycleOwner) {
it.consume {
Log.w("$TAG Recreate Activity")
@ -313,6 +320,7 @@ class SettingsFragment : GenericMainFragment() {
viewModel.reloadLdapServers()
viewModel.reloadConfiguredCardDavServers()
viewModel.reloadShowDeveloperSettings()
}
override fun onPause() {

View file

@ -188,6 +188,8 @@ class SettingsViewModel
)
// Advanced settings
val showAdvancedSettings = MutableLiveData<Boolean>()
val startAtBoot = MutableLiveData<Boolean>()
val keepAliveThirdPartyAccountsService = MutableLiveData<Boolean>()
val useSmffForCallRecording = MutableLiveData<Boolean>()
@ -202,7 +204,6 @@ class SettingsViewModel
val mediaEncryptionLabels = arrayListOf<String>()
private val mediaEncryptionValues = arrayListOf<MediaEncryption>()
val mediaEncryptionMandatory = MutableLiveData<Boolean>()
val createEndToEndEncryptedConferences = MutableLiveData<Boolean>()
val acceptEarlyMedia = MutableLiveData<Boolean>()
val ringDuringEarlyMedia = MutableLiveData<Boolean>()
val allowOutgoingEarlyMedia = MutableLiveData<Boolean>()
@ -223,6 +224,11 @@ class SettingsViewModel
val expandVideoCodecs = MutableLiveData<Boolean>()
val videoCodecs = MutableLiveData<List<CodecModel>>()
// Developer settings
val showDeveloperSettings = MutableLiveData<Boolean>()
val createEndToEndEncryptedConferences = MutableLiveData<Boolean>()
private val coreListener = object : CoreListenerStub() {
@WorkerThread
override fun onAudioDevicesListUpdated(core: Core) {
@ -249,6 +255,8 @@ class SettingsViewModel
ldapAvailable.postValue(core.ldapAvailable())
showThemeSelector.postValue(corePreferences.darkModeAllowed)
showColorSelector.postValue(corePreferences.changeMainColorAllowed)
showAdvancedSettings.postValue(!corePreferences.hideAdvancedSettings)
showDeveloperSettings.postValue(corePreferences.showDeveloperSettings)
}
showContactsSettings.value = true
@ -328,7 +336,6 @@ class SettingsViewModel
fileSharingServerUrl.postValue(core.fileTransferServer)
remoteProvisioningUrl.postValue(core.provisioningUri)
createEndToEndEncryptedConferences.postValue(corePreferences.createEndToEndEncryptedMeetingsAndGroupCalls)
acceptEarlyMedia.postValue(corePreferences.acceptEarlyMedia)
ringDuringEarlyMedia.postValue(core.ringDuringIncomingEarlyMedia)
allowOutgoingEarlyMedia.postValue(corePreferences.allowOutgoingEarlyMedia)
@ -338,6 +345,8 @@ class SettingsViewModel
setupMediaEncryption()
setupAudioDevices()
setupCodecs()
createEndToEndEncryptedConferences.postValue(corePreferences.createEndToEndEncryptedMeetingsAndGroupCalls)
}
}
@ -792,16 +801,6 @@ class SettingsViewModel
}
}
@UiThread
fun toggleConferencesEndToEndEncryption() {
val newValue = createEndToEndEncryptedConferences.value == false
coreContext.postOnCoreThread { core ->
corePreferences.createEndToEndEncryptedMeetingsAndGroupCalls = newValue
createEndToEndEncryptedConferences.postValue(newValue)
}
}
@UiThread
fun toggleAcceptEarlyMedia() {
val newValue = acceptEarlyMedia.value == false
@ -1031,4 +1030,31 @@ class SettingsViewModel
}
calibratedEchoCancellerValue.postValue(value)
}
@UiThread
fun toggleDeveloperSettings() {
val newValue = showDeveloperSettings.value == false
coreContext.postOnCoreThread { core ->
corePreferences.showDeveloperSettings = newValue
showDeveloperSettings.postValue(newValue)
}
}
@UiThread
fun reloadShowDeveloperSettings() {
coreContext.postOnCoreThread {
showDeveloperSettings.postValue(corePreferences.showDeveloperSettings)
}
}
@UiThread
fun toggleConferencesEndToEndEncryption() {
val newValue = createEndToEndEncryptedConferences.value == false
coreContext.postOnCoreThread { core ->
corePreferences.createEndToEndEncryptedMeetingsAndGroupCalls = newValue
createEndToEndEncryptedConferences.postValue(newValue)
}
}
}

View file

@ -144,7 +144,8 @@
<LinearLayout
android:id="@+id/version"
android:layout_width="wrap_content"
android:onClick="@{() -> viewModel.versionClicked()}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="MissingConstraints">

View file

@ -167,34 +167,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/media_encryption" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
android:onClick="@{() -> viewModel.toggleConferencesEndToEndEncryption()}"
android:id="@+id/e2e_encrypted_conferences_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="10dp"
android:text="@string/settings_advanced_create_e2e_encrypted_conferences_title"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintTop_toTopOf="@id/e2e_encrypted_conferences_switch"
app:layout_constraintBottom_toBottomOf="@id/e2e_encrypted_conferences_switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/e2e_encrypted_conferences_switch"/>
<com.google.android.material.materialswitch.MaterialSwitch
style="@style/material_switch_style"
android:id="@+id/e2e_encrypted_conferences_switch"
android:onClick="@{() -> viewModel.toggleConferencesEndToEndEncryption()}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:checked="@{viewModel.createEndToEndEncryptedConferences}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/media_encryption_mandatory_switch" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
android:onClick="@{() -> viewModel.toggleAcceptEarlyMedia()}"
@ -221,7 +193,7 @@
android:layout_marginEnd="16dp"
android:checked="@{viewModel.acceptEarlyMedia}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/e2e_encrypted_conferences_switch" />
app:layout_constraintTop_toBottomOf="@id/media_encryption_mandatory_switch" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="backClickListener"
type="View.OnClickListener" />
<variable
name="viewModel"
type="org.linphone.ui.main.settings.viewmodel.SettingsViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/color_background_contrast_in_dark_mode">
<ImageView
android:id="@+id/back"
android:onClick="@{backClickListener}"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:padding="15dp"
android:src="@drawable/caret_left"
android:contentDescription="@string/content_description_go_back_icon"
app:tint="?attr/color_main1_500"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/title" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/main_page_title_style"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="@dimen/top_bar_height"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="@string/settings_developer_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/back"
app:layout_constraintTop_toTopOf="parent"/>
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
android:background="?attr/color_grey_100"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
android:onClick="@{() -> viewModel.toggleDeveloperSettings()}"
android:id="@+id/settings_developer_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="10dp"
android:text="@string/settings_developer_show_title"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintTop_toTopOf="@id/settings_developer_switch"
app:layout_constraintBottom_toBottomOf="@id/settings_developer_switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/settings_developer_switch"/>
<com.google.android.material.materialswitch.MaterialSwitch
style="@style/material_switch_style"
android:id="@+id/settings_developer_switch"
android:onClick="@{() -> viewModel.toggleDeveloperSettings()}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:checked="@{viewModel.showDeveloperSettings}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
android:onClick="@{() -> viewModel.toggleConferencesEndToEndEncryption()}"
android:id="@+id/e2e_encrypted_conferences_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="10dp"
android:text="@string/settings_advanced_create_e2e_encrypted_conferences_title"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintTop_toTopOf="@id/e2e_encrypted_conferences_switch"
app:layout_constraintBottom_toBottomOf="@id/e2e_encrypted_conferences_switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/e2e_encrypted_conferences_switch"/>
<com.google.android.material.materialswitch.MaterialSwitch
style="@style/material_switch_style"
android:id="@+id/e2e_encrypted_conferences_switch"
android:onClick="@{() -> viewModel.toggleConferencesEndToEndEncryption()}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:checked="@{viewModel.createEndToEndEncryptedConferences}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_developer_switch" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -14,6 +14,9 @@
<variable
name="advancedSettingsClickListener"
type="View.OnClickListener" />
<variable
name="developerSettingsClickListener"
type="View.OnClickListener" />
<variable
name="viewModel"
type="org.linphone.ui.main.settings.viewmodel.SettingsViewModel" />
@ -315,10 +318,30 @@
android:text="@string/settings_advanced_title"
android:drawableEnd="@drawable/caret_right"
android:drawableTint="?attr/color_main2_600"
android:visibility="@{viewModel.showAdvancedSettings ? View.VISIBLE : View.GONE}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tunnel_settings"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/section_header_style"
android:id="@+id/developer_settings"
android:onClick="@{developerSettingsClickListener}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_marginStart="26dp"
android:layout_marginEnd="26dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="@dimen/screen_bottom_margin"
android:text="@string/settings_developer_title"
android:drawableEnd="@drawable/caret_right"
android:drawableTint="?attr/color_main2_600"
android:visibility="@{viewModel.showDeveloperSettings ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintVertical_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tunnel_settings"
app:layout_constraintTop_toBottomOf="@id/advanced_settings"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -137,6 +137,14 @@
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right" />
<action
android:id="@+id/action_settingsFragment_to_settingsDeveloperFragment"
app:destination="@id/settingsDeveloperFragment"
app:launchSingleTop="true"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right" />
</fragment>
<action
@ -432,4 +440,10 @@
android:label="RecordingMediaPlayerFragment"
tools:layout="@layout/recording_player_fragment"/>
<fragment
android:id="@+id/settingsDeveloperFragment"
android:name="org.linphone.ui.main.settings.fragment.SettingsDeveloperFragment"
android:label="SettingsDeveloperFragment"
tools:layout="@layout/settings_developer_fragment"/>
</navigation>

View file

@ -289,6 +289,11 @@
<string name="settings_advanced_video_codecs_title">Codecs vidéo</string>
<string name="settings_advanced_go_to_android_app_settings_title">Paramètres Android de &appName;</string>
<string name="settings_developer_title">Paramètres développeurs</string>
<string name="settings_developer_show_title">Afficher les paramètres développeurs</string>
<string name="settings_developer_enabled_toast">Paramètres développeurs activés</string>
<string name="settings_developer_already_enabled_toast">Paramètres développeurs déjà activés</string>
<!-- Account profile & settings -->
<string name="manage_account_title">Mon compte</string>
<string name="manage_account_details_title">Détails</string>

View file

@ -329,6 +329,11 @@
<string name="settings_advanced_video_codecs_title">Video codecs</string>
<string name="settings_advanced_go_to_android_app_settings_title">&appName; Android settings</string>
<string name="settings_developer_title">Developer settings</string>
<string name="settings_developer_show_title">Show developer settings</string>
<string name="settings_developer_enabled_toast">Developer settings enabled</string>
<string name="settings_developer_already_enabled_toast">Developer settings already enabled</string>
<!-- Account profile & settings -->
<string name="manage_account_title">Manage account</string>
<string name="manage_account_details_title">Details</string>