mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Changed troubleshooting toggle to only enable/disable printing logs to adb logcat
This commit is contained in:
parent
2ca3d017bf
commit
ef53eb62ae
5 changed files with 27 additions and 36 deletions
|
|
@ -67,10 +67,8 @@ class LinphoneApplication : Application(), ImageLoaderFactory {
|
|||
|
||||
val appName = context.getString(R.string.app_name)
|
||||
Factory.instance().setLoggerDomain(appName)
|
||||
Factory.instance().enableLogcatLogs(true)
|
||||
if (corePreferences.debugLogs) {
|
||||
Factory.instance().loggingService.setLogLevel(LogLevel.Message)
|
||||
}
|
||||
Factory.instance().loggingService.setLogLevel(LogLevel.Message)
|
||||
Factory.instance().enableLogcatLogs(corePreferences.printLogsInLogcat)
|
||||
|
||||
Log.i("[Linphone Application] Report Core preferences initialized")
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
}
|
||||
|
||||
@get:WorkerThread @set:WorkerThread
|
||||
var debugLogs: Boolean
|
||||
var printLogsInLogcat: Boolean
|
||||
get() = config.getBool("app", "debug", org.linphone.BuildConfig.DEBUG)
|
||||
set(value) {
|
||||
config.setBool("app", "debug", value)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.linphone.R
|
|||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.LogLevel
|
||||
import org.linphone.core.VersionUpdateCheckResult
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.AppUtils
|
||||
|
|
@ -47,7 +46,7 @@ class HelpViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val sdkVersion = MutableLiveData<String>()
|
||||
|
||||
val debugModeEnabled = MutableLiveData<Boolean>()
|
||||
val printLogInLogcatEnabled = MutableLiveData<Boolean>()
|
||||
|
||||
val newVersionAvailableEvent: MutableLiveData<Event<Pair<String, String>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, String>>>()
|
||||
|
|
@ -124,7 +123,7 @@ class HelpViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
core.addListener(coreListener)
|
||||
debugModeEnabled.postValue(corePreferences.debugLogs)
|
||||
printLogInLogcatEnabled.postValue(corePreferences.printLogsInLogcat)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,19 +137,13 @@ class HelpViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
|
||||
@UiThread
|
||||
fun toggleDebugMode() {
|
||||
val enabled = debugModeEnabled.value == false
|
||||
debugModeEnabled.value = enabled
|
||||
|
||||
if (!enabled) {
|
||||
cleanLogs()
|
||||
}
|
||||
fun togglePrintLogsInLogcat() {
|
||||
val enabled = printLogInLogcatEnabled.value == false
|
||||
printLogInLogcatEnabled.value = enabled
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
corePreferences.debugLogs = enabled
|
||||
val logLevel = if (enabled) LogLevel.Message else LogLevel.Error
|
||||
Factory.instance().loggingService.setLogLevel(logLevel)
|
||||
Log.i("$TAG Debug logs have been ${if (enabled) "enabled" else "disabled"}")
|
||||
corePreferences.printLogsInLogcat = enabled
|
||||
Factory.instance().enableLogcatLogs(corePreferences.printLogsInLogcat)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
android:id="@+id/debug_title"
|
||||
android:id="@+id/print_logs_in_logcat_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
|
|
@ -55,11 +55,11 @@
|
|||
android:text="@string/help_troubleshooting_debug_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/debug_mode_switch"/>
|
||||
app:layout_constraintEnd_toStartOf="@id/print_logs_in_logcat_switch"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/debug_subtitle"
|
||||
android:id="@+id/print_logs_in_logcat_subtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
|
|
@ -67,29 +67,29 @@
|
|||
android:text="@string/help_troubleshooting_debug_subtitle"
|
||||
android:textSize="14sp"
|
||||
android:textColor="?attr/color_main2_600"
|
||||
app:layout_constraintTop_toBottomOf="@id/debug_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/print_logs_in_logcat_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/debug_mode_switch" />
|
||||
app:layout_constraintEnd_toStartOf="@id/print_logs_in_logcat_switch" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
style="@style/material_switch_style"
|
||||
android:onClick="@{() -> viewModel.toggleDebugMode()}"
|
||||
android:id="@+id/debug_mode_switch"
|
||||
android:onClick="@{() -> viewModel.togglePrintLogsInLogcat()}"
|
||||
android:id="@+id/print_logs_in_logcat_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:checked="@{viewModel.debugModeEnabled, default=true}"
|
||||
app:layout_constraintStart_toEndOf="@id/debug_title"
|
||||
android:checked="@{viewModel.printLogInLogcatEnabled, default=true}"
|
||||
app:layout_constraintStart_toEndOf="@id/print_logs_in_logcat_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/debug_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/debug_subtitle" />
|
||||
app:layout_constraintTop_toTopOf="@id/print_logs_in_logcat_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/print_logs_in_logcat_subtitle" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/tertiary_button_label_style"
|
||||
android:onClick="@{() -> viewModel.cleanLogs()}"
|
||||
android:id="@+id/clean_logs"
|
||||
android:enabled="@{viewModel.debugModeEnabled}"
|
||||
android:enabled="@{viewModel.printLogInLogcatEnabled}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
|
|
@ -105,13 +105,13 @@
|
|||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/debug_subtitle"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/print_logs_in_logcat_subtitle"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/tertiary_button_label_style"
|
||||
android:onClick="@{() -> viewModel.shareLogs()}"
|
||||
android:id="@+id/send_logs"
|
||||
android:enabled="@{viewModel.debugModeEnabled}"
|
||||
android:enabled="@{viewModel.printLogInLogcatEnabled}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
|
|
@ -127,7 +127,7 @@
|
|||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintStart_toEndOf="@id/clean_logs"
|
||||
app:layout_constraintTop_toBottomOf="@id/debug_subtitle"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/print_logs_in_logcat_subtitle"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/app_version_icon"
|
||||
|
|
|
|||
|
|
@ -246,8 +246,8 @@
|
|||
<string name="help_version_up_to_date_toast_message">Your version is up-to-date</string>
|
||||
<string name="help_error_checking_version_toast_message">An error occurred while checking for update</string>
|
||||
<string name="help_troubleshooting_title">Troubleshooting</string>
|
||||
<string name="help_troubleshooting_debug_title">Enable/disable debug logs</string>
|
||||
<string name="help_troubleshooting_debug_subtitle">Blah</string> <!-- TODO -->
|
||||
<string name="help_troubleshooting_debug_title">Enable/disable printing logs in ADB</string>
|
||||
<string name="help_troubleshooting_debug_subtitle">Blah blah blah?</string> <!-- TODO -->
|
||||
<string name="help_troubleshooting_clean_logs">Clean logs</string>
|
||||
<string name="help_troubleshooting_share_logs">Share logs</string>
|
||||
<string name="help_troubleshooting_app_version_title">Linphone app version</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue