mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
cleaning up
This commit is contained in:
@ -330,10 +330,10 @@ class ItemsAdapter(
|
|||||||
if (activity.getIsPathDirectory(path)) {
|
if (activity.getIsPathDirectory(path)) {
|
||||||
val shouldShowHidden = activity.config.shouldShowHidden
|
val shouldShowHidden = activity.config.shouldShowHidden
|
||||||
when {
|
when {
|
||||||
activity.isRestrictedAndroidDir(path) -> {
|
activity.isRestrictedSAFOnlyRoot(path) -> {
|
||||||
activity.getStorageItemsWithTreeUri(path, shouldShowHidden, false) { files ->
|
activity.getAndroidSAFFileItems(path, shouldShowHidden, false) { files ->
|
||||||
files.forEach {
|
files.forEach {
|
||||||
addFileUris(activity.getPrimaryAndroidSAFUri(it.path).toString(), paths)
|
addFileUris(activity.getAndroidSAFUri(it.path).toString(), paths)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -403,7 +403,7 @@ class ItemsAdapter(
|
|||||||
if (!isCopyOperation) {
|
if (!isCopyOperation) {
|
||||||
files.forEach { sourceFileDir ->
|
files.forEach { sourceFileDir ->
|
||||||
val sourcePath = sourceFileDir.path
|
val sourcePath = sourceFileDir.path
|
||||||
if (activity.isRestrictedAndroidDir(sourcePath) && activity.getDoesFilePathExist(sourcePath)) {
|
if (activity.isRestrictedSAFOnlyRoot(sourcePath) && activity.getDoesFilePathExist(sourcePath)) {
|
||||||
activity.deleteFile(sourceFileDir, true) {
|
activity.deleteFile(sourceFileDir, true) {
|
||||||
listener?.refreshFragment()
|
listener?.refreshFragment()
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
@ -521,8 +521,7 @@ class ItemsAdapter(
|
|||||||
|
|
||||||
private fun tryDecompressingPaths(sourcePaths: List<String>, callback: (success: Boolean) -> Unit) {
|
private fun tryDecompressingPaths(sourcePaths: List<String>, callback: (success: Boolean) -> Unit) {
|
||||||
sourcePaths.forEach { path ->
|
sourcePaths.forEach { path ->
|
||||||
val zipInputStream = ZipInputStream(BufferedInputStream(activity.getFileInputStreamSync(path)))
|
ZipInputStream(BufferedInputStream(activity.getFileInputStreamSync(path))).use { zipInputStream ->
|
||||||
zipInputStream.use {
|
|
||||||
try {
|
try {
|
||||||
val fileDirItems = ArrayList<FileDirItem>()
|
val fileDirItems = ArrayList<FileDirItem>()
|
||||||
var entry = zipInputStream.nextEntry
|
var entry = zipInputStream.nextEntry
|
||||||
@ -541,6 +540,7 @@ class ItemsAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
|
exception.printStackTrace()
|
||||||
activity.showErrorToast(exception)
|
activity.showErrorToast(exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -643,8 +643,8 @@ class ItemsAdapter(
|
|||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
mainFilePath = queue.pop()
|
mainFilePath = queue.pop()
|
||||||
if (activity.getIsPathDirectory(mainFilePath)) {
|
if (activity.getIsPathDirectory(mainFilePath)) {
|
||||||
if (activity.isRestrictedAndroidDir(mainFilePath)) {
|
if (activity.isRestrictedSAFOnlyRoot(mainFilePath)) {
|
||||||
activity.getStorageItemsWithTreeUri(mainFilePath, true) { files ->
|
activity.getAndroidSAFFileItems(mainFilePath, true) { files ->
|
||||||
for (file in files) {
|
for (file in files) {
|
||||||
name = file.path.relativizeWith(base)
|
name = file.path.relativizeWith(base)
|
||||||
if (activity.getIsPathDirectory(file.path)) {
|
if (activity.getIsPathDirectory(file.path)) {
|
||||||
@ -884,8 +884,8 @@ class ItemsAdapter(
|
|||||||
path
|
path
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.isRestrictedAndroidDir(path)) {
|
if (activity.isRestrictedSAFOnlyRoot(path)) {
|
||||||
itemToLoad = activity.getPrimaryAndroidSAFUri(path)
|
itemToLoad = activity.getAndroidSAFUri(path)
|
||||||
} else if (hasOTGConnected && itemToLoad is String && activity.isPathOnOTG(itemToLoad) && baseConfig.OTGTreeUri.isNotEmpty() && baseConfig.OTGPartition.isNotEmpty()) {
|
} else if (hasOTGConnected && itemToLoad is String && activity.isPathOnOTG(itemToLoad) && baseConfig.OTGTreeUri.isNotEmpty() && baseConfig.OTGPartition.isNotEmpty()) {
|
||||||
itemToLoad = getOTGPublicPath(itemToLoad)
|
itemToLoad = getOTGPublicPath(itemToLoad)
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,27 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||||||
|
|
||||||
private fun createDirectory(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
private fun createDirectory(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
||||||
when {
|
when {
|
||||||
|
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
|
||||||
|
if (activity.isRestrictedSAFOnlyRoot(path)) {
|
||||||
|
activity.handlePrimaryAndroidSAFDialog(path) {
|
||||||
|
if (!it) {
|
||||||
|
callback(false)
|
||||||
|
return@handlePrimaryAndroidSAFDialog
|
||||||
|
}
|
||||||
|
if (activity.createAndroidSAFDirectory(path)) {
|
||||||
|
success(alertDialog)
|
||||||
|
} else {
|
||||||
|
val error = String.format(activity.getString(R.string.could_not_create_folder), path)
|
||||||
|
activity.showErrorToast(error)
|
||||||
|
callback(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (File(path).mkdirs()) {
|
||||||
|
success(alertDialog)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) {
|
activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
return@handleSAFDialog
|
return@handleSAFDialog
|
||||||
@ -66,27 +87,6 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||||||
documentFile.createDirectory(path.getFilenameFromPath())
|
documentFile.createDirectory(path.getFilenameFromPath())
|
||||||
success(alertDialog)
|
success(alertDialog)
|
||||||
}
|
}
|
||||||
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
|
|
||||||
if (activity.isRestrictedAndroidDir(path)) {
|
|
||||||
activity.handlePrimaryAndroidSAFDialog(path) {
|
|
||||||
if (!it) {
|
|
||||||
callback(false)
|
|
||||||
return@handlePrimaryAndroidSAFDialog
|
|
||||||
}
|
|
||||||
if (activity.createSAFOnlyDirectory(path)) {
|
|
||||||
success(alertDialog)
|
|
||||||
} else {
|
|
||||||
val error = String.format(activity.getString(R.string.could_not_create_folder), path)
|
|
||||||
activity.showErrorToast(error)
|
|
||||||
callback(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (File(path).mkdirs()) {
|
|
||||||
success(alertDialog)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> {
|
else -> {
|
||||||
RootHelpers(activity).createFileFolder(path, false) {
|
RootHelpers(activity).createFileFolder(path, false) {
|
||||||
if (it) {
|
if (it) {
|
||||||
@ -102,13 +102,13 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||||||
private fun createFile(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
private fun createFile(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
||||||
try {
|
try {
|
||||||
when {
|
when {
|
||||||
activity.isRestrictedAndroidDir(path) -> {
|
activity.isRestrictedSAFOnlyRoot(path) -> {
|
||||||
activity.handlePrimaryAndroidSAFDialog(path) {
|
activity.handlePrimaryAndroidSAFDialog(path) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
callback(false)
|
callback(false)
|
||||||
return@handlePrimaryAndroidSAFDialog
|
return@handlePrimaryAndroidSAFDialog
|
||||||
}
|
}
|
||||||
if (activity.createSAFOnlyFile(path)) {
|
if (activity.createAndroidSAFFile(path)) {
|
||||||
success(alertDialog)
|
success(alertDialog)
|
||||||
} else {
|
} else {
|
||||||
val error = String.format(activity.getString(R.string.could_not_create_file), path)
|
val error = String.format(activity.getString(R.string.could_not_create_file), path)
|
||||||
@ -141,7 +141,6 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||||||
success(alertDialog)
|
success(alertDialog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
RootHelpers(activity).createFileFolder(path, true) {
|
RootHelpers(activity).createFileFolder(path, true) {
|
||||||
if (it) {
|
if (it) {
|
||||||
|
@ -3,9 +3,8 @@ package com.simplemobiletools.filemanager.pro.extensions
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.simplemobiletools.commons.extensions.isPathOnOTG
|
import com.simplemobiletools.commons.extensions.isPathOnOTG
|
||||||
import com.simplemobiletools.commons.extensions.isPathOnSD
|
import com.simplemobiletools.commons.extensions.isPathOnSD
|
||||||
import com.simplemobiletools.commons.extensions.otgPath
|
|
||||||
import com.simplemobiletools.commons.extensions.sdCardPath
|
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.Config
|
import com.simplemobiletools.filemanager.pro.helpers.Config
|
||||||
|
|
||||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||||
|
|
||||||
fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || isPathOnOTG(path) || (isPathOnSD(path)))
|
fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || isPathOnOTG(path) || (isPathOnSD(path)))
|
||||||
|
@ -187,15 +187,15 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
||||||
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
|
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
|
||||||
|
|
||||||
if (context.isRestrictedAndroidDir(path)) {
|
if (context.isRestrictedSAFOnlyRoot(path)) {
|
||||||
activity?.handlePrimaryAndroidSAFDialog(path) {
|
activity?.handlePrimaryAndroidSAFDialog(path) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
activity?.toast(R.string.no_storage_permissions)
|
activity?.toast(R.string.no_storage_permissions)
|
||||||
return@handlePrimaryAndroidSAFDialog
|
return@handlePrimaryAndroidSAFDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
context.getStorageItemsWithTreeUri(path, context.config.shouldShowHidden, getProperChildCount) {
|
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden, getProperChildCount) { fileItems ->
|
||||||
callback(path, getListItemsFromFileDirItems(it))
|
callback(path, getListItemsFromFileDirItems(fileItems))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,7 +149,6 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
|
||||||
activity?.showErrorToast(e)
|
activity?.showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
app:showAsAction="always"/>
|
app:showAsAction="always"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_properties"
|
android:id="@+id/cab_properties"
|
||||||
android:icon="@drawable/ic_info"
|
android:icon="@drawable/ic_info_vector"
|
||||||
android:title="@string/properties"
|
android:title="@string/properties"
|
||||||
app:showAsAction="always"/>
|
app:showAsAction="always"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_rename"
|
android:id="@+id/cab_rename"
|
||||||
android:icon="@drawable/ic_rename_new"
|
android:icon="@drawable/ic_rename_new_vector"
|
||||||
android:title="@string/rename"
|
android:title="@string/rename"
|
||||||
app:showAsAction="always"/>
|
app:showAsAction="always"/>
|
||||||
<item
|
<item
|
||||||
@ -28,7 +28,7 @@
|
|||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_hide"
|
android:id="@+id/cab_hide"
|
||||||
android:icon="@drawable/ic_hide"
|
android:icon="@drawable/ic_hide_vector"
|
||||||
android:title="@string/hide"
|
android:title="@string/hide"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
<item
|
||||||
|
@ -44,9 +44,9 @@
|
|||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
|
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
|
||||||
<string name="app_title">Simple File Manager Pro - Manage files easily & fast</string>
|
<string name="app_title">Simple File Manager Pro - Manage files easily & fast</string>
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
<string name="app_short_description">Quick file management with no ads. Browse files easily, securely & fast</string>
|
<string name="app_short_description">Quick file management with no ads. Browse files easily, securely & fast</string>
|
||||||
<string name="app_long_description">
|
<string name="app_long_description">
|
||||||
Un xestor de ficheiros rápido e lixeiro para uso diario. Ofrece unha funcionalidade de busca útil e podes personalizar o cartafol de inicio e seleccionar os cartafoles favoritos para un acceso rápido.
|
Un xestor de ficheiros rápido e lixeiro para uso diario. Ofrece unha funcionalidade de busca útil e podes personalizar o cartafol de inicio e seleccionar os cartafoles favoritos para un acceso rápido.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user