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; 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.NonNull;
import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import org.communiquons.android.comunic.client.R; 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.models.FriendUser;
import org.communiquons.android.comunic.client.data.utils.Utilities; import org.communiquons.android.comunic.client.data.models.UserInfo;
import org.communiquons.android.comunic.client.ui.fragments.FriendsListFragment; 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; import java.util.ArrayList;
@ -26,100 +27,188 @@ import java.util.ArrayList;
* Created by pierre on 11/15/17. * 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 * Class constructor
* *
* @param friendsListFragment Friends list fragment object
* @param context The context of execution of the application * @param context The context of execution of the application
* @param friendsList The list of friends to display (with user information) * @param friendsList The list of friends to display (with user information)
* @param listener Actions on friendlist listener
*/ */
public FriendsAdapter(FriendsListFragment friendsListFragment, public FriendsAdapter(Context context, ArrayList<FriendUser> friendsList,
Activity context, ArrayList<FriendUser> friendsList){ OnFriendListActionListener listener){
super(context, 0, friendsList); super(context);
mFLfragment = friendsListFragment;
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 @NonNull
@Override @Override
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int type) {
View listItemView = convertView; View view;
//Check if the view has to be created if(type == VIEW_TYPE_ACCEPTED_FRIEND){
if(listItemView == null){ view = LayoutInflater.from(getContext()).inflate(R.layout.friend_accepted_item,
listItemView = LayoutInflater.from(getContext()) viewGroup, false);
.inflate(R.layout.fragment_friends_list_friend_item, parent, false); return new AcceptedFriendHolder(view);
} }
//Get friend information if(type == VIEW_TYPE_PENDING_FRIEND){
FriendUser friendUser = getItem(position); view = LayoutInflater.from(getContext()).inflate(R.layout.friend_pending_item,
viewGroup, false);
return new PendingFriendHolder(view);
}
//Update user account image throw new RuntimeException("Undefined view type: " + type);
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);
//Update user name @Override
TextView user_name = listItemView.findViewById(R.id.fragment_friendslist_item_fullname); public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int pos) {
user_name.setText(Utilities.prepareStringTextView(friendUser.getUserInfo().getFullName())); ((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 //Update user status
boolean signed_in = friendUser.getFriend().signed_in(); boolean signed_in = getFriend(pos).signed_in();
TextView statusView = listItemView.findViewById(R.id.fragment_friendslist_item_status); 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 //Open user page on click
int status_color; itemView.setOnClickListener(new View.OnClickListener() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { @Override
status_color = getContext().getResources().getColor(signed_in ? R.color.holo_green_dark : R.color.darker_gray, null); 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 AcceptedFriendHolder(@NonNull View itemView) {
action.setVisibility(View.VISIBLE); super(itemView);
action.setText(R.string.action_friends_respond_request);
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 @Override
public void onClick(View v) { public void onClick(View v) {
//Hide the view mAcceptButton.setVisibility(View.INVISIBLE);
v.setVisibility(View.GONE); 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; package org.communiquons.android.comunic.client.ui.fragments;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.support.v4.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; 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.util.ArrayMap;
import android.view.ContextMenu;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.PopupMenu;
import android.widget.ListView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; 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.R;
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper; 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.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.Friend;
import org.communiquons.android.comunic.client.data.models.FriendUser; 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.models.UserInfo;
import org.communiquons.android.comunic.client.data.helpers.FriendsListHelper;
import org.communiquons.android.comunic.client.data.utils.FriendsUtils; 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.onOpenUsersPageListener;
import org.communiquons.android.comunic.client.ui.listeners.openConversationListener; import org.communiquons.android.comunic.client.ui.listeners.openConversationListener;
import org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,8 +44,8 @@ import java.util.ArrayList;
* Created by pierre on 11/11/17. * Created by pierre on 11/11/17.
*/ */
public class FriendsListFragment extends Fragment public class FriendsListFragment extends Fragment implements OnFriendListActionListener,
implements AdapterView.OnItemClickListener{ PopupMenu.OnMenuItemClickListener {
/** /**
* Debug tag * Debug tag
@ -103,7 +105,12 @@ public class FriendsListFragment extends Fragment
/** /**
* Friends list view * Friends list view
*/ */
private ListView mFriendsListView; private ScrollRecyclerView mFriendsList;
/**
* Current friend on context menu
*/
private int mPosInContextMenu;
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
@ -136,13 +143,13 @@ public class FriendsListFragment extends Fragment
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_friendslist, container, false); return inflater.inflate(R.layout.fragment_friendslist, container, false);
} }
@Override @Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
//Get loading progress bar //Get loading progress bar
@ -152,8 +159,8 @@ public class FriendsListFragment extends Fragment
mNoFriendNotice = view.findViewById(R.id.no_friend_notice); mNoFriendNotice = view.findViewById(R.id.no_friend_notice);
mNoFriendNotice.setVisibility(View.GONE); mNoFriendNotice.setVisibility(View.GONE);
//Get friends listview //Get friends RecyclerView
mFriendsListView = view.findViewById(R.id.fragment_friendslist_listview); mFriendsList = view.findViewById(R.id.friendslist);
//Retain the fragment //Retain the fragment
//setRetainInstance(true); //setRetainInstance(true);
@ -192,7 +199,7 @@ public class FriendsListFragment extends Fragment
if (friendsList == null) if (friendsList == null)
return null; return null;
//Get user infos //Get user info
ArrayMap<Integer, UserInfo> userInfos = usersHelper.getMultiple( ArrayMap<Integer, UserInfo> userInfos = usersHelper.getMultiple(
FriendsUtils.getFriendsIDs(friendsList)); FriendsUtils.getFriendsIDs(friendsList));
@ -241,47 +248,15 @@ public class FriendsListFragment extends Fragment
updateNoFriendNoticeVisibility(); updateNoFriendNoticeVisibility();
//Set the adapter //Set the adapter
fAdapter = new FriendsAdapter(this, getActivity(), friendsList); fAdapter = new FriendsAdapter(getActivity(), friendsList, this);
mFriendsListView.setAdapter(fAdapter); mFriendsList.setLayoutManager(new LinearLayoutManager(getActivity()));
mFriendsList.addItemDecoration(new DividerItemDecoration(mFriendsList.getContext(),
DividerItemDecoration.VERTICAL));
mFriendsList.setAdapter(fAdapter);
//Register the view for the context menu //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);
} }
/** /**
@ -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 @Override
public void onClick(DialogInterface dialog, int which) { public void onOpenUserPage(int userID) {
respondRequest(pos, false); usersPageOpener.openUserPage(userID);
} }
})
.setPositiveButton(R.string.action_friends_accept_request, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onRespondFrienshipRequest(int pos, final boolean response) {
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){
//Get the Friend object //Get the Friend object
Friend targetFriend = friendsList.get(pos).getFriend(); Friend targetFriend = friendsList.get(pos).getFriend();
if(accept) if (response)
//Mark the friend as accepted //Mark the friend as accepted
targetFriend.setAccepted(true); targetFriend.setAccepted(true);
else else
@ -380,10 +326,44 @@ public class FriendsListFragment extends Fragment
new AsyncTask<Friend, Void, Void>() { new AsyncTask<Friend, Void, Void>() {
@Override @Override
protected Void doInBackground(Friend... params) { protected Void doInBackground(Friend... params) {
flistHelper.respondRequest(params[0], accept); flistHelper.respondRequest(params[0], response);
return null; return null;
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, targetFriend); }.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;
} }
/** /**
@ -402,14 +382,4 @@ public class FriendsListFragment extends Fragment
if (friendsList != null) if (friendsList != null)
mNoFriendNotice.setVisibility(friendsList.size() == 0 ? View.VISIBLE : View.GONE); 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:textAlignment="center"
android:layout_marginTop="50dp"/> android:layout_marginTop="50dp"/>
<ListView <org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView
android:id="@+id/fragment_friendslist_listview" android:id="@+id/friendslist"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"

View File

@ -1,14 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:paddingBottom="8dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:paddingStart="8dp"> android:paddingStart="8dp"
android:paddingTop="8dp"
android:clickable="true"
android:focusable="true"
android:background="?selectableItemBackground">
<ImageView <org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
android:id="@+id/fragment_friendslist_item_accountimage" android:id="@+id/account_image"
android:layout_width="@dimen/account_image_default_width" android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height" android:layout_height="@dimen/account_image_default_height"
android:layout_gravity="center" android:layout_gravity="center"
@ -19,20 +24,26 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical" android:orientation="vertical"
android:paddingEnd="4dp" 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 <TextView
android:id="@+id/fragment_friendslist_item_fullname" android:id="@+id/account_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16sp" android:textSize="16sp"
tools:text="Full user name" /> tools:text="Full user name" />
<TextView <TextView
android:id="@+id/fragment_friendslist_item_status" android:id="@+id/user_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/user_status_offline" android:text="@string/user_status_offline"
@ -41,12 +52,5 @@
</LinearLayout> </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="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_more">Plus</string>
<string name="action_about">A propos</string> <string name="action_about">A propos</string>
<string name="action_reject_friend_request">Rejeter</string>
<string name="notice_request">Demande</string>
</resources> </resources>

View File

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

View File

@ -240,4 +240,6 @@
<string name="activity_about_title">About</string> <string name="activity_about_title">About</string>
<string name="dialog_open_source_licenses_title">Open Source Licenses</string> <string name="dialog_open_source_licenses_title">Open Source Licenses</string>
<string name="btn_open_source_licences">Open Source Licences</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> </resources>