Skip to content

Commit

Permalink
Apply spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelMess committed Jan 29, 2022
1 parent d62d329 commit 7860d98
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.file_operations.filesystem.filetypes

import android.os.Parcel
Expand Down Expand Up @@ -134,7 +135,7 @@ class AmazeFile : Comparable<AmazeFile?> {

object AmazeFileParceler : Parceler<AmazeFile> {
override fun create(parcel: Parcel): AmazeFile =
AmazeFile(parcel.readString() ?: "")
AmazeFile(parcel.readString() ?: "")

override fun AmazeFile.write(parcel: Parcel, flags: Int) {
parcel.writeString(absolutePath)
Expand Down Expand Up @@ -257,7 +258,7 @@ class AmazeFile : Comparable<AmazeFile?> {
* `child` pathname string is taken to denote either a directory or a file. If the
* `child` pathname string is absolute then it is converted into a relative pathname in
* a system-dependent way. If `parent` is the empty string then the new `AmazeFile
` * instance is created by converting `child` into an abstract pathname and
` * instance is created by converting `child` into an abstract pathname and
* resolving the result against a system-dependent default directory. Otherwise each pathname
* string is converted into an abstract pathname and the child abstract pathname is resolved
* against the parent.
Expand Down Expand Up @@ -814,7 +815,9 @@ class AmazeFile : Comparable<AmazeFile?> {
* @see java.nio.file.Files.newDirectoryStream
*/
fun listFiles(
filter: AmazeFilenameFilter?, contextProvider: ContextProvider): Array<AmazeFile>? {
filter: AmazeFilenameFilter?,
contextProvider: ContextProvider
): Array<AmazeFile>? {
val ss = list(contextProvider) ?: return null
val files = ArrayList<AmazeFile>()
for (s in ss) if (filter == null || filter.accept(this, s)) files.add(AmazeFile(s!!, this))
Expand Down Expand Up @@ -888,8 +891,10 @@ class AmazeFile : Comparable<AmazeFile?> {
return false
}
val parent = canonFile.parentFile
return (parent != null && (parent.mkdirs(contextProvider) || parent.exists(contextProvider))
&& canonFile.mkdir(contextProvider))
return (
parent != null && (parent.mkdirs(contextProvider) || parent.exists(contextProvider)) &&
canonFile.mkdir(contextProvider)
)
}
// Android-changed: Replaced generic platform info with Android specific one.
/**
Expand Down Expand Up @@ -930,7 +935,7 @@ class AmazeFile : Comparable<AmazeFile?> {
* precision. The argument will be truncated to fit the supported precision. If the operation
* succeeds and no intervening operations on the file take place, then the next invocation of the
* `[.lastModified]` method will return the (possibly truncated) `time
` * argument that was passed to this method.
` * argument that was passed to this method.
*
* @param time The new last-modified time, measured in milliseconds since the epoch (00:00:00 GMT,
* January 1, 1970)
Expand Down Expand Up @@ -1205,7 +1210,11 @@ class AmazeFile : Comparable<AmazeFile?> {
val name = prefix + java.lang.Long.toString(n) + suffix
val f = AmazeFile(dir, name)
if (name != f.name || f.isInvalid) {
if (System.getSecurityManager() != null) throw IOException("Unable to create temporary file") else throw IOException("Unable to create temporary file, $f")
if (System.getSecurityManager() != null) {
throw IOException("Unable to create temporary file")
} else {
throw IOException("Unable to create temporary file, $f")
}
}
return f
}
Expand Down Expand Up @@ -1253,7 +1262,7 @@ class AmazeFile : Comparable<AmazeFile?> {
* @param prefix The prefix string to be used in generating the file's name; must be at least
* three characters long
* @param suffix The suffix string to be used in generating the file's name; may be `null
` * , in which case the suffix `".tmp"` will be used
` * , in which case the suffix `".tmp"` will be used
* @param directory The directory in which the file is to be created, or `null` if the
* default temporary-file directory is to be used
* @return An abstract pathname denoting a newly-created empty file
Expand All @@ -1263,10 +1272,11 @@ class AmazeFile : Comparable<AmazeFile?> {
*/
@Throws(IOException::class)
fun createTempFile(
contextProvider: ContextProvider,
prefix: String,
suffix: String?,
directory: AmazeFile?): AmazeFile {
contextProvider: ContextProvider,
prefix: String,
suffix: String?,
directory: AmazeFile?
): AmazeFile {
require(prefix.length >= 3) { "Prefix string too short" }

// Android-changed: Handle java.io.tmpdir changes.
Expand All @@ -1293,7 +1303,7 @@ class AmazeFile : Comparable<AmazeFile?> {
* @param prefix The prefix string to be used in generating the file's name; must be at least
* three characters long
* @param suffix The suffix string to be used in generating the file's name; may be `null
` * , in which case the suffix `".tmp"` will be used
` * , in which case the suffix `".tmp"` will be used
* @return An abstract pathname denoting a newly-created empty file
* @throws IllegalArgumentException If the `prefix` argument contains fewer than three
* characters
Expand All @@ -1302,7 +1312,10 @@ class AmazeFile : Comparable<AmazeFile?> {
*/
@Throws(IOException::class)
fun createTempFile(
contextProvider: ContextProvider, prefix: String, suffix: String?): AmazeFile {
contextProvider: ContextProvider,
prefix: String,
suffix: String?
): AmazeFile {
return createTempFile(contextProvider, prefix, suffix, null)
}
/* -- Basic infrastructure -- */
Expand Down Expand Up @@ -1360,4 +1373,4 @@ class AmazeFile : Comparable<AmazeFile?> {
override fun toString(): String {
return path
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.file_operations.filesystem.filetypes

import java.io.File
Expand Down Expand Up @@ -172,7 +173,7 @@ abstract class AmazeFilesystem {

/**
* Delete the file or directory denoted by the given abstract pathname, returning `true
` * if and only if the operation succeeds.
` * if and only if the operation succeeds.
*/
abstract fun delete(f: AmazeFile, contextProvider: ContextProvider): Boolean

Expand All @@ -184,7 +185,9 @@ abstract class AmazeFilesystem {
abstract fun list(f: AmazeFile, contextProvider: ContextProvider): Array<String>?
abstract fun getInputStream(f: AmazeFile, contextProvider: ContextProvider): InputStream?
abstract fun getOutputStream(
f: AmazeFile, contextProvider: ContextProvider): OutputStream?
f: AmazeFile,
contextProvider: ContextProvider
): OutputStream?

/**
* Create a new directory denoted by the given abstract pathname, returning `true` if
Expand All @@ -197,7 +200,10 @@ abstract class AmazeFilesystem {
* pathname, returning `true` if and only if the operation succeeds.
*/
abstract fun rename(
file1: AmazeFile, file2: AmazeFile, contextProvider: ContextProvider): Boolean
file1: AmazeFile,
file2: AmazeFile,
contextProvider: ContextProvider
): Boolean

/**
* Set the last-modified time of the file or directory denoted by the given abstract pathname,
Expand Down Expand Up @@ -356,8 +362,10 @@ abstract class AmazeFilesystem {
}

init {
useCanonCaches = getBooleanProperty("sun.io.useCanonCaches", useCanonCaches)
useCanonPrefixCache = getBooleanProperty("sun.io.useCanonPrefixCache", useCanonPrefixCache)
useCanonCaches =
getBooleanProperty("sun.io.useCanonCaches", useCanonCaches)
useCanonPrefixCache =
getBooleanProperty("sun.io.useCanonPrefixCache", useCanonPrefixCache)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud

import android.util.Log
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.ContextProvider
import com.cloudrail.si.types.CloudMetaData
import java.io.File
Expand All @@ -34,7 +35,9 @@ import java.util.*
abstract class CloudAmazeFilesystem : AmazeFilesystem() {
abstract val account: Account
override fun prefixLength(path: String): Int {
require(path.length != 0) { "This should never happen, all paths must start with OTG prefix" }
require(path.isNotEmpty()) {
"This should never happen, all paths must start with OTG prefix"
}
return super.prefixLength(path)
}

Expand Down Expand Up @@ -182,7 +185,11 @@ abstract class CloudAmazeFilesystem : AmazeFilesystem() {
return true // This seems to never fail
}

override fun rename(file1: AmazeFile, file2: AmazeFile, contextProvider: ContextProvider): Boolean {
override fun rename(
file1: AmazeFile,
file2: AmazeFile,
contextProvider: ContextProvider
): Boolean {
val account = account.account ?: return false
account.move(removePrefix(file1.path), removePrefix(file2.path))
return true // This seems to never fail
Expand Down Expand Up @@ -221,4 +228,4 @@ abstract class CloudAmazeFilesystem : AmazeFilesystem() {
companion object {
val TAG = CloudAmazeFilesystem::class.java.simpleName
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.box

import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.box.BoxAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.Account
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.box.BoxAccount
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem

object BoxAmazeFilesystem : CloudAmazeFilesystem() {
@JvmStatic
Expand All @@ -35,8 +34,8 @@ object BoxAmazeFilesystem : CloudAmazeFilesystem() {
AmazeFile.addFilesystem(this)
}

override val prefix: String = PREFIX
override val prefix: String = PREFIX

override val account: Account
get() = BoxAccount
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.dropbox

import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.dropbox.DropboxAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.Account
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.dropbox.DropboxAccount
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem

object DropboxAmazeFilesystem : CloudAmazeFilesystem() {
@JvmStatic
Expand All @@ -34,8 +33,8 @@ object DropboxAmazeFilesystem : CloudAmazeFilesystem() {
AmazeFile.addFilesystem(this)
}

override val prefix: String = PREFIX
override val prefix: String = PREFIX

override val account: Account
get() = DropboxAccount
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.gdrive

import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.gdrive.GoogledriveAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.Account
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.gdrive.GoogledriveAccount
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem

object GoogledriveAmazeFilesystem : CloudAmazeFilesystem() {
@JvmStatic
Expand All @@ -38,4 +37,4 @@ object GoogledriveAmazeFilesystem : CloudAmazeFilesystem() {

override val account: Account
get() = GoogledriveAccount
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.onedrive

import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.Account
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem

object OnedriveAmazeFilesystem : CloudAmazeFilesystem() {
@JvmStatic
Expand All @@ -36,4 +37,4 @@ object OnedriveAmazeFilesystem : CloudAmazeFilesystem() {

override val account: Account
get() = OnedriveAccount
}
}

0 comments on commit 7860d98

Please sign in to comment.