Merge branch 'master' of github.com:sagidayan/TheSocialNotework-Android
This commit is contained in:
commit
c5ffa81c3b
8 changed files with 594 additions and 431 deletions
|
@ -1,6 +1,9 @@
|
||||||
package com.android_app.matan.ara.sagi.thesocialnotework;
|
package com.android_app.matan.ara.sagi.thesocialnotework;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -8,10 +11,16 @@ import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
|
|
||||||
|
@ -32,166 +41,259 @@ import java.util.ListIterator;
|
||||||
*/
|
*/
|
||||||
public class ExploreFragment extends Fragment {
|
public class ExploreFragment extends Fragment {
|
||||||
|
|
||||||
private static final String TAG = "[TSN/Explore]";
|
private static final String TAG = "[TSN/Explore]";
|
||||||
protected User user;
|
protected User user;
|
||||||
protected MainActivity parent;
|
protected MainActivity parent;
|
||||||
private ListAdapter noteListAdapter;
|
private ListAdapter noteListAdapter;
|
||||||
private List<Note> notes;
|
private List<Note> notes;
|
||||||
protected ListView list_notes;
|
protected ListView list_notes;
|
||||||
|
|
||||||
private ImageButton dateFilter;
|
private ImageButton dateFilter;
|
||||||
private ImageButton locationFilter;
|
private ImageButton locationFilter;
|
||||||
private ImageButton userFilter;
|
// private ImageButton userFilter;
|
||||||
private Button map_small_filter;
|
private Button map_small_filter;
|
||||||
private Button map_medium_filter;
|
private Button map_medium_filter;
|
||||||
private Button map_large_filter;
|
private Button map_large_filter;
|
||||||
private LinearLayout exploreFilters;
|
private LinearLayout exploreFilters;
|
||||||
private boolean dateFilterIsVisible = false;
|
private boolean dateFilterIsVisible = false;
|
||||||
private boolean locationFilterIsVisible = false;
|
private boolean locationFilterIsVisible = false;
|
||||||
private boolean userFilterIsVisible = false;
|
// private boolean userFilterIsVisible = false;
|
||||||
|
|
||||||
private final String day = "24 hours";
|
private final String day = "24 hours";
|
||||||
private final String week = "Week";
|
private final String week = "Week";
|
||||||
private final String month = "Month";
|
private final String month = "Month";
|
||||||
private final String hundredMeters = "100 meters";
|
private final String hundredMeters = "100 meters";
|
||||||
private final String kilometer = "1 Km";
|
private final String kilometer = "1 Km";
|
||||||
private final String threeKilometer = "3 Km";
|
private final String threeKilometer = "3 Km";
|
||||||
private final String mine = "Mine";
|
// private final String mine = "Mine";
|
||||||
private final String others = "Others";
|
// private final String others = "Others";
|
||||||
private final String all = "All";
|
// private final String all = "All";
|
||||||
|
|
||||||
public ExploreFragment() {
|
public ExploreFragment() {
|
||||||
// Required empty public constructor
|
// 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);
|
|
||||||
|
|
||||||
|
|
||||||
dateFilter = (ImageButton) view.findViewById(R.id.explore_date_filter);
|
|
||||||
locationFilter = (ImageButton) view.findViewById(R.id.explore_location_filter);
|
|
||||||
userFilter = (ImageButton) view.findViewById(R.id.explore_user_filter);
|
|
||||||
|
|
||||||
map_small_filter = (Button) view.findViewById(R.id.explore_small_filter);
|
|
||||||
map_medium_filter = (Button) view.findViewById(R.id.explore_medium_filter);
|
|
||||||
map_large_filter = (Button) view.findViewById(R.id.explore_large_filter);
|
|
||||||
|
|
||||||
exploreFilters = (LinearLayout) view.findViewById(R.id.explore_filter_options);
|
|
||||||
|
|
||||||
dateFilter.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (dateFilterIsVisible) {
|
|
||||||
dateFilterIsVisible = false;
|
|
||||||
exploreFilters.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
exploreFilters.setVisibility(View.VISIBLE);
|
|
||||||
dateFilterIsVisible = true;
|
|
||||||
locationFilterIsVisible = false;
|
|
||||||
userFilterIsVisible = false;
|
|
||||||
|
|
||||||
// set text button in the right filter string
|
|
||||||
map_small_filter.setText(day);
|
|
||||||
map_medium_filter.setText(week);
|
|
||||||
map_large_filter.setText(month);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
locationFilter.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (locationFilterIsVisible) {
|
|
||||||
locationFilterIsVisible = false;
|
|
||||||
exploreFilters.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
exploreFilters.setVisibility(View.VISIBLE);
|
|
||||||
locationFilterIsVisible = true;
|
|
||||||
dateFilterIsVisible = false;
|
|
||||||
userFilterIsVisible = false;
|
|
||||||
|
|
||||||
// set text button in the right filter string
|
|
||||||
map_small_filter.setText(hundredMeters);
|
|
||||||
map_medium_filter.setText(kilometer);
|
|
||||||
map_large_filter.setText(threeKilometer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
userFilter.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (userFilterIsVisible) {
|
|
||||||
userFilterIsVisible = false;
|
|
||||||
exploreFilters.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
exploreFilters.setVisibility(View.VISIBLE);
|
|
||||||
userFilterIsVisible = true;
|
|
||||||
dateFilterIsVisible = false;
|
|
||||||
locationFilterIsVisible = false;
|
|
||||||
|
|
||||||
// set text button in the right filter string
|
|
||||||
map_small_filter.setText(mine);
|
|
||||||
map_medium_filter.setText(others);
|
|
||||||
map_large_filter.setText(all);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: choose a default filter for openning explore mode
|
|
||||||
|
|
||||||
try {
|
|
||||||
getAllNotes();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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();
|
|
||||||
payload.put("id", user.getId());
|
|
||||||
VolleyUtilSingleton.getInstance(getActivity()).post(url, payload ,getNotesSuccessListener,Utils.genericErrorListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
Response.Listener<JSONObject> getNotesSuccessListener = new Response.Listener<JSONObject>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(JSONObject response) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Log.d(TAG, "getNotesSuccessListener: " + response.toString());
|
Bundle savedInstanceState) {
|
||||||
Utils.dismissLoadingDialog();
|
// Inflate the layout for this fragment
|
||||||
try {
|
View view = inflater.inflate(R.layout.fragment_explore, container, false);
|
||||||
//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);
|
|
||||||
Utils.dismissLoadingDialog();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "newNoteSuccess:" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
list_notes.setOnItemClickListener(new ItemClickedListener());
|
||||||
|
|
||||||
|
|
||||||
|
dateFilter = (ImageButton) view.findViewById(R.id.explore_date_filter);
|
||||||
|
locationFilter = (ImageButton) view.findViewById(R.id.explore_location_filter);
|
||||||
|
|
||||||
|
map_small_filter = (Button) view.findViewById(R.id.explore_small_filter);
|
||||||
|
map_medium_filter = (Button) view.findViewById(R.id.explore_medium_filter);
|
||||||
|
map_large_filter = (Button) view.findViewById(R.id.explore_large_filter);
|
||||||
|
|
||||||
|
exploreFilters = (LinearLayout) view.findViewById(R.id.explore_filter_options);
|
||||||
|
|
||||||
|
dateFilter.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (dateFilterIsVisible) {
|
||||||
|
dateFilterIsVisible = false;
|
||||||
|
exploreFilters.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
exploreFilters.setVisibility(View.VISIBLE);
|
||||||
|
dateFilterIsVisible = true;
|
||||||
|
locationFilterIsVisible = false;
|
||||||
|
// userFilterIsVisible = false;
|
||||||
|
|
||||||
|
// set text button in the right filter string
|
||||||
|
map_small_filter.setText(day);
|
||||||
|
map_medium_filter.setText(week);
|
||||||
|
map_large_filter.setText(month);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
locationFilter.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (locationFilterIsVisible) {
|
||||||
|
locationFilterIsVisible = false;
|
||||||
|
exploreFilters.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
exploreFilters.setVisibility(View.VISIBLE);
|
||||||
|
locationFilterIsVisible = true;
|
||||||
|
dateFilterIsVisible = false;
|
||||||
|
// userFilterIsVisible = false;
|
||||||
|
|
||||||
|
// set text button in the right filter string
|
||||||
|
map_small_filter.setText(hundredMeters);
|
||||||
|
map_medium_filter.setText(kilometer);
|
||||||
|
map_large_filter.setText(threeKilometer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// userFilter.setOnClickListener(new View.OnClickListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onClick(View v) {
|
||||||
|
// if (userFilterIsVisible) {
|
||||||
|
// userFilterIsVisible = false;
|
||||||
|
// exploreFilters.setVisibility(View.GONE);
|
||||||
|
// } else {
|
||||||
|
// exploreFilters.setVisibility(View.VISIBLE);
|
||||||
|
// userFilterIsVisible = true;
|
||||||
|
// dateFilterIsVisible = false;
|
||||||
|
// locationFilterIsVisible = false;
|
||||||
|
//
|
||||||
|
// // set text button in the right filter string
|
||||||
|
// map_small_filter.setText(mine);
|
||||||
|
// map_medium_filter.setText(others);
|
||||||
|
// map_large_filter.setText(all);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// TODO: choose a default filter for openning explore mode
|
||||||
|
|
||||||
|
try {
|
||||||
|
getAllNotes();
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
payload.put("id", user.getId());
|
||||||
|
VolleyUtilSingleton.getInstance(getActivity()).post(url, payload, getNotesSuccessListener, Utils.genericErrorListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
Response.Listener<JSONObject> getNotesSuccessListener = new Response.Listener<JSONObject>() {
|
||||||
|
@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);
|
||||||
|
Utils.dismissLoadingDialog();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "newNoteSuccess:" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// click on listView item
|
||||||
|
class ItemClickedListener implements AdapterView.OnItemClickListener {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
|
||||||
|
//create and configure dialog
|
||||||
|
final Note note = notes.get(position);
|
||||||
|
final Dialog noteViewDialog = new Dialog(getActivity());
|
||||||
|
noteViewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
noteViewDialog.setContentView(R.layout.note_display_full);
|
||||||
|
// noteViewDialog.setTitle("You wrote...");
|
||||||
|
|
||||||
|
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
||||||
|
lp.copyFrom(noteViewDialog.getWindow().getAttributes());
|
||||||
|
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||||
|
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||||
|
noteViewDialog.show();
|
||||||
|
// dialog.getWindow().setAttributes(lp);
|
||||||
|
|
||||||
|
|
||||||
|
//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);
|
||||||
|
final TextView time = (TextView) noteViewDialog.findViewById(R.id.ndf_time_textview);
|
||||||
|
final TextView date = (TextView) noteViewDialog.findViewById(R.id.ndf_date_textview);
|
||||||
|
final TextView location = (TextView) noteViewDialog.findViewById(R.id.ndf_address_textview);
|
||||||
|
final TextView likes = (TextView) noteViewDialog.findViewById(R.id.ndf_likes_textview);
|
||||||
|
final TextView permission = (TextView) noteViewDialog.findViewById(R.id.ndf_permission_textview);
|
||||||
|
final ImageButton likeBtn = (ImageButton) noteViewDialog.findViewById(R.id.ndf_delete_imagebutton);
|
||||||
|
final ImageView avatar = (RoundAvatarImageView) noteViewDialog.findViewById(R.id.note_user_avatar);
|
||||||
|
final ImageView permission_image = (ImageView) noteViewDialog.findViewById(R.id.permission_image);
|
||||||
|
|
||||||
|
title.setText(note.getTitle());
|
||||||
|
body.setText(note.getBody());
|
||||||
|
date.setText(note.getDate());
|
||||||
|
time.setText(note.getTime());
|
||||||
|
location.setText(note.getAddress());
|
||||||
|
if (likes != null) likes.setText("" + note.getLikes());
|
||||||
|
likeBtn.setBackgroundResource(R.drawable.like_icon);
|
||||||
|
// tags.setText("Tags: "+ note.getTags().toString());
|
||||||
|
// permission.setText("" + (note.isPublic() ? "Public" : "Private"));
|
||||||
|
permission.setVisibility(View.GONE);
|
||||||
|
Utils.URLtoImageView(avatar, note.getAvatar());
|
||||||
|
permission_image.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
likeBtn.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, Utils.deleteNoteSuccessListener, Utils.genericErrorListener);
|
||||||
|
// listOfNotes.remove(presentedNotes.get(position));
|
||||||
|
// presentedNotes.remove(position);
|
||||||
|
//
|
||||||
|
// } catch (JSONException e) {
|
||||||
|
// Toast.makeText(getActivity(), "Something went wrong.\n Failed to delete note...", Toast.LENGTH_LONG).show();
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// updateShowedNotes();
|
||||||
|
//// 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();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,21 +77,27 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
private boolean dateFilterIsVisible = false;
|
private boolean dateFilterIsVisible = false;
|
||||||
private boolean locationFilterIsVisible = false;
|
private boolean locationFilterIsVisible = false;
|
||||||
private boolean userFilterIsVisible = false;
|
private boolean userFilterIsVisible = false;
|
||||||
|
private int userFilterSelection;
|
||||||
|
private Long dateFilterSelection;
|
||||||
|
private float locationFilterSelection;
|
||||||
|
List<Note> listOfNotes;
|
||||||
|
|
||||||
private final String day = "24 hours";
|
private final String day = "24 hours";
|
||||||
private final String week = "Week";
|
private final String week = "Week";
|
||||||
private final String month = "Month";
|
private final String month = "Month";
|
||||||
private final String hundredMeters = "100 meters";
|
private final String hundredMeters = "1 Km";
|
||||||
private final String kilometer = "1 Km";
|
private final String kilometer = "10 Km";
|
||||||
private final String threeKilometer = "3 Km";
|
private final String tenKilometers = "100 Km";
|
||||||
private final String mine = "Mine";
|
private final String mine = "Mine";
|
||||||
private final String others = "Others";
|
private final String others = "Others";
|
||||||
private final String all = "All";
|
private final String all = "All";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GmapFragment() {
|
public GmapFragment() {
|
||||||
eventMarkerMap = new HashMap<Marker, Note>();
|
eventMarkerMap = new HashMap<Marker, Note>();
|
||||||
|
dateFilterSelection = Utils.MONTH_MILI;
|
||||||
|
userFilterSelection = 3;
|
||||||
|
locationFilterSelection = Utils.DISTANCE_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,6 +136,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
SupportMapFragment frag = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.mapFragment);
|
SupportMapFragment frag = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.mapFragment);
|
||||||
frag.getMapAsync(this);
|
frag.getMapAsync(this);
|
||||||
|
listOfNotes = new ArrayList<>();
|
||||||
|
|
||||||
dateFilter = (ImageButton) view.findViewById(R.id.map_date_filter);
|
dateFilter = (ImageButton) view.findViewById(R.id.map_date_filter);
|
||||||
locationFilter = (ImageButton) view.findViewById(R.id.map_location_filter);
|
locationFilter = (ImageButton) view.findViewById(R.id.map_location_filter);
|
||||||
|
@ -139,6 +146,10 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
map_medium_filter = (Button) view.findViewById(R.id.map_medium_filter);
|
map_medium_filter = (Button) view.findViewById(R.id.map_medium_filter);
|
||||||
map_large_filter = (Button) view.findViewById(R.id.map_large_filter);
|
map_large_filter = (Button) view.findViewById(R.id.map_large_filter);
|
||||||
|
|
||||||
|
map_small_filter.setOnClickListener(button1ClickListener);
|
||||||
|
map_medium_filter.setOnClickListener(button2ClickListener);
|
||||||
|
map_large_filter.setOnClickListener(button3ClickListener);
|
||||||
|
|
||||||
mapFilters = (LinearLayout) view.findViewById(R.id.map_filter_options);
|
mapFilters = (LinearLayout) view.findViewById(R.id.map_filter_options);
|
||||||
|
|
||||||
dateFilter.setOnClickListener(new View.OnClickListener() {
|
dateFilter.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -156,8 +167,10 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
// set text button in the right filter string
|
// set text button in the right filter string
|
||||||
map_small_filter.setText(day);
|
map_small_filter.setText(day);
|
||||||
map_medium_filter.setText(week);
|
map_medium_filter.setText(week);
|
||||||
|
map_medium_filter.setText(week);
|
||||||
map_large_filter.setText(month);
|
map_large_filter.setText(month);
|
||||||
}
|
}
|
||||||
|
setButtonsColor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -176,8 +189,9 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
// set text button in the right filter string
|
// set text button in the right filter string
|
||||||
map_small_filter.setText(hundredMeters);
|
map_small_filter.setText(hundredMeters);
|
||||||
map_medium_filter.setText(kilometer);
|
map_medium_filter.setText(kilometer);
|
||||||
map_large_filter.setText(threeKilometer);
|
map_large_filter.setText(tenKilometers);
|
||||||
}
|
}
|
||||||
|
setButtonsColor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -198,6 +212,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
map_medium_filter.setText(others);
|
map_medium_filter.setText(others);
|
||||||
map_large_filter.setText(all);
|
map_large_filter.setText(all);
|
||||||
}
|
}
|
||||||
|
setButtonsColor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -314,8 +329,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isOwner)
|
if (isOwner) {
|
||||||
{
|
|
||||||
deleteBtn.setOnClickListener(new View.OnClickListener() {
|
deleteBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
//Put up the Yes/No message box
|
//Put up the Yes/No message box
|
||||||
|
@ -359,8 +373,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
//like Btn
|
//like Btn
|
||||||
deleteBtn.setOnClickListener(new View.OnClickListener() {
|
deleteBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -378,7 +391,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/like", jsonObj, getNotesSuccessListener, Utils.genericErrorListener);
|
VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/like", jsonObj, getNotesSuccessListener, Utils.genericErrorListener);
|
||||||
mainActivity.getUser().getLiked_notes().add(note.getId());
|
mainActivity.getUser().getLiked_notes().add(note.getId());
|
||||||
mainActivity.getUser().updateUser(mainActivity);
|
mainActivity.getUser().updateUser(mainActivity);
|
||||||
likes.setText("Likes: "+(note.getLikes()+1));
|
likes.setText("Likes: " + (note.getLikes() + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -398,7 +411,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(JSONObject response) {
|
public void onResponse(JSONObject response) {
|
||||||
Log.d(TAG, "getNotesSuccessListener: " + response.toString());
|
Log.d(TAG, "getNotesSuccessListener: " + response.toString());
|
||||||
List<Note> listOfNotes = new ArrayList<>();
|
// listOfNotes = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//need to get all notes and add to listOfNotes
|
//need to get all notes and add to listOfNotes
|
||||||
|
@ -409,7 +422,9 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
time.setTime(noteObject.getLong("created_at"));
|
time.setTime(noteObject.getLong("created_at"));
|
||||||
listOfNotes.add(Utils.getNoteFromJsonObj(noteObject, time));
|
listOfNotes.add(Utils.getNoteFromJsonObj(noteObject, time));
|
||||||
}
|
}
|
||||||
new getMarkersFromNotes(mMap, eventMarkerMap).execute(listOfNotes);
|
updateShowedNotes();
|
||||||
|
// new getMarkersFromNotes(mMap, eventMarkerMap).execute(listOfNotes);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "newNoteSuccess:" + e.getMessage());
|
Log.e(TAG, "newNoteSuccess:" + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -418,7 +433,6 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class getMarkersFromNotes extends AsyncTask<List<Note>, MarkerNoteStruct, Void> {
|
private class getMarkersFromNotes extends AsyncTask<List<Note>, MarkerNoteStruct, Void> {
|
||||||
GoogleMap mMap;
|
GoogleMap mMap;
|
||||||
HashMap<Marker, Note> eventMarkerMap;
|
HashMap<Marker, Note> eventMarkerMap;
|
||||||
|
@ -432,7 +446,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(MarkerNoteStruct... mo) {
|
protected void onProgressUpdate(MarkerNoteStruct... mo) {
|
||||||
|
|
||||||
eventMarkerMap.put(mMap.addMarker(mo[0].getMarker()),mo[0].getNote());
|
eventMarkerMap.put(mMap.addMarker(mo[0].getMarker()), mo[0].getNote());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +464,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
.snippet(n.getBody())
|
.snippet(n.getBody())
|
||||||
.icon(b);
|
.icon(b);
|
||||||
|
|
||||||
publishProgress(new MarkerNoteStruct(n,mo));
|
publishProgress(new MarkerNoteStruct(n, mo));
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -460,19 +474,179 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Marker placeMarker(Note eventInfo) {
|
//set main filter colors
|
||||||
//
|
private void setButtonsColor() {
|
||||||
// Marker m = getMap().addMarker(new MarkerOptions()
|
|
||||||
//
|
Log.d(TAG, "setButtonsColor: start");
|
||||||
// .position(eventInfo.getLatLong())
|
//set date filter colors
|
||||||
//
|
if (dateFilterIsVisible) {
|
||||||
// .title(eventInfo.getName()));
|
Log.d(TAG, "setButtonsColor: dateselection :" + dateFilterSelection);
|
||||||
//
|
dateFilter.setBackgroundColor(Utils.filterColor);
|
||||||
//
|
if (dateFilterSelection == Utils.DAY_MILI) {
|
||||||
//
|
map_small_filter.setBackgroundColor(Utils.filterColor);
|
||||||
// return m;
|
map_medium_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
//
|
map_large_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
// }
|
} else if (dateFilterSelection == Utils.WEEK_MILI) {
|
||||||
|
map_small_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_medium_filter.setBackgroundColor(Utils.filterColor);
|
||||||
|
map_large_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
} else {
|
||||||
|
map_small_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_medium_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_large_filter.setBackgroundColor(Utils.filterColor);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dateFilter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
}
|
||||||
|
|
||||||
|
//set date filter colors
|
||||||
|
if (userFilterIsVisible) {
|
||||||
|
Log.d(TAG, "setButtonsColor: userFilter: " + userFilterSelection);
|
||||||
|
userFilter.setBackgroundColor(Utils.filterColor);
|
||||||
|
if (userFilterSelection == 1) {
|
||||||
|
map_small_filter.setBackgroundColor(Utils.filterColor);
|
||||||
|
map_medium_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_large_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
} else if (userFilterSelection == 2) {
|
||||||
|
map_small_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_medium_filter.setBackgroundColor(Utils.filterColor);
|
||||||
|
map_large_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
} else {
|
||||||
|
map_small_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_medium_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_large_filter.setBackgroundColor(Utils.filterColor);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
userFilter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
}
|
||||||
|
|
||||||
|
//set distance filter colors
|
||||||
|
if (locationFilterIsVisible) {
|
||||||
|
Log.d(TAG, "setButtonsColor: userFilter: " + userFilterSelection);
|
||||||
|
locationFilter.setBackgroundColor(Utils.filterColor);
|
||||||
|
if (locationFilterSelection == Utils.DISTANCE_SMALL) {
|
||||||
|
map_small_filter.setBackgroundColor(Utils.filterColor);
|
||||||
|
map_medium_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_large_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
} else if (locationFilterSelection == Utils.DISTANCE_MEDIUM) {
|
||||||
|
map_small_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_medium_filter.setBackgroundColor(Utils.filterColor);
|
||||||
|
map_large_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
} else {
|
||||||
|
map_small_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_medium_filter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
map_large_filter.setBackgroundColor(Utils.filterColor);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
locationFilter.setBackgroundResource(android.R.drawable.btn_default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateShowedNotes() {
|
||||||
|
List<Note> presentedNotes = new ArrayList<>();
|
||||||
|
long timeDifference;
|
||||||
|
float distance;
|
||||||
|
//get current date and location
|
||||||
|
Location currLocation = new Location(gpsUtils.getLocation());
|
||||||
|
Date now = new Date();
|
||||||
|
Location targetLocation = new Location("");//provider name is unecessary
|
||||||
|
Date targetDate;
|
||||||
|
|
||||||
|
for (Note note : listOfNotes) {
|
||||||
|
// get note location and date
|
||||||
|
targetLocation.setLatitude(note.getLat());//your coords of course
|
||||||
|
targetLocation.setLongitude(note.getLon());
|
||||||
|
targetDate = new Date(note.getTimestamp());
|
||||||
|
//get time and date differences
|
||||||
|
timeDifference = now.getTime() - targetDate.getTime();
|
||||||
|
distance = currLocation.distanceTo(targetLocation);
|
||||||
|
//add to currently presented list according to filters.
|
||||||
|
if (timeDifference <= dateFilterSelection
|
||||||
|
&& distance <= locationFilterSelection
|
||||||
|
&& ((note.getOwnerId().equals(mainActivity.getUserId()) && userFilterSelection == 1) || (!note.getOwnerId().equals(mainActivity.getUserId()) && userFilterSelection == 2) || (userFilterSelection == 3))) {
|
||||||
|
presentedNotes.add(note);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.d(TAG, "updateShowedNotes: ======= markers presented: "+ presentedNotes.size()+"=============");
|
||||||
|
mMap.clear();
|
||||||
|
new getMarkersFromNotes(mMap, eventMarkerMap).execute(presentedNotes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//all buttons listener
|
||||||
|
public View.OnClickListener button1ClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(final View v) {
|
||||||
|
//user filters
|
||||||
|
if (userFilterIsVisible) {
|
||||||
|
userFilterSelection = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//location filter
|
||||||
|
else if (locationFilterIsVisible) {
|
||||||
|
locationFilterSelection = Utils.DISTANCE_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//date filters
|
||||||
|
else {
|
||||||
|
dateFilterSelection = Utils.DAY_MILI;
|
||||||
|
|
||||||
|
}
|
||||||
|
//change colors of buttons and update visible notes
|
||||||
|
setButtonsColor();
|
||||||
|
updateShowedNotes();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//all buttons listener
|
||||||
|
public View.OnClickListener button2ClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(final View v) {
|
||||||
|
//user filters
|
||||||
|
if (userFilterIsVisible) {
|
||||||
|
userFilterSelection = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//location filter
|
||||||
|
else if (locationFilterIsVisible) {
|
||||||
|
locationFilterSelection = Utils.DISTANCE_MEDIUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
//date filters
|
||||||
|
else {
|
||||||
|
dateFilterSelection = Utils.WEEK_MILI;
|
||||||
|
}
|
||||||
|
//change colors of buttons and update visible notes
|
||||||
|
setButtonsColor();
|
||||||
|
updateShowedNotes();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//all buttons listener
|
||||||
|
public View.OnClickListener button3ClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(final View v) {
|
||||||
|
//user filters
|
||||||
|
if (userFilterIsVisible) {
|
||||||
|
userFilterSelection = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
//location filter
|
||||||
|
else if (locationFilterIsVisible) {
|
||||||
|
locationFilterSelection = Utils.DISTANCE_LONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
//date filters
|
||||||
|
else {
|
||||||
|
dateFilterSelection = Utils.MONTH_MILI;
|
||||||
|
|
||||||
|
}
|
||||||
|
//change colors of buttons and update visible notes
|
||||||
|
setButtonsColor();
|
||||||
|
updateShowedNotes();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,8 +220,8 @@ public class PersonalFragment extends Fragment {
|
||||||
|
|
||||||
//create and configure dialog
|
//create and configure dialog
|
||||||
final Dialog dialog = new Dialog(getActivity());
|
final Dialog dialog = new Dialog(getActivity());
|
||||||
|
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
dialog.setContentView(R.layout.note_view_full);
|
dialog.setContentView(R.layout.note_view_full);
|
||||||
dialog.setTitle("New Note");
|
|
||||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
||||||
lp.copyFrom(dialog.getWindow().getAttributes());
|
lp.copyFrom(dialog.getWindow().getAttributes());
|
||||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||||
|
@ -505,15 +505,6 @@ public class PersonalFragment extends Fragment {
|
||||||
public View.OnClickListener button1ClickListener = new View.OnClickListener() {
|
public View.OnClickListener button1ClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View v) {
|
public void onClick(final View v) {
|
||||||
|
|
||||||
// Log.d(TAG, "onClick: start");
|
|
||||||
// Log.d(TAG, "onClick: v id: " + v.getId());
|
|
||||||
// Log.d(TAG, "onClick: map_small_filter id: " + R.id.map_small_filter);
|
|
||||||
// Log.d(TAG, "onCreateView: personalSpace_filter_options = " + R.id.personalSpace_filter_options);
|
|
||||||
//
|
|
||||||
// Log.d(TAG, "onClick: are equal? " + (v.getId() == R.id.map_small_filter));
|
|
||||||
//
|
|
||||||
// Log.d(TAG, "onClick: case map_small_filter");
|
|
||||||
//user filters
|
//user filters
|
||||||
if (userFilterIsVisible) {
|
if (userFilterIsVisible) {
|
||||||
userFilterSelection = 1;
|
userFilterSelection = 1;
|
||||||
|
@ -531,29 +522,15 @@ public class PersonalFragment extends Fragment {
|
||||||
public View.OnClickListener button2ClickListener = new View.OnClickListener() {
|
public View.OnClickListener button2ClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View v) {
|
public void onClick(final View v) {
|
||||||
|
|
||||||
// Log.d(TAG, "onClick: start");
|
|
||||||
// Log.d(TAG, "onClick: v id: " + v.getId());
|
|
||||||
// Log.d(TAG, "onClick: map_small_filter id: " + R.id.map_small_filter);
|
|
||||||
// Log.d(TAG, "onCreateView: personalSpace_filter_options = " + R.id.personalSpace_filter_options);
|
|
||||||
//
|
|
||||||
// Log.d(TAG, "onClick: are equal? " + (v.getId() == R.id.map_small_filter));
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Log.d(TAG, "onClick: case map_medium_filter");
|
|
||||||
|
|
||||||
//user filters
|
//user filters
|
||||||
if (userFilterIsVisible) {
|
if (userFilterIsVisible) {
|
||||||
userFilterSelection = 2;
|
userFilterSelection = 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
//date filters
|
//date filters
|
||||||
else {
|
else {
|
||||||
dateFilterSelection = Utils.WEEK_MILI;
|
dateFilterSelection = Utils.WEEK_MILI;
|
||||||
|
|
||||||
}
|
}
|
||||||
setButtonsColor();
|
setButtonsColor();
|
||||||
|
|
||||||
updateShowedNotes();
|
updateShowedNotes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -563,15 +540,6 @@ public class PersonalFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View v) {
|
public void onClick(final View v) {
|
||||||
|
|
||||||
// Log.d(TAG, "onClick: start");
|
|
||||||
// Log.d(TAG, "onClick: v id: " + v.getId());
|
|
||||||
// Log.d(TAG, "onClick: map_small_filter id: " + R.id.map_small_filter);
|
|
||||||
// Log.d(TAG, "onCreateView: personalSpace_filter_options = " + R.id.personalSpace_filter_options);
|
|
||||||
//
|
|
||||||
// Log.d(TAG, "onClick: are equal? " + (v.getId() == R.id.map_small_filter));
|
|
||||||
//
|
|
||||||
// Log.d(TAG, "onClick: case map_large_filter");
|
|
||||||
|
|
||||||
//user filters
|
//user filters
|
||||||
if (userFilterIsVisible) {
|
if (userFilterIsVisible) {
|
||||||
userFilterSelection = 3;
|
userFilterSelection = 3;
|
||||||
|
@ -588,111 +556,34 @@ public class PersonalFragment extends Fragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// //all buttons listener
|
|
||||||
// public View.OnClickListener buttonClickListener = new View.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(final View v) {
|
|
||||||
//
|
|
||||||
// Log.d(TAG, "onClick: start");
|
|
||||||
// Log.d(TAG, "onClick: v id: "+ v.getId());
|
|
||||||
// Log.d(TAG, "onClick: map_small_filter id: "+ R.id.map_small_filter);
|
|
||||||
// Log.d(TAG, "onCreateView: personalSpace_filter_options = "+R.id.personalSpace_filter_options);
|
|
||||||
//
|
|
||||||
// Log.d(TAG, "onClick: are equal? "+ (v.getId() ==R.id.map_small_filter));
|
|
||||||
//
|
|
||||||
// switch (v.getId()) {
|
|
||||||
// case R.id.map_small_filter:
|
|
||||||
// Log.d(TAG, "onClick: case map_small_filter");
|
|
||||||
// //user filters
|
|
||||||
// if (userFilterIsVisible) {
|
|
||||||
// userFilterSelection = 1;
|
|
||||||
// }
|
|
||||||
// //date filters
|
|
||||||
// else {
|
|
||||||
// dateFilterSelection = 86400000L;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// updateShowedNotes();
|
|
||||||
// break;
|
|
||||||
// case R.id.map_medium_filter:
|
|
||||||
// Log.d(TAG, "onClick: case map_medium_filter");
|
|
||||||
//
|
|
||||||
// //user filters
|
|
||||||
// if (userFilterIsVisible) {
|
|
||||||
// userFilterSelection = 2;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// //date filters
|
|
||||||
// else {
|
|
||||||
// dateFilterSelection = 604800000L;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// updateShowedNotes();
|
|
||||||
// break;
|
|
||||||
// case R.id.map_large_filter:
|
|
||||||
// Log.d(TAG, "onClick: case map_large_filter");
|
|
||||||
//
|
|
||||||
// //user filters
|
|
||||||
// if (userFilterIsVisible) {
|
|
||||||
// userFilterSelection = 3;
|
|
||||||
// }
|
|
||||||
// //date filters
|
|
||||||
// else {
|
|
||||||
// dateFilterSelection = 2592000000L;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// updateShowedNotes();
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// Log.d(TAG, "onClick: in default");
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
public void updateShowedNotes() {
|
public void updateShowedNotes() {
|
||||||
presentedNotes = new ArrayList<>();
|
presentedNotes = new ArrayList<>();
|
||||||
long timeDifference;
|
long timeDifference;
|
||||||
// float distance;
|
|
||||||
// Log.d(TAG, "updateShowedNotes: start");
|
|
||||||
// Log.d(TAG, "updateShowedNotes: userPrefFilter = " + userFilterSelection);
|
|
||||||
// Log.d(TAG, "updateShowedNotes: timeDifferencePerf = " + dateFilterSelection);
|
|
||||||
// Log.d(TAG, "updateShowedNotes: +++++++++++++++++++++++++++++++++++++++++++++++++");
|
|
||||||
|
|
||||||
|
|
||||||
// Location currLocation = new Location(gpsUtils.getLocation());
|
// Location currLocation = new Location(gpsUtils.getLocation());
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|
||||||
// Location targetLocation = new Location("");//provider name is unecessary
|
// Location targetLocation = new Location("");//provider name is unecessary
|
||||||
Date targetDate;
|
Date targetDate;
|
||||||
for (Note note : listOfNotes) {
|
for (Note note : listOfNotes) {
|
||||||
// Log.d(TAG, "updateShowedNotes: checkcing note with title: " + note.title);
|
|
||||||
//get note location and date
|
//get note location and date
|
||||||
// targetLocation.setLatitude(note.getLat());//your coords of course
|
// targetLocation.setLatitude(note.getLat());//your coords of course
|
||||||
// targetLocation.setLongitude(note.getLon());
|
// targetLocation.setLongitude(note.getLon());
|
||||||
targetDate = new Date(note.getTimestamp());
|
targetDate = new Date(note.getTimestamp());
|
||||||
|
|
||||||
//get time and date differences
|
//get time and date differences
|
||||||
timeDifference = now.getTime() - targetDate.getTime();
|
timeDifference = now.getTime() - targetDate.getTime();
|
||||||
// distance = currLocation.distanceTo(targetLocation);
|
// distance = currLocation.distanceTo(targetLocation);
|
||||||
|
|
||||||
// Log.d(TAG, "updateShowedNotes: time difference = " + timeDifference);
|
|
||||||
//add to currently presented list according to filters.
|
//add to currently presented list according to filters.
|
||||||
if (timeDifference <= dateFilterSelection
|
if (timeDifference <= dateFilterSelection
|
||||||
&& ((!note.isPublic && userFilterSelection == 1) || (note.isPublic && userFilterSelection == 2) || (userFilterSelection == 3))) {
|
&& ((!note.isPublic && userFilterSelection == 1) || (note.isPublic && userFilterSelection == 2) || (userFilterSelection == 3))) {
|
||||||
presentedNotes.add(note);
|
presentedNotes.add(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log.d(TAG, "updateShowedNotes: ======================================");
|
|
||||||
}
|
}
|
||||||
// Log.d(TAG, "updateShowedNotes: presentedNotes size = " + presentedNotes.size());
|
|
||||||
|
|
||||||
noteListAdapter.updateList(presentedNotes);
|
noteListAdapter.updateList(presentedNotes);
|
||||||
noteList.setAdapter(noteListAdapter);
|
noteList.setAdapter(noteListAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//set main filter colors
|
//set secondery filter colors filter colors
|
||||||
private void setButtonsColor() {
|
private void setButtonsColor() {
|
||||||
|
|
||||||
Log.d(TAG, "setButtonsColor: start");
|
Log.d(TAG, "setButtonsColor: start");
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class SettingsFragment extends Fragment implements View.OnClickListener, TextWatcher {
|
public class SettingsFragment extends Fragment implements View.OnClickListener, TextWatcher {
|
||||||
private static final String TAG = "[TSN/Settings]" ;
|
private static final String TAG = "[TSN/Settings]";
|
||||||
private MainActivity parent;
|
private MainActivity parent;
|
||||||
private ImageButton cameraBtn;
|
private ImageButton cameraBtn;
|
||||||
private ImageView avatarImage;
|
private ImageView avatarImage;
|
||||||
|
@ -43,7 +43,7 @@ public class SettingsFragment extends Fragment implements View.OnClickListener,
|
||||||
private Uri currentImgUri;
|
private Uri currentImgUri;
|
||||||
private TextView lbl_num_of_notes, lbl_num_of_liked;
|
private TextView lbl_num_of_notes, lbl_num_of_liked;
|
||||||
private User user;
|
private User user;
|
||||||
private Button btn_save;
|
private Button btn_save;
|
||||||
|
|
||||||
|
|
||||||
public SettingsFragment() {
|
public SettingsFragment() {
|
||||||
|
@ -51,7 +51,6 @@ public class SettingsFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -62,33 +61,33 @@ public class SettingsFragment extends Fragment implements View.OnClickListener,
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_settings, container, false);
|
View view = inflater.inflate(R.layout.fragment_settings, container, false);
|
||||||
this.parent = (MainActivity)getActivity();
|
this.parent = (MainActivity) getActivity();
|
||||||
Utils.showLoadingDialog(parent, "Just a sec...", "");
|
Utils.showLoadingDialog(parent, "Just a sec...", "");
|
||||||
this.user = parent.getUser();
|
this.user = parent.getUser();
|
||||||
this.cameraBtn = (ImageButton) view.findViewById(R.id.btn_camera);
|
this.cameraBtn = (ImageButton) view.findViewById(R.id.btn_camera);
|
||||||
this.cameraBtn.setOnClickListener(this);
|
this.cameraBtn.setOnClickListener(this);
|
||||||
this.avatarImage = (ImageView) view.findViewById(R.id.settings_userAvater_iamgeView);
|
this.avatarImage = (ImageView) view.findViewById(R.id.settings_userAvater_iamgeView);
|
||||||
this.txt_email = (EditText)view.findViewById(R.id.txt_email);
|
this.txt_email = (EditText) view.findViewById(R.id.txt_email);
|
||||||
this.txt_password = (EditText)view.findViewById(R.id.txt_password);
|
this.txt_password = (EditText) view.findViewById(R.id.txt_password);
|
||||||
this.txt_username = (EditText)view.findViewById(R.id.txt_username);
|
this.txt_username = (EditText) view.findViewById(R.id.txt_username);
|
||||||
this.lbl_num_of_notes = (TextView)view.findViewById(R.id.lbl_num_of_notes);
|
this.lbl_num_of_notes = (TextView) view.findViewById(R.id.lbl_num_of_notes);
|
||||||
this.lbl_num_of_liked = (TextView)view.findViewById(R.id.lbl_num_of_liked);
|
this.lbl_num_of_liked = (TextView) view.findViewById(R.id.lbl_num_of_liked);
|
||||||
this.btn_save = (Button)view.findViewById(R.id.btn_save);
|
this.btn_save = (Button) view.findViewById(R.id.btn_save);
|
||||||
this.btn_save.setOnClickListener(this);
|
this.btn_save.setOnClickListener(this);
|
||||||
|
|
||||||
this.txt_username.setEnabled(false);
|
this.txt_username.setEnabled(false);
|
||||||
|
|
||||||
//Populate The data
|
//Populate The data
|
||||||
Utils.URLtoImageView(avatarImage, user.getAvatar());
|
Utils.URLtoImageView(avatarImage, user.getAvatar());
|
||||||
this.txt_username.setText(""+user.getUsername());
|
this.txt_username.setText("" + user.getUsername());
|
||||||
this.txt_password.setText(""+user.getPassword());
|
this.txt_password.setText("" + user.getPassword());
|
||||||
this.txt_email.setText(""+parent.getUser().getEmail());
|
this.txt_email.setText("" + parent.getUser().getEmail());
|
||||||
|
|
||||||
this.lbl_num_of_notes.setText(""+user.getNumber_of_notes()); //TODO
|
this.lbl_num_of_notes.setText("" + user.getNumber_of_notes()); //TODO
|
||||||
this.lbl_num_of_liked.setText(""+user.getLiked_notes().size());
|
this.lbl_num_of_liked.setText("" + user.getLiked_notes().size());
|
||||||
|
|
||||||
this.txt_password.addTextChangedListener(this);
|
this.txt_password.addTextChangedListener(this);
|
||||||
this.txt_email.addTextChangedListener(this);
|
this.txt_email.addTextChangedListener(this);
|
||||||
|
|
||||||
Utils.dismissLoadingDialog();
|
Utils.dismissLoadingDialog();
|
||||||
return view;
|
return view;
|
||||||
|
@ -102,121 +101,124 @@ public class SettingsFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetach() {
|
public void onDetach() {
|
||||||
super.onDetach();
|
super.onDetach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch(view.getId()){
|
switch (view.getId()) {
|
||||||
case R.id.btn_camera:
|
case R.id.btn_camera:
|
||||||
//check for permission
|
//check for permission
|
||||||
// ActivityCompat.requestPermissions(parent, new String[]{Manifest.permission.CAMERA}, 1);
|
// ActivityCompat.requestPermissions(parent, new String[]{Manifest.permission.CAMERA}, 1);
|
||||||
if ((ActivityCompat.checkSelfPermission(parent, android.Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED)
|
if ((ActivityCompat.checkSelfPermission(parent, android.Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED)
|
||||||
&&(ActivityCompat.checkSelfPermission(parent, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) {
|
&& (ActivityCompat.checkSelfPermission(parent, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) {
|
||||||
openCamera(view);
|
openCamera(view);
|
||||||
}else{
|
} else {
|
||||||
Toast.makeText(getActivity(), "No Camera or Storage Permissions granted.\n\"An App is nothing without its permissions\"", Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), "No Camera or Storage Permissions granted.\n\"An App is nothing without its permissions\"", Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case R.id.btn_save:
|
||||||
|
if (txt_password.getText().length() > 3 && txt_email.getText().length() > 0)
|
||||||
|
user.updateUser(parent);
|
||||||
|
else
|
||||||
|
Toast.makeText(parent, "Password should be more than 4 chars long, valid email", Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a new camera intent
|
||||||
|
*
|
||||||
|
* @param v
|
||||||
|
*/
|
||||||
|
protected void openCamera(View v) {
|
||||||
|
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
|
||||||
|
createDir();
|
||||||
|
Long currentImageTimeStamp = System.currentTimeMillis();
|
||||||
|
String timeStamp = Long.toString(currentImageTimeStamp);
|
||||||
|
File photo = new File(Utils.PHOTOS_DIR_PATH, timeStamp + ".jpg");
|
||||||
|
currentImgUri = Uri.fromFile(photo);
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, currentImgUri);
|
||||||
|
Log.d(TAG, "openCamera: Image URI is: " + currentImgUri);
|
||||||
|
startActivityForResult(intent, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createDir() {
|
||||||
|
File f = new File(Utils.PHOTOS_DIR_PATH);
|
||||||
|
f.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resaultCode, Intent intent) {
|
||||||
|
super.onActivityResult(requestCode, requestCode, intent);
|
||||||
|
if (resaultCode == Activity.RESULT_OK) {
|
||||||
|
if (currentImgUri != null) {
|
||||||
|
saveImage();
|
||||||
|
Log.d(TAG, "onActivityResult: Image Capured!! - Now Upload That Shit!!");
|
||||||
|
} else { //capturing failed
|
||||||
|
Toast.makeText(getActivity(), "Failed to Get Photo, Try Again", Toast.LENGTH_LONG).show();
|
||||||
|
Log.e(TAG, "onActivityResult: Image URI returned as NULL - Orientation Fail");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "onActivityResult: User Canceled Image taking");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
case R.id.btn_save:
|
|
||||||
if(txt_password.getText().length() > 3 && txt_email.getText().length() > 0) user.updateUser(parent);
|
|
||||||
else Toast.makeText(parent, "Password should be more than 4 chars long, valid email", Toast.LENGTH_LONG).show();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private void saveImage() {
|
||||||
* creates a new camera intent
|
Utils.showLoadingDialog(parent, "Saving Image...", "This Can Take a while");
|
||||||
* @param v
|
File myFile = new File(currentImgUri.getPath());
|
||||||
*/
|
|
||||||
protected void openCamera(View v) {
|
|
||||||
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
|
|
||||||
createDir();
|
|
||||||
Long currentImageTimeStamp = System.currentTimeMillis();
|
|
||||||
String timeStamp = Long.toString(currentImageTimeStamp);
|
|
||||||
File photo = new File(Utils.PHOTOS_DIR_PATH, timeStamp + ".jpg");
|
|
||||||
currentImgUri = Uri.fromFile(photo);
|
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, currentImgUri);
|
|
||||||
Log.d(TAG, "openCamera: Image URI is: " + currentImgUri);
|
|
||||||
startActivityForResult(intent, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createDir() {
|
JSONObject payload = new JSONObject();
|
||||||
File f = new File(Utils.PHOTOS_DIR_PATH);
|
|
||||||
f.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityResult(int requestCode, int resaultCode, Intent intent) {
|
|
||||||
super.onActivityResult(requestCode, requestCode, intent);
|
|
||||||
if (resaultCode == Activity.RESULT_OK) {
|
|
||||||
if (currentImgUri != null) {
|
|
||||||
saveImage();
|
|
||||||
Log.d(TAG, "onActivityResult: Image Capured!! - Now Upload That Shit!!");
|
|
||||||
} else { //capturing failed
|
|
||||||
Toast.makeText(getActivity(), "Failed to Get Photo, Try Again", Toast.LENGTH_LONG).show();
|
|
||||||
Log.e(TAG, "onActivityResult: Image URI returned as NULL - Orientation Fail");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "onActivityResult: User Canceled Image taking");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveImage() {
|
|
||||||
Utils.showLoadingDialog(parent, "Saving Image...", "This Can Take a while");
|
|
||||||
File myFile = new File(currentImgUri.getPath());
|
|
||||||
|
|
||||||
JSONObject payload = new JSONObject();
|
|
||||||
try {
|
|
||||||
payload.put("image", ImageToBase64(myFile.getAbsolutePath()));
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Utils.dismissLoadingDialog();
|
|
||||||
Toast.makeText(parent, "Failed to upload image.. Try Again", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
VolleyUtilSingleton.getInstance(parent).post(Utils.BASE_URL + Utils.UPLOAD_IMAGE_PATH, payload, new Response.Listener<JSONObject>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(JSONObject response) {
|
|
||||||
Log.d(TAG, "onResponse: "+response.toString());
|
|
||||||
try {
|
try {
|
||||||
user.setAvatar(response.getString("image_url"));
|
payload.put("image", ImageToBase64(myFile.getAbsolutePath()));
|
||||||
//Populate The data
|
|
||||||
Utils.URLtoImageView(avatarImage, user.getAvatar());
|
|
||||||
user.updateUser(parent);
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Utils.dismissLoadingDialog();
|
||||||
|
Toast.makeText(parent, "Failed to upload image.. Try Again", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
Utils.dismissLoadingDialog();
|
VolleyUtilSingleton.getInstance(parent).post(Utils.BASE_URL + Utils.UPLOAD_IMAGE_PATH, payload, new Response.Listener<JSONObject>() {
|
||||||
}
|
@Override
|
||||||
}, Utils.genericErrorListener);
|
public void onResponse(JSONObject response) {
|
||||||
}
|
Log.d(TAG, "onResponse: " + response.toString());
|
||||||
|
try {
|
||||||
|
user.setAvatar(response.getString("image_url"));
|
||||||
|
//Populate The data
|
||||||
|
Utils.URLtoImageView(avatarImage, user.getAvatar());
|
||||||
|
user.updateUser(parent);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Utils.dismissLoadingDialog();
|
||||||
|
}
|
||||||
|
}, Utils.genericErrorListener);
|
||||||
|
}
|
||||||
|
|
||||||
private String ImageToBase64(String filePath){
|
private String ImageToBase64(String filePath) {
|
||||||
Bitmap bm = BitmapFactory.decodeFile(filePath);
|
Bitmap bm = BitmapFactory.decodeFile(filePath);
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
bm.compress(Bitmap.CompressFormat.JPEG, 50, baos); //bm is the bitmap object
|
bm.compress(Bitmap.CompressFormat.JPEG, 50, baos); //bm is the bitmap object
|
||||||
byte[] b = baos.toByteArray();
|
byte[] b = baos.toByteArray();
|
||||||
Log.d(TAG, "ImageToBase64: "+b.length/1000);
|
Log.d(TAG, "ImageToBase64: " + b.length / 1000);
|
||||||
return Base64.encodeToString(b, Base64.DEFAULT);
|
return Base64.encodeToString(b, Base64.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
user.setEmail(txt_email.getText().toString());
|
user.setEmail(txt_email.getText().toString());
|
||||||
user.setPassword(txt_password.getText().toString());
|
user.setPassword(txt_password.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable editable) {
|
public void afterTextChanged(Editable editable) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class Utils {
|
||||||
private static SharedPreferences prefs;
|
private static SharedPreferences prefs;
|
||||||
public static int filterColor = Color.parseColor("#33adff");
|
public static int filterColor = Color.parseColor("#33adff");
|
||||||
public static final long DAY_MILI = 86400000L,WEEK_MILI = 604800000L,MONTH_MILI = 2592000000L;
|
public static final long DAY_MILI = 86400000L,WEEK_MILI = 604800000L,MONTH_MILI = 2592000000L;
|
||||||
|
public static final float DISTANCE_SMALL = 1000,DISTANCE_MEDIUM = 10000,DISTANCE_LONG = 100000;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
android:contextClickable="false" >
|
android:contextClickable="false" >
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:id="@+id/explore_date_filter"
|
android:id="@+id/explore_date_filter"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
android:scaleType="fitCenter" />
|
android:scaleType="fitCenter" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:id="@+id/explore_location_filter"
|
android:id="@+id/explore_location_filter"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
|
@ -42,13 +42,6 @@
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:src="@drawable/location_filter" />
|
android:src="@drawable/location_filter" />
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:layout_width="50dp"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:id="@+id/explore_user_filter"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
android:src="@drawable/users_filter" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -61,21 +54,21 @@
|
||||||
android:id="@+id/explore_filter_options" >
|
android:id="@+id/explore_filter_options" >
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 1"
|
android:text="filter 1"
|
||||||
android:id="@+id/explore_small_filter"
|
android:id="@+id/explore_small_filter"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 2"
|
android:text="filter 2"
|
||||||
android:id="@+id/explore_medium_filter"
|
android:id="@+id/explore_medium_filter"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 3"
|
android:text="filter 3"
|
||||||
android:id="@+id/explore_large_filter"
|
android:id="@+id/explore_large_filter"
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
android:contextClickable="false">
|
android:contextClickable="false">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:id="@+id/map_date_filter"
|
android:id="@+id/map_date_filter"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
android:scaleType="fitCenter" />
|
android:scaleType="fitCenter" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:id="@+id/map_location_filter"
|
android:id="@+id/map_location_filter"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
android:src="@drawable/location_filter" />
|
android:src="@drawable/location_filter" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:id="@+id/map_user_filter"
|
android:id="@+id/map_user_filter"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -62,21 +62,21 @@
|
||||||
android:id="@+id/map_filter_options">
|
android:id="@+id/map_filter_options">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 1"
|
android:text="filter 1"
|
||||||
android:id="@+id/map_small_filter"
|
android:id="@+id/map_small_filter"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 2"
|
android:text="filter 2"
|
||||||
android:id="@+id/map_medium_filter"
|
android:id="@+id/map_medium_filter"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 3"
|
android:text="filter 3"
|
||||||
android:id="@+id/map_large_filter"
|
android:id="@+id/map_large_filter"
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
android:contextClickable="false" >
|
android:contextClickable="false" >
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:id="@+id/personalSpace_date_filter"
|
android:id="@+id/personalSpace_date_filter"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
android:focusable="false" />
|
android:focusable="false" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:id="@+id/personalSpace_premission_filter"
|
android:id="@+id/personalSpace_premission_filter"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -60,21 +60,21 @@
|
||||||
android:focusableInTouchMode="false">
|
android:focusableInTouchMode="false">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 1"
|
android:text="filter 1"
|
||||||
android:id="@+id/personalSpace_small_filter"
|
android:id="@+id/personalSpace_small_filter"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 2"
|
android:text="filter 2"
|
||||||
android:id="@+id/personalSpace_medium_filter"
|
android:id="@+id/personalSpace_medium_filter"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="50dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="filter 3"
|
android:text="filter 3"
|
||||||
android:id="@+id/personalSpace_large_filter"
|
android:id="@+id/personalSpace_large_filter"
|
||||||
|
|
Loading…
Reference in a new issue