Avoid useless posts reloading on LatestPostsFragment pauses

This commit is contained in:
Pierre HUBERT 2018-08-23 13:53:12 +02:00
parent 686379b015
commit 6dda9c3753
9 changed files with 409 additions and 216 deletions

View File

@ -1,21 +1,22 @@
package org.communiquons.android.comunic.client.ui.adapters;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import org.communiquons.android.comunic.client.R;
import org.communiquons.android.comunic.client.data.helpers.ImageLoadHelper;
import org.communiquons.android.comunic.client.data.models.Friend;
import org.communiquons.android.comunic.client.data.models.FriendUser;
import org.communiquons.android.comunic.client.data.utils.Utilities;
import org.communiquons.android.comunic.client.ui.fragments.FriendsListFragment;
import org.communiquons.android.comunic.client.data.models.UserInfo;
import org.communiquons.android.comunic.client.ui.listeners.OnFriendListActionListener;
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage;
import java.util.ArrayList;
@ -26,100 +27,188 @@ import java.util.ArrayList;
* Created by pierre on 11/15/17.
*/
public class FriendsAdapter extends ArrayAdapter<FriendUser> {
public class FriendsAdapter extends BaseRecyclerViewAdapter {
/**
* The fragment creating the adapter
* View type
*/
private FriendsListFragment mFLfragment;
private static final int VIEW_TYPE_ACCEPTED_FRIEND = 1;
private static final int VIEW_TYPE_PENDING_FRIEND = 2;
/**
* The list of friends, with their information
*/
private ArrayList<FriendUser> mList;
/**
* Actions listener
*/
private OnFriendListActionListener mListener;
/**
* Class constructor
*
* @param friendsListFragment Friends list fragment object
* @param context The context of execution of the application
* @param friendsList The list of friends to display (with user information)
* @param listener Actions on friendlist listener
*/
public FriendsAdapter(FriendsListFragment friendsListFragment,
Activity context, ArrayList<FriendUser> friendsList){
super(context, 0, friendsList);
mFLfragment = friendsListFragment;
public FriendsAdapter(Context context, ArrayList<FriendUser> friendsList,
OnFriendListActionListener listener){
super(context);
mList = friendsList;
mListener = listener;
}
@Override
public int getItemCount() {
return mList.size();
}
@Override
public int getItemViewType(int position) {
return mList.get(position).getFriend().isAccepted() ? VIEW_TYPE_ACCEPTED_FRIEND :
VIEW_TYPE_PENDING_FRIEND;
}
@NonNull
@Override
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View listItemView = convertView;
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int type) {
View view;
//Check if the view has to be created
if(listItemView == null){
listItemView = LayoutInflater.from(getContext())
.inflate(R.layout.fragment_friends_list_friend_item, parent, false);
if(type == VIEW_TYPE_ACCEPTED_FRIEND){
view = LayoutInflater.from(getContext()).inflate(R.layout.friend_accepted_item,
viewGroup, false);
return new AcceptedFriendHolder(view);
}
//Get friend information
FriendUser friendUser = getItem(position);
if(type == VIEW_TYPE_PENDING_FRIEND){
view = LayoutInflater.from(getContext()).inflate(R.layout.friend_pending_item,
viewGroup, false);
return new PendingFriendHolder(view);
}
//Update user account image
ImageView user_image = listItemView.findViewById(R.id.fragment_friendslist_item_accountimage);
user_image.setImageDrawable(getContext().getDrawable(R.drawable.default_account_image));
ImageLoadHelper.load(getContext(), friendUser.getUserInfo().getAcountImageURL(), user_image);
throw new RuntimeException("Undefined view type: " + type);
}
//Update user name
TextView user_name = listItemView.findViewById(R.id.fragment_friendslist_item_fullname);
user_name.setText(Utilities.prepareStringTextView(friendUser.getUserInfo().getFullName()));
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int pos) {
((BaseFriendHolder)viewHolder).bind(pos);
}
/**
* Base Friend ViewHolder
*/
private class BaseFriendHolder extends RecyclerView.ViewHolder {
private WebUserAccountImage mUserAccountImage;
private TextView mUserName;
private TextView mUserStatus;
BaseFriendHolder(@NonNull View itemView) {
super(itemView);
mUserAccountImage = itemView.findViewById(R.id.account_image);
mUserName = itemView.findViewById(R.id.account_name);
mUserStatus = itemView.findViewById(R.id.user_status);
}
Friend getFriend(int pos){
return mList.get(pos).getFriend();
}
UserInfo getUserInfo(int pos){
return mList.get(pos).getUserInfo();
}
int getCurrentUserID(){
return getUserInfo(getLayoutPosition()).getId();
}
@CallSuper
void bind(int pos){
//Update user information
mUserAccountImage.setUser(getUserInfo(pos));
mUserName.setText(getUserInfo(pos).getDisplayFullName());
//Update user status
boolean signed_in = friendUser.getFriend().signed_in();
TextView statusView = listItemView.findViewById(R.id.fragment_friendslist_item_status);
boolean signed_in = getFriend(pos).signed_in();
mUserStatus.setText(UiUtils.getString(getContext(), signed_in ?
R.string.user_status_online : R.string.user_status_offline));
mUserStatus.setTextColor(UiUtils.getColor(getContext(),
signed_in ? R.color.holo_green_dark : R.color.darker_gray));
//Set the text
statusView.setText(signed_in ?
getContext().getText(R.string.user_status_online) :
getContext().getText(R.string.user_status_offline)
);
//Set the color
int status_color;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
status_color = getContext().getResources().getColor(signed_in ? R.color.holo_green_dark : R.color.darker_gray, null);
//Open user page on click
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onOpenUserPage(getCurrentUserID());
}
});
}
else {
status_color = getContext().getResources().getColor(signed_in ? R.color.holo_green_dark : R.color.darker_gray);
}
statusView.setTextColor(status_color);
//Action button
Button action = listItemView.findViewById(R.id.fragment_friendslist_item_action);
//Define the action of the accept request button
if(!friendUser.getFriend().isAccepted()){
/**
* Accepted friend holder
*/
private class AcceptedFriendHolder extends BaseFriendHolder implements View.OnLongClickListener {
//Update the button
action.setVisibility(View.VISIBLE);
action.setText(R.string.action_friends_respond_request);
AcceptedFriendHolder(@NonNull View itemView) {
super(itemView);
itemView.setOnLongClickListener(this);
}
@Override
public boolean onLongClick(View v) {
if(!v.equals(itemView))
return false;
mListener.onOpenContextMenuForFriend(itemView, getLayoutPosition());
return true;
}
}
/**
* Pending friend view holder
*/
private class PendingFriendHolder extends BaseFriendHolder implements View.OnClickListener {
private Button mAcceptButton;
private Button mRejectButton;
PendingFriendHolder(@NonNull View itemView) {
super(itemView);
mAcceptButton = itemView.findViewById(R.id.accept_button);
mRejectButton = itemView.findViewById(R.id.reject_button);
mAcceptButton.setOnClickListener(this);
mRejectButton.setOnClickListener(this);
}
@Override
void bind(int pos) {
super.bind(pos);
mAcceptButton.setVisibility(View.VISIBLE);
mRejectButton.setVisibility(View.VISIBLE);
}
//Make the button lives
action.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Hide the view
v.setVisibility(View.GONE);
mAcceptButton.setVisibility(View.INVISIBLE);
mRejectButton.setVisibility(View.INVISIBLE);
mFLfragment.showPopupRequestResponse(position);
boolean accept = v.equals(mAcceptButton);
mListener.onRespondFrienshipRequest(getLayoutPosition(), accept);
}
});
}
else {
//Remove button actions and hide it
action.setVisibility(View.GONE);
action.setOnClickListener(null);
}
return listItemView;
}
}

View File

@ -1,37 +1,39 @@
package org.communiquons.android.comunic.client.ui.fragments;
import android.app.AlertDialog;
import android.support.v4.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.util.ArrayMap;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import org.communiquons.android.comunic.client.ui.activities.MainActivity;
import org.communiquons.android.comunic.client.R;
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
import org.communiquons.android.comunic.client.data.helpers.FriendsListHelper;
import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper;
import org.communiquons.android.comunic.client.data.models.UserInfo;
import org.communiquons.android.comunic.client.data.models.Friend;
import org.communiquons.android.comunic.client.data.models.FriendUser;
import org.communiquons.android.comunic.client.ui.adapters.FriendsAdapter;
import org.communiquons.android.comunic.client.data.helpers.FriendsListHelper;
import org.communiquons.android.comunic.client.data.models.UserInfo;
import org.communiquons.android.comunic.client.data.utils.FriendsUtils;
import org.communiquons.android.comunic.client.ui.activities.MainActivity;
import org.communiquons.android.comunic.client.ui.adapters.FriendsAdapter;
import org.communiquons.android.comunic.client.ui.listeners.OnFriendListActionListener;
import org.communiquons.android.comunic.client.ui.listeners.onOpenUsersPageListener;
import org.communiquons.android.comunic.client.ui.listeners.openConversationListener;
import org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView;
import java.util.ArrayList;
@ -42,8 +44,8 @@ import java.util.ArrayList;
* Created by pierre on 11/11/17.
*/
public class FriendsListFragment extends Fragment
implements AdapterView.OnItemClickListener{
public class FriendsListFragment extends Fragment implements OnFriendListActionListener,
PopupMenu.OnMenuItemClickListener {
/**
* Debug tag
@ -103,7 +105,12 @@ public class FriendsListFragment extends Fragment
/**
* Friends list view
*/
private ListView mFriendsListView;
private ScrollRecyclerView mFriendsList;
/**
* Current friend on context menu
*/
private int mPosInContextMenu;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@ -125,7 +132,7 @@ public class FriendsListFragment extends Fragment
try {
convOpener = (openConversationListener) getActivity();
usersPageOpener = (onOpenUsersPageListener) getActivity();
} catch (ClassCastException e){
} catch (ClassCastException e) {
e.printStackTrace();
throw new RuntimeException(getActivity().getClass().getName() + " must implement" +
@ -136,13 +143,13 @@ public class FriendsListFragment extends Fragment
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_friendslist, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//Get loading progress bar
@ -152,8 +159,8 @@ public class FriendsListFragment extends Fragment
mNoFriendNotice = view.findViewById(R.id.no_friend_notice);
mNoFriendNotice.setVisibility(View.GONE);
//Get friends listview
mFriendsListView = view.findViewById(R.id.fragment_friendslist_listview);
//Get friends RecyclerView
mFriendsList = view.findViewById(R.id.friendslist);
//Retain the fragment
//setRetainInstance(true);
@ -175,12 +182,12 @@ public class FriendsListFragment extends Fragment
/**
* Refresh the friend list
*/
void refresh_friend_list(){
void refresh_friend_list() {
//Display loading bar
display_progress_bar(true);
new AsyncTask<Void, Void, ArrayList<FriendUser>>(){
new AsyncTask<Void, Void, ArrayList<FriendUser>>() {
@Override
protected ArrayList<FriendUser> doInBackground(Void... params) {
@ -189,15 +196,15 @@ public class FriendsListFragment extends Fragment
ArrayList<Friend> friendsList = flistHelper.get();
//Check for errors
if(friendsList == null)
if (friendsList == null)
return null;
//Get user infos
//Get user info
ArrayMap<Integer, UserInfo> userInfos = usersHelper.getMultiple(
FriendsUtils.getFriendsIDs(friendsList));
//Check for errors
if(userInfos == null)
if (userInfos == null)
return null;
//Merge friend and user and return result
@ -209,7 +216,7 @@ public class FriendsListFragment extends Fragment
protected void onPostExecute(ArrayList<FriendUser> friendUsers) {
//Check the activity still exists
if(getActivity() == null)
if (getActivity() == null)
return;
apply_friends_list(friendUsers);
@ -222,13 +229,13 @@ public class FriendsListFragment extends Fragment
*
* @param friendsList The friends list to apply
*/
private void apply_friends_list(@Nullable ArrayList<FriendUser> friendsList){
private void apply_friends_list(@Nullable ArrayList<FriendUser> friendsList) {
//Remove progress bar
display_progress_bar(false);
//Check for errors
if(friendsList == null){
if (friendsList == null) {
Toast.makeText(mContext, R.string.fragment_friendslist_err_refresh,
Toast.LENGTH_LONG).show();
return;
@ -241,47 +248,15 @@ public class FriendsListFragment extends Fragment
updateNoFriendNoticeVisibility();
//Set the adapter
fAdapter = new FriendsAdapter(this, getActivity(), friendsList);
mFriendsListView.setAdapter(fAdapter);
fAdapter = new FriendsAdapter(getActivity(), friendsList, this);
mFriendsList.setLayoutManager(new LinearLayoutManager(getActivity()));
mFriendsList.addItemDecoration(new DividerItemDecoration(mFriendsList.getContext(),
DividerItemDecoration.VERTICAL));
mFriendsList.setAdapter(fAdapter);
//Register the view for the context menu
registerForContextMenu(mFriendsListView);
registerForContextMenu(mFriendsList);
mFriendsListView.setOnItemClickListener(this);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.menu_fragment_friendslist_item, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info =
(AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
//Get the friend position in the list
int friendPos = info.position;
switch (item.getItemId()){
//To open a private conversation with the friend
case R.id.menu_fragment_friendslist_private_conversation:
convOpener.openPrivateConversation(friendsList.get(friendPos).getFriend().getId());
return true;
//To delete the friend
case R.id.menu_fragment_friendslist_delete_friend:
delete_friend(friendPos);
return true;
}
//If it is not for us, it is for someone else
return super.onContextItemSelected(item);
}
/**
@ -289,7 +264,7 @@ public class FriendsListFragment extends Fragment
*
* @param pos the position of the friend to delete
*/
private void delete_friend(final int pos){
private void delete_friend(final int pos) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.popup_deletefriend_title)
@ -307,7 +282,7 @@ public class FriendsListFragment extends Fragment
fAdapter.notifyDataSetChanged();
//Remove the friend list on a parallel thread
new AsyncTask<Integer, Void, Void>(){
new AsyncTask<Integer, Void, Void>() {
@Override
protected Void doInBackground(Integer[] params) {
@ -325,48 +300,19 @@ public class FriendsListFragment extends Fragment
}
/**
* Show a popup to offer the user to respond to a friendship request
*
* @param pos The position of the friend in the list
*/
public void showPopupRequestResponse(final int pos){
new AlertDialog.Builder(getActivity())
.setTitle(R.string.popup_respond_friendship_request_title)
.setMessage(R.string.popup_respond_friendship_request_message)
.setNegativeButton(R.string.action_friends_deny_request, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
respondRequest(pos, false);
public void onOpenUserPage(int userID) {
usersPageOpener.openUserPage(userID);
}
})
.setPositiveButton(R.string.action_friends_accept_request, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
respondRequest(pos, true);
}
})
.show();
}
/**
* Respond to a friendship request
*
* @param pos The position of the friend respond the request
* @param accept Specify wether the user accepted the request or not
*/
private void respondRequest(int pos, final boolean accept){
public void onRespondFrienshipRequest(int pos, final boolean response) {
//Get the Friend object
Friend targetFriend = friendsList.get(pos).getFriend();
if(accept)
if (response)
//Mark the friend as accepted
targetFriend.setAccepted(true);
else
@ -377,13 +323,47 @@ public class FriendsListFragment extends Fragment
fAdapter.notifyDataSetChanged();
//Accept the request on a separate thread
new AsyncTask<Friend, Void, Void>(){
new AsyncTask<Friend, Void, Void>() {
@Override
protected Void doInBackground(Friend... params) {
flistHelper.respondRequest(params[0], accept);
flistHelper.respondRequest(params[0], response);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, targetFriend);
}
@Override
public void onOpenContextMenuForFriend(View view, int pos) {
//Save selected position
mPosInContextMenu = pos;
//Initialize and show menu
PopupMenu menu = new PopupMenu(getActivity(), view);
menu.inflate(R.menu.menu_fragment_friendslist_item);
menu.setOnMenuItemClickListener(this);
menu.show();
}
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
//To open a private conversation with the friend
case R.id.menu_fragment_friendslist_private_conversation:
convOpener.openPrivateConversation(friendsList.get(mPosInContextMenu).getFriend().getId());
return true;
//To delete the friend
case R.id.menu_fragment_friendslist_delete_friend:
delete_friend(mPosInContextMenu);
return true;
}
return false;
}
/**
@ -391,25 +371,15 @@ public class FriendsListFragment extends Fragment
*
* @param display Specify whether the loading bar has to be shown or not
*/
private void display_progress_bar(boolean display){
private void display_progress_bar(boolean display) {
mProgressBar.setVisibility(display ? View.VISIBLE : View.GONE);
}
/**
* Update the visibility of the no friend notice
*/
private void updateNoFriendNoticeVisibility(){
if(friendsList != null)
private void updateNoFriendNoticeVisibility() {
if (friendsList != null)
mNoFriendNotice.setVisibility(friendsList.size() == 0 ? View.VISIBLE : View.GONE);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//Get clicked user ID
int userID = friendsList.get(position).get_user_id();
//Open user page
usersPageOpener.openUserPage(userID);
}
}

View File

@ -0,0 +1,33 @@
package org.communiquons.android.comunic.client.ui.listeners;
import android.view.View;
/**
* Friends action listener
*
* @author Pierre HUBERT
*/
public interface OnFriendListActionListener {
/**
* Open a user page
*
* @param userID The ID of the user page to open
*/
void onOpenUserPage(int userID);
/**
* Respond to a friendship request
*
* @param pos Position of the friend on the list
* @param response TRUE to accept / FALSE else
*/
void onRespondFrienshipRequest(int pos, boolean response);
/**
* Open the context menu for a friend
*
* @param pos The position of the friend in the list
*/
void onOpenContextMenuForFriend(View view, int pos);
}

View File

@ -19,8 +19,8 @@
android:textAlignment="center"
android:layout_marginTop="50dp"/>
<ListView
android:id="@+id/fragment_friendslist_listview"
<org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView
android:id="@+id/friendslist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"

View File

@ -1,14 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingEnd="8dp"
android:paddingStart="8dp">
android:paddingStart="8dp"
android:paddingTop="8dp"
android:clickable="true"
android:focusable="true"
android:background="?selectableItemBackground">
<ImageView
android:id="@+id/fragment_friendslist_item_accountimage"
<org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
android:id="@+id/account_image"
android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height"
android:layout_gravity="center"
@ -19,20 +24,26 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:orientation="vertical"
android:paddingEnd="4dp"
android:paddingStart="8dp">
android:paddingStart="8dp"
app:layout_constraintBottom_toBottomOf="@+id/account_image"
app:layout_constraintStart_toEndOf="@+id/account_image"
app:layout_constraintTop_toTopOf="@+id/account_image">
<TextView
android:id="@+id/fragment_friendslist_item_fullname"
android:id="@+id/account_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
tools:text="Full user name" />
<TextView
android:id="@+id/fragment_friendslist_item_status"
android:id="@+id/user_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_status_offline"
@ -41,12 +52,5 @@
</LinearLayout>
<!-- Action button on user -->
<Button
android:id="@+id/fragment_friendslist_item_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:text="Action" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingEnd="8dp"
android:paddingStart="8dp"
android:paddingTop="8dp"
android:clickable="true"
android:focusable="true"
android:background="?selectableItemBackground">
<org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
android:id="@+id/account_image"
android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height"
android:layout_gravity="center"
android:contentDescription="@string/user_image_description"
android:src="@drawable/default_account_image" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:orientation="vertical"
android:paddingEnd="4dp"
android:paddingStart="8dp"
app:layout_constraintBottom_toBottomOf="@+id/account_image"
app:layout_constraintStart_toEndOf="@+id/account_image"
app:layout_constraintTop_toTopOf="@+id/account_image">
<TextView
android:id="@+id/account_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
tools:text="Full user name" />
<TextView
android:id="@+id/user_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_status_offline"
android:textColor="@android:color/holo_green_dark"
tools:text="Online" />
</LinearLayout>
<Button
android:id="@+id/reject_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:backgroundTint="@color/holo_red_dark"
android:text="@string/action_reject_friend_request"
android:textColor="@android:color/white"
app:layout_constraintBottom_toBottomOf="@+id/accept_button"
app:layout_constraintEnd_toStartOf="@+id/accept_button"
app:layout_constraintTop_toTopOf="@+id/accept_button" />
<Button
android:id="@+id/accept_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:backgroundTint="@color/holo_green_dark"
android:text="@string/action_friends_accept_request"
android:textColor="@android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/account_image" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:text="@string/notice_request"
app:layout_constraintBottom_toBottomOf="@+id/reject_button"
app:layout_constraintEnd_toStartOf="@+id/reject_button"
app:layout_constraintTop_toTopOf="@+id/reject_button" />
</android.support.constraint.ConstraintLayout>

View File

@ -238,4 +238,6 @@
<string name="err_create_account_too_many_requests">Trop de création de compte. Veuillez réessayer ultérieurement.</string>
<string name="action_more">Plus</string>
<string name="action_about">A propos</string>
<string name="action_reject_friend_request">Rejeter</string>
<string name="notice_request">Demande</string>
</resources>

View File

@ -8,6 +8,7 @@
<color name="darker_gray">#aaa</color>
<color name="darker_darker_gray">#5b5b5b</color>
<color name="dark_blue">#303f9f</color>
<color name="holo_red_dark">#ffcc0000</color>
<color name="default_drawable_color">#000000</color>

View File

@ -240,4 +240,6 @@
<string name="activity_about_title">About</string>
<string name="dialog_open_source_licenses_title">Open Source Licenses</string>
<string name="btn_open_source_licences">Open Source Licences</string>
<string name="action_reject_friend_request">Reject</string>
<string name="notice_request">Requested</string>
</resources>