-
Notifications
You must be signed in to change notification settings - Fork 526
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 #1762: NavigationDrawer cancel switch profile always mark home #1816
Fix #1762: NavigationDrawer cancel switch profile always mark home #1816
Conversation
@anandwana001 PTAL |
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.
@prayutsu we need to take a deep look into this why we are having this issue, what sort of things causing this failure and also need to write proper test cases which fails without fix and passes with the fix.
app/src/main/java/org/oppia/app/drawer/ExitProfileDialogInterface.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/app/drawer/ExitProfileDialogFragment.kt
Outdated
Show resolved
Hide resolved
@rt4914 Currently, we are facing issues on all test cases regarding NavigationDrawerTestActivityTest and this PR will require to add test cases especially for the navigation drawer. I think we need to block this PR till we solve #1968 for NavigationDrawerTestActivityTest |
Okay, so I'll work on other pending issues then. |
@prayutsu By the time the test file is getting fixed, you can work on this issue other than writing test cases. |
@anandwana001 Everything seems to work fine. The only problem is in the last case (please see the video in description) that is Administrator Controls->Switch Profile->Cancel->Rotate Device. |
@anandwana001 I have updated the video in the description of the PR, please have a look at that. |
That's an issue we have to solve. |
Sure |
@prayutsu You need to update the branch with |
… navigation-drawer-switch-profile-fix
app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
@anandwana001 @rt4914 Please have a look. |
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.
Thanks @prayutsu! I really like the new proto usage. Left some comments to see if we can leverage it to make some potential improvements that would have been harder before.
ExitProfileDialogArguments.newBuilder() | ||
.setRestoreLastCheckedMenuItem(restoreLastCheckedMenuItem) | ||
.setIsAdministratorControlsSelected(isAdministratorControlsSelected) | ||
.setLastCheckedMenuItemId(lastCheckedMenuItemId).build() |
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.
.setLastCheckedMenuItemId(lastCheckedMenuItemId).build() | |
.setLastCheckedMenuItemId(lastCheckedMenuItemId) | |
.build() |
ktlint doesn't enforce this correctly, but continuation for call chains like this should be broken up such that each operation at the same logical "level" should also be at the same syntactical "level" (meaning on its own line in this case).
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.
NavigationDrawerItem.HOME.value -> 0 | ||
NavigationDrawerItem.OPTIONS.value -> 1 | ||
NavigationDrawerItem.HELP.value -> 2 | ||
NavigationDrawerItem.DOWNLOADS.value -> 3 |
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.
So now that we're using a proto, could we also use an enum to represent the last checked menu item? That provides type safety vs. passing an integer around.
We may be able to share the draw item enum & the menu item enum as well (e.g. just have 1 proto enum to define both so that we can include it in argument protos).
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.
model/src/main/proto/arguments.proto
Outdated
|
||
// The id of the menu item that was checked before the Exit Profile Dialog appears. | ||
int32 last_checked_menu_item_id = 1; | ||
} |
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.
Add EOF newline.
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.
model/src/main/proto/arguments.proto
Outdated
bool is_administrator_controls_selected = 2; | ||
|
||
// The id of the menu item that was checked before the Exit Profile Dialog appears. | ||
int32 last_checked_menu_item_id = 1; |
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.
Is it possible to consolidate these into a single value the represents the place from which we opened the exit profile dialog?
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.
model/src/main/proto/arguments.proto
Outdated
|
||
// Represents the arguments associated with ExitProfileDialogFragment. | ||
message ExitProfileDialogArguments { | ||
// The last checked menu item needs to be restored or not. |
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 last checked menu item needs to be restored or not. | |
// Whether the last checked menu item needs to be restored or not. |
Ditto elsewhere when documenting booleans.
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.
model/src/main/proto/arguments.proto
Outdated
// Fragment/Activity or not. | ||
bool is_administrator_controls_selected = 2; | ||
|
||
// The id of the menu item that was checked before the Exit Profile Dialog appears. |
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.
Menu item from where? Suggest being specific here.
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.
mentioned menu item from Navigation Drawer.
model/src/main/proto/arguments.proto
Outdated
|
||
// Represents the arguments associated with ExitProfileDialogFragment. | ||
message ExitProfileDialogArguments { | ||
// The last checked menu item needs to be restored or not. |
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 documentation comment overall may benefit from more context: what does 'restore' mean & what menu is being described here?
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.
Provided more context on what does restore actually mean.
model/src/main/proto/arguments.proto
Outdated
option java_package = "org.oppia.android.app.model"; | ||
option java_multiple_files = true; | ||
|
||
// Represents the arguments associated with ExitProfileDialogFragment. |
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.
Suggest instead: The fragment arguments passed to instances of ExitProfileDialogFragment.
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.
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.
PTAL @BenHenning, I have tried making some changes, and I need some good name suggestions as mentioned below.
package org.oppia.android.app.drawer | ||
|
||
sealed class Argument { | ||
class LastCheckedMenuItem(val navigationDrawerItem: NavigationDrawerItem) : Argument() |
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.
Need suggestion for a better name.
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 suggest a good KDoc.
3 -> NavigationDrawerItem.DOWNLOADS | ||
4 -> NavigationDrawerItem.SWITCH_PROFILE | ||
else -> NavigationDrawerItem.HOME | ||
} |
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.
How should we handle else branch here?
} | ||
|
||
enum LastCheckedMenuItem { | ||
HOME_MENU_ITEM_UNSPECIFIED = 0; |
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.
Need suggestion for the documentation comment.
3 -> NavigationDrawerItem.DOWNLOADS | ||
4 -> NavigationDrawerItem.SWITCH_PROFILE | ||
else -> NavigationDrawerItem.HOME | ||
} |
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.
How should we handle else branch here?
) | ||
else -> Argument.LastCheckedMenuItem( | ||
getNavigationDrawerItem( | ||
exitProfileDialogArguments.lastCheckedMenuItemValue |
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.
Should we create a constant with value - 2
, so that it looks cleaner and expressive?
Or do we have a better way to handle it?
@prayutsu @BenHenning @rt4914 @anandwana001 I tried to solve this bug, with this solution issue #2650 will not arise |
@chrk2205 I think this works really well, and now I am thinking that we were passing arguments from the Screenrecorder-2021-02-08-00-14-47-901.mp4
@BenHenning WDYT? |
@prayutsu |
@chrk2205 I guess we'll have to use |
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.
Took a high-level pass @prayutsu. I think I need some clarification on the desired behavior before I can go further thoughts on the specifics.
message ExitProfileDialogArguments { | ||
// Whether the last checked navigation drawer menu item needs to be restored(highlighted) or | ||
// not after cancelling the Exit Profile Dialog. | ||
bool restore_last_checked_menu_item = 1; |
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.
Can this be true if admin_controls_or_nav_drawer_items is not of type last_checked_menu_item? Can you enumerate via a reply all the different behaviors we expect to be supported by this proto? I think that will better help me understand if it's structured in a way that can satisfy those requirements.
@@ -0,0 +1,6 @@ | |||
package org.oppia.android.app.drawer | |||
|
|||
sealed class Argument { |
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.
Why do we need a sealed class if we have a proto with a oneof? That should satisfy the same need.
Re: the discussion, I think it's preferable to keep the tab state management in the navigation drawer itself as much as possible. However given the issues around the drawer not knowing if navigation succeeded, I think we need some way to confirm the navigation before changing the status. |
@rt4914 As there are a lot of changes that need to be reverted, should I consider making a new PR? |
Closing this PR as created a new PR simplifying the implementation #2671 |
Explanation
Fixes #1762
Earlier, always home menu item got marked in the nav menu after canceling the switch profile dialog box. This is now fixed to show the correct corresponding menu item.
Quick Updates-
All the newly added test cases are passing on Espresso -
All the newly added test cases need to be fixed for robolectric.
Checklist