Skip to content

Commit ef60d63

Browse files
committed
Removed deprecated public constructor
1 parent 2b23887 commit ef60d63

File tree

3 files changed

+8
-30
lines changed

3 files changed

+8
-30
lines changed

firebase-crashlytics/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Unreleased
2-
2+
[changed] **Breaking Change**: Removed deprecated public constructor `KeyValueBuilder(crashlytics: FirebaseCrashlytics)`
33

44
# 19.4.2
55
* [changed] Internal changes to read version control info more efficiently [#6754]

firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/CrashlyticsTests.kt

-16
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,6 @@ class CrashlyticsTests {
8383
assertThat(result).isEqualTo(expectedKeys)
8484
}
8585

86-
@Test
87-
fun keyValueBuilder_withCrashlyticsInstance() {
88-
@Suppress("DEPRECATION") val keyValueBuilder = KeyValueBuilder(Firebase.crashlytics)
89-
keyValueBuilder.key("string", "world")
90-
keyValueBuilder.key("int", Int.MAX_VALUE)
91-
keyValueBuilder.key("float", Float.MAX_VALUE)
92-
keyValueBuilder.key("boolean", true)
93-
keyValueBuilder.key("double", Double.MAX_VALUE)
94-
keyValueBuilder.key("long", Long.MAX_VALUE)
95-
96-
val result: Map<String, String> = keyValueBuilder.build().keysAndValues
97-
98-
// The result is empty because it called crashlytics.setCustomKey for every key.
99-
assertThat(result).isEmpty()
100-
}
101-
10286
companion object {
10387
private const val APP_ID = "1:1:android:1a"
10488
private const val API_KEY = "API-KEY-API-KEY-API-KEY-API-KEY-API-KEY"

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/KeyValueBuilder.kt

+7-13
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,39 @@ package com.google.firebase.crashlytics
1919
/** Helper class to enable convenient syntax in [setCustomKeys] and [recordException] */
2020
class KeyValueBuilder
2121
private constructor(
22-
private val crashlytics: FirebaseCrashlytics?,
2322
private val builder: CustomKeysAndValues.Builder,
2423
) {
25-
@Deprecated(
26-
"Do not construct this directly. Use `setCustomKeys` instead. To be removed in the next major release."
27-
)
28-
constructor(crashlytics: FirebaseCrashlytics) : this(crashlytics, CustomKeysAndValues.Builder())
29-
30-
internal constructor() : this(crashlytics = null, CustomKeysAndValues.Builder())
24+
internal constructor() : this(CustomKeysAndValues.Builder())
3125

3226
internal fun build(): CustomKeysAndValues = builder.build()
3327

3428
/** Sets a custom key and value that are associated with reports. */
3529
fun key(key: String, value: Boolean) {
36-
crashlytics?.setCustomKey(key, value) ?: builder.putBoolean(key, value)
30+
builder.putBoolean(key, value)
3731
}
3832

3933
/** Sets a custom key and value that are associated with reports. */
4034
fun key(key: String, value: Double) {
41-
crashlytics?.setCustomKey(key, value) ?: builder.putDouble(key, value)
35+
builder.putDouble(key, value)
4236
}
4337

4438
/** Sets a custom key and value that are associated with reports. */
4539
fun key(key: String, value: Float) {
46-
crashlytics?.setCustomKey(key, value) ?: builder.putFloat(key, value)
40+
builder.putFloat(key, value)
4741
}
4842

4943
/** Sets a custom key and value that are associated with reports. */
5044
fun key(key: String, value: Int) {
51-
crashlytics?.setCustomKey(key, value) ?: builder.putInt(key, value)
45+
builder.putInt(key, value)
5246
}
5347

5448
/** Sets a custom key and value that are associated with reports. */
5549
fun key(key: String, value: Long) {
56-
crashlytics?.setCustomKey(key, value) ?: builder.putLong(key, value)
50+
builder.putLong(key, value)
5751
}
5852

5953
/** Sets a custom key and value that are associated with reports. */
6054
fun key(key: String, value: String) {
61-
crashlytics?.setCustomKey(key, value) ?: builder.putString(key, value)
55+
builder.putString(key, value)
6256
}
6357
}

0 commit comments

Comments
 (0)