Commit 8385ec05 authored by preetamozarde3's avatar preetamozarde3 Committed by GitHub

Merge pull request #1 from sshivam95/subbranch_nss-patch1

Subbranch nss patch1
parents be6dd191 7db0c351
...@@ -3,6 +3,7 @@ package app.insti.fragment; ...@@ -3,6 +3,7 @@ package app.insti.fragment;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentSender; import android.content.IntentSender;
...@@ -18,6 +19,7 @@ import android.provider.MediaStore; ...@@ -18,6 +19,7 @@ import android.provider.MediaStore;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
...@@ -33,10 +35,12 @@ import android.text.TextWatcher; ...@@ -33,10 +35,12 @@ import android.text.TextWatcher;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
...@@ -83,6 +87,7 @@ import app.insti.api.request.ComplaintCreateRequest; ...@@ -83,6 +87,7 @@ import app.insti.api.request.ComplaintCreateRequest;
import app.insti.api.request.ImageUploadRequest; import app.insti.api.request.ImageUploadRequest;
import app.insti.api.response.ComplaintCreateResponse; import app.insti.api.response.ComplaintCreateResponse;
import app.insti.api.response.ImageUploadResponse; import app.insti.api.response.ImageUploadResponse;
import app.insti.utils.CustomScrollView;
import app.insti.utils.TagCategories; import app.insti.utils.TagCategories;
import me.relex.circleindicator.CircleIndicator; import me.relex.circleindicator.CircleIndicator;
import retrofit2.Call; import retrofit2.Call;
...@@ -102,6 +107,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -102,6 +107,7 @@ public class FileComplaintFragment extends Fragment {
private CustomAutoCompleteTextView autoCompleteTextView; private CustomAutoCompleteTextView autoCompleteTextView;
private EditText editTextSuggestions; private EditText editTextSuggestions;
private EditText editTextTags; private EditText editTextTags;
private EditText editTextLocationDetails;
private MapView mMapView; private MapView mMapView;
GoogleMap googleMap; GoogleMap googleMap;
private TagView tagView; private TagView tagView;
...@@ -129,6 +135,8 @@ public class FileComplaintFragment extends Fragment { ...@@ -129,6 +135,8 @@ public class FileComplaintFragment extends Fragment {
private boolean GPSIsSetup = false; private boolean GPSIsSetup = false;
FusedLocationProviderClient mFusedLocationClient; FusedLocationProviderClient mFusedLocationClient;
ProgressDialog progressDialog; ProgressDialog progressDialog;
CollapsingToolbarLayout collapsing_toolbar;
LinearLayout linear_layout_file_complaint;
public FileComplaintFragment() { public FileComplaintFragment() {
// Required empty public constructor // Required empty public constructor
...@@ -175,6 +183,8 @@ public class FileComplaintFragment extends Fragment { ...@@ -175,6 +183,8 @@ public class FileComplaintFragment extends Fragment {
Bundle bundle = getArguments(); Bundle bundle = getArguments();
userId = bundle.getString(Constants.USER_ID); userId = bundle.getString(Constants.USER_ID);
/*mapLinearLayout = (LinearLayout) view.findViewById(R.id.mapLinearLayout);*/
prepareTags(); prepareTags();
progressDialog = new ProgressDialog(getContext()); progressDialog = new ProgressDialog(getContext());
...@@ -185,11 +195,15 @@ public class FileComplaintFragment extends Fragment { ...@@ -185,11 +195,15 @@ public class FileComplaintFragment extends Fragment {
getResources().getDisplayMetrics().heightPixels / 2 getResources().getDisplayMetrics().heightPixels / 2
); );
collapsing_toolbar = view.findViewById(R.id.collapsing_toolbar);
collapsing_toolbar.setVisibility(View.GONE);
imageViewHolder.setLayoutParams(layoutParams); imageViewHolder.setLayoutParams(layoutParams);
Toolbar toolbar = getActivity().findViewById(R.id.toolbar); Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Add Complaint"); toolbar.setTitle("Add Complaint");
nestedScrollView = view.findViewById(R.id.nested_scrollview); nestedScrollView = view.findViewById(R.id.nested_scrollview);
layout_buttons = view.findViewById(R.id.layout_buttons); layout_buttons = view.findViewById(R.id.layout_buttons);
layout_buttons.setVisibility(View.GONE); layout_buttons.setVisibility(View.GONE);
...@@ -206,14 +220,17 @@ public class FileComplaintFragment extends Fragment { ...@@ -206,14 +220,17 @@ public class FileComplaintFragment extends Fragment {
viewPager = view.findViewById(R.id.complaint_image_view_pager); viewPager = view.findViewById(R.id.complaint_image_view_pager);
indicator = view.findViewById(R.id.indicator); indicator = view.findViewById(R.id.indicator);
linearLayoutAddImage = view.findViewById(R.id.linearLayoutAddImage); linearLayoutAddImage = view.findViewById(R.id.linearLayoutAddImage);
linear_layout_file_complaint = view.findViewById(R.id.linear_layout_file_complaint);
floatingActionButton = view.findViewById(R.id.fabButton); floatingActionButton = view.findViewById(R.id.fabButton);
floatingActionButton.show();
floatingActionButton.setOnClickListener(new View.OnClickListener() { floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
giveOptionsToAddImage(); giveOptionsToAddImage();
} }
}); });
ImageButton imageButtonAddTags = (ImageButton) view.findViewById(R.id.imageButtonAddTags); ImageButton imageButtonAddTags = (ImageButton) view.findViewById(R.id.imageButtonAddTags);
autoCompleteTextView = (CustomAutoCompleteTextView) view.findViewById(R.id.dynamicAutoCompleteTextView); autoCompleteTextView = (CustomAutoCompleteTextView) view.findViewById(R.id.dynamicAutoCompleteTextView);
...@@ -238,6 +255,8 @@ public class FileComplaintFragment extends Fragment { ...@@ -238,6 +255,8 @@ public class FileComplaintFragment extends Fragment {
editTextSuggestions = view.findViewById(R.id.editTextSuggestions); editTextSuggestions = view.findViewById(R.id.editTextSuggestions);
editTextLocationDetails = view.findViewById(R.id.editTextLocationDetails);
editTextTags = view.findViewById(R.id.editTextTags); editTextTags = view.findViewById(R.id.editTextTags);
editTextTags.addTextChangedListener(new TextWatcher() { editTextTags.addTextChangedListener(new TextWatcher() {
...@@ -319,6 +338,8 @@ public class FileComplaintFragment extends Fragment { ...@@ -319,6 +338,8 @@ public class FileComplaintFragment extends Fragment {
}); });
// ends here // ends here
tagView = view.findViewById(R.id.tag_view); tagView = view.findViewById(R.id.tag_view);
tagView.setOnTagDeleteListener(new TagView.OnTagDeleteListener() { tagView.setOnTagDeleteListener(new TagView.OnTagDeleteListener() {
...@@ -370,6 +391,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -370,6 +391,7 @@ public class FileComplaintFragment extends Fragment {
} }
public void getMapReady() { public void getMapReady() {
Log.i(TAG, "in getMapReady"); Log.i(TAG, "in getMapReady");
mMapView.getMapAsync(new OnMapReadyCallback() { mMapView.getMapAsync(new OnMapReadyCallback() {
@Override @Override
...@@ -565,10 +587,12 @@ public class FileComplaintFragment extends Fragment { ...@@ -565,10 +587,12 @@ public class FileComplaintFragment extends Fragment {
@Override @Override
public void run() { public void run() {
nestedScrollView.fullScroll(ScrollView.FOCUS_DOWN); nestedScrollView.fullScroll(ScrollView.FOCUS_DOWN);
} }
}); });
} }
private void prepareTags() { private void prepareTags() {
tagList = new ArrayList<>(); tagList = new ArrayList<>();
try { try {
...@@ -583,38 +607,44 @@ public class FileComplaintFragment extends Fragment { ...@@ -583,38 +607,44 @@ public class FileComplaintFragment extends Fragment {
private void addComplaint() { private void addComplaint() {
String complaint = "Complaint: " + autoCompleteTextView.getText().toString(); String complaint = "Complaint: " + autoCompleteTextView.getText().toString();
String suggestion = null; String suggestion = null;
String locationDetails = null;
Log.i(TAG, "Suggestion: " + editTextSuggestions.getText().toString()); Log.i(TAG, "Suggestion: " + editTextSuggestions.getText().toString());
if (!(editTextSuggestions.getText().toString().isEmpty())) { if (!(editTextSuggestions.getText().toString().isEmpty())) {
suggestion = "\nSuggestion: " + editTextSuggestions.getText().toString(); suggestion = "\nSuggestion: " + editTextSuggestions.getText().toString();
} else { } else {
suggestion = ""; suggestion = "";
} }
if (Location == null) { if (!(editTextLocationDetails.getText().toString().isEmpty())) {
Toast.makeText(getContext(), "Please specify the location", Toast.LENGTH_LONG).show(); locationDetails = "\nLocation Details: " + editTextLocationDetails.getText().toString();
} else { } else {
ComplaintCreateRequest complaintCreateRequest = new ComplaintCreateRequest(complaint + suggestion, Address, (float) Location.latitude, (float) Location.longitude, Tags, uploadedImagesUrl); locationDetails = "";
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface(); }
retrofitInterface.postComplaint("sessionid=" + getArguments().getString(Constants.SESSION_ID), complaintCreateRequest).enqueue(new Callback<ComplaintCreateResponse>() { if (Location == null) {
@Override Location = new LatLng(19.1208, 72.9014);
public void onResponse(Call<ComplaintCreateResponse> call, Response<ComplaintCreateResponse> response) { Address = "IIT Area";
Toast.makeText(getContext(), "Complaint successfully posted", Toast.LENGTH_LONG).show();
Bundle bundle = getArguments();
bundle.putString(Constants.USER_ID, userId);
ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, complaintFragment, complaintFragment.getTag());
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();
}
});
} }
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);
ComplaintFragment complaintFragment = new ComplaintFragment();
complaintFragment.setArguments(bundle);
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, complaintFragment, complaintFragment.getTag());
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) { private void updateMap(LatLng Location, String Name, String Address, int cursor) {
...@@ -675,6 +705,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -675,6 +705,7 @@ public class FileComplaintFragment extends Fragment {
Bundle bundle = data.getExtras(); Bundle bundle = data.getExtras();
Bitmap bitmap = (Bitmap) bundle.get("data"); Bitmap bitmap = (Bitmap) bundle.get("data");
base64Image = convertImageToString(bitmap); base64Image = convertImageToString(bitmap);
collapsing_toolbar.setVisibility(View.VISIBLE);
sendImage(); sendImage();
} else if (resultCode == Activity.RESULT_OK && requestCode == Constants.RESULT_LOAD_IMAGE && data != null) { } else if (resultCode == Activity.RESULT_OK && requestCode == Constants.RESULT_LOAD_IMAGE && data != null) {
...@@ -689,6 +720,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -689,6 +720,7 @@ public class FileComplaintFragment extends Fragment {
String picturePath = cursor.getString(columnIndex); String picturePath = cursor.getString(columnIndex);
cursor.close(); cursor.close();
base64Image = convertImageToString(getScaledBitmap(picturePath, 800, 800)); base64Image = convertImageToString(getScaledBitmap(picturePath, 800, 800));
collapsing_toolbar.setVisibility(View.VISIBLE);
sendImage(); sendImage();
} }
} }
......
...@@ -39,22 +39,6 @@ ...@@ -39,22 +39,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end"
android:layout_marginEnd="20dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:src="@drawable/ic_add_a_photo_black_24dp"
app:backgroundTint="@color/colorSecondary"
app:borderWidth="0dp"
app:fabSize="normal"
app:layout_anchorGravity="bottom|end" />
<LinearLayout <LinearLayout
android:id="@+id/linearLayoutAddImage" android:id="@+id/linearLayoutAddImage"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -66,7 +50,7 @@ ...@@ -66,7 +50,7 @@
android:id="@+id/imageViewAddImage" android:id="@+id/imageViewAddImage"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="100dp" android:layout_height="100dp"
android:src="@drawable/baseline_photo_size_select_actual_black_48"/> android:src="@drawable/baseline_photo_size_select_actual_black_48" />
</LinearLayout> </LinearLayout>
...@@ -187,10 +171,18 @@ ...@@ -187,10 +171,18 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
android:id="@+id/google_map" android:id="@+id/mapLinearLayout"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="200dp" /> android:layout_height="300dp"
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>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -198,25 +190,24 @@ ...@@ -198,25 +190,24 @@
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <android.support.design.widget.TextInputLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="#ccc" app:hintTextAppearance="@style/edit_text_hint_apperarance">
android:padding="10dp">
<TextView <EditText
android:layout_width="wrap_content" android:id="@+id/editTextLocationDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TAGS" android:gravity="top"
android:textColor="#4A4A4A" android:hint="@string/enter_location_details"
android:textSize="16sp" android:imeOptions="flagNoExtractUi|actionSearch"
android:textStyle="bold" /> android:inputType="textMultiLine"
android:minLines="3"
</LinearLayout> android:textColor="@android:color/black"
android:textSize="14sp" />
<View </android.support.design.widget.TextInputLayout>
android:layout_width="match_parent"
android:layout_height="7dp" />
<com.cunoraz.tagview.TagView <com.cunoraz.tagview.TagView
android:id="@+id/tag_view" android:id="@+id/tag_view"
...@@ -224,10 +215,6 @@ ...@@ -224,10 +215,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="10dp" /> android:layout_margin="10dp" />
<View
android:layout_width="match_parent"
android:layout_height="7dp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
...@@ -247,7 +234,7 @@ ...@@ -247,7 +234,7 @@
android:id="@+id/editTextTags" android:id="@+id/editTextTags"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="Add more Tags" android:hint="Add Tags"
android:inputType="text" android:inputType="text"
android:textColor="@android:color/black" android:textColor="@android:color/black"
android:textColorHint="#66000000" android:textColorHint="#66000000"
...@@ -276,7 +263,9 @@ ...@@ -276,7 +263,9 @@
android:id="@+id/tag_populate" android:id="@+id/tag_populate"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="10dp" /> android:layout_margin="10dp"
android:focusable="true"
android:focusableInTouchMode="true"/>
</ScrollView> </ScrollView>
...@@ -290,8 +279,24 @@ ...@@ -290,8 +279,24 @@
</android.support.v4.widget.NestedScrollView> </android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:src="@drawable/ic_add_a_photo_black_24dp"
app:backgroundTint="@color/colorSecondary"
app:borderWidth="0dp"
app:fabSize="normal" />
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
<LinearLayout <LinearLayout
android:id="@+id/layout_buttons" android:id="@+id/layout_buttons"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -48,4 +48,5 @@ ...@@ -48,4 +48,5 @@
<string name="getting_current_location">Getting current location. Please try after some time</string> <string name="getting_current_location">Getting current location. Please try after some time</string>
<string name="GPS_not_enables">GPS is not enabled!</string> <string name="GPS_not_enables">GPS is not enabled!</string>
<string name="no_permission">No permission!</string> <string name="no_permission">No permission!</string>
<string name="enter_location_details">Enter Location Details</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment