Commit 346905ff authored by sshivam95's avatar sshivam95

Venter: add complaint form module.

parent cf8ff48c
...@@ -29,15 +29,21 @@ ext { ...@@ -29,15 +29,21 @@ ext {
picassoVersion = '2.71828' picassoVersion = '2.71828'
circleImageViewVersion = '2.2.0' circleImageViewVersion = '2.2.0'
markwonVersion = '1.0.6' markwonVersion = '1.0.6'
commonsIOVersion = '2.4'
tagViewVersion = '1.3'
circleIndicatorVersion = '1.2.2@aar'
} }
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-messaging:17.3.2' implementation 'com.google.firebase:firebase-messaging:17.3.2'
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 +52,8 @@ dependencies { ...@@ -46,5 +52,8 @@ 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 "commons-io:commons-io:${commonsIOVersion}"
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"
......
...@@ -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";
......
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 CustomAutoCompleteTextView 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) {
CustomAutoCompleteTextView.super.performFiltering((CharSequence) msg.obj, msg.arg1);
}
};
public CustomAutoCompleteTextView(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;
import java.util.ArrayList;
import java.util.Random;
/**
* Created by Shivam Sharma on 13-08-2018.
*/
public class TagClass {
private String name;
private String color;
public TagClass(String name) {
this.name = name;
this.color = getRandomColor();
}
public String getRandomColor() {
ArrayList<String> colors = new ArrayList<>();
colors.add("#ED7D31");
colors.add("#00B0F0");
colors.add("#FF0000");
colors.add("#D0CECE");
colors.add("#00B050");
colors.add("#9999FF");
colors.add("#FF5FC6");
colors.add("#FFC000");
colors.add("#7F7F7F");
colors.add("#4800FF");
return colors.get(new Random().nextInt(colors.size()));
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}
\ No newline at end of file
...@@ -57,9 +57,11 @@ import app.insti.api.request.UserFCMPatchRequest; ...@@ -57,9 +57,11 @@ 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.BodyFragment;
import app.insti.fragment.CalendarFragment; import app.insti.fragment.CalendarFragment;
import app.insti.fragment.ComplaintFragment;
import app.insti.fragment.EventFragment; import app.insti.fragment.EventFragment;
import app.insti.fragment.ExploreFragment; import app.insti.fragment.ExploreFragment;
import app.insti.fragment.FeedFragment; import app.insti.fragment.FeedFragment;
import app.insti.fragment.FileComplaintFragment;
import app.insti.fragment.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 +81,7 @@ import static app.insti.Constants.DATA_TYPE_PT; ...@@ -79,6 +81,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;
...@@ -94,7 +97,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -94,7 +97,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private RetrofitInterface retrofitInterface; private RetrofitInterface retrofitInterface;
private List<Notification> notifications = null; private List<Notification> notifications = null;
/** which menu item should be checked on activity start */ /**
* which menu item should be checked on activity start
*/
private int initMenuChecked = R.id.nav_feed; private int initMenuChecked = R.id.nav_feed;
public static void hideKeyboard(Activity activity) { public static void hideKeyboard(Activity activity) {
...@@ -152,7 +157,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -152,7 +157,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
checkLatestVersion(); checkLatestVersion();
} }
/** Get the notifications from memory cache or network */ /**
* Get the notifications from memory cache or network
*/
private void fetchNotifications() { private void fetchNotifications() {
// Try memory cache // Try memory cache
if (notifications != null) { if (notifications != null) {
...@@ -173,7 +180,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -173,7 +180,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}); });
} }
/** Show the right notification icon */ /**
* Show the right notification icon
*/
private void showNotifications() { private void showNotifications() {
if (notifications != null && !notifications.isEmpty()) { if (notifications != null && !notifications.isEmpty()) {
menu.findItem(R.id.action_notifications).setIcon(R.drawable.baseline_notifications_active_white_24); menu.findItem(R.id.action_notifications).setIcon(R.drawable.baseline_notifications_active_white_24);
...@@ -182,7 +191,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -182,7 +191,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
/** Get version code we are currently on */ /**
* Get version code we are currently on
*/
private int getCurrentVersion() { private int getCurrentVersion() {
try { try {
PackageInfo pInfo = this.getPackageManager().getPackageInfo(getPackageName(), 0); PackageInfo pInfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
...@@ -192,10 +203,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -192,10 +203,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
/** Check for updates in andro.json */ /**
* Check for updates in andro.json
*/
private void checkLatestVersion() { private void checkLatestVersion() {
final int versionCode = getCurrentVersion(); final int versionCode = getCurrentVersion();
if (versionCode == 0) { return; } if (versionCode == 0) {
return;
}
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getLatestVersion().enqueue(new EmptyCallback<JsonObject>() { retrofitInterface.getLatestVersion().enqueue(new EmptyCallback<JsonObject>() {
@Override @Override
...@@ -257,7 +272,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -257,7 +272,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
mNotificationManager.createNotificationChannel(mChannel); mNotificationManager.createNotificationChannel(mChannel);
} }
/** Handle opening event/body/blog from FCM notification */ /**
* Handle opening event/body/blog from FCM notification
*/
private void handleFCMIntent(Bundle bundle) { private void handleFCMIntent(Bundle bundle) {
/* Mark the notification read */ /* Mark the notification read */
final String notificationId = bundle.getString(FCM_BUNDLE_NOTIFICATION_ID); final String notificationId = bundle.getString(FCM_BUNDLE_NOTIFICATION_ID);
...@@ -273,7 +290,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -273,7 +290,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
); );
} }
/** Handle intents for links */ /**
* Handle intents for links
*/
private void handleIntent(Intent appLinkIntent) { private void handleIntent(Intent appLinkIntent) {
String appLinkAction = appLinkIntent.getAction(); String appLinkAction = appLinkIntent.getAction();
String appLinkData = appLinkIntent.getDataString(); String appLinkData = appLinkIntent.getDataString();
...@@ -282,9 +301,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -282,9 +301,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
/** Open the proper fragment from given type and id */ /**
* Open the proper fragment from given type and id
*/
private void chooseIntent(String type, String id) { private void chooseIntent(String type, String id) {
if (type == null || id == null) { return; } if (type == null || id == null) {
return;
}
switch (type) { switch (type) {
case DATA_TYPE_BODY: case DATA_TYPE_BODY:
openBodyFragment(id); openBodyFragment(id);
...@@ -303,7 +326,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -303,7 +326,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Log.e("NOTIFICATIONS", "Server sent invalid notification?"); Log.e("NOTIFICATIONS", "Server sent invalid notification?");
} }
/** Open the proper fragment from given type, id and extra */ /**
* Open the proper fragment from given type, id and extra
*/
private void chooseIntent(String type, String id, String extra) { private void chooseIntent(String type, String id, String extra) {
if (extra == null) { if (extra == null) {
chooseIntent(type, id); chooseIntent(type, id);
...@@ -323,18 +348,24 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -323,18 +348,24 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
/** Open user fragment from given id */ /**
* Open user fragment from given id
*/
private void openUserFragment(String id) { private void openUserFragment(String id) {
UserFragment userFragment = UserFragment.newInstance(id); UserFragment userFragment = UserFragment.newInstance(id);
updateFragment(userFragment); updateFragment(userFragment);
} }
/** Open the body fragment from given id */ /**
* Open the body fragment from given id
*/
private void openBodyFragment(String id) { private void openBodyFragment(String id) {
Utils.openBodyFragment(new Body(id), this); Utils.openBodyFragment(new Body(id), this);
} }
/** Open the event fragment from the provided id */ /**
* Open the event fragment from the provided id
*/
private void openEventFragment(String id) { private void openEventFragment(String id) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
final FragmentActivity self = this; final FragmentActivity self = this;
...@@ -525,6 +556,15 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -525,6 +556,15 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
updateFragment(mapFragment); updateFragment(mapFragment);
break; break;
case R.id.nav_complaint:
if (session.isLoggedIn()) {
ComplaintFragment complaintFragment = new ComplaintFragment();
updateFragment(complaintFragment);
} 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);
...@@ -536,7 +576,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -536,7 +576,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return true; return true;
} }
/** Open placement blog fragment */ /**
* Open placement blog fragment
*/
private void openPlacementBlog() { private void openPlacementBlog() {
if (session.isLoggedIn()) { if (session.isLoggedIn()) {
PlacementBlogFragment placementBlogFragment = new PlacementBlogFragment(); PlacementBlogFragment placementBlogFragment = new PlacementBlogFragment();
...@@ -555,7 +597,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -555,7 +597,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
/** Change the active fragment to the supplied one */ /**
* Change the active fragment to the supplied one
*/
public void updateFragment(Fragment fragment) { public void updateFragment(Fragment fragment) {
Log.d(TAG, "updateFragment: " + fragment.toString()); Log.d(TAG, "updateFragment: " + fragment.toString());
Bundle bundle = fragment.getArguments(); Bundle bundle = fragment.getArguments();
...@@ -565,7 +609,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -565,7 +609,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
bundle.putString(Constants.SESSION_ID, session.pref.getString(Constants.SESSION_ID, "")); bundle.putString(Constants.SESSION_ID, session.pref.getString(Constants.SESSION_ID, ""));
if (fragment instanceof MessMenuFragment) if (fragment instanceof MessMenuFragment)
bundle.putString(Constants.USER_HOSTEL, session.isLoggedIn() && currentUser.getHostel() != null ? currentUser.getHostel() : "1"); bundle.putString(Constants.USER_HOSTEL, session.isLoggedIn() && currentUser.getHostel() != null ? currentUser.getHostel() : "1");
if (fragment instanceof SettingsFragment && session.isLoggedIn()) if (fragment instanceof SettingsFragment && session.isLoggedIn() || fragment instanceof ComplaintFragment && session.isLoggedIn())
bundle.putString(Constants.USER_ID, currentUser.getUserID()); bundle.putString(Constants.USER_ID, currentUser.getUserID());
fragment.setArguments(bundle); fragment.setArguments(bundle);
FragmentManager manager = getSupportFragmentManager(); FragmentManager manager = getSupportFragmentManager();
...@@ -599,6 +643,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -599,6 +643,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.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.support.annotation.NonNull;
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.EditText;
import android.widget.ImageButton;
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.activity.MainActivity;
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 CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final String TAG = CommentRecyclerViewAdapter.class.getSimpleName();
private Context context;
private LayoutInflater inflater;
private String sessionId, userId;
private Activity activity;
private List<Venter.Comment> commentList = new ArrayList<>();
public CommentRecyclerViewAdapter(Activity activity, Context context, String sessionId, String userId) {
this.context = context;
this.sessionId = sessionId;
this.userId = userId;
inflater = LayoutInflater.from(context);
this.activity = activity;
}
public class CommentsViewHolder extends RecyclerView.ViewHolder {
private CardView cardView;
private CircleImageView circleImageView;
private TextView textViewName;
private TextView textViewCommentTime;
private TextView textViewComment;
final RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
public 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);
}
public void bindHolder(final int position) {
final Venter.Comment comment = commentList.get(position);
try {
String profileUrl = comment.getUser().getUserProfilePictureUrl();
Log.i(TAG, "PROFILE URL: " + profileUrl);
if (profileUrl != null)
Picasso.get().load(profileUrl).into(circleImageView);
else
Picasso.get().load(R.drawable.baseline_account_circle_black_36).into(circleImageView);
} catch (Exception e) {
e.printStackTrace();
}
try {
textViewName.setText(comment.getUser().getUserName());
} catch (Exception e) {
e.printStackTrace();
}
try {
String time = DateTimeUtil.getDate(comment.getTime().toString());
Log.i(TAG, "time: " + time);
Log.i(TAG, "inside try");
textViewCommentTime.setText(time);
} catch (Exception e) {
Log.i(TAG, "Inside catch");
e.printStackTrace();
}
try {
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());
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()) {
Toast.makeText(context, "Comment Deleted", Toast.LENGTH_SHORT).show();
commentList.remove(position);
notifyDataSetChanged();
notifyItemRemoved(position);
notifyItemRangeChanged(position, commentList.size() - position);
} 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;
}
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);
CommentsViewHolder commentsViewHolder = new CommentsViewHolder(view);
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) {
this.commentList = commentList;
}
}
\ No newline at end of file
package app.insti.adapter;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import app.insti.api.model.Venter;
import app.insti.fragment.DetailedComplaintFragment;
/**
* Created by Shivam Sharma on 19-09-2018.
*/
public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter {
Venter.Complaint detailedComplaint;
Context context;
String sessionid, complaintid, userid;
public ComplaintDetailsPagerAdapter(FragmentManager fm, Venter.Complaint detailedComplaint, Context context, String sessionid, String complaintid, String userid) {
super(fm);
this.context = context;
this.detailedComplaint = detailedComplaint;
this.sessionid = sessionid;
this.complaintid = complaintid;
this.userid = userid;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return DetailedComplaintFragment.getInstance(sessionid, complaintid, userid);
default:
return DetailedComplaintFragment.getInstance(sessionid, complaintid, userid);
}
}
@Override
public CharSequence getPageTitle(int position) {
return "Complaint Details";
}
@Override
public int getCount() {
return 1; /* Update as 2 on adding RelevantComplints*/
}
}
package app.insti.adapter;
import android.content.Context;
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.HomeFragment;
import app.insti.fragment.MeFragment;
/**
* Created by Shivam Sharma on 15-08-2018.
*/
public class ComplaintFragmentViewPagerAdapter extends FragmentStatePagerAdapter {
private static final String TAG = ComplaintFragmentViewPagerAdapter.class.getSimpleName();
Context context;
String userID, sessionID;
public ComplaintFragmentViewPagerAdapter(FragmentManager fm, Context context, String userID, String sessionID) {
super(fm);
this.context = context;
this.userID = userID;
this.sessionID = sessionID;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return HomeFragment.getInstance(sessionID, userID);
case 1:
return MeFragment.getInstance(sessionID,userID);
default:
return HomeFragment.getInstance(sessionID, userID);
}
}
@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.graphics.Color;
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.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.TimeZone;
import app.insti.R;
import app.insti.api.model.Venter;
import app.insti.fragment.ComplaintDetailsFragment;
import app.insti.utils.DateTimeUtil;
import app.insti.utils.GsonProvider;
/**
* Created by Shivam Sharma on 15-08-2018.
*/
public class ComplaintsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private LayoutInflater inflater;
private Activity context;
private String sessionID;
private String userID;
private static final String TAG = ComplaintsRecyclerViewAdapter.class.getSimpleName();
List<Venter.Complaint> complaintList = new ArrayList<>();
public class ComplaintsViewHolder extends RecyclerView.ViewHolder {
private CardView cardView;
private TextView textViewDescription;
private Button buttonComments;
private Button buttonVotes;
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);
}
public void bindHolder(int position) {
this.pos = position;
Log.i(TAG, "json = " + GsonProvider.getGsonOutput().toJson(complaintList.get(pos)));
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);
ComplaintDetailsFragment complaintDetailsFragment = new ComplaintDetailsFragment();
complaintDetailsFragment.setArguments(bundle);
AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_for_fragment, complaintDetailsFragment).addToBackStack(TAG).commit();
}
});
Venter.Complaint complaint = complaintList.get(position);
try {
textViewDescription.setText(complaint.getDescription());
} catch (Exception e) {
e.printStackTrace();
}
try {
textViewLocation.setText(complaint.getLocationDescription());
} catch (Exception e) {
e.printStackTrace();
}
try {
textViewUserName.setText(complaint.getComplaintCreatedBy().getUserName());
} catch (Exception e) {
e.printStackTrace();
}
try {
textViewStatus.setText(complaint.getStatus().toUpperCase());
if (complaint.getStatus().equalsIgnoreCase("Reported")) {
textViewStatus.setBackgroundColor(Color.parseColor("#FF0000"));
textViewStatus.setTextColor(context.getResources().getColor(R.color.primaryTextColor));
} else if (complaint.getStatus().equalsIgnoreCase("In Progress")) {
textViewStatus.setBackgroundColor(context.getResources().getColor(R.color.colorSecondary));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
} else if (complaint.getStatus().equalsIgnoreCase("Resolved")) {
textViewStatus.setBackgroundColor(Color.parseColor("#00FF00"));
textViewStatus.setTextColor(context.getResources().getColor(R.color.secondaryTextColor));
}
} catch (Exception e) {
e.printStackTrace();
}
try {
String time = DateTimeUtil.getDate(complaint.getComplaintReportDate().toString());
Log.i(TAG, "time: " + time);
textViewReportDate.setText(time);
} catch (Exception e) {
e.printStackTrace();
}
try {
buttonComments.setText("COMMENTS(" + complaint.getComment().size() + ")");
} catch (Exception e) {
e.printStackTrace();
}
try {
buttonVotes.setText("UP VOTES(" + complaint.getUsersUpVoted().size() + ")");
} catch (Exception e) {
e.printStackTrace();
}
}
}
public ComplaintsRecyclerViewAdapter(Activity ctx, String sessionID, String userID) {
this.context = ctx;
this.sessionID = sessionID;
this.userID = userID;
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) {
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.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import app.insti.api.model.Venter;
import app.insti.fragment.AddImageFragment;
import app.insti.fragment.ImageFragment;
/**
* Created by Shivam Sharma on 25-09-2018.
*/
public class ImageViewPagerAdapter extends FragmentPagerAdapter {
private static final String TAG = ImageViewPagerAdapter.class.getSimpleName();
private List<String> images = new ArrayList<>();
Venter.Complaint detailedComplaint;
public ImageViewPagerAdapter(FragmentManager fragmentManager, List<String> images) {
super(fragmentManager);
this.images = images;
}
public ImageViewPagerAdapter(FragmentManager fragmentManager, Venter.Complaint detailedComplaint){
super(fragmentManager);
this.detailedComplaint = detailedComplaint;
for (String image: detailedComplaint.getImages()){
images.add(image);
}
}
@Override
public int getCount() {
if (images.size() == 0)
return 1;
return images.size();
}
@Override
public Fragment getItem(int position) {
Log.i(TAG, "images = " + images.size());
Log.i(TAG, "size = " + getCount());
Log.i(TAG, "pos = " + position);
if (images.size() == 0){
Log.i(TAG,"calling 1");
return new AddImageFragment();
}else {
Log.i(TAG,"calling 2");
return ImageFragment.newInstance(images.get(position),position);
}
}
}
\ No newline at end of file
package app.insti.api;
import android.app.Activity;
import android.content.Context;
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();
GoogleMap googleMap;
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);
@PUT("venter/complaints/{complaintId}")
Call<Venter.Complaint> upVote(@Header("Cookie") String sessionId, @Path("complaintId") String complaintId);
@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;
import app.insti.api.model.User;
/**
* Created by Shivam Sharma on 04-09-2018.
*/
public class Venter {
public Venter(){
}
public static class Complaint {
@NonNull
@SerializedName("id")
String complaintID;
@SerializedName("created_by")
User complaintCreatedBy;
@SerializedName("description")
String description;
@SerializedName("report_date")
String complaintReportDate;
@SerializedName("status")
String status;
@SerializedName("latitude")
Float latitude;
@SerializedName("longitude")
Float longitude;
@SerializedName("location_description")
String locationDescription;
@SerializedName("tags")
List<TagUri> tags;
@SerializedName("users_up_voted")
List<User> usersUpVoted;
@SerializedName("images")
List<String> images;
@SerializedName("comments")
List<Comment> comment;
public Complaint(@NonNull String complaintID, User complaintCreatedBy, String description, String complaintReportDate, String status, Float latitude, Float longitude, String locationDescription, List<TagUri> tags, List<User> usersUpVoted, List<String> images, List<Comment> comment) {
this.complaintID = complaintID;
this.complaintCreatedBy = complaintCreatedBy;
this.description = description;
this.complaintReportDate = complaintReportDate;
this.status = status;
this.latitude = latitude;
this.longitude = longitude;
this.locationDescription = locationDescription;
this.tags = tags;
this.usersUpVoted = usersUpVoted;
this.images = images;
this.comment = comment;
}
@NonNull
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 static class TagUri {
@NonNull
@SerializedName("id")
String id;
@SerializedName("tag_uri")
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 {
@NonNull
@SerializedName("id")
String id;
@SerializedName("time")
String time;
@SerializedName("text")
String text;
@SerializedName("commented_by")
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.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import app.insti.R;
/**
* Created by Shivam Sharma on 25-09-2018.
*/
public class AddImageFragment extends BaseFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_add_image, container, false);
return view;
}
}
package app.insti.fragment;
import android.content.Context;
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 ComplaintFragment extends BaseFragment {
private static String TAG = ComplaintFragment.class.getSimpleName();
String userID;
Context context;
private Button buttonVentIssues;
private ViewPager viewPager;
private TabLayout slidingTabLayout;
private CollapsingToolbarLayout collapsingToolbarLayout;
public ComplaintFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_complaint, container, false);
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Complaints/Suggestions");
Bundle bundle = getArguments();
userID = bundle.getString(Constants.USER_ID);
collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setTitleEnabled(false);
viewPager = (ViewPager) view.findViewById(R.id.tab_viewpager);
slidingTabLayout = (TabLayout) view.findViewById(R.id.sliding_tab_layout);
context = getContext();
buttonVentIssues = view.findViewById(R.id.buttonVentIssues);
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(fileComplaintFragment.getTag()).commit();
}
});
viewPager = view.findViewById(R.id.tab_viewpager);
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(), getContext(), userID, getArguments().getString(Constants.SESSION_ID)));
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) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
viewPager.setOffscreenPageLimit(3);
}
}
package app.insti.fragment;
import android.app.Activity;
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.activity.MainActivity;
import app.insti.adapter.ComplaintsRecyclerViewAdapter;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class HomeFragment extends Fragment {
Activity activity;
ComplaintsRecyclerViewAdapter homeListAdapter;
RecyclerView recyclerViewHome;
private SwipeRefreshLayout swipeContainer;
private static String TAG = HomeFragment.class.getSimpleName();
private boolean isCalled = false;
private TextView error_message_home;
static String sID, uID;
public static HomeFragment getInstance(String sessionID, String userID) {
sID = sessionID;
uID = userID;
return new HomeFragment();
}
@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_home, container, false);
recyclerViewHome = (RecyclerView) view.findViewById(R.id.recyclerViewHome);
homeListAdapter = new ComplaintsRecyclerViewAdapter(getActivity(), sID, uID);
swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipeContainer);
error_message_home = view.findViewById(R.id.error_message_home);
LinearLayoutManager llm = new LinearLayoutManager(activity);
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.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
import app.insti.R;
public class ImageFragment extends BaseFragment {
private static final String TAG = ImageFragment.class.getSimpleName();
private String image;
int indexChosen;
public static ImageFragment newInstance(String image, int index) {
ImageFragment fragment = new ImageFragment();
Bundle args = new Bundle();
args.putString("image", image);
args.putInt("index", index);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "getArguments in ImageFragment" + getArguments());
if (getArguments() != null) {
image = getArguments().getString("image");
indexChosen = getArguments().getInt("index", 0);
}
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_image, container, false);
ImageView imageView = view.findViewById(R.id.imageView);
Picasso.get().load(image).into(imageView);
return view;
}
}
\ No newline at end of file
package app.insti.fragment;
import android.app.Activity;
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.activity.MainActivity;
import app.insti.adapter.ComplaintsRecyclerViewAdapter;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venter;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MeFragment extends Fragment {
static String uID, sID;
Activity activity;
RecyclerView recyclerViewMe;
ComplaintsRecyclerViewAdapter meListAdapter;
TextView error_message_me;
SwipeRefreshLayout swipeContainer;
private static String TAG = MeFragment.class.getSimpleName();
private boolean isCalled = false;
public static MeFragment getInstance(String sessionID, String userID) {
sID = sessionID;
uID = userID;
return new MeFragment();
}
@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_me, container, false);
recyclerViewMe = view.findViewById(R.id.recyclerViewMe);
meListAdapter = new ComplaintsRecyclerViewAdapter(getActivity(), sID, uID);
swipeContainer = view.findViewById(R.id.swipeContainer);
error_message_me = view.findViewById(R.id.error_message_me);
LinearLayoutManager llm = new LinearLayoutManager(activity);
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();
}
}
\ 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 {
private static String time_ago = "";
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 time_ago = "now";
} else if (seconds < 60 && seconds > 0) {
return time_ago = seconds + " seconds ago";
} else if (minutes < 60 && minutes > 0) {
return time_ago = minutes + " minutes ago";
} else if (hours < 24 && hours > 0) {
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 < 14)
return days + " days ago";
else if (days < 30)
return ((int) (days / 7)) + " weeks ago";
else if (days < 365)
return ((int) (days / 30)) + " months ago";
else
return ((int) (days / 365)) + " years ago";
}
} catch (ParseException e) {
e.printStackTrace();
}
return "";
}
}
\ No newline at end of file
package app.insti.utils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* Created by Shivam Sharma on 13-08-2018.
*/
public class GsonProvider {
private static final Gson gsonInput = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
private static final Gson gsonOutput = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
public static Gson getGsonInput() {
return gsonInput;
}
public static Gson getGsonOutput() {
return gsonOutput;
}
}
\ No newline at end of file
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"};
}
<?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="M21,3H3C2,3 1,4 1,5v14c0,1.1 0.9,2 2,2h18c1,0 2,-1 2,-2V5c0,-1 -1,-2 -2,-2zM5,17l3.5,-4.5 2.5,3.01L14.5,11l4.5,6H5z"/>
</vector>
<?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"
xmlns:tools="http://schemas.android.com/tools"
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="5dp">
<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" />
</LinearLayout>
<TextView
android:id="@+id/textViewReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorGray"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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:textColor="@android:color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="@+id/buttonComments"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="1"
android:background="#12C1D6"
android:textColor="@color/colorWhite" />
<Button
android:id="@+id/buttonVotes"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@android:color/black"
android:textColor="@color/colorWhite" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/baseline_photo_size_select_actual_black_48"
android:id="@+id/image_view_image"/>
</LinearLayout>
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="app.insti.fragment.ComplaintFragment">
<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/nobody_taking_care_of_your_civic_complaints_be_it_garbage_water_potholes_etc"
android:textColor="@color/primaryTextColor"
android:textStyle="bold" />
<Button
android:id="@+id/buttonVentIssues"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/colorSecondary"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="@string/vent_your_issues_now"
android:textAllCaps="false"
android:textColor="@color/secondaryTextColor"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tab_layout"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:tabIndicatorColor="@color/colorAccent"
style="@style/CustomTabLayout"
android:background="?attr/colorPrimary" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tab_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<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.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="@android:color/white"
android:background="@color/colorWhite"
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" />
</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/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>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="@+id/buttonVoteUp"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textColor="@color/secondaryTextColor"
android:background="@color/colorSecondary"
android:text="Upvote"
android:layout_weight="2"/>
</LinearLayout>
</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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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:paddingHorizontal="10dp"
android:text="STATUS"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textViewReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Report Date"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
<View
android:layout_width="match_parent"
android:layout_height="10dp" />
<TextView
android:id="@+id/textViewDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description"
android:textColor="@android:color/black"
android:textSize="14sp" />
</LinearLayout>
<com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/google_map"
android:layout_width="match_parent"
android:layout_height="200dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
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"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="7dp" />
<ScrollView
android:id="@+id/tags_laoyut"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editText"
android:layout_marginLeft="6dp"
android:background="@android:color/white"
android:visibility="visible">
<com.cunoraz.tagview.TagView
android:id="@+id/tag_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" />
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="7dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:padding="10dp">
<TextView
android:id="@+id/comment_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COMMENTS"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</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">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/comment_user_image"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<EditText
android:id="@+id/edit_comment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="9"
android:hint="@string/enter_comment" />
<ImageButton
android:id="@+id/send_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/ic_menu_send" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:padding="10dp">
<TextView
android:id="@+id/up_vote_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VoteUp"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/layoutVotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="20dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
This diff is collapsed.
<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:gravity="center">
<ImageView
android:id="@+id/imageView"
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"?>
<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>
<?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="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<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: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>
</LinearLayout>
\ 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_description_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,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<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>
<!-- Map --> <!-- Map -->
......
...@@ -32,4 +32,29 @@ ...@@ -32,4 +32,29 @@
</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="enter_title">Enter title</string>
<string name="enter_description">Enter Complaint Description</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="select_file">Select File</string>
<string name="please_try_again">Please try again</string>
<string name="relevant_complaints">Relevant Complaints</string>
<string name="complaint_details">Complaint Details</string>
<string name="more">MORE</string>
<string name="vent_your_issues_now">Vent your issues now!</string>
<string name="nobody_taking_care_of_your_civic_complaints_be_it_garbage_water_potholes_etc">Nobody taking care of your civic complaints? Be it garbage, water, potholes etc.</string>
<string name="my_complaints">My complaints</string>
<string name="voted_complaints">Voted Complaints</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. Please try after some time</string>
<string name="GPS_not_enables">GPS is not enabled!</string>
<string name="no_permission">No permission!</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