mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-14 21:18:56 +01:00
Add .nomedia file in each chapter download folder (#2199)
* Move .nomedia creation to directory fetch * Add .nomedia file to all chapter download directories
This commit is contained in:
@@ -7,6 +7,7 @@ import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.os.EnvironmentCompat
|
||||
import com.hippo.unifile.UniFile
|
||||
import java.io.File
|
||||
|
||||
object DiskUtil {
|
||||
@@ -54,6 +55,19 @@ object DiskUtil {
|
||||
return directories
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't display downloaded chapters in gallery apps creating `.nomedia`.
|
||||
*/
|
||||
fun createNoMediaFile(dir: UniFile?, context: Context?) {
|
||||
if (dir != null && dir.exists()) {
|
||||
val nomedia = dir.findFile(".nomedia")
|
||||
if (nomedia == null) {
|
||||
dir.createFile(".nomedia")
|
||||
context?.let { scanMedia(it, dir.uri) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans the given file so that it can be shown in gallery apps, for example.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user