mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added device ID setting + fixed some wrong styles
This commit is contained in:
parent
ed1cf58fd4
commit
bed9288f21
8 changed files with 79 additions and 13 deletions
|
|
@ -806,8 +806,14 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun computeUserAgent() {
|
||||
val deviceName = AppUtils.getDeviceName(context)
|
||||
fun computeUserAgent() {
|
||||
if (corePreferences.deviceName.isEmpty()) {
|
||||
Log.i("$TAG Device name not fetched yet, doing it now")
|
||||
corePreferences.deviceName = AppUtils.getDeviceName(context)
|
||||
Log.i("$TAG Fetched device name is [${corePreferences.deviceName}]")
|
||||
}
|
||||
val deviceName = corePreferences.deviceName
|
||||
|
||||
val appName = context.getString(org.linphone.R.string.app_name)
|
||||
val androidVersion = BuildConfig.VERSION_NAME
|
||||
val userAgent = "${appName}Android/$androidVersion ($deviceName) LinphoneSDK"
|
||||
|
|
|
|||
|
|
@ -90,6 +90,13 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
config.setBool("app", "keep_service_alive", value)
|
||||
}
|
||||
|
||||
@get:WorkerThread @set:WorkerThread
|
||||
var deviceName: String
|
||||
get() = config.getString("app", "device", "").orEmpty().trim()
|
||||
set(value) {
|
||||
config.setString("app", "device", value.trim())
|
||||
}
|
||||
|
||||
/* Call settings */
|
||||
|
||||
// This won't be done if bluetooth or wired headset is used
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ class SettingsAdvancedFragment : GenericMainFragment() {
|
|||
}
|
||||
|
||||
override fun onPause() {
|
||||
viewModel.updateDeviceName()
|
||||
viewModel.updateRemoteProvisioningUrl()
|
||||
|
||||
super.onPause()
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ class SettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
// Advanced settings
|
||||
val keepAliveThirdPartyAccountsService = MutableLiveData<Boolean>()
|
||||
|
||||
val deviceName = MutableLiveData<String>()
|
||||
val remoteProvisioningUrl = MutableLiveData<String>()
|
||||
|
||||
val expandAudioDevices = MutableLiveData<Boolean>()
|
||||
|
|
@ -252,6 +253,7 @@ class SettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
|
||||
keepAliveThirdPartyAccountsService.postValue(corePreferences.keepServiceAlive)
|
||||
|
||||
deviceName.postValue(corePreferences.deviceName)
|
||||
remoteProvisioningUrl.postValue(core.provisioningUri)
|
||||
|
||||
setupAudioDevices()
|
||||
|
|
@ -556,10 +558,24 @@ class SettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun updateDeviceName() {
|
||||
coreContext.postOnCoreThread {
|
||||
val newDeviceName = deviceName.value.orEmpty().trim()
|
||||
if (newDeviceName != corePreferences.deviceName) {
|
||||
corePreferences.deviceName = newDeviceName
|
||||
Log.i(
|
||||
"$TAG Updated device name to [${corePreferences.deviceName}], re-compute user-agent"
|
||||
)
|
||||
coreContext.computeUserAgent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun updateRemoteProvisioningUrl() {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val newProvisioningUri = remoteProvisioningUrl.value.orEmpty()
|
||||
val newProvisioningUri = remoteProvisioningUrl.value.orEmpty().trim()
|
||||
if (newProvisioningUri != core.provisioningUri) {
|
||||
Log.i("$TAG Updating remote provisioning URI to [$newProvisioningUri]")
|
||||
if (newProvisioningUri.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/prefix"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/sip_address_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -237,7 +237,7 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/sip_address_label"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/device_id_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -274,7 +274,7 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/device_id_label"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/display_name_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -308,7 +308,7 @@
|
|||
app:layout_constraintEnd_toEndOf="@id/details_background"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/prefix_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -328,7 +328,7 @@
|
|||
android:layout_marginStart="8dp"
|
||||
android:src="@drawable/info"
|
||||
android:contentDescription="@string/content_description_click_for_more_info"
|
||||
app:tint="@color/black"
|
||||
app:tint="?attr/color_main2_600"
|
||||
app:layout_constraintTop_toTopOf="@id/prefix_label"
|
||||
app:layout_constraintBottom_toBottomOf="@id/prefix_label"
|
||||
app:layout_constraintStart_toEndOf="@id/prefix_label" />
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/keep_alive_service_switch" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/push_notifications_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -116,7 +116,41 @@
|
|||
app:layout_constraintEnd_toStartOf="@id/keep_alive_service_switch"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/device_id_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_device_id"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/enable_fec_switch"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/device_id"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:text="@={viewModel.deviceName}"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_main2_600"
|
||||
android:maxLines="1"
|
||||
android:background="@drawable/edit_text_background"
|
||||
android:inputType="text|textUri"
|
||||
android:hint="@string/settings_advanced_device_id"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintWidth_max="@dimen/text_input_max_width"
|
||||
app:layout_constraintTop_toBottomOf="@id/device_id_label"
|
||||
app:layout_constraintStart_toStartOf="@id/device_id_label"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/remote_provisioning_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -126,7 +160,7 @@
|
|||
android:paddingBottom="8dp"
|
||||
android:text="@string/settings_advanced_remote_provisioning_url"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/enable_fec_switch"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/device_id"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
style="@style/default_text_style"
|
||||
|
|
@ -203,7 +237,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/input_audio_device_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -250,7 +284,7 @@
|
|||
app:layout_constraintEnd_toEndOf="@id/input_audio_device"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/output_audio_device_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@
|
|||
|
||||
<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_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>
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@
|
|||
|
||||
<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_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>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue