Commit a1d90606 authored by sshivam95's avatar sshivam95

Merge branch 'nss' of https://github.com/sshivam95/InstiApp into nss

# Conflicts:
#	app/src/main/java/app/insti/fragment/FileComplaintFragment.java
parents 933a501c f05521e9
...@@ -52,5 +52,6 @@ dependencies { ...@@ -52,5 +52,6 @@ dependencies {
implementation "ru.noties:markwon:${markwonVersion}" implementation "ru.noties:markwon:${markwonVersion}"
implementation "com.github.Cutta:TagView:${tagViewVersion}" implementation "com.github.Cutta:TagView:${tagViewVersion}"
implementation "me.relex:circleindicator:${circleIndicatorVersion}" implementation "me.relex:circleindicator:${circleIndicatorVersion}"
implementation 'com.android.support:support-v4:28.0.0'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
...@@ -3,11 +3,11 @@ package app.insti; ...@@ -3,11 +3,11 @@ package app.insti;
/** /**
* Created by Shivam Sharma on 13-08-2018. * Created by Shivam Sharma on 13-08-2018.
*/ */
public class TagClass { public class ComplaintTag {
private String name; private String name;
public TagClass(String name) { public ComplaintTag(String name) {
this.name = name; this.name = name;
} }
......
...@@ -20,6 +20,7 @@ public class Constants { ...@@ -20,6 +20,7 @@ public class Constants {
public static final String IS_LOGGED_IN = "IsLoggedIn"; public static final String IS_LOGGED_IN = "IsLoggedIn";
public static final String GCM_ID = "GcmId"; public static final String GCM_ID = "GcmId";
public static final String CURRENT_USER = "current_user"; public static final String CURRENT_USER = "current_user";
public static final String CURRENT_USER_PROFILE_PICTURE = "current_user_profile_picture";
public static final String SESSION_ID = "session_id"; public static final String SESSION_ID = "session_id";
public static final int STATUS_GOING = 2; public static final int STATUS_GOING = 2;
public static final int STATUS_INTERESTED = 1; public static final int STATUS_INTERESTED = 1;
......
...@@ -55,10 +55,8 @@ import app.insti.api.model.Role; ...@@ -55,10 +55,8 @@ import app.insti.api.model.Role;
import app.insti.api.model.User; import app.insti.api.model.User;
import app.insti.api.request.UserFCMPatchRequest; import app.insti.api.request.UserFCMPatchRequest;
import app.insti.fragment.BackHandledFragment; import app.insti.fragment.BackHandledFragment;
import app.insti.fragment.BodyFragment;
import app.insti.fragment.CalendarFragment; import app.insti.fragment.CalendarFragment;
import app.insti.fragment.ComplaintFragment; import app.insti.fragment.ComplaintsFragment;
import app.insti.fragment.EventFragment;
import app.insti.fragment.ExploreFragment; import app.insti.fragment.ExploreFragment;
import app.insti.fragment.FeedFragment; import app.insti.fragment.FeedFragment;
import app.insti.fragment.FileComplaintFragment; import app.insti.fragment.FileComplaintFragment;
...@@ -530,8 +528,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -530,8 +528,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
case R.id.nav_complaint: case R.id.nav_complaint:
if (session.isLoggedIn()) { if (session.isLoggedIn()) {
ComplaintFragment complaintFragment = new ComplaintFragment(); ComplaintsFragment complaintsFragment = new ComplaintsFragment();
updateFragment(complaintFragment); updateFragment(complaintsFragment);
} else { } else {
Toast.makeText(this, Constants.LOGIN_MESSAGE, Toast.LENGTH_LONG).show(); Toast.makeText(this, Constants.LOGIN_MESSAGE, Toast.LENGTH_LONG).show();
} }
...@@ -577,8 +575,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -577,8 +575,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
bundle.putString(Constants.SESSION_ID, session.pref.getString(Constants.SESSION_ID, "")); bundle.putString(Constants.SESSION_ID, session.pref.getString(Constants.SESSION_ID, ""));
if (fragment instanceof MessMenuFragment) if (fragment instanceof MessMenuFragment)
bundle.putString(Constants.USER_HOSTEL, session.isLoggedIn() && currentUser.getHostel() != null ? currentUser.getHostel() : "1"); bundle.putString(Constants.USER_HOSTEL, session.isLoggedIn() && currentUser.getHostel() != null ? currentUser.getHostel() : "1");
if (fragment instanceof SettingsFragment && session.isLoggedIn() || fragment instanceof ComplaintFragment && session.isLoggedIn()) if (fragment instanceof SettingsFragment && session.isLoggedIn())
bundle.putString(Constants.USER_ID, currentUser.getUserID()); bundle.putString(Constants.USER_ID, currentUser.getUserID());
if (fragment instanceof ComplaintsFragment && session.isLoggedIn()){
bundle.putString(Constants.USER_ID, currentUser.getUserID());
bundle.putString(Constants.CURRENT_USER_PROFILE_PICTURE, currentUser.getUserProfilePictureUrl());
}
fragment.setArguments(bundle); fragment.setArguments(bundle);
FragmentManager manager = getSupportFragmentManager(); FragmentManager manager = getSupportFragmentManager();
if (fragment instanceof FeedFragment) if (fragment instanceof FeedFragment)
......
package app.insti.adapter; package app.insti.adapter;
import android.app.Activity;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView; import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
...@@ -12,8 +12,6 @@ import android.view.LayoutInflater; ...@@ -12,8 +12,6 @@ import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.PopupMenu; import android.widget.PopupMenu;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -25,7 +23,6 @@ import java.util.List; ...@@ -25,7 +23,6 @@ import java.util.List;
import app.insti.R; import app.insti.R;
import app.insti.Utils; import app.insti.Utils;
import app.insti.activity.MainActivity;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter; import app.insti.api.model.Venter;
import app.insti.utils.DateTimeUtil; import app.insti.utils.DateTimeUtil;
...@@ -38,25 +35,24 @@ import retrofit2.Response; ...@@ -38,25 +35,24 @@ import retrofit2.Response;
* Created by Shivam Sharma on 23-09-2018. * Created by Shivam Sharma on 23-09-2018.
*/ */
public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final String TAG = CommentRecyclerViewAdapter.class.getSimpleName(); private static final String TAG = CommentsAdapter.class.getSimpleName();
private Context context; private Context context;
private LayoutInflater inflater; private LayoutInflater inflater;
private String sessionId, userId; private String sessionId, userId;
Activity activity; private Fragment fragment;
private TextView textViewCommentLabel; private TextView textViewCommentLabel;
private List<Venter.Comment> commentList = new ArrayList<>(); private List<Venter.Comment> commentList = new ArrayList<>();
public CommentRecyclerViewAdapter(Activity activity, Context context, String sessionId, String userId, TextView textViewCommentLabel) { public CommentsAdapter(Context context, String sessionId, String userId, Fragment fragment) {
this.context = context; this.context = context;
this.sessionId = sessionId; this.sessionId = sessionId;
this.userId = userId; this.userId = userId;
inflater = LayoutInflater.from(context); inflater = LayoutInflater.from(context);
this.activity = activity; this.fragment =fragment;
this.textViewCommentLabel = textViewCommentLabel;
} }
public class CommentsViewHolder extends RecyclerView.ViewHolder { public class CommentsViewHolder extends RecyclerView.ViewHolder {
...@@ -66,9 +62,9 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ...@@ -66,9 +62,9 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
private TextView textViewName; private TextView textViewName;
private TextView textViewCommentTime; private TextView textViewCommentTime;
private TextView textViewComment; private TextView textViewComment;
final RetrofitInterface retrofitInterface = Utils.getRetrofitInterface(); private final RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
public CommentsViewHolder(View itemView) { CommentsViewHolder(View itemView) {
super(itemView); super(itemView);
cardView = itemView.findViewById(R.id.cardViewComment); cardView = itemView.findViewById(R.id.cardViewComment);
textViewName = itemView.findViewById(R.id.textViewUserComment); textViewName = itemView.findViewById(R.id.textViewUserComment);
...@@ -77,22 +73,19 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ...@@ -77,22 +73,19 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
circleImageView = itemView.findViewById(R.id.circleImageViewUserImage); circleImageView = itemView.findViewById(R.id.circleImageViewUserImage);
} }
public void bindHolder(final int position) { private void bindHolder(final int position) {
final Venter.Comment comment = commentList.get(position); final Venter.Comment comment = commentList.get(position);
try { try {
String profileUrl = comment.getUser().getUserProfilePictureUrl(); String profileUrl = comment.getUser().getUserProfilePictureUrl();
Log.i(TAG, "PROFILE URL: " + profileUrl); Log.i(TAG, "PROFILE URL: " + profileUrl);
if (profileUrl != null) Picasso.get().load(profileUrl).placeholder(R.drawable.user_placeholder).into(circleImageView);
Picasso.get().load(profileUrl).into(circleImageView);
else
Picasso.get().load(R.drawable.baseline_account_circle_black_36).into(circleImageView);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
textViewName.setText(comment.getUser().getUserName()); textViewName.setText(comment.getUser().getUserName());
String time = DateTimeUtil.getDate(comment.getTime().toString()); String time = DateTimeUtil.getDate(comment.getTime());
Log.i(TAG, "time: " + time); Log.i(TAG, "time: " + time);
textViewCommentTime.setText(time); textViewCommentTime.setText(time);
textViewComment.setText(comment.getText()); textViewComment.setText(comment.getText());
...@@ -114,9 +107,11 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ...@@ -114,9 +107,11 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.copy_comment_option: case R.id.copy_comment_option:
ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE); ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("Text Copied", textViewComment.getText().toString()); ClipData clipData = ClipData.newPlainText("Text Copied", textViewComment.getText().toString());
clipboardManager.setPrimaryClip(clipData); if (clipboardManager != null) {
clipboardManager.setPrimaryClip(clipData);
}
Toast.makeText(context, "Comment Copied", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "Comment Copied", Toast.LENGTH_SHORT).show();
break; break;
case R.id.delete_comment_option: case R.id.delete_comment_option:
...@@ -124,7 +119,6 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ...@@ -124,7 +119,6 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
@Override @Override
public void onResponse(Call<String> call, Response<String> response) { public void onResponse(Call<String> call, Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
Toast.makeText(context, "Comment Deleted", Toast.LENGTH_SHORT).show();
commentList.remove(position); commentList.remove(position);
notifyDataSetChanged(); notifyDataSetChanged();
notifyItemRemoved(position); notifyItemRemoved(position);
...@@ -141,6 +135,15 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ...@@ -141,6 +135,15 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
} }
}); });
break; break;
default:
clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipData = ClipData.newPlainText("Text Copied", textViewComment.getText().toString());
if (clipboardManager != null) {
clipboardManager.setPrimaryClip(clipData);
}
Toast.makeText(context, "Comment Copied", Toast.LENGTH_SHORT).show();
break;
} }
return true; return true;
} }
...@@ -157,7 +160,14 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ...@@ -157,7 +160,14 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.comments_card, parent, false); View view = inflater.inflate(R.layout.comments_card, parent, false);
CommentsViewHolder commentsViewHolder = new CommentsViewHolder(view); final CommentsViewHolder commentsViewHolder = new CommentsViewHolder(view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Utils.openUserFragment(commentList.get(commentsViewHolder.getAdapterPosition()).getUser(), fragment.getActivity());
}
});
return commentsViewHolder; return commentsViewHolder;
} }
...@@ -173,7 +183,8 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ...@@ -173,7 +183,8 @@ public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
return commentList.size(); return commentList.size();
} }
public void setCommentList(List<Venter.Comment> commentList) { public void setCommentList(List<Venter.Comment> commentList, TextView textViewCommentLabel) {
this.commentList = commentList; this.commentList = commentList;
this.textViewCommentLabel = textViewCommentLabel;
} }
} }
\ No newline at end of file
package app.insti.adapter; package app.insti.adapter;
import android.content.Context;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentPagerAdapter;
import app.insti.api.model.Venter; import app.insti.fragment.ComplaintDetailsFragment;
import app.insti.fragment.DetailedComplaintFragment;
/** /**
* Created by Shivam Sharma on 19-09-2018. * Created by Shivam Sharma on 19-09-2018.
...@@ -14,38 +12,43 @@ import app.insti.fragment.DetailedComplaintFragment; ...@@ -14,38 +12,43 @@ import app.insti.fragment.DetailedComplaintFragment;
public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter { public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter {
Venter.Complaint detailedComplaint; private String sessionid, complaintid, userid, userProfileUrl;
Context context;
String sessionid, complaintid, userid;
int voteCount;
public ComplaintDetailsPagerAdapter(FragmentManager fm, Venter.Complaint detailedComplaint, Context context, String sessionid, String complaintid, String userid, int voteCount) { public ComplaintDetailsPagerAdapter(FragmentManager fm, String sessionid, String complaintid, String userid, String userProfileUrl) {
super(fm); super(fm);
this.context = context;
this.detailedComplaint = detailedComplaint;
this.sessionid = sessionid; this.sessionid = sessionid;
this.complaintid = complaintid; this.complaintid = complaintid;
this.userid = userid; this.userid = userid;
this.voteCount = voteCount; this.userProfileUrl = userProfileUrl;
} }
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
switch (position) { switch (position) {
case 0: case 0:
return DetailedComplaintFragment.getInstance(sessionid, complaintid, userid, voteCount); return ComplaintDetailsFragment.getInstance(sessionid, complaintid, userid, userProfileUrl);
/*
For version 2:
case 1:
return RelevantComplaintsFragment.getInstance(sessionid, userid);
*/
default: default:
return DetailedComplaintFragment.getInstance(sessionid, complaintid, userid, voteCount); return ComplaintDetailsFragment.getInstance(sessionid, complaintid, userid, userProfileUrl);
} }
} }
@Override @Override
public CharSequence getPageTitle(int position) { public CharSequence getPageTitle(int position) {
return "Complaint Details"; if (position == 0) {
return "Complaint Details";
} else {
return "Relevant Complaints";
}
} }
@Override @Override
public int getCount() { public int getCount() {
return 1; /* Update as 2 on adding RelevantComplints*/ return 1;
} }
} }
package app.insti.adapter; package app.insti.adapter;
import android.content.Context;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.app.FragmentStatePagerAdapter;
import app.insti.fragment.HomeFragment; import app.insti.fragment.ComplaintsHomeFragment;
import app.insti.fragment.MeFragment; import app.insti.fragment.ComplaintsMeFragment;
/** /**
* Created by Shivam Sharma on 15-08-2018. * Created by Shivam Sharma on 15-08-2018.
...@@ -15,26 +14,24 @@ import app.insti.fragment.MeFragment; ...@@ -15,26 +14,24 @@ import app.insti.fragment.MeFragment;
public class ComplaintFragmentViewPagerAdapter extends FragmentStatePagerAdapter { public class ComplaintFragmentViewPagerAdapter extends FragmentStatePagerAdapter {
private static final String TAG = ComplaintFragmentViewPagerAdapter.class.getSimpleName(); private String userID, sessionID, userProfileUrl;
Context context;
String userID, sessionID;
public ComplaintFragmentViewPagerAdapter(FragmentManager fm, Context context, String userID, String sessionID) { public ComplaintFragmentViewPagerAdapter(FragmentManager fm,String userID, String sessionID, String userProfileUrl) {
super(fm); super(fm);
this.context = context;
this.userID = userID; this.userID = userID;
this.sessionID = sessionID; this.sessionID = sessionID;
this.userProfileUrl = userProfileUrl;
} }
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
switch (position) { switch (position) {
case 0: case 0:
return HomeFragment.getInstance(sessionID, userID); return ComplaintsHomeFragment.getInstance(sessionID, userID, userProfileUrl);
case 1: case 1:
return MeFragment.getInstance(sessionID,userID); return ComplaintsMeFragment.getInstance(sessionID,userID, userProfileUrl);
default: default:
return HomeFragment.getInstance(sessionID, userID); return ComplaintsHomeFragment.getInstance(sessionID, userID, userProfileUrl);
} }
} }
......
...@@ -2,36 +2,26 @@ package app.insti.adapter; ...@@ -2,36 +2,26 @@ package app.insti.adapter;
import android.app.Activity; import android.app.Activity;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView; import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.format.DateUtils;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TimeZone;
import app.insti.R; import app.insti.R;
import app.insti.Utils; import app.insti.Utils;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.User;
import app.insti.api.model.Venter; import app.insti.api.model.Venter;
import app.insti.fragment.ComplaintDetailsFragment; import app.insti.fragment.ComplaintFragment;
import app.insti.utils.DateTimeUtil; import app.insti.utils.DateTimeUtil;
import app.insti.utils.GsonProvider;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -40,14 +30,15 @@ import retrofit2.Response; ...@@ -40,14 +30,15 @@ import retrofit2.Response;
* Created by Shivam Sharma on 15-08-2018. * Created by Shivam Sharma on 15-08-2018.
*/ */
public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class ComplaintsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private LayoutInflater inflater; private LayoutInflater inflater;
private Activity context; private Activity context;
private String sessionID; private String sessionID;
private String userID; private String userID;
private static final String TAG = ComplaintsRecyclerViewAdapter.class.getSimpleName(); private String userProfileUrl;
List<Venter.Complaint> complaintList = new ArrayList<>(); private static final String TAG = ComplaintsAdapter.class.getSimpleName();
private List<Venter.Complaint> complaintList = new ArrayList<>();
public class ComplaintsViewHolder extends RecyclerView.ViewHolder { public class ComplaintsViewHolder extends RecyclerView.ViewHolder {
...@@ -61,9 +52,7 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -61,9 +52,7 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private TextView textViewUserName; private TextView textViewUserName;
private TextView textViewReportDate; private TextView textViewReportDate;
private TextView textViewStatus; private TextView textViewStatus;
private int pos; private int pos;
private int voteCount = 0;
public ComplaintsViewHolder(View currentView) { public ComplaintsViewHolder(View currentView) {
super(currentView); super(currentView);
...@@ -81,7 +70,6 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -81,7 +70,6 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public void bindHolder(final int position) { public void bindHolder(final int position) {
this.pos = position; this.pos = position;
Log.i(TAG, "json = " + GsonProvider.getGsonOutput().toJson(complaintList.get(pos)));
cardView.setOnClickListener(new View.OnClickListener() { cardView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
...@@ -89,10 +77,11 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -89,10 +77,11 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
bundle.putString("id", complaintList.get(pos).getComplaintID()); bundle.putString("id", complaintList.get(pos).getComplaintID());
bundle.putString("sessionId", sessionID); bundle.putString("sessionId", sessionID);
bundle.putString("userId", userID); bundle.putString("userId", userID);
ComplaintDetailsFragment complaintDetailsFragment = new ComplaintDetailsFragment(); bundle.putString("userProfileUrl", userProfileUrl);
complaintDetailsFragment.setArguments(bundle); ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context; AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintDetailsFragment).addToBackStack(TAG).commit(); activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintFragment).addToBackStack(TAG).commit();
} }
}); });
...@@ -124,18 +113,19 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -124,18 +113,19 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
bundle.putString("id", complaintList.get(pos).getComplaintID()); bundle.putString("id", complaintList.get(pos).getComplaintID());
bundle.putString("sessionId", sessionID); bundle.putString("sessionId", sessionID);
bundle.putString("userId", userID); bundle.putString("userId", userID);
ComplaintDetailsFragment complaintDetailsFragment = new ComplaintDetailsFragment(); bundle.putString("userProfileUrl", userProfileUrl);
complaintDetailsFragment.setArguments(bundle); ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context; AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintDetailsFragment).addToBackStack(TAG).commit(); activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintFragment).addToBackStack(TAG).commit();
} }
}); });
buttonVotes.setOnClickListener(new View.OnClickListener() { buttonVotes.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (voteCount == 0) { if (complaintList.get(position).getVoteCount() == 0) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.upVote("sessionid=" + sessionID, complaintList.get(pos).getComplaintID()).enqueue(new Callback<Venter.Complaint>() { retrofitInterface.upVote("sessionid=" + sessionID, complaintList.get(pos).getComplaintID(), 1).enqueue(new Callback<Venter.Complaint>() {
@Override @Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) { public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -143,8 +133,26 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -143,8 +133,26 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (complaint != null) { if (complaint != null) {
textViewVotes.setText(String.valueOf(complaint.getUsersUpVoted().size())); textViewVotes.setText(String.valueOf(complaint.getUsersUpVoted().size()));
} }
Toast.makeText(context, "You have Up Voted this complaint", Toast.LENGTH_SHORT).show(); complaintList.get(position).setVoteCount(1);
voteCount++; }
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in up vote: " + t.toString());
}
});
} else if (complaintList.get(position).getVoteCount() == 1) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.upVote("sessionid=" + sessionID, complaintList.get(pos).getComplaintID(), 0).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
Venter.Complaint complaint = response.body();
if (complaint != null) {
textViewVotes.setText(String.valueOf(complaint.getUsersUpVoted().size()));
}
complaintList.get(position).setVoteCount(0);
} }
} }
...@@ -153,8 +161,6 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -153,8 +161,6 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
Log.i(TAG, "failure in up vote: " + t.toString()); Log.i(TAG, "failure in up vote: " + t.toString());
} }
}); });
} else {
Toast.makeText(context, "You have already UpVoted this complaint", Toast.LENGTH_SHORT).show();
} }
} }
}); });
...@@ -164,10 +170,11 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -164,10 +170,11 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
} }
} }
public ComplaintsRecyclerViewAdapter(Activity ctx, String sessionID, String userID) { public ComplaintsAdapter(Activity ctx, String sessionID, String userID, String userProfileUrl) {
this.context = ctx; this.context = ctx;
this.sessionID = sessionID; this.sessionID = sessionID;
this.userID = userID; this.userID = userID;
this.userProfileUrl = userProfileUrl;
inflater = LayoutInflater.from(ctx); inflater = LayoutInflater.from(ctx);
} }
...@@ -181,6 +188,13 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -181,6 +188,13 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@Override @Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
List<User> userList = complaintList.get(position).getUsersUpVoted();
for (User user : userList) {
if (user.getUserID().equals(userID))
complaintList.get(position).setVoteCount(1);
else
complaintList.get(position).setVoteCount(0);
}
if (viewHolder instanceof ComplaintsViewHolder) { if (viewHolder instanceof ComplaintsViewHolder) {
((ComplaintsViewHolder) viewHolder).bindHolder(position); ((ComplaintsViewHolder) viewHolder).bindHolder(position);
} }
......
...@@ -20,7 +20,6 @@ public class ImageViewPagerAdapter extends FragmentPagerAdapter { ...@@ -20,7 +20,6 @@ public class ImageViewPagerAdapter extends FragmentPagerAdapter {
private static final String TAG = ImageViewPagerAdapter.class.getSimpleName(); private static final String TAG = ImageViewPagerAdapter.class.getSimpleName();
private List<String> images = new ArrayList<>(); private List<String> images = new ArrayList<>();
Venter.Complaint detailedComplaint;
public ImageViewPagerAdapter(FragmentManager fragmentManager, List<String> images) { public ImageViewPagerAdapter(FragmentManager fragmentManager, List<String> images) {
super(fragmentManager); super(fragmentManager);
...@@ -29,11 +28,7 @@ public class ImageViewPagerAdapter extends FragmentPagerAdapter { ...@@ -29,11 +28,7 @@ public class ImageViewPagerAdapter extends FragmentPagerAdapter {
public ImageViewPagerAdapter(FragmentManager fragmentManager, Venter.Complaint detailedComplaint){ public ImageViewPagerAdapter(FragmentManager fragmentManager, Venter.Complaint detailedComplaint){
super(fragmentManager); super(fragmentManager);
this.detailedComplaint = detailedComplaint; images.addAll(detailedComplaint.getImages());
for (String image: detailedComplaint.getImages()){
images.add(image);
}
} }
@Override @Override
...@@ -54,7 +49,7 @@ public class ImageViewPagerAdapter extends FragmentPagerAdapter { ...@@ -54,7 +49,7 @@ public class ImageViewPagerAdapter extends FragmentPagerAdapter {
return new AddImageFragment(); return new AddImageFragment();
}else { }else {
Log.i(TAG,"calling 2"); Log.i(TAG,"calling 2");
return ImageFragment.newInstance(images.get(position),position); return ImageFragment.newInstance(images.get(position));
} }
} }
} }
\ No newline at end of file
package app.insti.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
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.model.User;
import de.hdodenhof.circleimageview.CircleImageView;
public class UpVotesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final String TAG = CommentsAdapter.class.getSimpleName();
private LayoutInflater inflater;
private Fragment fragment;
private List<User> userList = new ArrayList<>();
public UpVotesAdapter(Fragment fragment, Context context) {
inflater = LayoutInflater.from(context);
this.fragment = fragment;
}
public class UpVotesViewHolder extends RecyclerView.ViewHolder {
private CardView cardView;
private CircleImageView circleImageView;
private TextView textViewName;
UpVotesViewHolder(View itemView) {
super(itemView);
cardView = itemView.findViewById(R.id.cardViewUpVote);
textViewName = itemView.findViewById(R.id.textViewUserUpVoteName);
circleImageView = itemView.findViewById(R.id.circleImageViewUserUpVoteImage);
cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Utils.openUserFragment(userList.get(getAdapterPosition()), fragment.getActivity());
}
});
}
private void bindHolder(final int position) {
final User user = userList.get(position);
try {
String profileUrl = user.getUserProfilePictureUrl();
Log.i(TAG, "PROFILE URL: " + profileUrl);
Picasso.get().load(profileUrl).placeholder(R.drawable.user_placeholder).into(circleImageView);
textViewName.setText(user.getUserName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = inflater.inflate(R.layout.vote_up_card, viewGroup, false);
return new UpVotesViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
if (viewHolder instanceof UpVotesViewHolder) {
((UpVotesViewHolder) viewHolder).bindHolder(i);
}
}
@Override
public int getItemCount() {
return userList.size();
}
public void setUpVoteList(List<User> userList) {
this.userList = userList;
}
}
\ No newline at end of file
package app.insti.adapter; package app.insti.adapter;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -20,7 +21,6 @@ import app.insti.api.model.User; ...@@ -20,7 +21,6 @@ import app.insti.api.model.User;
public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
private List<User> userList; private List<User> userList;
private Context context;
private Fragment fragment; private Fragment fragment;
public UserAdapter(List<User> userList, Fragment mFragment) { public UserAdapter(List<User> userList, Fragment mFragment) {
...@@ -28,9 +28,10 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { ...@@ -28,9 +28,10 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
fragment = mFragment; fragment = mFragment;
} }
@NonNull
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext(); Context context = parent.getContext();
View v = LayoutInflater.from(context) View v = LayoutInflater.from(context)
.inflate(R.layout.feed_card, parent, false); .inflate(R.layout.feed_card, parent, false);
final ViewHolder postViewHolder = new ViewHolder(v); final ViewHolder postViewHolder = new ViewHolder(v);
...@@ -46,7 +47,7 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { ...@@ -46,7 +47,7 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
} }
@Override @Override
public void onBindViewHolder(ViewHolder holder, int position) { public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
User user = userList.get(position); User user = userList.get(position);
holder.userName.setText(user.getUserName()); holder.userName.setText(user.getUserName());
if (user.getCurrentRole() == null || user.getCurrentRole().equals("")) { if (user.getCurrentRole() == null || user.getCurrentRole().equals("")) {
...@@ -72,15 +73,15 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { ...@@ -72,15 +73,15 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
} }
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
public TextView userName; private TextView userName;
public TextView role; private TextView role;
public ImageView image; public ImageView image;
public ViewHolder(View itemView) { public ViewHolder(View itemView) {
super(itemView); super(itemView);
userName = (TextView) itemView.findViewById(R.id.object_title); userName = itemView.findViewById(R.id.object_title);
role = (TextView) itemView.findViewById(R.id.object_subtitle); role = itemView.findViewById(R.id.object_subtitle);
image = (ImageView) itemView.findViewById(R.id.object_picture); image = itemView.findViewById(R.id.object_picture);
} }
} }
} }
package app.insti.api; package app.insti.api;
import android.app.Activity;
import android.content.Context;
import android.util.Log; import android.util.Log;
import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.MapView;
...@@ -21,8 +18,8 @@ import com.google.android.gms.maps.model.MarkerOptions; ...@@ -21,8 +18,8 @@ import com.google.android.gms.maps.model.MarkerOptions;
public class LocationAPIUtils { public class LocationAPIUtils {
private static final String TAG = LocationAPIUtils.class.getSimpleName(); private static final String TAG = LocationAPIUtils.class.getSimpleName();
GoogleMap googleMap; private GoogleMap googleMap;
MapView mMapView; private MapView mMapView;
public LocationAPIUtils(GoogleMap googleMap, MapView mMapView) { public LocationAPIUtils(GoogleMap googleMap, MapView mMapView) {
this.googleMap = googleMap; this.googleMap = googleMap;
......
...@@ -123,8 +123,8 @@ public interface RetrofitInterface { ...@@ -123,8 +123,8 @@ public interface RetrofitInterface {
@GET("venter/complaints/{complaintId}") @GET("venter/complaints/{complaintId}")
Call<Venter.Complaint> getComplaint(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId); Call<Venter.Complaint> getComplaint(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId);
@PUT("venter/complaints/{complaintId}") @GET("venter/complaints/{complaintId}/upvote")
Call<Venter.Complaint> upVote(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId); Call<Venter.Complaint> upVote(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId, @Query("action") int count);
@POST("venter/complaints") @POST("venter/complaints")
Call<ComplaintCreateResponse> postComplaint(@Header("Cookie") String sessionId, @Body ComplaintCreateRequest complaintCreateRequest); Call<ComplaintCreateResponse> postComplaint(@Header("Cookie") String sessionId, @Body ComplaintCreateRequest complaintCreateRequest);
......
...@@ -4,59 +4,38 @@ import android.support.annotation.NonNull; ...@@ -4,59 +4,38 @@ import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.List; import java.util.List;
import app.insti.api.model.User;
/** /**
* Created by Shivam Sharma on 04-09-2018. * Created by Shivam Sharma on 04-09-2018.
*/ */
public class Venter { public class Venter {
public Venter(){ public static class Complaint{
}
public static class Complaint {
@NonNull
@SerializedName("id") @SerializedName("id")
String complaintID; private String complaintID;
@SerializedName("created_by") @SerializedName("created_by")
User complaintCreatedBy; private User complaintCreatedBy;
@SerializedName("description") @SerializedName("description")
String description; private String description;
@SerializedName("report_date") @SerializedName("report_date")
String complaintReportDate; private String complaintReportDate;
@SerializedName("status") @SerializedName("status")
String status; private String status;
@SerializedName("latitude") @SerializedName("latitude")
Float latitude; private Float latitude;
@SerializedName("longitude") @SerializedName("longitude")
Float longitude; private Float longitude;
@SerializedName("location_description") @SerializedName("location_description")
String locationDescription; private String locationDescription;
@SerializedName("tags") @SerializedName("tags")
List<TagUri> tags; private List<TagUri> tags;
@SerializedName("users_up_voted") @SerializedName("users_up_voted")
List<User> usersUpVoted; private List<User> usersUpVoted;
@SerializedName("images") @SerializedName("images")
List<String> images; private List<String> images;
@SerializedName("comments") @SerializedName("comments")
List<Comment> comment; private List<Comment> comment;
private int voteCount;
public Complaint(@NonNull String complaintID, User complaintCreatedBy, String description, String complaintReportDate, String status, Float latitude, Float longitude, String locationDescription, List<TagUri> tags, List<User> usersUpVoted, List<String> images, List<Comment> comment) {
this.complaintID = complaintID;
this.complaintCreatedBy = complaintCreatedBy;
this.description = description;
this.complaintReportDate = complaintReportDate;
this.status = status;
this.latitude = latitude;
this.longitude = longitude;
this.locationDescription = locationDescription;
this.tags = tags;
this.usersUpVoted = usersUpVoted;
this.images = images;
this.comment = comment;
}
@NonNull @NonNull
public String getComplaintID() { public String getComplaintID() {
...@@ -154,14 +133,21 @@ public class Venter { ...@@ -154,14 +133,21 @@ public class Venter {
public void setComment(List<Comment> comment) { public void setComment(List<Comment> comment) {
this.comment = comment; this.comment = comment;
} }
public int getVoteCount() {
return voteCount;
}
public void setVoteCount(int voteCount) {
this.voteCount = voteCount;
}
} }
public static class TagUri { public static class TagUri {
@NonNull
@SerializedName("id") @SerializedName("id")
String id; private String id;
@SerializedName("tag_uri") @SerializedName("tag_uri")
String tagUri; private String tagUri;
@NonNull @NonNull
public String getId() { public String getId() {
...@@ -183,15 +169,14 @@ public class Venter { ...@@ -183,15 +169,14 @@ public class Venter {
public static class Comment { public static class Comment {
@NonNull
@SerializedName("id") @SerializedName("id")
String id; private String id;
@SerializedName("time") @SerializedName("time")
String time; private String time;
@SerializedName("text") @SerializedName("text")
String text; private String text;
@SerializedName("commented_by") @SerializedName("commented_by")
User commented_by; private User commented_by;
@NonNull @NonNull
public String getId() { public String getId() {
......
package app.insti.fragment; package app.insti.fragment;
import android.content.res.TypedArray; import android.content.res.ColorStateList;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager; import android.support.v4.widget.NestedScrollView;
import android.util.DisplayMetrics; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.util.Objects; import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import app.insti.R; import app.insti.R;
import app.insti.Utils; import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.adapter.ComplaintDetailsPagerAdapter; import app.insti.adapter.CommentsAdapter;
import app.insti.adapter.ImageViewPagerAdapter; import app.insti.adapter.UpVotesAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.User; import app.insti.api.model.User;
import app.insti.api.model.Venter; import app.insti.api.model.Venter;
import me.relex.circleindicator.CircleIndicator; import app.insti.api.request.CommentCreateRequest;
import app.insti.utils.DateTimeUtil;
import de.hdodenhof.circleimageview.CircleImageView;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
public class ComplaintDetailsFragment extends Fragment { public class ComplaintDetailsFragment extends Fragment {
private static final String TAG = ComplaintDetailsFragment.class.getSimpleName(); private final String TAG = ComplaintDetailsFragment.class.getSimpleName();
TabLayout slidingTabLayout; private Venter.Complaint detailedComplaint;
ViewPager viewPager; private MapView mMapView;
View mview; private TextView textViewUserName;
private String complaintId, sessionID, userId; private TextView textViewReportDate;
private ComplaintDetailsPagerAdapter complaintDetailsPagerAdapter; private TextView textViewLocation;
CircleIndicator circleIndicator; private TextView textViewDescription;
private int voteCount = 0; private TextView textViewCommentLabel;
private TextView textViewVoteUpLabel;
private TextView textViewStatus;
private LinearLayout tagsLayout;
private EditText editTextComment;
private ImageButton imageButtonSend;
private CircleImageView circleImageViewCommentUserImage;
private RecyclerView recyclerViewComments;
private RecyclerView recyclerViewUpVotes;
private Button buttonVoteUp;
private static String sId, cId, uId, uProfileUrl;
private CommentsAdapter commentListAdapter;
private UpVotesAdapter upVotesAdapter;
private List<Venter.Comment> commentList;
private List<User> upVotesList;
private LinearLayout linearLayoutTags;
private ScrollView layoutUpVotes;
private NestedScrollView nestedScrollView;
public static ComplaintDetailsFragment getInstance(String sessionid, String complaintid, String userid, String userProfileUrl) {
sId = sessionid;
cId = complaintid;
uId = userid;
uProfileUrl = userProfileUrl;
return new ComplaintDetailsFragment();
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_complaint_details, container, false); View view = inflater.inflate(R.layout.fragment_complaint_details, container, false);
commentList = new ArrayList<>();
initialiseViews(view);
upVotesList = new ArrayList<>();
commentListAdapter = new CommentsAdapter(getContext(), sId, uId, this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
upVotesAdapter = new UpVotesAdapter(this, getContext());
recyclerViewComments.setLayoutManager(linearLayoutManager);
recyclerViewUpVotes.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerViewComments.setHasFixedSize(true);
recyclerViewUpVotes.setHasFixedSize(true);
recyclerViewComments.setAdapter(commentListAdapter);
recyclerViewUpVotes.setAdapter(upVotesAdapter);
upVotesAdapter.setUpVoteList(upVotesList);
upVotesAdapter.notifyDataSetChanged();
mMapView = view.findViewById(R.id.google_map);
mMapView.onCreate(savedInstanceState);
mMapView.onResume();
LinearLayout imageViewHolder = view.findViewById(R.id.image_holder_view); try {
CollapsingToolbarLayout.LayoutParams layoutParams = new CollapsingToolbarLayout.LayoutParams MapsInitializer.initialize(getActivity().getApplicationContext());
(CollapsingToolbarLayout.LayoutParams.MATCH_PARENT, } catch (Exception e) {
getResources().getDisplayMetrics().heightPixels / 2); e.printStackTrace();
imageViewHolder.setLayoutParams(layoutParams); }
imageButtonSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!(editTextComment.getText().toString().trim().isEmpty())) {
postComment();
} else {
Toast.makeText(getContext(), "Please enter comment text", Toast.LENGTH_SHORT).show();
}
}
});
buttonVoteUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
upVote(detailedComplaint);
}
});
slidingTabLayout = view.findViewById(R.id.sliding_tab_layout);
circleIndicator = view.findViewById(R.id.indicator);
this.mview = view;
return view; return view;
} }
@Override private void initialiseViews(View view) {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { nestedScrollView = view.findViewById(R.id.nestedScrollViewComplaintDetail);
super.onViewCreated(view, savedInstanceState); textViewUserName = view.findViewById(R.id.textViewUserName);
textViewReportDate = view.findViewById(R.id.textViewReportDate);
textViewLocation = view.findViewById(R.id.textViewLocation);
textViewDescription = view.findViewById(R.id.textViewDescription);
textViewStatus = view.findViewById(R.id.textViewStatus);
textViewCommentLabel = view.findViewById(R.id.comment_label);
textViewVoteUpLabel = view.findViewById(R.id.up_vote_label);
tagsLayout = view.findViewById(R.id.tags_layout);
linearLayoutTags = view.findViewById(R.id.linearLayoutTags);
layoutUpVotes = view.findViewById(R.id.layoutUpVotes);
recyclerViewComments = view.findViewById(R.id.recyclerViewComments);
recyclerViewUpVotes = view.findViewById(R.id.recyclerViewUpVotes);
editTextComment = view.findViewById(R.id.edit_comment);
imageButtonSend = view.findViewById(R.id.send_comment);
circleImageViewCommentUserImage = view.findViewById(R.id.comment_user_image);
buttonVoteUp = view.findViewById(R.id.buttonVoteUp);
}
Bundle bundle = getArguments(); public void setDetailedComplaint(Venter.Complaint detailedComplaint) {
complaintId = bundle.getString("id"); this.detailedComplaint = detailedComplaint;
sessionID = bundle.getString("sessionId"); populateViews();
userId = bundle.getString("userId"); }
if (bundle != null) { private void populateViews() {
Log.i(TAG, "bundle != null"); try {
callServerToGetDetailedComplaint(); buttonVoteUp.setText("UpVote");
textViewUserName.setText(detailedComplaint.getComplaintCreatedBy().getUserName());
String time = DateTimeUtil.getDate(detailedComplaint.getComplaintReportDate().toString());
Log.i(TAG, " time: " + time);
textViewReportDate.setText(time);
textViewLocation.setText(detailedComplaint.getLocationDescription());
textViewDescription.setText(detailedComplaint.getDescription());
textViewStatus.setText(detailedComplaint.getStatus().toUpperCase());
if (detailedComplaint.getStatus().equalsIgnoreCase("Reported")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorRed)));
textViewStatus.setTextColor(getContext().getResources().getColor(R.color.primaryTextColor));
} else if (detailedComplaint.getStatus().equalsIgnoreCase("In Progress")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorSecondary)));
textViewStatus.setTextColor(getContext().getResources().getColor(R.color.secondaryTextColor));
} else if (detailedComplaint.getStatus().equalsIgnoreCase("Resolved")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorGreen)));
textViewStatus.setTextColor(getContext().getResources().getColor(R.color.secondaryTextColor));
}
addTagsToView(detailedComplaint);
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);
} catch (Exception e) {
e.printStackTrace();
} }
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap mGoogleMap) {
GoogleMap googleMap = mGoogleMap;
// For dropping a marker at a point on the Map
LatLng loc = new LatLng(detailedComplaint.getLatitude(), detailedComplaint.getLongitude());
if (loc != null) {
googleMap.addMarker(new MarkerOptions().position(loc).title(detailedComplaint.getLatitude().toString() + " , " + detailedComplaint.getLongitude().toString()).snippet(detailedComplaint.getLocationDescription()));
// For zooming automatically to the location of the marker
CameraPosition cameraPosition = new CameraPosition.Builder().target(loc).zoom(16).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
}
});
} }
private void callServerToGetDetailedComplaint() { private void postComment() {
final CommentCreateRequest commentCreateRequest = new CommentCreateRequest(editTextComment.getText().toString());
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getComplaint("sessionid=" + sessionID, complaintId).enqueue(new Callback<Venter.Complaint>() { retrofitInterface.postComment("sessionid=" + sId, cId, commentCreateRequest).enqueue(new Callback<Venter.Comment>() {
@Override @Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) { public void onResponse(Call<Venter.Comment> call, Response<Venter.Comment> response) {
if (response.body() != null) { if (response.isSuccessful()) {
Venter.Complaint complaint = response.body(); Venter.Comment comment = response.body();
for (User currentUser : complaint.getUsersUpVoted()) { addNewComment(comment);
if (currentUser.getUserID().equals(userId)) { editTextComment.setText(null);
voteCount = 1;
}
}
initViewPagerForImages(complaint);
initTabViews(complaint);
} }
} }
@Override @Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) { public void onFailure(Call<Venter.Comment> call, Throwable t) {
if (t != null) { Log.i(TAG, "failure in posting comments: " + t.toString());
Log.i(TAG, "error and t = " + t.toString());
}
} }
}); });
} }
private void initViewPagerForImages(Venter.Complaint detailedComplaint) { private void addNewComment(Venter.Comment newComment) {
commentList.add(newComment);
viewPager = mview.findViewById(R.id.complaint_image_view_pager); commentListAdapter.setCommentList(commentList, textViewCommentLabel);
if (viewPager != null) { commentListAdapter.notifyItemInserted(commentList.indexOf(newComment));
try { commentListAdapter.notifyItemRangeChanged(0, commentListAdapter.getItemCount());
ImageViewPagerAdapter imageFragmentPagerAdapter = new ImageViewPagerAdapter(getChildFragmentManager(), detailedComplaint); textViewCommentLabel.setText("Comments (" + commentList.size() + ")");
recyclerViewComments.post(new Runnable() {
viewPager.setAdapter(imageFragmentPagerAdapter); @Override
circleIndicator.setViewPager(viewPager); public void run() {
imageFragmentPagerAdapter.registerDataSetObserver(circleIndicator.getDataSetObserver()); MainActivity.hideKeyboard(getActivity());
viewPager.getAdapter().notifyDataSetChanged();
synchronized (viewPager) {
viewPager.notifyAll();
}
} catch (Exception e) {
e.printStackTrace();
} }
} });
} }
private void initTabViews(final Venter.Complaint detailedComplaint) { private void addCommentsToView(Venter.Complaint detailedComplaint) {
for (Venter.Comment comment : detailedComplaint.getComment())
try { commentList.add(comment);
if (detailedComplaint != null) { commentListAdapter.setCommentList(commentList, textViewCommentLabel);
viewPager = mview.findViewById(R.id.tab_viewpager_details); commentListAdapter.notifyDataSetChanged();
if (viewPager != null) { }
Log.i(TAG, "viewPager != null");
complaintDetailsPagerAdapter = new ComplaintDetailsPagerAdapter(getChildFragmentManager(), detailedComplaint, getContext(), sessionID, complaintId, userId, voteCount);
viewPager.setAdapter(complaintDetailsPagerAdapter);
slidingTabLayout.setupWithViewPager(viewPager);
slidingTabLayout.post(new Runnable() {
@Override
public void run() {
int tablLayoutWidth = slidingTabLayout.getWidth();
DisplayMetrics metrics = new DisplayMetrics();
Objects.requireNonNull(getActivity()).getWindowManager().getDefaultDisplay().getMetrics(metrics);
int deviceWidth = metrics.widthPixels;
if (tablLayoutWidth <= deviceWidth) {
final TypedArray styledAttributes = Objects.requireNonNull(ComplaintDetailsFragment.this.getActivity()).getTheme().obtainStyledAttributes(
new int[]{android.R.attr.actionBarSize});
int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
styledAttributes.recycle();
// Replace second parameter to mActionBarSize after adding "Relevant Complaints" private void upVote(final Venter.Complaint detailedComplaint) {
AppBarLayout.LayoutParams layoutParams = new AppBarLayout.LayoutParams(AppBarLayout.LayoutParams.MATCH_PARENT, RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
0); if (detailedComplaint.getVoteCount() == 0) {
slidingTabLayout.setLayoutParams(layoutParams); retrofitInterface.upVote("sessionid=" + sId, cId, 1).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
Venter.Complaint complaint = response.body();
detailedComplaint.setVoteCount(1);
addVotesToView(complaint);
onUpvote();
}
}
slidingTabLayout.setTabMode(TabLayout.MODE_FIXED); @Override
slidingTabLayout.setTabGravity(TabLayout.GRAVITY_FILL); public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in up vote: " + t.toString());
}
});
} else if (detailedComplaint.getVoteCount() ==1){
retrofitInterface.upVote("sessionid=" + sId, cId, 0).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
Venter.Complaint complaint = response.body();
detailedComplaint.setVoteCount(0);
addVotesToView(complaint);
}
}
} else { @Override
slidingTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); public void onFailure(Call<Venter.Complaint> call, Throwable t) {
} Log.i(TAG, "failure in up vote: " + t.toString());
} }
}); });
}
}
slidingTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { public void addVotesToView(Venter.Complaint detailedComplaint) {
@Override upVotesList.clear();
public void onTabSelected(TabLayout.Tab tab) { for (User users : detailedComplaint.getUsersUpVoted()) {
viewPager.setCurrentItem(tab.getPosition()); upVotesList.add(users);
} }
upVotesAdapter.setUpVoteList(upVotesList);
upVotesAdapter.notifyDataSetChanged();
textViewVoteUpLabel.setText("Up Votes (" + detailedComplaint.getUsersUpVoted().size() + ")");
}
@Override private void onUpvote(){
public void onTabUnselected(TabLayout.Tab tab) { layoutUpVotes.post(new Runnable() {
@Override
public void run() {
nestedScrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
} private void addTagsToView(Venter.Complaint detailedComplaint) {
for (Venter.TagUri tagUri : detailedComplaint.getTags()) {
TextView textViewTags = new TextView(getContext());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(10,10,10,10);
textViewTags.setLayoutParams(layoutParams);
textViewTags.setText(tagUri.getTagUri());
textViewTags.setBackgroundResource(R.drawable.customborder);
textViewTags.setPadding(30,25,30,25);
int fontDp = 4;
float density = getContext().getResources().getDisplayMetrics().density;
int fontPixel = (int) (fontDp * density);
textViewTags.setTextSize(fontPixel);
textViewTags.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorTagGreen)));
textViewTags.setTextColor(getContext().getResources().getColor(R.color.primaryTextColor));
tagsLayout.setLayoutParams(layoutParams);
tagsLayout.addView(textViewTags);
}
}
@Override @Override
public void onTabReselected(TabLayout.Tab tab) { public void onResume() {
super.onResume();
mMapView.onResume();
}
} @Override
}); public void onPause() {
super.onPause();
mMapView.onPause();
}
DetailedComplaintFragment detailedComplaintFragment = (DetailedComplaintFragment) getChildFragmentManager().findFragmentByTag( @Override
"android:switcher:" + R.id.tab_viewpager_details + ":0" public void onDestroy() {
); super.onDestroy();
mMapView.onDestroy();
}
if (detailedComplaintFragment != null) @Override
detailedComplaintFragment.setDetailedComplaint(detailedComplaint); public void onLowMemory() {
} super.onLowMemory();
} mMapView.onLowMemory();
} catch (Exception e) {
e.printStackTrace();
}
} }
} }
\ No newline at end of file
package app.insti.fragment; package app.insti.fragment;
import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout; import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.LinearLayout;
import app.insti.Constants; import java.util.Objects;
import app.insti.R;
import app.insti.adapter.ComplaintFragmentViewPagerAdapter;
public class ComplaintFragment extends BaseFragment {
private static String TAG = ComplaintFragment.class.getSimpleName(); import app.insti.R;
String userID; import app.insti.Utils;
Context context; import app.insti.adapter.ComplaintDetailsPagerAdapter;
private Button buttonVentIssues; import app.insti.adapter.ImageViewPagerAdapter;
private ViewPager viewPager; import app.insti.api.RetrofitInterface;
import app.insti.api.model.User;
import app.insti.api.model.Venter;
import me.relex.circleindicator.CircleIndicator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ComplaintFragment extends Fragment {
private static final String TAG = ComplaintFragment.class.getSimpleName();
private TabLayout slidingTabLayout; private TabLayout slidingTabLayout;
private CollapsingToolbarLayout collapsingToolbarLayout; private ViewPager viewPager;
private View mview;
public ComplaintFragment() { private String complaintId, sessionID, userId, userProfileUrl;
// Required empty public constructor private CircleIndicator circleIndicator;
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_complaint, container, false); View view = inflater.inflate(R.layout.fragment_complaint, container, false);
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Complaints/Suggestions");
Bundle bundle = getArguments();
userID = bundle.getString(Constants.USER_ID);
collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setTitleEnabled(false);
viewPager = (ViewPager) view.findViewById(R.id.tab_viewpager);
slidingTabLayout = (TabLayout) view.findViewById(R.id.sliding_tab_layout);
context = getContext();
buttonVentIssues = view.findViewById(R.id.buttonVentIssues);
LinearLayout imageViewHolder = view.findViewById(R.id.image_holder_view);
buttonVentIssues.setOnClickListener(new View.OnClickListener() { CollapsingToolbarLayout.LayoutParams layoutParams = new CollapsingToolbarLayout.LayoutParams
@Override (CollapsingToolbarLayout.LayoutParams.MATCH_PARENT,
public void onClick(View v) { getResources().getDisplayMetrics().heightPixels / 2);
FileComplaintFragment fileComplaintFragment = new FileComplaintFragment(); imageViewHolder.setLayoutParams(layoutParams);
fileComplaintFragment.setArguments(getArguments());
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.framelayout_for_fragment, fileComplaintFragment, fileComplaintFragment.getTag());
fragmentTransaction.addToBackStack("Complaint Fragment").commit();
}
});
viewPager = view.findViewById(R.id.tab_viewpager);
slidingTabLayout = view.findViewById(R.id.sliding_tab_layout); slidingTabLayout = view.findViewById(R.id.sliding_tab_layout);
circleIndicator = view.findViewById(R.id.indicator);
if (viewPager != null) { this.mview = view;
setupViewPager(viewPager);
}
return view; return view;
} }
private void setupViewPager(final ViewPager viewPager) { @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
viewPager.setAdapter(new ComplaintFragmentViewPagerAdapter(getChildFragmentManager(), getContext(), userID, getArguments().getString(Constants.SESSION_ID))); super.onViewCreated(view, savedInstanceState);
slidingTabLayout.setupWithViewPager(viewPager);
slidingTabLayout.post(new Runnable() {
@Override
public void run() {
int tabLayoutWidth = slidingTabLayout.getWidth();
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int deviceWidth = metrics.widthPixels;
if (tabLayoutWidth <= (deviceWidth + 1)) {
final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(
new int[]{android.R.attr.actionBarSize}
);
int mActionBarSize = (int) styledAttributes.getDimension(0, 0); Bundle bundle = getArguments();
styledAttributes.recycle(); if (bundle != null) {
complaintId = bundle.getString("id");
sessionID = bundle.getString("sessionId");
userId = bundle.getString("userId");
userProfileUrl = bundle.getString("userProfileUrl");
callServerToGetDetailedComplaint();
}
}
AppBarLayout.LayoutParams layoutParams = new AppBarLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, private void callServerToGetDetailedComplaint() {
mActionBarSize);
slidingTabLayout.setLayoutParams(layoutParams); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
slidingTabLayout.setTabMode(TabLayout.MODE_FIXED); retrofitInterface.getComplaint("sessionid=" + sessionID, complaintId).enqueue(new Callback<Venter.Complaint>() {
slidingTabLayout.setTabGravity(TabLayout.GRAVITY_FILL); @Override
} else { public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
slidingTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); if (response.body() != null) {
Venter.Complaint complaint = response.body();
if (complaint != null) {
for (User currentUser : complaint.getUsersUpVoted()) {
if (currentUser.getUserID().equals(userId)) {
complaint.setVoteCount(1);
} else {
complaint.setVoteCount(0);
}
}
}
initViewPagerForImages(complaint);
initTabViews(complaint);
} }
} }
});
slidingTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override @Override
public void onTabSelected(TabLayout.Tab tab) { public void onFailure(Call<Venter.Complaint> call, Throwable t) {
viewPager.setCurrentItem(tab.getPosition()); if (t != null) {
Log.i(TAG, "error and t = " + t.toString());
}
} }
});
}
@Override private void initViewPagerForImages(Venter.Complaint detailedComplaint) {
public void onTabUnselected(TabLayout.Tab tab) {
viewPager = mview.findViewById(R.id.complaint_image_view_pager);
if (viewPager != null) {
try {
ImageViewPagerAdapter imageFragmentPagerAdapter = new ImageViewPagerAdapter(getChildFragmentManager(), detailedComplaint);
viewPager.setAdapter(imageFragmentPagerAdapter);
circleIndicator.setViewPager(viewPager);
imageFragmentPagerAdapter.registerDataSetObserver(circleIndicator.getDataSetObserver());
Objects.requireNonNull(viewPager.getAdapter()).notifyDataSetChanged();
synchronized (viewPager) {
viewPager.notifyAll();
}
} catch (Exception e) {
e.printStackTrace();
} }
}
}
@Override private void initTabViews(final Venter.Complaint detailedComplaint) {
public void onTabReselected(TabLayout.Tab tab) { try {
if (detailedComplaint != null) {
viewPager = mview.findViewById(R.id.tab_viewpager_details);
if (viewPager != null) {
Log.i(TAG, "viewPager != null");
ComplaintDetailsPagerAdapter complaintDetailsPagerAdapter = new ComplaintDetailsPagerAdapter(getChildFragmentManager(), sessionID, complaintId, userId, userProfileUrl);
viewPager.setAdapter(complaintDetailsPagerAdapter);
slidingTabLayout.setupWithViewPager(viewPager);
slidingTabLayout.post(new Runnable() {
@Override
public void run() {
int tablLayoutWidth = slidingTabLayout.getWidth();
DisplayMetrics metrics = new DisplayMetrics();
Objects.requireNonNull(getActivity()).getWindowManager().getDefaultDisplay().getMetrics(metrics);
int deviceWidth = metrics.widthPixels;
if (tablLayoutWidth <= deviceWidth) {
final TypedArray styledAttributes = Objects.requireNonNull(ComplaintFragment.this.getActivity()).getTheme().obtainStyledAttributes(
new int[]{android.R.attr.actionBarSize});
// int mActionBarSize = (int) styledAttributes.getDimension(0, 0); For future Uae
styledAttributes.recycle();
// Replace second parameter to mActionBarSize after adding "Relevant Complaints"
AppBarLayout.LayoutParams layoutParams = new AppBarLayout.LayoutParams(AppBarLayout.LayoutParams.MATCH_PARENT,
0);
slidingTabLayout.setLayoutParams(layoutParams);
slidingTabLayout.setTabMode(TabLayout.MODE_FIXED);
slidingTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
} else {
slidingTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
}
}
});
slidingTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
//on Tab Unselected
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
//on Tab Reselected
}
});
ComplaintDetailsFragment complaintDetailsFragment = (ComplaintDetailsFragment) getChildFragmentManager().findFragmentByTag(
"android:switcher:" + R.id.tab_viewpager_details + ":0"
);
if (complaintDetailsFragment != null)
complaintDetailsFragment.setDetailedComplaint(detailedComplaint);
}
} }
}); } catch (Exception e) {
e.printStackTrace();
viewPager.setOffscreenPageLimit(3); }
} }
} }
\ No newline at end of file
package app.insti.fragment;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import app.insti.Constants;
import app.insti.R;
import app.insti.adapter.ComplaintFragmentViewPagerAdapter;
public class ComplaintsFragment extends BaseFragment {
private String userID, userProfileUrl;
private TabLayout slidingTabLayout;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_complaints, container, false);
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Complaints/Suggestions");
Bundle bundle = getArguments();
userID = bundle.getString(Constants.USER_ID);
userProfileUrl = bundle.getString(Constants.CURRENT_USER_PROFILE_PICTURE);
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setTitleEnabled(false);
ViewPager viewPager = view.findViewById(R.id.tab_viewpager);
slidingTabLayout = view.findViewById(R.id.sliding_tab_layout);
Button buttonVentIssues = view.findViewById(R.id.buttonVentIssues);
buttonVentIssues.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FileComplaintFragment fileComplaintFragment = new FileComplaintFragment();
fileComplaintFragment.setArguments(getArguments());
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.framelayout_for_fragment, fileComplaintFragment, fileComplaintFragment.getTag());
fragmentTransaction.addToBackStack("Complaint Fragment").commit();
}
});
slidingTabLayout = view.findViewById(R.id.sliding_tab_layout);
if (viewPager != null) {
setupViewPager(viewPager);
}
return view;
}
private void setupViewPager(final ViewPager viewPager) {
viewPager.setAdapter(new ComplaintFragmentViewPagerAdapter(getChildFragmentManager(), userID, getArguments().getString(Constants.SESSION_ID), userProfileUrl));
slidingTabLayout.setupWithViewPager(viewPager);
slidingTabLayout.post(new Runnable() {
@Override
public void run() {
int tabLayoutWidth = slidingTabLayout.getWidth();
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int deviceWidth = metrics.widthPixels;
if (tabLayoutWidth <= (deviceWidth + 1)) {
final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(
new int[]{android.R.attr.actionBarSize}
);
int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
styledAttributes.recycle();
AppBarLayout.LayoutParams layoutParams = new AppBarLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
mActionBarSize);
slidingTabLayout.setLayoutParams(layoutParams);
slidingTabLayout.setTabMode(TabLayout.MODE_FIXED);
slidingTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
} else {
slidingTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
}
}
});
slidingTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
//On Tab Unselected
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
//On Tab Reselected
}
});
viewPager.setOffscreenPageLimit(3);
}
}
package app.insti.fragment; package app.insti.fragment;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
...@@ -12,35 +11,31 @@ import android.view.LayoutInflater; ...@@ -12,35 +11,31 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import java.util.List; import java.util.List;
import app.insti.R; import app.insti.R;
import app.insti.Utils; import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.adapter.ComplaintsAdapter;
import app.insti.adapter.ComplaintsRecyclerViewAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter; import app.insti.api.model.Venter;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
public class HomeFragment extends Fragment { public class ComplaintsHomeFragment extends Fragment {
Activity activity; private ComplaintsAdapter homeListAdapter;
ComplaintsRecyclerViewAdapter homeListAdapter;
RecyclerView recyclerViewHome;
private SwipeRefreshLayout swipeContainer; private SwipeRefreshLayout swipeContainer;
private static String TAG = HomeFragment.class.getSimpleName(); private static String TAG = ComplaintsHomeFragment.class.getSimpleName();
private boolean isCalled = false; private boolean isCalled = false;
private TextView error_message_home; private TextView error_message_home;
static String sID, uID; private static String sID, uID, uProfileUrl;
public static HomeFragment getInstance(String sessionID, String userID) { public static ComplaintsHomeFragment getInstance(String sessionID, String userID, String userProfileUrl) {
sID = sessionID; sID = sessionID;
uID = userID; uID = userID;
return new HomeFragment(); uProfileUrl = userProfileUrl;
return new ComplaintsHomeFragment();
} }
@Override @Override
...@@ -58,13 +53,13 @@ public class HomeFragment extends Fragment { ...@@ -58,13 +53,13 @@ public class HomeFragment extends Fragment {
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false); View view = inflater.inflate(R.layout.fragment_complaints_home, container, false);
recyclerViewHome = (RecyclerView) view.findViewById(R.id.recyclerViewHome); RecyclerView recyclerViewHome = view.findViewById(R.id.recyclerViewHome);
homeListAdapter = new ComplaintsRecyclerViewAdapter(getActivity(), sID, uID); homeListAdapter = new ComplaintsAdapter(getActivity(), sID, uID, uProfileUrl);
swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipeContainer); swipeContainer = view.findViewById(R.id.swipeContainer);
error_message_home = view.findViewById(R.id.error_message_home); error_message_home = view.findViewById(R.id.error_message_home);
LinearLayoutManager llm = new LinearLayoutManager(activity); LinearLayoutManager llm = new LinearLayoutManager(getActivity());
recyclerViewHome.setLayoutManager(llm); recyclerViewHome.setLayoutManager(llm);
recyclerViewHome.setHasFixedSize(true); recyclerViewHome.setHasFixedSize(true);
...@@ -130,3 +125,4 @@ public class HomeFragment extends Fragment { ...@@ -130,3 +125,4 @@ public class HomeFragment extends Fragment {
homeListAdapter.notifyDataSetChanged(); homeListAdapter.notifyDataSetChanged();
} }
} }
package app.insti.fragment; package app.insti.fragment;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
...@@ -12,34 +11,30 @@ import android.view.LayoutInflater; ...@@ -12,34 +11,30 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import java.util.List; import java.util.List;
import app.insti.R; import app.insti.R;
import app.insti.Utils; import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.adapter.ComplaintsAdapter;
import app.insti.adapter.ComplaintsRecyclerViewAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter; import app.insti.api.model.Venter;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
public class MeFragment extends Fragment { public class ComplaintsMeFragment extends Fragment {
static String uID, sID; private static String uID, sID, uProfileUrl;
Activity activity; private ComplaintsAdapter meListAdapter;
RecyclerView recyclerViewMe; private TextView error_message_me;
ComplaintsRecyclerViewAdapter meListAdapter; private SwipeRefreshLayout swipeContainer;
TextView error_message_me; private static String TAG = ComplaintsMeFragment.class.getSimpleName();
SwipeRefreshLayout swipeContainer;
private static String TAG = MeFragment.class.getSimpleName();
private boolean isCalled = false; private boolean isCalled = false;
public static MeFragment getInstance(String sessionID, String userID) { public static ComplaintsMeFragment getInstance(String sessionID, String userID, String userProfileUrl) {
sID = sessionID; sID = sessionID;
uID = userID; uID = userID;
return new MeFragment(); uProfileUrl = userProfileUrl;
return new ComplaintsMeFragment();
} }
@Override @Override
...@@ -58,13 +53,13 @@ public class MeFragment extends Fragment { ...@@ -58,13 +53,13 @@ public class MeFragment extends Fragment {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_me, container, false); View view = inflater.inflate(R.layout.fragment_complaints_me, container, false);
recyclerViewMe = view.findViewById(R.id.recyclerViewMe); RecyclerView recyclerViewMe = view.findViewById(R.id.recyclerViewMe);
meListAdapter = new ComplaintsRecyclerViewAdapter(getActivity(), sID, uID); meListAdapter = new ComplaintsAdapter(getActivity(), sID, uID, uProfileUrl);
swipeContainer = view.findViewById(R.id.swipeContainer); swipeContainer = view.findViewById(R.id.swipeContainer);
error_message_me = view.findViewById(R.id.error_message_me); error_message_me = view.findViewById(R.id.error_message_me);
LinearLayoutManager llm = new LinearLayoutManager(activity); LinearLayoutManager llm = new LinearLayoutManager(getActivity());
recyclerViewMe.setLayoutManager(llm); recyclerViewMe.setLayoutManager(llm);
recyclerViewMe.setHasFixedSize(true); recyclerViewMe.setHasFixedSize(true);
recyclerViewMe.setAdapter(meListAdapter); recyclerViewMe.setAdapter(meListAdapter);
...@@ -128,4 +123,4 @@ public class MeFragment extends Fragment { ...@@ -128,4 +123,4 @@ public class MeFragment extends Fragment {
meListAdapter.setcomplaintList(list); meListAdapter.setcomplaintList(list);
meListAdapter.notifyDataSetChanged(); meListAdapter.notifyDataSetChanged();
} }
} }
\ No newline at end of file
package app.insti.fragment;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.cunoraz.tagview.TagView;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import app.insti.R;
import app.insti.Utils;
import app.insti.activity.MainActivity;
import app.insti.adapter.CommentRecyclerViewAdapter;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.User;
import app.insti.api.model.Venter;
import app.insti.api.request.CommentCreateRequest;
import app.insti.utils.DateTimeUtil;
import de.hdodenhof.circleimageview.CircleImageView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class DetailedComplaintFragment extends Fragment {
private final String TAG = DetailedComplaintFragment.class.getSimpleName();
private LayoutInflater inflater;
private Venter.Complaint detailedComplaint;
private MapView mMapView;
private GoogleMap googleMap;
private TextView textViewUserName;
private TextView textViewReportDate;
private TextView textViewLocation;
private TextView textViewDescription;
private TextView textViewCommentLabel;
private TextView textViewVoteUpLabel;
private TextView textViewStatus;
private LinearLayout layoutVotes;
private TagView tagView;
private EditText editTextComment;
private ImageButton imageButtonSend;
private CircleImageView circleImageViewCommentUserImage;
private RecyclerView recyclerViewComments;
private Button buttonVoteUp;
private static String sId, cId, uId;
private CommentRecyclerViewAdapter commentListAdapter;
private List<Venter.Comment> commentList;
private static int voteCount;
public static DetailedComplaintFragment getInstance(String sessionid, String complaintid, String userid, int vCount) {
sId = sessionid;
cId = complaintid;
uId = userid;
voteCount = vCount;
return new DetailedComplaintFragment();
}
private void initialiseViews(View view) {
textViewUserName = view.findViewById(R.id.textViewUserName);
textViewReportDate = view.findViewById(R.id.textViewReportDate);
textViewLocation = view.findViewById(R.id.textViewLocation);
textViewDescription = view.findViewById(R.id.textViewDescription);
textViewStatus = view.findViewById(R.id.textViewStatus);
textViewCommentLabel = view.findViewById(R.id.comment_label);
textViewVoteUpLabel = view.findViewById(R.id.up_vote_label);
layoutVotes = view.findViewById(R.id.layoutVotes);
tagView = view.findViewById(R.id.tag_group);
recyclerViewComments = view.findViewById(R.id.recyclerViewComments);
editTextComment = view.findViewById(R.id.edit_comment);
imageButtonSend = view.findViewById(R.id.send_comment);
circleImageViewCommentUserImage = view.findViewById(R.id.comment_user_image);
Picasso.get().load(R.drawable.baseline_account_circle_black_36).into(circleImageViewCommentUserImage);
buttonVoteUp = view.findViewById(R.id.buttonVoteUp);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_detailed_complaint, container, false);
this.inflater = inflater;
commentList = new ArrayList<>();
initialiseViews(view);
commentListAdapter = new CommentRecyclerViewAdapter(getActivity(), getContext(), sId, uId, textViewCommentLabel);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
recyclerViewComments.setLayoutManager(linearLayoutManager);
recyclerViewComments.setHasFixedSize(true);
recyclerViewComments.setAdapter(commentListAdapter);
mMapView = view.findViewById(R.id.google_map);
mMapView.onCreate(savedInstanceState);
mMapView.onResume();
try {
MapsInitializer.initialize(getActivity().getApplicationContext());
} catch (Exception e) {
e.printStackTrace();
}
imageButtonSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!(editTextComment.getText().toString().trim().isEmpty())) {
postComment();
} else {
Toast.makeText(getContext(), "Please enter comment text", Toast.LENGTH_SHORT).show();
}
}
});
buttonVoteUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
upVote();
}
});
return view;
}
private void postComment() {
final CommentCreateRequest commentCreateRequest = new CommentCreateRequest(editTextComment.getText().toString());
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.postComment("sessionid=" + sId, cId, commentCreateRequest).enqueue(new Callback<Venter.Comment>() {
@Override
public void onResponse(Call<Venter.Comment> call, Response<Venter.Comment> response) {
if (response.isSuccessful()) {
Venter.Comment comment = response.body();
addNewComment(comment);
editTextComment.setText(null);
Toast.makeText(getActivity(), "Comment Added", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<Venter.Comment> call, Throwable t) {
Log.i(TAG, "failure in posting comments: " + t.toString());
}
});
}
private void addNewComment(Venter.Comment newComment) {
commentList.add(newComment);
commentListAdapter.setCommentList(commentList);
commentListAdapter.notifyItemInserted(commentList.indexOf(newComment));
commentListAdapter.notifyItemRangeChanged(0, commentListAdapter.getItemCount());
textViewCommentLabel.setText("Comments (" + commentList.size() + ")");
recyclerViewComments.post(new Runnable() {
@Override
public void run() {
MainActivity.hideKeyboard(getActivity());
}
});
}
public void setDetailedComplaint(Venter.Complaint detailedComplaint) {
this.detailedComplaint = detailedComplaint;
populateViews();
}
private void populateViews() {
try {
buttonVoteUp.setText("UpVote");
textViewUserName.setText(detailedComplaint.getComplaintCreatedBy().getUserName());
String time = DateTimeUtil.getDate(detailedComplaint.getComplaintReportDate().toString());
Log.i(TAG, " time: " + time);
textViewReportDate.setText(time);
textViewLocation.setText(detailedComplaint.getLocationDescription());
textViewDescription.setText(detailedComplaint.getDescription());
textViewStatus.setText(detailedComplaint.getStatus().toUpperCase());
if (detailedComplaint.getStatus().equalsIgnoreCase("Reported")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorRed)));
textViewStatus.setTextColor(getContext().getResources().getColor(R.color.primaryTextColor));
} else if (detailedComplaint.getStatus().equalsIgnoreCase("In Progress")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorSecondary)));
textViewStatus.setTextColor(getContext().getResources().getColor(R.color.secondaryTextColor));
} else if (detailedComplaint.getStatus().equalsIgnoreCase("Resolved")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorGreen)));
textViewStatus.setTextColor(getContext().getResources().getColor(R.color.secondaryTextColor));
}
textViewCommentLabel.setText("Comments (" + detailedComplaint.getComment().size() + ")");
textViewVoteUpLabel.setText("Up Votes (" + detailedComplaint.getUsersUpVoted().size() + ")");
addVotesToView(detailedComplaint);
addCommentsToView(detailedComplaint);
} catch (Exception e) {
e.printStackTrace();
}
List<String> tags = new ArrayList<>();
for (Venter.TagUri tagUri : detailedComplaint.getTags()) {
tags.add(tagUri.getTagUri());
}
String[] tagArray = tags.toArray(new String[tags.size()]);
tagView.addTags(tagArray);
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap mGoogleMap) {
googleMap = mGoogleMap;
// For dropping a marker at a point on the Map
LatLng loc = new LatLng(detailedComplaint.getLatitude(), detailedComplaint.getLongitude());
if (loc != null) {
googleMap.addMarker(new MarkerOptions().position(loc).title(detailedComplaint.getLatitude().toString() + " , " + detailedComplaint.getLongitude().toString()).snippet(detailedComplaint.getLocationDescription()));
// For zooming automatically to the location of the marker
CameraPosition cameraPosition = new CameraPosition.Builder().target(loc).zoom(16).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
}
});
}
private void addCommentsToView(Venter.Complaint detailedComplaint) {
for (Venter.Comment comment : detailedComplaint.getComment())
commentList.add(comment);
commentListAdapter.setCommentList(commentList);
commentListAdapter.notifyDataSetChanged();
}
private void upVote() {
if (voteCount == 0) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.upVote("sessionid=" + sId, cId).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
Venter.Complaint complaint = response.body();
addVotesToView(complaint);
Toast.makeText(getActivity().getApplicationContext(), "You have Up Voted this complaint", Toast.LENGTH_SHORT).show();
voteCount++;
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in up vote: " + t.toString());
}
});
} else {
Toast.makeText(getActivity().getApplicationContext(), "You have already UpVoted this complaint", Toast.LENGTH_SHORT).show();
}
}
public void addVotesToView(Venter.Complaint detailedComplaint) {
layoutVotes.removeAllViews();
for (User users : detailedComplaint.getUsersUpVoted()) {
View voteView = inflater.inflate(R.layout.vote_up_card, null);
CircleImageView circleImageView = voteView.findViewById(R.id.circleImageViewUserUpVoteImage);
String profileUrl = users.getUserProfilePictureUrl();
if (profileUrl != null)
Picasso.get().load(profileUrl).into(circleImageView);
else
Picasso.get().load(R.drawable.baseline_account_circle_black_36).into(circleImageView);
TextView textViewName = voteView.findViewById(R.id.textViewUserUpVoteName);
textViewName.setText(users.getUserName());
layoutVotes.addView(voteView);
}
textViewVoteUpLabel.setText("Up Votes (" + detailedComplaint.getUsersUpVoted().size() + ")");
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
}
\ No newline at end of file
...@@ -16,7 +16,6 @@ import android.os.Bundle; ...@@ -16,7 +16,6 @@ import android.os.Bundle;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
...@@ -73,7 +72,7 @@ import java.util.List; ...@@ -73,7 +72,7 @@ import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.CustomAutoCompleteTextView; import app.insti.CustomAutoCompleteTextView;
import app.insti.R; import app.insti.R;
import app.insti.TagClass; import app.insti.ComplaintTag;
import app.insti.Utils; import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.adapter.ImageViewPagerAdapter; import app.insti.adapter.ImageViewPagerAdapter;
...@@ -91,6 +90,7 @@ import retrofit2.Response; ...@@ -91,6 +90,7 @@ import retrofit2.Response;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION; import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE; import static app.insti.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
import static app.insti.Constants.REQUEST_CAMERA_INT_ID;
import static app.insti.Constants.RESULT_LOAD_IMAGE; import static app.insti.Constants.RESULT_LOAD_IMAGE;
public class FileComplaintFragment extends Fragment { public class FileComplaintFragment extends Fragment {
...@@ -98,43 +98,39 @@ public class FileComplaintFragment extends Fragment { ...@@ -98,43 +98,39 @@ public class FileComplaintFragment extends Fragment {
private static final String TAG = FileComplaintFragment.class.getSimpleName(); private static final String TAG = FileComplaintFragment.class.getSimpleName();
private static FileComplaintFragment mainactivity; private static FileComplaintFragment mainactivity;
private Button buttonSubmit; private Button buttonSubmit;
private ImageButton imageActionButton;
private CustomAutoCompleteTextView autoCompleteTextView; private CustomAutoCompleteTextView autoCompleteTextView;
private EditText editTextSuggestions; private EditText editTextSuggestions;
private EditText editTextTags; private EditText editTextTags;
private EditText editTextLocationDetails; private EditText editTextLocationDetails;
private MapView mMapView; private MapView mMapView;
GoogleMap googleMap; private GoogleMap googleMap;
private TagView tagView; private TagView tagView;
private TagView tagViewPopulate; private TagView tagViewPopulate;
private ScrollView tagsLayout; private ScrollView tagsLayout;
private LatLng Location; private LatLng Location;
private String Name;
private String Address; private String Address;
private List<String> Tags; private List<String> Tags;
private ArrayList<TagClass> tagList; private ArrayList<ComplaintTag> tagList;
private List<String> uploadedImagesUrl = new ArrayList<>(); private List<String> uploadedImagesUrl = new ArrayList<>();
private int cursor = 1; private int cursor = 1;
private List<TagClass> tagList2 = new ArrayList<>(); private List<ComplaintTag> tagList2 = new ArrayList<>();
private String base64Image; private String base64Image;
private ImageViewPagerAdapter imageViewPagerAdapter; private ImageViewPagerAdapter imageViewPagerAdapter;
private ViewPager viewPager; private ViewPager viewPager;
private CircleIndicator indicator; private CircleIndicator indicator;
private Button buttonAnalysis;
private RelativeLayout layout_buttons; private RelativeLayout layout_buttons;
String userId; private String userId;
View view; private View view;
NestedScrollView nestedScrollView; private NestedScrollView nestedScrollView;
private boolean GPSIsSetup = false; private boolean GPSIsSetup = false;
FusedLocationProviderClient mFusedLocationClient; private ProgressDialog progressDialog;
ProgressDialog progressDialog; private CollapsingToolbarLayout collapsing_toolbar;
CollapsingToolbarLayout collapsing_toolbar; private LinearLayout linearLayoutAnalyse;
LinearLayout linearLayoutAnalyse; private LinearLayout linearLayoutScrollTags;
private boolean userAddedTag = false;
public FileComplaintFragment() { private ImageButton imageButtonAddTags;
// Required empty public constructor private Button buttonAnalysis;
} private ImageButton imageActionButton;
public static FileComplaintFragment getMainActivity() { public static FileComplaintFragment getMainActivity() {
return mainactivity; return mainactivity;
...@@ -153,13 +149,11 @@ public class FileComplaintFragment extends Fragment { ...@@ -153,13 +149,11 @@ public class FileComplaintFragment extends Fragment {
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
mainactivity = this; mainactivity = this;
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity());
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
if (view != null) { if (view != null) {
ViewGroup parent = (ViewGroup) view.getParent(); ViewGroup parent = (ViewGroup) view.getParent();
...@@ -167,104 +161,35 @@ public class FileComplaintFragment extends Fragment { ...@@ -167,104 +161,35 @@ public class FileComplaintFragment extends Fragment {
parent.removeView(view); parent.removeView(view);
} }
view = inflater.inflate(R.layout.fragment_file_complaint, container, false); view = inflater.inflate(R.layout.fragment_file_complaint, container, false);
bundleCollection();
Bundle bundle = getArguments();
userId = bundle.getString(Constants.USER_ID);
Toast.makeText(getContext(), getString(R.string.initial_message_file_complaint), Toast.LENGTH_LONG).show();
prepareTags(); prepareTags();
progressDialog = new ProgressDialog(getContext()); progressDialog = new ProgressDialog(getContext());
final Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
LinearLayout imageViewHolder = view.findViewById(R.id.image_holder_view);
CollapsingToolbarLayout.LayoutParams layoutParams = new CollapsingToolbarLayout.LayoutParams(
CollapsingToolbarLayout.LayoutParams.MATCH_PARENT,
getResources().getDisplayMetrics().heightPixels / 2
);
collapsing_toolbar = view.findViewById(R.id.collapsing_toolbar);
collapsing_toolbar.setVisibility(View.GONE);
imageViewHolder.setLayoutParams(layoutParams);
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Add Complaint"); toolbar.setTitle("Add Complaint");
initviews(view);
nestedScrollView = view.findViewById(R.id.nested_scrollview);
linearLayoutAnalyse = view.findViewById(R.id.layoutAnalyse);
layout_buttons = view.findViewById(R.id.layout_buttons);
layout_buttons.setVisibility(View.GONE);
buttonSubmit = view.findViewById(R.id.buttonSubmit);
buttonSubmit.setVisibility(View.INVISIBLE);
buttonSubmit.setVisibility(View.GONE);
buttonAnalysis = view.findViewById(R.id.button_analysis);
buttonAnalysis.setVisibility(View.INVISIBLE);
buttonAnalysis.setVisibility(View.GONE);
tagsLayout = view.findViewById(R.id.tags_layout);
viewPager = view.findViewById(R.id.complaint_image_view_pager);
indicator = view.findViewById(R.id.indicator);
imageActionButton = view.findViewById(R.id.add_image);
imageActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "@@@@@@@@ imageActionButton onClick");
giveOptionsToAddImage();
}
});
ImageButton imageButtonAddTags = (ImageButton) view.findViewById(R.id.imageButtonAddTags);
autoCompleteTextView = (CustomAutoCompleteTextView) view.findViewById(R.id.dynamicAutoCompleteTextView);
autoCompleteTextView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
if (!(autoCompleteTextView.getText().toString().trim().isEmpty())) {
int paddingDp = 60;
float density = getContext().getResources().getDisplayMetrics().density;
int paddingPixel = (int) (paddingDp * density);
linearLayoutAnalyse.setPadding(0, 0, 0, paddingPixel);
layout_buttons.setVisibility(View.VISIBLE);
buttonSubmit.setVisibility(View.VISIBLE);
} else {
Toast.makeText(getContext(), getString(R.string.initial_message_file_complaint), Toast.LENGTH_SHORT).show();
}
} else {
buttonSubmit.setVisibility(View.INVISIBLE);
buttonSubmit.setVisibility(View.GONE);
linearLayoutAnalyse.setPadding(0, 0, 0, 0);
}
}
});
editTextSuggestions = view.findViewById(R.id.editTextSuggestions);
editTextLocationDetails = view.findViewById(R.id.editTextLocationDetails);
editTextTags = view.findViewById(R.id.editTextTags);
editTextTags.addTextChangedListener(new TextWatcher() { editTextTags.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//Before Text Changed
} }
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
linearLayoutScrollTags.setVisibility(View.VISIBLE);
setTags(s); setTags(s);
} }
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
//After Text Changed
}
});
imageActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
giveOptionsToAddImage();
} }
}); });
...@@ -272,21 +197,14 @@ public class FileComplaintFragment extends Fragment { ...@@ -272,21 +197,14 @@ public class FileComplaintFragment extends Fragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
//Add Tags //Add Tags
populateTags(editTextTags.getText().toString()); addUserTags();
editTextTags.setText("");
tagViewPopulate.addTags(new ArrayList<Tag>());
MainActivity.hideKeyboard(getActivity());
} }
}); });
buttonSubmit.setOnClickListener(new View.OnClickListener() { buttonSubmit.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Tags = new ArrayList<>(); submitComplaint();
for (int i = 0; i < tagList2.size(); i++) {
Tags.add(tagList2.get(i).getName());
}
addComplaint();
} }
}); });
...@@ -297,88 +215,128 @@ public class FileComplaintFragment extends Fragment { ...@@ -297,88 +215,128 @@ public class FileComplaintFragment extends Fragment {
} }
}); });
mMapView = view.findViewById(R.id.google_map); autoCompleteTextView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
searchComplaint(hasFocus);
}
});
mMapView.onCreate(savedInstanceState); mMapView.onCreate(savedInstanceState);
mMapView.onResume(); mMapView.onResume();
getMapReady(); getMapReady();
// Autocomplete location bar //Autocomplete location bar
autoLocation();
final PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment) getActivity().getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment); //ends here
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setCountry("IN")
.build();
autocompleteFragment.setFilter(typeFilter);
autocompleteFragment.setHint("Enter Location");
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
tagView.setOnTagDeleteListener(new TagView.OnTagDeleteListener() {
@Override @Override
public void onPlaceSelected(com.google.android.gms.location.places.Place place) { public void onTagDeleted(TagView tagView, Tag tag, int i) {
Location = place.getLatLng(); //Delete Tag
Name = place.getName().toString(); deleteTag(tagView, tag, i);
Address = place.getAddress().toString();
updateMap(Location, Name, Address, cursor); //on selecting the place will automatically shows the Details on the map.
cursor++;
} }
});
tagViewPopulate.setOnTagClickListener(new TagView.OnTagClickListener() {
@Override @Override
public void onError(Status status) { public void onTagClick(Tag tag, int i) {
Log.i(TAG, "An error occurred: " + status); //Add Tags
addTags(tag);
} }
}); });
// ends here return view;
}
private void initviews(View view) {
LinearLayout imageViewHolder = view.findViewById(R.id.image_holder_view);
CollapsingToolbarLayout.LayoutParams layoutParams = new CollapsingToolbarLayout.LayoutParams(
CollapsingToolbarLayout.LayoutParams.MATCH_PARENT,
getResources().getDisplayMetrics().heightPixels / 2
);
imageViewHolder.setLayoutParams(layoutParams);
tagView = view.findViewById(R.id.tag_view); collapsing_toolbar = view.findViewById(R.id.collapsing_toolbar);
collapsing_toolbar.setVisibility(View.GONE);
tagView.setOnTagDeleteListener(new TagView.OnTagDeleteListener() { nestedScrollView = view.findViewById(R.id.nested_scrollview);
@Override linearLayoutAnalyse = view.findViewById(R.id.layoutAnalyse);
public void onTagDeleted(final TagView tagView, final Tag tag, final int i) {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity()); layout_buttons = view.findViewById(R.id.layout_buttons);
builder.setMessage("\"" + tag.text + "\" will be deleted. Are you sure?"); layout_buttons.setVisibility(View.GONE);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override buttonSubmit = view.findViewById(R.id.buttonSubmit);
public void onClick(DialogInterface dialog, int which) { buttonSubmit.setVisibility(View.INVISIBLE);
tagView.remove(i); buttonSubmit.setVisibility(View.GONE);
tagList2.remove(i);
Log.i(TAG, "tagList2: " + tagList2.toString()); buttonAnalysis = view.findViewById(R.id.button_analysis);
Toast.makeText(getContext(), "\"" + tag.text + "\" deleted", Toast.LENGTH_SHORT).show(); buttonAnalysis.setVisibility(View.INVISIBLE);
} buttonAnalysis.setVisibility(View.GONE);
});
builder.setNegativeButton("No", null); linearLayoutScrollTags = view.findViewById(R.id.linearLayoutScrollTags);
builder.show(); linearLayoutScrollTags.setVisibility(View.INVISIBLE);
} linearLayoutScrollTags.setVisibility(View.GONE);
}); tagsLayout = view.findViewById(R.id.tags_layout);
viewPager = view.findViewById(R.id.complaint_image_view_pager);
indicator = view.findViewById(R.id.indicator);
imageActionButton = view.findViewById(R.id.fabButton);
imageButtonAddTags = view.findViewById(R.id.imageButtonAddTags);
editTextSuggestions = view.findViewById(R.id.editTextSuggestions);
editTextLocationDetails = view.findViewById(R.id.editTextLocationDetails);
editTextTags = view.findViewById(R.id.editTextTags);
autoCompleteTextView = view.findViewById(R.id.dynamicAutoCompleteTextView);
mMapView = view.findViewById(R.id.google_map);
tagView = view.findViewById(R.id.tag_view);
tagViewPopulate = view.findViewById(R.id.tag_populate); tagViewPopulate = view.findViewById(R.id.tag_populate);
}
tagViewPopulate.setOnTagClickListener(new TagView.OnTagClickListener() { private void bundleCollection() {
@Override Bundle bundle = getArguments();
public void onTagClick(Tag tag, int i) { userId = bundle.getString(Constants.USER_ID);
editTextTags.setText(tag.text); }
editTextTags.setSelection(tag.text.length()); //to set cursor position
}
});
tagViewPopulate.setOnTagDeleteListener(new TagView.OnTagDeleteListener() { private void searchComplaint(boolean hasFocus) {
@Override if (!hasFocus) {
public void onTagDeleted(final TagView tagView, final Tag tag, final int i) { if (!(autoCompleteTextView.getText().toString().trim().isEmpty())) {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity()); int paddingDp = 60;
builder.setMessage("\"" + tag.text + "\" will be deleted. Are you sure?"); float density = getContext().getResources().getDisplayMetrics().density;
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { int paddingPixel = (int) (paddingDp * density);
@Override linearLayoutAnalyse.setPadding(0, 0, 0, paddingPixel);
public void onClick(DialogInterface dialog, int which) { layout_buttons.setVisibility(View.VISIBLE);
tagView.remove(i); buttonSubmit.setVisibility(View.VISIBLE);
Toast.makeText(getContext(), "\"" + tag.text + "\" deleted", Toast.LENGTH_SHORT).show(); } else {
} Toast.makeText(getContext(), getString(R.string.initial_message_file_complaint), Toast.LENGTH_SHORT).show();
});
builder.setNegativeButton("No", null);
builder.show();
} }
});
return view; } else {
buttonSubmit.setVisibility(View.INVISIBLE);
buttonSubmit.setVisibility(View.GONE);
linearLayoutAnalyse.setPadding(0, 0, 0, 0);
}
}
private void addUserTags() {
userAddedTag = true;
populateTags(editTextTags.getText().toString(), userAddedTag);
editTextTags.setText("");
userAddedTag = false;
tagViewPopulate.addTags(new ArrayList<Tag>());
MainActivity.hideKeyboard(getActivity());
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);
}
private void addTags(Tag tag) {
userAddedTag = false;
editTextTags.setText(tag.text);
editTextTags.setSelection(tag.text.length());
populateTags(editTextTags.getText().toString(), userAddedTag);
editTextTags.setText("");
tagViewPopulate.addTags(new ArrayList<Tag>());
MainActivity.hideKeyboard(getActivity());
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);//to set cursor position
} }
public void getMapReady() { public void getMapReady() {
...@@ -412,6 +370,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -412,6 +370,7 @@ public class FileComplaintFragment extends Fragment {
return false; return false;
} }
}); });
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity());
mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() { mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override @Override
public void onSuccess(Location location) { public void onSuccess(Location location) {
...@@ -446,6 +405,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -446,6 +405,7 @@ public class FileComplaintFragment extends Fragment {
} else { } else {
Log.i(TAG, "GPS enabled"); Log.i(TAG, "GPS enabled");
try { try {
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity());
mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() { mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override @Override
public void onSuccess(Location location) { public void onSuccess(Location location) {
...@@ -465,6 +425,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -465,6 +425,7 @@ public class FileComplaintFragment extends Fragment {
@Override @Override
public void onFailure(Exception e) { public void onFailure(Exception e) {
e.printStackTrace(); e.printStackTrace();
Toast.makeText(getContext(), "Something went wrong while getting your location \n" + e, Toast.LENGTH_LONG).show();
} }
}); });
GPSIsSetup = true; GPSIsSetup = true;
...@@ -516,6 +477,9 @@ public class FileComplaintFragment extends Fragment { ...@@ -516,6 +477,9 @@ public class FileComplaintFragment extends Fragment {
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Toast.makeText(getContext(), getString(R.string.GPS_not_enables), Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), getString(R.string.GPS_not_enables), Toast.LENGTH_LONG).show();
break; break;
default:
Toast.makeText(getContext(), getString(R.string.GPS_not_enables), Toast.LENGTH_LONG).show();
break;
} }
} }
} }
...@@ -534,6 +498,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -534,6 +498,7 @@ public class FileComplaintFragment extends Fragment {
MY_PERMISSIONS_REQUEST_LOCATION); MY_PERMISSIONS_REQUEST_LOCATION);
} else { } else {
try { try {
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity());
mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() { mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override @Override
public void onSuccess(Location location) { public void onSuccess(Location location) {
...@@ -562,9 +527,36 @@ public class FileComplaintFragment extends Fragment { ...@@ -562,9 +527,36 @@ public class FileComplaintFragment extends Fragment {
} }
} }
private void populateTags(String cs) { private void autoLocation() {
final PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment) getActivity().getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setCountry("IN")
.build();
autocompleteFragment.setFilter(typeFilter);
autocompleteFragment.setHint("Enter Location");
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(com.google.android.gms.location.places.Place place) {
Location = place.getLatLng();
String Name = place.getName().toString();
Address = place.getAddress().toString();
updateMap(Location, Name, Address, cursor); //on selecting the place will automatically shows the Details on the map.
cursor++;
}
@Override
public void onError(Status status) {
Log.i(TAG, "An error occurred: " + status);
}
});
}
private void populateTags(String cs, Boolean userAddedTag) {
if (!(cs.isEmpty())) { if (!(cs.isEmpty())) {
tagList2.add(new TagClass(cs));
tagList2.add(new ComplaintTag(cs));
ArrayList<Tag> tags = new ArrayList<>(); ArrayList<Tag> tags = new ArrayList<>();
Tag tag; Tag tag;
for (int i = 0; i < tagList2.size(); i++) { for (int i = 0; i < tagList2.size(); i++) {
...@@ -574,27 +566,43 @@ public class FileComplaintFragment extends Fragment { ...@@ -574,27 +566,43 @@ public class FileComplaintFragment extends Fragment {
tags.add(tag); tags.add(tag);
} }
tagView.addTags(tags); tagView.addTags(tags);
for (int i = 0; i < tagList2.size(); i++) {
if (userAddedTag && tagList2.get(i).getName() == cs)
tagList2.get(i).setName(cs + " (U)");
}
} else { } else {
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);
Toast.makeText(getContext(), "Please enter some tags", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Please enter some tags", Toast.LENGTH_SHORT).show();
} }
} }
private void setTags(CharSequence cs) { private void setTags(CharSequence cs) {
int counter = 0;
if (!cs.toString().equals("")) { if (!cs.toString().equals("")) {
String text = cs.toString(); String text = cs.toString();
ArrayList<Tag> tags = new ArrayList<>(); ArrayList<Tag> tags = new ArrayList<>();
Tag tag; Tag tag;
for (int i = 0; i < tagList.size(); i++) { for (int i = 0; i < tagList.size(); i++) {
if (tagList.get(i).getName().toLowerCase().contains(text.toLowerCase())) { if (tagList.get(i).getName().toLowerCase().contains(text.toLowerCase())) {
linearLayoutScrollTags.setVisibility(View.VISIBLE);
tagsLayout.setVisibility(View.VISIBLE); tagsLayout.setVisibility(View.VISIBLE);
tag = new Tag(tagList.get(i).getName()); tag = new Tag(tagList.get(i).getName());
tag.radius = 10f; tag.radius = 10f;
tag.isDeletable = false; tag.isDeletable = false;
tags.add(tag); tags.add(tag);
counter++;
} }
} }
tagViewPopulate.addTags(tags); if (counter != 0) {
tagViewPopulate.addTags(tags);
} else {
linearLayoutScrollTags.setVisibility(View.GONE);
}
} else { } else {
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);
tagViewPopulate.addTags(new ArrayList<Tag>()); tagViewPopulate.addTags(new ArrayList<Tag>());
return; return;
} }
...@@ -608,18 +616,43 @@ public class FileComplaintFragment extends Fragment { ...@@ -608,18 +616,43 @@ public class FileComplaintFragment extends Fragment {
}); });
} }
private void prepareTags() { private void prepareTags() {
tagList = new ArrayList<>(); tagList = new ArrayList<>();
try { try {
for (int i = 0; i < TagCategories.CATEGORIES.length; i++) { for (int i = 0; i < TagCategories.CATEGORIES.length; i++) {
tagList.add(new TagClass(TagCategories.CATEGORIES[i])); tagList.add(new ComplaintTag(TagCategories.CATEGORIES[i]));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void deleteTag(final TagView tagView, final Tag tag, final int i) {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
builder.setMessage("\"" + tag.text + "\" will be deleted. Are you sure?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tagView.remove(i);
tagList2.remove(i);
Log.i(TAG, "tagList2: " + tagList2.toString());
Toast.makeText(getContext(), "\"" + tag.text + "\" deleted", Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("No", null);
builder.show();
}
private void submitComplaint() {
Tags = new ArrayList<>();
for (int i = 0; i < tagList2.size(); i++) {
Tags.add(tagList2.get(i).getName());
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);
}
addComplaint();
}
private void addComplaint() { private void addComplaint() {
final String complaint = "Complaint: " + autoCompleteTextView.getText().toString(); final String complaint = "Complaint: " + autoCompleteTextView.getText().toString();
final String suggestion; final String suggestion;
...@@ -654,12 +687,12 @@ public class FileComplaintFragment extends Fragment { ...@@ -654,12 +687,12 @@ public class FileComplaintFragment extends Fragment {
Toast.makeText(getContext(), "Complaint successfully posted", Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), "Complaint successfully posted", Toast.LENGTH_LONG).show();
Bundle bundle = getArguments(); Bundle bundle = getArguments();
bundle.putString(Constants.USER_ID, userId); bundle.putString(Constants.USER_ID, userId);
ComplaintFragment complaintFragment = new ComplaintFragment(); ComplaintsFragment complaintsFragment = new ComplaintsFragment();
complaintFragment.setArguments(bundle); complaintsFragment.setArguments(bundle);
FragmentManager manager = getFragmentManager(); FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction(); FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, complaintFragment, complaintFragment.getTag()); transaction.replace(R.id.framelayout_for_fragment, complaintsFragment, complaintsFragment.getTag());
transaction.addToBackStack(complaintFragment.getTag()); transaction.addToBackStack(complaintsFragment.getTag());
manager.popBackStackImmediate("Complaint Fragment", FragmentManager.POP_BACK_STACK_INCLUSIVE); manager.popBackStackImmediate("Complaint Fragment", FragmentManager.POP_BACK_STACK_INCLUSIVE);
transaction.commit(); transaction.commit();
} }
...@@ -690,12 +723,12 @@ public class FileComplaintFragment extends Fragment { ...@@ -690,12 +723,12 @@ public class FileComplaintFragment extends Fragment {
Toast.makeText(getContext(), "Complaint successfully posted", Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), "Complaint successfully posted", Toast.LENGTH_LONG).show();
Bundle bundle = getArguments(); Bundle bundle = getArguments();
bundle.putString(Constants.USER_ID, userId); bundle.putString(Constants.USER_ID, userId);
ComplaintFragment complaintFragment = new ComplaintFragment(); ComplaintsFragment complaintsFragment = new ComplaintsFragment();
complaintFragment.setArguments(bundle); complaintsFragment.setArguments(bundle);
FragmentManager manager = getFragmentManager(); FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction(); FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, complaintFragment, complaintFragment.getTag()); transaction.replace(R.id.framelayout_for_fragment, complaintsFragment, complaintsFragment.getTag());
transaction.addToBackStack(complaintFragment.getTag()); transaction.addToBackStack(complaintsFragment.getTag());
manager.popBackStackImmediate("Complaint Fragment", FragmentManager.POP_BACK_STACK_INCLUSIVE); manager.popBackStackImmediate("Complaint Fragment", FragmentManager.POP_BACK_STACK_INCLUSIVE);
transaction.commit(); transaction.commit();
} }
...@@ -734,7 +767,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -734,7 +767,7 @@ public class FileComplaintFragment extends Fragment {
} }
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) { if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(intent, Constants.REQUEST_CAMERA_INT_ID); startActivityForResult(intent, REQUEST_CAMERA_INT_ID);
} }
} else if (items[item].equals(getString(R.string.choose_from_library))) { } else if (items[item].equals(getString(R.string.choose_from_library))) {
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
...@@ -760,7 +793,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -760,7 +793,7 @@ public class FileComplaintFragment extends Fragment {
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == Constants.REQUEST_CAMERA_INT_ID && data != null) { if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CAMERA_INT_ID && data != null) {
progressDialog.setIndeterminate(true); progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false); progressDialog.setCancelable(false);
progressDialog.show(); progressDialog.show();
...@@ -770,7 +803,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -770,7 +803,7 @@ public class FileComplaintFragment extends Fragment {
collapsing_toolbar.setVisibility(View.VISIBLE); collapsing_toolbar.setVisibility(View.VISIBLE);
sendImage(); sendImage();
} else if (resultCode == Activity.RESULT_OK && requestCode == Constants.RESULT_LOAD_IMAGE && data != null) { } else if (resultCode == Activity.RESULT_OK && requestCode == RESULT_LOAD_IMAGE && data != null) {
progressDialog.setIndeterminate(true); progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false); progressDialog.setCancelable(false);
progressDialog.show(); progressDialog.show();
......
package app.insti.fragment; package app.insti.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -16,13 +17,11 @@ public class ImageFragment extends BaseFragment { ...@@ -16,13 +17,11 @@ public class ImageFragment extends BaseFragment {
private static final String TAG = ImageFragment.class.getSimpleName(); private static final String TAG = ImageFragment.class.getSimpleName();
private String image; private String image;
int indexChosen;
public static ImageFragment newInstance(String image, int index) { public static ImageFragment newInstance(String image) {
ImageFragment fragment = new ImageFragment(); ImageFragment fragment = new ImageFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("image", image); args.putString("image", image);
args.putInt("index", index);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
...@@ -33,13 +32,12 @@ public class ImageFragment extends BaseFragment { ...@@ -33,13 +32,12 @@ public class ImageFragment extends BaseFragment {
Log.i(TAG, "getArguments in ImageFragment" + getArguments()); Log.i(TAG, "getArguments in ImageFragment" + getArguments());
if (getArguments() != null) { if (getArguments() != null) {
image = getArguments().getString("image"); image = getArguments().getString("image");
indexChosen = getArguments().getInt("index", 0);
} }
} }
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_image, container, false); View view = inflater.inflate(R.layout.fragment_image, container, false);
ImageView imageView = view.findViewById(R.id.imageView); ImageView imageView = view.findViewById(R.id.imageView);
Picasso.get().load(image).into(imageView); Picasso.get().load(image).into(imageView);
......
...@@ -7,8 +7,6 @@ import java.util.concurrent.TimeUnit; ...@@ -7,8 +7,6 @@ import java.util.concurrent.TimeUnit;
public class DateTimeUtil { public class DateTimeUtil {
private static String time_ago = "";
public static String getDate(String dtStart) { public static String getDate(String dtStart) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+05:30'"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+05:30'");
try { try {
...@@ -19,12 +17,18 @@ public class DateTimeUtil { ...@@ -19,12 +17,18 @@ public class DateTimeUtil {
long minutes = TimeUnit.MILLISECONDS.toMinutes(now.getTime() - date.getTime()); long minutes = TimeUnit.MILLISECONDS.toMinutes(now.getTime() - date.getTime());
long hours = TimeUnit.MILLISECONDS.toHours(now.getTime() - date.getTime()); long hours = TimeUnit.MILLISECONDS.toHours(now.getTime() - date.getTime());
if (seconds <= 0) { if (seconds <= 0) {
return time_ago = "now"; return "now";
} else if (seconds < 60 && seconds > 0) { } else if (seconds == 1){
return time_ago = seconds + " seconds ago"; return seconds + " second ago";
} else if (minutes < 60 && minutes > 0) { } else if (seconds < 60 && seconds > 1) {
return time_ago = minutes + " minutes ago"; return seconds + " seconds ago";
} else if (hours < 24 && hours > 0) { } else if (minutes == 1) {
return minutes + " 1 minute ago";
} else if (minutes < 60 && minutes > 1) {
return minutes + " minutes ago";
} else if (hours == 1) {
return hours + " hour ago";
} else if (hours < 24 && hours > 1) {
return hours + " hours ago"; return hours + " hours ago";
} else { } else {
long days = Math.round(diff / (24.0 * 60 * 60 * 1000)); long days = Math.round(diff / (24.0 * 60 * 60 * 1000));
...@@ -32,14 +36,25 @@ public class DateTimeUtil { ...@@ -32,14 +36,25 @@ public class DateTimeUtil {
return "today"; return "today";
else if (days == 1) else if (days == 1)
return "yesterday"; return "yesterday";
else if (days == 1)
return days + " day ago";
else if (days < 14) else if (days < 14)
return days + " days ago"; return days + " days ago";
else if (days < 30) else if (days < 30)
return ((int) (days / 7)) + " weeks ago"; if ((int) (days / 7) == 1)
return ((int) (days / 7)) + " week ago";
else
return ((int) (days / 7)) + " weeks ago";
else if (days < 365) else if (days < 365)
return ((int) (days / 30)) + " months ago"; if ((int) (days / 30) == 1)
return ((int) (days / 30)) + " month ago";
else
return ((int) (days / 30)) + " months ago";
else else
return ((int) (days / 365)) + " years ago"; if ((int) (days / 365) == 1)
return ((int) (days / 365)) + " year ago";
else
return ((int) (days / 365)) + " years ago";
} }
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
......
package app.insti.utils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* Created by Shivam Sharma on 13-08-2018.
*/
public class GsonProvider {
private static final Gson gsonInput = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
private static final Gson gsonOutput = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
public static Gson getGsonInput() {
return gsonInput;
}
public static Gson getGsonOutput() {
return gsonOutput;
}
}
\ No newline at end of file
...@@ -28,6 +28,13 @@ public class TagCategories { ...@@ -28,6 +28,13 @@ public class TagCategories {
"Fencing issues", "Fencing issues",
"Security issues", "Security issues",
"Infrastructural defaults in the academic area", "Infrastructural defaults in the academic area",
"Cycle pooling issues"}; "Cycle pooling issues",
"Water coolers & Aqua Guards",
"Mess menu complaints",
"PHO cleaning complaints",
"PHO cleaning complaints",
"Hostel common room complaints",
"Hostel Stationary shop complaints"
};
} }
<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>
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<corners android:radius="20dp"/> <corners android:radius="20dp"/>
<!--<padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>--> <padding android:left="10dp" android:right="10dp"/>
<stroke android:width="1dp" android:color="@color/colorPrimary"/> <stroke android:width="1dp" android:color="@color/colorPrimary"/>
</shape> </shape>
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <?xml version="1.0" encoding="utf-8"?>
xmlns:tools="http://schemas.android.com/tools" <LinearLayout 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_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="app.insti.fragment.ComplaintFragment"> android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout <android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:id="@+id/appBar" android:id="@+id/appBar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout <android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar" android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary" app:contentScrim="@android:color/white"
android:background="@color/colorWhite"
app:layout_scrollFlags="scroll|exitUntilCollapsed"> app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout <LinearLayout
android:id="@+id/layoutTopCardViewHolder" android:id="@+id/image_holder_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="175dp" android:layout_height="2dp"
android:orientation="vertical" android:orientation="vertical"
app:layout_collapseMode="parallax"> app:layout_collapseMode="parallax">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:layout_marginTop="30dp">
<LinearLayout <android.support.v4.view.ViewPager
android:id="@+id/complaint_image_view_pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"/>
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="20dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/venter_super_head"
android:textColor="@color/primaryTextColor"
android:textStyle="bold" />
<Button <me.relex.circleindicator.CircleIndicator
android:id="@+id/buttonVentIssues" android:id="@+id/indicator"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_marginTop="10dp" app:ci_animator="@animator/scale_with_alpha"
android:background="@color/colorSecondary" app:ci_drawable="@drawable/selected_dot" />
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="@string/vent_your_issues_now"
android:textAllCaps="false"
android:textColor="@color/secondaryTextColor"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout> </RelativeLayout>
...@@ -78,18 +57,20 @@ ...@@ -78,18 +57,20 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom" android:layout_gravity="bottom"
app:tabIndicatorColor="@color/colorAccent" app:tabIndicatorColor="@color/colorPrimary"
style="@style/CustomTabLayout" android:background="@color/colorWhite"
android:background="?attr/colorPrimary" /> app:tabTextColor="@color/colorGray"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
app:tabSelectedTextColor="#4a4a4a"/>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager
android:id="@+id/tab_viewpager" android:id="@+id/tab_viewpager_details"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
</FrameLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/nestedScrollViewComplaintDetail">
<android.support.design.widget.CoordinatorLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"> android:orientation="vertical"
android:paddingTop="10dp">
<android.support.design.widget.AppBarLayout <LinearLayout
android:id="@+id/appBar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar"> android:orientation="vertical"
android:padding="10dp">
<android.support.design.widget.CollapsingToolbarLayout <LinearLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:contentScrim="@android:color/white" android:orientation="horizontal">
android:background="@color/colorWhite"
app:layout_scrollFlags="scroll|exitUntilCollapsed"> <TextView
android:id="@+id/textViewUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Username"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout <LinearLayout
android:id="@+id/image_holder_view" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textViewStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/customborder"
android:paddingHorizontal="10dp"
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="10dp" />
<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" />
</LinearLayout>
<com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/google_map"
android:layout_width="match_parent"
android:layout_height="200dp" />
<LinearLayout
android:id="@+id/linearLayoutTags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tags"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/tags_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/comment_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/layoutComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewComments"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="2dp" android:layout_height="wrap_content" />
android:orientation="vertical"
app:layout_collapseMode="parallax"> </android.support.design.widget.CoordinatorLayout>
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingHorizontal="10dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/comment_user_image"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<android.support.design.widget.TextInputLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:paddingHorizontal="10dp"
app:hintTextAppearance="@style/edit_text_hint_apperarance">
<EditText
android:id="@+id/edit_comment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:gravity="top"
android:hint="Enter Comment"
android:inputType="textMultiLine"
android:textColor="@android:color/black"
android:textColorHint="#4a4a4a"
android:textSize="14sp" />
<android.support.v4.view.ViewPager </android.support.design.widget.TextInputLayout>
android:id="@+id/complaint_image_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<me.relex.circleindicator.CircleIndicator <ImageButton
android:id="@+id/indicator" android:id="@+id/send_comment"
android:layout_width="match_parent" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_height="48dp" android:layout_width="30dp"
app:ci_animator="@animator/scale_with_alpha" android:layout_height="wrap_content"
app:ci_drawable="@drawable/selected_dot" /> android:layout_gravity="center"
android:src="@drawable/baseline_send_black_18" />
</RelativeLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout> <LinearLayout
android:id="@+id/linearLayoutUpVotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TabLayout <LinearLayout
android:id="@+id/sliding_tab_layout" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="?attr/actionBarSize" android:padding="10dp">
android:layout_gravity="bottom"
app:tabIndicatorColor="@color/colorPrimary" <TextView
android:background="@color/colorWhite" android:id="@+id/up_vote_label"
app:tabTextColor="@color/colorGray" android:layout_width="wrap_content"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget" android:layout_height="wrap_content"
app:tabSelectedTextColor="#4a4a4a"/> android:textColor="@android:color/black"
android:textSize="16sp" />
</android.support.design.widget.AppBarLayout>
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tab_viewpager_details" <ScrollView
android:id="@+id/layoutUpVotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:background="@android:color/white">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewUpVotes"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.CoordinatorLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/> android:layout_gravity="bottom"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="2">
<Button
android:id="@+id/buttonVoteUp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="2"
android:background="@color/colorSecondary"
android:text="Upvote"
android:textColor="@color/secondaryTextColor" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout> </LinearLayout>
</LinearLayout> </android.support.v4.widget.NestedScrollView>
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="app.insti.fragment.ComplaintsFragment">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:id="@+id/layoutTopCardViewHolder"
android:layout_width="match_parent"
android:layout_height="175dp"
android:orientation="vertical"
app:layout_collapseMode="parallax">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="20dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/venter_super_head"
android:textColor="@color/primaryTextColor"
android:textStyle="bold" />
<Button
android:id="@+id/buttonVentIssues"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/colorSecondary"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="@string/vent_your_issues_now"
android:textAllCaps="false"
android:textColor="@color/secondaryTextColor"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tab_layout"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:tabIndicatorColor="@color/colorAccent"
style="@style/CustomTabLayout"
android:background="?attr/colorPrimary" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tab_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Username"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textViewStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/customborder"
android:paddingHorizontal="10dp"
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="10dp" />
<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" />
</LinearLayout>
<com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/google_map"
android:layout_width="match_parent"
android:layout_height="200dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tags"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="7dp" />
<ScrollView
android:id="@+id/tags_laoyut"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editText"
android:layout_marginLeft="6dp"
android:background="@android:color/white"
android:visibility="visible">
<com.cunoraz.tagview.TagView
android:id="@+id/tag_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" />
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="7dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/comment_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/layoutComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewComments"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingHorizontal="10dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/comment_user_image"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<android.support.design.widget.TextInputLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:paddingHorizontal="10dp"
app:hintTextAppearance="@style/edit_text_hint_apperarance">
<EditText
android:id="@+id/edit_comment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:hint="Enter Comment"
android:inputType="textMultiLine"
android:textColor="@android:color/black"
android:textColorHint="#4a4a4a"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/send_comment"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:srcCompat="@android:drawable/ic_menu_send" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/up_vote_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layoutVotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="2">
<Button
android:id="@+id/buttonVoteUp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="2"
android:background="@color/colorSecondary"
android:text="Upvote"
android:textColor="@color/secondaryTextColor" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
...@@ -251,25 +251,34 @@ ...@@ -251,25 +251,34 @@
</LinearLayout> </LinearLayout>
<ScrollView <LinearLayout
android:id="@+id/tags_layout" android:id="@+id/linearLayoutScrollTags"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="6dp" android:orientation="vertical">
android:background="@android:color/white"
android:visibility="invisible">
<com.cunoraz.tagview.TagView <ScrollView
android:id="@+id/tag_populate" android:id="@+id/tags_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_margin="10dp" /> android:layout_marginLeft="6dp"
android:background="@android:color/white"
android:visibility="invisible">
</ScrollView> <com.cunoraz.tagview.TagView
android:id="@+id/tag_populate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
<View </ScrollView>
android:layout_width="match_parent"
android:layout_height="17dp" /> <View
android:id="@+id/viewTagsLayout"
android:layout_width="match_parent"
android:layout_height="17dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardViewUpVote"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:padding="10dp"> android:layout_margin="5dp"
android:padding="10dp"
app:cardUseCompatPadding="true"
app:cardBackgroundColor="@color/colorWhite"
app:cardCornerRadius="0dp">>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -15,6 +22,7 @@ ...@@ -15,6 +22,7 @@
android:paddingTop="4dp"> android:paddingTop="4dp">
<LinearLayout <LinearLayout
android:id="@+id/layoutUpVote"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="80dp"
android:orientation="horizontal"> android:orientation="horizontal">
...@@ -49,4 +57,4 @@ ...@@ -49,4 +57,4 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </android.support.v7.widget.CardView>
\ No newline at end of file \ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<color name="colorGray">#757575</color> <color name="colorGray">#757575</color>
<color name="colorWhite">#FFFFFF</color> <color name="colorWhite">#FFFFFF</color>
<color name="colorTagGreen">#AED581</color>
<color name="colorRed">#FF0000</color> <color name="colorRed">#FF0000</color>
<color name="colorGreen">#00FF00</color> <color name="colorGreen">#00FF00</color>
<!-- Map --> <!-- Map -->
......
...@@ -45,8 +45,9 @@ ...@@ -45,8 +45,9 @@
<string name="enter_suggestions_if_any">Enter Suggestions (if any)</string> <string name="enter_suggestions_if_any">Enter Suggestions (if any)</string>
<string name="no_complaints">No complaints at the moment</string> <string name="no_complaints">No complaints at the moment</string>
<string name="initial_message_file_complaint">Please provide the complaint description before submitting</string> <string name="initial_message_file_complaint">Please provide the complaint description before submitting</string>
<string name="getting_current_location">Getting current location. Please try after some time</string> <string name="getting_current_location">Getting current location.</string>
<string name="GPS_not_enables">GPS is not enabled!</string> <string name="GPS_not_enables">GPS is not enabled!</string>
<string name="no_permission">No permission!</string> <string name="no_permission">No permission!</string>
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="enter_location_details">Enter Location Details</string> <string name="enter_location_details">Enter Location Details</string>
</resources> </resources>
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