Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code with latest code style #3975

Merged
merged 16 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*.{kt,kts}]
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_value-argument-comment = disabled
ktlint_standard_kdoc-wrapping = disabled
ktlint_standard_no-consecutive-comments = disabled
9 changes: 9 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Run this command to always ignore specific commits in `git blame`
# git config blame.ignoreRevsFile .git-blame-ignore-revs

# format all java files
94dae8259f075e4099cd92c258386dc39bfc30c1

# format all kotlin files
45178b3d348cd1fe768bcfc086b04b15ea5d69ea

File renamed without changes.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ dependencies {
testImplementation "io.mockk:mockk:$mockkVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutineTestVersion"
testImplementation "androidx.arch.core:core-testing:$androidXArchCoreTestVersion"
kaptTest "com.google.auto.service:auto-service:1.0-rc4"
testImplementation 'ch.qos.logback:logback-classic:1.4.14'
kaptTest "com.google.auto.service:auto-service:1.1.1"

androidTestImplementation "junit:junit:$junitVersion"//tests the app logic
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import java.util.concurrent.TimeUnit
@Suppress("StringLiteralDuplication")
@androidx.test.filters.Suppress
class FtpServiceEspressoTest {

@get:Rule
var serviceTestRule = ServiceTestRule()

Expand All @@ -88,10 +87,11 @@ class FtpServiceEspressoTest {
.remove(FtpService.KEY_PREFERENCE_USERNAME)
.remove(FtpService.KEY_PREFERENCE_PASSWORD)
.commit()
service = create(
Intent(FtpService.ACTION_START_FTPSERVER)
.putExtra(FtpService.TAG_STARTED_BY_TILE, false)
)
service =
create(
Intent(FtpService.ACTION_START_FTPSERVER)
.putExtra(FtpService.TAG_STARTED_BY_TILE, false),
)

await().atMost(10, TimeUnit.SECONDS).until {
FtpService.isRunning() && isServerReady()
Expand All @@ -116,10 +116,11 @@ class FtpServiceEspressoTest {
.remove(FtpService.KEY_PREFERENCE_USERNAME)
.remove(FtpService.KEY_PREFERENCE_PASSWORD)
.commit()
service = create(
Intent(FtpService.ACTION_START_FTPSERVER)
.putExtra(FtpService.TAG_STARTED_BY_TILE, false)
)
service =
create(
Intent(FtpService.ACTION_START_FTPSERVER)
.putExtra(FtpService.TAG_STARTED_BY_TILE, false),
)

await().atMost(10, TimeUnit.SECONDS).until {
FtpService.isRunning() && isServerReady()
Expand All @@ -146,14 +147,15 @@ class FtpServiceEspressoTest {
FtpService.KEY_PREFERENCE_PASSWORD,
PasswordUtil.encryptPassword(
ApplicationProvider.getApplicationContext(),
"passw0rD"
)
"passw0rD",
),
)
.commit()
service = create(
Intent(FtpService.ACTION_START_FTPSERVER)
.putExtra(FtpService.TAG_STARTED_BY_TILE, false)
)
service =
create(
Intent(FtpService.ACTION_START_FTPSERVER)
.putExtra(FtpService.TAG_STARTED_BY_TILE, false),
)

await().atMost(10, TimeUnit.SECONDS).until {
FtpService.isRunning() && isServerReady()
Expand All @@ -176,7 +178,7 @@ class FtpServiceEspressoTest {
assertTrue(
"No files found on device? It is also possible that app doesn't have " +
"permission to access storage, which may occur on broken Android emulators",
files.isNotEmpty()
files.isNotEmpty(),
)
var downloadFolderExists = false
for (f in files) {
Expand All @@ -187,7 +189,7 @@ class FtpServiceEspressoTest {
assertTrue(
"Download folder not found on device. Either storage is not available, " +
"or something is really wrong with FtpService. Check logcat.",
downloadFolderExists
downloadFolderExists,
)
}

Expand Down Expand Up @@ -289,13 +291,14 @@ class FtpServiceEspressoTest {
}

private fun create(intent: Intent): FtpService {
val binder = serviceTestRule
.bindService(
intent.setClass(
ApplicationProvider.getApplicationContext(),
FtpService::class.java
val binder =
serviceTestRule
.bindService(
intent.setClass(
ApplicationProvider.getApplicationContext(),
FtpService::class.java,
),
)
)
return ((binder as ObtainableServiceBinder<FtpService>).service as FtpService).also {
it.onStartCommand(intent, 0, 0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import org.junit.runner.RunWith
@SmallTest
@RunWith(AndroidJUnit4::class)
class FtpServiceStaticMethodsTest {

/** To test [FtpService.getLocalInetAddress] must not return an empty string. */
@Test
fun testGetLocalInetAddressMustNotBeEmpty() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2020 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2020 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2020 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2020 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2020 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2020 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ package com.amaze.filemanager.test
// import org.junit.Assert.assertTrue

object StoragePermissionHelper {

/**
* This method is intended for Android R or above devices to obtain MANAGE_EXTERNAL_STORAGE
* permission via UI Automator framework when running relevant Espresso tests.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2020 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import java.io.File

@RunWith(AndroidJUnit4::class)
class BackupPrefsFragmentTest {

var storagePath = "/storage/emulated/0"
var fileName = "amaze_backup.json"

Expand All @@ -63,7 +62,7 @@ class BackupPrefsFragmentTest {
File(
storagePath +
File.separator +
fileName
fileName,
)

exportFile.delete() // delete if already exists
Expand All @@ -80,7 +79,7 @@ class BackupPrefsFragmentTest {
File(
ApplicationProvider.getApplicationContext<Context>().cacheDir.absolutePath +
File.separator +
fileName
fileName,
)

Assert.assertTrue(tempFile.exists())
Expand Down Expand Up @@ -108,34 +107,37 @@ class BackupPrefsFragmentTest {
File(
storagePath +
File.separator +
fileName
fileName,
)

activityScenario.onActivity { preferencesActivity ->
preferencesActivity.supportFragmentManager.beginTransaction()
.add(backupPrefsFragment, null)
.commitNow()

val preferences = PreferenceManager
.getDefaultSharedPreferences(preferencesActivity)
val preferences =
PreferenceManager
.getDefaultSharedPreferences(preferencesActivity)

val preferenceMap: Map<String?, *> = preferences.all

val inputString = file
.inputStream()
.bufferedReader()
.use {
it.readText()
}
val inputString =
file
.inputStream()
.bufferedReader()
.use {
it.readText()
}

val type = object : TypeToken<Map<String?, *>>() {}.type

val importMap: Map<String?, *> = GsonBuilder()
.create()
.fromJson(
inputString,
type
)
val importMap: Map<String?, *> =
GsonBuilder()
.create()
.fromJson(
inputString,
type,
)

for ((key, value) in preferenceMap) {
var mapValue = importMap[key]
Expand All @@ -162,7 +164,7 @@ class BackupPrefsFragmentTest {
File(
storagePath +
File.separator +
fileName
fileName,
)

exportFile.delete() // delete if already exists
Expand All @@ -178,28 +180,31 @@ class BackupPrefsFragmentTest {
BackupPrefsFragment.IMPORT_BACKUP_FILE,
Activity.RESULT_OK,
Intent().setData(
Uri.fromFile(exportFile)
)
Uri.fromFile(exportFile),
),
)

val inputString = exportFile
.inputStream()
.bufferedReader()
.use {
it.readText()
}
val inputString =
exportFile
.inputStream()
.bufferedReader()
.use {
it.readText()
}

val type = object : TypeToken<Map<String?, *>>() {}.type

val importMap: Map<String?, *> = GsonBuilder()
.create()
.fromJson(
inputString,
type
)
val importMap: Map<String?, *> =
GsonBuilder()
.create()
.fromJson(
inputString,
type,
)

val preferences = PreferenceManager
.getDefaultSharedPreferences(preferencesActivity)
val preferences =
PreferenceManager
.getDefaultSharedPreferences(preferencesActivity)

val preferenceMap: Map<String?, *> = preferences.all

Expand All @@ -213,13 +218,14 @@ class BackupPrefsFragmentTest {
preferences: SharedPreferences,
importMap: Map<String?, *>,
key: String?,
value: Any?
value: Any?,
): Boolean {
when (value!!::class.simpleName) {
"Boolean" -> return importMap[key] as Boolean ==
preferences.getBoolean(key, false)
"Float" -> importMap[key] as Float ==
preferences.getFloat(key, 0f)
"Float" ->
importMap[key] as Float ==
preferences.getFloat(key, 0f)
"Int" -> {
// since Gson parses Integer as Double
val toInt = (importMap[key] as Double).toInt()
Expand Down
Loading
Loading