Commit 7db0c351 authored by Preetam Ozarde's avatar Preetam Ozarde

Add Location Details

parent f144420d
......@@ -19,6 +19,7 @@ import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
......@@ -106,6 +107,7 @@ public class FileComplaintFragment extends Fragment {
private CustomAutoCompleteTextView autoCompleteTextView;
private EditText editTextSuggestions;
private EditText editTextTags;
private EditText editTextLocationDetails;
private MapView mMapView;
GoogleMap googleMap;
private TagView tagView;
......@@ -134,6 +136,7 @@ public class FileComplaintFragment extends Fragment {
FusedLocationProviderClient mFusedLocationClient;
ProgressDialog progressDialog;
CollapsingToolbarLayout collapsing_toolbar;
LinearLayout linear_layout_file_complaint;
public FileComplaintFragment() {
// Required empty public constructor
......@@ -217,14 +220,17 @@ public class FileComplaintFragment extends Fragment {
viewPager = view.findViewById(R.id.complaint_image_view_pager);
indicator = view.findViewById(R.id.indicator);
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.show();
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
giveOptionsToAddImage();
}
});
ImageButton imageButtonAddTags = (ImageButton) view.findViewById(R.id.imageButtonAddTags);
autoCompleteTextView = (CustomAutoCompleteTextView) view.findViewById(R.id.dynamicAutoCompleteTextView);
......@@ -249,6 +255,8 @@ public class FileComplaintFragment extends Fragment {
editTextSuggestions = view.findViewById(R.id.editTextSuggestions);
editTextLocationDetails = view.findViewById(R.id.editTextLocationDetails);
editTextTags = view.findViewById(R.id.editTextTags);
editTextTags.addTextChangedListener(new TextWatcher() {
......@@ -330,6 +338,8 @@ public class FileComplaintFragment extends Fragment {
});
// ends here
tagView = view.findViewById(R.id.tag_view);
tagView.setOnTagDeleteListener(new TagView.OnTagDeleteListener() {
......@@ -577,10 +587,12 @@ public class FileComplaintFragment extends Fragment {
@Override
public void run() {
nestedScrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
private void prepareTags() {
tagList = new ArrayList<>();
try {
......@@ -595,38 +607,44 @@ public class FileComplaintFragment extends Fragment {
private void addComplaint() {
String complaint = "Complaint: " + autoCompleteTextView.getText().toString();
String suggestion = null;
String locationDetails = null;
Log.i(TAG, "Suggestion: " + editTextSuggestions.getText().toString());
if (!(editTextSuggestions.getText().toString().isEmpty())) {
suggestion = "\nSuggestion: " + editTextSuggestions.getText().toString();
} else {
suggestion = "";
}
if (Location == null) {
Toast.makeText(getContext(), "Please specify the location", Toast.LENGTH_LONG).show();
if (!(editTextLocationDetails.getText().toString().isEmpty())) {
locationDetails = "\nLocation Details: " + editTextLocationDetails.getText().toString();
} else {
ComplaintCreateRequest complaintCreateRequest = new ComplaintCreateRequest(complaint + suggestion, 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();
}
});
locationDetails = "";
}
if (Location == null) {
Location = new LatLng(19.1208, 72.9014);
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);
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) {
......
......@@ -75,7 +75,7 @@
</android.support.design.widget.AppBarLayout>
<app.insti.utils.CustomScrollView
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -190,31 +190,24 @@
android:layout_marginTop="20dp"
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_height="wrap_content"
android:background="#ccc"
android:padding="10dp">
app:hintTextAppearance="@style/edit_text_hint_apperarance">
<RelativeLayout
<EditText
android:id="@+id/editTextLocationDetails"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TAGS"
android:textColor="#4A4A4A"
android:textSize="16sp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
android:layout_height="wrap_content"
android:gravity="top"
android:hint="@string/enter_location_details"
android:imeOptions="flagNoExtractUi|actionSearch"
android:inputType="textMultiLine"
android:minLines="3"
android:textColor="@android:color/black"
android:textSize="14sp" />
<View
android:layout_width="match_parent"
android:layout_height="7dp" />
</android.support.design.widget.TextInputLayout>
<com.cunoraz.tagview.TagView
android:id="@+id/tag_view"
......@@ -222,10 +215,6 @@
android:layout_height="match_parent"
android:layout_margin="10dp" />
<View
android:layout_width="match_parent"
android:layout_height="7dp" />
</LinearLayout>
<LinearLayout
......@@ -245,7 +234,7 @@
android:id="@+id/editTextTags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Add more Tags"
android:hint="Add Tags"
android:inputType="text"
android:textColor="@android:color/black"
android:textColorHint="#66000000"
......@@ -274,7 +263,9 @@
android:id="@+id/tag_populate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
android:layout_margin="10dp"
android:focusable="true"
android:focusableInTouchMode="true"/>
</ScrollView>
......@@ -286,7 +277,7 @@
</LinearLayout>
</app.insti.utils.CustomScrollView>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabButton"
......@@ -302,8 +293,7 @@
android:src="@drawable/ic_add_a_photo_black_24dp"
app:backgroundTint="@color/colorSecondary"
app:borderWidth="0dp"
app:fabSize="normal"
android:padding="100dp"/>
app:fabSize="normal" />
</android.support.design.widget.CoordinatorLayout>
......
......@@ -57,4 +57,5 @@
<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="no_permission">No permission!</string>
<string name="enter_location_details">Enter Location Details</string>
</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