Skip to content

Commit 983bdba

Browse files
committed
Migrate to Kotlin Instant
1 parent 37c8ab1 commit 983bdba

56 files changed

Lines changed: 177 additions & 207 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app-common-io/src/main/java/eu/darken/butler/common/files/APathGateway.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package eu.darken.butler.common.files
33
import eu.darken.butler.common.sharedresource.HasSharedResource
44
import kotlinx.coroutines.flow.Flow
55
import okio.FileHandle
6-
import java.time.Instant
6+
import kotlin.time.Instant
77

88
interface APathGateway<
99
P : APath,

app-common-io/src/main/java/eu/darken/butler/common/files/APathLookup.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package eu.darken.butler.common.files
33
import androidx.annotation.Keep
44
import eu.darken.butler.common.ca.CaString
55
import eu.darken.butler.common.files.extensions.Segments
6-
import java.time.Instant
6+
import kotlin.time.Instant
77

88
@Keep
99
interface APathLookup<out T : APath> {

app-common-io/src/main/java/eu/darken/butler/common/files/GatewaySwitch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import kotlinx.coroutines.flow.Flow
1616
import kotlinx.coroutines.plus
1717
import okio.FileHandle
1818
import okio.IOException
19-
import java.time.Instant
2019
import javax.inject.Inject
2120
import javax.inject.Singleton
21+
import kotlin.time.Instant
2222

2323
@Singleton
2424
class GatewaySwitch @Inject constructor(

app-common-io/src/main/java/eu/darken/butler/common/files/extensions/APathExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import kotlinx.coroutines.flow.Flow
2525
import okio.FileHandle
2626
import java.io.File
2727
import java.io.IOException
28-
import java.time.Instant
2928
import java.util.Collections
29+
import kotlin.time.Instant
3030
import eu.darken.butler.common.files.local.removePrefix as removePrefixLocalPath
3131
import eu.darken.butler.common.files.saf.removePrefix as removePrefixSafPath
3232

app-common-io/src/main/java/eu/darken/butler/common/files/local/LocalGateway.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ import kotlinx.coroutines.withContext
4646
import okio.FileHandle
4747
import java.io.File
4848
import java.io.IOException
49-
import java.time.Instant
5049
import javax.inject.Inject
5150
import javax.inject.Singleton
51+
import kotlin.time.Instant
5252

5353
@Suppress("BlockingMethodInNonBlockingContext")
5454
@Singleton
@@ -879,7 +879,7 @@ class LocalGateway @Inject constructor(
879879
when {
880880
mode == Mode.NORMAL || mode == Mode.AUTO && canNormalWrite -> {
881881
log(TAG, VERBOSE) { "setModifiedAt($mode->NORMAL): $path" }
882-
path.file.setLastModified(modifiedAt.toEpochMilli())
882+
path.file.setLastModified(modifiedAt.toEpochMilliseconds())
883883
}
884884

885885
hasRoot() && (mode == Mode.ROOT || mode == Mode.AUTO) -> {

app-common-io/src/main/java/eu/darken/butler/common/files/local/LocalPathExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import eu.darken.butler.common.files.extensions.asFile
1515
import eu.darken.butler.common.funnel.IPCFunnel
1616
import eu.darken.butler.common.pkgs.pkgops.LibcoreTool
1717
import java.io.File
18-
import java.time.Instant
18+
import kotlin.time.Instant
1919

2020

2121
fun LocalPath.crumbsTo(child: LocalPath): Array<String> {
@@ -45,7 +45,7 @@ fun LocalPath.performLookup(): LocalPathLookup {
4545
fileType = type,
4646
lookedUp = this,
4747
size = file.length(),
48-
modifiedAt = Instant.ofEpochMilli(file.lastModified()),
48+
modifiedAt = Instant.fromEpochMilliseconds(file.lastModified()),
4949
target = file.readLink()?.let { LocalPath.build(it) }
5050
)
5151
}

app-common-io/src/main/java/eu/darken/butler/common/files/local/LocalPathLookup.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import eu.darken.butler.common.files.APathLookup
55
import eu.darken.butler.common.files.FileType
66
import eu.darken.butler.common.files.LocalPath
77
import kotlinx.parcelize.Parcelize
8-
import java.time.Instant
8+
import kotlin.time.Instant
99

1010
@Parcelize
1111
data class LocalPathLookup(

app-common-io/src/main/java/eu/darken/butler/common/files/local/ipc/FileOpsClient.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import eu.darken.butler.common.ipc.IpcClientModule
1717
import eu.darken.butler.common.ipc.fileHandle
1818
import kotlinx.coroutines.flow.Flow
1919
import okio.FileHandle
20-
import java.time.Instant
20+
import kotlin.time.Instant
2121

2222
class FileOpsClient @AssistedInject constructor(
2323
@Assisted private val fileOpsConnection: FileOpsConnection
@@ -142,7 +142,7 @@ class FileOpsClient @AssistedInject constructor(
142142
}
143143

144144
fun setModifiedAt(path: LocalPath, modifiedAt: Instant): Boolean = try {
145-
fileOpsConnection.setModifiedAt(path, modifiedAt.toEpochMilli())
145+
fileOpsConnection.setModifiedAt(path, modifiedAt.toEpochMilliseconds())
146146
} catch (e: Exception) {
147147
throw e.refineException()
148148
}

app-common-io/src/main/java/eu/darken/butler/common/files/saf/SAFDocFile.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import eu.darken.butler.common.files.io.useQuietly
2323
import java.io.File
2424
import java.io.FileNotFoundException
2525
import java.io.IOException
26-
import java.time.Instant
26+
import kotlin.time.Instant
2727

2828

2929
data class SAFDocFile(
@@ -86,7 +86,7 @@ data class SAFDocFile(
8686
}
8787

8888
val lastModified: Instant
89-
get() = Instant.ofEpochMilli(queryForLong(DocumentsContract.Document.COLUMN_LAST_MODIFIED) ?: 0)
89+
get() = Instant.fromEpochMilliseconds(queryForLong(DocumentsContract.Document.COLUMN_LAST_MODIFIED) ?: 0)
9090

9191
val length: Long
9292
get() = queryForLong(DocumentsContract.Document.COLUMN_SIZE) ?: 0
@@ -157,7 +157,7 @@ data class SAFDocFile(
157157

158158
fun setLastModified(lastModified: Instant): Boolean = try {
159159
val updateValues = ContentValues()
160-
updateValues.put(DocumentsContract.Document.COLUMN_LAST_MODIFIED, lastModified.toEpochMilli())
160+
updateValues.put(DocumentsContract.Document.COLUMN_LAST_MODIFIED, lastModified.toEpochMilliseconds())
161161
val updated: Int = resolver.update(uri, updateValues, null, null)
162162
updated == 1
163163
} catch (e: Exception) {

app-common-io/src/main/java/eu/darken/butler/common/files/saf/SAFGateway.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import kotlinx.coroutines.plus
3030
import kotlinx.coroutines.withContext
3131
import okio.FileHandle
3232
import java.io.IOException
33-
import java.time.Instant
3433
import java.util.LinkedList
3534
import javax.inject.Inject
3635
import javax.inject.Singleton
36+
import kotlin.time.Instant
3737

3838
@Singleton
3939
class SAFGateway @Inject constructor(

0 commit comments

Comments
 (0)