Skip to content

Commit 845bbf6

Browse files
Spotless and formatting
1 parent 9e504b5 commit 845bbf6

File tree

67 files changed

+381
-417
lines changed

Some content is hidden

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

67 files changed

+381
-417
lines changed

app/src/main/java/io/getstream/android/core/sample/SampleActivity.kt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
3434
import androidx.lifecycle.lifecycleScope
3535
import androidx.lifecycle.repeatOnLifecycle
3636
import io.getstream.android.core.api.StreamClient
37-
import io.getstream.android.core.sample.client.createStreamClient
3837
import io.getstream.android.core.api.authentication.StreamTokenProvider
3938
import io.getstream.android.core.api.model.value.StreamApiKey
4039
import io.getstream.android.core.api.model.value.StreamHttpClientInfoHeader
4140
import io.getstream.android.core.api.model.value.StreamToken
4241
import io.getstream.android.core.api.model.value.StreamUserId
4342
import io.getstream.android.core.api.model.value.StreamWsUrl
43+
import io.getstream.android.core.sample.client.createStreamClient
4444
import io.getstream.android.core.sample.ui.theme.StreamandroidcoreTheme
4545
import kotlinx.coroutines.launch
4646
import kotlinx.coroutines.runBlocking
@@ -53,16 +53,20 @@ class SampleActivity : ComponentActivity() {
5353
scope = lifecycleScope,
5454
apiKey = StreamApiKey.fromString("pd67s34fzpgw"),
5555
userId = userId,
56-
wsUrl = StreamWsUrl.fromString("wss://chat-edge-frankfurt-ce1.stream-io-api.com/api/v2/connect"),
57-
clientInfoHeader = StreamHttpClientInfoHeader.create(
58-
product = "android-core",
59-
productVersion = "1.0.0",
60-
os = "Android",
61-
apiLevel = Build.VERSION.SDK_INT,
62-
deviceModel = "Pixel 7 Pro",
63-
app = "Stream Android Core Sample",
64-
appVersion = "1.0.0",
65-
),
56+
wsUrl =
57+
StreamWsUrl.fromString(
58+
"wss://chat-edge-frankfurt-ce1.stream-io-api.com/api/v2/connect"
59+
),
60+
clientInfoHeader =
61+
StreamHttpClientInfoHeader.create(
62+
product = "android-core",
63+
productVersion = "1.0.0",
64+
os = "Android",
65+
apiLevel = Build.VERSION.SDK_INT,
66+
deviceModel = "Pixel 7 Pro",
67+
app = "Stream Android Core Sample",
68+
appVersion = "1.0.0",
69+
),
6670
tokenProvider =
6771
object : StreamTokenProvider {
6872
override suspend fun loadToken(userId: StreamUserId): StreamToken {
Lines changed: 65 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
/*
2+
* Copyright (c) 2014-2025 Stream.io Inc. All rights reserved.
3+
*
4+
* Licensed under the Stream License;
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://github.com/GetStream/stream-android-base/blob/main/LICENSE
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package io.getstream.android.core.sample.client
217

318
import io.getstream.android.core.api.StreamClient
419
import io.getstream.android.core.api.authentication.StreamTokenManager
520
import io.getstream.android.core.api.authentication.StreamTokenProvider
621
import io.getstream.android.core.api.log.StreamLogger
722
import io.getstream.android.core.api.log.StreamLoggerProvider
8-
import io.getstream.android.core.api.model.config.StreamClientSerializationConfig
923
import io.getstream.android.core.api.model.value.StreamApiKey
1024
import io.getstream.android.core.api.model.value.StreamHttpClientInfoHeader
1125
import io.getstream.android.core.api.model.value.StreamUserId
@@ -14,15 +28,13 @@ import io.getstream.android.core.api.processing.StreamBatcher
1428
import io.getstream.android.core.api.processing.StreamRetryProcessor
1529
import io.getstream.android.core.api.processing.StreamSerialProcessingQueue
1630
import io.getstream.android.core.api.processing.StreamSingleFlightProcessor
17-
import io.getstream.android.core.api.serialization.StreamJsonSerialization
1831
import io.getstream.android.core.api.socket.StreamConnectionIdHolder
1932
import io.getstream.android.core.api.socket.StreamWebSocketFactory
2033
import io.getstream.android.core.api.socket.listeners.StreamClientListener
2134
import io.getstream.android.core.api.socket.monitor.StreamHealthMonitor
2235
import io.getstream.android.core.api.subscribe.StreamSubscriptionManager
2336
import kotlinx.coroutines.CoroutineScope
2437

25-
2638
/**
2739
* Creates a [createStreamClient] instance with the given configuration and dependencies.
2840
*
@@ -43,25 +55,26 @@ fun createStreamClient(
4355
clientInfoHeader: StreamHttpClientInfoHeader,
4456
tokenProvider: StreamTokenProvider,
4557
module: StreamClientModule = StreamClientModule.defaults(scope, userId, tokenProvider),
46-
): StreamClient = StreamClient(
47-
scope = scope,
48-
apiKey = apiKey,
49-
userId = userId,
50-
wsUrl = wsUrl,
51-
products = listOf("feeds"),
52-
clientInfoHeader = clientInfoHeader,
53-
tokenProvider = tokenProvider,
54-
logProvider = module.logProvider,
55-
clientSubscriptionManager = module.clientSubscriptionManager,
56-
tokenManager = module.tokenManager,
57-
singleFlight = module.singleFlight,
58-
serialQueue = module.serialQueue,
59-
retryProcessor = module.retryProcessor,
60-
connectionIdHolder = module.connectionIdHolder,
61-
socketFactory = module.socketFactory,
62-
healthMonitor = module.healthMonitor,
63-
batcher = module.batcher,
64-
)
58+
): StreamClient =
59+
StreamClient(
60+
scope = scope,
61+
apiKey = apiKey,
62+
userId = userId,
63+
wsUrl = wsUrl,
64+
products = listOf("feeds"),
65+
clientInfoHeader = clientInfoHeader,
66+
tokenProvider = tokenProvider,
67+
logProvider = module.logProvider,
68+
clientSubscriptionManager = module.clientSubscriptionManager,
69+
tokenManager = module.tokenManager,
70+
singleFlight = module.singleFlight,
71+
serialQueue = module.serialQueue,
72+
retryProcessor = module.retryProcessor,
73+
connectionIdHolder = module.connectionIdHolder,
74+
socketFactory = module.socketFactory,
75+
healthMonitor = module.healthMonitor,
76+
batcher = module.batcher,
77+
)
6578

6679
/**
6780
* Holds configuration and dependencies for the Stream client, including logging, coroutine scope,
@@ -83,48 +96,41 @@ fun createStreamClient(
8396
* @property batcher Batches socket events for batch processing.
8497
*/
8598
@ConsistentCopyVisibility
86-
data class StreamClientModule private constructor(
87-
val logProvider: StreamLoggerProvider = StreamLoggerProvider.Companion.defaultAndroidLogger(
88-
minLevel = StreamLogger.LogLevel.Verbose,
89-
honorAndroidIsLoggable = false,
90-
),
99+
data class StreamClientModule
100+
private constructor(
101+
val logProvider: StreamLoggerProvider =
102+
StreamLoggerProvider.Companion.defaultAndroidLogger(
103+
minLevel = StreamLogger.LogLevel.Verbose,
104+
honorAndroidIsLoggable = false,
105+
),
91106
val scope: CoroutineScope,
92-
val clientSubscriptionManager: StreamSubscriptionManager<StreamClientListener> = StreamSubscriptionManager(
93-
logger = logProvider.taggedLogger("SCClientSubscriptions"),
94-
maxStrongSubscriptions = 250,
95-
maxWeakSubscriptions = 250,
96-
),
107+
val clientSubscriptionManager: StreamSubscriptionManager<StreamClientListener> =
108+
StreamSubscriptionManager(
109+
logger = logProvider.taggedLogger("SCClientSubscriptions"),
110+
maxStrongSubscriptions = 250,
111+
maxWeakSubscriptions = 250,
112+
),
97113
val tokenManager: StreamTokenManager,
98-
val singleFlight: StreamSingleFlightProcessor = StreamSingleFlightProcessor(
99-
scope = scope,
100-
),
101-
val serialQueue: StreamSerialProcessingQueue = StreamSerialProcessingQueue(
102-
logger = logProvider.taggedLogger("SCSerialProcessing"),
103-
scope = scope,
104-
),
105-
val retryProcessor: StreamRetryProcessor = StreamRetryProcessor(
106-
logger = logProvider.taggedLogger("SCRetryProcessor")
107-
),
114+
val singleFlight: StreamSingleFlightProcessor = StreamSingleFlightProcessor(scope = scope),
115+
val serialQueue: StreamSerialProcessingQueue =
116+
StreamSerialProcessingQueue(
117+
logger = logProvider.taggedLogger("SCSerialProcessing"),
118+
scope = scope,
119+
),
120+
val retryProcessor: StreamRetryProcessor =
121+
StreamRetryProcessor(logger = logProvider.taggedLogger("SCRetryProcessor")),
108122
val connectionIdHolder: StreamConnectionIdHolder = StreamConnectionIdHolder(),
109-
val socketFactory: StreamWebSocketFactory = StreamWebSocketFactory(
110-
logger = logProvider.taggedLogger("SCWebSocketFactory")
111-
),
112-
val healthMonitor: StreamHealthMonitor = StreamHealthMonitor(
113-
logger = logProvider.taggedLogger("SCHealthMonitor"),
114-
scope = scope,
115-
),
123+
val socketFactory: StreamWebSocketFactory =
124+
StreamWebSocketFactory(logger = logProvider.taggedLogger("SCWebSocketFactory")),
125+
val healthMonitor: StreamHealthMonitor =
126+
StreamHealthMonitor(logger = logProvider.taggedLogger("SCHealthMonitor"), scope = scope),
116127
val batcher: StreamBatcher<String> =
117-
StreamBatcher(
118-
scope = scope,
119-
batchSize = 10,
120-
initialDelayMs = 100L,
121-
maxDelayMs = 1_000L,
122-
)
128+
StreamBatcher(scope = scope, batchSize = 10, initialDelayMs = 100L, maxDelayMs = 1_000L),
123129
) {
124-
125130
companion object {
126131
/**
127-
* Creates a default [StreamClientModule] instance with recommended settings and dependencies.
132+
* Creates a default [StreamClientModule] instance with recommended settings and
133+
* dependencies.
128134
*
129135
* @param scope Coroutine scope for async operations.
130136
* @param userId The user ID for authentication.
@@ -134,7 +140,7 @@ data class StreamClientModule private constructor(
134140
fun defaults(
135141
scope: CoroutineScope,
136142
userId: StreamUserId,
137-
tokenProvider: StreamTokenProvider
143+
tokenProvider: StreamTokenProvider,
138144
): StreamClientModule {
139145
val singleFlight = StreamSingleFlightProcessor(scope)
140146
return StreamClientModule(
@@ -144,4 +150,4 @@ data class StreamClientModule private constructor(
144150
)
145151
}
146152
}
147-
}
153+
}

app/src/main/java/io/getstream/android/core/sample/ui/theme/Theme.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private val LightColorScheme =
4242
onTertiary = Color.White,
4343
onBackground = Color(0xFF1C1B1F),
4444
onSurface = Color(0xFF1C1B1F),
45-
*/
45+
*/
4646
)
4747

4848
@Composable

app/src/main/java/io/getstream/android/core/sample/ui/theme/Type.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ val Typography =
4747
lineHeight = 16.sp,
4848
letterSpacing = 0.5.sp
4949
)
50-
*/
50+
*/
5151
)

stream-android-core-lint/src/main/java/io/getstream/android/core/lint/detectors/MustBeInternalDetector.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class MustBeInternalDetector : Detector(), Detector.UastScanner {
6363
val isProtected =
6464
kt.hasModifier(
6565
KtTokens.PROTECTED_KEYWORD
66-
) // top-level protected is invalid in Kotlin, but just in case
66+
) // top-level protected is invalid in Kotlin, but just in
67+
// case
6768

6869
if (isInternal || isPrivate) return // OK
6970
// Default (no modifier) behaves as public in Kotlin → flag

stream-android-core-lint/src/main/java/io/getstream/android/core/lint/detectors/StreamCoreApiDetector.kt

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ import org.jetbrains.uast.UMethod
4848
* value="io.getstream.android.core.api,io.getstream.other.api" /> </issue>
4949
*/
5050
class StreamCoreApiDetector : Detector(), Detector.UastScanner {
51-
5251
override fun getApplicableUastTypes(): List<Class<out UElement>> =
5352
listOf(UClass::class.java, UMethod::class.java, UField::class.java)
5453

5554
override fun createUastHandler(context: JavaContext): UElementHandler =
5655
object : UElementHandler() {
57-
5856
override fun visitClass(node: UClass) {
5957
// Only top-level declarations
6058
val uFile = node.uastParent as? UFile ?: return
@@ -191,9 +189,9 @@ class StreamCoreApiDetector : Detector(), Detector.UastScanner {
191189
// top-level: public if no visibility modifier or explicit `public`
192190
val isPublic =
193191
hasModifier(KtTokens.PUBLIC_KEYWORD) ||
194-
(!hasModifier(KtTokens.INTERNAL_KEYWORD) &&
195-
!hasModifier(KtTokens.PRIVATE_KEYWORD) &&
196-
!hasModifier(KtTokens.PROTECTED_KEYWORD))
192+
(!hasModifier(KtTokens.INTERNAL_KEYWORD) &&
193+
!hasModifier(KtTokens.PRIVATE_KEYWORD) &&
194+
!hasModifier(KtTokens.PROTECTED_KEYWORD))
197195
return isPublic
198196
}
199197

@@ -252,19 +250,19 @@ class StreamCoreApiDetector : Detector(), Detector.UastScanner {
252250
@JvmField
253251
val ISSUE: Issue =
254252
Issue.create(
255-
id = "StreamCoreApiMissing",
256-
briefDescription = "Missing @StreamCoreApi on public API",
257-
explanation =
258-
"""
259-
Top-level public declarations in configured packages must be annotated \
260-
with @StreamCoreApi to indicate they are part of the Stream Core API surface.
261-
"""
262-
.trimIndent(),
263-
category = Category.CORRECTNESS,
264-
priority = 7,
265-
severity = Severity.ERROR,
266-
implementation = IMPLEMENTATION,
267-
)
253+
id = "StreamCoreApiMissing",
254+
briefDescription = "Missing @StreamCoreApi on public API",
255+
explanation =
256+
"""
257+
Top-level public declarations in configured packages must be annotated \
258+
with @StreamCoreApi to indicate they are part of the Stream Core API surface.
259+
"""
260+
.trimIndent(),
261+
category = Category.CORRECTNESS,
262+
priority = 7,
263+
severity = Severity.ERROR,
264+
implementation = IMPLEMENTATION,
265+
)
268266
.setOptions(listOf(OPTION_PACKAGES, OPTION_PACKAGES_EXCLUDE))
269267
}
270268
}

0 commit comments

Comments
 (0)