[Android] Add a whatsapp browser favorite with the new path
Nicolas Pomepuy
git at videolan.org
Thu Feb 24 10:58:19 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jan 14 07:52:28 2022 +0100| [75956c68ed874bec1a0a6da7b08c6d9837abf4d4] | committer: Nicolas Pomepuy
Add a whatsapp browser favorite with the new path
> https://code.videolan.org/videolan/vlc-android/commit/75956c68ed874bec1a0a6da7b08c6d9837abf4d4
---
.../src/main/java/org/videolan/vlc/mediadb/MediaDatabase.kt | 5 +++--
.../src/main/java/org/videolan/vlc/mediadb/Migrations.kt | 11 ++++++++++-
.../src/main/java/org/videolan/resources/AndroidDevices.kt | 2 ++
libvlc/src/org/videolan/libvlc/util/AndroidUtil.java | 1 +
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/application/mediadb/src/main/java/org/videolan/vlc/mediadb/MediaDatabase.kt b/application/mediadb/src/main/java/org/videolan/vlc/mediadb/MediaDatabase.kt
index 9ffbad365..fc4cbb56c 100644
--- a/application/mediadb/src/main/java/org/videolan/vlc/mediadb/MediaDatabase.kt
+++ b/application/mediadb/src/main/java/org/videolan/vlc/mediadb/MediaDatabase.kt
@@ -60,7 +60,7 @@ import org.videolan.vlc.mediadb.models.Slave
private const val DB_NAME = "vlc_database"
- at Database(entities = [ExternalSub::class, Slave::class, BrowserFav::class, CustomDirectory::class], version = 29)
+ at Database(entities = [ExternalSub::class, Slave::class, BrowserFav::class, CustomDirectory::class], version = 30)
@TypeConverters(Converters::class)
abstract class MediaDatabase: RoomDatabase() {
abstract fun externalSubDao(): ExternalSubDao
@@ -79,7 +79,8 @@ private fun buildDatabase(context: Context) = Room.databaseBuilder(context.appli
migration_13_14, migration_14_15, migration_15_16, migration_16_17,
migration_17_18, migration_18_19, migration_19_20, migration_20_21,
migration_21_22, migration_22_23, migration_23_24, migration_24_25,
- migration_25_26, migration_26_27, migration_27_28, migration_28_29)
+ migration_25_26, migration_26_27, migration_27_28, migration_28_29,
+ migration_29_30)
.addCallback(object : RoomDatabase.Callback() {
override fun onCreate(db: SupportSQLiteDatabase) { if (!AndroidDevices.isTv) populateDB(context) }
})
diff --git a/application/mediadb/src/main/java/org/videolan/vlc/mediadb/Migrations.kt b/application/mediadb/src/main/java/org/videolan/vlc/mediadb/Migrations.kt
index 73cf9a50d..fd69389ce 100644
--- a/application/mediadb/src/main/java/org/videolan/vlc/mediadb/Migrations.kt
+++ b/application/mediadb/src/main/java/org/videolan/vlc/mediadb/Migrations.kt
@@ -202,12 +202,21 @@ val migration_28_29 = object:Migration(28, 29) {
}
}
+val migration_29_30 = object:Migration(29, 30) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ // Insert the new whatsapp path
+ val uri = AndroidDevices.MediaFolders.WHATSAPP_VIDEOS_FILE_URI_A11
+ database.execSQL("INSERT INTO $FAV_TABLE_NAME(uri, type, title, icon_url) VALUES (\"$uri\", 1, \"${uri.lastPathSegment}\", null)")
+ }
+}
+
fun populateDB(context: Context) = GlobalScope.launch(Dispatchers.IO) {
val uris = listOf(AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_MOVIES_DIRECTORY_URI,
AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_MUSIC_DIRECTORY_URI,
AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_PODCAST_DIRECTORY_URI,
AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_DOWNLOAD_DIRECTORY_URI,
- AndroidDevices.MediaFolders.WHATSAPP_VIDEOS_FILE_URI)
+ AndroidDevices.MediaFolders.WHATSAPP_VIDEOS_FILE_URI,
+ AndroidDevices.MediaFolders.WHATSAPP_VIDEOS_FILE_URI_A11)
val browserFavDao = MediaDatabase.getInstance(context).browserFavDao()
for (uri in uris) browserFavDao.insert(org.videolan.vlc.mediadb.models.BrowserFav(uri, TYPE_LOCAL_FAV, uri.lastPathSegment
diff --git a/application/resources/src/main/java/org/videolan/resources/AndroidDevices.kt b/application/resources/src/main/java/org/videolan/resources/AndroidDevices.kt
index 3fa925168..f97358144 100644
--- a/application/resources/src/main/java/org/videolan/resources/AndroidDevices.kt
+++ b/application/resources/src/main/java/org/videolan/resources/AndroidDevices.kt
@@ -203,6 +203,7 @@ object AndroidDevices {
private val EXTERNAL_PUBLIC_DOWNLOAD_DIRECTORY_FILE: File = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
private val EXTERNAL_PUBLIC_DCIM_DIRECTORY_FILE: File = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
private val WHATSAPP_VIDEOS_FILE: File = File("$EXTERNAL_PUBLIC_DIRECTORY/WhatsApp/Media/WhatsApp Video/")
+ private val WHATSAPP_VIDEOS_FILE_A11: File = File("$EXTERNAL_PUBLIC_DIRECTORY/Android/media/com.whatsapp/WhatsApp/Media/WhatsApp Video/")
val EXTERNAL_PUBLIC_MOVIES_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_MOVIES_DIRECTORY_FILE)
val EXTERNAL_PUBLIC_MUSIC_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_MUSIC_DIRECTORY_FILE)
@@ -210,6 +211,7 @@ object AndroidDevices {
val EXTERNAL_PUBLIC_DOWNLOAD_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_DOWNLOAD_DIRECTORY_FILE)
val EXTERNAL_PUBLIC_DCIM_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_DCIM_DIRECTORY_FILE)
val WHATSAPP_VIDEOS_FILE_URI = getFolderUri(WHATSAPP_VIDEOS_FILE)
+ val WHATSAPP_VIDEOS_FILE_URI_A11 = getFolderUri(WHATSAPP_VIDEOS_FILE_A11)
private fun getFolderUri(file: File): Uri {
return try {
diff --git a/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java b/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
index 6f91666af..4441acb20 100644
--- a/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
+++ b/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
@@ -30,6 +30,7 @@ import java.io.File;
public class AndroidUtil {
+ public static final boolean isROrLater = android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
public static final boolean isPOrLater = android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;
public static final boolean isOOrLater = isPOrLater || android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
public static final boolean isNougatMR1OrLater = isOOrLater || android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1;
More information about the Android
mailing list