mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-01 07:13:56 +01:00
* 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:
parent
56e21ab7c8
commit
1aa07f9368
3 changed files with 15 additions and 4 deletions
|
|
@ -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 "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue