mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* fixed Leaderboard: Taping on my avatar should open tip popup explaining how to change it #4774 * fixed Leaderboard: Taping on my avatar should open tip popup explaining how to change it #4774 * Leaderboard: Taping on my avatar should open tip popup explaining how to change it #4774 * fixed Leaderboard: Taping on my avatar should open tip popup explaining how to change it #4775
This commit is contained in:
parent
e4e13587d0
commit
b917fe3229
2 changed files with 34 additions and 0 deletions
|
|
@ -1,16 +1,22 @@
|
|||
package fr.free.nrw.commons.profile.leaderboard;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
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 android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.internal.DebouncingOnClickListener;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
import fr.free.nrw.commons.R;
|
||||
|
||||
|
||||
/**
|
||||
* This class extends RecyclerView.Adapter and creates the UserDetail section of the leaderboard
|
||||
*/
|
||||
|
|
@ -18,6 +24,11 @@ public class UserDetailAdapter extends RecyclerView.Adapter<UserDetailAdapter.Da
|
|||
|
||||
private LeaderboardResponse leaderboardResponse;
|
||||
|
||||
/**
|
||||
* Stores the username of currently logged in user.
|
||||
*/
|
||||
private String currentlyLoggedInUserName = null;
|
||||
|
||||
public UserDetailAdapter(LeaderboardResponse leaderboardResponse) {
|
||||
this.leaderboardResponse = leaderboardResponse;
|
||||
}
|
||||
|
|
@ -84,6 +95,28 @@ public class UserDetailAdapter extends RecyclerView.Adapter<UserDetailAdapter.Da
|
|||
holder.getContext().getResources().getString(R.string.count_prefix),
|
||||
leaderboardResponse.getCategoryCount()));
|
||||
|
||||
// When user tap on avatar shows the toast on how to change avatar
|
||||
// fixing: https://github.com/commons-app/apps-android-commons/issues/47747
|
||||
if (currentlyLoggedInUserName == null) {
|
||||
// If the current login username has not been fetched yet, then fetch it.
|
||||
final AccountManager accountManager = AccountManager.get(username.getContext());
|
||||
final Account[] allAccounts = accountManager.getAccountsByType(
|
||||
BuildConfig.ACCOUNT_TYPE);
|
||||
if (allAccounts.length != 0) {
|
||||
currentlyLoggedInUserName = allAccounts[0].name;
|
||||
}
|
||||
}
|
||||
if (currentlyLoggedInUserName != null && currentlyLoggedInUserName.equals(
|
||||
leaderboardResponse.getUsername())) {
|
||||
avatar.setOnClickListener(new DebouncingOnClickListener() {
|
||||
@Override
|
||||
public void doClick(View v) {
|
||||
Toast.makeText(v.getContext(),
|
||||
R.string.set_up_avatar_toast_string,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -749,4 +749,5 @@ Upload your first media by tapping on the add button.</string>
|
|||
<string name="welcome_to_full_screen_mode_text">Welcome to Full-Screen Selection Mode</string>
|
||||
<string name="full_screen_mode_zoom_info">Use two fingers to zoom in and out.</string>
|
||||
<string name="full_screen_mode_features_info">Swipe fast and long to perform these actions: \n- Left/Right: Go to previous/next \n- Up: Select\n- Down: Mark as not for upload.</string>
|
||||
<string name="set_up_avatar_toast_string">To set up your leaderboard avatar, tap \"Set as avatar\" in the three-dots menu of any image.</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue