-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixes #3191 Make the username along with the rewards icon clickable in the Navigation Drawer #3283
Conversation
Click on user name open AchievmentsActivity
When TextView username is clicked
Codecov Report
@@ Coverage Diff @@
## master #3283 +/- ##
=========================================
- Coverage 7.5% 7.5% -0.01%
=========================================
Files 255 255
Lines 11199 11205 +6
Branches 892 892
=========================================
Hits 841 841
- Misses 10296 10302 +6
Partials 62 62
Continue to review full report at Codecov.
|
@@ -139,6 +139,11 @@ private void setUserName() { | |||
drawerLayout.closeDrawer(navigationView); | |||
AchievementsActivity.startYourself(NavigationBaseActivity.this); | |||
}); | |||
TextView userName = navHeaderView.findViewById(R.id.username); | |||
userName.setOnClickListener(v -> { |
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.
I think it would make sense to somehow extract the onclick listener to a method or something, so that you do not simply need to duplicate the code, but instead call a function :)
@FlorianSW suggests implementing a specific method. This method is called |
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 @ajuancer , it works for me:)
Just a small issue, can you please add Javadocs for the method you just added? |
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 👍
Just add the javadocs for the new method please.
To add the javadocs, type /**
on the line above the new makeClickable
methods and press enter.
Now it can change to any activity, not just AchievementsActivity. For this reason, startYourself() of AchievmentsActivity should be deleted.
Javadoc included, and method modified to work with other activities, maybe it could replace the respective methods that exit in each activity to change from one to it, what do you think? |
This change has also been tested in Android 10 and works perfectly! |
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 for the work @ajuancer. Looks good now 🎉
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.
Not quite happy with the name of the method, but because of my lack of a better one in my head, it's ok :D Thanks for working on that! Looks good.
@@ -135,9 +135,23 @@ private void setUserName() { | |||
username.setText(allAccounts[0].name); | |||
} | |||
ImageView userIcon = navHeaderView.findViewById(R.id.user_icon); | |||
userIcon.setOnClickListener(v -> { | |||
makeClickable(userIcon, NavigationBaseActivity.this, AchievementsActivity.class); |
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.
Instead of adding event listeners on both the views separately wrap the icon and name in a Linearlayout and add a listener to it.
* @param actualContext The context of actual activity. | ||
* @param activity The activity to launch. | ||
*/ | ||
public void makeClickable(View pressedView, Context actualContext, Class activity){ |
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.
Based on the first comment this change won't be needed. U can continue using
AchievementsActivity.startYourself()
fixed by #3401 |
Implementing call to the AchievementsActivity.java when the user name is pressed as it occurs when the rewards icon is pressed.
Fixes #3191 Make the username along with the rewards icon clickable in the Navigation Drawer.
What changes did you make and why?
Set an onClick listener on the user name textview and make the listener have the same action as that of the trophy icon, in order to make navigation easier.
Tests performed (required)
Tested on Android 10.
Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request.