Skip to content

Commit

Permalink
Changed statistics to badges
Browse files Browse the repository at this point in the history
  • Loading branch information
YujingZHG committed Nov 1, 2024
1 parent 197855a commit 776e099
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 221 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
implementation 'com.github.pedrovgs:renderers:3.3.3'
implementation "org.maplibre.gl:android-sdk:$MAPLIBRE_VERSION"
implementation 'org.maplibre.gl:android-plugin-scalebar-v9:1.0.0'
implementation 'com.google.android.flexbox:flexbox:3.0.0'

implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import android.accounts.Account;
import android.content.Context;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.net.Uri;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.view.ContextThemeWrapper;
Expand All @@ -28,6 +32,7 @@
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import javax.inject.Inject;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -92,10 +97,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
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.wikidataEditsIcon.setOnClickListener(view -> showImagesViaNearbyInfo());
binding.qualityImageIcon.setOnClickListener(view -> showFeaturedImagesInfo());
binding.featuredImageIcon.setOnClickListener(view -> showThanksReceivedInfo());
binding.thanksImageIcon.setOnClickListener(view -> showThanksReceivedInfo());

// DisplayMetrics used to fetch the size of the screen
DisplayMetrics displayMetrics = new DisplayMetrics();
Expand Down Expand Up @@ -132,11 +137,26 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
binding.imageFeatured.setText("0");
binding.qualityImages.setText("0");
binding.achievementLevel.setText("0");
binding.thanksReceived.setText("0");
Map<ImageView,TextView> badgeMap = Map.of(
binding.wikidataEditsIcon,binding.wikidataEdits,
binding.featuredImageIcon,binding.imageFeatured,
binding.qualityImageIcon, binding.qualityImages,
binding.thanksImageIcon, binding.thanksReceived
);
badgeRender(badgeMap);
setMenuVisibility(true);
return rootView;
}
setWikidataEditCount();
setAchievements();
Map<ImageView,TextView> badgeMap = Map.of(
binding.wikidataEditsIcon,binding.wikidataEdits,
binding.featuredImageIcon,binding.imageFeatured,
binding.qualityImageIcon, binding.qualityImages,
binding.thanksImageIcon, binding.thanksReceived
);
badgeRender(badgeMap);
return rootView;
}

Expand Down Expand Up @@ -479,4 +499,28 @@ private boolean checkAccount(){
}
return true;
}
/**
* list the badgeset and set the 0 one to gray
* @param badgeMap
*/
public void badgeRender(Map<ImageView, TextView> badgeMap){
for(Map.Entry<ImageView,TextView> badge:badgeMap.entrySet()){
TextView textView= badge.getValue();
ImageView imageView=badge.getKey();
if(textView.getText().equals("0")){
Grayfilter(imageView);
textView.setVisibility(View.GONE);
}
}
}
/**
* Set imageView element to Gray
* @param imageView
*/
public void Grayfilter(ImageView imageView){
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imageView.setColorFilter(filter);
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/badge_number_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/divider_grey"/>
<corners android:radius="12dp"/>
</shape>
Loading

0 comments on commit 776e099

Please sign in to comment.