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

Fixes #3191 Make the username along with the rewards icon clickable in the Navigation Drawer #3283

Closed
wants to merge 4 commits into from

Conversation

ajuancer
Copy link

@ajuancer ajuancer commented Dec 7, 2019

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.

Click on user name open AchievmentsActivity
When TextView username is clicked
@ajuancer ajuancer closed this Dec 7, 2019
@ajuancer ajuancer reopened this Dec 7, 2019
@codecov-io
Copy link

codecov-io commented Dec 7, 2019

Codecov Report

Merging #3283 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
...free/nrw/commons/theme/NavigationBaseActivity.java 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0be497...3fbcf03. Read the comment docs.

@@ -139,6 +139,11 @@ private void setUserName() {
drawerLayout.closeDrawer(navigationView);
AchievementsActivity.startYourself(NavigationBaseActivity.this);
});
TextView userName = navHeaderView.findViewById(R.id.username);
userName.setOnClickListener(v -> {

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 :)

@ajuancer ajuancer closed this Dec 8, 2019
@ajuancer ajuancer reopened this Dec 8, 2019
@ajuancer
Copy link
Author

ajuancer commented Dec 8, 2019

@FlorianSW suggests implementing a specific method. This method is called makeClickable

@nicolas-raoul nicolas-raoul changed the title Merge pull request #1 from commons-app/master Implementing call to the AchievementsActivity.java when the user name is pressed as it occurs when the rewards icon is pressed Dec 9, 2019
@neslihanturan neslihanturan changed the title Implementing call to the AchievementsActivity.java when the user name is pressed as it occurs when the rewards icon is pressed Fixes #3192 Improve the share message of the app Dec 9, 2019
Copy link
Collaborator

@neslihanturan neslihanturan left a 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:)

@neslihanturan
Copy link
Collaborator

Just a small issue, can you please add Javadocs for the method you just added?

Copy link
Contributor

@yashk2000 yashk2000 left a 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.
@ajuancer
Copy link
Author

ajuancer commented Dec 9, 2019

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?

@ajuancer
Copy link
Author

ajuancer commented Dec 9, 2019

This change has also been tested in Android 10 and works perfectly!

@yashk2000
Copy link
Contributor

@ajuancer please correct the issue number you fixed and the pr title.
You've fixed #3191 but have mentioned #3192 in your templated by mistake.
Please take care of this small detail.
Rest looks good 🚀

@ajuancer ajuancer changed the title Fixes #3192 Improve the share message of the app Fixes #3191 Improve the share message of the app Dec 9, 2019
@yashk2000
Copy link
Contributor

@ajuancer #3191 is "Make the username along with the rewards icon clickable in the Navigation Drawer", not "Improve the share message of the app". Please update the main pr title and the fixes line of the pr template too where you've written "Improve the share message of the app".

@ajuancer ajuancer changed the title Fixes #3191 Improve the share message of the app Fixes #3191 Make the username along with the rewards icon clickable in the Navigation Drawer Dec 10, 2019
Copy link
Contributor

@yashk2000 yashk2000 left a 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 🎉

Copy link

@FlorianSW FlorianSW left a 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);
Copy link
Member

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){
Copy link
Member

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()

@macgills
Copy link
Collaborator

fixed by #3401

@macgills macgills closed this May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the username along with the rewards icon clickable in the Navigation Drawer
7 participants