forked from hardcoresushi/DroidFS
Compare commits
9 Commits
translate_
...
master
Author | SHA1 | Date | |
---|---|---|---|
82dda95211 | |||
40bed2db21 | |||
f901495e41 | |||
07f5f8b5d9 | |||
2d5f5a82c9 | |||
b477272d65 | |||
88bd746359 | |||
9872cab7c2 | |||
4aa211bca4 |
@ -9,6 +9,8 @@ import android.system.Os
|
||||
import android.util.Log
|
||||
import androidx.preference.PreferenceManager
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
||||
import sushi.hardcore.droidfs.util.Compat
|
||||
@ -86,9 +88,11 @@ class EncryptedFileProvider(context: Context) {
|
||||
}
|
||||
|
||||
override fun free() {
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
Wiper.wipe(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ExportedMemFile private constructor(path: String, private val file: MemFile) :
|
||||
ExportedFile(path) {
|
||||
@ -160,8 +164,10 @@ class EncryptedFileProvider(context: Context) {
|
||||
exportedFile: ExportedFile,
|
||||
encryptedVolume: EncryptedVolume,
|
||||
): Boolean {
|
||||
val fd = exportedFile.open(ParcelFileDescriptor.MODE_WRITE_ONLY, false).fileDescriptor
|
||||
return encryptedVolume.exportFile(exportedFile.path, FileOutputStream(fd))
|
||||
val pfd = exportedFile.open(ParcelFileDescriptor.MODE_WRITE_ONLY, false)
|
||||
return encryptedVolume.exportFile(exportedFile.path, FileOutputStream(pfd.fileDescriptor)).also {
|
||||
pfd.close()
|
||||
}
|
||||
}
|
||||
|
||||
enum class Error {
|
||||
|
@ -4,8 +4,8 @@ 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("image", listOf("png", "jpg", "jpeg", "gif", "avif", "webp", "bmp", "heic")),
|
||||
Pair("video", listOf("mp4", "webm", "mkv", "mov", "m4v")),
|
||||
Pair("audio", listOf("mp3", "ogg", "m4a", "wav", "flac", "opus")),
|
||||
Pair("pdf", listOf("pdf")),
|
||||
Pair("text", listOf(
|
||||
|
@ -328,8 +328,8 @@ class ExplorerActivity : BaseExplorerActivity() {
|
||||
activityScope.launch {
|
||||
onTaskResult(
|
||||
fileOperationService.moveElements(volumeId, toMove, toClean),
|
||||
R.string.move_success,
|
||||
R.string.move_failed,
|
||||
R.string.move_success,
|
||||
)
|
||||
setCurrentPath(currentDirectoryPath)
|
||||
}
|
||||
|
@ -104,7 +104,9 @@ class FileOperationService : Service() {
|
||||
activity.lifecycle.addObserver(object : DefaultLifecycleObserver {
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
activity.unbindService(serviceConnection)
|
||||
service.notificationPermissionHelpers.removeLast()
|
||||
// Could have been more efficient with a LinkedHashMap but the JDK implementation doesn't allow
|
||||
// to access the latest element in O(1) unless using reflection
|
||||
service.notificationPermissionHelpers.removeAll { it.activity == activity }
|
||||
}
|
||||
})
|
||||
activity.bindService(
|
||||
|
@ -14,6 +14,8 @@ import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.coroutines.withContext
|
||||
import sushi.hardcore.droidfs.BaseActivity
|
||||
import sushi.hardcore.droidfs.FileTypes
|
||||
@ -21,7 +23,6 @@ import sushi.hardcore.droidfs.R
|
||||
import sushi.hardcore.droidfs.VolumeManagerApp
|
||||
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
||||
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
||||
import sushi.hardcore.droidfs.util.IntentUtils
|
||||
import sushi.hardcore.droidfs.util.PathUtils
|
||||
import sushi.hardcore.droidfs.util.finishOnClose
|
||||
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
||||
@ -32,9 +33,8 @@ abstract class FileViewerActivity: BaseActivity() {
|
||||
private lateinit var originalParentPath: String
|
||||
private lateinit var windowInsetsController: WindowInsetsControllerCompat
|
||||
private var windowTypeMask = 0
|
||||
private var foldersFirst = true
|
||||
private var wasMapped = false
|
||||
protected val mappedPlaylist = mutableListOf<ExplorerElement>()
|
||||
protected val playlist = mutableListOf<ExplorerElement>()
|
||||
private val playlistMutex = Mutex()
|
||||
protected var currentPlaylistIndex = -1
|
||||
private val isLegacyFullscreen = Build.VERSION.SDK_INT <= Build.VERSION_CODES.R
|
||||
|
||||
@ -46,7 +46,6 @@ abstract class FileViewerActivity: BaseActivity() {
|
||||
intent.getIntExtra("volumeId", -1)
|
||||
)!!
|
||||
finishOnClose(encryptedVolume)
|
||||
foldersFirst = sharedPrefs.getBoolean("folders_first", true)
|
||||
windowInsetsController = WindowInsetsControllerCompat(window, window.decorView)
|
||||
windowInsetsController.addOnControllableInsetsChangedListener { _, typeMask ->
|
||||
windowTypeMask = typeMask
|
||||
@ -131,48 +130,57 @@ abstract class FileViewerActivity: BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
protected fun createPlaylist() {
|
||||
if (!wasMapped){
|
||||
encryptedVolume.recursiveMapFiles(originalParentPath)?.let { elements ->
|
||||
for (e in elements) {
|
||||
if (e.isRegularFile) {
|
||||
if (FileTypes.isExtensionType(getFileType(), e.name) || filePath == e.fullPath) {
|
||||
mappedPlaylist.add(e)
|
||||
}
|
||||
}
|
||||
protected suspend fun createPlaylist() {
|
||||
playlistMutex.withLock {
|
||||
if (currentPlaylistIndex != -1) {
|
||||
// playlist already initialized
|
||||
return
|
||||
}
|
||||
withContext(Dispatchers.IO) {
|
||||
if (sharedPrefs.getBoolean("map_folders", true)) {
|
||||
encryptedVolume.recursiveMapFiles(originalParentPath)
|
||||
} else {
|
||||
encryptedVolume.readDir(originalParentPath)
|
||||
}?.filterTo(playlist) { e ->
|
||||
e.isRegularFile && (FileTypes.isExtensionType(getFileType(), e.name) || filePath == e.fullPath)
|
||||
}
|
||||
val sortOrder = intent.getStringExtra("sortOrder") ?: "name"
|
||||
ExplorerElement.sortBy(sortOrder, foldersFirst, mappedPlaylist)
|
||||
//find current index
|
||||
for ((i, e) in mappedPlaylist.withIndex()){
|
||||
if (filePath == e.fullPath){
|
||||
currentPlaylistIndex = i
|
||||
break
|
||||
val foldersFirst = sharedPrefs.getBoolean("folders_first", true)
|
||||
ExplorerElement.sortBy(sortOrder, foldersFirst, playlist)
|
||||
currentPlaylistIndex = playlist.indexOfFirst { it.fullPath == filePath }
|
||||
}
|
||||
}
|
||||
wasMapped = true
|
||||
}
|
||||
}
|
||||
|
||||
protected fun playlistNext(forward: Boolean) {
|
||||
private fun updateCurrentItem() {
|
||||
filePath = playlist[currentPlaylistIndex].fullPath
|
||||
}
|
||||
|
||||
protected suspend fun playlistNext(forward: Boolean) {
|
||||
createPlaylist()
|
||||
currentPlaylistIndex = if (forward) {
|
||||
(currentPlaylistIndex+1)%mappedPlaylist.size
|
||||
(currentPlaylistIndex + 1).mod(playlist.size)
|
||||
} else {
|
||||
var x = (currentPlaylistIndex-1)%mappedPlaylist.size
|
||||
if (x < 0) {
|
||||
x += mappedPlaylist.size
|
||||
(currentPlaylistIndex - 1).mod(playlist.size)
|
||||
}
|
||||
x
|
||||
}
|
||||
filePath = mappedPlaylist[currentPlaylistIndex].fullPath
|
||||
updateCurrentItem()
|
||||
}
|
||||
|
||||
protected fun refreshPlaylist() {
|
||||
mappedPlaylist.clear()
|
||||
wasMapped = false
|
||||
createPlaylist()
|
||||
protected suspend fun deleteCurrentFile(): Boolean {
|
||||
createPlaylist() // ensure we know the current position in the playlist
|
||||
return if (encryptedVolume.deleteFile(filePath)) {
|
||||
playlist.removeAt(currentPlaylistIndex)
|
||||
if (playlist.size != 0) {
|
||||
if (currentPlaylistIndex == playlist.size) {
|
||||
// deleted the last element of the playlist, go back to the first
|
||||
currentPlaylistIndex = 0
|
||||
}
|
||||
updateCurrentItem()
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
protected fun goBackToExplorer() {
|
||||
|
@ -12,10 +12,12 @@ import android.widget.Toast
|
||||
import androidx.activity.addCallback
|
||||
import androidx.activity.viewModels
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestBuilder
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||
import kotlinx.coroutines.launch
|
||||
import sushi.hardcore.droidfs.Constants
|
||||
import sushi.hardcore.droidfs.R
|
||||
import sushi.hardcore.droidfs.databinding.ActivityImageViewerBinding
|
||||
@ -105,17 +107,15 @@ class ImageViewer: FileViewerActivity() {
|
||||
.keepFullScreen()
|
||||
.setTitle(R.string.warning)
|
||||
.setPositiveButton(R.string.ok) { _, _ ->
|
||||
createPlaylist() //be sure the playlist is created before deleting if there is only one image
|
||||
if (encryptedVolume.deleteFile(filePath)) {
|
||||
playlistNext(true)
|
||||
refreshPlaylist()
|
||||
if (mappedPlaylist.size == 0) { //deleted all images of the playlist
|
||||
lifecycleScope.launch {
|
||||
if (deleteCurrentFile()) {
|
||||
if (playlist.size == 0) { // no more image left
|
||||
goBackToExplorer()
|
||||
} else {
|
||||
loadImage(true)
|
||||
}
|
||||
} else {
|
||||
CustomAlertDialogBuilder(this, theme)
|
||||
CustomAlertDialogBuilder(this@ImageViewer, theme)
|
||||
.keepFullScreen()
|
||||
.setTitle(R.string.error)
|
||||
.setMessage(getString(R.string.remove_failed, fileName))
|
||||
@ -123,6 +123,7 @@ class ImageViewer: FileViewerActivity() {
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setMessage(getString(R.string.single_delete_confirm, fileName))
|
||||
.show()
|
||||
@ -198,16 +199,18 @@ class ImageViewer: FileViewerActivity() {
|
||||
rotateImage()
|
||||
}
|
||||
|
||||
private fun swipeImage(deltaX: Float, slideshowSwipe: Boolean = false){
|
||||
private fun swipeImage(deltaX: Float, slideshowSwipe: Boolean = false) {
|
||||
lifecycleScope.launch {
|
||||
playlistNext(deltaX < 0)
|
||||
loadImage(true)
|
||||
if (slideshowActive) {
|
||||
if (!slideshowSwipe) { //reset slideshow delay if user swipes
|
||||
if (!slideshowSwipe) { // reset slideshow delay if user swipes
|
||||
handler.removeCallbacks(slideshowNext)
|
||||
}
|
||||
handler.postDelayed(slideshowNext, Constants.SLIDESHOW_DELAY)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopSlideshow(){
|
||||
slideshowActive = false
|
||||
|
@ -2,6 +2,7 @@ package sushi.hardcore.droidfs.file_viewers
|
||||
|
||||
import android.view.WindowManager
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.PlaybackException
|
||||
import androidx.media3.common.Player
|
||||
@ -11,6 +12,7 @@ import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.exoplayer.source.MediaSource
|
||||
import androidx.media3.exoplayer.source.ProgressiveMediaSource
|
||||
import androidx.media3.extractor.DefaultExtractorsFactory
|
||||
import kotlinx.coroutines.launch
|
||||
import sushi.hardcore.droidfs.Constants
|
||||
import sushi.hardcore.droidfs.R
|
||||
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
||||
@ -39,12 +41,16 @@ abstract class MediaPlayer: FileViewerActivity() {
|
||||
private fun initializePlayer(){
|
||||
player = ExoPlayer.Builder(this).setSeekForwardIncrementMs(5000).build()
|
||||
bindPlayer(player)
|
||||
player.addMediaSource(createMediaSource(filePath))
|
||||
lifecycleScope.launch {
|
||||
createPlaylist()
|
||||
for (e in mappedPlaylist) {
|
||||
player.addMediaSource(createMediaSource(e.fullPath))
|
||||
playlist.forEachIndexed { index, e ->
|
||||
if (index != currentPlaylistIndex) {
|
||||
player.addMediaSource(index, createMediaSource(e.fullPath))
|
||||
}
|
||||
}
|
||||
}
|
||||
player.repeatMode = Player.REPEAT_MODE_ALL
|
||||
player.seekToDefaultPosition(currentPlaylistIndex)
|
||||
player.playWhenReady = true
|
||||
player.addListener(object : Player.Listener{
|
||||
override fun onVideoSizeChanged(videoSize: VideoSize) {
|
||||
@ -67,11 +73,13 @@ abstract class MediaPlayer: FileViewerActivity() {
|
||||
}
|
||||
|
||||
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
|
||||
if (player.repeatMode != Player.REPEAT_MODE_ONE) {
|
||||
playlistNext(player.currentMediaItemIndex == (currentPlaylistIndex + 1) % mappedPlaylist.size)
|
||||
if (player.repeatMode != Player.REPEAT_MODE_ONE && currentPlaylistIndex != -1) {
|
||||
lifecycleScope.launch {
|
||||
playlistNext(player.currentMediaItemIndex == (currentPlaylistIndex + 1) % player.mediaItemCount)
|
||||
refreshFileName()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
player.prepare()
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ object AndroidUtils {
|
||||
/**
|
||||
* A [Manifest.permission.POST_NOTIFICATIONS] permission helper.
|
||||
*
|
||||
* Must be initialized before [Activity.onCreate].
|
||||
* Must be initialized before [Activity.onCreate] finishes.
|
||||
*/
|
||||
class NotificationPermissionHelper<out A: AppCompatActivity>(val activity: A) {
|
||||
private var listener: ((Boolean) -> Unit)? = null
|
||||
|
@ -196,6 +196,7 @@ Java_sushi_hardcore_droidfs_filesystems_GocryptfsVolume_native_1list_1dir(JNIEnv
|
||||
jint sessionID, jstring jplain_dir) {
|
||||
const char* plain_dir = (*env)->GetStringUTFChars(env, jplain_dir, NULL);
|
||||
const size_t plain_dir_len = strlen(plain_dir);
|
||||
const char append_slash = plain_dir[plain_dir_len-1] != '/';
|
||||
GoString go_plain_dir = {plain_dir, plain_dir_len};
|
||||
|
||||
struct gcf_list_dir_return elements = gcf_list_dir(sessionID, go_plain_dir);
|
||||
@ -216,7 +217,7 @@ Java_sushi_hardcore_droidfs_filesystems_GocryptfsVolume_native_1list_1dir(JNIEnv
|
||||
|
||||
char* fullPath = malloc(sizeof(char) * (plain_dir_len + nameLen + 2));
|
||||
strcpy(fullPath, plain_dir);
|
||||
if (plain_dir[-2] != '/') {
|
||||
if (append_slash) {
|
||||
strcat(fullPath, "/");
|
||||
}
|
||||
strcat(fullPath, name);
|
||||
|
@ -74,12 +74,11 @@
|
||||
<string name="usf_screenshot">אפשר צילומי מסך</string>
|
||||
<string name="usf_fingerprint">אפשר שימרת גיבוב של הסיסמא באמצעות טביעת אצבע</string>
|
||||
<string name="usf_volume_management">הגדרת אמצעי אחסון</string>
|
||||
<string name="usf_keep_open">השאר את האמצעי אחסון פתוח כשהאפליקציה רצה ברקע</string>
|
||||
<string name="unsafe_features">פיצרים לא בטוחים</string>
|
||||
<string name="manage_unsafe_features">נהל פיצרים לא בטוחים</string>
|
||||
<string name="manage_unsafe_features_summary">אפשר/מנע פיצרים לא בטוחים</string>
|
||||
<string name="usf_home_warning_msg">DroidFS מנסה להיות מאובטח ככל האפשר,עם זאת אבטחה כרוכה לעיתים קרובת בחוסר נוחות. זה הסיבה ש DroidFS מציע פיצרים לא בטוחים שאתה יכול להפעיל /להשבית בהתאם לצרכים שלך .
|
||||
|
||||
אזהרה: פיצרים אלה יכולים להיות לא בטוחים. אל תשתמש בהם אלא אם כן אתה יודע בידיוק מה אתה עושה. מומלץ מאוד לקרוא את הקובץ דוקמנטציה לפני שמפעילים אותם.</string>
|
||||
<string name="usf_home_warning_msg">DroidFS מנסה להיות מאובטח ככל האפשר,עם זאת אבטחה כרוכה לעיתים קרובת בחוסר נוחות. זה הסיבה ש DroidFS מציע פיצרים לא בטוחים שאתה יכול להפעיל /להשבית בהתאם לצרכים שלך .\n\n אזהרה: פיצרים אלה יכולים להיות לא בטוחים. אל תשתמש בהם אלא אם כן אתה יודע בידיוק מה אתה עושה. מומלץ מאוד לקרוא את הקובץ דוקמנטציה לפני שמפעילים אותם.</string>
|
||||
<string name="see_unsafe_features">הראה פיצרים לא בטוחים</string>
|
||||
<string name="open_as">פתח כ</string>
|
||||
<string name="image">תמונה</string>
|
||||
@ -198,7 +197,7 @@
|
||||
<string name="password_confirmation_label">חזור שנית על הסיסמא:</string>
|
||||
<string name="password_confirmation_hint">אישור סיסמא</string>
|
||||
<string name="password_hash_saved">הגיבוב של הסיסמא נשמר</string>
|
||||
<string name="no_volumes_text">אין אמצעי אחסון שמורים, הוסף ע\"י לחציה על הסימן +</string>
|
||||
<string name="no_volumes_text">אין אמצעי אחסון שמורים, הוסף ע"י לחציה על הסימן +</string>
|
||||
<string name="fingerprint_error_msg">לא ניתן להשתמש באימות טביעת אצבע: %s.</string>
|
||||
<string name="keyguard_not_secure">מגן מקשים לא מאובטח</string>
|
||||
<string name="no_hardware">לא נמצאה חומרה מתאימה</string>
|
||||
@ -232,7 +231,7 @@
|
||||
<string name="multiple_folders">%d תיקיות</string>
|
||||
<string name="default_open">פתח אמצעי אחסון זה בעת הפעלת היישום</string>
|
||||
<string name="remove_default_open">אל תפתח כברירת מחדל</string>
|
||||
<string name="elements_selected" formatted="false">%d/%d נבחרו</string>
|
||||
<string name="elements_selected">%d/%d נבחרו</string>
|
||||
<string name="pin_passwords_title">פריסת מקלדת מספרים</string>
|
||||
<string name="pin_passwords_summary">שימוש בפריסת מקלדת מספרים בעת הזנת סיסמאות אמצעי אחסון</string>
|
||||
<string name="volume_type_label">סוג אמצעי אחסון:</string>
|
||||
@ -280,18 +279,4 @@
|
||||
<string name="debug">דיבאג</string>
|
||||
<string name="logcat_title">DroidFS Logcat</string>
|
||||
<string name="logcat_saved">Logcat נשמר</string>
|
||||
<string name="later">אחר כך</string>
|
||||
<string name="notification_denied_msg">הרשאת ההתראות נדחתה. פעולות קובץ ברקע לא יהיו נראות. אתה יכול לשנות זאת בהגדרות ההרשאות של האפליקציה.</string>
|
||||
<string name="keep_alive_notification_title">שומר על האפליקציה שתרוץ ברקע</string>
|
||||
<string name="keep_alive_notification_text">אמצעי אחסון אחד או יותר נשמרים פתוחים.</string>
|
||||
<string name="close_all">סגור הכל</string>
|
||||
<string name="usf_background">בטל נעילה אוטומטית לאמצעי אחסון</string>
|
||||
<string name="usf_background_summary">אל תנעל את האמצעי אחסון כשהאפליקציה רצה ברקע</string>
|
||||
<string name="usf_keep_open">השאר את האמצעי אחסון פתוח כשהאפליקציה רצה ברקע</string>
|
||||
<string name="usf_keep_open_summary">השאר את האפליקציה רצה תמיד ברקע כדי לשמור על אמצעי אחסון פתוחים</string>
|
||||
<string name="gocryptfs_details">מהיר, אבל לא מסתיר את גדול הקבצים ומבנה התיקיות.</string>
|
||||
<string name="cryfs_details">איטי יותר, אבל מגן על מטא נתונים (גודל קבצים ומבנה תיקיות)
|
||||
ומונע מתקפה של החלפת קבצים.</string>
|
||||
<string name="or">או</string>
|
||||
<string name="enter_volume_path">הכנס מתיב תיקייה</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user