Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
linphone-android
Commits
439e1153
Commit
439e1153
authored
6 months ago
by
Sylvain Berfini
Browse files
Options
Download
Patches
Plain Diff
Added media encryption & media encryption mandatory advanced settings
parent
722840f1
master
feature/show_unsecure_conversation_event_at_top
feature/use_theme_main_color_for_icon_and_splashscreen
fix/insistent_notification
fix/restore_previous_release_ringtone_player
fix/telecom_default_audio_endpoint
release/6.0
6.1.0-alpha
6.0.0
6.0.0-beta
1 merge request
!1512
Hide software echo canceller toggle
Pipeline
#82916
canceled with stage
in 4 minutes and 1 second
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
app/src/main/java/org/linphone/ui/main/settings/fragment/SettingsAdvancedFragment.kt
+26
-0
...one/ui/main/settings/fragment/SettingsAdvancedFragment.kt
app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt
+54
-0
.../linphone/ui/main/settings/viewmodel/SettingsViewModel.kt
app/src/main/res/layout/settings_advanced_fragment.xml
+74
-1
app/src/main/res/layout/settings_advanced_fragment.xml
app/src/main/res/values-fr/strings.xml
+2
-0
app/src/main/res/values-fr/strings.xml
app/src/main/res/values/strings.xml
+2
-0
app/src/main/res/values/strings.xml
with
158 additions
and
1 deletion
app/src/main/java/org/linphone/ui/main/settings/fragment/SettingsAdvancedFragment.kt
+
26
−
0
View file @
439e1153
...
...
@@ -42,6 +42,15 @@ class SettingsAdvancedFragment : GenericMainFragment() {
private
lateinit
var
viewModel
:
SettingsViewModel
private
val
mediaEncryptionDropdownListener
=
object
:
AdapterView
.
OnItemSelectedListener
{
override
fun
onItemSelected
(
parent
:
AdapterView
<
*
>?,
view
:
View
?,
position
:
Int
,
id
:
Long
)
{
viewModel
.
setMediaEncryption
(
position
)
}
override
fun
onNothingSelected
(
parent
:
AdapterView
<
*
>?)
{
}
}
private
val
inputAudioDeviceDropdownListener
=
object
:
AdapterView
.
OnItemSelectedListener
{
override
fun
onItemSelected
(
parent
:
AdapterView
<
*
>?,
view
:
View
?,
position
:
Int
,
id
:
Long
)
{
viewModel
.
setInputAudioDevice
(
position
)
...
...
@@ -83,6 +92,10 @@ class SettingsAdvancedFragment : GenericMainFragment() {
goBack
()
}
viewModel
.
mediaEncryptionIndex
.
observe
(
viewLifecycleOwner
)
{
setupMediaEncryptionPicker
()
}
viewModel
.
inputAudioDeviceIndex
.
observe
(
viewLifecycleOwner
)
{
setupInputAudioDevicePicker
()
}
...
...
@@ -101,6 +114,19 @@ class SettingsAdvancedFragment : GenericMainFragment() {
super
.
onPause
()
}
private
fun
setupMediaEncryptionPicker
()
{
val
index
=
viewModel
.
mediaEncryptionIndex
.
value
?:
0
val
adapter
=
ArrayAdapter
(
requireContext
(),
R
.
layout
.
drop_down_item
,
viewModel
.
mediaEncryptionLabels
)
adapter
.
setDropDownViewResource
(
R
.
layout
.
generic_dropdown_cell
)
binding
.
mediaEncryption
.
adapter
=
adapter
binding
.
mediaEncryption
.
onItemSelectedListener
=
mediaEncryptionDropdownListener
binding
.
mediaEncryption
.
setSelection
(
index
)
}
private
fun
setupInputAudioDevicePicker
()
{
val
index
=
viewModel
.
inputAudioDeviceIndex
.
value
?:
0
val
adapter
=
ArrayAdapter
(
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt
+
54
−
0
View file @
439e1153
...
...
@@ -33,6 +33,7 @@ import org.linphone.core.CoreListenerStub
import
org.linphone.core.EcCalibratorStatus
import
org.linphone.core.Factory
import
org.linphone.core.FriendList
import
org.linphone.core.MediaEncryption
import
org.linphone.core.Tunnel
import
org.linphone.core.VFS
import
org.linphone.core.tools.Log
...
...
@@ -179,6 +180,11 @@ class SettingsViewModel @UiThread constructor() : GenericViewModel() {
val
deviceName
=
MutableLiveData
<
String
>()
val
remoteProvisioningUrl
=
MutableLiveData
<
String
>()
val
mediaEncryptionIndex
=
MutableLiveData
<
Int
>()
val
mediaEncryptionLabels
=
arrayListOf
<
String
>()
private
val
mediaEncryptionValues
=
arrayListOf
<
MediaEncryption
>()
val
mediaEncryptionMandatory
=
MutableLiveData
<
Boolean
>()
val
expandAudioDevices
=
MutableLiveData
<
Boolean
>()
val
inputAudioDeviceIndex
=
MutableLiveData
<
Int
>()
val
inputAudioDeviceLabels
=
arrayListOf
<
String
>()
...
...
@@ -291,6 +297,7 @@ class SettingsViewModel @UiThread constructor() : GenericViewModel() {
deviceName
.
postValue
(
corePreferences
.
deviceName
)
remoteProvisioningUrl
.
postValue
(
core
.
provisioningUri
)
setupMediaEncryption
()
setupAudioDevices
()
setupCodecs
()
}
...
...
@@ -622,6 +629,53 @@ class SettingsViewModel @UiThread constructor() : GenericViewModel() {
}
}
@WorkerThread
private
fun
setupMediaEncryption
()
{
val
core
=
coreContext
.
core
mediaEncryptionLabels
.
clear
()
mediaEncryptionValues
.
clear
()
var
index
=
0
val
defaultMediaEncryption
=
core
.
mediaEncryption
Log
.
i
(
"$TAG Current media encryption is [$defaultMediaEncryption]"
)
for
(
encryption
in
MediaEncryption
.
entries
)
{
if
(
core
.
isMediaEncryptionSupported
(
encryption
))
{
mediaEncryptionLabels
.
add
(
encryption
.
toString
())
mediaEncryptionValues
.
add
(
encryption
)
if
(
encryption
==
defaultMediaEncryption
)
{
mediaEncryptionIndex
.
postValue
(
index
)
}
index
+=
1
}
}
mediaEncryptionMandatory
.
postValue
(
core
.
isMediaEncryptionMandatory
)
}
@UiThread
fun
setMediaEncryption
(
index
:
Int
)
{
coreContext
.
postOnCoreThread
{
core
->
val
mediaEncryption
=
mediaEncryptionValues
[
index
]
core
.
mediaEncryption
=
mediaEncryption
if
(
mediaEncryption
==
MediaEncryption
.
None
)
{
core
.
isMediaEncryptionMandatory
=
false
mediaEncryptionMandatory
.
postValue
(
false
)
}
}
}
@UiThread
fun
toggleMediaEncryptionMandatory
()
{
val
newValue
=
mediaEncryptionMandatory
.
value
==
false
coreContext
.
postOnCoreThread
{
core
->
core
.
isMediaEncryptionMandatory
=
newValue
mediaEncryptionMandatory
.
postValue
(
newValue
)
}
}
@UiThread
fun
updateDeviceName
()
{
coreContext
.
postOnCoreThread
{
...
...
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/settings_advanced_fragment.xml
+
74
−
1
View file @
439e1153
...
...
@@ -100,6 +100,79 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/keep_alive_service_switch"
/>
<androidx.appcompat.widget.AppCompatTextView
style=
"@style/settings_title_style"
android:id=
"@+id/media_encryption_label"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"16dp"
android:paddingTop=
"8dp"
android:paddingBottom=
"8dp"
android:text=
"@string/settings_advanced_media_encryption_title"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/enable_fec_switch"
/>
<androidx.appcompat.widget.AppCompatSpinner
style=
"@style/default_text_style"
android:id=
"@+id/media_encryption"
android:layout_width=
"0dp"
android:layout_height=
"50dp"
android:layout_marginEnd=
"16dp"
android:paddingStart=
"20dp"
android:paddingEnd=
"20dp"
android:textSize=
"14sp"
android:textColor=
"@color/gray_main2_600"
android:gravity=
"center_vertical"
android:overlapAnchor=
"false"
android:dropDownVerticalOffset=
"2dp"
android:spinnerMode=
"dropdown"
android:popupBackground=
"@drawable/shape_squircle_white_background"
android:background=
"@drawable/edit_text_background"
app:layout_constraintTop_toBottomOf=
"@id/media_encryption_label"
app:layout_constraintStart_toStartOf=
"@id/media_encryption_label"
app:layout_constraintEnd_toEndOf=
"parent"
/>
<ImageView
android:id=
"@+id/media_encryption_caret"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@drawable/caret_down"
android:contentDescription=
"@null"
app:layout_constraintTop_toTopOf=
"@id/media_encryption"
app:layout_constraintBottom_toBottomOf=
"@id/media_encryption"
app:layout_constraintEnd_toEndOf=
"@id/media_encryption"
/>
<androidx.appcompat.widget.AppCompatTextView
style=
"@style/settings_title_style"
android:onClick=
"@{() -> viewModel.toggleMediaEncryptionMandatory()}"
android:id=
"@+id/media_encryption_mandatory_title"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginEnd=
"10dp"
android:text=
"@string/settings_advanced_media_encryption_mandatory_title"
android:maxLines=
"2"
android:ellipsize=
"end"
app:layout_constraintTop_toTopOf=
"@id/media_encryption_mandatory_switch"
app:layout_constraintBottom_toBottomOf=
"@id/media_encryption_mandatory_switch"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/media_encryption_mandatory_switch"
/>
<com.google.android.material.materialswitch.MaterialSwitch
style=
"@style/material_switch_style"
android:id=
"@+id/media_encryption_mandatory_switch"
android:onClick=
"@{() -> viewModel.toggleMediaEncryptionMandatory()}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:layout_marginEnd=
"16dp"
android:checked=
"@{viewModel.mediaEncryptionMandatory}"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/media_encryption"
/>
<androidx.appcompat.widget.AppCompatTextView
style=
"@style/settings_title_style"
android:id=
"@+id/push_notifications_title"
...
...
@@ -126,7 +199,7 @@
android:paddingBottom=
"8dp"
android:text=
"@string/settings_advanced_device_id"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/
enable_fec
_switch"
/>
app:layout_constraintTop_toBottomOf=
"@id/
media_encryption_mandatory
_switch"
/>
<androidx.appcompat.widget.AppCompatEditText
style=
"@style/default_text_style"
...
...
This diff is collapsed.
Click to expand it.
app/src/main/res/values-fr/strings.xml
+
2
−
0
View file @
439e1153
...
...
@@ -252,6 +252,8 @@
<string
name=
"settings_advanced_title"
>
Paramètres avancés
</string>
<string
name=
"settings_advanced_keep_alive_service_title"
>
Garder l\'app en vie via un Service
</string>
<string
name=
"settings_advanced_device_id"
>
Nom du périphérique
</string>
<string
name=
"settings_advanced_media_encryption_title"
>
Chiffrement du média
</string>
<string
name=
"settings_advanced_media_encryption_mandatory_title"
>
Rendre le chiffrement du média obligatoire
</string>
<string
name=
"settings_advanced_remote_provisioning_url"
>
URL de configuration distante
</string>
<string
name=
"settings_advanced_download_apply_remote_provisioning"
>
Télécharger
&
appliquer
</string>
<string
name=
"settings_advanced_audio_devices_title"
>
Périphériques audio
</string>
...
...
This diff is collapsed.
Click to expand it.
app/src/main/res/values/strings.xml
+
2
−
0
View file @
439e1153
...
...
@@ -289,6 +289,8 @@
<string
name=
"settings_advanced_title"
>
Advanced settings
</string>
<string
name=
"settings_advanced_keep_alive_service_title"
>
Keep app alive using Service
</string>
<string
name=
"settings_advanced_device_id"
>
Device ID
</string>
<string
name=
"settings_advanced_media_encryption_title"
>
Media encryption
</string>
<string
name=
"settings_advanced_media_encryption_mandatory_title"
>
Media encryption mandatory
</string>
<string
name=
"settings_advanced_remote_provisioning_url"
>
Remote provisioning URL
</string>
<string
name=
"settings_advanced_download_apply_remote_provisioning"
>
Download
&
apply
</string>
<string
name=
"settings_advanced_audio_devices_title"
>
Audio devices
</string>
...
...
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets