Commit 9baac208 authored by Geoffrey Métais's avatar Geoffrey Métais

Upgrade AppCompat to v28

parent 0e7fc6ad
...@@ -24,7 +24,7 @@ allprojects { ...@@ -24,7 +24,7 @@ allprojects {
} }
ext { ext {
appCompatVersion = '27.1.1' appCompatVersion = '28.0.0'
constraintLayoutVersion = '1.1.3' constraintLayoutVersion = '1.1.3'
archVersion = '1.1.1' archVersion = '1.1.1'
roomVersion = '1.1.1' roomVersion = '1.1.1'
......
...@@ -37,6 +37,13 @@ android { ...@@ -37,6 +37,13 @@ android {
res.srcDirs = ['res'] res.srcDirs = ['res']
assets.srcDirs = ['assets', 'libcompat/libs/armeabi'] assets.srcDirs = ['assets', 'libcompat/libs/armeabi']
} }
test {
java.srcDirs = ['test']
}
androidTest {
java.srcDirs = ['androidTest']
assets.srcDirs += files("$projectDir/assets/schemas".toString())
}
} }
buildTypes { buildTypes {
...@@ -67,4 +74,5 @@ dependencies { ...@@ -67,4 +74,5 @@ dependencies {
api "com.android.support:support-fragment:$rootProject.ext.appCompatVersion" api "com.android.support:support-fragment:$rootProject.ext.appCompatVersion"
testImplementation "junit:junit:$rootProject.ext.junitVersion" testImplementation "junit:junit:$rootProject.ext.junitVersion"
implementation project(':tools') implementation project(':tools')
implementation 'junit:junit:4.12'
} }
\ No newline at end of file
package org.videolan.medialibrary; 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 { import static org.junit.Assert.assertEquals;
public void testIsArrayEmpty() throws Exception {
@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("3min30s", Tools.millisToString(210000, true, true));
assertEquals("3min", Tools.millisToString(180000, true, true)); assertEquals("3min", Tools.millisToString(180000, true, true));
assertEquals("1h30min30s", Tools.millisToString(5430000, true, true)); assertEquals("1h30min30s", Tools.millisToString(5430000, true, true));
......
...@@ -145,7 +145,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr ...@@ -145,7 +145,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
did.setDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.divider_grey_50_18dp)!!) did.setDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.divider_grey_50_18dp)!!)
ariane.addItemDecoration(did) ariane.addItemDecoration(did)
} }
ariane.scrollToPosition(ariane.adapter.itemCount - 1) ariane.scrollToPosition(ariane.adapter!!.itemCount - 1)
} else ariane.visibility = View.GONE } else ariane.visibility = View.GONE
} }
......
...@@ -180,14 +180,15 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb { ...@@ -180,14 +180,15 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb {
if (entryPoint.endsWith("/")) if (entryPoint.endsWith("/"))
entryPoint = entryPoint.substring(0, entryPoint.length - 1) entryPoint = entryPoint.substring(0, entryPoint.length - 1)
if (mProcessingFolders.containsKey(entryPoint)) { if (mProcessingFolders.containsKey(entryPoint)) {
val cb = mProcessingFolders.remove(entryPoint) mProcessingFolders.remove(entryPoint)?.let {
handler.post { handler.post {
cb.isEnabled = true it.isEnabled = true
if (success) { if (success) {
(adapter as StorageBrowserAdapter).updateMediaDirs(requireContext()) (adapter as StorageBrowserAdapter).updateMediaDirs(requireContext())
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
} else } else
cb.isChecked = true it.isChecked = true
}
} }
} }
} }
...@@ -201,7 +202,7 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb { ...@@ -201,7 +202,7 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb {
if (path.endsWith("/")) path = path.dropLast(1) if (path.endsWith("/")) path = path.dropLast(1)
if (mProcessingFolders.containsKey(path)) { if (mProcessingFolders.containsKey(path)) {
val finalPath = path val finalPath = path
handler.post { mProcessingFolders.get(finalPath).isEnabled = true } handler.post { mProcessingFolders.get(finalPath)?.isEnabled = true }
(adapter as StorageBrowserAdapter).updateMediaDirs(requireContext()) (adapter as StorageBrowserAdapter).updateMediaDirs(requireContext())
} }
} }
......
...@@ -72,7 +72,7 @@ fun getDocumentFiles(context: Context, path: String) : List<MediaWrapper>? { ...@@ -72,7 +72,7 @@ fun getDocumentFiles(context: Context, path: String) : List<MediaWrapper>? {
val parts = path.substringAfterLast(':').split("/".toRegex()).dropLastWhile { it.isEmpty() } val parts = path.substringAfterLast(':').split("/".toRegex()).dropLastWhile { it.isEmpty() }
for (part in parts) { for (part in parts) {
if (part == "") continue if (part == "") continue
documentFile = documentFile.findFile(part) documentFile = documentFile?.findFile(part)
} }
if (documentFile == null) { if (documentFile == null) {
...@@ -84,12 +84,12 @@ fun getDocumentFiles(context: Context, path: String) : List<MediaWrapper>? { ...@@ -84,12 +84,12 @@ fun getDocumentFiles(context: Context, path: String) : List<MediaWrapper>? {
val list = mutableListOf<MediaWrapper>() val list = mutableListOf<MediaWrapper>()
for (file in documentFile.listFiles()) { for (file in documentFile.listFiles()) {
if (file.exists() && file.canRead()) { if (file.exists() && file.canRead()) {
if (file.name.startsWith(".")) continue if (file.name?.startsWith(".") == true) continue
val mw = MediaWrapper(file.uri).apply { val mw = MediaWrapper(file.uri).apply {
type = when { type = when {
file.isDirectory -> MediaWrapper.TYPE_DIR file.isDirectory -> MediaWrapper.TYPE_DIR
file.type.startsWith("video") -> MediaWrapper.TYPE_VIDEO file.type?.startsWith("video") == true -> MediaWrapper.TYPE_VIDEO
file.type.startsWith("audio") -> MediaWrapper.TYPE_AUDIO file.type?.startsWith("audio") == true -> MediaWrapper.TYPE_AUDIO
else -> type else -> type
} }
title = file.name title = file.name
......
...@@ -69,7 +69,7 @@ class WriteExternalDelegate : BaseHeadlessFragment() { ...@@ -69,7 +69,7 @@ class WriteExternalDelegate : BaseHeadlessFragment() {
val persistedUriPermissions = contentResolver.persistedUriPermissions val persistedUriPermissions = contentResolver.persistedUriPermissions
for (uriPermission in persistedUriPermissions) { for (uriPermission in persistedUriPermissions) {
val file = DocumentFile.fromTreeUri(context, uriPermission.uri) 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) contentResolver.releasePersistableUriPermission(uriPermission.uri, Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment