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:
arkon
2019-12-26 12:39:20 -05:00
committed by GitHub
parent 5ddd7d1b14
commit b8b118bdeb
4 changed files with 19 additions and 11 deletions

View File

@@ -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.
*/