[Android] Upgrade AppCompat to v28

Geoffrey Métais git at videolan.org
Mon Sep 24 16:01:36 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Sep 24 15:12:31 2018 +0200| [9baac2085dddf58db861dbda05270fd6413c652b] | committer: Geoffrey Métais

Upgrade AppCompat to v28

> https://code.videolan.org/videolan/vlc-android/commit/9baac2085dddf58db861dbda05270fd6413c652b
---

 build.gradle                                          |  2 +-
 medialibrary/build.gradle                             |  8 ++++++++
 .../org/videolan/medialibrary/ToolsTest.java          | 15 +++++++++++----
 .../videolan/vlc/gui/browser/BaseBrowserFragment.kt   |  2 +-
 .../vlc/gui/browser/StorageBrowserFragment.kt         | 19 ++++++++++---------
 .../src/org/videolan/vlc/gui/helpers/hf/OtgAccess.kt  |  8 ++++----
 .../vlc/gui/helpers/hf/WriteExternalDelegate.kt       |  2 +-
 7 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/build.gradle b/build.gradle
index 4d295ad63..f47812078 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,7 +24,7 @@ allprojects {
 }
 
 ext {
-    appCompatVersion = '27.1.1'
+    appCompatVersion = '28.0.0'
     constraintLayoutVersion = '1.1.3'
     archVersion = '1.1.1'
     roomVersion = '1.1.1'
diff --git a/medialibrary/build.gradle b/medialibrary/build.gradle
index c4ccd3956..b59ea4a26 100644
--- a/medialibrary/build.gradle
+++ b/medialibrary/build.gradle
@@ -37,6 +37,13 @@ android {
             res.srcDirs = ['res']
             assets.srcDirs = ['assets', 'libcompat/libs/armeabi']
         }
+        test {
+            java.srcDirs = ['test']
+        }
+        androidTest {
+            java.srcDirs = ['androidTest']
+            assets.srcDirs += files("$projectDir/assets/schemas".toString())
+        }
     }
 
     buildTypes {
@@ -67,4 +74,5 @@ dependencies {
     api "com.android.support:support-fragment:$rootProject.ext.appCompatVersion"
     testImplementation "junit:junit:$rootProject.ext.junitVersion"
     implementation project(':tools')
+    implementation 'junit:junit:4.12'
 }
\ No newline at end of file
diff --git a/medialibrary/src/test/java/org/videolan/medialibrary/ToolsTest.java b/medialibrary/test/org/videolan/medialibrary/ToolsTest.java
similarity index 71%
rename from medialibrary/src/test/java/org/videolan/medialibrary/ToolsTest.java
rename to medialibrary/test/org/videolan/medialibrary/ToolsTest.java
index 7cb469921..ae3c095b2 100644
--- a/medialibrary/src/test/java/org/videolan/medialibrary/ToolsTest.java
+++ b/medialibrary/test/org/videolan/medialibrary/ToolsTest.java
@@ -1,13 +1,20 @@
 package org.videolan.medialibrary;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
 
-public class ToolsTest extends TestCase {
-    public void testIsArrayEmpty() throws Exception {
+import static org.junit.Assert.assertEquals;
+
+ at RunWith(JUnit4::class)
+public class ToolsTest {
+    @Test
+    public void testIsArrayEmpty() {
 
     }
 
-    public void testMillisToString() throws Exception {
+    @Test
+    public void testMillisToString()n {
         assertEquals("3min30s", Tools.millisToString(210000, true, true));
         assertEquals("3min", Tools.millisToString(180000, true, true));
         assertEquals("1h30min30s", Tools.millisToString(5430000, true, true));
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 8146cd54c..602ebc462 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -145,7 +145,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
                 did.setDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.divider_grey_50_18dp)!!)
                 ariane.addItemDecoration(did)
             }
-            ariane.scrollToPosition(ariane.adapter.itemCount - 1)
+            ariane.scrollToPosition(ariane.adapter!!.itemCount - 1)
         } else ariane.visibility = View.GONE
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
index bbedb4cac..30fa2e914 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
@@ -180,14 +180,15 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb {
         if (entryPoint.endsWith("/"))
             entryPoint = entryPoint.substring(0, entryPoint.length - 1)
         if (mProcessingFolders.containsKey(entryPoint)) {
-            val cb = mProcessingFolders.remove(entryPoint)
-            handler.post {
-                cb.isEnabled = true
-                if (success) {
-                    (adapter as StorageBrowserAdapter).updateMediaDirs(requireContext())
-                    adapter.notifyDataSetChanged()
-                } else
-                    cb.isChecked = true
+            mProcessingFolders.remove(entryPoint)?.let {
+                handler.post {
+                    it.isEnabled = true
+                    if (success) {
+                        (adapter as StorageBrowserAdapter).updateMediaDirs(requireContext())
+                        adapter.notifyDataSetChanged()
+                    } else
+                        it.isChecked = true
+                }
             }
         }
     }
@@ -201,7 +202,7 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb {
         if (path.endsWith("/")) path = path.dropLast(1)
         if (mProcessingFolders.containsKey(path)) {
             val finalPath = path
-            handler.post { mProcessingFolders.get(finalPath).isEnabled = true }
+            handler.post { mProcessingFolders.get(finalPath)?.isEnabled = true }
             (adapter as StorageBrowserAdapter).updateMediaDirs(requireContext())
         }
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/OtgAccess.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/OtgAccess.kt
index 306e96109..ab4f7e653 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/OtgAccess.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/OtgAccess.kt
@@ -72,7 +72,7 @@ fun getDocumentFiles(context: Context, path: String) : List<MediaWrapper>? {
     val parts = path.substringAfterLast(':').split("/".toRegex()).dropLastWhile { it.isEmpty() }
     for (part in parts) {
         if (part == "") continue
-        documentFile = documentFile.findFile(part)
+        documentFile = documentFile?.findFile(part)
     }
 
     if (documentFile == null) {
@@ -84,12 +84,12 @@ fun getDocumentFiles(context: Context, path: String) : List<MediaWrapper>? {
     val list = mutableListOf<MediaWrapper>()
     for (file in documentFile.listFiles()) {
         if (file.exists() && file.canRead()) {
-            if (file.name.startsWith(".")) continue
+            if (file.name?.startsWith(".") == true) continue
             val mw = MediaWrapper(file.uri).apply {
                 type = when {
                     file.isDirectory -> MediaWrapper.TYPE_DIR
-                    file.type.startsWith("video") -> MediaWrapper.TYPE_VIDEO
-                    file.type.startsWith("audio") -> MediaWrapper.TYPE_AUDIO
+                    file.type?.startsWith("video") == true -> MediaWrapper.TYPE_VIDEO
+                    file.type?.startsWith("audio") == true -> MediaWrapper.TYPE_AUDIO
                     else -> type
                 }
                 title = file.name
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
index 618598ba6..b35017adc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
@@ -69,7 +69,7 @@ class WriteExternalDelegate : BaseHeadlessFragment() {
                 val persistedUriPermissions = contentResolver.persistedUriPermissions
                 for (uriPermission in persistedUriPermissions) {
                     val file = DocumentFile.fromTreeUri(context, uriPermission.uri)
-                    if (treeFile.name == file.name) {
+                    if (treeFile?.name == file?.name) {
                         contentResolver.releasePersistableUriPermission(uriPermission.uri, Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
                         return
                     }



More information about the Android mailing list