From 01aaf28247fb0748374aea813bf00ee0b91bc2e1 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 9 Jul 2016 19:14:07 +0300 Subject: [PATCH 1/8] Explore --- .../thesocialnotework/ExploreFragment.java | 99 +++++++++++++++++++ .../sagi/thesocialnotework/ListAdapter.java | 9 +- .../sagi/thesocialnotework/MainActivity.java | 5 + .../thesocialnotework/PersonalFragment.java | 2 +- app/src/main/res/layout/fragment_explore.xml | 16 +++ app/src/main/res/layout/fragment_personal.xml | 3 +- app/src/main/res/layout/note_view_mini.xml | 25 ++--- app/src/main/res/values/strings.xml | 66 ++++++------- 8 files changed, 175 insertions(+), 50 deletions(-) create mode 100644 app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ExploreFragment.java create mode 100644 app/src/main/res/layout/fragment_explore.xml diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ExploreFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ExploreFragment.java new file mode 100644 index 0000000..8be26f9 --- /dev/null +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ExploreFragment.java @@ -0,0 +1,99 @@ +package com.android_app.matan.ara.sagi.thesocialnotework; + + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.Fragment; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; + +import com.android.volley.Response; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + + +/** + * A simple {@link Fragment} subclass. + */ +public class ExploreFragment extends Fragment { + + private static final String TAG = "[TSN/Explore]"; + protected User user; + protected MainActivity parent; + private ListAdapter noteListAdapter; + private List notes; + protected ListView list_notes; + + public ExploreFragment() { + // 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_explore, container, false); + + parent = (MainActivity)getActivity(); + user = parent.getUser(); + notes = new ArrayList<>(); + //Get Views + list_notes = (ListView)view.findViewById(R.id.list_notes); + noteListAdapter = new ListAdapter(parent, notes); + + + try { + getAllNotes(); + } catch (JSONException e) { + e.printStackTrace(); + } + return view; + } + + + + public void getAllNotes() throws JSONException { + Log.d(TAG, "url: " + Utils.BASE_URL + "/note/getPublic"); + String url = Utils.BASE_URL + "/note/getPublic"; + JSONObject payload = new JSONObject(); + payload.put("id", user.getId()); + VolleyUtilSingleton.getInstance(getActivity()).post(url, payload ,getNotesSuccessListener,Utils.genericErrorListener); + } + + Response.Listener getNotesSuccessListener = new Response.Listener() { + @Override + public void onResponse(JSONObject response) { + Log.d(TAG, "getNotesSuccessListener: " + response.toString()); + Utils.dismissLoadingDialog(); + try { + //need to get all notes and add to listOfNotes + JSONArray noteObjectsArray = response.getJSONArray("notes"); + parent.getUser().setNumber_of_notes(noteObjectsArray.length()); + Date time = new Date(); + for (int i = 0; i < noteObjectsArray.length(); i++) { + JSONObject noteObject = noteObjectsArray.getJSONObject(i); + time.setTime(noteObject.getLong("created_at")); + notes.add(Utils.getNoteFromJsonObj(noteObject, time)); + } + list_notes.setAdapter(noteListAdapter); + } catch (Exception e) { + Log.e(TAG, "newNoteSuccess:" + e.getMessage()); + } + + } + }; + +} diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java index baf9c12..43260f3 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java @@ -9,6 +9,7 @@ import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.BaseAdapter; +import android.widget.ImageView; import android.widget.TextView; //import com.android.volley.toolbox.NetworkImageView; @@ -62,7 +63,7 @@ public class ListAdapter extends BaseAdapter { TextView date = (TextView) v.findViewById(R.id.nvm_date_textview); TextView location = (TextView) v.findViewById(R.id.nvm_location_textview); TextView likes = (TextView) v.findViewById(R.id.nvm_likes_textview); - TextView permission = (TextView) v.findViewById(R.id.nvm_permission_textview); + ImageView permission = (ImageView) v.findViewById(R.id.nvm_permission_image_view); // NetworkImageView thumbNail = (NetworkImageView) v.findViewById(R.id.infoImageImageView); // String url = mVideos.get(position).getImgURL(); // thumbNail.setImageUrl(url, VolleyUtilSingleTone.getInstance(mContext).getImageLoader()); @@ -73,7 +74,11 @@ public class ListAdapter extends BaseAdapter { location.setText(curNote.getAddress()); if(likes !=null )likes.setText(""+curNote.getLikes()); // permission.setText(curNote.isPublic() ? "Public":"Private"); - permission.setBackground(curNote.isPublic() ? v.getResources().getDrawable(R.drawable.public_icon): v.getResources().getDrawable(R.drawable.private_icon)); + if(((MainActivity)mContext).getUser().getId().equals(curNote.ownerId)){// MY Note + permission.setBackground(curNote.isPublic() ? v.getResources().getDrawable(R.drawable.public_icon): v.getResources().getDrawable(R.drawable.private_icon)); + }else{ + Utils.URLtoImageView(permission, curNote.getAvatar()); + } Animation animation = AnimationUtils.loadAnimation(mContext, (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top); v.startAnimation(animation); diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java index 6b0988f..fee6bd3 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java @@ -52,6 +52,7 @@ public class MainActivity extends AppCompatActivity private GmapFragment gmapFragment; private PersonalFragment personalFragment; private SettingsFragment settingsFragment; + private ExploreFragment exploreFragment; private Toolbar toolbar; public static final String BASE_URL = "http://thesocialnotework-api.appspot.com/api"; private ImageView menu_avatar; @@ -71,6 +72,7 @@ public class MainActivity extends AppCompatActivity gmapFragment = new GmapFragment(); personalFragment = new PersonalFragment(); settingsFragment = new SettingsFragment(); + exploreFragment = new ExploreFragment(); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); @@ -153,6 +155,9 @@ public class MainActivity extends AppCompatActivity if (id == R.id.nav_explore) { toolbar.setTitle("Explore"); setSupportActionBar(toolbar); + Log.d(TAG, "Before going to Explore"); + ft.replace(R.id.fragment_container, exploreFragment); + ft.commit(); } else if (id == R.id.nav_map) { Log.d(TAG, "Before going to map"); 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 6636b88..e5eb014 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 @@ -114,7 +114,7 @@ public class PersonalFragment extends Fragment { gpsUtils = activity.getGPSUtils(); gpsUtils.getLocation(); listOfNotes = new ArrayList<>(); - noteListAdapter = new ListAdapter(getContext(), listOfNotes); + noteListAdapter = new ListAdapter(activity, listOfNotes); noteList.setAdapter(noteListAdapter); noteList.setOnItemClickListener(new ItemClickedListener()); Utils.showLoadingDialog(getActivity(), "Fetching..", "getting your notes"); diff --git a/app/src/main/res/layout/fragment_explore.xml b/app/src/main/res/layout/fragment_explore.xml new file mode 100644 index 0000000..b17eaa6 --- /dev/null +++ b/app/src/main/res/layout/fragment_explore.xml @@ -0,0 +1,16 @@ + + + + + + diff --git a/app/src/main/res/layout/fragment_personal.xml b/app/src/main/res/layout/fragment_personal.xml index 02141dd..8f0328e 100644 --- a/app/src/main/res/layout/fragment_personal.xml +++ b/app/src/main/res/layout/fragment_personal.xml @@ -81,8 +81,7 @@ android:id="@+id/ps_list_listview" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_weight="0.8" - android:layout_marginTop="10dp" /> + android:layout_weight="0.8" /> - + - + android:layout_marginLeft="15dp" + android:layout_gravity="center"> + android:layout_height="wrap_content"> + android:layout_weight="0.3" + android:gravity="end" + android:layout_gravity="right"> - TSN + TSN - - Email - Username - Password - Login - Register - Register - No account yet? Create one for FREE - Sign in - This email address is invalid - This password is too short - This password is incorrect - This field is required + + Email + Username + Password + Login + Register + Register + No account yet? Create one for FREE + Sign in + This email address is invalid + This password is too short + This password is incorrect + This field is required "Contacts permissions are needed for providing email completions." - PersonalSpaceActivity - Private - Public - Logo - Title - Content - Discard - Save - Username - Password - MainActivity + PersonalSpaceActivity + Private + Public + Logo + Title + Content + Discard + Save + Username + Password + MainActivity - Open navigation drawer - Close navigation drawer + Open navigation drawer + Close navigation drawer - Settings + Settings - - Hello blank fragment - Password should be at least 4 chars long - Map - Avatar + + Hello blank fragment + Password should be at least 4 chars long + Map + Avatar From 59a2504220d8103d4f04aa9fd2ec32f2d13981b1 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 9 Jul 2016 19:21:34 +0300 Subject: [PATCH 2/8] Explore works - Need filtering --- .../matan/ara/sagi/thesocialnotework/ExploreFragment.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ExploreFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ExploreFragment.java index 8be26f9..71b0287 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ExploreFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ExploreFragment.java @@ -66,6 +66,7 @@ public class ExploreFragment extends Fragment { public void getAllNotes() throws JSONException { + Utils.showLoadingDialog(parent, "Exploring...", "Finding some new interesting notes just for you"); Log.d(TAG, "url: " + Utils.BASE_URL + "/note/getPublic"); String url = Utils.BASE_URL + "/note/getPublic"; JSONObject payload = new JSONObject(); @@ -89,6 +90,7 @@ public class ExploreFragment extends Fragment { notes.add(Utils.getNoteFromJsonObj(noteObject, time)); } list_notes.setAdapter(noteListAdapter); + Utils.dismissLoadingDialog(); } catch (Exception e) { Log.e(TAG, "newNoteSuccess:" + e.getMessage()); } From 4fe2a0ab516ac4bbd74fb23a4ed7d4596d54c401 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sat, 9 Jul 2016 19:33:05 +0300 Subject: [PATCH 3/8] - note_display_full width bug fixed --- .../matan/ara/sagi/thesocialnotework/GmapFragment.java | 6 +++--- app/src/main/res/layout/note_display_full.xml | 3 ++- 2 files changed, 5 insertions(+), 4 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 68b7f09..9a494ae 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 @@ -84,9 +84,9 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { private final String hundredMeters = "100 meters"; private final String kilometer = "1 Km"; private final String threeKilometer = "3 Km"; - private final String mine = "mine"; - private final String others = "others"; - private final String all = "all"; + private final String mine = "Mine"; + private final String others = "Others"; + private final String all = "All"; diff --git a/app/src/main/res/layout/note_display_full.xml b/app/src/main/res/layout/note_display_full.xml index 28d3834..4994856 100644 --- a/app/src/main/res/layout/note_display_full.xml +++ b/app/src/main/res/layout/note_display_full.xml @@ -8,7 +8,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="20dp" - android:orientation="vertical"> + android:orientation="vertical" + android:minWidth="330dp"> Date: Sat, 9 Jul 2016 19:47:39 +0300 Subject: [PATCH 4/8] - fragment_explore list align --- .../sagi/thesocialnotework/ListAdapter.java | 2 +- app/src/main/res/layout/fragment_explore.xml | 4 +- app/src/main/res/layout/note_view_mini.xml | 102 ++++++++++-------- 3 files changed, 58 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java index 43260f3..5562f0f 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java @@ -63,7 +63,7 @@ public class ListAdapter extends BaseAdapter { TextView date = (TextView) v.findViewById(R.id.nvm_date_textview); TextView location = (TextView) v.findViewById(R.id.nvm_location_textview); TextView likes = (TextView) v.findViewById(R.id.nvm_likes_textview); - ImageView permission = (ImageView) v.findViewById(R.id.nvm_permission_image_view); + ImageView permission = (RoundAvatarImageView) v.findViewById(R.id.nvm_permission_image_view); // NetworkImageView thumbNail = (NetworkImageView) v.findViewById(R.id.infoImageImageView); // String url = mVideos.get(position).getImgURL(); // thumbNail.setImageUrl(url, VolleyUtilSingleTone.getInstance(mContext).getImageLoader()); diff --git a/app/src/main/res/layout/fragment_explore.xml b/app/src/main/res/layout/fragment_explore.xml index b17eaa6..b9d86e3 100644 --- a/app/src/main/res/layout/fragment_explore.xml +++ b/app/src/main/res/layout/fragment_explore.xml @@ -1,6 +1,6 @@ diff --git a/app/src/main/res/layout/note_view_mini.xml b/app/src/main/res/layout/note_view_mini.xml index 7a3708a..89a4469 100644 --- a/app/src/main/res/layout/note_view_mini.xml +++ b/app/src/main/res/layout/note_view_mini.xml @@ -1,122 +1,130 @@ - + + + + + - + + + android:layout_weight="0.6" + android:orientation="vertical"> + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="18dp" + android:textStyle="bold" /> + android:layout_height="match_parent" + android:orientation="horizontal"> + android:padding="5dp" + android:text="Date and time" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textSize="9dp" /> + android:padding="5dp" + android:text="Date and time" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textSize="9dp" /> + android:layout_height="wrap_content" + android:orientation="horizontal"> + android:padding="5dp" + android:text="location" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textSize="9dp" /> + android:gravity="end"> - + android:gravity="center" + android:orientation="horizontal" + android:weightSum="1"> + android:gravity="center_vertical|center_horizontal" + android:text="Likes" /> From 9a7680c489da1351cf3fabd79f1e15b088120b87 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sat, 9 Jul 2016 20:00:20 +0300 Subject: [PATCH 5/8] - filters do not take space anymore when they are invisible --- .../ara/sagi/thesocialnotework/GmapFragment.java | 6 +++--- .../sagi/thesocialnotework/PersonalFragment.java | 4 ++-- app/src/main/res/layout/fragment_personal.xml | 13 +++++++++---- 3 files changed, 14 insertions(+), 9 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 9a494ae..e91ea7f 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 @@ -147,7 +147,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { // Log.d(TAG, "" + v.getId()); if (dateFilterIsVisible) { dateFilterIsVisible = false; - mapFilters.setVisibility(View.INVISIBLE); + mapFilters.setVisibility(View.GONE); } else { mapFilters.setVisibility(View.VISIBLE); dateFilterIsVisible = true; @@ -167,7 +167,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { public void onClick(View v) { if (locationFilterIsVisible) { locationFilterIsVisible = false; - mapFilters.setVisibility(View.INVISIBLE); + mapFilters.setVisibility(View.GONE); } else { mapFilters.setVisibility(View.VISIBLE); locationFilterIsVisible = true; @@ -187,7 +187,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { public void onClick(View v) { if (userFilterIsVisible) { userFilterIsVisible = false; - mapFilters.setVisibility(View.INVISIBLE); + mapFilters.setVisibility(View.GONE); } else { mapFilters.setVisibility(View.VISIBLE); userFilterIsVisible = true; 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 81573b1..cae9a6e 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 @@ -132,7 +132,7 @@ public class PersonalFragment extends Fragment { public void onClick(View v) { if (dateFilterIsVisible) { dateFilterIsVisible = false; - personalSpaceFilters.setVisibility(View.INVISIBLE); + personalSpaceFilters.setVisibility(View.GONE); } else { personalSpaceFilters.setVisibility(View.VISIBLE); dateFilterIsVisible = true; @@ -151,7 +151,7 @@ public class PersonalFragment extends Fragment { public void onClick(View v) { if (userFilterIsVisible) { userFilterIsVisible = false; - personalSpaceFilters.setVisibility(View.INVISIBLE); + personalSpaceFilters.setVisibility(View.GONE); } else { personalSpaceFilters.setVisibility(View.VISIBLE); userFilterIsVisible = true; diff --git a/app/src/main/res/layout/fragment_personal.xml b/app/src/main/res/layout/fragment_personal.xml index 8f0328e..51dda74 100644 --- a/app/src/main/res/layout/fragment_personal.xml +++ b/app/src/main/res/layout/fragment_personal.xml @@ -34,7 +34,8 @@ android:id="@+id/personalSpace_date_filter" android:layout_weight="1" android:src="@drawable/date_icon" - android:scaleType="fitCenter" /> + android:scaleType="fitCenter" + android:focusable="false" /> + android:src="@drawable/permission_icon" + android:focusable="false" + android:focusableInTouchMode="false" /> + android:visibility="gone" + android:id="@+id/personalSpace_filter_options" + android:clickable="false" + android:focusableInTouchMode="false">