mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Arman Navodia
						Arman Navodia