Commit 2d066a06 authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge pull request #221 from sshivam95/nss

Complaint module form added with changes
parents eb245a15 d6beac76
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<module fileurl="file://$PROJECT_DIR$/IITB-App.iml" filepath="$PROJECT_DIR$/IITB-App.iml" /> <module fileurl="file://$PROJECT_DIR$/IITB-App.iml" filepath="$PROJECT_DIR$/IITB-App.iml" />
<module fileurl="file://$PROJECT_DIR$/IITBApp.iml" filepath="$PROJECT_DIR$/IITBApp.iml" /> <module fileurl="file://$PROJECT_DIR$/IITBApp.iml" filepath="$PROJECT_DIR$/IITBApp.iml" />
<module fileurl="file://$PROJECT_DIR$/InstiApp.iml" filepath="$PROJECT_DIR$/InstiApp.iml" /> <module fileurl="file://$PROJECT_DIR$/InstiApp.iml" filepath="$PROJECT_DIR$/InstiApp.iml" />
<module fileurl="file://$PROJECT_DIR$/InstiApp2.iml" filepath="$PROJECT_DIR$/InstiApp2.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules> </modules>
</component> </component>
......
...@@ -29,6 +29,8 @@ ext { ...@@ -29,6 +29,8 @@ ext {
picassoVersion = '2.71828' picassoVersion = '2.71828'
circleImageViewVersion = '2.2.0' circleImageViewVersion = '2.2.0'
markwonVersion = '1.0.6' markwonVersion = '1.0.6'
tagViewVersion = '1.3'
circleIndicatorVersion = '1.2.2@aar'
} }
dependencies { dependencies {
...@@ -37,7 +39,9 @@ dependencies { ...@@ -37,7 +39,9 @@ dependencies {
implementation "com.android.support:design:${supportLibVersion}" implementation "com.android.support:design:${supportLibVersion}"
implementation "com.android.support:exifinterface:${supportLibVersion}" implementation "com.android.support:exifinterface:${supportLibVersion}"
implementation "com.android.support:support-v4:${supportLibVersion}" implementation "com.android.support:support-v4:${supportLibVersion}"
implementation "com.google.android.gms:play-services-maps:${playServicesVersion}"
implementation "com.google.android.gms:play-services-location:${playServicesVersion}" implementation "com.google.android.gms:play-services-location:${playServicesVersion}"
implementation "com.google.android.gms:play-services-places:${playServicesVersion}"
implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}" implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}"
implementation "com.squareup.retrofit2:converter-gson:${retrofitVersion}" implementation "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
implementation "com.squareup.okhttp3:okhttp:${okhttpVersion}" implementation "com.squareup.okhttp3:okhttp:${okhttpVersion}"
...@@ -46,5 +50,7 @@ dependencies { ...@@ -46,5 +50,7 @@ dependencies {
implementation "com.android.support:cardview-v7:${supportLibVersion}" implementation "com.android.support:cardview-v7:${supportLibVersion}"
implementation "de.hdodenhof:circleimageview:${circleImageViewVersion}" implementation "de.hdodenhof:circleimageview:${circleImageViewVersion}"
implementation "ru.noties:markwon:${markwonVersion}" implementation "ru.noties:markwon:${markwonVersion}"
implementation "com.github.Cutta:TagView:${tagViewVersion}"
implementation "me.relex:circleindicator:${circleIndicatorVersion}"
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
android:name="com.google.android.gms.version" android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" /> android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_api_key" />
<!-- FCM styling --> <!-- FCM styling -->
<meta-data <meta-data
android:name="com.google.firebase.messaging.default_notification_icon" android:name="com.google.firebase.messaging.default_notification_icon"
......
package app.insti;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ProgressBar;
/**
* Created by Shivam Sharma on 13-08-2018.
*/
public class ComplaintDescriptionAutoCompleteTextView extends android.support.v7.widget.AppCompatAutoCompleteTextView {
private static final int MESSAGE_TEXT_CHANGED = 100;
private static final int DEFAULT_AUTOCOMPLETE_DELAY = 750;
private int mAutoCompleteDelay = DEFAULT_AUTOCOMPLETE_DELAY;
private ProgressBar mLoadingIndicator;
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
ComplaintDescriptionAutoCompleteTextView.super.performFiltering((CharSequence) msg.obj, msg.arg1);
}
};
public ComplaintDescriptionAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setLoadingIndicator(ProgressBar progressBar) {
mLoadingIndicator = progressBar;
}
public void setAutoCompleteDelay(int autoCompleteDelay) {
mAutoCompleteDelay = autoCompleteDelay;
}
@Override
protected void performFiltering(CharSequence text, int keyCode) {
if (mLoadingIndicator != null) {
mLoadingIndicator.setVisibility(View.VISIBLE);
}
mHandler.removeMessages(MESSAGE_TEXT_CHANGED);
mHandler.sendMessageDelayed(mHandler.obtainMessage(MESSAGE_TEXT_CHANGED, text), mAutoCompleteDelay);
}
@Override
public void onFilterComplete(int count) {
if (mLoadingIndicator != null) {
mLoadingIndicator.setVisibility(View.GONE);
}
super.onFilterComplete(count);
}
}
package app.insti;
/**
* Created by Shivam Sharma on 13-08-2018.
*/
public class ComplaintTag {
private String name;
public ComplaintTag(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
...@@ -5,6 +5,7 @@ public class Constants { ...@@ -5,6 +5,7 @@ public class Constants {
public static final int MY_PERMISSIONS_REQUEST_ACCESS_LOCATION = 2; public static final int MY_PERMISSIONS_REQUEST_ACCESS_LOCATION = 2;
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 3; public static final int MY_PERMISSIONS_REQUEST_LOCATION = 3;
public static final int RESULT_LOAD_IMAGE = 11; public static final int RESULT_LOAD_IMAGE = 11;
public static final int REQUEST_CAMERA_INT_ID = 101;
public static final String NOTIFICATIONS_RESPONSE_JSON = "notifications_json"; public static final String NOTIFICATIONS_RESPONSE_JSON = "notifications_json";
public static final String EVENT_ID = "event_id"; public static final String EVENT_ID = "event_id";
public static final String EVENT_LATITUDE = "event_latitude"; public static final String EVENT_LATITUDE = "event_latitude";
...@@ -19,6 +20,7 @@ public class Constants { ...@@ -19,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,11 +55,11 @@ import app.insti.api.model.Role; ...@@ -55,11 +55,11 @@ 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.EventFragment; import app.insti.fragment.ComplaintsFragment;
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.MapFragment; import app.insti.fragment.MapFragment;
import app.insti.fragment.MessMenuFragment; import app.insti.fragment.MessMenuFragment;
import app.insti.fragment.NewsFragment; import app.insti.fragment.NewsFragment;
...@@ -79,6 +79,7 @@ import static app.insti.Constants.DATA_TYPE_PT; ...@@ -79,6 +79,7 @@ import static app.insti.Constants.DATA_TYPE_PT;
import static app.insti.Constants.DATA_TYPE_USER; import static app.insti.Constants.DATA_TYPE_USER;
import static app.insti.Constants.FCM_BUNDLE_NOTIFICATION_ID; import static app.insti.Constants.FCM_BUNDLE_NOTIFICATION_ID;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION; import static app.insti.Constants.MY_PERMISSIONS_REQUEST_ACCESS_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.RESULT_LOAD_IMAGE; import static app.insti.Constants.RESULT_LOAD_IMAGE;
...@@ -525,6 +526,15 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -525,6 +526,15 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
updateFragment(mapFragment); updateFragment(mapFragment);
break; break;
case R.id.nav_complaint:
if (session.isLoggedIn()) {
ComplaintsFragment complaintsFragment = new ComplaintsFragment();
updateFragment(complaintsFragment);
} else {
Toast.makeText(this, Constants.LOGIN_MESSAGE, Toast.LENGTH_LONG).show();
}
break;
case R.id.nav_settings: case R.id.nav_settings:
SettingsFragment settingsFragment = new SettingsFragment(); SettingsFragment settingsFragment = new SettingsFragment();
updateFragment(settingsFragment); updateFragment(settingsFragment);
...@@ -567,6 +577,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -567,6 +577,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
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()) 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)
...@@ -599,6 +613,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -599,6 +613,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
break;
case MY_PERMISSIONS_REQUEST_LOCATION:
Log.i(TAG, "Permission request captured");
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "Permission Granted");
FileComplaintFragment.getMainActivity().getMapReady();
} else {
Log.i(TAG, "Permission Cancelled");
Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT);
toast.show();
}
} }
} }
......
package app.insti.adapter;
import android.content.ClipData;
import android.content.ClipboardManager;
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.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import app.insti.R;
import app.insti.Utils;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter;
import app.insti.utils.DateTimeUtil;
import de.hdodenhof.circleimageview.CircleImageView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by Shivam Sharma on 23-09-2018.
*/
public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final String TAG = CommentsAdapter.class.getSimpleName();
private Context context;
private LayoutInflater inflater;
private String sessionId, userId;
private Fragment fragment;
private TextView textViewCommentLabel;
private List<Venter.Comment> commentList = new ArrayList<>();
public CommentsAdapter(Context context, String sessionId, String userId, Fragment fragment) {
this.context = context;
this.sessionId = sessionId;
this.userId = userId;
inflater = LayoutInflater.from(context);
this.fragment =fragment;
}
public class CommentsViewHolder extends RecyclerView.ViewHolder {
private CardView cardView;
private CircleImageView circleImageView;
private TextView textViewName;
private TextView textViewCommentTime;
private TextView textViewComment;
private final RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
CommentsViewHolder(View itemView) {
super(itemView);
cardView = itemView.findViewById(R.id.cardViewComment);
textViewName = itemView.findViewById(R.id.textViewUserComment);
textViewComment = itemView.findViewById(R.id.textViewComment);
textViewCommentTime = itemView.findViewById(R.id.textViewTime);
circleImageView = itemView.findViewById(R.id.circleImageViewUserImage);
}
private void bindHolder(final int position) {
final Venter.Comment comment = commentList.get(position);
try {
String profileUrl = comment.getUser().getUserProfilePictureUrl();
Log.i(TAG, "PROFILE URL: " + profileUrl);
Picasso.get().load(profileUrl).placeholder(R.drawable.user_placeholder).into(circleImageView);
} catch (Exception e) {
e.printStackTrace();
}
try {
textViewName.setText(comment.getUser().getUserName());
String time = DateTimeUtil.getDate(comment.getTime());
Log.i(TAG, "time: " + time);
textViewCommentTime.setText(time);
textViewComment.setText(comment.getText());
} catch (Exception e) {
e.printStackTrace();
}
cardView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(final View v) {
PopupMenu popupMenu = new PopupMenu(context, cardView);
if (!(comment.getUser().getUserID().equals(userId))) {
popupMenu.inflate(R.menu.comments_options_secondary_menu);
} else {
popupMenu.inflate(R.menu.comment_options_primary_menu);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.copy_comment_option:
ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("Text Copied", textViewComment.getText().toString());
if (clipboardManager != null) {
clipboardManager.setPrimaryClip(clipData);
}
Toast.makeText(context, "Comment Copied", Toast.LENGTH_SHORT).show();
break;
case R.id.delete_comment_option:
retrofitInterface.deleteComment("sessionid=" + sessionId, comment.getId()).enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
if (response.isSuccessful()) {
commentList.remove(position);
notifyDataSetChanged();
notifyItemRemoved(position);
notifyItemRangeChanged(position, commentList.size() - position);
textViewCommentLabel.setText("Comments (" + commentList.size() + ")");
} else {
Toast.makeText(context, "You can't delete this comment", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<String> call, Throwable t) {
Log.i(TAG, " failure in deleting: " + t.toString());
}
});
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;
}
});
popupMenu.show();
return true;
}
});
}
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.comments_card, parent, false);
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;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof CommentsViewHolder) {
((CommentsViewHolder) holder).bindHolder(position);
}
}
@Override
public int getItemCount() {
return commentList.size();
}
public void setCommentList(List<Venter.Comment> commentList, TextView textViewCommentLabel) {
this.commentList = commentList;
this.textViewCommentLabel = textViewCommentLabel;
}
}
\ No newline at end of file
package app.insti.adapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import app.insti.fragment.ComplaintDetailsFragment;
/**
* Created by Shivam Sharma on 19-09-2018.
*/
public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter {
private String sessionid, complaintid, userid, userProfileUrl;
public ComplaintDetailsPagerAdapter(FragmentManager fm, String sessionid, String complaintid, String userid, String userProfileUrl) {
super(fm);
this.sessionid = sessionid;
this.complaintid = complaintid;
this.userid = userid;
this.userProfileUrl = userProfileUrl;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return ComplaintDetailsFragment.getInstance(sessionid, complaintid, userid, userProfileUrl);
/*
For version 2:
case 1:
return RelevantComplaintsFragment.getInstance(sessionid, userid);
*/
default:
return ComplaintDetailsFragment.getInstance(sessionid, complaintid, userid, userProfileUrl);
}
}
@Override
public CharSequence getPageTitle(int position) {
if (position == 0) {
return "Complaint Details";
} else {
return "Relevant Complaints";
}
}
@Override
public int getCount() {
return 1;
}
}
package app.insti.adapter;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import app.insti.fragment.ComplaintsHomeFragment;
import app.insti.fragment.ComplaintsMeFragment;
/**
* Created by Shivam Sharma on 15-08-2018.
*/
public class ComplaintFragmentViewPagerAdapter extends FragmentStatePagerAdapter {
private String userID, sessionID, userProfileUrl;
public ComplaintFragmentViewPagerAdapter(FragmentManager fm,String userID, String sessionID, String userProfileUrl) {
super(fm);
this.userID = userID;
this.sessionID = sessionID;
this.userProfileUrl = userProfileUrl;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return ComplaintsHomeFragment.getInstance(sessionID, userID, userProfileUrl);
case 1:
return ComplaintsMeFragment.getInstance(sessionID,userID, userProfileUrl);
default:
return ComplaintsHomeFragment.getInstance(sessionID, userID, userProfileUrl);
}
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
if (position == 0) {
return "Home";
} else {
return "Me";
}
}
@Override
public int getCount() {
return 2;
}
}
package app.insti.adapter;
import android.app.Activity;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
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.ImageButton;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import app.insti.R;
import app.insti.Utils;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.User;
import app.insti.api.model.Venter;
import app.insti.fragment.ComplaintFragment;
import app.insti.utils.DateTimeUtil;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by Shivam Sharma on 15-08-2018.
*/
public class ComplaintsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private LayoutInflater inflater;
private Activity context;
private String sessionID;
private String userID;
private String userProfileUrl;
private static final String TAG = ComplaintsAdapter.class.getSimpleName();
private List<Venter.Complaint> complaintList = new ArrayList<>();
public class ComplaintsViewHolder extends RecyclerView.ViewHolder {
private CardView cardView;
private TextView textViewDescription;
private ImageButton buttonComments;
private ImageButton buttonVotes;
private TextView textViewComments;
private TextView textViewVotes;
private TextView textViewLocation;
private TextView textViewUserName;
private TextView textViewReportDate;
private TextView textViewStatus;
private int pos;
public ComplaintsViewHolder(View currentView) {
super(currentView);
cardView = currentView.findViewById(R.id.cardView);
textViewUserName = currentView.findViewById(R.id.textViewUserName);
textViewStatus = currentView.findViewById(R.id.textViewStatus);
textViewReportDate = currentView.findViewById(R.id.textViewReportDate);
textViewLocation = currentView.findViewById(R.id.textViewLocation);
textViewDescription = currentView.findViewById(R.id.textViewDescription);
buttonComments = currentView.findViewById(R.id.buttonComments);
buttonVotes = currentView.findViewById(R.id.buttonVotes);
textViewComments = currentView.findViewById(R.id.text_comments);
textViewVotes = currentView.findViewById(R.id.text_votes);
}
public void bindHolder(final int position) {
this.pos = position;
cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString("id", complaintList.get(pos).getComplaintID());
bundle.putString("sessionId", sessionID);
bundle.putString("userId", userID);
bundle.putString("userProfileUrl", userProfileUrl);
ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintFragment).addToBackStack(TAG).commit();
}
});
Venter.Complaint complaint = complaintList.get(position);
try {
textViewDescription.setText(complaint.getDescription());
textViewLocation.setText(complaint.getLocationDescription());
textViewUserName.setText(complaint.getComplaintCreatedBy().getUserName());
textViewStatus.setText(complaint.getStatus().toUpperCase());
if (complaint.getStatus().equalsIgnoreCase("Reported")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorRed)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.primaryTextColor));
} else if (complaint.getStatus().equalsIgnoreCase("In Progress")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorSecondary)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
} else if (complaint.getStatus().equalsIgnoreCase("Resolved")) {
textViewStatus.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.colorGreen)));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
}
String time = DateTimeUtil.getDate(complaint.getComplaintReportDate());
Log.i(TAG, "time: " + time);
textViewReportDate.setText(time);
textViewComments.setText(String.valueOf(complaint.getComment().size()));
textViewVotes.setText(String.valueOf(complaint.getUsersUpVoted().size()));
buttonComments.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString("id", complaintList.get(pos).getComplaintID());
bundle.putString("sessionId", sessionID);
bundle.putString("userId", userID);
bundle.putString("userProfileUrl", userProfileUrl);
ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintFragment).addToBackStack(TAG).commit();
}
});
buttonVotes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (complaintList.get(position).getVoteCount() == 0) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.upVote("sessionid=" + sessionID, complaintList.get(pos).getComplaintID(), 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();
if (complaint != null) {
textViewVotes.setText(String.valueOf(complaint.getUsersUpVoted().size()));
}
complaintList.get(position).setVoteCount(1);
}
}
@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);
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in up vote: " + t.toString());
}
});
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
public ComplaintsAdapter(Activity ctx, String sessionID, String userID, String userProfileUrl) {
this.context = ctx;
this.sessionID = sessionID;
this.userID = userID;
this.userProfileUrl = userProfileUrl;
inflater = LayoutInflater.from(ctx);
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view;
view = inflater.inflate(R.layout.complaint_card, parent, false);
return new ComplaintsViewHolder(view);
}
@Override
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) {
((ComplaintsViewHolder) viewHolder).bindHolder(position);
}
}
@Override
public int getItemCount() {
return complaintList.size();
}
public void setcomplaintList(List<Venter.Complaint> list) {
this.complaintList = list;
}
}
\ No newline at end of file
package app.insti.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import app.insti.R;
import app.insti.api.model.Venter;
/**
* Created by Shivam Sharma on 25-09-2018.
*/
public class ImageViewPagerAdapter extends PagerAdapter {
private List<String> images = new ArrayList<>();
public Context context;
public LayoutInflater inflater;
public ImageViewPagerAdapter(Context context, List<String> images)
{
this.context = context;
this.images = images;
inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public ImageViewPagerAdapter(Context context, Venter.Complaint detailedComplaint)
{
this.context = context;
inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for (String image: detailedComplaint.getImages()){
images.add(image);
}
}
@Override
public int getCount() {
if (images.size() == 0)
return 1;
else
return images.size();
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
return view.equals(o);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public Object instantiateItem(ViewGroup view, int position)
{
View imageLayout = inflater.inflate(R.layout.slidingimages_layout, view, false);
assert imageLayout != null;
final ImageView imageView = imageLayout.findViewById(R.id.slidingImageView);
if (images.size() != 0)
Picasso.get().load(images.get(position)).into(imageView);
else
Picasso.get().load(R.drawable.baseline_photo_size_select_actual_black_48).resize(500,500).into(imageView);
view.addView(imageLayout, 0);
return imageLayout;
}
}
\ 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;
import android.util.Log;
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.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;
/**
* Created by Shivam Sharma on 13-08-2018.
* <p>
* This API updates the Google Map when the location is added.
*/
public class LocationAPIUtils {
private static final String TAG = LocationAPIUtils.class.getSimpleName();
private GoogleMap googleMap;
private MapView mMapView;
public LocationAPIUtils(GoogleMap googleMap, MapView mMapView) {
this.googleMap = googleMap;
this.mMapView = mMapView;
}
public void callGoogleToShowLocationOnMap( final LatLng location, final String name, final String address, final int cursor) {
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap mMap) {
googleMap = mMap;
if (cursor != 0) {
googleMap.clear();
}
googleMap.addMarker(new MarkerOptions().position(location).title(name).snippet(address));
CameraPosition cameraPosition = new CameraPosition.Builder().target(location).zoom(17).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Log.i(TAG, "curser = " + cursor);
}
});
}
}
\ No newline at end of file
...@@ -11,10 +11,14 @@ import app.insti.api.model.Notification; ...@@ -11,10 +11,14 @@ import app.insti.api.model.Notification;
import app.insti.api.model.PlacementBlogPost; import app.insti.api.model.PlacementBlogPost;
import app.insti.api.model.TrainingBlogPost; import app.insti.api.model.TrainingBlogPost;
import app.insti.api.model.User; import app.insti.api.model.User;
import app.insti.api.model.Venter;
import app.insti.api.model.Venue; import app.insti.api.model.Venue;
import app.insti.api.request.CommentCreateRequest;
import app.insti.api.request.ComplaintCreateRequest;
import app.insti.api.request.EventCreateRequest; import app.insti.api.request.EventCreateRequest;
import app.insti.api.request.ImageUploadRequest; import app.insti.api.request.ImageUploadRequest;
import app.insti.api.request.UserFCMPatchRequest; import app.insti.api.request.UserFCMPatchRequest;
import app.insti.api.response.ComplaintCreateResponse;
import app.insti.api.response.EventCreateResponse; import app.insti.api.response.EventCreateResponse;
import app.insti.api.response.ExploreResponse; import app.insti.api.response.ExploreResponse;
import app.insti.api.response.ImageUploadResponse; import app.insti.api.response.ImageUploadResponse;
...@@ -22,10 +26,12 @@ import app.insti.api.response.LoginResponse; ...@@ -22,10 +26,12 @@ import app.insti.api.response.LoginResponse;
import app.insti.api.response.NewsFeedResponse; import app.insti.api.response.NewsFeedResponse;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.Header; import retrofit2.http.Header;
import retrofit2.http.PATCH; import retrofit2.http.PATCH;
import retrofit2.http.POST; import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path; import retrofit2.http.Path;
import retrofit2.http.Query; import retrofit2.http.Query;
...@@ -107,4 +113,29 @@ public interface RetrofitInterface { ...@@ -107,4 +113,29 @@ public interface RetrofitInterface {
@GET("search") @GET("search")
Call<ExploreResponse> search(@Header("Cookie") String sessionID, @Query("query") String query); Call<ExploreResponse> search(@Header("Cookie") String sessionID, @Query("query") String query);
@GET("venter/complaints")
Call<List<Venter.Complaint>> getAllComplaints(@Header("Cookie") String sessionId);
@GET("venter/complaints?filter=me")
Call<List<Venter.Complaint>> getUserComplaints(@Header("Cookie") String sessionId);
@GET("venter/complaints/{complaintId}")
Call<Venter.Complaint> getComplaint(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId);
@GET("venter/complaints/{complaintId}/upvote")
Call<Venter.Complaint> upVote(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId, @Query("action") int count);
@POST("venter/complaints")
Call<ComplaintCreateResponse> postComplaint(@Header("Cookie") String sessionId, @Body ComplaintCreateRequest complaintCreateRequest);
@POST("venter/complaints/{complaintId}/comments")
Call<Venter.Comment> postComment(@Header("Cookie") String sessionId, @Path("complaintId") String commentId, @Body CommentCreateRequest commentCreateRequest);
@PUT("venter/comments/{commentId}")
Call<Venter.Comment> updateComment(@Header("Cookie") String sessionId, @Path("commentId") String commentId, @Body CommentCreateRequest commentCreateRequest);
@DELETE("venter/comments/{commentId}")
Call<String> deleteComment(@Header("Cookie") String sessionId, @Path("commentId") String commentId);
} }
package app.insti.api.model;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by Shivam Sharma on 04-09-2018.
*/
public class Venter {
public static class Complaint{
@SerializedName("id")
private String complaintID;
@SerializedName("created_by")
private User complaintCreatedBy;
@SerializedName("description")
private String description;
@SerializedName("report_date")
private String complaintReportDate;
@SerializedName("status")
private String status;
@SerializedName("latitude")
private Float latitude;
@SerializedName("longitude")
private Float longitude;
@SerializedName("location_description")
private String locationDescription;
@SerializedName("tags")
private List<TagUri> tags;
@SerializedName("users_up_voted")
private List<User> usersUpVoted;
@SerializedName("images")
private List<String> images;
@SerializedName("comments")
private List<Comment> comment;
private int voteCount;
@NonNull
public String getComplaintID() {
return complaintID;
}
public void setComplaintID(@NonNull String complaintID) {
this.complaintID = complaintID;
}
public User getComplaintCreatedBy() {
return complaintCreatedBy;
}
public void setComplaintCreatedBy(User complaintCreatedBy) {
this.complaintCreatedBy = complaintCreatedBy;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getComplaintReportDate() {
return complaintReportDate;
}
public void setComplaintReportDate(String complaintReportDate) {
this.complaintReportDate = complaintReportDate;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Float getLatitude() {
return latitude;
}
public void setLatitude(Float latitude) {
this.latitude = latitude;
}
public Float getLongitude() {
return longitude;
}
public void setLongitude(Float longitude) {
this.longitude = longitude;
}
public String getLocationDescription() {
return locationDescription;
}
public void setLocationDescription(String locationDescription) {
this.locationDescription = locationDescription;
}
public List<TagUri> getTags() {
return tags;
}
public void setTags(List<TagUri> tags) {
this.tags = tags;
}
public List<User> getUsersUpVoted() {
return usersUpVoted;
}
public void setUsersUpVoted(List<User> usersUpVoted) {
this.usersUpVoted = usersUpVoted;
}
public List<String> getImages() {
return images;
}
public void setImages(List<String> images) {
this.images = images;
}
public List<Comment> getComment() {
return comment;
}
public void setComment(List<Comment> comment) {
this.comment = comment;
}
public int getVoteCount() {
return voteCount;
}
public void setVoteCount(int voteCount) {
this.voteCount = voteCount;
}
}
public static class TagUri {
@SerializedName("id")
private String id;
@SerializedName("tag_uri")
private String tagUri;
@NonNull
public String getId() {
return id;
}
public void setId(@NonNull String id) {
this.id = id;
}
public String getTagUri() {
return tagUri;
}
public void setTagUri(String tagUri) {
this.tagUri = tagUri;
}
}
public static class Comment {
@SerializedName("id")
private String id;
@SerializedName("time")
private String time;
@SerializedName("text")
private String text;
@SerializedName("commented_by")
private User commented_by;
@NonNull
public String getId() {
return id;
}
public void setId(@NonNull String id) {
this.id = id;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public User getUser() {
return commented_by;
}
public void setUser(User commented_by) {
this.commented_by = commented_by;
}
}
}
package app.insti.api.request;
import com.google.gson.annotations.SerializedName;
/**
* Created by Shivam Sharma on 21-09-2018.
*/
public class CommentCreateRequest {
@SerializedName("text")
private String text;
public CommentCreateRequest(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
package app.insti.api.request;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by Shivam Sharma on 18-09-2018.
*/
public class ComplaintCreateRequest {
@SerializedName("description")
private String complaintDescription;
@SerializedName("location_description")
private String complaintLocation;
@SerializedName("latitude")
private Float complaintLatitude;
@SerializedName("longitude")
private Float complaintLongitude;
@SerializedName("tags")
private List<String> tags;
@SerializedName("images")
private List<String> images;
public ComplaintCreateRequest(String complaintDescription, String complaintLocation, Float complaintLatitude, Float complaintLongitude, List<String> tags, List<String> images) {
this.complaintDescription = complaintDescription;
this.complaintLocation = complaintLocation;
this.complaintLatitude = complaintLatitude;
this.complaintLongitude = complaintLongitude;
this.tags = tags;
this.images = images;
}
public String getComplaintDescription() {
return complaintDescription;
}
public void setComplaintDescription(String complaintDescription) {
this.complaintDescription = complaintDescription;
}
public String getComplaintLocation() {
return complaintLocation;
}
public void setComplaintLocation(String complaintLocation) {
this.complaintLocation = complaintLocation;
}
public Float getComplaintLatitude() {
return complaintLatitude;
}
public void setComplaintLatitude(Float complaintLatitude) {
this.complaintLatitude = complaintLatitude;
}
public Float getComplaintLongitude() {
return complaintLongitude;
}
public void setComplaintLongitude(Float complaintLongitude) {
this.complaintLongitude = complaintLongitude;
}
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
public List<String> getImages() {
return images;
}
public void setImages(List<String> images) {
this.images = images;
}
}
package app.insti.api.response;
/**
* Created by Shivam Sharma on 18-09-2018.
*/
public class ComplaintCreateResponse {
private String result;
private String complaintId;
public ComplaintCreateResponse(String result, String complaintId) {
this.result = result;
this.complaintId = complaintId;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getComplaintId() {
return complaintId;
}
public void setComplaintId(String complaintId) {
this.complaintId = complaintId;
}
}
package app.insti.fragment;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.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.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
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 java.util.Objects;
import app.insti.R;
import app.insti.Utils;
import app.insti.activity.MainActivity;
import app.insti.adapter.CommentsAdapter;
import app.insti.adapter.ImageViewPagerAdapter;
import app.insti.adapter.UpVotesAdapter;
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 me.relex.circleindicator.CircleIndicator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ComplaintDetailsFragment extends Fragment {
private final String TAG = ComplaintDetailsFragment.class.getSimpleName();
private Venter.Complaint detailedComplaint;
private MapView mMapView;
private TextView textViewUserName;
private TextView textViewReportDate;
private TextView textViewLocation;
private TextView textViewDescription;
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 View mView;
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;
private CircleIndicator circleIndicator;
public static ComplaintDetailsFragment getInstance(String sessionid, String complaintid, String userid, String userProfileUrl) {
sId = sessionid;
cId = complaintid;
uId = userid;
uProfileUrl = userProfileUrl;
return new ComplaintDetailsFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
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();
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(detailedComplaint);
}
});
mView = view;
return view;
}
private void initialiseViews(View view) {
nestedScrollView = view.findViewById(R.id.nestedScrollViewComplaintDetail);
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);
circleIndicator = view.findViewById(R.id.indicator);
LinearLayout imageViewHolder = view.findViewById(R.id.image_holder_view);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams
(LinearLayout.LayoutParams.MATCH_PARENT,
getResources().getDisplayMetrics().heightPixels / 2);
imageViewHolder.setLayoutParams(layoutParams);
}
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));
}
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);
initViewPagerForImages(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 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);
}
}
@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, textViewCommentLabel);
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());
}
});
}
private void addCommentsToView(Venter.Complaint detailedComplaint) {
for (Venter.Comment comment : detailedComplaint.getComment())
commentList.add(comment);
commentListAdapter.setCommentList(commentList, textViewCommentLabel);
commentListAdapter.notifyDataSetChanged();
}
private void upVote(final Venter.Complaint detailedComplaint) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
if (detailedComplaint.getVoteCount() == 0) {
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();
}
}
@Override
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);
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in up vote: " + t.toString());
}
});
}
}
public void addVotesToView(Venter.Complaint detailedComplaint) {
upVotesList.clear();
for (User users : detailedComplaint.getUsersUpVoted()) {
upVotesList.add(users);
}
upVotesAdapter.setUpVoteList(upVotesList);
upVotesAdapter.notifyDataSetChanged();
textViewVoteUpLabel.setText("Up Votes (" + detailedComplaint.getUsersUpVoted().size() + ")");
}
private void onUpvote(){
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);
}
}
private void initViewPagerForImages(Venter.Complaint detailedComplaint) {
ViewPager viewPager = mView.findViewById(R.id.complaint_image_view_pager);
if (viewPager != null) {
try {
ImageViewPagerAdapter imageFragmentPagerAdapter = new ImageViewPagerAdapter(getActivity(), 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
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
package app.insti.fragment;
import android.content.res.TypedArray;
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.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.Objects;
import app.insti.R;
import app.insti.Utils;
import app.insti.adapter.ComplaintDetailsPagerAdapter;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.User;
import app.insti.api.model.Venter;
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 ViewPager viewPager;
private View mview;
private String complaintId, sessionID, userId, userProfileUrl;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_complaint, container, false);
slidingTabLayout = view.findViewById(R.id.sliding_tab_layout);
this.mview = view;
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Bundle bundle = getArguments();
if (bundle != null) {
complaintId = bundle.getString("id");
sessionID = bundle.getString("sessionId");
userId = bundle.getString("userId");
userProfileUrl = bundle.getString("userProfileUrl");
callServerToGetDetailedComplaint();
}
}
private void callServerToGetDetailedComplaint() {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getComplaint("sessionid=" + sessionID, complaintId).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
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);
}
}
}
initTabViews(complaint);
//Make progress circle gone After loading
getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
if (t != null) {
Log.i(TAG, "error and t = " + t.toString());
}
}
});
}
private void initTabViews(final Venter.Complaint detailedComplaint) {
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});
styledAttributes.recycle();
//Replace second parameter to mActionBarSize = (int) styledAttributes.getDimension(0, 0) 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();
}
}
}
\ 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;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
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.TextView;
import java.util.List;
import app.insti.R;
import app.insti.Utils;
import app.insti.adapter.ComplaintsAdapter;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ComplaintsHomeFragment extends Fragment {
private ComplaintsAdapter homeListAdapter;
private SwipeRefreshLayout swipeContainer;
private static String TAG = ComplaintsHomeFragment.class.getSimpleName();
private boolean isCalled = false;
private TextView error_message_home;
private static String sID, uID, uProfileUrl;
public static ComplaintsHomeFragment getInstance(String sessionID, String userID, String userProfileUrl) {
sID = sessionID;
uID = userID;
uProfileUrl = userProfileUrl;
return new ComplaintsHomeFragment();
}
@Override
public void onStart() {
super.onStart();
swipeContainer.post(new Runnable() {
@Override
public void run() {
swipeContainer.setRefreshing(true);
callServerToGetNearbyComplaints();
}
});
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_complaints_home, container, false);
RecyclerView recyclerViewHome = view.findViewById(R.id.recyclerViewHome);
homeListAdapter = new ComplaintsAdapter(getActivity(), sID, uID, uProfileUrl);
swipeContainer = view.findViewById(R.id.swipeContainer);
error_message_home = view.findViewById(R.id.error_message_home);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
recyclerViewHome.setLayoutManager(llm);
recyclerViewHome.setHasFixedSize(true);
recyclerViewHome.setAdapter(homeListAdapter);
swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
callServerToGetNearbyComplaints();
}
});
swipeContainer.setColorSchemeResources(R.color.colorPrimary);
if (!isCalled) {
swipeContainer.post(new Runnable() {
@Override
public void run() {
swipeContainer.setRefreshing(true);
callServerToGetNearbyComplaints();
}
});
isCalled = true;
}
return view;
}
private void callServerToGetNearbyComplaints() {
try {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getAllComplaints("sessionid=" + sID).enqueue(new Callback<List<Venter.Complaint>>() {
@Override
public void onResponse(@NonNull Call<List<Venter.Complaint>> call, @NonNull Response<List<Venter.Complaint>> response) {
if (response.body() != null && !(response.body().isEmpty())) {
Log.i(TAG, "response.body != null");
Log.i(TAG, "response: " + response.body());
initialiseRecyclerView(response.body());
swipeContainer.setRefreshing(false);
} else {
Log.i(TAG, "response.body is empty");
error_message_home.setVisibility(View.VISIBLE);
error_message_home.setText(getString(R.string.no_complaints));
swipeContainer.setRefreshing(false);
}
}
@Override
public void onFailure(@NonNull Call<List<Venter.Complaint>> call, @NonNull Throwable t) {
Log.i(TAG, "failure" + t.toString());
swipeContainer.setRefreshing(false);
error_message_home.setVisibility(View.VISIBLE);
}
});
} catch (Exception e) {
e.printStackTrace();
swipeContainer.setRefreshing(false);
}
}
private void initialiseRecyclerView(List<Venter.Complaint> list) {
homeListAdapter.setcomplaintList(list);
homeListAdapter.notifyDataSetChanged();
}
}
package app.insti.fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
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.TextView;
import java.util.List;
import app.insti.R;
import app.insti.Utils;
import app.insti.adapter.ComplaintsAdapter;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ComplaintsMeFragment extends Fragment {
private static String uID, sID, uProfileUrl;
private ComplaintsAdapter meListAdapter;
private TextView error_message_me;
private SwipeRefreshLayout swipeContainer;
private static String TAG = ComplaintsMeFragment.class.getSimpleName();
private boolean isCalled = false;
public static ComplaintsMeFragment getInstance(String sessionID, String userID, String userProfileUrl) {
sID = sessionID;
uID = userID;
uProfileUrl = userProfileUrl;
return new ComplaintsMeFragment();
}
@Override
public void onStart() {
super.onStart();
swipeContainer.post(new Runnable() {
@Override
public void run() {
swipeContainer.setRefreshing(true);
getMeItems();
}
});
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_complaints_me, container, false);
RecyclerView recyclerViewMe = view.findViewById(R.id.recyclerViewMe);
meListAdapter = new ComplaintsAdapter(getActivity(), sID, uID, uProfileUrl);
swipeContainer = view.findViewById(R.id.swipeContainer);
error_message_me = view.findViewById(R.id.error_message_me);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
recyclerViewMe.setLayoutManager(llm);
recyclerViewMe.setHasFixedSize(true);
recyclerViewMe.setAdapter(meListAdapter);
swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
getMeItems();
}
});
swipeContainer.setColorSchemeColors(getResources().getColor(R.color.colorPrimary));
if (!isCalled) {
swipeContainer.post(new Runnable() {
@Override
public void run() {
swipeContainer.setRefreshing(true);
getMeItems();
}
});
isCalled = true;
}
return view;
}
private void getMeItems() {
callServerToGetMyComplaints();
}
private void callServerToGetMyComplaints() {
try {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getUserComplaints("sessionid=" + sID).enqueue(new Callback<List<Venter.Complaint>>() {
@Override
public void onResponse(@NonNull Call<List<Venter.Complaint>> call, @NonNull Response<List<Venter.Complaint>> response) {
if (response.body() != null && !(response.body().isEmpty())) {
Log.i(TAG, "response.body != null");
Log.i(TAG, "response: " + response.body());
initialiseRecyclerView(response.body());
swipeContainer.setRefreshing(false);
} else {
error_message_me.setVisibility(View.VISIBLE);
error_message_me.setText(getString(R.string.no_complaints));
swipeContainer.setRefreshing(false);
}
}
@Override
public void onFailure(@NonNull Call<List<Venter.Complaint>> call, @NonNull Throwable t) {
Log.i(TAG, "failure" + t.toString());
swipeContainer.setRefreshing(false);
error_message_me.setVisibility(View.VISIBLE);
}
});
} catch (Exception e) {
e.printStackTrace();
swipeContainer.setRefreshing(false);
}
}
private void initialiseRecyclerView(List<Venter.Complaint> list) {
meListAdapter.setcomplaintList(list);
meListAdapter.notifyDataSetChanged();
}
}
package app.insti.fragment;
import android.Manifest;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Base64;
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.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Toast;
import com.cunoraz.tagview.Tag;
import com.cunoraz.tagview.TagView;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.ResolvableApiException;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResponse;
import com.google.android.gms.location.LocationSettingsStatusCodes;
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.ui.PlaceAutocompleteFragment;
import com.google.android.gms.location.places.ui.PlaceSelectionListener;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
import app.insti.Constants;
import app.insti.ComplaintDescriptionAutoCompleteTextView;
import app.insti.R;
import app.insti.ComplaintTag;
import app.insti.Utils;
import app.insti.activity.MainActivity;
import app.insti.adapter.ImageViewPagerAdapter;
import app.insti.api.LocationAPIUtils;
import app.insti.api.RetrofitInterface;
import app.insti.api.request.ComplaintCreateRequest;
import app.insti.api.request.ImageUploadRequest;
import app.insti.api.response.ComplaintCreateResponse;
import app.insti.api.response.ImageUploadResponse;
import app.insti.utils.TagCategories;
import me.relex.circleindicator.CircleIndicator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
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.REQUEST_CAMERA_INT_ID;
import static app.insti.Constants.RESULT_LOAD_IMAGE;
public class FileComplaintFragment extends Fragment {
private static final String TAG = FileComplaintFragment.class.getSimpleName();
private static FileComplaintFragment mainactivity;
private Button buttonSubmit;
private ComplaintDescriptionAutoCompleteTextView descriptionAutoCompleteTextview;
private EditText editTextSuggestions;
private EditText editTextTags;
private EditText editTextLocationDetails;
private MapView mMapView;
private GoogleMap googleMap;
private TagView tagView;
private TagView tagViewPopulate;
private ScrollView tagsLayout;
private LatLng Location;
private String Address;
private List<String> Tags;
private ArrayList<ComplaintTag> tagList;
private List<String> uploadedImagesUrl = new ArrayList<>();
private int cursor = 1;
private List<ComplaintTag> tagList2 = new ArrayList<>();
private String base64Image;
private ImageViewPagerAdapter imageViewPagerAdapter;
private ViewPager viewPager;
private CircleIndicator indicator;
private RelativeLayout layout_buttons;
private String userId;
private View view;
private NestedScrollView nestedScrollView;
private boolean GPSIsSetup = false;
private ProgressDialog progressDialog;
private CollapsingToolbarLayout collapsing_toolbar;
private LinearLayout linearLayoutAnalyse;
private LinearLayout linearLayoutScrollTags;
private boolean userAddedTag = false;
private ImageButton imageButtonAddTags;
private Button buttonAnalysis;
private ImageButton imageActionButton;
public static FileComplaintFragment getMainActivity() {
return mainactivity;
}
@Override
public void onDestroyView() {
super.onDestroyView();
android.app.FragmentManager fragmentManager = getActivity().getFragmentManager();
PlaceAutocompleteFragment fragment = (PlaceAutocompleteFragment) fragmentManager.findFragmentById(R.id.place_autocomplete_fragment);
android.app.FragmentTransaction ft = fragmentManager.beginTransaction();
ft.remove(fragment);
ft.commit();
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
mainactivity = this;
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
if (view != null) {
ViewGroup parent = (ViewGroup) view.getParent();
if (parent != null)
parent.removeView(view);
}
view = inflater.inflate(R.layout.fragment_file_complaint, container, false);
bundleCollection();
prepareTags();
progressDialog = new ProgressDialog(getContext());
final Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Add Complaint");
initviews(view);
editTextTags.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//Before Text Changed
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
linearLayoutScrollTags.setVisibility(View.VISIBLE);
setTags(s);
}
@Override
public void afterTextChanged(Editable s) {
//After Text Changed
}
});
imageActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
giveOptionsToAddImage();
}
});
imageButtonAddTags.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Add Tags
addUserTags();
}
});
buttonSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
submitComplaint();
}
});
buttonAnalysis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showAnalysis();
}
});
descriptionAutoCompleteTextview.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
searchComplaint(hasFocus);
}
});
mMapView.onCreate(savedInstanceState);
mMapView.onResume();
getMapReady();
//Autocomplete location bar
autoLocation();
//ends here
tagView.setOnTagDeleteListener(new TagView.OnTagDeleteListener() {
@Override
public void onTagDeleted(TagView tagView, Tag tag, int i) {
//Delete Tag
deleteTag(tagView, tag, i);
}
});
tagViewPopulate.setOnTagClickListener(new TagView.OnTagClickListener() {
@Override
public void onTagClick(Tag tag, int i) {
//Add Tags
addTags(tag);
}
});
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);
collapsing_toolbar = view.findViewById(R.id.collapsing_toolbar);
collapsing_toolbar.setVisibility(View.GONE);
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);
linearLayoutScrollTags = view.findViewById(R.id.linearLayoutScrollTags);
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.add_image);
imageButtonAddTags = view.findViewById(R.id.imageButtonAddTags);
editTextSuggestions = view.findViewById(R.id.editTextSuggestions);
editTextLocationDetails = view.findViewById(R.id.editTextLocationDetails);
editTextTags = view.findViewById(R.id.editTextTags);
descriptionAutoCompleteTextview = 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);
}
private void bundleCollection() {
Bundle bundle = getArguments();
userId = bundle.getString(Constants.USER_ID);
}
private void searchComplaint(boolean hasFocus) {
if (!hasFocus) {
if (!(descriptionAutoCompleteTextview.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);
}
}
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() {
Log.i(TAG, "in getMapReady");
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap map) {
googleMap = map;
UiSettings uiSettings = googleMap.getUiSettings();
uiSettings.setAllGesturesEnabled(true);
uiSettings.setZoomControlsEnabled(true);
uiSettings.setMyLocationButtonEnabled(true);
uiSettings.setIndoorLevelPickerEnabled(true);
uiSettings.setScrollGesturesEnabled(true);
if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "No initial permission granted");
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_LOCATION);
} else {
Log.i(TAG, "Initial Permission Granted");
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
@Override
public boolean onMyLocationButtonClick() {
Log.i(TAG, "in onMyLocationButtonClick");
locate();
return false;
}
});
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity());
mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
// Got last known location. In some rare situations this can be null.
if (location != null) {
// Logic to handle location object
Log.i(TAG, "lat = " + location.getLatitude() + " lon = " + location.getLongitude());
Location = new LatLng(location.getLatitude(), location.getLongitude());
updateMap(Location, "Current Location", location.getLatitude() + ", " + location.getLongitude(), cursor);
} else {
Toast.makeText(getContext(), getString(R.string.getting_current_location), Toast.LENGTH_SHORT).show();
}
}
});
mFusedLocationClient.getLastLocation().addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
e.printStackTrace();
}
});
}
}
});
}
private void locate() {
Log.i(TAG, "In locate");
if (!GPSIsSetup) {
Log.i(TAG, "GPS not enabled");
displayLocationSettingsRequest();
} else {
Log.i(TAG, "GPS enabled");
try {
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity());
mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
// Got last known location. In some rare situations this can be null.
if (location != null) {
// Logic to handle location object
Log.i(TAG, "lat = " + location.getLatitude() + " lon = " + location.getLongitude());
Location = new LatLng(location.getLatitude(), location.getLongitude());
updateMap(Location, "Current Location", location.getLatitude() + ", " + location.getLongitude(), cursor);
} else {
Toast.makeText(getContext(), getString(R.string.getting_current_location), Toast.LENGTH_SHORT).show();
}
}
});
mFusedLocationClient.getLastLocation().addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
e.printStackTrace();
Toast.makeText(getContext(), "Something went wrong while getting your location \n" + e, Toast.LENGTH_LONG).show();
}
});
GPSIsSetup = true;
} catch (SecurityException ignored) {
Toast.makeText(getContext(), getString(R.string.no_permission), Toast.LENGTH_LONG).show();
}
}
}
private void displayLocationSettingsRequest() {
Log.i(TAG, "In displayLocationSettingsRequest");
if (getView() == null || getActivity() == null) return;
LocationRequest mLocationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setInterval(10 * 1000)
.setFastestInterval(1 * 1000);
LocationSettingsRequest.Builder settingsBuilder = new LocationSettingsRequest.Builder()
.addLocationRequest(mLocationRequest);
settingsBuilder.setAlwaysShow(true);
Task<LocationSettingsResponse> result = LocationServices.getSettingsClient(getActivity())
.checkLocationSettings(settingsBuilder.build());
result.addOnCompleteListener(new OnCompleteListener<LocationSettingsResponse>() {
@Override
public void onComplete(@NonNull Task<LocationSettingsResponse> task) {
try {
Log.i(TAG, "In displayLocationSettingsRequest try");
LocationSettingsResponse result = task.getResult(ApiException.class);
if (result.getLocationSettingsStates().isGpsPresent() &&
result.getLocationSettingsStates().isGpsUsable() &&
result.getLocationSettingsStates().isLocationPresent() &&
result.getLocationSettingsStates().isLocationUsable()) {
Log.i(TAG, "In displayLocationSettingsRequest if setupGPS called");
setupGPS();
}
} catch (ApiException ex) {
Log.i(TAG, "In displayLocationSettingsRequest catch");
switch (ex.getStatusCode()) {
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
ResolvableApiException resolvableApiException =
(ResolvableApiException) ex;
resolvableApiException
.startResolutionForResult(getActivity(), 87);
Log.i(TAG, "In displayLocationSettingsRequest catch case1 try setupGPS called");
setupGPS();
} catch (IntentSender.SendIntentException e) {
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Toast.makeText(getContext(), getString(R.string.GPS_not_enables), Toast.LENGTH_LONG).show();
break;
default:
Toast.makeText(getContext(), getString(R.string.GPS_not_enables), Toast.LENGTH_LONG).show();
break;
}
}
}
});
}
private void setupGPS() {
Log.i(TAG, "In setup");
if (getView() == null || getActivity() == null) return;
// Permissions stuff
if (ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_LOCATION);
} else {
try {
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity());
mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
// Got last known location. In some rare situations this can be null.
if (location != null) {
// Logic to handle location object
Log.i(TAG, "lat = " + location.getLatitude() + " lon = " + location.getLongitude());
Location = new LatLng(location.getLatitude(), location.getLongitude());
updateMap(Location, "Current Location", location.getLatitude() + ", " + location.getLongitude(), cursor);
} else {
Toast.makeText(getContext(), getString(R.string.getting_current_location), Toast.LENGTH_SHORT).show();
}
}
});
mFusedLocationClient.getLastLocation().addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
e.printStackTrace();
}
});
GPSIsSetup = true;
} catch (SecurityException ignored) {
Toast.makeText(getContext(), getString(R.string.no_permission), Toast.LENGTH_LONG).show();
}
}
}
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())) {
tagList2.add(new ComplaintTag(cs));
ArrayList<Tag> tags = new ArrayList<>();
Tag tag;
for (int i = 0; i < tagList2.size(); i++) {
tag = new Tag(tagList2.get(i).getName());
tag.radius = 10f;
tag.isDeletable = true;
tags.add(tag);
}
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 {
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);
Toast.makeText(getContext(), "Please enter some tags", Toast.LENGTH_SHORT).show();
}
}
private void setTags(CharSequence cs) {
int counter = 0;
if (!cs.toString().equals("")) {
String text = cs.toString();
ArrayList<Tag> tags = new ArrayList<>();
Tag tag;
for (int i = 0; i < tagList.size(); i++) {
if (tagList.get(i).getName().toLowerCase().contains(text.toLowerCase())) {
linearLayoutScrollTags.setVisibility(View.VISIBLE);
tagsLayout.setVisibility(View.VISIBLE);
tag = new Tag(tagList.get(i).getName());
tag.radius = 10f;
tag.isDeletable = false;
tags.add(tag);
counter++;
}
}
if (counter != 0) {
tagViewPopulate.addTags(tags);
} else {
linearLayoutScrollTags.setVisibility(View.GONE);
}
} else {
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);
tagViewPopulate.addTags(new ArrayList<Tag>());
return;
}
tagsLayout.post(new Runnable() {
@Override
public void run() {
nestedScrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
private void prepareTags() {
tagList = new ArrayList<>();
try {
for (int i = 0; i < TagCategories.CATEGORIES.length; i++) {
tagList.add(new ComplaintTag(TagCategories.CATEGORIES[i]));
}
} catch (Exception e) {
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() {
final String complaint = "Complaint: " + descriptionAutoCompleteTextview.getText().toString();
final String suggestion;
final String locationDetails;
Log.i(TAG, "Suggestion: " + editTextSuggestions.getText().toString());
if (!(editTextSuggestions.getText().toString().isEmpty())) {
suggestion = "\nSuggestion: " + editTextSuggestions.getText().toString();
} else {
suggestion = "";
}
if (!(editTextLocationDetails.getText().toString().isEmpty())) {
locationDetails = "\nLocation Details: " + editTextLocationDetails.getText().toString();
} else {
locationDetails = "";
}
if (Location == null) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response!
new AlertDialog.Builder(getContext())
.setTitle("Location Needed")
.setMessage("You have not specified your location. The app will by default make \"IIT Area\" as your location.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Location = new LatLng(19.133810, 72.913257);
Address = "IIT Area";
ComplaintCreateRequest complaintCreateRequest = new ComplaintCreateRequest(complaint + suggestion + locationDetails, Address, (float) Location.latitude, (float) Location.longitude, Tags, uploadedImagesUrl);
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.postComplaint("sessionid=" + getArguments().getString(Constants.SESSION_ID), complaintCreateRequest).enqueue(new Callback<ComplaintCreateResponse>() {
@Override
public void onResponse(Call<ComplaintCreateResponse> call, Response<ComplaintCreateResponse> response) {
Toast.makeText(getContext(), "Complaint successfully posted", Toast.LENGTH_LONG).show();
Bundle bundle = getArguments();
bundle.putString(Constants.USER_ID, userId);
ComplaintsFragment complaintsFragment = new ComplaintsFragment();
complaintsFragment.setArguments(bundle);
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, complaintsFragment, complaintsFragment.getTag());
transaction.addToBackStack(complaintsFragment.getTag());
manager.popBackStackImmediate("Complaint Fragment", FragmentManager.POP_BACK_STACK_INCLUSIVE);
transaction.commit();
}
@Override
public void onFailure(Call<ComplaintCreateResponse> call, Throwable t) {
Log.i(TAG, "failure in addComplaint: " + t.toString());
Toast.makeText(getContext(), "Complaint Creation Failed", Toast.LENGTH_SHORT).show();
}
});
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getContext(), "Submission aborted", Toast.LENGTH_SHORT).show();
dialog.cancel();
}
})
.create()
.show();
} else {
ComplaintCreateRequest complaintCreateRequest = new ComplaintCreateRequest(complaint + suggestion + locationDetails, Address, (float) Location.latitude, (float) Location.longitude, Tags, uploadedImagesUrl);
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.postComplaint("sessionid=" + getArguments().getString(Constants.SESSION_ID), complaintCreateRequest).enqueue(new Callback<ComplaintCreateResponse>() {
@Override
public void onResponse(Call<ComplaintCreateResponse> call, Response<ComplaintCreateResponse> response) {
Toast.makeText(getContext(), "Complaint successfully posted", Toast.LENGTH_LONG).show();
Bundle bundle = getArguments();
bundle.putString(Constants.USER_ID, userId);
ComplaintsFragment complaintsFragment = new ComplaintsFragment();
complaintsFragment.setArguments(bundle);
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, complaintsFragment, complaintsFragment.getTag());
transaction.addToBackStack(complaintsFragment.getTag());
manager.popBackStackImmediate("Complaint Fragment", FragmentManager.POP_BACK_STACK_INCLUSIVE);
transaction.commit();
}
@Override
public void onFailure(Call<ComplaintCreateResponse> call, Throwable t) {
Log.i(TAG, "failure in addComplaint: " + t.toString());
Toast.makeText(getContext(), "Complaint Creation Failed", Toast.LENGTH_SHORT).show();
}
});
}
}
private void updateMap(LatLng Location, String Name, String Address, int cursor) {
Log.i(TAG, "In updateMap");
LocationAPIUtils locationAPIUtils = new LocationAPIUtils(googleMap, mMapView);
locationAPIUtils.callGoogleToShowLocationOnMap(Location, Name, Address, cursor);
showAnalysis();
}
private void showAnalysis() {
/* Machine Learning Part */
}
private void giveOptionsToAddImage() {
final CharSequence[] items = {getString(R.string.take_photo_using_camera), getString(R.string.choose_from_library)};
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.add_photo);
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
if (items[item].equals(getString(R.string.take_photo_using_camera))) {
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
}
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(intent, REQUEST_CAMERA_INT_ID);
}
} else if (items[item].equals(getString(R.string.choose_from_library))) {
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
}
Intent intent = new Intent(
Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(intent, RESULT_LOAD_IMAGE);
} else {
dialog.dismiss();
}
}
});
builder.show();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CAMERA_INT_ID && data != null) {
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.show();
Bundle bundle = data.getExtras();
Bitmap bitmap = (Bitmap) bundle.get("data");
base64Image = convertImageToString(bitmap);
collapsing_toolbar.setVisibility(View.VISIBLE);
sendImage();
} else if (resultCode == Activity.RESULT_OK && requestCode == RESULT_LOAD_IMAGE && data != null) {
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.show();
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getActivity().getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
base64Image = convertImageToString(getScaledBitmap(picturePath, 800, 800));
collapsing_toolbar.setVisibility(View.VISIBLE);
sendImage();
}
}
private void sendImage() {
progressDialog.setMessage("Uploading Image");
ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image);
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.uploadImage("sessionid=" + getArguments().getString(Constants.SESSION_ID), imageUploadRequest).enqueue(new Callback<ImageUploadResponse>() {
@Override
public void onResponse(Call<ImageUploadResponse> call, Response<ImageUploadResponse> response) {
if (response.isSuccessful()) {
ImageUploadResponse imageUploadResponse = response.body();
uploadedImagesUrl.add(imageUploadResponse.getPictureURL());
showImage(uploadedImagesUrl);
Log.i(TAG, "ImageURL: " + uploadedImagesUrl.toString());
} else {
progressDialog.dismiss();
Toast.makeText(getContext(), getString(R.string.error_message), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Call<ImageUploadResponse> call, Throwable t) {
Log.i(TAG, "failure in sendImage: " + t.toString());
progressDialog.dismiss();
Toast.makeText(getContext(), getString(R.string.error_message), Toast.LENGTH_LONG).show();
}
});
}
private void showImage(List<String> uploadedImagesUrl) {
if (viewPager != null) {
try {
imageViewPagerAdapter = new ImageViewPagerAdapter(getActivity(), uploadedImagesUrl);
collapsing_toolbar.setVisibility(View.VISIBLE);
viewPager.setAdapter(imageViewPagerAdapter);
indicator.setViewPager(viewPager);
imageViewPagerAdapter.registerDataSetObserver(indicator.getDataSetObserver());
viewPager.getAdapter().notifyDataSetChanged();
synchronized (viewPager) {
viewPager.notifyAll();
}
imageViewPagerAdapter.notifyDataSetChanged();
progressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private Bitmap getScaledBitmap(String picturePath, int width, int height) {
BitmapFactory.Options sizeOptions = new BitmapFactory.Options();
sizeOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(picturePath, sizeOptions);
int inSampleSize = calculaInSampleSize(sizeOptions, width, height);
sizeOptions.inJustDecodeBounds = false;
sizeOptions.inSampleSize = inSampleSize;
return BitmapFactory.decodeFile(picturePath, sizeOptions);
}
private int calculaInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
// Calculate ratios of height and width to requested height and
// width
final int heightRatio = Math.round((float) height / (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
// Choose the smallest ratio as inSampleSize value, this will
// guarantee
// a final image with both dimensions larger than or equal to the
// requested height and width.
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
}
private String convertImageToString(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
if (bitmap != null) {
bitmap.compress(Bitmap.CompressFormat.JPEG, 60, stream);
byte[] byteArray = stream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
} else {
return null;
}
}
}
\ No newline at end of file
package app.insti.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
public class DateTimeUtil {
public static String getDate(String dtStart) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+05:30'");
try {
Date date = format.parse(dtStart);
Date now = new Date();
long diff = System.currentTimeMillis() - date.getTime();
long seconds = TimeUnit.MILLISECONDS.toSeconds(now.getTime() - date.getTime());
long minutes = TimeUnit.MILLISECONDS.toMinutes(now.getTime() - date.getTime());
long hours = TimeUnit.MILLISECONDS.toHours(now.getTime() - date.getTime());
if (seconds <= 0) {
return "now";
} else if (seconds < 60 && seconds > 1) {
return seconds + " seconds ago";
} else if (minutes == 1) {
return " 1 minute ago";
} else if (minutes < 60 && minutes > 1) {
return minutes + " minutes ago";
} else if (hours == 1) {
return "an hour ago";
} else if (hours < 24 && hours > 1) {
return hours + " hours ago";
} else {
long days = Math.round(diff / (24.0 * 60 * 60 * 1000));
if (days == 0)
return "today";
else if (days == 1)
return "yesterday";
else if (days == 1)
return "a day ago";
else if (days < 14)
return days + " days ago";
else if (days < 30)
if ((int) (days / 7) == 1)
return "a week ago";
else
return ((int) (days / 7)) + " weeks ago";
else if (days < 365)
if ((int) (days / 30) == 1)
return ((int) (days / 30)) + " month ago";
else
return ((int) (days / 30)) + " months ago";
else
if ((int) (days / 365) == 1)
return "a year ago";
else
return ((int) (days / 365)) + " years ago";
}
} catch (ParseException e) {
e.printStackTrace();
}
return "";
}
}
\ No newline at end of file
package app.insti.utils;
/**
* Created by Shivam Sharma on 13-08-2018.
*/
public class TagCategories {
public static final String[] CATEGORIES = new String[]{
"Used Flexes",
"Plastic Bottles (in Hostel messes)",
"Placards on Trees",
"Request for donation of clothes",
"Other donations",
"Cattle Issues",
"Autorickshaws",
"Potholes in Roads",
"Broken stormwater drains",
"Desilting - lakes",
"Flooding of roads and footpaths",
"Damaged footbaths",
"Garbage issues",
"Illegal posters and boardings",
"Manholes",
"Streetlights issues",
"Sewage drains issues",
"Toilets infrastructural issues",
"Fencing issues",
"Security issues",
"Infrastructural defaults in the academic area",
"Cycle pooling issues",
"Water coolers & Aqua Guards",
"Mess menu complaints",
"PHO cleaning complaints",
"PHO cleaning complaints",
"Hostel common room complaints",
"Hostel Stationary shop complaints"
};
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="2"
android:useLevel="false" >
<solid
android:color="@android:color/black"/>
<stroke
android:width="1dp"
android:color="@android:color/white" />
</shape>
\ No newline at end of file
<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>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM13,14h-2v-2h2v2zM13,10h-2L11,6h2v4z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</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"/>
<stroke android:width="1dp" android:color="@color/colorPrimary"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<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/cardViewComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:layout_margin="5dp"
android:padding="10dp"
app:cardUseCompatPadding="true"
app:cardBackgroundColor="@color/colorWhite"
app:cardCornerRadius="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageViewUserImage"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="@+id/textViewUserComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Name"
android:textColor="@android:color/black"
android:textSize="18sp" />
<TextView
android:id="@+id/textViewTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time of Comment" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:scrollHorizontally="true"
android:text="Comment"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:layout_margin="5dp"
card_view:cardBackgroundColor="@color/colorWhite"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4">
<TextView
android:id="@+id/textViewUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="User"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="10dp"
android:text="status"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"
android:background="@drawable/customborder" />
</LinearLayout>
<TextView
android:id="@+id/textViewReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="report date"
android:textColor="@color/colorGray"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="location"
android:textColor="@color/colorGray"
android:textSize="14sp" />
<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="location"
android:textColor="@android:color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:paddingStart="50dp"
android:paddingEnd="20dp"
android:weightSum="2"
android:background="@drawable/customborder">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="2">
<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
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="2">
<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>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<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_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">
<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/colorPrimary"
android:background="@color/colorWhite"
app:tabTextColor="@color/colorGray"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
app:tabSelectedTextColor="#4a4a4a"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tab_viewpager_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<!--Progress Bar will show unless the data is being loaded-->
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:theme="@style/BlueAccent" />
</RelativeLayout>
</LinearLayout>
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/nestedScrollViewComplaintDetail">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="2dp"
android:orientation="vertical"
android:paddingTop="10dp">
<LinearLayout
android:id="@+id/image_holder_view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/complaint_image_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<me.relex.circleindicator.CircleIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="48dp"
app:ci_animator="@animator/scale_with_alpha"
app:ci_drawable="@drawable/selected_dot" />
</RelativeLayout>
</LinearLayout>
<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: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_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"
android:src="@drawable/baseline_send_black_18" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutUpVotes"
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/up_vote_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<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_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>
<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
<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_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ededed">
<TextView
android:id="@+id/error_message_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:text="@string/error_message"
android:textColor="@color/secondaryTextColor"
android:visibility="invisible" />
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewHome"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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="0dp"
android:layout_weight="1"
android:background="#ededed">
<TextView
android:id="@+id/error_message_me"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:text="@string/error_message"
android:textColor="@color/secondaryTextColor"
android:visibility="gone" />
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewMe"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="vertical"
tools:context="app.insti.fragment.FileComplaintFragment">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Widget.AppCompat.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
app:contentScrim="@android:color/white"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:id="@+id/image_holder_view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:orientation="vertical"
app:layout_collapseMode="parallax">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/complaint_image_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<me.relex.circleindicator.CircleIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="48dp"
app:ci_animator="@animator/scale_with_alpha"
app:ci_drawable="@drawable/selected_dot"
app:ci_drawable_unselected="@drawable/white_radius" />
</RelativeLayout>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="vertical">
<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:paddingHorizontal="5dp"
android:weightSum="10">
<android.support.design.widget.TextInputLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/editTextIncCreditScoreLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="8"
app:hintTextAppearance="@style/edit_text_hint_apperarance">
<app.insti.ComplaintDescriptionAutoCompleteTextView
android:id="@+id/dynamicAutoCompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:hint="Enter Description"
android:imeOptions="flagNoExtractUi|actionSearch"
android:inputType="textMultiLine"
android:minLines="3"
android:textColor="@android:color/black"
android:textColorHint="#4a4a4a"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
<ProgressBar
android:id="@+id/pb_loading_indicator"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:visibility="gone" />
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/add_image"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:layout_weight="1"
style="@style/Widget.AppCompat.Button.Borderless"
android:src="@drawable/ic_add_a_photo_black_24dp" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="5dp">
<android.support.design.widget.TextInputLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/edit_text_hint_apperarance">
<EditText
android:id="@+id/editTextSuggestions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:hint="@string/enter_suggestions_if_any"
android:inputType="textMultiLine"
android:minLines="3"
android:textColor="@android:color/black"
android:textColorHint="#4a4a4a"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="5dp">
<android.support.design.widget.TextInputLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/edit_text_hint_apperarance">
<EditText
android:id="@+id/editTextLocationDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:hint="@string/enter_location_details"
android:inputType="textMultiLine"
android:minLines="3"
android:textColor="@android:color/black"
android:textColorHint="#4a4a4a"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
</FrameLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5sp"
android:paddingHorizontal="5dp">
<fragment
android:id="@+id/place_autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:id="@+id/layoutAnalyse"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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="300dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.cunoraz.tagview.TagView
android:id="@+id/tag_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingHorizontal="5dp"
android:weightSum="100">
<android.support.design.widget.TextInputLayout
android:id="@+id/textLayoutTags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="90"
app:hintTextAppearance="@style/edit_text_hint_apperarance">
<EditText
android:id="@+id/editTextTags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Add Tags"
android:inputType="text"
android:textColor="@android:color/black"
android:textColorHint="#66000000"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/imageButtonAddTags"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="10"
style="@style/Widget.AppCompat.Button.Borderless"
app:srcCompat="@drawable/ic_add_black_24dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutScrollTags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:id="@+id/tags_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:background="@android:color/white"
android:visibility="invisible">
<com.cunoraz.tagview.TagView
android:id="@+id/tag_populate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
</ScrollView>
<View
android:id="@+id/viewTagsLayout"
android:layout_width="match_parent"
android:layout_height="17dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<RelativeLayout
android:id="@+id/layout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTintMode="screen"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="2"
android:layout_gravity="bottom">
<Button
android:id="@+id/button_analysis"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:text="ANALYSIS"
android:textColor="@color/colorWhite" />
<Button
android:id="@+id/buttonSubmit"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@color/colorSecondary"
android:text="SUBMIT"
android:textColor="@color/secondaryTextColor" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/slidingImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<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_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:layout_margin="5dp"
android:padding="10dp"
app:cardUseCompatPadding="true"
app:cardBackgroundColor="@color/colorWhite"
app:cardCornerRadius="0dp">>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="4dp"
android:paddingLeft="18dp"
android:paddingRight="10dp"
android:paddingTop="4dp">
<LinearLayout
android:id="@+id/layoutUpVote"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageViewUserUpVoteImage"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="@+id/textViewUserUpVoteName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Name"
android:textColor="@android:color/black"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
...@@ -43,6 +43,11 @@ ...@@ -43,6 +43,11 @@
android:icon="@drawable/ic_map_black_48dp" android:icon="@drawable/ic_map_black_48dp"
android:title="Map" /> android:title="Map" />
<item
android:id="@+id/nav_complaint"
android:icon="@drawable/baseline_feedback_black_48"
android:title="Complaints/Suggestions" />
<item <item
android:id="@+id/nav_qlinks" android:id="@+id/nav_qlinks"
android:icon="@drawable/ic_link_black_24dp" android:icon="@drawable/ic_link_black_24dp"
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/copy_comment_option"
android:title="Copy"/>
<item
android:id="@+id/delete_comment_option"
android:title="Delete"/>
</menu>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/copy_comment_option"
android:title="Copy" />
</menu>
\ No newline at end of file
...@@ -9,8 +9,12 @@ ...@@ -9,8 +9,12 @@
<color name="primaryTextColor">#fafafa</color> <color name="primaryTextColor">#fafafa</color>
<color name="secondaryTextColor">#000000</color> <color name="secondaryTextColor">#000000</color>
<color name="colorCalendarWeek">#000000</color> <color name="colorCalendarWeek">#000000</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="colorGreen">#00FF00</color>
<!-- Map --> <!-- Map -->
<item name="transparent_black" type="color">#20000000</item> <item name="transparent_black" type="color">#20000000</item>
<item name="list_item_gray_even" type="color">#ffe6e6e6</item> <item name="list_item_gray_even" type="color">#ffe6e6e6</item>
......
...@@ -32,4 +32,22 @@ ...@@ -32,4 +32,22 @@
</string-array> </string-array>
<string name="default_notification_channel_id">INSTIAPP_NOTIFS</string> <string name="default_notification_channel_id">INSTIAPP_NOTIFS</string>
<!--NSS side-->
<string name="google_maps_api_key">AIzaSyC0T4chZbdcKjLkgEts9YVonPFyP7ckMIE</string>
<string name="take_photo_using_camera">Take photo using Camera</string>
<string name="choose_from_library">Choose from gallery</string>
<string name="add_photo">Add Image</string>
<string name="vent_your_issues_now">Vent your issues now!</string>
<string name="venter_super_head">Nobody taking care of your civic complaints? Be it garbage, water, potholes etc.</string>
<string name="error_message">Please check your Network Connectivity</string>
<string name="enter_comment">Enter Comment</string>
<string name="enter_suggestions_if_any">Enter Suggestions (if any)</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="getting_current_location">Getting current location.</string>
<string name="GPS_not_enables">GPS is not enabled!</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>
</resources> </resources>
...@@ -39,4 +39,18 @@ ...@@ -39,4 +39,18 @@
<item name="android:textSize">18sp</item> <item name="android:textSize">18sp</item>
</style> </style>
<style name="CustomTabLayout" parent="Widget.Design.TabLayout">
<item name="tabTextAppearance">@style/CustomTextAppearance</item>
</style>
<style name="CustomTextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textSize">15sp</item>
<item name="textAllCaps">false</item>
<item name="android:singleLine">true</item>
</style>
<style name="edit_text_hint_apperarance" parent="@android:style/TextAppearance">
<item name="android:textColor">#999</item>
<item name="android:textSize">12sp</item>
</style>
</resources> </resources>
...@@ -10,7 +10,7 @@ buildscript { ...@@ -10,7 +10,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.2.0' classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:3.2.0' classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
...@@ -22,6 +22,9 @@ allprojects { ...@@ -22,6 +22,9 @@ allprojects {
jcenter() jcenter()
maven { url 'https://maven.google.com' } maven { url 'https://maven.google.com' }
google() google()
maven {
url "https://jitpack.io"
}
} }
} }
......
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