mapbox / mapbox/mapbox-navigation-android
[Android 13] - Bundle#get is deprecated
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 651
- Forks
- 321
- PR merge metrics
- No merged PRs in 30d
Description
We use this API to create FixLocation#extras. The logic is simple: there are multiple predefined types, we use bundle.get and check if the returned value is instance of one of the predefined types. If yes, create map entry with the following type, if no, ignore the entry. Code:
val key = iterator.next()
when (val value = this.get(key)) {
is Boolean -> map[key] = Value(value)
is Byte -> map[key] = Value(value.toLong())
is Char -> map[key] = Value(value.toString())
is Double -> map[key] = Value(value)
is Float -> map[key] = Value(value.toDouble())
is Int -> map[key] = Value(value.toLong())
is Long -> map[key] = Value(value)
is Short -> map[key] = Value(value.toLong())
is String -> map[key] = Value(value)
else -> {
logW(
"Unsupported type in location extras",
LOG_CATEGORY
)
}
}
Now Bundle#get is deprecated and there is no other way to determine which type has the value by a concrete key. For now we can leave it as-is because deprecation is not removal, but it's very probable that in the future we'll have to face this problem anyway.
Questions:
- Where is
FixLocation#extrasused? We use it only to convert back toLocation#extras. The whole object is passed toNavigator#updateLocation. Are the extras somehow used there? I see that iOS does not have any extras. - Do we need all extras there or just some predefined ones? This way we can use type-safe methods like
Bundle#getStringif we know the key (and which type the value has).
cc @mapbox/navnative
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing FixLocation#extras through its conversion back to Location#extras and the Navigator#updateLocation call. Determine whether extras are required and which predefined keys and types are supported; done means an agreed replacement for Bundle#get or a documented reason to retain it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100