mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed text file sharing (including linphone config)
This commit is contained in:
parent
ab9aedf5ee
commit
a3489f4064
4 changed files with 35 additions and 20 deletions
|
|
@ -172,7 +172,7 @@ class FileViewerActivity : GenericActivity() {
|
|||
val copy = FileUtils.getFilePath(
|
||||
baseContext,
|
||||
Uri.parse(filePath),
|
||||
overrideExisting = true,
|
||||
overrideExisting = false,
|
||||
copyToCache = true
|
||||
)
|
||||
if (!copy.isNullOrEmpty()) {
|
||||
|
|
|
|||
|
|
@ -542,33 +542,36 @@ class MainActivity : GenericActivity() {
|
|||
val parcelablesUri = arrayListOf<Uri>()
|
||||
|
||||
if (intent.type == "text/plain") {
|
||||
Log.i("$TAG Intent type is [${intent.type}], expecting text in Intent.EXTRA_TEXT")
|
||||
intent.getStringExtra(Intent.EXTRA_TEXT)?.let { extraText ->
|
||||
Log.i("$TAG Found extra text in intent, long of [${extraText.length}]")
|
||||
sharedViewModel.textToShareFromIntent.value = extraText
|
||||
}
|
||||
} else {
|
||||
if (multiple) {
|
||||
val parcelables =
|
||||
intent.getParcelableArrayListExtra<Parcelable>(Intent.EXTRA_STREAM)
|
||||
for (parcelable in parcelables.orEmpty()) {
|
||||
val uri = parcelable as? Uri
|
||||
if (uri != null) {
|
||||
Log.i("$TAG Found URI [$uri] in parcelable extra list")
|
||||
parcelablesUri.add(uri)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val uri = intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri
|
||||
}
|
||||
|
||||
if (multiple) {
|
||||
val parcelables =
|
||||
intent.getParcelableArrayListExtra<Parcelable>(Intent.EXTRA_STREAM)
|
||||
for (parcelable in parcelables.orEmpty()) {
|
||||
val uri = parcelable as? Uri
|
||||
if (uri != null) {
|
||||
Log.i("$TAG Found URI [$uri] in parcelable extra")
|
||||
Log.i("$TAG Found URI [$uri] in parcelable extra list")
|
||||
parcelablesUri.add(uri)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val uri = intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri
|
||||
if (uri != null) {
|
||||
Log.i("$TAG Found URI [$uri] in parcelable extra")
|
||||
parcelablesUri.add(uri)
|
||||
}
|
||||
}
|
||||
|
||||
val list = arrayListOf<String>()
|
||||
lifecycleScope.launch {
|
||||
val deferred = arrayListOf<Deferred<String?>>()
|
||||
for (uri in parcelablesUri) {
|
||||
Log.i("$TAG Deferring copy from file [${uri.path}] to local storage")
|
||||
deferred.add(async { FileUtils.getFilePath(this@MainActivity, uri, false) })
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import android.view.ViewGroup
|
|||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import org.linphone.R
|
||||
import org.linphone.core.CorePreferences
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.HelpDebugFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
|
|
@ -116,12 +115,11 @@ class DebugFragment : GenericMainFragment() {
|
|||
}
|
||||
|
||||
viewModel.showConfigFileEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { content ->
|
||||
it.consume { path ->
|
||||
if (findNavController().currentDestination?.id == R.id.debugFragment) {
|
||||
val intent = Intent(requireActivity(), FileViewerActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("path", CorePreferences.CONFIG_FILE_NAME)
|
||||
bundle.putString("content", content)
|
||||
bundle.putString("path", path)
|
||||
val nowInSeconds = System.currentTimeMillis() / 1000
|
||||
bundle.putLong("timestamp", nowInSeconds)
|
||||
intent.putExtras(bundle)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ package org.linphone.ui.main.help.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.linphone.BuildConfig
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
|
|
@ -34,6 +36,7 @@ import org.linphone.core.tools.Log
|
|||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
class HelpViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
|
|
@ -196,7 +199,18 @@ class HelpViewModel @UiThread constructor() : GenericViewModel() {
|
|||
coreContext.postOnCoreThread { core ->
|
||||
Log.i("$TAG Dumping & displaying Core's config")
|
||||
val config = core.config.dump()
|
||||
showConfigFileEvent.postValue(Event(config))
|
||||
val file = FileUtils.getFileStorageCacheDir(
|
||||
"linphonerc.txt",
|
||||
overrideExisting = true
|
||||
)
|
||||
viewModelScope.launch {
|
||||
if (FileUtils.dumpStringToFile(config, file)) {
|
||||
Log.i("$TAG .linphonerc string saved as file in cache folder")
|
||||
showConfigFileEvent.postValue(Event(file.absolutePath))
|
||||
} else {
|
||||
Log.e("$TAG Failed to save .linphonerc string as file in cache folder")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue