Skip to content

Commit 5238f83

Browse files
committed
cleanup: Remove all star imports.
It's clearer to have explicit imports.
1 parent 5f2d200 commit 5238f83

File tree

12 files changed

+563
-355
lines changed

12 files changed

+563
-355
lines changed

lib/src/main/java/im/tox/tox4j/av/ToxAv.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package im.tox.tox4j.av
22

3-
import im.tox.tox4j.av.callbacks.*
4-
import im.tox.tox4j.av.data.*
3+
import im.tox.tox4j.av.callbacks.ToxAvEventListener
4+
import im.tox.tox4j.av.data.AudioChannels
5+
import im.tox.tox4j.av.data.BitRate
6+
import im.tox.tox4j.av.data.SampleCount
7+
import im.tox.tox4j.av.data.SamplingRate
58
import im.tox.tox4j.av.enums.ToxavCallControl
6-
import im.tox.tox4j.av.exceptions.*
79
import im.tox.tox4j.core.ToxCore
810
import im.tox.tox4j.core.data.ToxFriendNumber
911
import java.io.Closeable

lib/src/main/java/im/tox/tox4j/core/ToxCore.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
package im.tox.tox4j.core
22

33
import im.tox.core.network.Port
4-
import im.tox.tox4j.core.callbacks.*
5-
import im.tox.tox4j.core.data.*
6-
import im.tox.tox4j.core.enums.*
7-
import im.tox.tox4j.core.exceptions.*
4+
import im.tox.tox4j.core.callbacks.ToxCoreEventListener
5+
import im.tox.tox4j.core.data.ToxFriendNumber
6+
import im.tox.tox4j.core.data.ToxFriendAddress
7+
import im.tox.tox4j.core.data.ToxFriendMessage
8+
import im.tox.tox4j.core.data.ToxFriendRequestMessage
9+
import im.tox.tox4j.core.data.ToxPublicKey
10+
import im.tox.tox4j.core.data.ToxSecretKey
11+
import im.tox.tox4j.core.data.ToxFileId
12+
import im.tox.tox4j.core.data.ToxFilename
13+
import im.tox.tox4j.core.data.ToxLosslessPacket
14+
import im.tox.tox4j.core.data.ToxLossyPacket
15+
import im.tox.tox4j.core.data.ToxNickname
16+
import im.tox.tox4j.core.data.ToxStatusMessage
17+
import im.tox.tox4j.core.enums.ToxFileControl
18+
import im.tox.tox4j.core.enums.ToxMessageType
19+
import im.tox.tox4j.core.enums.ToxUserStatus
820
import im.tox.tox4j.core.options.ToxOptions
921
import java.io.Closeable
1022

lib/src/main/java/im/tox/tox4j/core/ToxCoreConstants.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import im.tox.tox4j.crypto.ToxCryptoConstants
55
object ToxCoreConstants {
66

77
/** The size of a Tox Public Key in bytes. */
8-
val PublicKeySize = ToxCryptoConstants.PublicKeyLength
8+
const val PublicKeySize = ToxCryptoConstants.PublicKeyLength
99

1010
/** The size of a Tox Secret Key in bytes. */
11-
val SecretKeySize = ToxCryptoConstants.SecretKeyLength
11+
const val SecretKeySize = ToxCryptoConstants.SecretKeyLength
1212

1313
/**
1414
* The size of a Tox address in bytes. Tox addresses are in the format
@@ -18,34 +18,34 @@ object ToxCoreConstants {
1818
* all the odd bytes, the second byte is an XOR of all the even bytes of the Public Key and
1919
* nospam.
2020
*/
21-
val AddressSize = PublicKeySize + 4 + 2
21+
const val AddressSize = PublicKeySize + 4 + 2
2222

2323
/** Maximum length of a nickname in bytes. */
24-
val MaxNameLength = 128
24+
const val MaxNameLength = 128
2525

2626
/** Maximum length of a status message in bytes. */
27-
val MaxStatusMessageLength = 1007
27+
const val MaxStatusMessageLength = 1007
2828

2929
/** Maximum length of a friend request message in bytes. */
30-
val MaxFriendRequestLength = 1016
30+
const val MaxFriendRequestLength = 1016
3131

3232
/** Maximum length of a single message after which it should be split. */
33-
val MaxMessageLength = 1372
33+
const val MaxMessageLength = 1372
3434

3535
/** Maximum size of custom packets. */
36-
val MaxCustomPacketSize = 1373
36+
const val MaxCustomPacketSize = 1373
3737

3838
/** Maximum file name length for file transfers. */
39-
val MaxFilenameLength = 255
39+
const val MaxFilenameLength = 255
4040

4141
/**
4242
* Maximum hostname length. This is determined by calling `getconf HOST_NAME_MAX` on the console.
4343
* The value presented here is valid for most systems.
4444
*/
45-
val MaxHostnameLength = 255
45+
const val MaxHostnameLength = 255
4646

4747
/** The number of bytes in a file id. */
48-
val FileIdLength = ToxCryptoConstants.HashLength
48+
const val FileIdLength = ToxCryptoConstants.HashLength
4949

5050
/** Default port for HTTP proxies. */
5151
val DefaultProxyPort = 8080.toUShort()

lib/src/main/java/im/tox/tox4j/crypto/ToxCrypto.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package im.tox.tox4j.crypto
22

3-
import im.tox.tox4j.crypto.exceptions.*
3+
import im.tox.tox4j.crypto.exceptions.ToxDecryptionException
4+
import im.tox.tox4j.crypto.exceptions.ToxEncryptionException
5+
import im.tox.tox4j.crypto.exceptions.ToxGetSaltException
6+
import im.tox.tox4j.crypto.exceptions.ToxKeyDerivationException
47

58
/**
69
* To perform encryption, first derive an encryption key from a password with

lib/src/main/java/im/tox/tox4j/crypto/ToxCryptoConstants.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ package im.tox.tox4j.crypto
33
object ToxCryptoConstants {
44

55
/** Length of salt in bytes. */
6-
val SaltLength = 32
6+
const val SaltLength = 32
77

88
/**
99
* The number of bytes in a serialised [[ToxCrypto.PassKey]] without salt. The serialised size is
1010
* [[KeyLength]] + [[SaltLength]].
1111
*/
12-
val KeyLength = 32
12+
const val KeyLength = 32
1313

1414
/** Number of bytes added to any encrypted data. */
15-
val EncryptionExtraLength = 80
15+
const val EncryptionExtraLength = 80
1616

1717
/** The number of bytes in a hash generated by tox_hash. */
18-
val HashLength = 32
18+
const val HashLength = 32
1919

20-
val PublicKeyLength = 32
21-
val SecretKeyLength = 32
22-
val SharedKeyLength = 32
23-
val NonceLength = 24
20+
const val PublicKeyLength = 32
21+
const val SecretKeyLength = 32
22+
const val SharedKeyLength = 32
23+
const val NonceLength = 24
2424

25-
val ZeroBytes = 32
26-
val BoxZeroBytes = 16
25+
const val ZeroBytes = 32
26+
const val BoxZeroBytes = 16
2727
}

lib/src/main/java/im/tox/tox4j/impl/jni/ToxAvEventDispatch.kt

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
package im.tox.tox4j.impl.jni
22

33
import com.google.protobuf.ByteString
4-
import im.tox.tox4j.av.callbacks.*
5-
import im.tox.tox4j.av.data.*
4+
import im.tox.tox4j.av.callbacks.AudioBitRateCallback
5+
import im.tox.tox4j.av.callbacks.AudioReceiveFrameCallback
6+
import im.tox.tox4j.av.callbacks.CallCallback
7+
import im.tox.tox4j.av.callbacks.CallStateCallback
8+
import im.tox.tox4j.av.callbacks.VideoBitRateCallback
9+
import im.tox.tox4j.av.callbacks.VideoReceiveFrameCallback
10+
import im.tox.tox4j.av.callbacks.ToxAvEventListener
11+
import im.tox.tox4j.av.data.AudioChannels
12+
import im.tox.tox4j.av.data.BitRate
13+
import im.tox.tox4j.av.data.Height
14+
import im.tox.tox4j.av.data.SamplingRate
15+
import im.tox.tox4j.av.data.Width
616
import im.tox.tox4j.av.enums.ToxavFriendCallState
7-
import im.tox.tox4j.av.proto.*
17+
import im.tox.tox4j.av.proto.AudioBitRate
18+
import im.tox.tox4j.av.proto.AudioReceiveFrame
19+
import im.tox.tox4j.av.proto.AvEvents
20+
import im.tox.tox4j.av.proto.Call
21+
import im.tox.tox4j.av.proto.CallState
22+
import im.tox.tox4j.av.proto.VideoBitRate
23+
import im.tox.tox4j.av.proto.VideoReceiveFrame
824
import im.tox.tox4j.core.data.ToxFriendNumber
925
import java.util.EnumSet
1026

@@ -43,7 +59,8 @@ object ToxAvEventDispatch {
4359
null -> 0
4460
}
4561
bitMask or nextMask
46-
})
62+
}
63+
)
4764

4865
private fun <S> dispatchCall(handler: CallCallback<S>, call: List<Call>, state: S): S =
4966
call.fold(
@@ -53,8 +70,10 @@ object ToxAvEventDispatch {
5370
ToxFriendNumber(ev.getFriendNumber()),
5471
ev.getAudioEnabled(),
5572
ev.getVideoEnabled(),
56-
next)
57-
})
73+
next
74+
)
75+
}
76+
)
5877

5978
private fun <S> dispatchCallState(
6079
handler: CallStateCallback<S>,
@@ -68,8 +87,10 @@ object ToxAvEventDispatch {
6887
handler.callState(
6988
ToxFriendNumber(ev.getFriendNumber()),
7089
EnumSet.of(bits[0], *bits.drop(1).toTypedArray()),
71-
next)
72-
})
90+
next
91+
)
92+
}
93+
)
7394

7495
private fun <S> dispatchAudioBitRate(
7596
handler: AudioBitRateCallback<S>,
@@ -80,8 +101,12 @@ object ToxAvEventDispatch {
80101
state,
81102
{ next, ev ->
82103
handler.audioBitRate(
83-
ToxFriendNumber(ev.getFriendNumber()), BitRate(ev.getAudioBitRate()), next)
84-
})
104+
ToxFriendNumber(ev.getFriendNumber()),
105+
BitRate(ev.getAudioBitRate()),
106+
next
107+
)
108+
}
109+
)
85110

86111
private fun <S> dispatchVideoBitRate(
87112
handler: VideoBitRateCallback<S>,
@@ -92,8 +117,12 @@ object ToxAvEventDispatch {
92117
state,
93118
{ next, ev ->
94119
handler.videoBitRate(
95-
ToxFriendNumber(ev.getFriendNumber()), BitRate(ev.getVideoBitRate()), next)
96-
})
120+
ToxFriendNumber(ev.getFriendNumber()),
121+
BitRate(ev.getVideoBitRate()),
122+
next
123+
)
124+
}
125+
)
97126

98127
private fun toShortArray(bytes: ByteString): ShortArray {
99128
val shortBuffer = bytes.asReadOnlyByteBuffer().asShortBuffer()
@@ -115,8 +144,10 @@ object ToxAvEventDispatch {
115144
toShortArray(ev.getPcm()),
116145
convert(ev.getChannels()),
117146
SamplingRate.values().filter { it.value == ev.getSamplingRate() }[0],
118-
next)
119-
})
147+
next
148+
)
149+
}
150+
)
120151

121152
private fun convert(
122153
arrays: Triple<ByteArray, ByteArray, ByteArray>?,
@@ -146,10 +177,15 @@ object ToxAvEventDispatch {
146177
val (yArray, uArray, vArray) =
147178
convert(
148179
handler.videoFrameCachedYUV(
149-
h, ev.getYStride(), ev.getUStride(), ev.getVStride()),
180+
h,
181+
ev.getYStride(),
182+
ev.getUStride(),
183+
ev.getVStride()
184+
),
150185
ev.getY(),
151186
ev.getU(),
152-
ev.getV())
187+
ev.getV()
188+
)
153189

154190
handler.videoReceiveFrame(
155191
ToxFriendNumber(ev.getFriendNumber()),
@@ -161,8 +197,10 @@ object ToxAvEventDispatch {
161197
ev.getYStride(),
162198
ev.getUStride(),
163199
ev.getVStride(),
164-
next)
165-
})
200+
next
201+
)
202+
}
203+
)
166204

167205
private fun <S> dispatchEvents(handler: ToxAvEventListener<S>, events: AvEvents, state: S): S =
168206
dispatchCall(
@@ -181,7 +219,15 @@ object ToxAvEventDispatch {
181219
handler,
182220
events.getAudioReceiveFrameList(),
183221
dispatchVideoReceiveFrame(
184-
handler, events.getVideoReceiveFrameList(), state))))))
222+
handler,
223+
events.getVideoReceiveFrameList(),
224+
state
225+
)
226+
)
227+
)
228+
)
229+
)
230+
)
185231

186232
fun <S> dispatch(handler: ToxAvEventListener<S>, eventData: ByteArray?, state: S): S =
187233
if (eventData == null) {

lib/src/main/java/im/tox/tox4j/impl/jni/ToxAvImpl.kt

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package im.tox.tox4j.impl.jni
22

3-
import im.tox.tox4j.av.*
4-
import im.tox.tox4j.av.callbacks.*
5-
import im.tox.tox4j.av.data.*
6-
import im.tox.tox4j.av.enums.*
7-
import im.tox.tox4j.av.exceptions.*
3+
import im.tox.tox4j.av.ToxAv
4+
import im.tox.tox4j.av.callbacks.ToxAvEventListener
5+
import im.tox.tox4j.av.data.AudioChannels
6+
import im.tox.tox4j.av.data.BitRate
7+
import im.tox.tox4j.av.data.SampleCount
8+
import im.tox.tox4j.av.data.SamplingRate
9+
import im.tox.tox4j.av.enums.ToxavCallControl
10+
import im.tox.tox4j.av.exceptions.ToxavNewException
811
import im.tox.tox4j.core.ToxCore
912
import im.tox.tox4j.core.data.ToxFriendNumber
10-
import java.util.EnumSet
1113

1214
/**
1315
* Initialise an A/V session for the existing Tox instance.
@@ -24,7 +26,9 @@ final class ToxAvImpl(private val tox: ToxCoreImpl) : ToxAv {
2426
ToxAvImpl(tox as ToxCoreImpl)
2527
} catch (_: ClassCastException) {
2628
throw ToxavNewException(
27-
ToxavNewException.Code.INCOMPATIBLE, tox::class.java.getCanonicalName())
29+
ToxavNewException.Code.INCOMPATIBLE,
30+
tox::class.java.getCanonicalName()
31+
)
2832
}
2933

3034
override fun close(): Unit = ToxAvJni.toxavKill(instanceNumber)
@@ -43,7 +47,12 @@ final class ToxAvImpl(private val tox: ToxCoreImpl) : ToxAv {
4347
audioBitRate: BitRate,
4448
videoBitRate: BitRate
4549
): Unit =
46-
ToxAvJni.toxavCall(instanceNumber, friendNumber.value, audioBitRate.value, videoBitRate.value)
50+
ToxAvJni.toxavCall(
51+
instanceNumber,
52+
friendNumber.value,
53+
audioBitRate.value,
54+
videoBitRate.value,
55+
)
4756

4857
// @throws[ToxavAnswerException]
4958
override fun answer(
@@ -52,7 +61,11 @@ final class ToxAvImpl(private val tox: ToxCoreImpl) : ToxAv {
5261
videoBitRate: BitRate
5362
): Unit =
5463
ToxAvJni.toxavAnswer(
55-
instanceNumber, friendNumber.value, audioBitRate.value, videoBitRate.value)
64+
instanceNumber,
65+
friendNumber.value,
66+
audioBitRate.value,
67+
videoBitRate.value,
68+
)
5669

5770
// @throws[ToxavCallControlException]
5871
override fun callControl(friendNumber: ToxFriendNumber, control: ToxavCallControl): Unit =
@@ -80,7 +93,8 @@ final class ToxAvImpl(private val tox: ToxCoreImpl) : ToxAv {
8093
pcm,
8194
sampleCount.value,
8295
channels.value,
83-
samplingRate.value)
96+
samplingRate.value
97+
)
8498

8599
// @throws[ToxavSendFrameException]
86100
override fun videoSendFrame(

lib/src/main/java/im/tox/tox4j/impl/jni/ToxAvJni.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package im.tox.tox4j.impl.jni;
22

3-
import im.tox.tox4j.av.exceptions.*;
3+
import im.tox.tox4j.av.exceptions.ToxavAnswerException;
4+
import im.tox.tox4j.av.exceptions.ToxavBitRateSetException;
5+
import im.tox.tox4j.av.exceptions.ToxavCallControlException;
6+
import im.tox.tox4j.av.exceptions.ToxavCallException;
7+
import im.tox.tox4j.av.exceptions.ToxavNewException;
8+
import im.tox.tox4j.av.exceptions.ToxavSendFrameException;
49

510
@SuppressWarnings({"checkstyle:emptylineseparator", "checkstyle:linelength"})
611
public final class ToxAvJni {

0 commit comments

Comments
 (0)