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

Resolves #2307 make achievements activity more visible #5442

Merged
merged 6 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand Down Expand Up @@ -91,17 +92,24 @@ public void onAttach(@NonNull final Context context) {
}

/**
* Set the username in navigationHeader.
* Set the username and user level (if available) in navigationHeader.
*/
private void setUserName() {
moreProfile.setText(getUserName());
BasicKvStore store = new BasicKvStore(this.getContext(), getUserName());
String level = store.getString("userLevel","0");
if(level.equals("0"))
ShashwatKedia marked this conversation as resolved.
Show resolved Hide resolved
{
moreProfile.setText(getUserName() + " ("+getString(R.string.see_your_achievements)+")");
ShashwatKedia marked this conversation as resolved.
Show resolved Hide resolved
}
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 "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.databinding.FragmentAchievementsBinding;
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
import fr.free.nrw.commons.kvstore.BasicKvStore;
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
import fr.free.nrw.commons.utils.ConfigUtils;
import fr.free.nrw.commons.utils.DialogUtil;
Expand Down Expand Up @@ -357,7 +358,7 @@ private void setImageRevertPercentage(int notRevertPercentage){

/**
* Used the inflate the fetched statistics of the images uploaded by user
* and assign badge and level
* and assign badge and level. Also stores the level of user in BasicKvStore to display in menu
* @param achievements
*/
private void inflateAchievements(Achievements achievements) {
Expand All @@ -377,6 +378,8 @@ private void inflateAchievements(Achievements achievements) {
binding.achievementBadgeImage.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.badge,
new ContextThemeWrapper(getActivity(), levelInfo.getLevelStyle()).getTheme()));
binding.achievementBadgeText.setText(Integer.toString(levelInfo.getLevelNumber()));
BasicKvStore store = new BasicKvStore(this.getContext(), userName);
store.putString("userLevel", Integer.toString(levelInfo.getLevelNumber()));
ShashwatKedia marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ Upload your first media by tapping on the add button.</string>
<string name="permissions_are_required_for_functionality">Permissions are required for functionality</string>
<string name="learn_how_to_write_a_useful_description">Learn how to write a useful description</string>
<string name="learn_how_to_write_a_useful_caption">Learn how to write a useful caption</string>
<string name="see_your_achievements">see your achievements</string>
ShashwatKedia marked this conversation as resolved.
Show resolved Hide resolved
<plurals name="custom_picker_images_selected_title_appendix">
<item quantity="one">%d image selected</item>
<item quantity="other">%d images selected</item>
Expand Down