From 84df7e043783114d78064198edbe5e4097d5b7ac Mon Sep 17 00:00:00 2001 From: Aran Zaiger Date: Fri, 8 Jul 2016 02:42:25 +0300 Subject: [PATCH] changes in dialog according to ownership - owner will see permission and delete icon - other wont see permission and will see like button --- .../sagi/thesocialnotework/GmapFragment.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 60ea4f7..2e899d1 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 @@ -20,6 +20,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -182,10 +183,18 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { Note note = eventMarkerMap.get(marker); final Dialog noteViewDialog = new Dialog(getActivity()); noteViewDialog.setContentView(R.layout.note_display_full); - noteViewDialog.setTitle("Someone wrote..."); + + boolean isOwner = note.getOwnerId() == mainActivity.getUserId(); + if (isOwner) + noteViewDialog.setTitle("I wrote..."); + else + noteViewDialog.setTitle("Someone wrote..."); + 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); @@ -194,6 +203,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { final TextView likes = (TextView) noteViewDialog.findViewById(R.id.ndf_likes_textview); final TextView tags = (TextView) noteViewDialog.findViewById(R.id.ndf_tags_textview); final TextView permission = (TextView) noteViewDialog.findViewById(R.id.ndf_permission_textview); + final ImageView avatar = (ImageView) noteViewDialog.findViewById(R.id.note_user_avatar); final ImageButton deleteBtn = (ImageButton) noteViewDialog.findViewById(R.id.ndf_delete_imagebutton); @@ -203,7 +213,15 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { location.setText("Tags: " + note.getAddress()); likes.setText("Likes: " + note.getLikes()); tags.setText(note.getTags().toString()); - permission.setText("Permission: " + (note.isPublic() ? "Public" : "Private")); +// avatar.setImageBitmap(); + if (isOwner) { + permission.setText("Permission: " + (note.isPublic() ? "Public" : "Private")); + } + else{ + deleteBtn.setBackgroundResource(R.drawable.like_icon); + } + + // deleteBtn.setOnClickListener(new View.OnClickListener() {