mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Can update group membership
This commit is contained in:
parent
8cf57d17c6
commit
36a15388cc
@ -161,6 +161,70 @@ public class GroupsHelper extends BaseHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a group membership request
|
||||
*
|
||||
* @param groupID The ID of the target group
|
||||
* @return Depends of the success of the operation
|
||||
*/
|
||||
public boolean sendRequest(int groupID){
|
||||
APIRequest request = new APIRequest(getContext(), "groups/send_request");
|
||||
request.addInt("id", groupID);
|
||||
return performMembershipUpdate(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a group membership request
|
||||
*
|
||||
* @param groupID the ID of the target group
|
||||
* @return TRUE in case of success / FALSE else
|
||||
*/
|
||||
public boolean cancelRequest(int groupID){
|
||||
APIRequest request = new APIRequest(getContext(), "groups/cancel_request");
|
||||
request.addInt("id", groupID);
|
||||
return performMembershipUpdate(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to a group membership invitation
|
||||
*
|
||||
* @param groupID The ID of the target group
|
||||
* @param accept TRUE to accept invitation / FALSE else
|
||||
*/
|
||||
public boolean respondInvitation(int groupID, boolean accept){
|
||||
APIRequest request = new APIRequest(getContext(), "groups/respond_invitation");
|
||||
request.addInt("id", groupID);
|
||||
request.addBoolean("accept", accept);
|
||||
return performMembershipUpdate(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave a group
|
||||
*
|
||||
* @param groupID The ID of the group to leave
|
||||
* @return TRUE for a success / FALSE else
|
||||
*/
|
||||
public boolean leaveGroup(int groupID){
|
||||
APIRequest request = new APIRequest(getContext(), "groups/remove_membership");
|
||||
request.addInt("id", groupID);
|
||||
return performMembershipUpdate(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform on the server a membership update
|
||||
*
|
||||
* @param request The request to perform
|
||||
* @return Depends of the success of the operation
|
||||
*/
|
||||
private boolean performMembershipUpdate(APIRequest request){
|
||||
try {
|
||||
return new APIRequestHelper().exec(request).getResponse_code() == 200;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse group information into GroupInfo object
|
||||
*
|
||||
|
@ -10,7 +10,9 @@ import android.widget.TextView;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.models.GroupInfo;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.OnGroupMembershipUpdateListener;
|
||||
import org.communiquons.android.comunic.client.ui.views.GroupImageView;
|
||||
import org.communiquons.android.comunic.client.ui.views.GroupMembershipStatusView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -26,6 +28,8 @@ public class GroupsListAdapter extends BaseRecyclerViewAdapter {
|
||||
*/
|
||||
private ArrayList<GroupInfo> mList = new ArrayList<>();
|
||||
|
||||
private OnGroupMembershipUpdateListener mOnGroupMembershipUpdateListener;
|
||||
|
||||
public GroupsListAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@ -39,6 +43,15 @@ public class GroupsListAdapter extends BaseRecyclerViewAdapter {
|
||||
this.mList = List;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the group membership update listener
|
||||
*
|
||||
* @param onGroupMembershipUpdateListener The listener
|
||||
*/
|
||||
public void setOnGroupMembershipUpdateListener(OnGroupMembershipUpdateListener onGroupMembershipUpdateListener) {
|
||||
this.mOnGroupMembershipUpdateListener = onGroupMembershipUpdateListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
@ -57,6 +70,7 @@ public class GroupsListAdapter extends BaseRecyclerViewAdapter {
|
||||
((GroupHolder)viewHolder).bind(i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Single group holder class
|
||||
*/
|
||||
@ -64,12 +78,16 @@ public class GroupsListAdapter extends BaseRecyclerViewAdapter {
|
||||
|
||||
private GroupImageView mGroupImageView;
|
||||
private TextView mGroupName;
|
||||
private GroupMembershipStatusView mGroupMembershipStatus;
|
||||
|
||||
GroupHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
mGroupImageView = itemView.findViewById(R.id.groupImage);
|
||||
mGroupName = itemView.findViewById(R.id.groupName);
|
||||
mGroupMembershipStatus = itemView.findViewById(R.id.groupMembershipStatusView);
|
||||
|
||||
mGroupMembershipStatus.setOnGroupMembershipUpdateListener(mOnGroupMembershipUpdateListener);
|
||||
}
|
||||
|
||||
GroupInfo getGroup(int pos){
|
||||
@ -80,6 +98,7 @@ public class GroupsListAdapter extends BaseRecyclerViewAdapter {
|
||||
GroupInfo groupInfo = getGroup(pos);
|
||||
mGroupImageView.setGroup(groupInfo);
|
||||
mGroupName.setText(groupInfo.getDisplayName());
|
||||
mGroupMembershipStatus.setGroup(groupInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.helpers.GroupsHelper;
|
||||
|
||||
/**
|
||||
* Cancel a group membership request task
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
public class CancelGroupMembershipRequestTask extends SafeAsyncTask<Integer, Void, Boolean> {
|
||||
public CancelGroupMembershipRequestTask(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Integer... integers) {
|
||||
return new GroupsHelper(getContext()).cancelRequest(integers[0]);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.helpers.GroupsHelper;
|
||||
|
||||
/**
|
||||
* Leave group task
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
public class LeaveGroupTask extends SafeAsyncTask<Integer, Void, Boolean> {
|
||||
public LeaveGroupTask(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Integer... integers) {
|
||||
return new GroupsHelper(getContext()).leaveGroup(integers[0]);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.helpers.GroupsHelper;
|
||||
|
||||
/**
|
||||
* Respond to a group membership invitation task
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
public class RespondGroupInvitationTask extends SafeAsyncTask<Integer, Void, Boolean> {
|
||||
|
||||
private boolean mAccept;
|
||||
|
||||
|
||||
public RespondGroupInvitationTask(Context context, boolean accept) {
|
||||
super(context);
|
||||
this.mAccept = accept;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Integer... integers) {
|
||||
return new GroupsHelper(getContext()).respondInvitation(integers[0], mAccept);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.helpers.GroupsHelper;
|
||||
|
||||
/**
|
||||
* Send a group membership request task
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
public class SendGroupMembershipRequestTask extends SafeAsyncTask<Integer, Void, Boolean> {
|
||||
public SendGroupMembershipRequestTask(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Integer... integers) {
|
||||
return new GroupsHelper(getContext()).sendRequest(integers[0]);
|
||||
}
|
||||
}
|
@ -1,8 +1,21 @@
|
||||
package org.communiquons.android.comunic.client.ui.fragments.groups;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.models.GroupInfo;
|
||||
import org.communiquons.android.comunic.client.ui.activities.MainActivity;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.CancelGroupMembershipRequestTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.LeaveGroupTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.RespondGroupInvitationTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SendGroupMembershipRequestTask;
|
||||
import org.communiquons.android.comunic.client.ui.fragments.AbstractFragment;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.OnGroupMembershipUpdateListener;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -11,7 +24,12 @@ import java.util.Objects;
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
abstract class AbstractGroupFragment extends AbstractFragment {
|
||||
abstract class AbstractGroupFragment extends AbstractFragment implements OnGroupMembershipUpdateListener {
|
||||
|
||||
/**
|
||||
* Debug tag
|
||||
*/
|
||||
private static final String TAG = AbstractGroupFragment.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
@ -20,4 +38,82 @@ abstract class AbstractGroupFragment extends AbstractFragment {
|
||||
MainActivity.SetNavbarSelectedOption(Objects.requireNonNull(getActivity()),
|
||||
R.id.action_personal_page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRespondInvitation(GroupInfo group, boolean accept) {
|
||||
RespondGroupInvitationTask respondGroupInvitationTask =
|
||||
new RespondGroupInvitationTask(getContext(), accept);
|
||||
performGroupMembershipUpdate(group.getId(), respondGroupInvitationTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelRequest(GroupInfo group) {
|
||||
CancelGroupMembershipRequestTask task = new CancelGroupMembershipRequestTask(getActivity());
|
||||
performGroupMembershipUpdate(group.getId(), task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendRequest(GroupInfo group) {
|
||||
SendGroupMembershipRequestTask task = new SendGroupMembershipRequestTask(getActivity());
|
||||
performGroupMembershipUpdate(group.getId(), task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeaveGroup(GroupInfo group) {
|
||||
final int groupID = group.getId();
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.dialog_leave_group_title)
|
||||
.setMessage(R.string.dialog_leave_group_message)
|
||||
.setNegativeButton(R.string.dialog_leave_group_cancel, null)
|
||||
|
||||
.setPositiveButton(R.string.dialog_leave_group_confirm, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
leaveGroup(groupID);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do leave the group for the user
|
||||
*
|
||||
* @param groupID The ID of the group to leave
|
||||
*/
|
||||
private void leaveGroup(final int groupID) {
|
||||
LeaveGroupTask leaveGroupTask = new LeaveGroupTask(getActivity());
|
||||
performGroupMembershipUpdate(groupID, leaveGroupTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform group membership update
|
||||
*
|
||||
* @param groupID The ID of the target group
|
||||
* @param task Task to execute
|
||||
*/
|
||||
private void performGroupMembershipUpdate(final int groupID, SafeAsyncTask<Integer, Void, Boolean> task) {
|
||||
task.setOnPostExecuteListener(new SafeAsyncTask.OnPostExecuteListener<Boolean>() {
|
||||
@Override
|
||||
public void OnPostExecute(Boolean success) {
|
||||
onGroupMembershipUpdated(success, groupID);
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, groupID);
|
||||
getTasksManager().addTask(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the membership to a group has been updated
|
||||
*
|
||||
* @param success TRUE if the operation was a success / FALSE else
|
||||
* @param groupID Information about the updated group
|
||||
*/
|
||||
@CallSuper
|
||||
public void onGroupMembershipUpdated(boolean success, int groupID) {
|
||||
|
||||
//Check for errors
|
||||
if (!success)
|
||||
Toast.makeText(getActivity(), R.string.err_update_group_membership,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -120,17 +120,29 @@ public class UserGroupsFragment extends AbstractGroupFragment {
|
||||
|
||||
setProgressBarVisibility(false);
|
||||
|
||||
if(mGroupsAdapter == null) {
|
||||
mGroupsAdapter = new GroupsListAdapter(getActivity());
|
||||
mGroupsAdapter.setList(new ArrayList<>(mGroupsList.values()));
|
||||
|
||||
mGroupsView.setAdapter(mGroupsAdapter);
|
||||
mGroupsView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
mGroupsView.addItemDecoration(new DividerItemDecoration(getActivity(),
|
||||
DividerItemDecoration.VERTICAL));
|
||||
}
|
||||
|
||||
|
||||
mGroupsAdapter.setOnGroupMembershipUpdateListener(this);
|
||||
mGroupsAdapter.setList(new ArrayList<>(mGroupsList.values()));
|
||||
mGroupsAdapter.notifyDataSetChanged();
|
||||
|
||||
setNoGroupNoticeVisibility(mGroupsList.size() == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGroupMembershipUpdated(boolean success, int groupID) {
|
||||
super.onGroupMembershipUpdated(success, groupID);
|
||||
getGroupsList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update (set) progressbar visibility
|
||||
*
|
||||
|
@ -0,0 +1,35 @@
|
||||
package org.communiquons.android.comunic.client.ui.listeners;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.models.GroupInfo;
|
||||
|
||||
public interface OnGroupMembershipUpdateListener {
|
||||
|
||||
/**
|
||||
* Respond to a group membership invitation
|
||||
*
|
||||
* @param group Information about the target group
|
||||
* @param accept TRUE to accept / FALSE else
|
||||
*/
|
||||
void onRespondInvitation(GroupInfo group, boolean accept);
|
||||
|
||||
/**
|
||||
* Cancel a group membership request
|
||||
*
|
||||
* @param group The target group
|
||||
*/
|
||||
void onCancelRequest(GroupInfo group);
|
||||
|
||||
/**
|
||||
* Send a request to join a group
|
||||
*
|
||||
* @param group The target group
|
||||
*/
|
||||
void onSendRequest(GroupInfo group);
|
||||
|
||||
/**
|
||||
* Send a request to leave a group
|
||||
*
|
||||
* @param group The target group
|
||||
*/
|
||||
void onLeaveGroup(GroupInfo group);
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
package org.communiquons.android.comunic.client.ui.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.constraint.ConstraintLayout;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.models.GroupInfo;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.OnGroupMembershipUpdateListener;
|
||||
|
||||
/**
|
||||
* Group membership button
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
public class GroupMembershipStatusView extends BaseFrameLayoutView implements View.OnClickListener {
|
||||
|
||||
/**
|
||||
* Views
|
||||
*/
|
||||
private ConstraintLayout respondInvitationForm;
|
||||
private Button rejectButton;
|
||||
private Button acceptButton;
|
||||
private ConstraintLayout cancelRequestForm;
|
||||
private Button cancelButton;
|
||||
private ConstraintLayout requestForm;
|
||||
private Button joinButton;
|
||||
private ConstraintLayout memberForm;
|
||||
private Button leaveButton;
|
||||
|
||||
/**
|
||||
* Group information
|
||||
*/
|
||||
private GroupInfo mInfo;
|
||||
|
||||
/**
|
||||
* Listener
|
||||
*/
|
||||
private OnGroupMembershipUpdateListener mOnGroupMembershipUpdateListener;
|
||||
|
||||
|
||||
public GroupMembershipStatusView(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public GroupMembershipStatusView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public GroupMembershipStatusView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
View view = inflate(getContext(), R.layout.view_group_membership_status, this);
|
||||
respondInvitationForm = view.findViewById(R.id.respondInvitationForm);
|
||||
rejectButton = view.findViewById(R.id.rejectButton);
|
||||
acceptButton = view.findViewById(R.id.acceptButton);
|
||||
cancelRequestForm = view.findViewById(R.id.cancelRequestForm);
|
||||
cancelButton = view.findViewById(R.id.cancelButton);
|
||||
requestForm = view.findViewById(R.id.requestForm);
|
||||
joinButton = view.findViewById(R.id.joinButton);
|
||||
memberForm = view.findViewById(R.id.memberForm);
|
||||
leaveButton = view.findViewById(R.id.leaveButton);
|
||||
|
||||
//Show only one form
|
||||
showForm(respondInvitationForm);
|
||||
|
||||
rejectButton.setOnClickListener(this);
|
||||
acceptButton.setOnClickListener(this);
|
||||
cancelButton.setOnClickListener(this);
|
||||
joinButton.setOnClickListener(this);
|
||||
leaveButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the group membership update listener
|
||||
*
|
||||
* @param onGroupMembershipUpdateListener The listener
|
||||
*/
|
||||
public void setOnGroupMembershipUpdateListener(OnGroupMembershipUpdateListener onGroupMembershipUpdateListener) {
|
||||
this.mOnGroupMembershipUpdateListener = onGroupMembershipUpdateListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign the view to a new group
|
||||
*
|
||||
* @param info Information about the group
|
||||
*/
|
||||
public void setGroup(GroupInfo info) {
|
||||
mInfo = info;
|
||||
showButtons(true);
|
||||
|
||||
switch (info.getMembershipLevel()) {
|
||||
case VISITOR:
|
||||
showForm(requestForm);
|
||||
return;
|
||||
|
||||
case PENDING:
|
||||
showForm(cancelRequestForm);
|
||||
return;
|
||||
|
||||
case INVITED:
|
||||
showForm(respondInvitationForm);
|
||||
return;
|
||||
|
||||
default:
|
||||
showForm(memberForm);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form contained in a specific view and hide the other ones
|
||||
*
|
||||
* @param v The container of the form to show
|
||||
*/
|
||||
private void showForm(View v) {
|
||||
|
||||
respondInvitationForm.setVisibility(v.equals(respondInvitationForm)
|
||||
? View.VISIBLE : View.GONE);
|
||||
cancelRequestForm.setVisibility(v.equals(cancelRequestForm)
|
||||
? View.VISIBLE : View.GONE);
|
||||
requestForm.setVisibility(v.equals(requestForm)
|
||||
? View.VISIBLE : View.GONE);
|
||||
memberForm.setVisibility(v.equals(memberForm) ? View.VISIBLE : View.GONE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update buttons visibility
|
||||
*
|
||||
* @param visible New visibility for the buttons
|
||||
*/
|
||||
private void showButtons(boolean visible){
|
||||
rejectButton.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
acceptButton.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
cancelButton.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
joinButton.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
leaveButton.setVisibility(View.VISIBLE); //View cannot be hidden
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if(mOnGroupMembershipUpdateListener == null)
|
||||
return;
|
||||
|
||||
showButtons(false);
|
||||
|
||||
if(v.equals(rejectButton)){
|
||||
mOnGroupMembershipUpdateListener.onRespondInvitation(mInfo, false);
|
||||
}
|
||||
|
||||
else if(v.equals(acceptButton)){
|
||||
mOnGroupMembershipUpdateListener.onRespondInvitation(mInfo, true);
|
||||
}
|
||||
|
||||
else if(v.equals(cancelButton)){
|
||||
mOnGroupMembershipUpdateListener.onCancelRequest(mInfo);
|
||||
}
|
||||
|
||||
else if (v.equals(joinButton)){
|
||||
mOnGroupMembershipUpdateListener.onSendRequest(mInfo);
|
||||
}
|
||||
|
||||
else if(v.equals(leaveButton)){
|
||||
mOnGroupMembershipUpdateListener.onLeaveGroup(mInfo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
137
app/src/main/res/layout/view_group_membership_status.xml
Normal file
137
app/src/main/res/layout/view_group_membership_status.xml
Normal file
@ -0,0 +1,137 @@
|
||||
<?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="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:id="@+id/respondInvitationForm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView9"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:text="@string/notice_group_invited"
|
||||
app:layout_constraintEnd_toEndOf="@+id/acceptButton"
|
||||
app:layout_constraintStart_toStartOf="@+id/acceptButton" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/rejectButton"
|
||||
style="@style/GroupMembershipButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@android:color/holo_red_dark"
|
||||
android:text="@string/action_group_reject_request"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintEnd_toEndOf="@+id/acceptButton"
|
||||
app:layout_constraintStart_toStartOf="@+id/acceptButton"
|
||||
app:layout_constraintTop_toBottomOf="@+id/acceptButton" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/acceptButton"
|
||||
style="@style/GroupMembershipButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:backgroundTint="@color/holo_green_dark"
|
||||
android:text="@string/action_group_accept_request"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView9" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:id="@+id/cancelRequestForm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/respondInvitationForm">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView10"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/notice_group_requested"
|
||||
app:layout_constraintEnd_toEndOf="@+id/cancelButton"
|
||||
app:layout_constraintStart_toStartOf="@+id/cancelButton"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancelButton"
|
||||
style="@style/GroupMembershipButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:backgroundTint="@android:color/holo_red_dark"
|
||||
android:text="@string/action_group_cancel_membership_request"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView10" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:id="@+id/requestForm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cancelRequestForm">
|
||||
|
||||
<Button
|
||||
android:id="@+id/joinButton"
|
||||
style="@style/GroupMembershipButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:backgroundTint="@color/dark_blue"
|
||||
android:text="@string/action_join_group"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:id="@+id/memberForm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/requestForm">
|
||||
|
||||
<Button
|
||||
android:id="@+id/leaveButton"
|
||||
style="@style/GroupMembershipButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:backgroundTint="@android:color/holo_red_dark"
|
||||
android:text="@string/action_leave_group"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -13,10 +13,11 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
tools:text="Group Name"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/groupImage"
|
||||
app:layout_constraintStart_toEndOf="@+id/groupImage"
|
||||
app:layout_constraintTop_toTopOf="@+id/groupImage" />
|
||||
app:layout_constraintTop_toTopOf="@+id/groupImage"
|
||||
tools:text="Group Name" />
|
||||
|
||||
<org.communiquons.android.comunic.client.ui.views.GroupImageView
|
||||
android:id="@+id/groupImage"
|
||||
@ -29,4 +30,13 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_friends" />
|
||||
|
||||
<org.communiquons.android.comunic.client.ui.views.GroupMembershipStatusView
|
||||
android:id="@+id/groupMembershipStatusView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -300,4 +300,16 @@
|
||||
<string name="action_user_groups">Mes groupes</string>
|
||||
<string name="err_get_user_groups">Une erreur a survenu lors de la récupération de vos groupes !</string>
|
||||
<string name="notice_no_group">Vous n\'avez aucun groupe pour le moment.</string>
|
||||
<string name="notice_group_invited">Invité</string>
|
||||
<string name="action_group_accept_request">Accepter</string>
|
||||
<string name="action_group_reject_request">Rejeter</string>
|
||||
<string name="notice_group_requested">Demande envoyée</string>
|
||||
<string name="action_group_cancel_membership_request">Annuler</string>
|
||||
<string name="action_join_group">Rejoindre</string>
|
||||
<string name="action_leave_group">Quitter</string>
|
||||
<string name="dialog_leave_group_title">Quitter le groupe</string>
|
||||
<string name="dialog_leave_group_message">Voulez-vous vraiment quitter ce groupe ? Il se peut que vous ne puissez pas le rejoindre ultérieurement !</string>
|
||||
<string name="dialog_leave_group_cancel">Annuler</string>
|
||||
<string name="dialog_leave_group_confirm">Quitter</string>
|
||||
<string name="err_update_group_membership">Une erreur a survenue lors de la mise à jour de votre appartenance au groupe !</string>
|
||||
</resources>
|
@ -4,7 +4,7 @@
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#ff4081</color>
|
||||
|
||||
<color name="holo_green_dark">#ff669900</color>
|
||||
<color name="holo_green_dark">#669900</color>
|
||||
<color name="darker_gray">#aaa</color>
|
||||
<color name="darker_darker_gray">#5b5b5b</color>
|
||||
<color name="dark_blue">#303f9f</color>
|
||||
|
@ -299,4 +299,16 @@
|
||||
<string name="action_user_groups">My groups</string>
|
||||
<string name="err_get_user_groups">Could not get the groups of the user!</string>
|
||||
<string name="notice_no_group">You do not have any group yet.</string>
|
||||
<string name="notice_group_invited">Invited</string>
|
||||
<string name="action_group_accept_request">Accept</string>
|
||||
<string name="action_group_reject_request">Reject</string>
|
||||
<string name="notice_group_requested">Requested</string>
|
||||
<string name="action_group_cancel_membership_request">Cancel</string>
|
||||
<string name="action_join_group">Join</string>
|
||||
<string name="action_leave_group">Leave</string>
|
||||
<string name="dialog_leave_group_title">Leave group</string>
|
||||
<string name="dialog_leave_group_message">Do you really want to leave this group? You might not be able to join it later!</string>
|
||||
<string name="dialog_leave_group_cancel">Cancel</string>
|
||||
<string name="dialog_leave_group_confirm">Leave</string>
|
||||
<string name="err_update_group_membership">Could not update group membership!</string>
|
||||
</resources>
|
||||
|
@ -174,4 +174,10 @@
|
||||
<item name="android:padding">2dp</item>
|
||||
<item name="android:layout_gravity">center</item>
|
||||
</style>
|
||||
|
||||
<!-- Groups membership button -->
|
||||
<style name="GroupMembershipButton" >
|
||||
<item name="android:minHeight">40dip</item>
|
||||
<item name="android:minWidth">80dip</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user