mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-17 04:10:39 +01:00
adding some USB related improvements
This commit is contained in:
parent
e4b5f2e51e
commit
ba21946f8f
@ -52,7 +52,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.18.14'
|
implementation 'com.simplemobiletools:commons:5.18.30'
|
||||||
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
||||||
implementation 'com.github.Stericson:RootShell:1.6'
|
implementation 'com.github.Stericson:RootShell:1.6'
|
||||||
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
||||||
|
@ -262,7 +262,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||||||
private fun getShortcutImage(path: String, drawable: Drawable, callback: () -> Unit) {
|
private fun getShortcutImage(path: String, drawable: Drawable, callback: () -> Unit) {
|
||||||
val appIconColor = baseConfig.appIconColor
|
val appIconColor = baseConfig.appIconColor
|
||||||
(drawable as LayerDrawable).findDrawableByLayerId(R.id.shortcut_folder_background).applyColorFilter(appIconColor)
|
(drawable as LayerDrawable).findDrawableByLayerId(R.id.shortcut_folder_background).applyColorFilter(appIconColor)
|
||||||
if (File(path).isDirectory) {
|
if (activity.getIsPathDirectory(path)) {
|
||||||
callback()
|
callback()
|
||||||
} else {
|
} else {
|
||||||
Thread {
|
Thread {
|
||||||
@ -297,7 +297,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addFileUris(path: String, paths: ArrayList<String>) {
|
private fun addFileUris(path: String, paths: ArrayList<String>) {
|
||||||
if (File(path).isDirectory) {
|
if (activity.getIsPathDirectory(path)) {
|
||||||
val shouldShowHidden = activity.config.shouldShowHidden
|
val shouldShowHidden = activity.config.shouldShowHidden
|
||||||
if (activity.isPathOnOTG(path)) {
|
if (activity.isPathOnOTG(path)) {
|
||||||
activity.getDocumentFile(path)?.listFiles()?.filter { if (shouldShowHidden) true else !it.name!!.startsWith(".") }?.forEach {
|
activity.getDocumentFile(path)?.listFiles()?.filter { if (shouldShowHidden) true else !it.name!!.startsWith(".") }?.forEach {
|
||||||
@ -471,10 +471,10 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||||||
val newPath = "$parentPath/$newFolderName/${entry.name.trimEnd('/')}"
|
val newPath = "$parentPath/$newFolderName/${entry.name.trimEnd('/')}"
|
||||||
|
|
||||||
val resolution = getConflictResolution(conflictResolutions, newPath)
|
val resolution = getConflictResolution(conflictResolutions, newPath)
|
||||||
val doesPathExist = File(newPath).exists()
|
val doesPathExist = activity.getDoesFilePathExist(newPath)
|
||||||
if (doesPathExist && resolution == CONFLICT_OVERWRITE) {
|
if (doesPathExist && resolution == CONFLICT_OVERWRITE) {
|
||||||
val fileDirItem = FileDirItem(newPath, newPath.getFilenameFromPath(), entry.isDirectory)
|
val fileDirItem = FileDirItem(newPath, newPath.getFilenameFromPath(), entry.isDirectory)
|
||||||
if (File(it).isDirectory) {
|
if (activity.getIsPathDirectory(it)) {
|
||||||
activity.deleteFolderBg(fileDirItem, false) {
|
activity.deleteFolderBg(fileDirItem, false) {
|
||||||
if (it) {
|
if (it) {
|
||||||
extractEntry(newPath, entry, zipFile)
|
extractEntry(newPath, entry, zipFile)
|
||||||
@ -505,7 +505,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||||||
|
|
||||||
private fun extractEntry(newPath: String, entry: ZipEntry, zipFile: ZipFile) {
|
private fun extractEntry(newPath: String, entry: ZipEntry, zipFile: ZipFile) {
|
||||||
if (entry.isDirectory) {
|
if (entry.isDirectory) {
|
||||||
if (!activity.createDirectorySync(newPath) && !File(newPath).exists()) {
|
if (!activity.createDirectorySync(newPath) && !activity.getDoesFilePathExist(newPath)) {
|
||||||
val error = String.format(activity.getString(R.string.could_not_create_file), newPath)
|
val error = String.format(activity.getString(R.string.could_not_create_file), newPath)
|
||||||
activity.showErrorToast(error)
|
activity.showErrorToast(error)
|
||||||
}
|
}
|
||||||
@ -544,17 +544,17 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||||||
val base = mainFile.parentFile.toURI()
|
val base = mainFile.parentFile.toURI()
|
||||||
res = zout
|
res = zout
|
||||||
queue.push(mainFile)
|
queue.push(mainFile)
|
||||||
if (mainFile.isDirectory) {
|
if (activity.getIsPathDirectory(mainFile.absolutePath)) {
|
||||||
name = "${mainFile.name.trimEnd('/')}/"
|
name = "${mainFile.name.trimEnd('/')}/"
|
||||||
zout.putNextEntry(ZipEntry(name))
|
zout.putNextEntry(ZipEntry(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
mainFile = queue.pop()
|
mainFile = queue.pop()
|
||||||
if (mainFile.isDirectory) {
|
if (activity.getIsPathDirectory(mainFile.absolutePath)) {
|
||||||
for (file in mainFile.listFiles()) {
|
for (file in mainFile.listFiles()) {
|
||||||
name = base.relativize(file.toURI()).path
|
name = base.relativize(file.toURI()).path
|
||||||
if (file.isDirectory) {
|
if (activity.getIsPathDirectory(file.absolutePath)) {
|
||||||
queue.push(file)
|
queue.push(file)
|
||||||
name = "${name.trimEnd('/')}/"
|
name = "${name.trimEnd('/')}/"
|
||||||
zout.putNextEntry(ZipEntry(name))
|
zout.putNextEntry(ZipEntry(name))
|
||||||
|
@ -8,14 +8,13 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_compress_as.view.*
|
import kotlinx.android.synthetic.main.dialog_compress_as.view.*
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String) -> Unit) {
|
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String) -> Unit) {
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_compress_as, null)
|
private val view = activity.layoutInflater.inflate(R.layout.dialog_compress_as, null)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val filename = path.getFilenameFromPath()
|
val filename = path.getFilenameFromPath()
|
||||||
val indexOfDot = if (filename.contains('.') && !File(path).isDirectory) filename.lastIndexOf(".") else filename.length
|
val indexOfDot = if (filename.contains('.') && !activity.getIsPathDirectory(path)) filename.lastIndexOf(".") else filename.length
|
||||||
val baseFilename = filename.substring(0, indexOfDot)
|
val baseFilename = filename.substring(0, indexOfDot)
|
||||||
var realPath = path.getParentPath()
|
var realPath = path.getParentPath()
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||||||
name.isEmpty() -> activity.toast(R.string.empty_name)
|
name.isEmpty() -> activity.toast(R.string.empty_name)
|
||||||
name.isAValidFilename() -> {
|
name.isAValidFilename() -> {
|
||||||
val newPath = "$realPath/$name.zip"
|
val newPath = "$realPath/$name.zip"
|
||||||
if (File(newPath).exists()) {
|
if (activity.getDoesFilePathExist(newPath)) {
|
||||||
activity.toast(R.string.name_taken)
|
activity.toast(R.string.name_taken)
|
||||||
return@OnClickListener
|
return@OnClickListener
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||||||
activity.toast(R.string.empty_name)
|
activity.toast(R.string.empty_name)
|
||||||
} else if (name.isAValidFilename()) {
|
} else if (name.isAValidFilename()) {
|
||||||
val newPath = "$path/$name"
|
val newPath = "$path/$name"
|
||||||
if (File(newPath).exists()) {
|
if (activity.getDoesFilePathExist(newPath)) {
|
||||||
activity.toast(R.string.name_taken)
|
activity.toast(R.string.name_taken)
|
||||||
return@OnClickListener
|
return@OnClickListener
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
|||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callback: (savePath: String) -> Unit) {
|
class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callback: (savePath: String) -> Unit) {
|
||||||
|
|
||||||
@ -65,7 +64,7 @@ class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callb
|
|||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File(newPath).exists()) {
|
if (activity.getDoesFilePathExist(newPath)) {
|
||||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
|
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
|
||||||
ConfirmationDialog(activity, title) {
|
ConfirmationDialog(activity, title) {
|
||||||
callback(newPath)
|
callback(newPath)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user