Skip to content

Commit 2893ca4

Browse files
Fixes part of #5440: ProfileId migration utility (#6199)
## Explanation Fixes part of #5440 - Adds `profile_id_migration_util` as a dependency for `CurrentUserProfileIdIntentDecorator.kt`. - Updates utility layer to use ProfileId internally and use `.toLegacyProfileId()` and `.toProfileId()` at boundaries. ## Essential Checklist - [x] The PR title starts with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] The explanation section above starts with "Fixes #bugnum: " (If this PR fixes part of an issue, use instead: "Fixes part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).
1 parent 0e3d62b commit 2893ca4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

utility/src/main/java/org/oppia/android/util/profile/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ kt_android_library(
3333
],
3434
visibility = ["//:oppia_api_visibility"],
3535
deps = [
36+
":profile_id_migration_util",
3637
"//model/src/main/proto:profile_java_proto_lite",
3738
"//utility/src/main/java/org/oppia/android/util/extensions:bundle_extensions",
3839
],

utility/src/main/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecorator.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.oppia.android.util.profile
33
import android.content.Intent
44
import android.os.Bundle
55
import org.oppia.android.app.model.LegacyProfileId
6+
import org.oppia.android.app.model.ProfileId
67
import org.oppia.android.util.extensions.getProto
78
import org.oppia.android.util.extensions.getProtoExtra
89
import org.oppia.android.util.extensions.putProto
@@ -13,14 +14,14 @@ const val PROFILE_ID_INTENT_DECORATOR = "CurrentUserProfileIdIntentDecorator.pro
1314
private const val PROFILE_ID_BUNDLE_DECORATOR =
1415
"CurrentUserProfileIdIntentDecorator.profile_id_bundle_key"
1516

16-
/** Decorator that allows an activity to wrap a user's [LegacyProfileId] within its intent. */
17+
/** Decorator that allows an activity to wrap a user's [ProfileId] within its intent. */
1718
object CurrentUserProfileIdIntentDecorator {
1819
/**
1920
* Packs [this] intent with a [LegacyProfileId] proto object.
2021
* [extractCurrentUserProfileId] should be used for retrieving the [LegacyProfileId] later.
2122
*/
2223
fun Intent.decorateWithUserProfileId(profileId: LegacyProfileId) {
23-
putProtoExtra(PROFILE_ID_INTENT_DECORATOR, profileId)
24+
putProtoExtra(PROFILE_ID_INTENT_DECORATOR, profileId.toProfileId())
2425
}
2526

2627
/**
@@ -30,16 +31,16 @@ object CurrentUserProfileIdIntentDecorator {
3031
fun Intent.extractCurrentUserProfileId(): LegacyProfileId {
3132
return getProtoExtra(
3233
PROFILE_ID_INTENT_DECORATOR,
33-
LegacyProfileId.getDefaultInstance()
34-
)
34+
ProfileId.getDefaultInstance()
35+
).toLegacyProfileId()
3536
}
3637

3738
/**
3839
* Packs [this] bundle with a [LegacyProfileId] proto object.
3940
* [extractCurrentUserProfileId] should be used for retrieving the [LegacyProfileId] later.
4041
*/
4142
fun Bundle.decorateWithUserProfileId(profileId: LegacyProfileId) {
42-
putProto(PROFILE_ID_BUNDLE_DECORATOR, profileId)
43+
putProto(PROFILE_ID_BUNDLE_DECORATOR, profileId.toProfileId())
4344
}
4445

4546
/**
@@ -49,7 +50,7 @@ object CurrentUserProfileIdIntentDecorator {
4950
fun Bundle.extractCurrentUserProfileId(): LegacyProfileId {
5051
return getProto(
5152
PROFILE_ID_BUNDLE_DECORATOR,
52-
LegacyProfileId.getDefaultInstance()
53-
)
53+
ProfileId.getDefaultInstance()
54+
).toLegacyProfileId()
5455
}
5556
}

0 commit comments

Comments
 (0)