Refactoring: Constants & FileTypes
This commit is contained in:
parent
6e500c23e5
commit
883874a5ab
@ -14,7 +14,7 @@ open class BaseActivity: AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
themeValue = sharedPrefs.getString(ConstValues.THEME_VALUE_KEY, ConstValues.DEFAULT_THEME_VALUE)!!
|
themeValue = sharedPrefs.getString(Constants.THEME_VALUE_KEY, Constants.DEFAULT_THEME_VALUE)!!
|
||||||
if (shouldCheckTheme && applyCustomTheme) {
|
if (shouldCheckTheme && applyCustomTheme) {
|
||||||
when (themeValue) {
|
when (themeValue) {
|
||||||
"black_green" -> setTheme(R.style.BlackGreen)
|
"black_green" -> setTheme(R.style.BlackGreen)
|
||||||
|
@ -50,7 +50,7 @@ class ChangePasswordActivity: BaseActivity() {
|
|||||||
if (!usfFingerprint || fingerprintProtector == null) {
|
if (!usfFingerprint || fingerprintProtector == null) {
|
||||||
binding.checkboxSavePassword.visibility = View.GONE
|
binding.checkboxSavePassword.visibility = View.GONE
|
||||||
}
|
}
|
||||||
if (sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false)) {
|
if (sharedPrefs.getBoolean(Constants.PIN_PASSWORDS_KEY, false)) {
|
||||||
arrayOf(binding.editCurrentPassword, binding.editNewPassword, binding.editPasswordConfirm).forEach {
|
arrayOf(binding.editCurrentPassword, binding.editNewPassword, binding.editPasswordConfirm).forEach {
|
||||||
it.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
|
it.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
|
||||||
}
|
}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
package sushi.hardcore.droidfs
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
object ConstValues {
|
|
||||||
const val VOLUME_DATABASE_NAME = "SavedVolumes"
|
|
||||||
const val CRYFS_LOCAL_STATE_DIR = "cryfsLocalState"
|
|
||||||
const val SORT_ORDER_KEY = "sort_order"
|
|
||||||
val FAKE_URI: Uri = Uri.parse("fakeuri://droidfs")
|
|
||||||
const val WIPE_PASSES = 2
|
|
||||||
const val IO_BUFF_SIZE = 16384
|
|
||||||
const val SLIDESHOW_DELAY: Long = 4000
|
|
||||||
const val DEFAULT_THEME_VALUE = "dark_green"
|
|
||||||
const val THEME_VALUE_KEY = "theme"
|
|
||||||
const val DEFAULT_VOLUME_KEY = "default_volume"
|
|
||||||
const val REMEMBER_VOLUME_KEY = "remember_volume"
|
|
||||||
const val THUMBNAIL_MAX_SIZE_KEY = "thumbnail_max_size"
|
|
||||||
const val DEFAULT_THUMBNAIL_MAX_SIZE = 10_000L
|
|
||||||
const val PIN_PASSWORDS_KEY = "pin_passwords"
|
|
||||||
private val FILE_EXTENSIONS = mapOf(
|
|
||||||
Pair("image", listOf("png", "jpg", "jpeg", "gif", "webp", "bmp", "heic")),
|
|
||||||
Pair("video", listOf("mp4", "webm", "mkv", "mov")),
|
|
||||||
Pair("audio", listOf("mp3", "ogg", "m4a", "wav", "flac")),
|
|
||||||
Pair("pdf", listOf("pdf")),
|
|
||||||
Pair("text", listOf("txt", "json", "conf", "log", "xml", "java", "kt", "py", "pl", "rb", "go", "c", "h", "cpp", "hpp", "rs", "sh", "bat", "js", "html", "css", "php", "yml", "yaml", "toml", "ini", "md", "properties"))
|
|
||||||
)
|
|
||||||
|
|
||||||
fun isExtensionType(extensionType: String, path: String): Boolean {
|
|
||||||
return FILE_EXTENSIONS[extensionType]?.contains(File(path).extension.lowercase()) ?: false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isImage(path: String): Boolean {
|
|
||||||
return isExtensionType("image", path)
|
|
||||||
}
|
|
||||||
fun isVideo(path: String): Boolean {
|
|
||||||
return isExtensionType("video", path)
|
|
||||||
}
|
|
||||||
fun isAudio(path: String): Boolean {
|
|
||||||
return isExtensionType("audio", path)
|
|
||||||
}
|
|
||||||
fun isPDF(path: String): Boolean {
|
|
||||||
return isExtensionType("pdf", path)
|
|
||||||
}
|
|
||||||
fun isText(path: String): Boolean {
|
|
||||||
return isExtensionType("text", path)
|
|
||||||
}
|
|
||||||
}
|
|
20
app/src/main/java/sushi/hardcore/droidfs/Constants.kt
Normal file
20
app/src/main/java/sushi/hardcore/droidfs/Constants.kt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package sushi.hardcore.droidfs
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
|
||||||
|
object Constants {
|
||||||
|
const val VOLUME_DATABASE_NAME = "SavedVolumes"
|
||||||
|
const val CRYFS_LOCAL_STATE_DIR = "cryfsLocalState"
|
||||||
|
const val SORT_ORDER_KEY = "sort_order"
|
||||||
|
val FAKE_URI: Uri = Uri.parse("fakeuri://droidfs")
|
||||||
|
const val WIPE_PASSES = 2
|
||||||
|
const val IO_BUFF_SIZE = 16384
|
||||||
|
const val SLIDESHOW_DELAY: Long = 4000
|
||||||
|
const val DEFAULT_THEME_VALUE = "dark_green"
|
||||||
|
const val THEME_VALUE_KEY = "theme"
|
||||||
|
const val DEFAULT_VOLUME_KEY = "default_volume"
|
||||||
|
const val REMEMBER_VOLUME_KEY = "remember_volume"
|
||||||
|
const val THUMBNAIL_MAX_SIZE_KEY = "thumbnail_max_size"
|
||||||
|
const val DEFAULT_THUMBNAIL_MAX_SIZE = 10_000L
|
||||||
|
const val PIN_PASSWORDS_KEY = "pin_passwords"
|
||||||
|
}
|
87
app/src/main/java/sushi/hardcore/droidfs/FileTypes.kt
Normal file
87
app/src/main/java/sushi/hardcore/droidfs/FileTypes.kt
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package sushi.hardcore.droidfs
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
object FileTypes {
|
||||||
|
private val FILE_EXTENSIONS = mapOf(
|
||||||
|
Pair("image", listOf("png", "jpg", "jpeg", "gif", "webp", "bmp", "heic")),
|
||||||
|
Pair("video", listOf("mp4", "webm", "mkv", "mov")),
|
||||||
|
Pair("audio", listOf("mp3", "ogg", "m4a", "wav", "flac")),
|
||||||
|
Pair("pdf", listOf("pdf")),
|
||||||
|
Pair("text", listOf(
|
||||||
|
"asc",
|
||||||
|
"asm",
|
||||||
|
"awk",
|
||||||
|
"bash",
|
||||||
|
"c",
|
||||||
|
"cfg",
|
||||||
|
"conf",
|
||||||
|
"cpp",
|
||||||
|
"css",
|
||||||
|
"csv",
|
||||||
|
"desktop",
|
||||||
|
"dot",
|
||||||
|
"g4",
|
||||||
|
"go",
|
||||||
|
"gradle",
|
||||||
|
"h",
|
||||||
|
"hpp",
|
||||||
|
"hs",
|
||||||
|
"html",
|
||||||
|
"ini",
|
||||||
|
"java",
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"kt",
|
||||||
|
"lisp",
|
||||||
|
"log",
|
||||||
|
"lua",
|
||||||
|
"markdown",
|
||||||
|
"md",
|
||||||
|
"mod",
|
||||||
|
"org",
|
||||||
|
"php",
|
||||||
|
"pl",
|
||||||
|
"pro",
|
||||||
|
"properties",
|
||||||
|
"py",
|
||||||
|
"qml",
|
||||||
|
"rb",
|
||||||
|
"rc",
|
||||||
|
"rs",
|
||||||
|
"sh",
|
||||||
|
"smali",
|
||||||
|
"sql",
|
||||||
|
"srt",
|
||||||
|
"tex",
|
||||||
|
"toml",
|
||||||
|
"ts",
|
||||||
|
"txt",
|
||||||
|
"vala",
|
||||||
|
"vim",
|
||||||
|
"xml",
|
||||||
|
"yaml",
|
||||||
|
"yml",
|
||||||
|
))
|
||||||
|
)
|
||||||
|
|
||||||
|
fun isExtensionType(extensionType: String, path: String): Boolean {
|
||||||
|
return FILE_EXTENSIONS[extensionType]?.contains(File(path).extension.lowercase()) ?: false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isImage(path: String): Boolean {
|
||||||
|
return isExtensionType("image", path)
|
||||||
|
}
|
||||||
|
fun isVideo(path: String): Boolean {
|
||||||
|
return isExtensionType("video", path)
|
||||||
|
}
|
||||||
|
fun isAudio(path: String): Boolean {
|
||||||
|
return isExtensionType("audio", path)
|
||||||
|
}
|
||||||
|
fun isPDF(path: String): Boolean {
|
||||||
|
return isExtensionType("pdf", path)
|
||||||
|
}
|
||||||
|
fun isText(path: String): Boolean {
|
||||||
|
return isExtensionType("text", path)
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ import androidx.documentfile.provider.DocumentFile
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import sushi.hardcore.droidfs.ConstValues.DEFAULT_VOLUME_KEY
|
import sushi.hardcore.droidfs.Constants.DEFAULT_VOLUME_KEY
|
||||||
import sushi.hardcore.droidfs.adapters.VolumeAdapter
|
import sushi.hardcore.droidfs.adapters.VolumeAdapter
|
||||||
import sushi.hardcore.droidfs.add_volume.AddVolumeActivity
|
import sushi.hardcore.droidfs.add_volume.AddVolumeActivity
|
||||||
import sushi.hardcore.droidfs.content_providers.RestrictedFileProvider
|
import sushi.hardcore.droidfs.content_providers.RestrictedFileProvider
|
||||||
@ -137,7 +137,7 @@ class MainActivity : BaseActivity(), VolumeAdapter.Listener {
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
// refresh theme if changed in SettingsActivity
|
// refresh theme if changed in SettingsActivity
|
||||||
val newThemeValue = sharedPrefs.getString(ConstValues.THEME_VALUE_KEY, ConstValues.DEFAULT_THEME_VALUE)!!
|
val newThemeValue = sharedPrefs.getString(Constants.THEME_VALUE_KEY, Constants.DEFAULT_THEME_VALUE)!!
|
||||||
onThemeChanged(newThemeValue)
|
onThemeChanged(newThemeValue)
|
||||||
volumeOpener.themeValue = newThemeValue
|
volumeOpener.themeValue = newThemeValue
|
||||||
volumeAdapter.refresh()
|
volumeAdapter.refresh()
|
||||||
|
@ -60,7 +60,7 @@ class SettingsActivity : BaseActivity() {
|
|||||||
showMaxSizeDialog()
|
showMaxSizeDialog()
|
||||||
} else {
|
} else {
|
||||||
with(sharedPrefs.edit()) {
|
with(sharedPrefs.edit()) {
|
||||||
putLong(ConstValues.THUMBNAIL_MAX_SIZE_KEY, value)
|
putLong(Constants.THUMBNAIL_MAX_SIZE_KEY, value)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
maxSizePreference.summary = PathUtils.formatSize(size)
|
maxSizePreference.summary = PathUtils.formatSize(size)
|
||||||
@ -82,16 +82,16 @@ class SettingsActivity : BaseActivity() {
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
||||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
findPreference<ListPreference>(ConstValues.THEME_VALUE_KEY)?.setOnPreferenceChangeListener { _, newValue ->
|
findPreference<ListPreference>(Constants.THEME_VALUE_KEY)?.setOnPreferenceChangeListener { _, newValue ->
|
||||||
(activity as BaseActivity).onThemeChanged(newValue as String)
|
(activity as BaseActivity).onThemeChanged(newValue as String)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
findPreference<Preference>(ConstValues.THUMBNAIL_MAX_SIZE_KEY)?.let {
|
findPreference<Preference>(Constants.THUMBNAIL_MAX_SIZE_KEY)?.let {
|
||||||
maxSizePreference = it
|
maxSizePreference = it
|
||||||
maxSizePreference.summary = getString(
|
maxSizePreference.summary = getString(
|
||||||
R.string.thumbnail_max_size_summary,
|
R.string.thumbnail_max_size_summary,
|
||||||
PathUtils.formatSize(sharedPrefs.getLong(
|
PathUtils.formatSize(sharedPrefs.getLong(
|
||||||
ConstValues.THUMBNAIL_MAX_SIZE_KEY, ConstValues.DEFAULT_THUMBNAIL_MAX_SIZE
|
Constants.THUMBNAIL_MAX_SIZE_KEY, Constants.DEFAULT_THUMBNAIL_MAX_SIZE
|
||||||
)*1000)
|
)*1000)
|
||||||
)
|
)
|
||||||
maxSizePreference.setOnPreferenceClickListener {
|
maxSizePreference.setOnPreferenceClickListener {
|
||||||
|
@ -10,7 +10,7 @@ import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
|||||||
import sushi.hardcore.droidfs.util.PathUtils
|
import sushi.hardcore.droidfs.util.PathUtils
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class VolumeDatabase(private val context: Context): SQLiteOpenHelper(context, ConstValues.VOLUME_DATABASE_NAME, null, 4) {
|
class VolumeDatabase(private val context: Context): SQLiteOpenHelper(context, Constants.VOLUME_DATABASE_NAME, null, 4) {
|
||||||
companion object {
|
companion object {
|
||||||
const val TABLE_NAME = "Volumes"
|
const val TABLE_NAME = "Volumes"
|
||||||
const val COLUMN_NAME = "name"
|
const val COLUMN_NAME = "name"
|
||||||
|
@ -9,7 +9,7 @@ import android.widget.Toast
|
|||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import sushi.hardcore.droidfs.ConstValues.DEFAULT_VOLUME_KEY
|
import sushi.hardcore.droidfs.Constants.DEFAULT_VOLUME_KEY
|
||||||
import sushi.hardcore.droidfs.databinding.DialogOpenVolumeBinding
|
import sushi.hardcore.droidfs.databinding.DialogOpenVolumeBinding
|
||||||
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
||||||
import sushi.hardcore.droidfs.util.ObjRef
|
import sushi.hardcore.droidfs.util.ObjRef
|
||||||
@ -28,7 +28,7 @@ class VolumeOpener(
|
|||||||
private val volumeDatabase = VolumeDatabase(activity)
|
private val volumeDatabase = VolumeDatabase(activity)
|
||||||
private var fingerprintProtector: FingerprintProtector? = null
|
private var fingerprintProtector: FingerprintProtector? = null
|
||||||
private val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity)
|
private val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
var themeValue = sharedPrefs.getString(ConstValues.THEME_VALUE_KEY, ConstValues.DEFAULT_THEME_VALUE)!!
|
var themeValue = sharedPrefs.getString(Constants.THEME_VALUE_KEY, Constants.DEFAULT_THEME_VALUE)!!
|
||||||
var defaultVolumeName: String? = sharedPrefs.getString(DEFAULT_VOLUME_KEY, null)
|
var defaultVolumeName: String? = sharedPrefs.getString(DEFAULT_VOLUME_KEY, null)
|
||||||
private var dialogBinding: DialogOpenVolumeBinding? = null
|
private var dialogBinding: DialogOpenVolumeBinding? = null
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class VolumeOpener(
|
|||||||
onPasswordSubmitted(volume, isVolumeSaved, callbacks)
|
onPasswordSubmitted(volume, isVolumeSaved, callbacks)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
if (sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false)) {
|
if (sharedPrefs.getBoolean(Constants.PIN_PASSWORDS_KEY, false)) {
|
||||||
inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
|
inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import com.bumptech.glide.Glide
|
|||||||
import com.bumptech.glide.request.target.DrawableImageViewTarget
|
import com.bumptech.glide.request.target.DrawableImageViewTarget
|
||||||
import com.bumptech.glide.request.transition.Transition
|
import com.bumptech.glide.request.transition.Transition
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.FileTypes
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
||||||
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
||||||
@ -173,17 +173,17 @@ class ExplorerElementAdapter(
|
|||||||
override fun bind(explorerElement: ExplorerElement, position: Int, isSelected: Boolean) {
|
override fun bind(explorerElement: ExplorerElement, position: Int, isSelected: Boolean) {
|
||||||
super.bind(explorerElement, position, isSelected)
|
super.bind(explorerElement, position, isSelected)
|
||||||
when {
|
when {
|
||||||
ConstValues.isImage(explorerElement.name) -> {
|
FileTypes.isImage(explorerElement.name) -> {
|
||||||
setThumbnailOrDefaultIcon(explorerElement.fullPath, R.drawable.icon_file_image)
|
setThumbnailOrDefaultIcon(explorerElement.fullPath, R.drawable.icon_file_image)
|
||||||
}
|
}
|
||||||
ConstValues.isVideo(explorerElement.name) -> {
|
FileTypes.isVideo(explorerElement.name) -> {
|
||||||
setThumbnailOrDefaultIcon(explorerElement.fullPath, R.drawable.icon_file_video)
|
setThumbnailOrDefaultIcon(explorerElement.fullPath, R.drawable.icon_file_video)
|
||||||
}
|
}
|
||||||
else -> icon.setImageResource(
|
else -> icon.setImageResource(
|
||||||
when {
|
when {
|
||||||
ConstValues.isText(explorerElement.name) -> R.drawable.icon_file_text
|
FileTypes.isText(explorerElement.name) -> R.drawable.icon_file_text
|
||||||
ConstValues.isPDF(explorerElement.name) -> R.drawable.icon_file_pdf
|
FileTypes.isPDF(explorerElement.name) -> R.drawable.icon_file_pdf
|
||||||
ConstValues.isAudio(explorerElement.name) -> R.drawable.icon_file_audio
|
FileTypes.isAudio(explorerElement.name) -> R.drawable.icon_file_audio
|
||||||
else -> R.drawable.icon_file_unknown
|
else -> R.drawable.icon_file_unknown
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -99,7 +99,7 @@ class AddVolumeActivity: BaseActivity() {
|
|||||||
volumePath,
|
volumePath,
|
||||||
isHidden,
|
isHidden,
|
||||||
rememberVolume,
|
rememberVolume,
|
||||||
sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false),
|
sharedPrefs.getBoolean(Constants.PIN_PASSWORDS_KEY, false),
|
||||||
sharedPrefs.getBoolean("usf_fingerprint", false),
|
sharedPrefs.getBoolean("usf_fingerprint", false),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -30,7 +30,7 @@ class CreateVolumeFragment: Fragment() {
|
|||||||
private const val KEY_VOLUME_PATH = "path"
|
private const val KEY_VOLUME_PATH = "path"
|
||||||
private const val KEY_IS_HIDDEN = "hidden"
|
private const val KEY_IS_HIDDEN = "hidden"
|
||||||
private const val KEY_REMEMBER_VOLUME = "remember"
|
private const val KEY_REMEMBER_VOLUME = "remember"
|
||||||
private const val KEY_PIN_PASSWORDS = ConstValues.PIN_PASSWORDS_KEY
|
private const val KEY_PIN_PASSWORDS = Constants.PIN_PASSWORDS_KEY
|
||||||
private const val KEY_USF_FINGERPRINT = "fingerprint"
|
private const val KEY_USF_FINGERPRINT = "fingerprint"
|
||||||
|
|
||||||
fun newInstance(
|
fun newInstance(
|
||||||
@ -55,7 +55,7 @@ class CreateVolumeFragment: Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var binding: FragmentCreateVolumeBinding
|
private lateinit var binding: FragmentCreateVolumeBinding
|
||||||
private var themeValue = ConstValues.DEFAULT_THEME_VALUE
|
private var themeValue = Constants.DEFAULT_THEME_VALUE
|
||||||
private val volumeTypes = ArrayList<String>(2)
|
private val volumeTypes = ArrayList<String>(2)
|
||||||
private lateinit var volumePath: String
|
private lateinit var volumePath: String
|
||||||
private var isHiddenVolume: Boolean = false
|
private var isHiddenVolume: Boolean = false
|
||||||
|
@ -20,7 +20,7 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import sushi.hardcore.droidfs.VolumeData
|
import sushi.hardcore.droidfs.VolumeData
|
||||||
import sushi.hardcore.droidfs.VolumeDatabase
|
import sushi.hardcore.droidfs.VolumeDatabase
|
||||||
@ -62,7 +62,7 @@ class SelectPathFragment: Fragment() {
|
|||||||
if (uri != null)
|
if (uri != null)
|
||||||
onDirectoryPicked(uri)
|
onDirectoryPicked(uri)
|
||||||
}
|
}
|
||||||
private var themeValue = ConstValues.DEFAULT_THEME_VALUE
|
private var themeValue = Constants.DEFAULT_THEME_VALUE
|
||||||
private lateinit var volumeDatabase: VolumeDatabase
|
private lateinit var volumeDatabase: VolumeDatabase
|
||||||
private lateinit var filesDir: String
|
private lateinit var filesDir: String
|
||||||
private lateinit var sharedPrefs: SharedPreferences
|
private lateinit var sharedPrefs: SharedPreferences
|
||||||
@ -82,7 +82,7 @@ class SelectPathFragment: Fragment() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
originalRememberVolume = sharedPrefs.getBoolean(ConstValues.REMEMBER_VOLUME_KEY, true)
|
originalRememberVolume = sharedPrefs.getBoolean(Constants.REMEMBER_VOLUME_KEY, true)
|
||||||
binding.switchRemember.isChecked = originalRememberVolume
|
binding.switchRemember.isChecked = originalRememberVolume
|
||||||
arguments?.let { arguments ->
|
arguments?.let { arguments ->
|
||||||
arguments.getString(KEY_THEME_VALUE)?.let { themeValue = it }
|
arguments.getString(KEY_THEME_VALUE)?.let { themeValue = it }
|
||||||
@ -229,7 +229,7 @@ class SelectPathFragment: Fragment() {
|
|||||||
private fun onPathSelected() {
|
private fun onPathSelected() {
|
||||||
if (binding.switchRemember.isChecked != originalRememberVolume) {
|
if (binding.switchRemember.isChecked != originalRememberVolume) {
|
||||||
with(sharedPrefs.edit()) {
|
with(sharedPrefs.edit()) {
|
||||||
putBoolean(ConstValues.REMEMBER_VOLUME_KEY, binding.switchRemember.isChecked)
|
putBoolean(Constants.REMEMBER_VOLUME_KEY, binding.switchRemember.isChecked)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,8 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import sushi.hardcore.droidfs.BaseActivity
|
import sushi.hardcore.droidfs.BaseActivity
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.ConstValues.isAudio
|
import sushi.hardcore.droidfs.FileTypes
|
||||||
import sushi.hardcore.droidfs.ConstValues.isImage
|
|
||||||
import sushi.hardcore.droidfs.ConstValues.isPDF
|
|
||||||
import sushi.hardcore.droidfs.ConstValues.isText
|
|
||||||
import sushi.hardcore.droidfs.ConstValues.isVideo
|
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import sushi.hardcore.droidfs.adapters.ExplorerElementAdapter
|
import sushi.hardcore.droidfs.adapters.ExplorerElementAdapter
|
||||||
import sushi.hardcore.droidfs.adapters.OpenAsDialogAdapter
|
import sushi.hardcore.droidfs.adapters.OpenAsDialogAdapter
|
||||||
@ -88,7 +84,7 @@ open class BaseExplorerActivity : BaseActivity(), ExplorerElementAdapter.Listene
|
|||||||
sortOrderValues = resources.getStringArray(R.array.sort_orders_values)
|
sortOrderValues = resources.getStringArray(R.array.sort_orders_values)
|
||||||
foldersFirst = sharedPrefs.getBoolean("folders_first", true)
|
foldersFirst = sharedPrefs.getBoolean("folders_first", true)
|
||||||
mapFolders = sharedPrefs.getBoolean("map_folders", true)
|
mapFolders = sharedPrefs.getBoolean("map_folders", true)
|
||||||
currentSortOrderIndex = resources.getStringArray(R.array.sort_orders_values).indexOf(sharedPrefs.getString(ConstValues.SORT_ORDER_KEY, "name"))
|
currentSortOrderIndex = resources.getStringArray(R.array.sort_orders_values).indexOf(sharedPrefs.getString(Constants.SORT_ORDER_KEY, "name"))
|
||||||
init()
|
init()
|
||||||
recycler_view_explorer = findViewById(R.id.recycler_view_explorer)
|
recycler_view_explorer = findViewById(R.id.recycler_view_explorer)
|
||||||
refresher = findViewById(R.id.refresher)
|
refresher = findViewById(R.id.refresher)
|
||||||
@ -112,7 +108,7 @@ open class BaseExplorerActivity : BaseActivity(), ExplorerElementAdapter.Listene
|
|||||||
null
|
null
|
||||||
},
|
},
|
||||||
this,
|
this,
|
||||||
sharedPrefs.getLong(ConstValues.THUMBNAIL_MAX_SIZE_KEY, ConstValues.DEFAULT_THUMBNAIL_MAX_SIZE)*1000,
|
sharedPrefs.getLong(Constants.THUMBNAIL_MAX_SIZE_KEY, Constants.DEFAULT_THUMBNAIL_MAX_SIZE)*1000,
|
||||||
)
|
)
|
||||||
explorerViewModel = ViewModelProvider(this).get(ExplorerViewModel::class.java)
|
explorerViewModel = ViewModelProvider(this).get(ExplorerViewModel::class.java)
|
||||||
currentDirectoryPath = explorerViewModel.currentDirectoryPath
|
currentDirectoryPath = explorerViewModel.currentDirectoryPath
|
||||||
@ -233,19 +229,19 @@ open class BaseExplorerActivity : BaseActivity(), ExplorerElementAdapter.Listene
|
|||||||
explorerElements[position].isParentFolder -> {
|
explorerElements[position].isParentFolder -> {
|
||||||
setCurrentPath(PathUtils.getParentPath(currentDirectoryPath))
|
setCurrentPath(PathUtils.getParentPath(currentDirectoryPath))
|
||||||
}
|
}
|
||||||
isImage(fullPath) -> {
|
FileTypes.isImage(fullPath) -> {
|
||||||
startFileViewer(ImageViewer::class.java, fullPath)
|
startFileViewer(ImageViewer::class.java, fullPath)
|
||||||
}
|
}
|
||||||
isVideo(fullPath) -> {
|
FileTypes.isVideo(fullPath) -> {
|
||||||
startFileViewer(VideoPlayer::class.java, fullPath)
|
startFileViewer(VideoPlayer::class.java, fullPath)
|
||||||
}
|
}
|
||||||
isText(fullPath) -> {
|
FileTypes.isText(fullPath) -> {
|
||||||
startFileViewer(TextEditor::class.java, fullPath)
|
startFileViewer(TextEditor::class.java, fullPath)
|
||||||
}
|
}
|
||||||
isPDF(fullPath) -> {
|
FileTypes.isPDF(fullPath) -> {
|
||||||
startFileViewer(PdfViewer::class.java, fullPath)
|
startFileViewer(PdfViewer::class.java, fullPath)
|
||||||
}
|
}
|
||||||
isAudio(fullPath) -> {
|
FileTypes.isAudio(fullPath) -> {
|
||||||
startFileViewer(AudioPlayer::class.java, fullPath)
|
startFileViewer(AudioPlayer::class.java, fullPath)
|
||||||
}
|
}
|
||||||
else -> showOpenAsDialog(fullPath)
|
else -> showOpenAsDialog(fullPath)
|
||||||
@ -271,7 +267,7 @@ open class BaseExplorerActivity : BaseActivity(), ExplorerElementAdapter.Listene
|
|||||||
unselectAll(false)
|
unselectAll(false)
|
||||||
explorerAdapter.explorerElements = explorerElements
|
explorerAdapter.explorerElements = explorerElements
|
||||||
val sharedPrefsEditor = sharedPrefs.edit()
|
val sharedPrefsEditor = sharedPrefs.edit()
|
||||||
sharedPrefsEditor.putString(ConstValues.SORT_ORDER_KEY, sortOrderValues[currentSortOrderIndex])
|
sharedPrefsEditor.putString(Constants.SORT_ORDER_KEY, sortOrderValues[currentSortOrderIndex])
|
||||||
sharedPrefsEditor.apply()
|
sharedPrefsEditor.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import androidx.core.app.NotificationCompat
|
|||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.documentfile.provider.DocumentFile
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
||||||
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
||||||
@ -130,7 +130,7 @@ class FileOperationService : Service() {
|
|||||||
val dstFileHandle = encryptedVolume.openFile(dstPath)
|
val dstFileHandle = encryptedVolume.openFile(dstPath)
|
||||||
if (dstFileHandle != -1L) {
|
if (dstFileHandle != -1L) {
|
||||||
var offset: Long = 0
|
var offset: Long = 0
|
||||||
val ioBuffer = ByteArray(ConstValues.IO_BUFF_SIZE)
|
val ioBuffer = ByteArray(Constants.IO_BUFF_SIZE)
|
||||||
var length: Long
|
var length: Long
|
||||||
while (remoteEncryptedVolume.read(srcFileHandle, offset, ioBuffer, 0, ioBuffer.size.toLong()).also { length = it.toLong() } > 0) {
|
while (remoteEncryptedVolume.read(srcFileHandle, offset, ioBuffer, 0, ioBuffer.size.toLong()).also { length = it.toLong() } > 0) {
|
||||||
val written = encryptedVolume.write(dstFileHandle, offset, ioBuffer, 0, length).toLong()
|
val written = encryptedVolume.write(dstFileHandle, offset, ioBuffer, 0, length).toLong()
|
||||||
|
@ -5,7 +5,7 @@ import com.google.android.exoplayer2.C
|
|||||||
import com.google.android.exoplayer2.upstream.DataSource
|
import com.google.android.exoplayer2.upstream.DataSource
|
||||||
import com.google.android.exoplayer2.upstream.DataSpec
|
import com.google.android.exoplayer2.upstream.DataSpec
|
||||||
import com.google.android.exoplayer2.upstream.TransferListener
|
import com.google.android.exoplayer2.upstream.TransferListener
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ class EncryptedVolumeDataSource(private val encryptedVolume: EncryptedVolume, pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getUri(): Uri {
|
override fun getUri(): Uri {
|
||||||
return ConstValues.FAKE_URI
|
return Constants.FAKE_URI
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
|
@ -12,7 +12,7 @@ import kotlinx.coroutines.isActive
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import sushi.hardcore.droidfs.BaseActivity
|
import sushi.hardcore.droidfs.BaseActivity
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.FileTypes
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import sushi.hardcore.droidfs.content_providers.RestrictedFileProvider
|
import sushi.hardcore.droidfs.content_providers.RestrictedFileProvider
|
||||||
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
||||||
@ -116,7 +116,7 @@ abstract class FileViewerActivity: BaseActivity() {
|
|||||||
encryptedVolume.recursiveMapFiles(originalParentPath)?.let { elements ->
|
encryptedVolume.recursiveMapFiles(originalParentPath)?.let { elements ->
|
||||||
for (e in elements) {
|
for (e in elements) {
|
||||||
if (e.isRegularFile) {
|
if (e.isRegularFile) {
|
||||||
if (ConstValues.isExtensionType(getFileType(), e.name) || filePath == e.fullPath) {
|
if (FileTypes.isExtensionType(getFileType(), e.name) || filePath == e.fullPath) {
|
||||||
mappedPlaylist.add(e)
|
mappedPlaylist.add(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import com.bumptech.glide.Glide
|
|||||||
import com.bumptech.glide.RequestBuilder
|
import com.bumptech.glide.RequestBuilder
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import sushi.hardcore.droidfs.databinding.ActivityImageViewerBinding
|
import sushi.hardcore.droidfs.databinding.ActivityImageViewerBinding
|
||||||
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
||||||
@ -120,7 +120,7 @@ class ImageViewer: FileViewerActivity() {
|
|||||||
binding.imageButtonSlideshow.setOnClickListener {
|
binding.imageButtonSlideshow.setOnClickListener {
|
||||||
if (!slideshowActive){
|
if (!slideshowActive){
|
||||||
slideshowActive = true
|
slideshowActive = true
|
||||||
handler.postDelayed(slideshowNext, ConstValues.SLIDESHOW_DELAY)
|
handler.postDelayed(slideshowNext, Constants.SLIDESHOW_DELAY)
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
hideUI.run()
|
hideUI.run()
|
||||||
Toast.makeText(this, R.string.slideshow_started, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.slideshow_started, Toast.LENGTH_SHORT).show()
|
||||||
@ -187,7 +187,7 @@ class ImageViewer: FileViewerActivity() {
|
|||||||
if (!slideshowSwipe) { //reset slideshow delay if user swipes
|
if (!slideshowSwipe) { //reset slideshow delay if user swipes
|
||||||
handler.removeCallbacks(slideshowNext)
|
handler.removeCallbacks(slideshowNext)
|
||||||
}
|
}
|
||||||
handler.postDelayed(slideshowNext, ConstValues.SLIDESHOW_DELAY)
|
handler.postDelayed(slideshowNext, Constants.SLIDESHOW_DELAY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
|
|||||||
import com.google.android.exoplayer2.source.MediaSource
|
import com.google.android.exoplayer2.source.MediaSource
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
||||||
import com.google.android.exoplayer2.video.VideoSize
|
import com.google.android.exoplayer2.video.VideoSize
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -27,7 +27,7 @@ abstract class MediaPlayer: FileViewerActivity() {
|
|||||||
private fun createMediaSource(filePath: String): MediaSource {
|
private fun createMediaSource(filePath: String): MediaSource {
|
||||||
val dataSourceFactory = EncryptedVolumeDataSource.Factory(encryptedVolume, filePath)
|
val dataSourceFactory = EncryptedVolumeDataSource.Factory(encryptedVolume, filePath)
|
||||||
return ProgressiveMediaSource.Factory(dataSourceFactory, DefaultExtractorsFactory())
|
return ProgressiveMediaSource.Factory(dataSourceFactory, DefaultExtractorsFactory())
|
||||||
.createMediaSource(MediaItem.fromUri(ConstValues.FAKE_URI))
|
.createMediaSource(MediaItem.fromUri(Constants.FAKE_URI))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initializePlayer(){
|
private fun initializePlayer(){
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package sushi.hardcore.droidfs.filesystems
|
package sushi.hardcore.droidfs.filesystems
|
||||||
|
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
||||||
import sushi.hardcore.droidfs.util.ObjRef
|
import sushi.hardcore.droidfs.util.ObjRef
|
||||||
import sushi.hardcore.droidfs.util.PathUtils
|
import sushi.hardcore.droidfs.util.PathUtils
|
||||||
@ -47,7 +47,7 @@ class CryfsVolume(private val fusePtr: Long): EncryptedVolume() {
|
|||||||
private external fun nativeIsClosed(fusePtr: Long): Boolean
|
private external fun nativeIsClosed(fusePtr: Long): Boolean
|
||||||
|
|
||||||
fun getLocalStateDir(filesDir: String): String {
|
fun getLocalStateDir(filesDir: String): String {
|
||||||
return PathUtils.pathJoin(filesDir, ConstValues.CRYFS_LOCAL_STATE_DIR)
|
return PathUtils.pathJoin(filesDir, Constants.CRYFS_LOCAL_STATE_DIR)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun init(
|
private fun init(
|
||||||
|
@ -4,7 +4,7 @@ import android.content.Context
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.VolumeData
|
import sushi.hardcore.droidfs.VolumeData
|
||||||
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
||||||
import sushi.hardcore.droidfs.util.ObjRef
|
import sushi.hardcore.droidfs.util.ObjRef
|
||||||
@ -94,7 +94,7 @@ abstract class EncryptedVolume: Parcelable {
|
|||||||
|
|
||||||
fun exportFile(fileHandle: Long, os: OutputStream): Boolean {
|
fun exportFile(fileHandle: Long, os: OutputStream): Boolean {
|
||||||
var offset: Long = 0
|
var offset: Long = 0
|
||||||
val ioBuffer = ByteArray(ConstValues.IO_BUFF_SIZE)
|
val ioBuffer = ByteArray(Constants.IO_BUFF_SIZE)
|
||||||
var length: Int
|
var length: Int
|
||||||
while (read(fileHandle, offset, ioBuffer, 0, ioBuffer.size.toLong()).also { length = it } > 0) {
|
while (read(fileHandle, offset, ioBuffer, 0, ioBuffer.size.toLong()).also { length = it } > 0) {
|
||||||
os.write(ioBuffer, 0, length)
|
os.write(ioBuffer, 0, length)
|
||||||
@ -131,7 +131,7 @@ abstract class EncryptedVolume: Parcelable {
|
|||||||
if (dstfileHandle != -1L) {
|
if (dstfileHandle != -1L) {
|
||||||
var success = true
|
var success = true
|
||||||
var offset: Long = 0
|
var offset: Long = 0
|
||||||
val ioBuffer = ByteArray(ConstValues.IO_BUFF_SIZE)
|
val ioBuffer = ByteArray(Constants.IO_BUFF_SIZE)
|
||||||
var length: Long
|
var length: Long
|
||||||
while (inputStream.read(ioBuffer).also { length = it.toLong() } > 0) {
|
while (inputStream.read(ioBuffer).also { length = it.toLong() } > 0) {
|
||||||
val written = write(dstfileHandle, offset, ioBuffer, 0, length).toLong()
|
val written = write(dstfileHandle, offset, ioBuffer, 0, length).toLong()
|
||||||
|
@ -4,7 +4,7 @@ import android.content.Context
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.OpenableColumns
|
import android.provider.OpenableColumns
|
||||||
import androidx.documentfile.provider.DocumentFile
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import sushi.hardcore.droidfs.ConstValues
|
import sushi.hardcore.droidfs.Constants
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
@ -25,11 +25,11 @@ object Wiper {
|
|||||||
val buff = ByteArray(buff_size)
|
val buff = ByteArray(buff_size)
|
||||||
Arrays.fill(buff, 0.toByte())
|
Arrays.fill(buff, 0.toByte())
|
||||||
val writes = ceil(size.toDouble() / buff_size).toInt()
|
val writes = ceil(size.toDouble() / buff_size).toInt()
|
||||||
for (i in 0 until ConstValues.WIPE_PASSES) {
|
for (i in 0 until Constants.WIPE_PASSES) {
|
||||||
for (j in 0 until writes) {
|
for (j in 0 until writes) {
|
||||||
os.write(buff)
|
os.write(buff)
|
||||||
}
|
}
|
||||||
if (i < ConstValues.WIPE_PASSES - 1) {
|
if (i < Constants.WIPE_PASSES - 1) {
|
||||||
//reopening to flush and seek
|
//reopening to flush and seek
|
||||||
os.close()
|
os.close()
|
||||||
os = context.contentResolver.openOutputStream(uri)!!
|
os = context.contentResolver.openOutputStream(uri)!!
|
||||||
@ -57,11 +57,11 @@ object Wiper {
|
|||||||
val buff = ByteArray(buff_size)
|
val buff = ByteArray(buff_size)
|
||||||
Arrays.fill(buff, 0.toByte())
|
Arrays.fill(buff, 0.toByte())
|
||||||
val writes = ceil(size.toDouble() / buff_size).toInt()
|
val writes = ceil(size.toDouble() / buff_size).toInt()
|
||||||
for (i in 0 until ConstValues.WIPE_PASSES) {
|
for (i in 0 until Constants.WIPE_PASSES) {
|
||||||
for (j in 0 until writes) {
|
for (j in 0 until writes) {
|
||||||
os.write(buff)
|
os.write(buff)
|
||||||
}
|
}
|
||||||
if (i < ConstValues.WIPE_PASSES - 1) {
|
if (i < Constants.WIPE_PASSES - 1) {
|
||||||
//reopening to flush and seek
|
//reopening to flush and seek
|
||||||
os.close()
|
os.close()
|
||||||
os = FileOutputStream(file)
|
os = FileOutputStream(file)
|
||||||
|
Loading…
Reference in New Issue
Block a user