diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java index bb097a7..91ea629 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java @@ -4,6 +4,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -169,18 +170,10 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { // Defines the contents of the InfoWindow @Override public View getInfoContents(Marker args) { - -// LatLng clickMarkerLatLng = args.getPosition(); - - // Getting view from the layout file info_window_layout - - // Getting the position from the marker - - mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { - public void onInfoWindowClick(Marker marker) { + public void onInfoWindowClick(final Marker marker) { - Note note = eventMarkerMap.get(marker); + final Note note = eventMarkerMap.get(marker); final Dialog noteViewDialog = new Dialog(getActivity()); noteViewDialog.setContentView(R.layout.note_display_full); @@ -193,8 +186,6 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { noteViewDialog.show(); - - //get note_view_full layout elements final TextView title = (TextView) noteViewDialog.findViewById(R.id.ndf_title_textview); final TextView body = (TextView) noteViewDialog.findViewById(R.id.ndf_body_textview); @@ -212,61 +203,61 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { time.setText(note.getTimestamp()); location.setText("Address: " + note.getAddress()); likes.setText("Likes: " + note.getLikes()); - tags.setText("Tags: "+note.getTags().toString()); + tags.setText("Tags: " + note.getTags().toString()); Utils.URLtoImageView(avatar, note.getAvatar()); if (isOwner) { permission.setText("Permission: " + (note.isPublic() ? "Public" : "Private")); - } - else{ + } else { permission.setText(""); deleteBtn.setBackgroundResource(R.drawable.like_icon); } - - -// deleteBtn.setOnClickListener(new View.OnClickListener() { -// public void onClick(View v) { -// //Put up the Yes/No message box -// AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); -// builder -// .setTitle("Delete Note") -// .setMessage("Are you sure you want to delete the note?") -// .setIcon(android.R.drawable.ic_dialog_alert) -// .setPositiveButton("Yes", new DialogInterface.OnClickListener() { -// public void onClick(DialogInterface dialog, int which) { -// //Yes button clicked, do something -// Toast.makeText(getActivity(), "Item Deleted!", -// Toast.LENGTH_SHORT).show(); -// //TODO send delete -// JSONObject delNote = new JSONObject(); -// try { -// delNote.put("uid", userId); -// delNote.put("nid", note.getId()); -// VolleyUtilSingleton.getInstance(getActivity()).post(BASE_URL + "/note/delete", delNote, deleteNoteSuccessListener, Utils.genericErrorListener); + if (isOwner) { + deleteBtn.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + //Put up the Yes/No message box + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder + .setTitle("Delete Note") + .setMessage("Are you sure you want to delete the note?") + .setIcon(android.R.drawable.ic_dialog_alert) + .setPositiveButton("Yes", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + //Yes button clicked, do something + Toast.makeText(getActivity(), "Item Deleted!", + Toast.LENGTH_SHORT).show(); + //TODO send delete + JSONObject delNote = new JSONObject(); + try { + delNote.put("uid", mainActivity.getUserId()); + delNote.put("nid", note.getId()); + VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/delete", delNote, Utils.deleteNoteSuccessListener, Utils.genericErrorListener); // listOfNotes.remove(position); -// -// } catch (JSONException e) { -// Toast.makeText(getActivity(), "Something went wrong.\n Failed to delete note...", Toast.LENGTH_LONG).show(); -// e.printStackTrace(); -// } + marker.remove(); + + } catch (JSONException e) { + Toast.makeText(getActivity(), "Something went wrong.\n Failed to delete note...", Toast.LENGTH_LONG).show(); + e.printStackTrace(); + } // noteList.setAdapter(noteListAdapter); -// noteViewDialog.dismiss(); -// } -// }) -// .setNegativeButton("No", new DialogInterface.OnClickListener() { -// public void onClick(DialogInterface dialog, int which) { -// //Yes button clicked, do something -// Toast.makeText(getActivity(), "Canceled", -// Toast.LENGTH_SHORT).show(); -// noteViewDialog.dismiss(); -// } -// }) //Do nothing on no -// .show(); -// } -// }); + noteViewDialog.dismiss(); + } + }) + .setNegativeButton("No", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + //Yes button clicked, do something + Toast.makeText(getActivity(), "Canceled", + Toast.LENGTH_SHORT).show(); + noteViewDialog.dismiss(); + } + }) //Do nothing on no + .show(); + } + }); + } } }); @@ -300,6 +291,19 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { }; + private View.OnClickListener cameraBtnListener = new View.OnClickListener() + { + + public void onClick(View v) + { + + Log.d(TAG, "in camera Button"); + + } + + }; + + private class getMarkersFromNotes extends AsyncTask, MarkerNoteStruct, Void> { GoogleMap mMap; HashMap eventMarkerMap; diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java index d09b42c..53c49a3 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java @@ -286,14 +286,11 @@ public class PersonalFragment extends Fragment { return stringArray; } - Response.Listener deleteNoteSuccessListener = new Response.Listener() { - @Override - public void onResponse(JSONObject response) { - Log.d(TAG, "deleteNoteSuccessListener: " + response.toString()); - } - }; - private void addNoteFromJsonObj(JSONObject noteObject, Date time) throws JSONException { + + + + private void addNoteFromJsonObj(JSONObject noteObject, Date time) throws JSONException { Note addNote = new Note( noteObject.getString("id"), Float.parseFloat(noteObject.getJSONObject("location").getString("lat")), @@ -369,7 +366,7 @@ public class PersonalFragment extends Fragment { try { delNote.put("uid", userId); delNote.put("nid", note.getId()); - VolleyUtilSingleton.getInstance(getActivity()).post(BASE_URL + "/note/delete", delNote, deleteNoteSuccessListener, Utils.genericErrorListener); + VolleyUtilSingleton.getInstance(getActivity()).post(BASE_URL + "/note/delete", delNote, Utils.deleteNoteSuccessListener, Utils.genericErrorListener); listOfNotes.remove(position); } catch (JSONException e) { diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java index 0d968d6..88c9c79 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java @@ -107,8 +107,8 @@ public class SettingsFragment extends Fragment { { Log.d(TAG, "in camera Button"); - Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intent, REQUEST_IMAGE_CAPTURE); + Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + startActivityForResult(intent, REQUEST_IMAGE_CAPTURE); } diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java index 1aea4ca..32dd0e0 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java @@ -58,6 +58,13 @@ public class Utils { } }; + public static Response.Listener deleteNoteSuccessListener = new Response.Listener() { + @Override + public void onResponse(JSONObject response) { + Log.d(TAG, "deleteNoteSuccessListener: " + response.toString()); + } + }; + public static void showLoadingDialog(Context context, String title, String msg) { progress = new ProgressDialog(context); progress.setTitle(title); @@ -133,4 +140,6 @@ public class Utils { } } + + } diff --git a/app/src/main/res/layout/note_display_full.xml b/app/src/main/res/layout/note_display_full.xml index 70e54e2..3489609 100644 --- a/app/src/main/res/layout/note_display_full.xml +++ b/app/src/main/res/layout/note_display_full.xml @@ -74,11 +74,12 @@ +