mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added button in debug help fragment to display config file
This commit is contained in:
parent
d91093cf01
commit
70e25b7792
11 changed files with 86 additions and 5 deletions
|
|
@ -137,9 +137,13 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
val defaultDomain: String
|
||||
get() = config.getString("app", "default_domain", "sip.linphone.org")!!
|
||||
|
||||
@get:AnyThread
|
||||
val configFile: String
|
||||
get() = ".linphonerc"
|
||||
|
||||
@get:AnyThread
|
||||
val configPath: String
|
||||
get() = context.filesDir.absolutePath + "/.linphonerc"
|
||||
get() = context.filesDir.absolutePath + "/" + configFile
|
||||
|
||||
@get:AnyThread
|
||||
val factoryConfigPath: String
|
||||
|
|
|
|||
|
|
@ -236,7 +236,8 @@ class ConversationsListFragment : AbstractTopBarFragment() {
|
|||
)
|
||||
} else {
|
||||
ConversationsListFragmentDirections.actionConversationsListFragmentToFileViewerFragment(
|
||||
path
|
||||
path,
|
||||
null
|
||||
)
|
||||
}
|
||||
findNavController().navigate(action)
|
||||
|
|
|
|||
|
|
@ -75,8 +75,11 @@ class FileViewerFragment : GenericFragment() {
|
|||
binding.viewModel = viewModel
|
||||
|
||||
val path = args.path
|
||||
Log.i("$TAG Path argument is [$path]")
|
||||
viewModel.loadFile(path)
|
||||
val preLoadedContent = args.content
|
||||
Log.i(
|
||||
"$TAG Path argument is [$path], pre loaded text content is ${if (preLoadedContent.isNullOrEmpty()) "not available" else "available, using it"}"
|
||||
)
|
||||
viewModel.loadFile(path, preLoadedContent)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -84,13 +84,21 @@ class FileViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
|
||||
@UiThread
|
||||
fun loadFile(file: String) {
|
||||
fun loadFile(file: String, content: String? = null) {
|
||||
fullScreenMode.value = true
|
||||
|
||||
filePath = file
|
||||
val name = FileUtils.getNameFromFilePath(file)
|
||||
fileName.value = name
|
||||
|
||||
if (!content.isNullOrEmpty()) {
|
||||
isText.value = true
|
||||
text.postValue(content)
|
||||
Log.i("$TAG Using pre-loaded content as PlainText")
|
||||
fileReadyEvent.postValue(Event(true))
|
||||
return
|
||||
}
|
||||
|
||||
val extension = FileUtils.getExtensionFromFileName(name)
|
||||
val mime = FileUtils.getMimeTypeFromExtension(extension)
|
||||
when (FileUtils.getMimeType(mime)) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.HelpDebugFragmentBinding
|
||||
|
|
@ -110,5 +112,17 @@ class DebugFragment : GenericFragment() {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showConfigFileEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { content ->
|
||||
if (findNavController().currentDestination?.id == R.id.debugFragment) {
|
||||
val action = DebugFragmentDirections.actionDebugFragmentToFileViewerFragment(
|
||||
corePreferences.configFile,
|
||||
content
|
||||
)
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ class HelpViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val showConfigFileEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
private val coreListener = object : CoreListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onVersionUpdateCheckResultReceived(
|
||||
|
|
@ -173,4 +177,13 @@ class HelpViewModel @UiThread constructor() : ViewModel() {
|
|||
core.checkForUpdate(currentVersion)
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun showConfigFile() {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
Log.i("$TAG Dumping & displaying Core's config")
|
||||
val config = core.config.dump()
|
||||
showConfigFileEvent.postValue(Event(config))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,11 @@ class CardDavViewModel : ViewModel() {
|
|||
syncInProgress.postValue(false)
|
||||
val icon = R.drawable.x
|
||||
showErrorToastEvent.postValue(Event(Pair(icon, message.orEmpty())))
|
||||
if (isEdit.value == false) {
|
||||
Log.e("$TAG Synchronization failed, removing Friend list from Core")
|
||||
friendList.removeListener(this)
|
||||
coreContext.core.removeFriendList(friendList)
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,6 +207,27 @@
|
|||
app:layout_constraintStart_toEndOf="@id/sdk_version_icon"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/tertiary_button_label_style"
|
||||
android:onClick="@{() -> viewModel.showConfigFile()}"
|
||||
android:id="@+id/show_config_file"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:background="@drawable/tertiary_button_background"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/help_troubleshooting_show_config_file"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/sdk_version_subtitle"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -208,6 +208,12 @@
|
|||
app:launchSingleTop="true"
|
||||
app:popUpTo="@id/helpFragment"
|
||||
app:popUpToInclusive="true"/>
|
||||
<action
|
||||
android:id="@+id/action_debugFragment_to_fileViewerFragment"
|
||||
app:destination="@id/fileViewerFragment"
|
||||
app:launchSingleTop="true"
|
||||
app:enterAnim="@anim/slide_in"
|
||||
app:popExitAnim="@anim/slide_out" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
|
|
@ -361,6 +367,10 @@
|
|||
<argument
|
||||
android:name="path"
|
||||
app:argType="string" />
|
||||
<argument
|
||||
android:name="content"
|
||||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@
|
|||
<string name="help_troubleshooting_share_logs_dialog_title">Partager le lien vers journaux avec…</string>
|
||||
<string name="help_troubleshooting_debug_logs_cleaned_toast_message">Les journaux ont été nettoyés</string>
|
||||
<string name="help_troubleshooting_debug_logs_upload_error_toast_message">Echec à l\'envoi des journaux</string>
|
||||
<string name="help_troubleshooting_show_config_file">Afficher la configuration</string>
|
||||
|
||||
<string name="settings_title">Paramètres</string>
|
||||
<string name="settings_security_title">Securité</string>
|
||||
|
|
|
|||
|
|
@ -228,6 +228,7 @@
|
|||
<string name="help_troubleshooting_share_logs_dialog_title">Share debug logs link using…</string>
|
||||
<string name="help_troubleshooting_debug_logs_cleaned_toast_message">Debug logs have been cleaned</string>
|
||||
<string name="help_troubleshooting_debug_logs_upload_error_toast_message">Failed to upload debug logs</string>
|
||||
<string name="help_troubleshooting_show_config_file">Show configuration</string>
|
||||
|
||||
<!-- App & SDK settings -->
|
||||
<string name="settings_title">Settings</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue