Merge branch 'leaderboard' into temp-leaderboard-merge

This commit is contained in:
Vivek Maskara 2020-07-08 19:24:59 -07:00 committed by GitHub
commit ec49edb7a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 1418 additions and 624 deletions

View file

@ -7,10 +7,9 @@ import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
import androidx.test.espresso.intent.rule.IntentsTestRule
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.filters.MediumTest
import androidx.test.runner.AndroidJUnit4
import fr.free.nrw.commons.achievements.AchievementsActivity
import fr.free.nrw.commons.auth.LoginActivity
import fr.free.nrw.commons.profile.ProfileActivity
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -32,6 +31,6 @@ class AchievementsActivityTest {
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
onView(withId(R.id.user_icon)).perform(click())
Intents.intended(hasComponent(AchievementsActivity::class.java.name))
Intents.intended(hasComponent(ProfileActivity::class.java.name))
}
}

View file

@ -137,8 +137,8 @@
/>
<activity
android:name=".achievements.AchievementsActivity"
android:label="@string/Achievements" />
android:name=".profile.ProfileActivity"
android:label="@string/Profile" />
<activity
android:name=".bookmarks.BookmarksActivity"

View file

@ -12,7 +12,7 @@ import javax.inject.Singleton;
import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.achievements.FeedbackResponse;
import fr.free.nrw.commons.profile.achievements.FeedbackResponse;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
import fr.free.nrw.commons.utils.ViewUtilWrapper;

View file

@ -4,7 +4,6 @@ import dagger.Module;
import dagger.android.ContributesAndroidInjector;
import fr.free.nrw.commons.AboutActivity;
import fr.free.nrw.commons.WelcomeActivity;
import fr.free.nrw.commons.achievements.AchievementsActivity;
import fr.free.nrw.commons.auth.LoginActivity;
import fr.free.nrw.commons.auth.SignupActivity;
import fr.free.nrw.commons.bookmarks.BookmarksActivity;
@ -15,6 +14,7 @@ import fr.free.nrw.commons.explore.depictions.WikidataItemDetailsActivity;
import fr.free.nrw.commons.explore.SearchActivity;
import fr.free.nrw.commons.explore.ExploreActivity;
import fr.free.nrw.commons.notification.NotificationActivity;
import fr.free.nrw.commons.profile.ProfileActivity;
import fr.free.nrw.commons.review.ReviewActivity;
import fr.free.nrw.commons.settings.SettingsActivity;
import fr.free.nrw.commons.upload.UploadActivity;
@ -68,7 +68,7 @@ public abstract class ActivityBuilderModule {
abstract ExploreActivity bindExploreActivity();
@ContributesAndroidInjector
abstract AchievementsActivity bindAchievementsActivity();
abstract ProfileActivity bindAchievementsActivity();
@ContributesAndroidInjector
abstract BookmarksActivity bindBookmarksActivity();

View file

@ -19,6 +19,8 @@ import fr.free.nrw.commons.explore.recentsearches.RecentSearchesFragment;
import fr.free.nrw.commons.media.MediaDetailFragment;
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
import fr.free.nrw.commons.nearby.fragments.NearbyParentFragment;
import fr.free.nrw.commons.profile.achievements.AchievementsFragment;
import fr.free.nrw.commons.profile.leaderboard.LeaderboardFragment;
import fr.free.nrw.commons.review.ReviewImageFragment;
import fr.free.nrw.commons.settings.SettingsFragment;
import fr.free.nrw.commons.upload.categories.UploadCategoriesFragment;
@ -103,4 +105,10 @@ public abstract class FragmentBuilderModule {
@ContributesAndroidInjector
abstract ParentCategoriesFragment bindParentCategoriesFragment();
@ContributesAndroidInjector
abstract AchievementsFragment bindAchievementsFragment();
@ContributesAndroidInjector
abstract LeaderboardFragment bindLeaderboardFragment();
}

View file

@ -85,11 +85,13 @@ public class NetworkingModule {
public OkHttpJsonApiClient provideOkHttpJsonApiClient(OkHttpClient okHttpClient,
DepictsClient depictsClient,
@Named("tools_forge") HttpUrl toolsForgeUrl,
@Named("test_tools_forge") HttpUrl testToolsForgeUrl,
@Named("default_preferences") JsonKvStore defaultKvStore,
Gson gson) {
return new OkHttpJsonApiClient(okHttpClient,
depictsClient,
toolsForgeUrl,
testToolsForgeUrl,
WIKIDATA_SPARQL_QUERY_URL,
BuildConfig.WIKIMEDIA_CAMPAIGNS_URL,
gson);
@ -124,6 +126,14 @@ public class NetworkingModule {
return HttpUrl.parse(TOOLS_FORGE_URL);
}
@Provides
@Named("test_tools_forge")
@NonNull
@SuppressWarnings("ConstantConditions")
public HttpUrl provideTestToolsForgeUrl() {
return HttpUrl.parse(TEST_TOOLS_FORGE_URL);
}
@Provides
@Singleton
@Named(NAMED_COMMONS_WIKI_SITE)

View file

@ -3,14 +3,15 @@ package fr.free.nrw.commons.mwapi;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import fr.free.nrw.commons.achievements.FeaturedImages;
import fr.free.nrw.commons.achievements.FeedbackResponse;
import fr.free.nrw.commons.profile.achievements.FeaturedImages;
import fr.free.nrw.commons.profile.achievements.FeedbackResponse;
import fr.free.nrw.commons.campaigns.CampaignResponseDTO;
import fr.free.nrw.commons.explore.depictions.DepictsClient;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.nearby.Place;
import fr.free.nrw.commons.nearby.model.NearbyResponse;
import fr.free.nrw.commons.nearby.model.NearbyResultItem;
import fr.free.nrw.commons.profile.leaderboard.LeaderboardResponse;
import fr.free.nrw.commons.upload.FileUtils;
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem;
import fr.free.nrw.commons.utils.ConfigUtils;
@ -40,6 +41,7 @@ public class OkHttpJsonApiClient {
private final OkHttpClient okHttpClient;
private final DepictsClient depictsClient;
private final HttpUrl wikiMediaToolforgeUrl;
private final HttpUrl wikiMediaTestToolforgeUrl;
private final String sparqlQueryUrl;
private final String campaignsUrl;
private final Gson gson;
@ -49,17 +51,58 @@ public class OkHttpJsonApiClient {
public OkHttpJsonApiClient(OkHttpClient okHttpClient,
DepictsClient depictsClient,
HttpUrl wikiMediaToolforgeUrl,
HttpUrl wikiMediaTestToolforgeUrl,
String sparqlQueryUrl,
String campaignsUrl,
Gson gson) {
this.okHttpClient = okHttpClient;
this.depictsClient = depictsClient;
this.wikiMediaToolforgeUrl = wikiMediaToolforgeUrl;
this.wikiMediaTestToolforgeUrl = wikiMediaTestToolforgeUrl;
this.sparqlQueryUrl = sparqlQueryUrl;
this.campaignsUrl = campaignsUrl;
this.gson = gson;
}
@NonNull
public Single<LeaderboardResponse> getLeaderboard(String userName, String duration, String category, String limit, String offset) {
final String fetchLeaderboardUrlTemplate = wikiMediaTestToolforgeUrl
+ "/leaderboard.py";
return Single.fromCallable(() -> {
String url = String.format(Locale.ENGLISH,
fetchLeaderboardUrlTemplate,
userName,
duration,
category,
limit,
offset);
HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
urlBuilder.addQueryParameter("user", userName);
urlBuilder.addQueryParameter("duration", duration);
urlBuilder.addQueryParameter("category", category);
urlBuilder.addQueryParameter("limit", limit);
urlBuilder.addQueryParameter("offset", offset);
Timber.i("Url %s", urlBuilder.toString());
Request request = new Request.Builder()
.url(urlBuilder.toString())
.build();
Response response = okHttpClient.newCall(request).execute();
if (response != null && response.body() != null && response.isSuccessful()) {
String json = response.body().string();
if (json == null) {
return null;
}
Timber.d("Response for leaderboard is %s", json);
try {
return gson.fromJson(json, LeaderboardResponse.class);
} catch (Exception e) {
return new LeaderboardResponse();
}
}
return null;
});
}
@NonNull
public Single<Integer> getUploadCount(String userName) {
HttpUrl.Builder urlBuilder = wikiMediaToolforgeUrl.newBuilder();

View file

@ -0,0 +1,79 @@
package fr.free.nrw.commons.profile;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.google.android.material.tabs.TabLayout;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.profile.achievements.AchievementsFragment;
import fr.free.nrw.commons.profile.leaderboard.LeaderboardFragment;
import fr.free.nrw.commons.theme.NavigationBaseActivity;
import java.util.ArrayList;
import java.util.List;
public class ProfileActivity extends NavigationBaseActivity {
private FragmentManager supportFragmentManager;
@BindView(R.id.viewPager)
ViewPager viewPager;
@BindView(R.id.tab_layout)
TabLayout tabLayout;
ViewPagerAdapter viewPagerAdapter;
private AchievementsFragment achievementsFragment;
private LeaderboardFragment leaderboardFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
ButterKnife.bind(this);
initDrawer();
setTitle(R.string.Profile);
supportFragmentManager = getSupportFragmentManager();
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(viewPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
setTabs();
}
/**
* Creates a way to change current activity to AchievementActivity
* @param context
*/
public static void startYourself(Context context) {
Intent intent = new Intent(context, ProfileActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(intent);
}
private void setTabs() {
List<Fragment> fragmentList = new ArrayList<>();
List<String> titleList = new ArrayList<>();
achievementsFragment = new AchievementsFragment();
fragmentList.add(achievementsFragment);
titleList.add(getResources().getString(R.string.achievements_tab_title).toUpperCase());
leaderboardFragment = new LeaderboardFragment();
fragmentList.add(leaderboardFragment);
titleList.add(getResources().getString(R.string.leaderboard_tab_title).toUpperCase());
viewPagerAdapter.setTabData(fragmentList, titleList);
viewPagerAdapter.notifyDataSetChanged();
}
@Override
public void onDestroy() {
super.onDestroy();
compositeDisposable.clear();
}
}

View file

@ -0,0 +1,54 @@
package fr.free.nrw.commons.profile;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.ArrayList;
import java.util.List;
public class ViewPagerAdapter extends FragmentPagerAdapter {
private List<Fragment> fragmentList = new ArrayList<>();
private List<String> fragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
/**
* This method returns the fragment of the viewpager at a particular position
* @param position
*/
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
/**
* This method returns the total number of fragments in the viewpager.
* @return size
*/
@Override
public int getCount() {
return fragmentList.size();
}
/**
* This method sets the fragment and title list in the viewpager
* @param fragmentList List of all fragments to be displayed in the viewpager
* @param fragmentTitleList List of all titles of the fragments
*/
public void setTabData(List<Fragment> fragmentList, List<String> fragmentTitleList) {
this.fragmentList = fragmentList;
this.fragmentTitleList = fragmentTitleList;
}
/**
* This method returns the title of the page at a particular position
* @param position
*/
@Override
public CharSequence getPageTitle(int position) {
return fragmentTitleList.get(position);
}
}

View file

@ -1,4 +1,4 @@
package fr.free.nrw.commons.achievements
package fr.free.nrw.commons.profile.achievements
/**
* Represents Achievements class and stores all the parameters
@ -87,12 +87,14 @@ class Achievements {
*/
@JvmStatic
fun from(response: FeedbackResponse): Achievements {
return Achievements(response.uniqueUsedImages,
response.articlesUsingImages,
response.thanksReceived,
response.featuredImages.qualityImages
+ response.featuredImages.featuredPicturesOnWikimediaCommons, 0,
response.deletedUploads)
return Achievements(
response.uniqueUsedImages,
response.articlesUsingImages,
response.thanksReceived,
response.featuredImages.qualityImages
+ response.featuredImages.featuredPicturesOnWikimediaCommons, 0,
response.deletedUploads
)
}
}
}

View file

@ -1,61 +1,52 @@
package fr.free.nrw.commons.achievements;
package fr.free.nrw.commons.profile.achievements;
import android.accounts.Account;
import android.annotation.SuppressLint;
import android.content.Context;
import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.FileProvider;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import com.dinuscxj.progressbar.CircleProgressBar;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Objects;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.dinuscxj.progressbar.CircleProgressBar;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
import fr.free.nrw.commons.theme.NavigationBaseActivity;
import fr.free.nrw.commons.utils.ViewUtil;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Objects;
import javax.inject.Inject;
import org.apache.commons.lang3.StringUtils;
import timber.log.Timber;
/**
* activity for sharing feedback on uploaded activity
* fragment for sharing feedback on uploaded activity
*/
public class AchievementsActivity extends NavigationBaseActivity {
public class AchievementsFragment extends CommonsDaggerSupportFragment {
private static final double BADGE_IMAGE_WIDTH_RATIO = 0.4;
private static final double BADGE_IMAGE_HEIGHT_RATIO = 0.3;
@ -64,55 +55,71 @@ public class AchievementsActivity extends NavigationBaseActivity {
@BindView(R.id.achievement_badge_image)
ImageView imageView;
@BindView(R.id.achievement_badge_text)
TextView badgeText;
@BindView(R.id.achievement_level)
TextView levelNumber;
@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.thanks_received)
TextView thanksReceived;
@BindView(R.id.images_uploaded_progressbar)
CircleProgressBar imagesUploadedProgressbar;
@BindView(R.id.images_used_by_wiki_progress_bar)
CircleProgressBar imagesUsedByWikiProgressBar;
@BindView(R.id.image_reverts_progressbar)
CircleProgressBar imageRevertsProgressbar;
@BindView(R.id.image_featured)
TextView imagesFeatured;
@BindView(R.id.images_revert_limit_text)
TextView imagesRevertLimitText;
@BindView(R.id.progressBar)
ProgressBar progressBar;
@BindView(R.id.layout_image_uploaded)
RelativeLayout layoutImageUploaded;
@BindView(R.id.layout_image_reverts)
RelativeLayout layoutImageReverts;
@BindView(R.id.layout_image_used_by_wiki)
RelativeLayout layoutImageUsedByWiki;
@BindView(R.id.layout_statistics)
LinearLayout layoutStatistics;
@BindView(R.id.images_used_by_wiki_text)
TextView imageByWikiText;
@BindView(R.id.images_reverted_text)
TextView imageRevertedText;
@BindView(R.id.images_upload_text_param)
TextView imageUploadedText;
@BindView(R.id.wikidata_edits)
TextView wikidataEditsText;
@Inject
SessionManager sessionManager;
@Inject
OkHttpJsonApiClient okHttpJsonApiClient;
MenuItem item;
private CompositeDisposable compositeDisposable = new CompositeDisposable();
// To keep track of the number of wiki edits made by a user
private int numberOfEdits = 0;
MenuItem item;
/**
* This method helps in the creation Achievement screen and
* dynamically set the size of imageView
@ -120,15 +127,13 @@ public class AchievementsActivity extends NavigationBaseActivity {
* @param savedInstanceState Data bundle
*/
@Override
@SuppressLint("StringFormatInvalid")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_achievements);
ButterKnife.bind(this);
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_achievements, container, false);
ButterKnife.bind(this, rootView);
// DisplayMetrics used to fetch the size of the screen
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
@ -139,37 +144,23 @@ public class AchievementsActivity extends NavigationBaseActivity {
params.width = (int) (width * BADGE_IMAGE_WIDTH_RATIO);
imageView.requestLayout();
setSupportActionBar(toolbar);
progressBar.setVisibility(View.VISIBLE);
setHasOptionsMenu(true);
hideLayouts();
setWikidataEditCount();
setAchievements();
initDrawer();
return rootView;
}
@Override
public void onDestroy() {
super.onDestroy();
compositeDisposable.clear();
}
/**
* To invoke the AlertDialog on clicking info button
*/
@OnClick(R.id.achievement_info)
public void showInfoDialog(){
launchAlert(getResources().getString(R.string.Achievements)
,getResources().getString(R.string.achievements_info_message));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_about, menu);
item=menu.getItem(0);
super.onCreateOptionsMenu(menu, menuInflater);
menuInflater.inflate(R.menu.menu_about, menu);
item = menu.getItem(0);
item.setVisible(false);
return true;
}
/**
@ -180,7 +171,7 @@ public class AchievementsActivity extends NavigationBaseActivity {
int id = item.getItemId();
// take screenshot in form of bitmap and show it in Alert Dialog
if (id == R.id.share_app_icon) {
View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
View rootView = getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
Bitmap screenShot = Utils.getScreenShot(rootView);
showAlert(screenShot);
}
@ -188,20 +179,39 @@ public class AchievementsActivity extends NavigationBaseActivity {
return super.onOptionsItemSelected(item);
}
/**
* It display the alertDialog with Image of screenshot
* @param screenshot
*/
public void showAlert(Bitmap screenshot){
AlertDialog.Builder alertadd = new AlertDialog.Builder(getActivity());
LayoutInflater factory = LayoutInflater.from(getActivity());
final View view = factory.inflate(R.layout.image_alert_layout, null);
ImageView screenShotImage = view.findViewById(R.id.alert_image);
screenShotImage.setImageBitmap(screenshot);
TextView shareMessage = view.findViewById(R.id.alert_text);
shareMessage.setText(R.string.achievements_share_message);
alertadd.setView(view);
alertadd.setPositiveButton(R.string.about_translate_proceed, (dialog, which) -> shareScreen(screenshot));
alertadd.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel());
alertadd.show();
}
/**
* To take bitmap and store it temporary storage and share it
* @param bitmap
*/
void shareScreen(Bitmap bitmap) {
try {
File file = new File(this.getExternalCacheDir(), "screen.png");
File file = new File(getActivity().getExternalCacheDir(), "screen.png");
FileOutputStream fOut = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
file.setReadable(true, false);
Uri fileUri = FileProvider.getUriForFile(getApplicationContext(), getPackageName()+".provider", file);
grantUriPermission(getPackageName(), fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri fileUri = FileProvider
.getUriForFile(getActivity().getApplicationContext(), getActivity().getPackageName()+".provider", file);
getActivity().grantUriPermission(getActivity().getPackageName(), fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
@ -212,6 +222,15 @@ public class AchievementsActivity extends NavigationBaseActivity {
}
}
/**
* To invoke the AlertDialog on clicking info button
*/
@OnClick(R.id.achievement_info)
public void showInfoDialog(){
launchAlert(getResources().getString(R.string.Achievements)
,getResources().getString(R.string.achievements_info_message));
}
/**
* To call the API to get results in form Single<JSONObject>
* which then calls parseJson when results are fetched
@ -234,7 +253,7 @@ public class AchievementsActivity extends NavigationBaseActivity {
layoutImageReverts.setVisibility(View.INVISIBLE);
imageView.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
// in some cases such high number of wiki edit counts cause the
// achievements calculator to fail in some cases, for more details
// refer Issue: #3295
if (numberOfEdits <= 150000) {
@ -264,7 +283,6 @@ public class AchievementsActivity extends NavigationBaseActivity {
* To call the API to fetch the count of wiki data edits
* in the form of JavaRx Single object<JSONobject>
*/
@SuppressLint("CheckResult")
private void setWikidataEditCount() {
String userName = sessionManager.getUserName();
if (StringUtils.isBlank(userName)) {
@ -285,18 +303,18 @@ public class AchievementsActivity extends NavigationBaseActivity {
/**
* Shows a snack bar which has an action button which on click dismisses the snackbar and invokes the
* listener passed
* @param tooManyAchievements if this value is true it means that the number of achievements of the
* user are so high that it wrecks havoc with the Achievements calculator due to which request may time
* @param tooManyAchievements if this value is true it means that the number of achievements of the
* user are so high that it wrecks havoc with the Achievements calculator due to which request may time
* out. Well this is the Ultimate Achievement
*/
private void showSnackBarWithRetry(boolean tooManyAchievements) {
if (tooManyAchievements) {
progressBar.setVisibility(View.GONE);
ViewUtil.showDismissibleSnackBar(findViewById(android.R.id.content),
ViewUtil.showDismissibleSnackBar(getActivity().findViewById(android.R.id.content),
R.string.achievements_fetch_failed_ultimate_achievement, R.string.retry, view -> setAchievements());
} else {
progressBar.setVisibility(View.GONE);
ViewUtil.showDismissibleSnackBar(findViewById(android.R.id.content),
ViewUtil.showDismissibleSnackBar(getActivity().findViewById(android.R.id.content),
R.string.achievements_fetch_failed, R.string.retry, view -> setAchievements());
}
}
@ -305,7 +323,7 @@ public class AchievementsActivity extends NavigationBaseActivity {
* Shows a generic error toast when error occurs while loading achievements or uploads
*/
private void onError() {
ViewUtil.showLongToast(this, getResources().getString(R.string.error_occurred));
ViewUtil.showLongToast(getActivity(), getResources().getString(R.string.error_occurred));
progressBar.setVisibility(View.GONE);
}
@ -355,7 +373,7 @@ public class AchievementsActivity extends NavigationBaseActivity {
}
private void setZeroAchievements() {
AlertDialog.Builder builder=new AlertDialog.Builder(this)
AlertDialog.Builder builder=new AlertDialog.Builder(getActivity())
.setMessage(getString(R.string.no_achievements_yet))
.setPositiveButton(getString(R.string.ok), (dialog, which) -> {
});
@ -399,20 +417,10 @@ public class AchievementsActivity extends NavigationBaseActivity {
levelUpInfoString += " " + levelInfo.getLevelNumber();
levelNumber.setText(levelUpInfoString);
imageView.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.badge,
new ContextThemeWrapper(this, levelInfo.getLevelStyle()).getTheme()));
new ContextThemeWrapper(getActivity(), levelInfo.getLevelStyle()).getTheme()));
badgeText.setText(Integer.toString(levelInfo.getLevelNumber()));
}
/**
* Creates a way to change current activity to AchievementActivity
* @param context
*/
public static void startYourself(Context context) {
Intent intent = new Intent(context, AchievementsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(intent);
}
/**
* to hide progressbar
*/
@ -447,24 +455,6 @@ public class AchievementsActivity extends NavigationBaseActivity {
levelNumber.setVisibility(View.INVISIBLE);
}
/**
* It display the alertDialog with Image of screenshot
* @param screenshot
*/
public void showAlert(Bitmap screenshot){
AlertDialog.Builder alertadd = new AlertDialog.Builder(AchievementsActivity.this);
LayoutInflater factory = LayoutInflater.from(AchievementsActivity.this);
final View view = factory.inflate(R.layout.image_alert_layout, null);
ImageView screenShotImage = view.findViewById(R.id.alert_image);
screenShotImage.setImageBitmap(screenshot);
TextView shareMessage = view.findViewById(R.id.alert_text);
shareMessage.setText(R.string.achievements_share_message);
alertadd.setView(view);
alertadd.setPositiveButton(R.string.about_translate_proceed, (dialog, which) -> shareScreen(screenshot));
alertadd.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel());
alertadd.show();
}
@OnClick(R.id.images_upload_info)
public void showUploadInfo(){
launchAlert(getResources().getString(R.string.images_uploaded)
@ -507,7 +497,7 @@ public class AchievementsActivity extends NavigationBaseActivity {
* @param message
*/
private void launchAlert(String title, String message){
new AlertDialog.Builder(AchievementsActivity.this)
new AlertDialog.Builder(getActivity())
.setTitle(title)
.setMessage(message)
.setCancelable(true)
@ -524,11 +514,11 @@ public class AchievementsActivity extends NavigationBaseActivity {
Account currentAccount = sessionManager.getCurrentAccount();
if (currentAccount == null) {
Timber.d("Current account is null");
ViewUtil.showLongToast(this, getResources().getString(R.string.user_not_logged_in));
sessionManager.forceLogin(this);
ViewUtil.showLongToast(getActivity(), getResources().getString(R.string.user_not_logged_in));
sessionManager.forceLogin(getActivity());
return false;
}
return true;
}
}
}

View file

@ -1,11 +1,11 @@
package fr.free.nrw.commons.achievements
package fr.free.nrw.commons.profile.achievements
import com.google.gson.annotations.SerializedName
/**
* Represents Featured Images on WikiMedia Commons platform
* Used by Achievements and FeedbackResponse (objects) of the user
*/
* Represents Featured Images on WikiMedia Commons platform
* Used by Achievements and FeedbackResponse (objects) of the user
*/
class FeaturedImages(
@field:SerializedName("Quality_images") val qualityImages: Int,
@field:SerializedName("Featured_pictures_on_Wikimedia_Commons") val featuredPicturesOnWikimediaCommons: Int

View file

@ -1,8 +1,8 @@
package fr.free.nrw.commons.achievements
package fr.free.nrw.commons.profile.achievements
/**
* Represent the Feedback Response of the user
*/
* Represent the Feedback Response of the user
*/
data class FeedbackResponse(val uniqueUsedImages: Int,
val articlesUsingImages: Int,
val deletedUploads: Int,

View file

@ -1,4 +1,4 @@
package fr.free.nrw.commons.achievements
package fr.free.nrw.commons.profile.achievements
import fr.free.nrw.commons.R

View file

@ -0,0 +1,162 @@
package fr.free.nrw.commons.profile.leaderboard;
import android.accounts.Account;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.facebook.drawee.view.SimpleDraweeView;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
import fr.free.nrw.commons.utils.ViewUtil;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import java.util.List;
import java.util.Objects;
import javax.inject.Inject;
import timber.log.Timber;
public class LeaderboardFragment extends CommonsDaggerSupportFragment {
@BindView(R.id.avatar)
SimpleDraweeView avatar;
@BindView(R.id.username)
TextView username;
@BindView(R.id.rank)
TextView rank;
@BindView(R.id.count)
TextView count;
@BindView(R.id.leaderboard_list)
RecyclerView leaderboardListRecyclerView;
@BindView(R.id.progressBar)
ProgressBar progressBar;
@Inject
SessionManager sessionManager;
@Inject
OkHttpJsonApiClient okHttpJsonApiClient;
private String avatarSourceURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/%s/1024px-%s.png";
private CompositeDisposable compositeDisposable = new CompositeDisposable();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_leaderboard, container, false);
ButterKnife.bind(this, rootView);
progressBar.setVisibility(View.VISIBLE);
hideLayouts();
setLeaderboard();
return rootView;
}
/**
* To call the API to get results in form Single<JSONObject>
* which then calls parseJson when results are fetched
*/
private void setLeaderboard() {
if (checkAccount()) {
try{
compositeDisposable.add(okHttpJsonApiClient
.getLeaderboard(Objects.requireNonNull(sessionManager.getCurrentAccount()).name,
"all_time", "upload", null, null)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
response -> {
if (response != null && response.getStatus() == 200) {
setLeaderboardUser(response);
setLeaderboardList(response.getLeaderboardList());
}
},
t -> {
Timber.e(t, "Fetching leaderboard statistics failed");
onError();
}
));
}
catch (Exception e){
Timber.d(e+"success");
}
}
}
private void setLeaderboardUser(LeaderboardResponse response) {
hideProgressBar();
avatar.setImageURI(
Uri.parse(String.format(avatarSourceURL, response.getAvatar(), response.getAvatar())));
username.setText(response.getUsername());
rank.setText(String.format("%s %d", getString(R.string.rank_prefix), response.getRank()));
count.setText(String.format("%s %d", getString(R.string.count_prefix), response.getCategoryCount()));
}
private void setLeaderboardList(List<LeaderboardList> leaderboardList) {
LeaderboardListAdapter leaderboardListAdapter = new LeaderboardListAdapter(leaderboardList);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
leaderboardListRecyclerView.setLayoutManager(linearLayoutManager);
leaderboardListRecyclerView.setAdapter(leaderboardListAdapter);
}
/**
* to hide progressbar
*/
private void hideProgressBar() {
if (progressBar != null) {
progressBar.setVisibility(View.GONE);
avatar.setVisibility(View.VISIBLE);
username.setVisibility(View.VISIBLE);
rank.setVisibility(View.VISIBLE);
leaderboardListRecyclerView.setVisibility(View.VISIBLE);
}
}
/**
* used to hide the layouts while fetching results from api
*/
private void hideLayouts(){
avatar.setVisibility(View.INVISIBLE);
username.setVisibility(View.INVISIBLE);
rank.setVisibility(View.INVISIBLE);
leaderboardListRecyclerView.setVisibility(View.INVISIBLE);
}
/**
* check to ensure that user is logged in
* @return
*/
private boolean checkAccount(){
Account currentAccount = sessionManager.getCurrentAccount();
if (currentAccount == null) {
Timber.d("Current account is null");
ViewUtil.showLongToast(getActivity(), getResources().getString(R.string.user_not_logged_in));
sessionManager.forceLogin(getActivity());
return false;
}
return true;
}
/**
* Shows a generic error toast when error occurs while loading leaderboard
*/
private void onError() {
ViewUtil.showLongToast(getActivity(), getResources().getString(R.string.error_occurred));
progressBar.setVisibility(View.GONE);
}
}

View file

@ -0,0 +1,53 @@
package fr.free.nrw.commons.profile.leaderboard;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class LeaderboardList {
@SerializedName("username")
@Expose
private String username;
@SerializedName("category_count")
@Expose
private Integer categoryCount;
@SerializedName("avatar")
@Expose
private String avatar;
@SerializedName("rank")
@Expose
private Integer rank;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Integer getCategoryCount() {
return categoryCount;
}
public void setCategoryCount(Integer categoryCount) {
this.categoryCount = categoryCount;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public Integer getRank() {
return rank;
}
public void setRank(Integer rank) {
this.rank = rank;
}
}

View file

@ -0,0 +1,73 @@
package fr.free.nrw.commons.profile.leaderboard;
import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.facebook.drawee.view.SimpleDraweeView;
import fr.free.nrw.commons.R;
import java.util.List;
public class LeaderboardListAdapter extends RecyclerView.Adapter<LeaderboardListAdapter.ListViewHolder> {
private List<LeaderboardList> leaderboardList;
private String avatarSourceURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/%s/1024px-%s.png";
public class ListViewHolder extends RecyclerView.ViewHolder {
TextView rank;
SimpleDraweeView avatar;
TextView username;
TextView count;
public ListViewHolder(View itemView) {
super(itemView);
this.rank = itemView.findViewById(R.id.user_rank);
this.avatar = itemView.findViewById(R.id.user_avatar);
this.username = itemView.findViewById(R.id.user_name);
this.count = itemView.findViewById(R.id.user_count);
}
public Context getContext() {
return itemView.getContext();
}
}
public LeaderboardListAdapter(List<LeaderboardList> leaderboardList) {
this.leaderboardList = leaderboardList;
}
@NonNull
@Override
public LeaderboardListAdapter.ListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.leaderboard_list_element, parent, false);
return new ListViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull LeaderboardListAdapter.ListViewHolder holder, int position) {
TextView rank = holder.rank;
SimpleDraweeView avatar = holder.avatar;
TextView username = holder.username;
TextView count = holder.count;
rank.setText(leaderboardList.get(position).getRank().toString());
avatar.setImageURI(
Uri.parse(String.format(avatarSourceURL, leaderboardList.get(position).getAvatar(),
leaderboardList.get(position).getAvatar())));
username.setText(leaderboardList.get(position).getUsername());
count.setText(leaderboardList.get(position).getCategoryCount().toString());
}
@Override
public int getItemCount() {
return leaderboardList.size();
}
}

View file

@ -0,0 +1,120 @@
package fr.free.nrw.commons.profile.leaderboard;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class LeaderboardResponse {
@SerializedName("status")
@Expose
private Integer status;
@SerializedName("username")
@Expose
private String username;
@SerializedName("category_count")
@Expose
private Integer categoryCount;
@SerializedName("limit")
@Expose
private Object limit;
@SerializedName("avatar")
@Expose
private String avatar;
@SerializedName("offset")
@Expose
private Object offset;
@SerializedName("duration")
@Expose
private String duration;
@SerializedName("leaderboard_list")
@Expose
private List<LeaderboardList> leaderboardList = null;
@SerializedName("category")
@Expose
private String category;
@SerializedName("rank")
@Expose
private Integer rank;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Integer getCategoryCount() {
return categoryCount;
}
public void setCategoryCount(Integer categoryCount) {
this.categoryCount = categoryCount;
}
public Object getLimit() {
return limit;
}
public void setLimit(Object limit) {
this.limit = limit;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public Object getOffset() {
return offset;
}
public void setOffset(Object offset) {
this.offset = offset;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public List<LeaderboardList> getLeaderboardList() {
return leaderboardList;
}
public void setLeaderboardList(List<LeaderboardList> leaderboardList) {
this.leaderboardList = leaderboardList;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public Integer getRank() {
return rank;
}
public void setRank(Integer rank) {
this.rank = rank;
}
}

View file

@ -26,6 +26,7 @@ import androidx.drawerlayout.widget.DrawerLayout;
import com.google.android.material.navigation.NavigationView;
import fr.free.nrw.commons.profile.ProfileActivity;
import org.wikipedia.dataclient.Service;
import javax.inject.Inject;
@ -37,7 +38,6 @@ import fr.free.nrw.commons.BuildConfig;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.WelcomeActivity;
import fr.free.nrw.commons.achievements.AchievementsActivity;
import fr.free.nrw.commons.auth.LoginActivity;
import fr.free.nrw.commons.auth.LogoutClient;
import fr.free.nrw.commons.bookmarks.BookmarksActivity;
@ -140,7 +140,7 @@ public abstract class NavigationBaseActivity extends BaseActivity
LinearLayout userIcon = navHeaderView.findViewById(R.id.user_details);
userIcon.setOnClickListener(v -> {
drawerLayout.closeDrawer(navigationView);
AchievementsActivity.startYourself(NavigationBaseActivity.this);
ProfileActivity.startYourself(NavigationBaseActivity.this);
});
}

View file

@ -1,495 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/toolbarLayout"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize">
<include layout="@layout/toolbar"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:layout_below="@id/toolbarLayout">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/achievementBackground"
android:orientation="vertical">
<TextView
style="?android:textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:text="@string/level"
android:id="@+id/achievement_level"
android:textAllCaps="true"/>
<ImageView
android:id="@+id/achievement_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin_vertical"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/black"
android:layout_marginVertical="@dimen/activity_margin_vertical" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/badge_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/achievement_info"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/achievement_badge_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/badge" />
<TextView
android:id="@+id/achievement_badge_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/achievement_badge_text"
android:textSize="75sp"
app:layout_constraintBottom_toBottomOf="@+id/achievement_badge_image"
app:layout_constraintEnd_toEndOf="@+id/achievement_badge_image"
app:layout_constraintStart_toStartOf="@+id/achievement_badge_image"
app:layout_constraintTop_toTopOf="@+id/achievement_badge_image"
app:layout_constraintVertical_bias="0.58" />
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:id="@+id/layout_image_uploaded"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/badge_layout"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal">
<TextView
style="?android:textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:id="@+id/images_upload_text_param"
android:layout_marginTop="@dimen/achievements_activity_margin_vertical"
android:text="@string/images_uploaded" />
<ImageView
android:layout_width="@dimen/quarter_standard_height"
android:layout_height="@dimen/quarter_standard_height"
android:id="@+id/images_upload_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_toRightOf="@+id/images_upload_text_param"
android:layout_toEndOf="@+id/images_upload_text_param"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"/>
<com.dinuscxj.progressbar.CircleProgressBar
android:layout_width="@dimen/dimen_40"
android:layout_height="@dimen/dimen_40"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/large_gap"
android:layout_marginRight="@dimen/large_gap"
android:id="@+id/images_uploaded_progressbar"
android:progress="50"
app:progress_text_size="@dimen/progressbar_text"
app:progress_end_color="#8C8B98"
app:progress_start_color="#3A3381"
app:progress_stroke_width="@dimen/progressbar_stroke"
app:progress_text_format_pattern="573/110"
app:progress_text_color="@color/secondaryColor"
app:style="solid_line" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_image_reverts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/tiny_margin"
android:layout_below="@+id/layout_image_uploaded"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal">
<TextView
style="?android:textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:id="@+id/images_reverted_text"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:text="@string/image_reverts" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:id="@+id/images_reverted_info"
android:layout_toRightOf="@+id/images_reverted_text"
android:layout_toEndOf="@+id/images_reverted_text"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/achievements_revert_limit_message"
android:textSize="@dimen/small_text"
android:id="@+id/images_revert_limit_text"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_below="@+id/images_reverted_text"/>
<com.dinuscxj.progressbar.CircleProgressBar
android:layout_width="@dimen/dimen_40"
android:layout_height="@dimen/dimen_40"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/large_gap"
android:layout_marginEnd="@dimen/large_gap"
android:progress="50"
android:id="@+id/image_reverts_progressbar"
app:progress_end_color="#8C8B98"
app:progress_start_color="#3A3381"
app:progress_text_size="@dimen/progressbar_text"
app:progress_stroke_width="@dimen/progressbar_stroke"
app:progress_text_format_pattern="92%%"
app:progress_text_color="@color/secondaryColor"
app:style="solid_line" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_image_used_by_wiki"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/tiny_margin"
android:layout_below="@+id/layout_image_reverts"
android:layout_marginBottom="@dimen/activity_margin_vertical"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal">
<TextView
style="?android:textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/images_used_by_wiki_text"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/achievements_activity_margin_vertical"
android:text="@string/images_used_by_wiki" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:id="@+id/images_used_by_wiki_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_toRightOf="@+id/images_used_by_wiki_text"
android:layout_toEndOf="@+id/images_used_by_wiki_text"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"/>
<com.dinuscxj.progressbar.CircleProgressBar
android:layout_width="@dimen/dimen_40"
android:layout_height="@dimen/dimen_40"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/large_gap"
android:layout_marginEnd="@dimen/large_gap"
android:progress="50"
app:progress_text_size="@dimen/progressbar_text"
android:id="@+id/images_used_by_wiki_progress_bar"
app:progress_end_color="#8C8B98"
app:progress_start_color="#3A3381"
app:progress_stroke_width="2.5dp"
app:progress_text_color="@color/secondaryColor"
app:progress_text_format_pattern="12/24"
app:style="solid_line" />
</RelativeLayout>
<ProgressBar
android:id="@+id/progressBar"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_statistics"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/statistics"
style="?android:textAppearanceLarge"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_vertical"
android:textAllCaps="true"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_toStartOf="@+id/wikidata_edits"
android:layout_toLeftOf="@+id/wikidata_edits"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="@dimen/overflow_icon_dimen"
android:layout_height="@dimen/overflow_icon_dimen"
android:id="@+id/wikidata_edits_icon"
app:srcCompat="@drawable/ic_custom_map_marker" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:text="@string/statistics_wikidata_edits" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:id="@+id/images_nearby_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_gravity="top"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/half_standard_height"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_centerVertical="true"
tools:text="2"
android:id="@+id/wikidata_edits"
android:layout_marginRight="@dimen/half_standard_height" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_toStartOf="@+id/image_featured"
android:layout_toLeftOf="@+id/image_featured"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="@dimen/overflow_icon_dimen"
android:layout_height="@dimen/overflow_icon_dimen"
android:id="@+id/featured_image_icon"
app:srcCompat="@drawable/featured"
android:scaleType="centerCrop" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:text="@string/statistics_featured" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:id="@+id/images_featured_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_gravity="top"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_centerVertical="true"
tools:text="2"
android:id="@+id/image_featured"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/half_standard_height"
android:layout_marginRight="@dimen/half_standard_height" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_toStartOf="@+id/thanks_received"
android:layout_toLeftOf="@+id/thanks_received"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="@dimen/overflow_icon_dimen"
android:layout_height="@dimen/overflow_icon_dimen"
android:id="@+id/thanks_image_icon"
app:srcCompat="@drawable/ic_thanks"
android:scaleType="centerCrop" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:text="@string/statistics_thanks" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:id="@+id/thanks_received_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_gravity="top"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_centerVertical="true"
tools:text="2"
android:id="@+id/thanks_received"
android:layout_marginEnd="@dimen/half_standard_height"
android:layout_marginRight="@dimen/half_standard_height" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<include layout="@layout/drawer_view" />
</androidx.drawerlayout.widget.DrawerLayout>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryDarkColor">
<include layout="@layout/toolbar"/>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
android:background="?attr/tabBackground"
app:tabIndicatorColor="?attr/tabIndicatorColor"
app:tabMode="fixed"
app:tabSelectedTextColor="?attr/tabSelectedTextColor"
app:tabTextColor="?attr/tabTextColor" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar_layout" />
</RelativeLayout>
<include layout="@layout/drawer_view" />
</androidx.drawerlayout.widget.DrawerLayout>

View file

@ -0,0 +1,482 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/achievementBackground"
android:orientation="vertical">
<TextView
style="?android:textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:text="@string/level"
android:id="@+id/achievement_level"
android:textAllCaps="true"/>
<ImageView
android:id="@+id/achievement_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin_vertical"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/black"
android:layout_marginVertical="@dimen/activity_margin_vertical" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/badge_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/achievement_info"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/achievement_badge_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/badge" />
<TextView
android:id="@+id/achievement_badge_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/achievement_badge_text"
android:textSize="75sp"
app:layout_constraintBottom_toBottomOf="@+id/achievement_badge_image"
app:layout_constraintEnd_toEndOf="@+id/achievement_badge_image"
app:layout_constraintStart_toStartOf="@+id/achievement_badge_image"
app:layout_constraintTop_toTopOf="@+id/achievement_badge_image"
app:layout_constraintVertical_bias="0.58" />
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:id="@+id/layout_image_uploaded"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/badge_layout"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal">
<TextView
style="?android:textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:id="@+id/images_upload_text_param"
android:layout_marginTop="@dimen/achievements_activity_margin_vertical"
android:text="@string/images_uploaded" />
<ImageView
android:layout_width="@dimen/quarter_standard_height"
android:layout_height="@dimen/quarter_standard_height"
android:id="@+id/images_upload_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_toRightOf="@+id/images_upload_text_param"
android:layout_toEndOf="@+id/images_upload_text_param"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"/>
<com.dinuscxj.progressbar.CircleProgressBar
android:layout_width="@dimen/dimen_40"
android:layout_height="@dimen/dimen_40"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/large_gap"
android:layout_marginRight="@dimen/large_gap"
android:id="@+id/images_uploaded_progressbar"
android:progress="50"
app:progress_text_size="@dimen/progressbar_text"
app:progress_end_color="#8C8B98"
app:progress_start_color="#3A3381"
app:progress_stroke_width="@dimen/progressbar_stroke"
app:progress_text_format_pattern="573/110"
app:progress_text_color="@color/secondaryColor"
app:style="solid_line" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_image_reverts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/tiny_margin"
android:layout_below="@+id/layout_image_uploaded"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal">
<TextView
style="?android:textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:id="@+id/images_reverted_text"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:text="@string/image_reverts" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:id="@+id/images_reverted_info"
android:layout_toRightOf="@+id/images_reverted_text"
android:layout_toEndOf="@+id/images_reverted_text"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/achievements_revert_limit_message"
android:textSize="@dimen/small_text"
android:id="@+id/images_revert_limit_text"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_below="@+id/images_reverted_text"/>
<com.dinuscxj.progressbar.CircleProgressBar
android:layout_width="@dimen/dimen_40"
android:layout_height="@dimen/dimen_40"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/large_gap"
android:layout_marginEnd="@dimen/large_gap"
android:progress="50"
android:id="@+id/image_reverts_progressbar"
app:progress_end_color="#8C8B98"
app:progress_start_color="#3A3381"
app:progress_text_size="@dimen/progressbar_text"
app:progress_stroke_width="@dimen/progressbar_stroke"
app:progress_text_format_pattern="92%%"
app:progress_text_color="@color/secondaryColor"
app:style="solid_line" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_image_used_by_wiki"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/tiny_margin"
android:layout_below="@+id/layout_image_reverts"
android:layout_marginBottom="@dimen/activity_margin_vertical"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal">
<TextView
style="?android:textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/images_used_by_wiki_text"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/achievements_activity_margin_vertical"
android:text="@string/images_used_by_wiki" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:id="@+id/images_used_by_wiki_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_toRightOf="@+id/images_used_by_wiki_text"
android:layout_toEndOf="@+id/images_used_by_wiki_text"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"/>
<com.dinuscxj.progressbar.CircleProgressBar
android:layout_width="@dimen/dimen_40"
android:layout_height="@dimen/dimen_40"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/large_gap"
android:layout_marginEnd="@dimen/large_gap"
android:progress="50"
app:progress_text_size="@dimen/progressbar_text"
android:id="@+id/images_used_by_wiki_progress_bar"
app:progress_end_color="#8C8B98"
app:progress_start_color="#3A3381"
app:progress_stroke_width="2.5dp"
app:progress_text_color="@color/secondaryColor"
app:progress_text_format_pattern="12/24"
app:style="solid_line" />
</RelativeLayout>
<ProgressBar
android:id="@+id/progressBar"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_statistics"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/statistics"
style="?android:textAppearanceLarge"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_vertical"
android:textAllCaps="true"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_toStartOf="@+id/wikidata_edits"
android:layout_toLeftOf="@+id/wikidata_edits"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="@dimen/overflow_icon_dimen"
android:layout_height="@dimen/overflow_icon_dimen"
android:id="@+id/wikidata_edits_icon"
app:srcCompat="@drawable/ic_custom_map_marker" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:text="@string/statistics_wikidata_edits" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:id="@+id/images_nearby_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_gravity="top"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/half_standard_height"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_centerVertical="true"
tools:text="2"
android:id="@+id/wikidata_edits"
android:layout_marginRight="@dimen/half_standard_height" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_toStartOf="@+id/image_featured"
android:layout_toLeftOf="@+id/image_featured"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="@dimen/overflow_icon_dimen"
android:layout_height="@dimen/overflow_icon_dimen"
android:id="@+id/featured_image_icon"
app:srcCompat="@drawable/featured"
android:scaleType="centerCrop" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:text="@string/statistics_featured" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:id="@+id/images_featured_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_gravity="top"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_centerVertical="true"
tools:text="2"
android:id="@+id/image_featured"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/half_standard_height"
android:layout_marginRight="@dimen/half_standard_height" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_toStartOf="@+id/thanks_received"
android:layout_toLeftOf="@+id/thanks_received"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="@dimen/overflow_icon_dimen"
android:layout_height="@dimen/overflow_icon_dimen"
android:id="@+id/thanks_image_icon"
app:srcCompat="@drawable/ic_thanks"
android:scaleType="centerCrop" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:text="@string/statistics_thanks" />
<ImageView
android:layout_width="@dimen/medium_width"
android:layout_height="@dimen/medium_height"
android:id="@+id/thanks_received_info"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginRight="@dimen/activity_margin_horizontal"
android:layout_marginEnd="@dimen/activity_margin_horizontal"
android:layout_gravity="top"
app:srcCompat="@drawable/ic_info_outline_24dp"
android:tint="@color/primaryDarkColor" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:textAppearanceMedium"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/activity_margin_horizontal"
android:layout_marginStart="@dimen/activity_margin_horizontal"
android:layout_marginLeft="@dimen/activity_margin_horizontal"
android:layout_centerVertical="true"
tools:text="2"
android:id="@+id/thanks_received"
android:layout_marginEnd="@dimen/half_standard_height"
android:layout_marginRight="@dimen/half_standard_height" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<include layout="@layout/drawer_view" />
</androidx.drawerlayout.widget.DrawerLayout>

View file

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/avatar"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="20dp"
fresco:roundAsCircle="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
style="?android:textAppearanceMedium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/avatar" />
<TextView
android:id="@+id/rank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
style="?android:textAppearanceMedium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/username" />
<TextView
android:id="@+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
style="?android:textAppearanceMedium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rank" />
<LinearLayout
android:id="@+id/column_names"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="15dp"
android:weightSum="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/count">
<TextView
style="?android:textAppearanceButton"
android:gravity="center_vertical|start"
android:layout_width="0dp"
android:layout_weight="0.2"
android:text="@string/leaderboard_column_rank"
android:layout_height="match_parent"/>
<TextView
style="?android:textAppearanceButton"
android:gravity="center_vertical|start"
android:layout_width="0dp"
android:layout_weight="0.6"
android:text="@string/leaderboard_column_user"
android:layout_height="match_parent"/>
<TextView
style="?android:textAppearanceButton"
android:gravity="center_vertical|end"
android:layout_width="0dp"
android:layout_weight="0.2"
android:text="@string/leaderboard_column_count"
android:layout_height="match_parent"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/leaderboard_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/column_names" />
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:weightSum="1">
<TextView
android:id="@+id/user_rank"
style="?android:textAppearanceMedium"
android:gravity="center_vertical|center_horizontal"
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="match_parent"/>
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/user_avatar"
android:layout_weight="0.1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
fresco:roundAsCircle="true"
fresco:viewAspectRatio="1"
android:gravity="center_vertical|start"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/user_name"
style="?android:textAppearanceMedium"
android:gravity="center_vertical|start"
android:layout_width="0dp"
android:layout_weight="0.6"
android:layout_height="match_parent"/>
<TextView
android:id="@+id/user_count"
style="?android:textAppearanceSmall"
android:gravity="center_vertical|end"
android:layout_width="0dp"
android:layout_weight="0.2"
android:layout_height="match_parent"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -399,6 +399,7 @@
<string name="nominate_delete">Nominate For Deletion</string>
<string name="delete">Delete</string>
<string name="Achievements">Achievements</string>
<string name="Profile">Profile</string>
<string name="statistics">Statistics</string>
<string name="statistics_thanks">Thanks Received</string>
<string name="statistics_featured">Featured Images</string>
@ -635,7 +636,6 @@ Upload your first media by tapping on the add button.</string>
<string name="use_location_from_similar_image">Did you shoot these two pictures at the same place? Do you want to use the latitude/longitude of the picture on the right?</string>
<string name="load_more">Load More</string>
<string name="nearby_no_results">No places found, try changing your search criteria.</string>
<string name="add_picture_to_wikipedia_article_title">Add image to Wikipedia</string>
<string name="add_picture_to_wikipedia_article_desc">Do you want to add this picture to the %1$s language Wikipedia article?</string>
@ -654,4 +654,12 @@ Upload your first media by tapping on the add button.</string>
<string name="pause">pause</string>
<string name="resume">resume</string>
<string name="paused">Paused</string>
<string name="achievements_tab_title">Achievements</string>
<string name="leaderboard_tab_title">Leaderboard</string>
<string name="rank_prefix">Rank:</string>
<string name="count_prefix">Count:</string>
<string name="leaderboard_column_rank">Rank</string>
<string name="leaderboard_column_user">User</string>
<string name="leaderboard_column_count">Count</string>
</resources>

View file

@ -3,9 +3,9 @@ package fr.free.nrw.commons.delete
import android.content.Context
import android.content.res.Resources
import fr.free.nrw.commons.Media
import fr.free.nrw.commons.achievements.FeedbackResponse
import fr.free.nrw.commons.auth.SessionManager
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
import fr.free.nrw.commons.profile.achievements.FeedbackResponse
import fr.free.nrw.commons.utils.ViewUtilWrapper
import io.reactivex.Single
import media