-
Notifications
You must be signed in to change notification settings - Fork 503
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 #1587 : Made intent/bundle/saved/tags instance keys consistent #1717
Conversation
@The-Pascal You can have a look at this wiki page, this will help you out in passing the ktlint check. |
🎉 Congratulations on your first PR 🎉 Few general points:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few nit changes.
@rt4914 What about key's like
const val LAST_LOADED_FRAGMENT_KEY = "LAST_LOADED_FRAGMENT_KEY"
internal const val KEY_APP_LANGUAGE_PREFERENCE_TITLE = "APP_LANGUAGE_PREFERENCE"
internal const val KEY_APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE =
"APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE"
internal const val KEY_SELECTED_LANGUAGE = "SELECTED_LANGUAGE"
private const val KEY_APP_LANGUAGE_PREFERENCE_TITLE = "APP_LANGUAGE_PREFERENCE"
private const val KEY_APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE =
"APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE"
private const val KEY_SELECTED_LANGUAGE = "SELECTED_LANGUAGE"
and others like the same
@@ -20,7 +20,8 @@ class TestFontScaleConfigurationUtilActivity : InjectableAppCompatActivity() { | |||
} | |||
|
|||
companion object { | |||
private const val FONT_SCALE_EXTRA_KEY = "FONT_SCALE_EXTRA_KEY" | |||
private const val FONT_SCALE_EXTRA_KEY = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No single space needed after =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal const val SUBTOPIC_ID_EXTRA_KEY = "SUBTOPIC_ID_EXTRA_KEY" | ||
internal const val INTERNAL_PROFILE_ID_EXTRA_KEY = | ||
"RevisionCardActivity.internal_profile_id" | ||
internal const val TOPIC_ID_EXTRA_KEY = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, no single space needed after =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
"RevisionCardActivity.internal_profile_id" | ||
internal const val TOPIC_ID_EXTRA_KEY = | ||
"RevisionCardActivity.topic_id" | ||
internal const val SUBTOPIC_ID_EXTRA_KEY = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, no single space needed after =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
private const val SOLUTION_INDEX_SAVED_KEY = | ||
"HintsAndSolutionDialogFragment.solution_index" | ||
private const val IS_SOLUTION_REVEALED_SAVED_KEY = | ||
"HintsAndSolutionDialogFragment.is_solution_revealed" | ||
|
||
/* Fragment that displays a fullscreen dialog for Hints and Solutions. */ | ||
class HintsAndSolutionDialogFragment : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below key is left untouched
internal const val ID_ARGUMENT_KEY = "ID"
internal const val NEW_AVAILABLE_HINT_INDEX_ARGUMENT_KEY = "NEW_AVAILABLE_HINT_INDEX"
internal const val ALL_HINTS_EXHAUSTED_ARGUMENT_KEY = "ALL_HINTS_EXHAUSTED"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const val STATE_FRAGMENT_PROFILE_ID_ARGUMENT_KEY = "StateFragmentPresenter.profile_id" | ||
const val STATE_FRAGMENT_TOPIC_ID_ARGUMENT_KEY = "StateFragmentPresenter.topic_id" | ||
const val STATE_FRAGMENT_STORY_ID_ARGUMENT_KEY = "StateFragmentPresenter.story_id" | ||
const val STATE_FRAGMENT_EXPLORATION_ID_ARGUMENT_KEY = "StateFragmentPresenter.exploration_id" | ||
private const val TAG_AUDIO_FRAGMENT = "AUDIO_FRAGMENT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TAG should be changed too!!
as per the pr title says about Tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rt4914 please confirm here, as tags are not mentioned in the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tags related to fragment / activities should be mentioned in their respective companion objects.
Example: internal const val TAG = "AudioFragment.tag"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Because the
This should be inside a companion object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@The-Pascal
Please take a look at comments by @anandwana001 . Also, make sure that you check corresponding test cases files too because most of these keys are used in test cases too especially during intent.
Thanks.
@anandwana001 Thank you so much for your advice. I will always remember that and hope to go a long way contributing in open source community. @rt4914 Thank you for providing me the opportunity. I have made changes considering all the previous comments. Please review these changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@The-Pascal I have left some comments but those comments apply to your entire PR.
You should follow these rules:
- TAG, EXTRA, ARGUMENT, SAVED_KEY all these types of keys should be mentioned in the
activity/fragment
's companion object. - If you are mentioning them in companion object make sure that they are
internal
, like :internal const val TAG = "HomeFragment.tag"
- For tags you can directly write
TAG
instead ofHOME_FRAGMENT_TAG
. - Make sure you follow other rules too which are mentioned in the issue itself.
Also, please make sure that you reply to comments also, like "DONE", "Mention what change you have done", etc.
Thanks.
@@ -12,7 +12,8 @@ import org.oppia.app.settings.profile.ProfileListActivity | |||
import javax.inject.Inject | |||
|
|||
const val SELECTED_CONTROLS_TITLE_KEY = "SELECTED_CONTROLS_TITLE_KEY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This need to be changed because this one is also getting used in savedInstanceState
, check line 34
in code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -12,7 +12,8 @@ import org.oppia.app.settings.profile.ProfileListActivity | |||
import javax.inject.Inject | |||
|
|||
const val SELECTED_CONTROLS_TITLE_KEY = "SELECTED_CONTROLS_TITLE_KEY" | |||
const val LAST_LOADED_FRAGMENT_KEY = "LAST_LOADED_FRAGMENT_KEY" | |||
const val LAST_LOADED_FRAGMENT_SAVED_KEY = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string is correct but it should be mentioned in the companion object.
companion object {
internal const val LAST_LOADED_FRAGMENT_SAVED_KEY =
"AdministratorControlsActivity.last_loaded_fragment"
fun createAdministratorControlsActivityIntent(context: Context, profileId: Int?): Intent {
val intent = Intent(context, AdministratorControlsActivity::class.java)
intent.putExtra(KEY_NAVIGATION_PROFILE_ID, profileId)
return intent
}
fun getIntentKey(): String {
return KEY_NAVIGATION_PROFILE_ID
}
}
Once you have mentioned it in companion object you can use it anywhere like this:
AdministratorControlsActivity.LAST_LOADED_FRAGMENT_SAVED_KEY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -28,7 +28,7 @@ class HelpActivity : InjectableAppCompatActivity(), RouteToFAQListListener { | |||
companion object { | |||
// TODO(#1655): Re-restrict access to fields in tests post-Gradle. | |||
const val BOOL_IS_FROM_NAVIGATION_DRAWER_EXTRA_KEY = | |||
"BOOL_IS_FROM_NAVIGATION_DRAWER_EXTRA_KEY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to
const val IS_FROM_NAVIGATION_DRAWER_EXTRA_KEY = "HelpActivity.is_from_navigation_drawer"
else everything is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
"HintsAndSolutionDialogFragment.is_hint_revealed" | ||
private const val SOLUTION_INDEX_SAVED_KEY = | ||
"HintsAndSolutionDialogFragment.solution_index" | ||
private const val IS_SOLUTION_REVEALED_SAVED_KEY = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shift all these private keys to companion object
, similar to what I mentioned for AdministratorControlsActivity
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
But I have used private keys only inside companion object also, so please check if I need to make those keys internal or not.
@@ -9,7 +9,7 @@ import org.oppia.app.activity.ActivityScope | |||
import org.oppia.app.drawer.NavigationDrawerFragment | |||
import javax.inject.Inject | |||
|
|||
const val TAG_HOME_FRAGMENT = "HOME_FRAGMENT" | |||
const val TAG_HOME_FRAGMENT = "HomeFragment.tag" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shift to companion object on HomeFragment
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please check this comment:
#1717 (comment)
As per this comment it should be named like this:
internal const val TAG = "HomeFragment.tag"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
But am not sure the way I did it. So please check it and guide me if am wrong in this.
@@ -15,7 +15,7 @@ private const val RECENTLY_PLAYED_FRAGMENT_INTERNAL_PROFILE_ID_KEY = | |||
/** Fragment that contains all recently played stories. */ | |||
class RecentlyPlayedFragment : InjectableFragment(), OngoingStoryClickListener { | |||
companion object { | |||
const val TAG_RECENTLY_PLAYED_FRAGMENT = "TAG_RECENTLY_PLAYED_FRAGMENT" | |||
const val TAG_RECENTLY_PLAYED_FRAGMENT = "RecentlyPlayedFragment.tag" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at this comment:
#1717 (comment)
As per this comment, you should rename like this:
internal const val TAG = "RecentlyPlayedFragment.tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -13,7 +13,7 @@ class OngoingTopicListFragment : InjectableFragment() { | |||
|
|||
companion object { | |||
// TODO(#1655): Re-restrict access to fields in tests post-Gradle. | |||
const val ONGOING_TOPIC_LIST_FRAGMENT_TAG = "TAG_ONGOING_TOPIC_LIST_FRAGMENT" | |||
const val ONGOING_TOPIC_LIST_FRAGMENT_TAG = "OngoingTopicListFragment.tag" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at this comment:
#1717 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@The-Pascal Any update on this? |
I have committed changes according to the suggestions. Please have a look. @rt4914 and @anandwana001 I really appreciate your time and support for guiding me. |
You can comment on requested changes comment which helps me to understand things are solved and then I can resolve those comments. |
Thanks @anandwana001 I have done the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far @The-Pascal
I found a couple of arguments like
private const val IS_MULTIPANE_KEY = "IS_MULTIPANE_KEY"
in AdministratorControlsFragment
,
const val KEY_NAVIGATION_PROFILE_ID = "KEY_NAVIGATION_PROFILE_ID"
in NavigationDrawerFragmentPresenter
,
intent.putExtra(KEY_NAVIGATION_PROFILE_ID, profileId)
in HelpActivity
(this can be same as
intent.putExtra(COMPLETED_STORY_LIST_ACTIVITY_PROFILE_ID_KEY, internalProfileId)
) and for all others internalProfileId
,
intent.putExtra(KEY_NAVIGATION_PROFILE_ID, profileId)
in HomeActivity
, MyDownloadsActivity
, OptionsActivity
, TopicActivity
and other places too.
To keep the track and make this work easier, I suggest creating a list of packages in the PR descriptions and make changes.
Let me know for any other assistance.
@The-Pascal You need to update the branch with |
Explanation
Fix #1587 : Made intent/bundle/saved/tags instance keys consistent
For fragments:
<PROPERTY_NAME>_ARGUMENT_KEY = ".<property_name>"
Example: INTERNAL_PROFILE_ID_ARGUMENT_KEY = "SampleFragment.internal_profile_id"
For activities:
<PROPERTY_NAME>_EXTRA_KEY = ".<property_name>"
Example: INTERNAL_PROFILE_ID_EXTRA_KEY = "SampleActivity.internal_profile_id"
For saved instances:
<PROPERTY_NAME>_SAVED_KEY = ".<property_name>"
Example: INTERNAL_PROFILE_ID_SAVED_KEY = "SampleActivity.internal_profile_id"
Checklist