Commit b743c356 authored by preetamozarde3's avatar preetamozarde3 Committed by Varun Patil

Add support for additional venter fields (#266)

* Relevant Complaints Changes, Edit comments

* Relevant Complaints Changes, Edit comments

* Comments adapter changes

* Add back button

* Merge with Master

* Modify .gitignore file

* Create seperate branch for edit comments feature

* Optimize the edit comments code

* Make minor codacy changes

* Remove commented code and remove files from gitignore

* Add option to edit comments and removal of commented code

* Add option to edit comments

* Add fields for suggestions and location details, make required changes to complaint card and complaint details fragment.

* Removing unwanted code

* Removing unwanted files

* Adding required files

* Minor Codacy Changes

* Make changes to the model and the UI to accomodate notifications and subscriptions.

* Minor Codacy Changes

* Fix a bug and optimize the code

* Fix a minor bug to display location details

* Remove unused resources
parent 3124030c
package app.insti.adapter;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
......@@ -12,9 +14,15 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import app.insti.R;
import app.insti.Utils;
import app.insti.api.RetrofitInterface;
......@@ -22,6 +30,7 @@ import app.insti.api.model.User;
import app.insti.api.model.Venter;
import app.insti.fragment.ComplaintFragment;
import app.insti.utils.DateTimeUtil;
import de.hdodenhof.circleimageview.CircleImageView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
......@@ -39,19 +48,26 @@ public class ComplaintsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private String userProfileUrl;
private static final String TAG = ComplaintsAdapter.class.getSimpleName();
private List<Venter.Complaint> complaintList = new ArrayList<>();
private LinearLayout linearLayoutSuggestions;
private LinearLayout linearLayoutLocationDetails;
private TextView textViewDescription;
private TextView textViewSuggestions;
private TextView textViewlocationDetails;
private TextView textViewLocation;
private TextView textViewUserName;
private TextView textViewReportDate;
private TextView textViewStatus;
public class ComplaintsViewHolder extends RecyclerView.ViewHolder {
private CardView cardView;
private TextView textViewDescription;
private CircleImageView circleImageView;
private ImageButton buttonComments;
private ImageButton buttonVotes;
private TextView textViewComments;
private ImageButton notificationson;
private ImageButton notificationsoff;
private TextView textViewVotes;
private TextView textViewLocation;
private TextView textViewUserName;
private TextView textViewReportDate;
private TextView textViewStatus;
private TextView textViewComments;
private int pos;
public ComplaintsViewHolder(View currentView) {
......@@ -61,63 +77,38 @@ public class ComplaintsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
textViewStatus = currentView.findViewById(R.id.textViewStatus);
textViewReportDate = currentView.findViewById(R.id.textViewReportDate);
textViewLocation = currentView.findViewById(R.id.textViewLocation);
linearLayoutSuggestions = currentView.findViewById(R.id.linearLayoutSuggestions);
linearLayoutLocationDetails = currentView.findViewById(R.id.linearLayoutLocationDetails);
textViewDescription = currentView.findViewById(R.id.textViewDescription);
textViewSuggestions = currentView.findViewById(R.id.textViewSuggestions);
textViewlocationDetails = currentView.findViewById(R.id.textViewLocationDetails);
buttonComments = currentView.findViewById(R.id.buttonComments);
buttonVotes = currentView.findViewById(R.id.buttonVotes);
notificationsoff = currentView.findViewById(R.id.buttonnotificationsoff);
notificationson = currentView.findViewById(R.id.buttonnotificationson);
textViewComments = currentView.findViewById(R.id.text_comments);
textViewVotes = currentView.findViewById(R.id.text_votes);
circleImageView = currentView.findViewById(R.id.circleImageViewUserImage);
}
public void bindHolder(final int position) {
private void bindHolder(final int position) {
this.pos = position;
cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString("id", complaintList.get(pos).getComplaintID());
bundle.putString("sessionId", sessionID);
bundle.putString("userId", userID);
bundle.putString("userProfileUrl", userProfileUrl);
ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintFragment).addToBackStack(TAG).commit();
Venter.Complaint detailedComplaint = complaintList.get(pos);
getComplaint(detailedComplaint);
}
});
Venter.Complaint complaint = complaintList.get(position);
try {
textViewDescription.setText(complaint.getDescription());
textViewLocation.setText(complaint.getLocationDescription());
textViewUserName.setText(complaint.getComplaintCreatedBy().getUserName());
textViewStatus.setText(complaint.getStatus().toUpperCase());
if (complaint.getStatus().equalsIgnoreCase("Reported")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorRed)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.primaryTextColor));
} else if (complaint.getStatus().equalsIgnoreCase("In Progress")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorSecondary)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
} else if (complaint.getStatus().equalsIgnoreCase("Resolved")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorGreen)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
}
String time = DateTimeUtil.getDate(complaint.getComplaintReportDate());
Log.i(TAG, "time: " + time);
textViewReportDate.setText(time);
textViewComments.setText(String.valueOf(complaint.getComment().size()));
textViewVotes.setText(String.valueOf(complaint.getUsersUpVoted().size()));
populateViews(pos, circleImageView, notificationson, notificationsoff, textViewVotes, textViewComments);
buttonComments.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString("id", complaintList.get(pos).getComplaintID());
bundle.putString("sessionId", sessionID);
bundle.putString("userId", userID);
bundle.putString("userProfileUrl", userProfileUrl);
ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintFragment).addToBackStack(TAG).commit();
Venter.Complaint detailedComplaint = complaintList.get(pos);
getComplaint(detailedComplaint);
}
});
buttonVotes.setOnClickListener(new View.OnClickListener() {
......@@ -155,21 +146,150 @@ public class ComplaintsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
complaintList.get(position).setVoteCount(0);
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in up vote: " + t.toString());
Log.i(TAG, "failure in subscribe: " + t.toString());
}
});
}
}
});
notificationsoff.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Venter.Complaint detailedComplaint = complaintList.get(pos);
subscribeToComplaint(detailedComplaint, notificationsoff, notificationson);
}
});
notificationson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Venter.Complaint detailedComplaint = complaintList.get(pos);
subscribeToComplaint(detailedComplaint, notificationsoff, notificationson);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void populateViews(int pos, CircleImageView circleImageView, ImageButton notificationson, ImageButton notificationsoff, TextView textViewVotes, TextView textViewComments) {
try {
String profileUrl = complaintList.get(pos).getComplaintCreatedBy().getUserProfilePictureUrl();
Picasso.get().load(profileUrl).placeholder(R.drawable.user_placeholder).into(circleImageView);
textViewLocation.setText(complaintList.get(pos).getLocationDescription());
textViewUserName.setText(complaintList.get(pos).getComplaintCreatedBy().getUserName());
textViewStatus.setText(complaintList.get(pos).getStatus().toUpperCase());
if (complaintList.get(pos).getStatus().equalsIgnoreCase("Reported")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorRed)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.primaryTextColor));
} else if (complaintList.get(pos).getStatus().equalsIgnoreCase("In Progress")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorSecondary)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
} else if (complaintList.get(pos).getStatus().equalsIgnoreCase("Resolved")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorGreen)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
}
String time = DateTimeUtil.getDate(complaintList.get(pos).getComplaintReportDate());
textViewReportDate.setText(time);
textViewDescription.setText(complaintList.get(pos).getDescription());
if (complaintList.get(pos).getComplaintsubscribed() == 1){
notificationson.setVisibility(View.VISIBLE);
notificationsoff.setVisibility(View.GONE);
}else if (complaintList.get(pos).getComplaintsubscribed() == 0){
notificationson.setVisibility(View.GONE);
notificationsoff.setVisibility(View.VISIBLE);
}
textViewVotes.setText(String.valueOf(complaintList.get(pos).getUsersUpVoted().size()));
textViewComments.setText(String.valueOf(complaintList.get(pos).getComment().size()));
if (!(complaintList.get(pos).getComplaintSuggestions().equals(""))){
linearLayoutSuggestions.setVisibility(View.VISIBLE);
textViewSuggestions.setText(complaintList.get(pos).getComplaintSuggestions());
}
if (!(complaintList.get(pos).getComplaintLocationDetails().equals(""))){
linearLayoutLocationDetails.setVisibility(View.VISIBLE);
textViewlocationDetails.setText(complaintList.get(pos).getComplaintLocationDetails());
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getComplaint(Venter.Complaint detailedComplaint) {
Bundle bundle = new Bundle();
bundle.putString("id", detailedComplaint.getComplaintID());
bundle.putString("sessionId", sessionID);
bundle.putString("userId", userID);
bundle.putString("userProfileUrl", userProfileUrl);
ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintFragment).addToBackStack(TAG).commit();
}
private void subscribeToComplaint(final Venter.Complaint detailedComplaint, final ImageButton notificationsoff, final ImageButton notificationson) {
final RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
if (detailedComplaint.getComplaintsubscribed() == 1) {
AlertDialog.Builder unsubscribe = new AlertDialog.Builder(context);
unsubscribe.setMessage("Are you sure you want to unsubscribe to this complaint?");
unsubscribe.setCancelable(true);
unsubscribe.setPositiveButton(
"Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
retrofitInterface.subscribetoComplaint("sessionid=" + sessionID, detailedComplaint.getComplaintID(), 0).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
notificationson.setVisibility(View.GONE);
notificationsoff.setVisibility(View.VISIBLE);
detailedComplaint.setComplaintsubscribed(0);
Toast.makeText(context, "You have been unsubscribed from this complaint!",
Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in subscribe: " + t.toString());
}
});
}
});
unsubscribe.setNegativeButton(
"No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert11 = unsubscribe.create();
alert11.show();
} else if (detailedComplaint.getComplaintsubscribed() == 0){
retrofitInterface.subscribetoComplaint("sessionid=" + sessionID, detailedComplaint.getComplaintID(), 1).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
notificationson.setVisibility(View.VISIBLE);
notificationsoff.setVisibility(View.GONE);
detailedComplaint.setComplaintsubscribed(1);
Toast.makeText(context, "You have been subscribed to this complaint!",
Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in subscribe: " + t.toString());
}
});
}
}
public ComplaintsAdapter(Activity ctx, String sessionID, String userID, String userProfileUrl) {
this.context = ctx;
this.sessionID = sessionID;
......@@ -205,6 +325,11 @@ public class ComplaintsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
return complaintList.size();
}
@Override
public int getItemViewType(int position) {
return position;
}
public void setcomplaintList(List<Venter.Complaint> list) {
this.complaintList = list;
}
......
......@@ -133,6 +133,9 @@ public interface RetrofitInterface {
@GET("venter/complaints/{complaintId}/upvote")
Call<Venter.Complaint> upVote(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId, @Query("action") int count);
@GET("venter/complaints/{complaintId}/subscribe")
Call<Venter.Complaint> subscribetoComplaint(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId, @Query("action") int count);
@POST("venter/complaints")
Call<ComplaintCreateResponse> postComplaint(@Header("Cookie") String sessionId, @Body ComplaintCreateRequest complaintCreateRequest);
......
......@@ -17,6 +17,10 @@ public class Venter {
private User complaintCreatedBy;
@SerializedName("description")
private String description;
@SerializedName("suggestions")
private String complaintSuggestions;
@SerializedName("location_details")
private String complaintLocationDetails;
@SerializedName("report_date")
private String complaintReportDate;
@SerializedName("status")
......@@ -36,6 +40,7 @@ public class Venter {
@SerializedName("comments")
private List<Comment> comment;
private int voteCount;
private int complaintsubscribed;
@NonNull
public String getComplaintID() {
......@@ -62,6 +67,23 @@ public class Venter {
this.description = description;
}
public String getComplaintSuggestions() {
return complaintSuggestions;
}
public void setComplaintSuggestions(String complaiintSuggestions) {
this.complaintSuggestions = complaiintSuggestions;
}
public String getComplaintLocationDetails() {
return complaintLocationDetails;
}
public void setComplaintLocationDetails(String complaintLocationDetails) {
this.complaintLocationDetails = complaintLocationDetails;
}
public String getComplaintReportDate() {
return complaintReportDate;
}
......@@ -141,6 +163,13 @@ public class Venter {
public void setVoteCount(int voteCount) {
this.voteCount = voteCount;
}
public int getComplaintsubscribed() {
return complaintsubscribed;
}
public void setComplaintsubscribed(int complaintsubscribed) {
this.complaintsubscribed = complaintsubscribed;
}
}
public static class TagUri {
......
......@@ -11,6 +11,10 @@ import java.util.List;
public class ComplaintCreateRequest {
@SerializedName("description")
private String complaintDescription;
@SerializedName("suggestions")
private String complaintSuggestions;
@SerializedName("location_details")
private String complaintLocationDetails;
@SerializedName("location_description")
private String complaintLocation;
@SerializedName("latitude")
......@@ -22,8 +26,10 @@ public class ComplaintCreateRequest {
@SerializedName("images")
private List<String> images;
public ComplaintCreateRequest(String complaintDescription, String complaintLocation, Float complaintLatitude, Float complaintLongitude, List<String> tags, List<String> images) {
public ComplaintCreateRequest(String complaintDescription, String complaintSuggestions, String complaintLocationDetails, String complaintLocation, Float complaintLatitude, Float complaintLongitude, List<String> tags, List<String> images) {
this.complaintDescription = complaintDescription;
this.complaintSuggestions = complaintSuggestions;
this.complaintLocationDetails = complaintLocationDetails;
this.complaintLocation = complaintLocation;
this.complaintLatitude = complaintLatitude;
this.complaintLongitude = complaintLongitude;
......@@ -39,6 +45,22 @@ public class ComplaintCreateRequest {
this.complaintDescription = complaintDescription;
}
public String getComplaintSuggestions() {
return complaintSuggestions;
}
public void setComplaintSuggestions(String complaintSuggestions) {
this.complaintSuggestions = complaintSuggestions;
}
public String getComplaintLocationDetails() {
return complaintLocationDetails;
}
public void setComplaintLocationDetails(String complaintLocationDetails) {
this.complaintLocationDetails = complaintLocationDetails;
}
public String getComplaintLocation() {
return complaintLocation;
}
......
package app.insti.fragment;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
......@@ -58,18 +60,25 @@ public class ComplaintDetailsFragment extends Fragment {
private MapView mMapView;
private TextView textViewUserName;
private TextView textViewReportDate;
private LinearLayout linearLayoutSuggestions;
private LinearLayout linearLayoutLocationDetails;
private TextView textViewLocation;
private TextView textViewDescription;
private TextView textViewSuggestions;
private TextView textViewLocationDetails;
private TextView textViewCommentLabel;
private TextView textViewVoteUpLabel;
private TextView textViewStatus;
private LinearLayout tagsLayout;
private EditText editTextComment;
private ImageButton imageButtonSend;
private ImageButton notificationsoff;
private ImageButton notificationson;
private CircleImageView circleImageViewCommentUserImage;
private RecyclerView recyclerViewComments;
private RecyclerView recyclerViewUpVotes;
private Button buttonVoteUp;
private CircleImageView circleImageViewCreatorImage;
private View mView;
private static String sId, cId, uId, uProfileUrl;
......@@ -121,6 +130,20 @@ public class ComplaintDetailsFragment extends Fragment {
e.printStackTrace();
}
notificationsoff.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subscribeToComplaint(detailedComplaint);
}
});
notificationson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subscribeToComplaint(detailedComplaint);
}
});
imageButtonSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -146,10 +169,15 @@ public class ComplaintDetailsFragment extends Fragment {
private void initialiseViews(View view) {
nestedScrollView = view.findViewById(R.id.nestedScrollViewComplaintDetail);
circleImageViewCreatorImage = view.findViewById(R.id.circleImageViewCreatorImage);
linearLayoutSuggestions = view.findViewById(R.id.linearLayoutSuggestions);
linearLayoutLocationDetails = view.findViewById(R.id.linearLayoutLocationDetails);
textViewUserName = view.findViewById(R.id.textViewUserName);
textViewReportDate = view.findViewById(R.id.textViewReportDate);
textViewLocation = view.findViewById(R.id.textViewLocation);
textViewDescription = view.findViewById(R.id.textViewDescription);
textViewSuggestions = view.findViewById(R.id.textViewSuggestions);
textViewLocationDetails = view.findViewById(R.id.textViewLocationDetails);
textViewStatus = view.findViewById(R.id.textViewStatus);
textViewCommentLabel = view.findViewById(R.id.comment_label);
textViewVoteUpLabel = view.findViewById(R.id.up_vote_label);
......@@ -160,6 +188,8 @@ public class ComplaintDetailsFragment extends Fragment {
recyclerViewUpVotes = view.findViewById(R.id.recyclerViewUpVotes);
editTextComment = view.findViewById(R.id.edit_comment);
imageButtonSend = view.findViewById(R.id.send_comment);
notificationsoff = view.findViewById(R.id.buttonnotificationsoff);
notificationson = view.findViewById(R.id.buttonnotificationson);
circleImageViewCommentUserImage = view.findViewById(R.id.comment_user_image);
buttonVoteUp = view.findViewById(R.id.buttonVoteUp);
circleIndicator = view.findViewById(R.id.indicator);
......@@ -178,6 +208,7 @@ public class ComplaintDetailsFragment extends Fragment {
private void populateViews() {
try {
buttonVoteUp.setText("UpVote");
Picasso.get().load(detailedComplaint.getComplaintCreatedBy().getUserProfilePictureUrl()).placeholder(R.drawable.user_placeholder).into(circleImageViewCreatorImage);
textViewUserName.setText(detailedComplaint.getComplaintCreatedBy().getUserName());
String time = DateTimeUtil.getDate(detailedComplaint.getComplaintReportDate().toString());
Log.i(TAG, " time: " + time);
......@@ -195,16 +226,31 @@ public class ComplaintDetailsFragment extends Fragment {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorGreen)));
textViewStatus.setTextColor(getContext().getResources().getColor(R.color.secondaryTextColor));
}
addVotesToView(detailedComplaint);
addCommentsToView(detailedComplaint);
initViewPagerForImages(detailedComplaint);
addTagsToView(detailedComplaint);
if (detailedComplaint.getComplaintsubscribed() == 1){
notificationson.setVisibility(View.VISIBLE);
notificationsoff.setVisibility(View.GONE);
} else if (detailedComplaint.getComplaintsubscribed() == 0){
notificationson.setVisibility(View.GONE);
notificationsoff.setVisibility(View.VISIBLE);
}
if (detailedComplaint.getTags().isEmpty())
linearLayoutTags.setVisibility(View.GONE);
textViewCommentLabel.setText("Comments (" + detailedComplaint.getComment().size() + ")");
textViewVoteUpLabel.setText("Up Votes (" + detailedComplaint.getUsersUpVoted().size() + ")");
Picasso.get().load(uProfileUrl).placeholder(R.drawable.user_placeholder).into(circleImageViewCommentUserImage);
addVotesToView(detailedComplaint);
addCommentsToView(detailedComplaint);
if (!(detailedComplaint.getComplaintSuggestions().equals(""))){
linearLayoutSuggestions.setVisibility(View.VISIBLE);
textViewSuggestions.setText(detailedComplaint.getComplaintSuggestions());
}
if (!(detailedComplaint.getComplaintLocationDetails().equals(""))){
linearLayoutLocationDetails.setVisibility(View.VISIBLE);
textViewLocationDetails.setText(detailedComplaint.getComplaintLocationDetails());
}
initViewPagerForImages(detailedComplaint);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -304,6 +350,66 @@ public class ComplaintDetailsFragment extends Fragment {
}
}
private void subscribeToComplaint(final Venter.Complaint detailedComplaint){
final RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
if (detailedComplaint.getComplaintsubscribed() == 1) {
AlertDialog.Builder unsubscribe = new AlertDialog.Builder(getActivity());
unsubscribe.setMessage("Are you sure you want to unsubscribe to this complaint?");
unsubscribe.setCancelable(true);
unsubscribe.setPositiveButton(
"Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
retrofitInterface.subscribetoComplaint("sessionid=" + sId, detailedComplaint.getComplaintID(), 0).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
detailedComplaint.setComplaintsubscribed(0);
notificationson.setVisibility(View.GONE);
notificationsoff.setVisibility(View.VISIBLE);
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in subscribe: " + t.toString());
}
});
}
});
unsubscribe.setNegativeButton(
"No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert11 = unsubscribe.create();
alert11.show();
} else if (detailedComplaint.getComplaintsubscribed() == 0){
retrofitInterface.subscribetoComplaint("sessionid=" + sId, detailedComplaint.getComplaintID(), 1).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
detailedComplaint.setComplaintsubscribed(1);
notificationsoff.setVisibility(View.GONE);
notificationson.setVisibility(View.VISIBLE);
Toast.makeText(getActivity(), "You are subscribed to this complaint!",
Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in subscribe: " + t.toString());
}
});
}
}
public void addVotesToView(Venter.Complaint detailedComplaint) {
upVotesList.clear();
for (User users : detailedComplaint.getUsersUpVoted()) {
......
......@@ -654,17 +654,16 @@ public class FileComplaintFragment extends Fragment {
}
private void addComplaint() {
final String complaint = "Complaint: \n" + descriptionAutoCompleteTextview.getText().toString();
final String complaint = descriptionAutoCompleteTextview.getText().toString();
final String suggestion;
final String locationDetails;
Log.i(TAG, "\nSuggestion: " + editTextSuggestions.getText().toString());
if (!(editTextSuggestions.getText().toString().isEmpty())) {
suggestion = "\n\nSuggestion: \n" + editTextSuggestions.getText().toString();
suggestion = editTextSuggestions.getText().toString();
} else {
suggestion = "";
}
if (!(editTextLocationDetails.getText().toString().isEmpty())) {
locationDetails = "\n\nLocation Details: \n" + editTextLocationDetails.getText().toString();
locationDetails = editTextLocationDetails.getText().toString();
} else {
locationDetails = "";
}
......@@ -679,7 +678,7 @@ public class FileComplaintFragment extends Fragment {
public void onClick(DialogInterface dialogInterface, int i) {
Location = new LatLng(19.133810, 72.913257);
Address = "IIT Area";
ComplaintCreateRequest complaintCreateRequest = new ComplaintCreateRequest(complaint + suggestion + locationDetails, Address, (float) Location.latitude, (float) Location.longitude, Tags, uploadedImagesUrl);
ComplaintCreateRequest complaintCreateRequest = new ComplaintCreateRequest(complaint, suggestion, locationDetails, Address, (float) Location.latitude, (float) Location.longitude, Tags, uploadedImagesUrl);
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.postComplaint("sessionid=" + getArguments().getString(Constants.SESSION_ID), complaintCreateRequest).enqueue(new Callback<ComplaintCreateResponse>() {
@Override
......@@ -715,7 +714,7 @@ public class FileComplaintFragment extends Fragment {
.create()
.show();
} else {
ComplaintCreateRequest complaintCreateRequest = new ComplaintCreateRequest(complaint + suggestion + locationDetails, Address, (float) Location.latitude, (float) Location.longitude, Tags, uploadedImagesUrl);
ComplaintCreateRequest complaintCreateRequest = new ComplaintCreateRequest(complaint, suggestion, locationDetails, Address, (float) Location.latitude, (float) Location.longitude, Tags, uploadedImagesUrl);
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.postComplaint("sessionid=" + getArguments().getString(Constants.SESSION_ID), complaintCreateRequest).enqueue(new Callback<ComplaintCreateResponse>() {
@Override
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM13,14h-2v-2h2v2zM13,10h-2L11,6h2v4z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -21,18 +22,53 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4">
android:padding="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewUserName"
android:layout_width="wrap_content"
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageViewUserImage"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="top"
android:scaleType="centerCrop" />
<LinearLayout
android:id="@+id/linearLayoutUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="User"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="@+id/textViewUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="User"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="report date"
android:textColor="@color/colorGray"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="location"
android:textColor="@color/colorGray"
android:textSize="14sp" />
</LinearLayout>
<TextView
android:id="@+id/textViewStatus"
......@@ -47,33 +83,113 @@
</LinearLayout>
<TextView
android:id="@+id/textViewReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="report date"
android:textColor="@color/colorGray"
android:textSize="14sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorPrimary"/>
<View
android:layout_width="match_parent"
android:layout_height="20dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textViewLocation"
android:id="@+id/complaint_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="location"
android:textColor="@color/colorGray"
android:textSize="14sp" />
android:text="Complaint:"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp" />
android:layout_height="5dp" />
<TextView
android:id="@+id/textViewDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="location"
android:textColor="@android:color/black"
android:textSize="14sp" />
android:textSize="16sp" />
<LinearLayout
android:id="@+id/linearLayoutSuggestions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="match_parent"
android:layout_height="20dp" />
<TextView
android:id="@+id/complaint_suggestions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Suggestions:"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<TextView
android:id="@+id/textViewSuggestions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutLocationDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="match_parent"
android:layout_height="20dp" />
<TextView
android:id="@+id/complaint_locationDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location Details:"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<TextView
android:id="@+id/textViewLocationDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorPrimary"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
......@@ -83,14 +199,14 @@
android:layout_gravity="center_horizontal"
android:paddingStart="50dp"
android:paddingEnd="20dp"
android:weightSum="2"
android:weightSum="3"
android:background="@drawable/customborder">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="2">
android:weightSum="3">
<ImageButton
android:id="@+id/buttonVotes"
......@@ -115,7 +231,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="2">
android:weightSum="3">
<ImageButton
android:id="@+id/buttonComments"
......@@ -135,6 +251,32 @@
android:text="12"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="3">
<ImageButton
android:id="@+id/buttonnotificationsoff"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="10dp"
android:layout_height="40dp"
android:visibility="visible"
android:layout_weight="1"
android:src="@drawable/baseline_notifications_black_24"/>
<ImageButton
android:id="@+id/buttonnotificationson"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="10dp"
android:layout_height="40dp"
android:visibility="gone"
android:layout_weight="1"
android:src="@drawable/baseline_notifications_active_black_24"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
......
......@@ -51,15 +51,50 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewUserName"
android:layout_width="wrap_content"
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageViewCreatorImage"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="top"
android:scaleType="centerCrop" />
<LinearLayout
android:id="@+id/linearLayoutUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Username"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="@+id/textViewUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Username"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Report Date"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
......@@ -74,37 +109,139 @@
android:text="STATUS"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textViewReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Report Date"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorPrimary"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp" />
android:layout_height="20dp"/>
<TextView
android:id="@+id/textViewDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description"
android:textColor="@android:color/black"
android:textSize="14sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/buttonnotificationsoff"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:src="@drawable/baseline_notifications_black_24"
android:visibility="visible"
android:layout_alignEnd="@id/complaint_details"
android:layout_alignParentTop="true"/>
<ImageButton
android:id="@+id/buttonnotificationson"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:src="@drawable/baseline_notifications_active_black_24"
android:visibility="gone"
android:layout_alignEnd="@id/complaint_details"
android:layout_alignParentTop="true"/>
<LinearLayout
android:id="@+id/complaint_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/complaint_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Complaint:"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<TextView
android:id="@+id/textViewDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/linearLayoutSuggestions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="match_parent"
android:layout_height="20dp" />
<TextView
android:id="@+id/complaint_suggestions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Suggestions:"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<TextView
android:id="@+id/textViewSuggestions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutLocationDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="match_parent"
android:layout_height="20dp" />
<TextView
android:id="@+id/complaint_locationDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location Details:"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<TextView
android:id="@+id/textViewLocationDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment