Commit a75556eb authored by Preetam Ozarde's avatar Preetam Ozarde

Merge remote-tracking branch 'origin/nss' into nss

# Conflicts:
#	app/src/main/java/app/insti/fragment/ComplaintFragment.java
#	app/src/main/java/app/insti/fragment/FileComplaintFragment.java
#	app/src/main/res/values/strings.xml
parents e64a590e ca4fe5b6
package app.insti.adapter; package app.insti.adapter;
import android.app.Activity; import android.app.Activity;
import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
...@@ -14,7 +15,9 @@ import android.view.LayoutInflater; ...@@ -14,7 +15,9 @@ 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.ImageButton;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -23,10 +26,15 @@ import java.util.List; ...@@ -23,10 +26,15 @@ import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import app.insti.R; import app.insti.R;
import app.insti.Utils;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter; import app.insti.api.model.Venter;
import app.insti.fragment.ComplaintDetailsFragment; import app.insti.fragment.ComplaintDetailsFragment;
import app.insti.utils.DateTimeUtil; import app.insti.utils.DateTimeUtil;
import app.insti.utils.GsonProvider; import app.insti.utils.GsonProvider;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/** /**
* Created by Shivam Sharma on 15-08-2018. * Created by Shivam Sharma on 15-08-2018.
...@@ -45,14 +53,17 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -45,14 +53,17 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private CardView cardView; private CardView cardView;
private TextView textViewDescription; private TextView textViewDescription;
private Button buttonComments; private ImageButton buttonComments;
private Button buttonVotes; private ImageButton buttonVotes;
private TextView textViewComments;
private TextView textViewVotes;
private TextView textViewLocation; private TextView textViewLocation;
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);
...@@ -64,9 +75,11 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -64,9 +75,11 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
textViewDescription = currentView.findViewById(R.id.textViewDescription); textViewDescription = currentView.findViewById(R.id.textViewDescription);
buttonComments = currentView.findViewById(R.id.buttonComments); buttonComments = currentView.findViewById(R.id.buttonComments);
buttonVotes = currentView.findViewById(R.id.buttonVotes); buttonVotes = currentView.findViewById(R.id.buttonVotes);
textViewComments = currentView.findViewById(R.id.text_comments);
textViewVotes = currentView.findViewById(R.id.text_votes);
} }
public void bindHolder(int position) { public void bindHolder(final int position) {
this.pos = position; this.pos = position;
Log.i(TAG, "json = " + GsonProvider.getGsonOutput().toJson(complaintList.get(pos))); Log.i(TAG, "json = " + GsonProvider.getGsonOutput().toJson(complaintList.get(pos)));
cardView.setOnClickListener(new View.OnClickListener() { cardView.setOnClickListener(new View.OnClickListener() {
...@@ -90,20 +103,61 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ...@@ -90,20 +103,61 @@ public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
textViewUserName.setText(complaint.getComplaintCreatedBy().getUserName()); textViewUserName.setText(complaint.getComplaintCreatedBy().getUserName());
textViewStatus.setText(complaint.getStatus().toUpperCase()); textViewStatus.setText(complaint.getStatus().toUpperCase());
if (complaint.getStatus().equalsIgnoreCase("Reported")) { if (complaint.getStatus().equalsIgnoreCase("Reported")) {
textViewStatus.setBackgroundColor(context.getResources().getColor(R.color.colorRed)); textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorRed)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.primaryTextColor)); textViewStatus.setTextColor(context.getResources().getColor(R.color.primaryTextColor));
} else if (complaint.getStatus().equalsIgnoreCase("In Progress")) { } else if (complaint.getStatus().equalsIgnoreCase("In Progress")) {
textViewStatus.setBackgroundColor(context.getResources().getColor(R.color.colorSecondary)); textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorSecondary)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor)); textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
} else if (complaint.getStatus().equalsIgnoreCase("Resolved")) { } else if (complaint.getStatus().equalsIgnoreCase("Resolved")) {
textViewStatus.setBackgroundColor(context.getResources().getColor(R.color.colorGreen)); textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorGreen)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor)); textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
} }
String time = DateTimeUtil.getDate(complaint.getComplaintReportDate().toString()); String time = DateTimeUtil.getDate(complaint.getComplaintReportDate());
Log.i(TAG, "time: " + time); Log.i(TAG, "time: " + time);
textViewReportDate.setText(time); textViewReportDate.setText(time);
buttonComments.setText("COMMENTS(" + complaint.getComment().size() + ")"); textViewComments.setText(String.valueOf(complaint.getComment().size()));
buttonVotes.setText("UP VOTES(" + complaint.getUsersUpVoted().size() + ")"); textViewVotes.setText(String.valueOf(complaint.getUsersUpVoted().size()));
buttonComments.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString("id", complaintList.get(pos).getComplaintID());
bundle.putString("sessionId", sessionID);
bundle.putString("userId", userID);
ComplaintDetailsFragment complaintDetailsFragment = new ComplaintDetailsFragment();
complaintDetailsFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintDetailsFragment).addToBackStack(TAG).commit();
}
});
buttonVotes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (voteCount == 0) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.upVote("sessionid=" + sessionID, complaintList.get(pos).getComplaintID()).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()));
}
Toast.makeText(context, "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(context, "You have already UpVoted this complaint", Toast.LENGTH_SHORT).show();
}
}
});
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -39,7 +39,6 @@ public class ComplaintFragment extends BaseFragment { ...@@ -39,7 +39,6 @@ public class ComplaintFragment extends BaseFragment {
@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
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 toolbar = getActivity().findViewById(R.id.toolbar);
...@@ -64,7 +63,7 @@ public class ComplaintFragment extends BaseFragment { ...@@ -64,7 +63,7 @@ public class ComplaintFragment extends BaseFragment {
fileComplaintFragment.setArguments(getArguments()); fileComplaintFragment.setArguments(getArguments());
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.framelayout_for_fragment, fileComplaintFragment, fileComplaintFragment.getTag()); fragmentTransaction.replace(R.id.framelayout_for_fragment, fileComplaintFragment, fileComplaintFragment.getTag());
fragmentTransaction.addToBackStack("ComplaintFragment").commit(); fragmentTransaction.addToBackStack("Complaint Fragment").commit();
} }
}); });
......
package app.insti.fragment; package app.insti.fragment;
import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
...@@ -182,14 +183,14 @@ public class DetailedComplaintFragment extends Fragment { ...@@ -182,14 +183,14 @@ public class DetailedComplaintFragment extends Fragment {
textViewDescription.setText(detailedComplaint.getDescription()); textViewDescription.setText(detailedComplaint.getDescription());
textViewStatus.setText(detailedComplaint.getStatus().toUpperCase()); textViewStatus.setText(detailedComplaint.getStatus().toUpperCase());
if (detailedComplaint.getStatus().equalsIgnoreCase("Reported")) { if (detailedComplaint.getStatus().equalsIgnoreCase("Reported")) {
textViewStatus.setBackgroundColor(Color.parseColor("#FF0000")); textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorRed)));
textViewStatus.setTextColor(getResources().getColor(R.color.primaryTextColor)); textViewStatus.setTextColor(getContext().getResources().getColor(R.color.primaryTextColor));
} else if (detailedComplaint.getStatus().equalsIgnoreCase("In Progress")) { } else if (detailedComplaint.getStatus().equalsIgnoreCase("In Progress")) {
textViewStatus.setBackgroundColor(getResources().getColor(R.color.colorSecondary)); textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorSecondary)));
textViewStatus.setTextColor(getResources().getColor(R.color.secondaryTextColor)); textViewStatus.setTextColor(getContext().getResources().getColor(R.color.secondaryTextColor));
} else if (detailedComplaint.getStatus().equalsIgnoreCase("Resolved")) { } else if (detailedComplaint.getStatus().equalsIgnoreCase("Resolved")) {
textViewStatus.setBackgroundColor(Color.parseColor("#00FF00")); textViewStatus.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorGreen)));
textViewStatus.setTextColor(getResources().getColor(R.color.secondaryTextColor)); textViewStatus.setTextColor(getContext().getResources().getColor(R.color.secondaryTextColor));
} }
textViewCommentLabel.setText("COMMENTS"); textViewCommentLabel.setText("COMMENTS");
textViewVoteUpLabel.setText("UP VOTES"); textViewVoteUpLabel.setText("UP VOTES");
......
<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="M4,12l1.41,1.41L11,7.83V20h2V7.83l5.58,5.59L20,12l-8,-8 -8,8z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M21.99,4c0,-1.1 -0.89,-2 -1.99,-2L4,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h14l4,4 -0.01,-18zM18,14L6,14v-2h12v2zM18,11L6,11L6,9h12v2zM18,8L6,8L6,6h12v2z"/>
</vector>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp"/>
<!--<padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>-->
<stroke android:width="1dp" android:color="@color/colorPrimary"/>
</shape>
\ No newline at end of file
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cardView" android:id="@+id/cardView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -17,7 +16,7 @@ ...@@ -17,7 +16,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:padding="5dp"> android:padding="15dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -43,7 +42,8 @@ ...@@ -43,7 +42,8 @@
android:text="status" android:text="status"
android:textColor="@android:color/black" android:textColor="@android:color/black"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" /> android:textStyle="bold"
android:background="@drawable/customborder" />
</LinearLayout> </LinearLayout>
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
android:id="@+id/textViewReportDate" android:id="@+id/textViewReportDate"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="report date"
android:textColor="@color/colorGray" android:textColor="@color/colorGray"
android:textSize="14sp" /> android:textSize="14sp" />
...@@ -58,6 +59,7 @@ ...@@ -58,6 +59,7 @@
android:id="@+id/textViewLocation" android:id="@+id/textViewLocation"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="location"
android:textColor="@color/colorGray" android:textColor="@color/colorGray"
android:textSize="14sp" /> android:textSize="14sp" />
...@@ -69,31 +71,69 @@ ...@@ -69,31 +71,69 @@
android:id="@+id/textViewDescription" android:id="@+id/textViewDescription"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="location"
android:textColor="@android:color/black" android:textColor="@android:color/black"
android:textSize="14sp" /> android:textSize="14sp" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="20dp"
android:orientation="horizontal" android:orientation="horizontal"
android:weightSum="2"> android:layout_gravity="center_horizontal"
android:paddingStart="50dp"
android:paddingEnd="20dp"
android:weightSum="2"
android:background="@drawable/customborder">
<Button <LinearLayout
android:id="@+id/buttonComments"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="40dp" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="#12C1D6" android:weightSum="2">
android:textColor="@color/colorWhite" />
<ImageButton
android:id="@+id/buttonComments"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="10dp"
android:layout_height="40dp"
android:layout_weight="1"
android:src="@drawable/baseline_comment_24" />
<TextView
android:id="@+id/text_comments"
android:layout_width="20dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textColor="@color/secondaryTextColor"
android:layout_weight="1"
android:text="12"/>
</LinearLayout>
<Button <LinearLayout
android:id="@+id/buttonVotes"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="40dp" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/black" android:weightSum="2">
android:textColor="@color/colorWhite" />
<ImageButton
android:id="@+id/buttonVotes"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="10dp"
android:layout_height="40dp"
android:layout_weight="1"
android:src="@drawable/baseline_arrow_upward_24" />
<TextView
android:id="@+id/text_votes"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="23"
android:textColor="@color/secondaryTextColor"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
......
...@@ -71,23 +71,25 @@ ...@@ -71,23 +71,25 @@
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> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="2"
android:layout_gravity="bottom">
<LinearLayout <Button
android:layout_width="match_parent" android:id="@+id/buttonVoteUp"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:orientation="horizontal" android:layout_height="50dp"
android:weightSum="2"> android:textColor="@color/secondaryTextColor"
android:background="@color/colorSecondary"
<Button android:text="Upvote"
android:id="@+id/buttonVoteUp" android:layout_weight="2"/>
android:layout_width="wrap_content"
android:layout_height="50dp" </RelativeLayout>
android:textColor="@color/secondaryTextColor"
android:background="@color/colorSecondary" </android.support.design.widget.CoordinatorLayout>
android:text="Upvote"
android:layout_weight="2"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <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:orientation="vertical"> android:orientation="vertical"
android:paddingTop="10dp"
android:paddingBottom="60dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -43,7 +45,8 @@ ...@@ -43,7 +45,8 @@
android:paddingHorizontal="10dp" android:paddingHorizontal="10dp"
android:text="STATUS" android:text="STATUS"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" /> android:textStyle="bold"
android:background="@drawable/customborder"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
......
...@@ -49,4 +49,5 @@ ...@@ -49,4 +49,5 @@
<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="hello_blank_fragment">Hello blank fragment</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