Skip to content

Commit

Permalink
Enhanced : Revamped Achievement Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldoshii committed Mar 27, 2024
1 parent 4c43bf2 commit 2f94524
Show file tree
Hide file tree
Showing 4 changed files with 536 additions and 696 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ dependencies {
debugImplementation "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY_VERSION"

// Support libraries
implementation "com.google.android.material:material:1.1.0-alpha04"
implementation "com.google.android.material:material:1.9.0"
implementation "androidx.browser:browser:1.3.0"
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
View rootView = binding.getRoot();

binding.achievementInfo.setOnClickListener(view -> showInfoDialog());
binding.imagesUploadInfo.setOnClickListener(view -> showUploadInfo());
binding.imagesRevertedInfo.setOnClickListener(view -> showRevertedInfo());
binding.imagesUsedByWikiInfo.setOnClickListener(view -> showUsedByWikiInfo());
binding.imagesNearbyInfo.setOnClickListener(view -> showImagesViaNearbyInfo());
binding.imagesFeaturedInfo.setOnClickListener(view -> showFeaturedImagesInfo());
binding.thanksReceivedInfo.setOnClickListener(view -> showThanksReceivedInfo());
binding.qualityImagesInfo.setOnClickListener(view -> showQualityImagesInfo());
binding.imagesUploadInfoIcon.setOnClickListener(view -> showUploadInfo());
binding.imagesRevertedInfoIcon.setOnClickListener(view -> showRevertedInfo());
binding.imagesUsedByWikiInfoIcon.setOnClickListener(view -> showUsedByWikiInfo());
binding.imagesNearbyInfoIcon.setOnClickListener(view -> showImagesViaNearbyInfo());
binding.imagesFeaturedInfoIcon.setOnClickListener(view -> showFeaturedImagesInfo());
binding.thanksReceivedInfoIcon.setOnClickListener(view -> showThanksReceivedInfo());
binding.qualityImagesInfoIcon.setOnClickListener(view -> showQualityImagesInfo());

// DisplayMetrics used to fetch the size of the screen
DisplayMetrics displayMetrics = new DisplayMetrics();
Expand All @@ -112,19 +112,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

setHasOptionsMenu(true);

// Set the initial value of WikiData edits to 0
binding.wikidataEdits.setText("0");
if(sessionManager.getUserName() == null || sessionManager.getUserName().equals(userName)){
binding.tvAchievementsOfUser.setVisibility(View.GONE);
}else{
binding.tvAchievementsOfUser.setVisibility(View.VISIBLE);
binding.tvAchievementsOfUser.setText(getString(R.string.achievements_of_user,userName));
}

// Achievements currently unimplemented in Beta flavor. Skip all API calls.
if(ConfigUtils.isBetaFlavour()) {
binding.progressBar.setVisibility(View.GONE);
binding.imagesUsedByWikiText.setText(R.string.no_image);
binding.imagesRevertedText.setText(R.string.no_image_reverted);
binding.imagesUploadTextParam.setText(R.string.no_image_uploaded);
binding.wikidataEdits.setText("0");
Expand Down Expand Up @@ -194,7 +184,7 @@ private void setAchievements() {
setUploadCount(Achievements.from(response));
} else {
Timber.d("success");
binding.layoutImageReverts.setVisibility(View.INVISIBLE);
// TODO Create a Method to Hide all the Statistics
binding.achievementBadgeImage.setVisibility(View.INVISIBLE);
// If the number of edits made by the user are more than 150,000
// in some cases such high number of wiki edit counts cause the
Expand Down Expand Up @@ -304,13 +294,13 @@ private void setAchievementsUploadCount(Achievements achievements, int uploadCou
*/
private void setUploadProgress(int uploadCount){
if (uploadCount==0){
setZeroAchievements();
// TODO
//setZeroAchievements();
}else {
binding.imagesUploadedProgressbar.setVisibility(View.VISIBLE);
binding.imagesUploadedProgressbar.setProgress
(100*uploadCount/levelInfo.getMaxUploadCount());
binding.tvUploadedImages.setText
(uploadCount + "/" + levelInfo.getMaxUploadCount());
binding.imageUploadedTVCount.setText(uploadCount+"/"+levelInfo.getMaxUploadCount());
}

}
Expand All @@ -329,7 +319,6 @@ private void setZeroAchievements() {
binding.imageRevertsProgressbar.setVisibility(View.INVISIBLE);
binding.imagesUsedByWikiProgressBar.setVisibility(View.INVISIBLE);
binding.achievementBadgeImage.setVisibility(View.INVISIBLE);
binding.imagesUsedByWikiText.setText(R.string.no_image);
binding.imagesRevertedText.setText(R.string.no_image_reverted);
binding.imagesUploadTextParam.setText(R.string.no_image_uploaded);
binding.achievementBadgeImage.setVisibility(View.INVISIBLE);
Expand All @@ -343,7 +332,7 @@ private void setImageRevertPercentage(int notRevertPercentage){
binding.imageRevertsProgressbar.setVisibility(View.VISIBLE);
binding.imageRevertsProgressbar.setProgress(notRevertPercentage);
String revertPercentage = Integer.toString(notRevertPercentage);
binding.imageRevertsProgressbar.setProgressTextFormatPattern(revertPercentage + "%%");
binding.imageRevertTVCount.setText(revertPercentage + "%");
binding.imagesRevertLimitText.setText(getResources().getString(R.string.achievements_revert_limit_message)+ levelInfo.getMinNonRevertPercentage() + "%");
}

Expand All @@ -357,10 +346,7 @@ private void inflateAchievements(Achievements achievements) {
binding.thanksReceived.setText(String.valueOf(achievements.getThanksReceived()));
binding.imagesUsedByWikiProgressBar.setProgress
(100 * achievements.getUniqueUsedImages() / levelInfo.getMaxUniqueImages());
if(binding.tvWikiPb != null) {
binding.tvWikiPb.setText
(achievements.getUniqueUsedImages() + "/" + levelInfo.getMaxUniqueImages());
}
binding.imagesUsedCount.setText(achievements.getUniqueUsedImages() + "/" + levelInfo.getMaxUploadCount());
binding.imageFeatured.setText(String.valueOf(achievements.getFeaturedImages()));
binding.qualityImages.setText(String.valueOf(achievements.getQualityImages()));
String levelUpInfoString = getString(R.string.level).toUpperCase();
Expand Down
Loading

0 comments on commit 2f94524

Please sign in to comment.