mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-12-27 22:18:58 +00:00
Created FriendshipStatusButton
This commit is contained in:
parent
54ccf6b042
commit
7944cab063
@ -8,17 +8,16 @@ import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
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.FriendshipStatus;
|
||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.OnFriendsStatusUpdateListener;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.onOpenUsersPageListener;
|
||||
import org.communiquons.android.comunic.client.ui.views.FriendshipStatusButton;
|
||||
import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage;
|
||||
|
||||
/**
|
||||
@ -28,7 +27,7 @@ import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage;
|
||||
* Created by pierre on 4/11/18.
|
||||
*/
|
||||
|
||||
public class UserAccessDeniedFragment extends Fragment implements View.OnClickListener {
|
||||
public class UserAccessDeniedFragment extends Fragment implements OnFriendsStatusUpdateListener {
|
||||
|
||||
/**
|
||||
* The name in the bundle of the target user ID
|
||||
@ -60,11 +59,6 @@ public class UserAccessDeniedFragment extends Fragment implements View.OnClickLi
|
||||
*/
|
||||
private UserInfo mUserInfo;
|
||||
|
||||
/**
|
||||
* Information about the friendship status
|
||||
*/
|
||||
private FriendshipStatus mFriendshipStatus;
|
||||
|
||||
/**
|
||||
* User account image
|
||||
*/
|
||||
@ -76,29 +70,9 @@ public class UserAccessDeniedFragment extends Fragment implements View.OnClickLi
|
||||
private TextView mUserName;
|
||||
|
||||
/**
|
||||
* Buttons list container
|
||||
* Friendship status button
|
||||
*/
|
||||
private LinearLayout mButtonsList;
|
||||
|
||||
/**
|
||||
* Send request button
|
||||
*/
|
||||
private Button mSendRequestButton;
|
||||
|
||||
/**
|
||||
* Cancel request button
|
||||
*/
|
||||
private Button mCancelRequestButton;
|
||||
|
||||
/**
|
||||
* Accept request button
|
||||
*/
|
||||
private Button mAcceptRequestButton;
|
||||
|
||||
/**
|
||||
* Reject request button
|
||||
*/
|
||||
private Button mRejectRequestButton;
|
||||
private FriendshipStatusButton mFriendshipStatus;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@ -133,22 +107,21 @@ public class UserAccessDeniedFragment extends Fragment implements View.OnClickLi
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
//Get user related fields
|
||||
mUserImage = view.findViewById(R.id.user_account_image);
|
||||
mUserName = view.findViewById(R.id.user_account_name);
|
||||
mFriendshipStatus = view.findViewById(R.id.friendship_status);
|
||||
|
||||
//Get the buttons
|
||||
mButtonsList = view.findViewById(R.id.buttons_list);
|
||||
mSendRequestButton = view.findViewById(R.id.button_send_request);
|
||||
mCancelRequestButton = view.findViewById(R.id.button_cancel_request);
|
||||
mAcceptRequestButton = view.findViewById(R.id.button_accept_request);
|
||||
mRejectRequestButton = view.findViewById(R.id.button_reject_request);
|
||||
mFriendshipStatus.setOnFriendsStatusUpdateListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
//Initialize FrienshipStatus button
|
||||
mFriendshipStatus.setUserID(mUserID);
|
||||
mFriendshipStatus.refreshIfRequired();
|
||||
|
||||
//Check if it is required to fetch user information
|
||||
if(mUserInfo == null){
|
||||
getUserInfo();
|
||||
@ -204,157 +177,11 @@ public class UserAccessDeniedFragment extends Fragment implements View.OnClickLi
|
||||
mUserName.setText(mUserInfo.getDisplayFullName());
|
||||
mUserImage.setUser(mUserInfo);
|
||||
|
||||
//Check if we have got the friends
|
||||
if(mFriendshipStatus == null){
|
||||
getFrienshipStatus();
|
||||
}
|
||||
else {
|
||||
onGotFriendshipStatus(mFriendshipStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the information about the friendship between the two users
|
||||
*/
|
||||
private void getFrienshipStatus(){
|
||||
|
||||
//Perform the request in the background
|
||||
new AsyncTask<Integer, Void, FriendshipStatus>(){
|
||||
|
||||
@Override
|
||||
protected FriendshipStatus doInBackground(Integer... params) {
|
||||
return mFriendListHelper.getFrienshipStatus(params[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(FriendshipStatus status) {
|
||||
if(getActivity() == null)
|
||||
return;
|
||||
|
||||
onGotFriendshipStatus(status);
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mUserID);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called once we got information about the friendship status
|
||||
*
|
||||
* @param status The status of the frienship or null in case of failure
|
||||
*/
|
||||
private void onGotFriendshipStatus(@Nullable FriendshipStatus status){
|
||||
|
||||
//Check for errors
|
||||
if(status == null){
|
||||
Toast.makeText(getActivity(), R.string.err_get_friendship_status,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
//Save the friendship status
|
||||
mFriendshipStatus = status;
|
||||
|
||||
//Hide all the button by default but the list
|
||||
mButtonsList.setVisibility(View.VISIBLE);
|
||||
mSendRequestButton.setVisibility(View.GONE);
|
||||
mCancelRequestButton.setVisibility(View.GONE);
|
||||
mAcceptRequestButton.setVisibility(View.GONE);
|
||||
mRejectRequestButton.setVisibility(View.GONE);
|
||||
|
||||
//Check if the users are friend
|
||||
if(mFriendshipStatus.isFriend()) {
|
||||
mOpenUsersPageListener.openUserPage(mUserID);
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if the current user has sent a friendship request
|
||||
if(mFriendshipStatus.isSentRequest()){
|
||||
mCancelRequestButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//Check if the current user has received a friendship request
|
||||
else if(mFriendshipStatus.isReceivedRequest()){
|
||||
mAcceptRequestButton.setVisibility(View.VISIBLE);
|
||||
mRejectRequestButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//Else the users have not pending request
|
||||
else {
|
||||
mSendRequestButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//Make all the buttons click point on the fragment
|
||||
mSendRequestButton.setOnClickListener(this);
|
||||
mCancelRequestButton.setOnClickListener(this);
|
||||
mAcceptRequestButton.setOnClickListener(this);
|
||||
mRejectRequestButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
//Make buttons list disappear
|
||||
mButtonsList.setVisibility(View.INVISIBLE);
|
||||
|
||||
//Get the ID of the button
|
||||
int action_id = v.getId();
|
||||
|
||||
//Process the request
|
||||
new AsyncTask<Integer, Void, FriendshipStatus>(){
|
||||
|
||||
@Override
|
||||
protected FriendshipStatus doInBackground(Integer... params) {
|
||||
|
||||
//Perform requested action
|
||||
performFriendshipUpdate(params[0]);
|
||||
|
||||
//Return new friendship status
|
||||
return mFriendListHelper.getFrienshipStatus(mUserID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(FriendshipStatus status) {
|
||||
if(getActivity() == null)
|
||||
return;
|
||||
|
||||
onGotFriendshipStatus(status);
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, action_id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the update of the friendship status, as requested per the click on the buttons
|
||||
*
|
||||
* @param action_id The ID of the button that has been clicked
|
||||
*/
|
||||
private void performFriendshipUpdate(int action_id){
|
||||
|
||||
switch (action_id){
|
||||
|
||||
//Send a friendship request
|
||||
case R.id.button_send_request:
|
||||
mFriendListHelper.sendRequest(mUserID);
|
||||
break;
|
||||
|
||||
//Accept a friendship request
|
||||
case R.id.button_accept_request:
|
||||
mFriendListHelper.respondRequest(mUserID, true);
|
||||
break;
|
||||
|
||||
//Reject a friendship request
|
||||
case R.id.button_reject_request:
|
||||
mFriendListHelper.respondRequest(mUserID, false);
|
||||
break;
|
||||
|
||||
//Cancel a friendship request
|
||||
case R.id.button_cancel_request:
|
||||
mFriendListHelper.cancelRequest(mUserID);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Unsupported action by updater!");
|
||||
}
|
||||
|
||||
public void onAreFriend() {
|
||||
mOpenUsersPageListener.openUserPage(mUserID);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package org.communiquons.android.comunic.client.ui.listeners;
|
||||
|
||||
/**
|
||||
* On friend status update listener
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
public interface OnFriendsStatusUpdateListener {
|
||||
|
||||
/**
|
||||
* This method is called when the two people are friends.
|
||||
*
|
||||
* Warning ! This may be called several times...
|
||||
*/
|
||||
void onAreFriend();
|
||||
|
||||
}
|
@ -0,0 +1,339 @@
|
||||
package org.communiquons.android.comunic.client.ui.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.FriendsListHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.FriendshipStatus;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.OnFriendsStatusUpdateListener;
|
||||
|
||||
/**
|
||||
* Friendship status button
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
public class FriendshipStatusButton extends BaseFrameLayoutView implements View.OnClickListener {
|
||||
|
||||
/**
|
||||
* Debug tag
|
||||
*/
|
||||
private static final String TAG = FriendshipStatusButton.class.getCanonicalName();
|
||||
|
||||
/**
|
||||
* The ID of the target user
|
||||
*/
|
||||
private int mUserID;
|
||||
|
||||
/**
|
||||
* Information about the friendship status
|
||||
*/
|
||||
private FriendshipStatus mFriendshipStatus;
|
||||
|
||||
/**
|
||||
* Buttons list container
|
||||
*/
|
||||
private LinearLayout mButtonsList;
|
||||
|
||||
/**
|
||||
* Actions buttons
|
||||
*/
|
||||
private Button mSendRequestButton;
|
||||
private Button mCancelRequestButton;
|
||||
private Button mAcceptRequestButton;
|
||||
private Button mRejectRequestButton;
|
||||
private Button mFollowButton;
|
||||
private Button mFollowingButton;
|
||||
|
||||
/**
|
||||
* Progress bar
|
||||
*/
|
||||
private ProgressBar mProgressBar;
|
||||
|
||||
/**
|
||||
* AsyncTasks
|
||||
*/
|
||||
private GetFriendshipStatus mGetFriendShipStatus;
|
||||
private UpdateStatusClass mUpdateStatusClass;
|
||||
|
||||
/**
|
||||
* On friend status update listener
|
||||
*/
|
||||
private OnFriendsStatusUpdateListener mOnFriendsStatusUpdateListener;
|
||||
|
||||
public FriendshipStatusButton(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public FriendshipStatusButton(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public FriendshipStatusButton(@NonNull Context context, @Nullable AttributeSet attrs,
|
||||
int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
View view = inflate(getContext(), R.layout.view_frienship_status, this);
|
||||
|
||||
mProgressBar = view.findViewById(R.id.progressBar);
|
||||
mButtonsList = view.findViewById(R.id.buttons_list);
|
||||
mButtonsList = view.findViewById(R.id.buttons_list);
|
||||
mSendRequestButton = view.findViewById(R.id.button_send_request);
|
||||
mCancelRequestButton = view.findViewById(R.id.button_cancel_request);
|
||||
mAcceptRequestButton = view.findViewById(R.id.button_accept_request);
|
||||
mRejectRequestButton = view.findViewById(R.id.button_reject_request);
|
||||
mFollowButton = view.findViewById(R.id.button_follow);
|
||||
mFollowingButton = view.findViewById(R.id.button_following);
|
||||
|
||||
mSendRequestButton.setOnClickListener(this);
|
||||
mCancelRequestButton.setOnClickListener(this);
|
||||
mAcceptRequestButton.setOnClickListener(this);
|
||||
mRejectRequestButton.setOnClickListener(this);
|
||||
mFollowButton.setOnClickListener(this);
|
||||
mFollowingButton.setOnClickListener(this);
|
||||
|
||||
hideAllButtons();
|
||||
setProgressBarVisibility(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if(mGetFriendShipStatus != null)
|
||||
mGetFriendShipStatus.setOnPostExecuteListener(null);
|
||||
|
||||
if(mUpdateStatusClass != null)
|
||||
mUpdateStatusClass.setOnPostExecuteListener(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ID of the target user
|
||||
*
|
||||
* @param mUserID The ID of the target user
|
||||
*/
|
||||
public void setUserID(int mUserID) {
|
||||
this.mUserID = mUserID;
|
||||
}
|
||||
|
||||
public OnFriendsStatusUpdateListener getOnFriendsStatusUpdateListener() {
|
||||
return mOnFriendsStatusUpdateListener;
|
||||
}
|
||||
|
||||
public void setOnFriendsStatusUpdateListener(OnFriendsStatusUpdateListener onFriendsStatusUpdateListener) {
|
||||
this.mOnFriendsStatusUpdateListener = onFriendsStatusUpdateListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh current user status, only if required
|
||||
*/
|
||||
public void refreshIfRequired(){
|
||||
if(mFriendshipStatus == null)
|
||||
refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh current friendship status
|
||||
*/
|
||||
public void refresh(){
|
||||
|
||||
hideAllButtons();
|
||||
setProgressBarVisibility(true);
|
||||
|
||||
mGetFriendShipStatus = new GetFriendshipStatus(getContext());
|
||||
mGetFriendShipStatus.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mUserID);
|
||||
mGetFriendShipStatus.setOnPostExecuteListener(new SafeAsyncTask.OnPostExecuteListener<FriendshipStatus>() {
|
||||
@Override
|
||||
public void OnPostExecute(FriendshipStatus friendshipStatus) {
|
||||
onGotFriendshipsStatus(friendshipStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Method called when we have got friendship status
|
||||
*
|
||||
* @param friendshipStatus New friendship status
|
||||
*/
|
||||
private void onGotFriendshipsStatus(@Nullable FriendshipStatus friendshipStatus){
|
||||
|
||||
hideAllButtons();
|
||||
setProgressBarVisibility(false);
|
||||
|
||||
mFriendshipStatus = friendshipStatus;
|
||||
|
||||
if(friendshipStatus == null) {
|
||||
Toast.makeText(getContext(), R.string.err_get_friendship_status,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Update buttons visibility
|
||||
if(!mFriendshipStatus.isFriend()){
|
||||
|
||||
if(mFriendshipStatus.isSentRequest())
|
||||
mCancelRequestButton.setVisibility(View.VISIBLE);
|
||||
|
||||
else if(mFriendshipStatus.isReceivedRequest()){
|
||||
mAcceptRequestButton.setVisibility(View.VISIBLE);
|
||||
mRejectRequestButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
else
|
||||
mSendRequestButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
//The two people are friends
|
||||
mOnFriendsStatusUpdateListener.onAreFriend();
|
||||
|
||||
if(mFriendshipStatus.isFollowing())
|
||||
mFollowingButton.setVisibility(View.VISIBLE);
|
||||
else
|
||||
mFollowingButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int action_id = v.getId();
|
||||
hideAllButtons();
|
||||
setProgressBarVisibility(true);
|
||||
|
||||
mUpdateStatusClass = new UpdateStatusClass(mUserID, action_id, getContext());
|
||||
mUpdateStatusClass.setOnPostExecuteListener(new SafeAsyncTask.
|
||||
OnPostExecuteListener<FriendshipStatus>() {
|
||||
@Override
|
||||
public void OnPostExecute(FriendshipStatus friendshipStatus) {
|
||||
onGotFriendshipsStatus(friendshipStatus);
|
||||
}
|
||||
});
|
||||
mUpdateStatusClass.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide all view buttons
|
||||
*/
|
||||
private void hideAllButtons(){
|
||||
mSendRequestButton.setVisibility(View.GONE);
|
||||
mCancelRequestButton.setVisibility(View.GONE);
|
||||
mAcceptRequestButton.setVisibility(View.GONE);
|
||||
mRejectRequestButton.setVisibility(View.GONE);
|
||||
mFollowButton.setVisibility(View.GONE);
|
||||
mFollowingButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update progress bar visibility
|
||||
*
|
||||
* @param visible TRUE : visible / FALSE : else
|
||||
*/
|
||||
private void setProgressBarVisibility(boolean visible){
|
||||
mProgressBar.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe AsyncTask used to get current friendship status
|
||||
*/
|
||||
private static class GetFriendshipStatus extends SafeAsyncTask<Integer, Void, FriendshipStatus>{
|
||||
|
||||
GetFriendshipStatus(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FriendshipStatus doInBackground(Integer... integers) {
|
||||
return new FriendsListHelper(getContext()).getFrienshipStatus(integers[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class used to update friendship status
|
||||
*/
|
||||
private static class UpdateStatusClass extends SafeAsyncTask<Void, Void, FriendshipStatus>{
|
||||
|
||||
private int mFriendID;
|
||||
private int mAction;
|
||||
|
||||
/**
|
||||
* Construct the class
|
||||
*
|
||||
* @param friendID The ID of the target friend
|
||||
* @param action The action to perform
|
||||
* @param context The context of the application
|
||||
*/
|
||||
UpdateStatusClass(int friendID, int action, Context context) {
|
||||
super(context);
|
||||
this.mFriendID = friendID;
|
||||
this.mAction = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FriendshipStatus doInBackground(Void... voids) {
|
||||
|
||||
//Friends helper
|
||||
FriendsListHelper helper = new FriendsListHelper(getContext());
|
||||
performUpdate(mAction, mFriendID, helper);
|
||||
return helper.getFrienshipStatus(mFriendID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the update of the friendship status, as requested per the click on the buttons
|
||||
*
|
||||
* @param action_id The ID of the button that has been clicked
|
||||
* @param friend_id The ID of the target friend
|
||||
* @param helper Helper object to use
|
||||
*/
|
||||
private void performUpdate(int action_id, int friend_id, FriendsListHelper helper){
|
||||
|
||||
switch (action_id){
|
||||
|
||||
//Send a friendship request
|
||||
case R.id.button_send_request:
|
||||
helper.sendRequest(friend_id);
|
||||
break;
|
||||
|
||||
//Accept a friendship request
|
||||
case R.id.button_accept_request:
|
||||
helper.respondRequest(friend_id, true);
|
||||
break;
|
||||
|
||||
//Reject a friendship request
|
||||
case R.id.button_reject_request:
|
||||
helper.respondRequest(friend_id, false);
|
||||
break;
|
||||
|
||||
//Cancel a friendship request
|
||||
case R.id.button_cancel_request:
|
||||
helper.cancelRequest(friend_id);
|
||||
break;
|
||||
|
||||
//Update following status
|
||||
case R.id.button_follow:
|
||||
helper.setFollowing(friend_id, true);
|
||||
break;
|
||||
case R.id.button_following:
|
||||
helper.setFollowing(friend_id, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Unsupported action by updater!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -7,90 +7,49 @@
|
||||
|
||||
<!-- Basic account information -->
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="16dp">
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
|
||||
android:id="@+id/user_account_image"
|
||||
android:layout_width="@dimen/account_image_default_width"
|
||||
android:layout_height="@dimen/account_image_default_height"
|
||||
android:src="@drawable/default_account_image"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:contentDescription="@string/user_image_description"
|
||||
android:layout_marginEnd="10dp"/>
|
||||
android:src="@drawable/default_account_image" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_account_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="User account name"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
android:layout_gravity="center_vertical"
|
||||
tools:text="User account name" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
<!-- Available actions -->
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_list"
|
||||
<org.communiquons.android.comunic.client.ui.views.FriendshipStatusButton
|
||||
android:id="@+id/friendship_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:layout_marginTop="0dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_send_request"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_send_friend_request"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_cancel_request"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_cancel_friend_request"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_send_request" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_accept_request"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_accept_friend_request"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_cancel_request"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_reject_request"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_reject_friend_request"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_accept_request" />
|
||||
</LinearLayout>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<!-- Account private notice -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/notice_user_page_private"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/friendship_status"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/buttons_list"
|
||||
android:layout_marginBottom="8dp" />
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
94
app/src/main/res/layout/view_frienship_status.xml
Normal file
94
app/src/main/res/layout/view_frienship_status.xml
Normal file
@ -0,0 +1,94 @@
|
||||
<?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"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!-- Available actions -->
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="0dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_send_request"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_send_friend_request"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_cancel_request"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_cancel_friend_request"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_send_request" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_accept_request"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/holo_green_dark"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/button_accept_friend_request"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_cancel_request" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_reject_request"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/holo_red_dark"
|
||||
android:text="@string/button_reject_friend_request"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_accept_request" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_follow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_follow"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_reject_request" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_following"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:text="@string/button_following"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_follow" />
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/buttons_list"
|
||||
app:layout_constraintEnd_toEndOf="@+id/buttons_list"
|
||||
app:layout_constraintStart_toStartOf="@+id/buttons_list"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -241,4 +241,7 @@
|
||||
<string name="action_reject_friend_request">Rejeter</string>
|
||||
<string name="notice_request">Demande</string>
|
||||
<string name="action_more_description">Plus d\'options</string>
|
||||
<string name="action_follow">Suivre</string>
|
||||
<string name="button_follow">Suivre</string>
|
||||
<string name="button_following">Suivi</string>
|
||||
</resources>
|
@ -244,4 +244,6 @@
|
||||
<string name="notice_request">Requested</string>
|
||||
<string name="action_more_description">Get more options</string>
|
||||
<string name="action_follow">Follow</string>
|
||||
<string name="button_follow">Follow</string>
|
||||
<string name="button_following">Following</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user