Also show print logs in logcat setting in troubleshooting fragment

This commit is contained in:
Sylvain Berfini 2026-02-16 15:35:38 +01:00
parent 64f04e4f53
commit 820eec9cf5
5 changed files with 69 additions and 1 deletions

View file

@ -31,6 +31,7 @@ import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.R
import org.linphone.core.Core
import org.linphone.core.CoreListenerStub
import org.linphone.core.Factory
import org.linphone.core.VersionUpdateCheckResult
import org.linphone.core.tools.Log
import org.linphone.ui.GenericViewModel
@ -61,6 +62,10 @@ class HelpViewModel
val logsUploadInProgress = MutableLiveData<Boolean>()
val printLogsInLogcat = MutableLiveData<Boolean>()
val developerSettingsEnabled = MutableLiveData<Boolean>()
val canConfigFileBeViewed = MutableLiveData<Boolean>()
val newVersionAvailableEvent: MutableLiveData<Event<Pair<String, String>>> by lazy {
@ -165,6 +170,8 @@ class HelpViewModel
coreContext.postOnCoreThread { core ->
core.addListener(coreListener)
printLogsInLogcat.postValue(corePreferences.printLogsInLogcat)
developerSettingsEnabled.postValue(corePreferences.showDeveloperSettings)
checkUpdateAvailable.postValue(corePreferences.checkForUpdateServerUrl.isNotEmpty())
uploadLogsAvailable.postValue(!core.logCollectionUploadServerUrl.isNullOrEmpty())
}
@ -195,6 +202,7 @@ class HelpViewModel
coreContext.postOnCoreThread {
Log.w("$TAG Enabling developer settings")
corePreferences.showDeveloperSettings = true
developerSettingsEnabled.postValue(true)
}
}
NUMBER_OF_CLICK_TO_ENABLE_DEVELOPER_MODE + 1 -> {
@ -231,6 +239,17 @@ class HelpViewModel
}
}
@UiThread
fun toggleLogcat() {
val newValue = printLogsInLogcat.value == false
coreContext.postOnCoreThread {
corePreferences.printLogsInLogcat = newValue
coreContext.updateLogcatEnabledSetting(newValue)
Factory.instance().enableLogcatLogs(newValue)
printLogsInLogcat.postValue(newValue)
}
}
@UiThread
fun showConfigFile() {
coreContext.postOnCoreThread { core ->

View file

@ -45,6 +45,8 @@
android:text="@={viewModel.stunServer}"
android:inputType="text|textUri"
android:hint="@string/account_settings_stun_server_url_title"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_max="@dimen/text_input_max_width"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/stun_server_title"/>
@ -133,6 +135,8 @@
android:text="@={viewModel.turnUsername}"
android:inputType="text|textPersonName"
android:hint="@string/account_settings_turn_username_title"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_max="@dimen/text_input_max_width"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/turn_username_title" />
@ -167,6 +171,8 @@
android:text="@={viewModel.turnPassword}"
android:hint="@string/account_settings_turn_password_title"
android:inputType="@{viewModel.showTurnPassword ? InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD : InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD, default=textPassword}"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_max="@dimen/text_input_max_width"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/turn_password_title"

View file

@ -165,6 +165,8 @@
android:text="@={viewModel.voicemailUri}"
android:inputType="text|textUri"
android:hint="@string/account_settings_voicemail_uri_title"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_max="@dimen/text_input_max_width"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/voicemail_uri_title" />
@ -198,6 +200,8 @@
android:text="@={viewModel.mwiUri}"
android:inputType="text|textUri"
android:hint="@string/account_settings_mwi_uri_title"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_max="@dimen/text_input_max_width"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/mwi_uri_title"

View file

@ -129,6 +129,41 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<androidx.constraintlayout.widget.Group
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="@{viewModel.developerSettingsEnabled ? View.VISIBLE : View.GONE, default=gone}"
app:constraint_referenced_ids="logcat_switch, logcat_title" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
android:onClick="@{() -> viewModel.toggleLogcat()}"
android:id="@+id/logcat_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="10dp"
android:text="@string/help_troubleshooting_print_logs_in_logcat"
android:maxLines="2"
android:ellipsize="end"
android:labelFor="@id/logcat_switch"
app:layout_constraintTop_toTopOf="@id/logcat_switch"
app:layout_constraintBottom_toBottomOf="@id/logcat_switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/logcat_switch"/>
<com.google.android.material.materialswitch.MaterialSwitch
style="@style/material_switch_style"
android:id="@+id/logcat_switch"
android:onClick="@{() -> viewModel.toggleLogcat()}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:checked="@{viewModel.printLogsInLogcat}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/app_version_icon"
android:layout_width="32dp"
@ -151,7 +186,7 @@
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:text="@string/help_troubleshooting_app_version_title"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@id/logcat_switch"
app:layout_constraintStart_toEndOf="@id/app_version_icon"
app:layout_constraintEnd_toEndOf="parent"/>

View file

@ -332,6 +332,8 @@
android:text="@string/settings_developer_clear_native_friends_in_database_title"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintWidth_max="@dimen/button_max_width"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/push_compatible_domains_list"/>
@ -371,6 +373,8 @@
android:text="@string/settings_developer_clear_orphan_auth_info_title"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintWidth_max="@dimen/button_max_width"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/clear_friends_db_subtitle"