[Android] Allow the user to directly share the ML DB dump
Nicolas Pomepuy
git at videolan.org
Wed Jun 22 12:37:48 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jun 22 13:59:29 2022 +0200| [f8579b0bd763e4537ddde7d83814b00249635af3] | committer: Nicolas Pomepuy
Allow the user to directly share the ML DB dump
> https://code.videolan.org/videolan/vlc-android/commit/f8579b0bd763e4537ddde7d83814b00249635af3
---
.../org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt | 8 +++++++-
.../vlc-android/src/org/videolan/vlc/util/Kextensions.kt | 13 +++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt
index adbea49cc..2b712b0ca 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt
@@ -58,6 +58,7 @@ import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate.Companion.getWritePermission
import org.videolan.vlc.util.FeatureFlag
import org.videolan.vlc.util.FileUtils
+import org.videolan.vlc.util.share
import java.io.File
import java.io.IOException
@@ -183,7 +184,12 @@ class PreferencesAdvanced : BasePreferenceFragment(), SharedPreferences.OnShared
FileUtils.copyFile(db, dst)
}
- Toast.makeText(context, getString(if (copied) R.string.dump_db_succes else R.string.dump_db_failure), Toast.LENGTH_LONG).show()
+ if (copied)
+ UiTools.snackerConfirm(requireActivity(), getString(R.string.dump_db_succes), confirmMessage = R.string.share, overAudioPlayer = false) {
+ requireActivity().share(dst)
+ } else {
+ Toast.makeText(context, getString(R.string.dump_db_failure), Toast.LENGTH_LONG).show()
+ }
}
}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt b/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
index 099d8cf37..8b234a2c1 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
@@ -80,6 +80,19 @@ inline fun <reified T : ViewModel> Fragment.getModel() = ViewModelProvider(this)
inline fun <reified T : ViewModel> FragmentActivity.getModel() = ViewModelProvider(this).get(T::class.java)
fun Media?.canExpand() = this != null && (type == IMedia.Type.Directory || type == IMedia.Type.Playlist)
+
+fun FragmentActivity.share(file: File) {
+ val intentShareFile = Intent(Intent.ACTION_SEND)
+ val fileWithinMyDir = File(file.path)
+ if (isStarted()) {
+ intentShareFile.type = "*/*"
+ intentShareFile.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, "$packageName.provider", fileWithinMyDir))
+ intentShareFile.putExtra(Intent.EXTRA_SUBJECT, file.name)
+ intentShareFile.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_message, file.name))
+ startActivity(Intent.createChooser(intentShareFile, getString(R.string.share_file,file.name)))
+ }
+}
+
suspend fun AppCompatActivity.share(media: MediaWrapper) {
val intentShareFile = Intent(Intent.ACTION_SEND)
val fileWithinMyDir = File(media.uri.path)
More information about the Android
mailing list