Fix #704. Dependency updates

This commit is contained in:
len
2017-03-11 16:00:07 +01:00
parent d8fa7bc9d2
commit b512c67b5d
5 changed files with 42 additions and 22 deletions

View File

@@ -1,6 +1,8 @@
package eu.kanade.tachiyomi.util
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.support.v4.content.ContextCompat
@@ -98,6 +100,20 @@ object DiskUtil {
return directories
}
/**
* Scans the given file so that it can be shown in gallery apps, for example.
*/
fun scanMedia(context: Context, file: File) {
val action = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
Intent.ACTION_MEDIA_MOUNTED
} else {
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE
}
val mediaScanIntent = Intent(action)
mediaScanIntent.data = Uri.fromFile(file)
context.sendBroadcast(mediaScanIntent)
}
/**
* Mutate the given filename to make it valid for a FAT filesystem,
* replacing any invalid characters with "_". This method doesn't allow hidden files (starting