Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #1587: Made intent keys consistent in the drawer, topic and testing packages in the app module #2590

Next Next commit
Made intent keys consistent in the topic package
  • Loading branch information
janewaitara committed Jan 30, 2021
commit 2b32d868df585048584a0929f21ec8a155ec5aa5
18 changes: 9 additions & 9 deletions app/src/main/java/org/oppia/android/app/topic/TopicActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.oppia.android.app.topic.questionplayer.QuestionPlayerActivity
import org.oppia.android.app.topic.revisioncard.RevisionCardActivity
import javax.inject.Inject

private const val TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY = "TopicActivity.topic_id"
private const val TOPIC_ACTIVITY_STORY_ID_ARGUMENT_KEY = "TopicActivity.story_id"
private const val TOPIC_ACTIVITY_TOPIC_ID_EXTRA_KEY = "TopicActivity.topic_activity_topic_id"
private const val TOPIC_ACTIVITY_STORY_ID_EXTRA_KEY = "TopicActivity.topic_activity_story_id"

/** The activity for displaying [TopicFragment]. */
class TopicActivity :
Expand All @@ -34,10 +34,10 @@ class TopicActivity :
super.onCreate(savedInstanceState)
activityComponent.inject(this)
internalProfileId = intent?.getIntExtra(KEY_NAVIGATION_PROFILE_ID, -1)!!
topicId = checkNotNull(intent?.getStringExtra(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY)) {
topicId = checkNotNull(intent?.getStringExtra(TOPIC_ACTIVITY_TOPIC_ID_EXTRA_KEY)) {
"Expected topic ID to be included in intent for TopicActivity."
}
storyId = intent?.getStringExtra(TOPIC_ACTIVITY_STORY_ID_ARGUMENT_KEY)
storyId = intent?.getStringExtra(TOPIC_ACTIVITY_STORY_ID_EXTRA_KEY)
topicActivityPresenter.handleOnCreate(internalProfileId, topicId, storyId)
}

Expand Down Expand Up @@ -102,11 +102,11 @@ class TopicActivity :
}

fun getTopicIdKey(): String {
return TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY
return TOPIC_ACTIVITY_TOPIC_ID_EXTRA_KEY
}

fun getStoryIdKey(): String {
return TOPIC_ACTIVITY_STORY_ID_ARGUMENT_KEY
return TOPIC_ACTIVITY_STORY_ID_EXTRA_KEY
}

/** Returns a new [Intent] to route to [TopicActivity] for a specified topic ID. */
Expand All @@ -117,7 +117,7 @@ class TopicActivity :
): Intent {
val intent = Intent(context, TopicActivity::class.java)
intent.putExtra(KEY_NAVIGATION_PROFILE_ID, internalProfileId)
intent.putExtra(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY, topicId)
intent.putExtra(TOPIC_ACTIVITY_TOPIC_ID_EXTRA_KEY, topicId)
return intent
}

Expand All @@ -130,8 +130,8 @@ class TopicActivity :
): Intent {
val intent = Intent(context, TopicActivity::class.java)
intent.putExtra(KEY_NAVIGATION_PROFILE_ID, internalProfileId)
intent.putExtra(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY, topicId)
intent.putExtra(TOPIC_ACTIVITY_STORY_ID_ARGUMENT_KEY, storyId)
intent.putExtra(TOPIC_ACTIVITY_TOPIC_ID_EXTRA_KEY, topicId)
intent.putExtra(TOPIC_ACTIVITY_STORY_ID_EXTRA_KEY, storyId)
return intent
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import org.oppia.android.app.player.stopplaying.StopStatePlayingSessionListener
import org.oppia.android.app.topic.conceptcard.ConceptCardListener
import javax.inject.Inject

const val QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_ARGUMENT_KEY =
"QuestionPlayerActivity.skill_id_list"
const val QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_EXTRA_KEY =
"QuestionPlayerActivity.question_player_activity_skill_id_list"
private const val TAG_STOP_TRAINING_SESSION_DIALOG = "STOP_TRAINING_SESSION_DIALOG"

/** Activity for QuestionPlayer in train mode. */
Expand Down Expand Up @@ -74,12 +74,12 @@ class QuestionPlayerActivity :
skillIdList: ArrayList<String>
): Intent {
val intent = Intent(context, QuestionPlayerActivity::class.java)
intent.putExtra(QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_ARGUMENT_KEY, skillIdList)
intent.putExtra(QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_EXTRA_KEY, skillIdList)
return intent
}

fun getIntentKey(): String {
return QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_ARGUMENT_KEY
return QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_EXTRA_KEY
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class QuestionPlayerActivityPresenter @Inject constructor(

private fun startTrainingSessionWithCallback(callback: () -> Unit) {
val skillIds =
activity.intent.getStringArrayListExtra(QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_ARGUMENT_KEY)
activity.intent.getStringArrayListExtra(QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_EXTRA_KEY)
questionTrainingController.startQuestionTrainingSession(skillIds).observe(
activity,
Observer {
Expand Down