Resolves #2307 make achievements activity more visible (#5442)

* Resolves #2307 by adding user level in menu

* Formatted code as requested

* Start sentence with uppercase

* javadoc

* Fixed my typo

* javadoc

---------

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Shashwat Kedia 2024-01-17 12:19:14 +05:30 committed by GitHub
parent 56e21ab7c8
commit 1aa07f9368
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 4 deletions

View file

@ -28,6 +28,7 @@ import fr.free.nrw.commons.di.ApplicationlessInjection;
import fr.free.nrw.commons.feedback.FeedbackContentCreator;
import fr.free.nrw.commons.feedback.model.Feedback;
import fr.free.nrw.commons.feedback.FeedbackDialog;
import fr.free.nrw.commons.kvstore.BasicKvStore;
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.logging.CommonsLogSender;
import fr.free.nrw.commons.profile.ProfileActivity;
@ -91,17 +92,23 @@ public class MoreBottomSheetFragment extends BottomSheetDialogFragment {
}
/**
* Set the username in navigationHeader.
* Set the username and user achievements level (if available) in navigationHeader.
*/
private void setUserName() {
moreProfile.setText(getUserName());
BasicKvStore store = new BasicKvStore(this.getContext(), getUserName());
String level = store.getString("userAchievementsLevel","0");
if (level.equals("0")) {
moreProfile.setText(getUserName() + " (" + getString(R.string.see_your_achievements) + ")");
}
else {
moreProfile.setText(getUserName() + " (" + getString(R.string.level) + " " + level + ")");
}
}
private String getUserName(){
final AccountManager accountManager = AccountManager.get(getActivity());
final Account[] allAccounts = accountManager.getAccountsByType(BuildConfig.ACCOUNT_TYPE);
if (allAccounts.length != 0) {
moreProfile.setText(allAccounts[0].name);
return allAccounts[0].name;
}
return "";