From 1009fe2467cc9874f556e29e3b778aba6de39448 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 10 Jul 2016 15:35:41 +0300 Subject: [PATCH 1/5] Black like button + less threads --- .../matan/ara/sagi/thesocialnotework/Utils.java | 6 +++++- app/src/main/res/drawable/like_icon_black.png | Bin 0 -> 7522 bytes app/src/main/res/layout/note_display_full.xml | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/like_icon_black.png diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java index e580c68..573b616 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java @@ -147,7 +147,11 @@ public class Utils { } public static void URLtoImageView(ImageView iv, String url){ - new setUserAvatar(iv, url).execute(); + if(bitmapHash.containsKey(url)){ + iv.setImageBitmap(bitmapHash.get(url)); + }else{ + new setUserAvatar(iv, url).execute(); + } } private static class setUserAvatar extends AsyncTask { diff --git a/app/src/main/res/drawable/like_icon_black.png b/app/src/main/res/drawable/like_icon_black.png new file mode 100644 index 0000000000000000000000000000000000000000..3b97bfa664db00a1ac91d5acd9e04a89ce54c339 GIT binary patch literal 7522 zcmb6;c{J4T*Ux7R#y(2+GEtGr5=Dg>*(yoX@>R*MC|R;Im=8*_w}()aXhEgy46;gILPaL*vyER!OJfw zzu!H3>@fhclZOrUPx*KL=?-{!Zzy1CnzHwyUBr*kzeb4W%}~(+v|>yEDwu@cb+pnh-)lY6VUJq zp)P3{abHLrdbGF}#4=U6*QYl*tJAxfqTw{NJMkz0zizu@0Ra+*0DuF41Y3|dJOC(c zVZr|~_5WP{A0+>Qj$*er469BQNStSEz!01^zV& zL-mzCy*9bWAq?SV*#m>TE0a5gNdOJ+d2|iI0gsO4Y$eVd<(&jK0nkF5Qmy6mAuqB^ z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U)LY&?zLOHC?y;WNZiRhKdrU4 z5GKGg)U?n0`->P;gw{=^9&jA`{3<1M5hf|8%r_$pd#ITJmC-{O>3{1QZgW^PnhRi2 z9H8~608X}349R;A6R#di0zg6tX7)q@s(T*JU`YBfxhu|rBmq>m0X&cgH0xNHzwL_$ z9#;_pz$0McA_8F64MC%Y07AeR0<`Q5L|6?ovP%$kBmm=OFfj~sv=;w8tc3hK{063Y z`EA{eIPgtC;hBGjDck?1phaK`8b!uaFt8@Xf;nsrbnOISr1Ovf0RzTw!4Yk=j0_kD zdGi$c!TBk$aPVI`82!9?Y?va)fYnVHnmy!?v%v=k1h{CMZh$a^Jh{zaw7|%z4-uwf zQEr^=q&_$k2^M5whtD<_b{>KSNd)EQpUPQ{Dl_`KlMe%GgteKX;0z5d<3iBuf*l%o zaHg4be{%f-KZ4c>6&@x5+b3KLFxnK?Nr()lS;NA^5~9T^R$$RR=C|QBP~wiek#p{z zx{$}z03Xy?R46NA;1RJam( zbyx?XwQveIfP{l}l()Ct5nBU{ix7Msv~X%Sa2S?l5O5HdQnrLI0$YXfotCO?g0O;e z3E(ck_oJT{tfiQPDMPpd9zTZB%!{CSPPqnny5AAw(q7UBjBLR95U{jL5e(Yu`pO>M zfM%<+;qNl|`JcUyoLUng@OX?um!pny$zj3M0W~~UI2e|sexZ^c3^;Diiw)(>XgeDI z`;EkgR&Rp+S3280I^Y7{t{#yO`8A;ia4=7V*FJ|kj0-l^KJxw!tqnJj#e#%y{^0fw z)jQMWTVO;Kr0~}wU}=E_ptf_00RV+9EC2-ff%^2nO#MHX{|C~4pl_*Xb9vv5R#xvS RcmeT&!$!vpa}L^u{TB-2x3K^K literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/note_display_full.xml b/app/src/main/res/layout/note_display_full.xml index 5b33b2a..ac519e3 100644 --- a/app/src/main/res/layout/note_display_full.xml +++ b/app/src/main/res/layout/note_display_full.xml @@ -141,8 +141,9 @@ android:layout_width="20dp" android:layout_height="20dp" android:id="@+id/imageView9" - android:src="@drawable/like_icon" - android:layout_gravity="center_vertical" /> + android:layout_gravity="center_vertical" + android:background="@drawable/like_icon_black" + android:backgroundTintMode="multiply" /> Date: Sun, 10 Jul 2016 16:14:35 +0300 Subject: [PATCH 2/5] - likes on explore implemented - likes on explore update the list as well --- .../thesocialnotework/ExploreFragment.java | 86 +++++++++---------- .../sagi/thesocialnotework/GmapFragment.java | 13 +-- .../ara/sagi/thesocialnotework/Utils.java | 12 ++- 3 files changed, 48 insertions(+), 63 deletions(-) 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 5a7bd99..ce8f689 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 @@ -43,6 +43,7 @@ import java.util.ListIterator; public class ExploreFragment extends Fragment { private static final String TAG = "[TSN/Explore]"; +// protected final User user = ((MainActivity) getActivity()).getUser(); protected User user; protected MainActivity parent; private ListAdapter noteListAdapter; @@ -76,7 +77,14 @@ public class ExploreFragment extends Fragment { public ExploreFragment() { // Required empty public constructor } + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + parent = (MainActivity) getActivity(); + gpsUtils = parent.getGPSUtils(); + user = parent.getUser(); + } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -84,9 +92,7 @@ public class ExploreFragment extends Fragment { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_explore, container, false); - parent = (MainActivity) getActivity(); - gpsUtils = parent.getGPSUtils(); - user = parent.getUser(); + notes = new ArrayList<>(); //Get Views list_notes = (ListView) view.findViewById(R.id.list_notes); @@ -205,6 +211,7 @@ public class ExploreFragment extends Fragment { public void onItemClick(AdapterView parent, View view, final int position, long id) { //create and configure dialog final Note note = notes.get(position); + final MainActivity localParent = (MainActivity)getActivity(); final Dialog noteViewDialog = new Dialog(getActivity()); noteViewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); noteViewDialog.setContentView(R.layout.note_display_full); @@ -235,57 +242,42 @@ public class ExploreFragment extends Fragment { 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")); + + if (likes != null) { + likeBtn.setBackgroundResource(R.drawable.like_icon); + if (localParent.getUser().getLiked_notes().contains(note.getId())) { + likeBtn.setBackgroundResource(R.drawable.like_icon); + } else { + likeBtn.setBackgroundResource(R.drawable.unlike_icon); + } + } + likes.setText("" + note.getLikes()); + 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(); -// } -// }); + //add like only if user didnt like already + if (!user.getLiked_notes().contains(note.getId())) { + JSONObject jsonObj = new JSONObject(); + try { + jsonObj.put("uid", localParent.getUserId()); + jsonObj.put("nid", note.getId()); + } catch (JSONException e) { + e.printStackTrace(); + } + VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/like", jsonObj, Utils.genericSuccessListener, Utils.genericErrorListener); + user.getLiked_notes().add(note.getId()); + user.updateUser(localParent); + note.setLikes(note.getLikes()+1); + likes.setText("" + note.getLikes()); + noteListAdapter.updateList(notes); + list_notes.setAdapter(noteListAdapter); + likeBtn.setBackgroundResource(R.drawable.like_icon); + } } }); } 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 b216eb2..ee45c08 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 @@ -338,7 +338,6 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { permissionImg.setVisibility(View.INVISIBLE); permission.setText(""); deleteBtn.setBackgroundResource(R.drawable.unlike_icon); - int filterColor; if (mainActivity.getUser().getLiked_notes().contains(note.getId())) { deleteBtn.setBackgroundResource(R.drawable.like_icon); } else { @@ -404,7 +403,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { } catch (JSONException e) { e.printStackTrace(); } - VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/like", jsonObj, likeNotesSuccessListener, Utils.genericErrorListener); + VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/like", jsonObj, Utils.genericSuccessListener, Utils.genericErrorListener); mainActivity.getUser().getLiked_notes().add(note.getId()); mainActivity.getUser().updateUser(mainActivity); note.setLikes(note.getLikes()+1); @@ -450,16 +449,6 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { } }; - //response listener for getting all user notes - Response.Listener likeNotesSuccessListener = new Response.Listener() { - @Override - public void onResponse(JSONObject response) { - Log.d(TAG, "likeNotesSuccessListener: " + response.toString()); - } - }; - - - private class getMarkersFromNotes extends AsyncTask, MarkerNoteStruct, Void> { GoogleMap mMap; HashMap eventMarkerMap; diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java index 8b2de97..5b6f234 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Utils.java @@ -96,6 +96,14 @@ public class Utils { } }; + //response listener for getting all user notes + public static Response.Listener genericSuccessListener = new Response.Listener() { + @Override + public void onResponse(JSONObject response) { + Log.d(TAG, "likeNotesSuccessListener: " + response.toString()); + } + }; + public static void showLoadingDialog(Context context, String title, String msg) { progress = new ProgressDialog(context); progress.setTitle(title); @@ -240,8 +248,4 @@ public class Utils { editor.remove("UserData"); editor.commit(); } - - - - } From d24176ec4717221d4a4cea7aff515ac4d328f45f Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 10 Jul 2016 17:04:57 +0300 Subject: [PATCH 3/5] Smaller Images --- .../thesocialnotework/SettingsFragment.java | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java index 784695a..cdb554c 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java @@ -33,6 +33,7 @@ import org.json.JSONObject; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileOutputStream; public class SettingsFragment extends Fragment implements View.OnClickListener, TextWatcher { private static final String TAG = "[TSN/Settings]"; @@ -170,11 +171,48 @@ public class SettingsFragment extends Fragment implements View.OnClickListener, private void saveImage() { Utils.showLoadingDialog(parent, "Saving Image...", "This Can Take a while"); - File myFile = new File(currentImgUri.getPath()); + + Bitmap b= BitmapFactory.decodeFile(currentImgUri.getPath()); // Original Image + Bitmap out; + if (b.getWidth() >= b.getHeight()){ + + out = Bitmap.createBitmap( + b, + b.getWidth()/2 - b.getHeight()/2, + 0, + b.getHeight(), + b.getHeight() + ); + + }else{ + out = Bitmap.createBitmap( + b, + 0, + b.getHeight()/2 - b.getWidth()/2, + b.getWidth(), + b.getWidth() + ); + } +// Bitmap out = Bitmap.createBitmap(b, 0,0,320, 320); + out = Bitmap.createScaledBitmap(out, 320, 320, false); + + File file = new File(currentImgUri.getPath()); + FileOutputStream fOut; + try { + fOut = new FileOutputStream(file); + out.compress(Bitmap.CompressFormat.PNG, 100, fOut); + fOut.flush(); + fOut.close(); + b.recycle(); + out.recycle(); + } catch (Exception e) {} + + + JSONObject payload = new JSONObject(); try { - payload.put("image", ImageToBase64(myFile.getAbsolutePath())); + payload.put("image", ImageToBase64(file.getAbsolutePath())); } catch (JSONException e) { e.printStackTrace(); Utils.dismissLoadingDialog(); From 990be679f7243fde678ed3ee30e190f87048ae57 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 10 Jul 2016 17:09:04 +0300 Subject: [PATCH 4/5] Clean --- .../matan/ara/sagi/thesocialnotework/SettingsFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java index cdb554c..cd0d235 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/SettingsFragment.java @@ -193,7 +193,6 @@ public class SettingsFragment extends Fragment implements View.OnClickListener, b.getWidth() ); } -// Bitmap out = Bitmap.createBitmap(b, 0,0,320, 320); out = Bitmap.createScaledBitmap(out, 320, 320, false); File file = new File(currentImgUri.getPath()); From 2ab96a1cfa732ef028e0bd88c8e5402a1c812cb9 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 10 Jul 2016 17:11:07 +0300 Subject: [PATCH 5/5] - string consts added - personal space filter 24 hours fixed - added documentation --- .../thesocialnotework/ExploreFragment.java | 30 ++------ .../sagi/thesocialnotework/GmapFragment.java | 42 +++------- .../sagi/thesocialnotework/LoginActivity.java | 77 ++++--------------- .../thesocialnotework/PersonalFragment.java | 44 ++--------- .../thesocialnotework/RegisterActivity.java | 46 +++++------ app/src/main/res/values/strings.xml | 15 ++++ 6 files changed, 70 insertions(+), 184 deletions(-) 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 ce8f689..d592c0d 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 @@ -1,12 +1,9 @@ package com.android_app.matan.ara.sagi.thesocialnotework; -import android.app.AlertDialog; import android.app.Dialog; -import android.content.DialogInterface; import android.location.Location; import android.os.Bundle; -import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; @@ -21,7 +18,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; -import android.widget.Toast; import com.android.volley.Response; @@ -30,11 +26,8 @@ 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; /** @@ -62,17 +55,6 @@ public class ExploreFragment extends Fragment { private Long dateFilterSelection; private float locationFilterSelection; private GPSUtils gpsUtils; -// private boolean userFilterIsVisible = false; - - private final String day = "24 hours"; - private final String week = "Week"; - private final String month = "Month"; - private final String hundredMeters = "1 K"; - private final String kilometer = "10 Km"; - private final String threeKilometer = "100 Km"; -// private final String mine = "Mine"; -// private final String others = "Others"; -// private final String all = "All"; public ExploreFragment() { // Required empty public constructor @@ -129,9 +111,9 @@ public class ExploreFragment extends Fragment { // 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); + map_small_filter.setText(R.string.day); + map_medium_filter.setText(R.string.week); + map_large_filter.setText(R.string.month); } setButtonsColor(); } @@ -150,9 +132,9 @@ public class ExploreFragment extends Fragment { // 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); + map_small_filter.setText(R.string.shortDistance); + map_medium_filter.setText(R.string.mediumDistance); + map_large_filter.setText(R.string.longDistance); } setButtonsColor(); } 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 ee45c08..7e6ea91 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java @@ -4,15 +4,9 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; import android.location.Location; -import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; //import android.app.Fragment; @@ -23,7 +17,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; -import android.view.WindowManager; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; @@ -34,7 +27,6 @@ import android.widget.Toast; import com.android.volley.Response; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.BitmapDescriptor; @@ -50,15 +42,10 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Timer; public class GmapFragment extends Fragment implements OnMapReadyCallback { @@ -88,17 +75,6 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { List listOfNotes; private Circle onMapCircle; - private final String day = "24 hours"; - private final String week = "Week"; - private final String month = "Month"; - private final String hundredMeters = "1 Km"; - private final String kilometer = "10 Km"; - private final String tenKilometers = "100 Km"; - private final String mine = "Mine"; - private final String others = "Others"; - private final String all = "All"; - - public GmapFragment() { eventMarkerMap = new HashMap(); dateFilterSelection = Utils.MONTH_MILI; @@ -171,9 +147,9 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { 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); + map_small_filter.setText(R.string.day); + map_medium_filter.setText(R.string.week); + map_large_filter.setText(R.string.month); } setButtonsColor(); } @@ -192,9 +168,9 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { userFilterIsVisible = false; // set text button in the right filter string - map_small_filter.setText(hundredMeters); - map_medium_filter.setText(kilometer); - map_large_filter.setText(tenKilometers); + map_small_filter.setText(R.string.shortDistance); + map_medium_filter.setText(R.string.mediumDistance); + map_large_filter.setText(R.string.longDistance); } setButtonsColor(); } @@ -213,9 +189,9 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { 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); + map_small_filter.setText(R.string.mine); + map_medium_filter.setText(R.string.others); + map_large_filter.setText(R.string.all); } setButtonsColor(); } diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java index 01b8bd9..243924c 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java @@ -31,7 +31,6 @@ import java.util.Vector; */ public class LoginActivity extends AppCompatActivity implements View.OnClickListener, TextWatcher { - // UI references. private EditText mUsernameView; private EditText mPasswordView; @@ -66,26 +65,20 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList } - private void removeFocuse() { - // Remove Auto Focus from the Text Fields + private void removeFocuse() { // Remove Auto Focus from the Text Fields mUsernameView.clearFocus(); mPasswordView.clearFocus(); layout.setFocusable(true); layout.setFocusableInTouchMode(true); - } - /** * Attempts to sign in or register the account specified by the login form. * If there are form errors (invalid email, missing fields, etc.), the * errors are presented and no actual login attempt is made. */ - private boolean isParamsValid(String username, String password) { - Log.d(TAG, "user: " + username); - Log.d(TAG, "pwd: " + password); - + private boolean isParamsValid(String username, String password) { // validate form if (TextUtils.isEmpty(username) || !isUsernameValid(username) || TextUtils.isEmpty(password) || !isPasswordValid(password)) { return false; } else { @@ -93,7 +86,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList } } - private void attemptLogin() { + private void attemptLogin() { // attempt login Utils.showLoadingDialog(this, "Connecting", "Authenticating data"); mPasswordView.setError(null); if (isParamsValid(mUsernameView.getText().toString(), mPasswordView.getText().toString())) { @@ -101,7 +94,6 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList String username = mUsernameView.getText().toString(); String password = mPasswordView.getText().toString(); - boolean cancel = false; // http request register JSONObject tempJson = new JSONObject(); try { @@ -112,18 +104,16 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList } VolleyUtilSingleton.getInstance(LoginActivity.this).post(Utils.BASE_URL + LOGIN_PATH, tempJson, onLoginSuccess, onLoginError); } else { - Utils.dismissLoadingDialog(); - Log.d(TAG, "Invalid params - make sure username exist & password is 4 characters or more"); + Utils.dismissLoadingDialog(); // invalid params } } Response.Listener onLoginSuccess = new Response.Listener() { @Override - public void onResponse(JSONObject response) { + public void onResponse(JSONObject response) { // listener to success login response from server try { - if (!response.isNull("user")) { - Log.e(TAG, "onLoginSuccess => user exist"); // TODO: REMOVE console + if (!response.isNull("user")) { // response user from server success String id, password, email, avatar, username, likedNotes = ""; JSONArray likedNotes_JSON; @@ -146,7 +136,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList personalSpaceActivity.putExtras(loginUserBundle); Utils.dismissLoadingDialog(); startActivity(personalSpaceActivity); - } else { + } else { // invalid params Utils.dismissLoadingDialog(); Toast.makeText(self, "Username or Password are incorrect", Toast.LENGTH_LONG).show(); self.mUsernameView.getText().clear(); @@ -164,38 +154,34 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList Response.ErrorListener onLoginError = new Response.ErrorListener() { @Override - public void onErrorResponse(VolleyError error) { + public void onErrorResponse(VolleyError error) { // listener to error login response from server Utils.dismissLoadingDialog(); Toast.makeText(self, "Username Or Password Incorrect", Toast.LENGTH_LONG).show(); - //Clean texts + // Clean texts self.mUsernameView.getText().clear(); self.mPasswordView.getText().clear(); self.removeFocuse(); - Log.d(TAG, "onErrorResponse: setting text to ''"); - Log.d(TAG, "onLoginError: msg: " + error.getMessage()); } }; private boolean isUsernameValid(String username) { return username.length() > 0; - } + } // validate username private boolean isPasswordValid(String password) { return password.length() > 3; - } + } // validate password @Override public void onClick(View view) { switch (view.getId()) { case R.id.al_login_button: - //Do Login - Log.d(TAG, "Login......."); + // Do Login attemptLogin(); break; case R.id.al_register_button: - //Do Register - Log.d(TAG, "going to Register...page"); + // Do Register Intent registerActivity = new Intent(LoginActivity.this, RegisterActivity.class); startActivity(registerActivity); break; @@ -222,42 +208,5 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList public void afterTextChanged(Editable editable) { } -// @Override -// public void onRequestPermissionsResult(int requestCode, -// String permissions[], int[] grantResults) { -// permissionsReturend = true; -// Log.d(TAG, "onRequestPermissionsResult: in func"); -// switch (requestCode) { -// case FINE_PERM: { -// // If request is cancelled, the result arrays are empty. -// if (grantResults.length > 0 -// && grantResults[0] == PackageManager.PERMISSION_GRANTED) { -// Log.d(TAG, "onRequestPermissionsResult: got permission for location"); -// Utils.setLocationPermission(true); -// ActivityCompat.requestPermissions(LoginActivity.this, new String[]{android.Manifest.permission.CAMERA}, CAMERA_PERM); -// } else { -// Log.d(TAG, "onRequestPermissionsResult:DIDNT get permission for location"); -// -// Toast.makeText(LoginActivity.this,"No Location Permissions granted.\n\"An App is nothing without its permissions\"",Toast.LENGTH_LONG); -//// System.exit(0); -// } -// return; -// } -// case CAMERA_PERM: { -// if (grantResults.length > 0 -// && grantResults[0] == PackageManager.PERMISSION_GRANTED) { -// Log.d(TAG, "onRequestPermissionsResult: got permission for camera"); -// Utils.setCameraPermission(true); -// -// -// } else { -// Log.d(TAG, "onRequestPermissionsResult: DIDNT get permission for camera"); -// Toast.makeText(LoginActivity.this,"No Camera Permissions granted.\n\"An App is nothing without its permissions\"",Toast.LENGTH_LONG); -// } -// return; -// } -// } -// } - } 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 337ab91..520f622 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 @@ -77,20 +77,13 @@ public class PersonalFragment extends Fragment { private boolean dateFilterIsVisible = false; private boolean userFilterIsVisible = false; - private final String day = "24 hours"; - private final String week = "Week"; - private final String month = "Month"; - private final String privateNote = "Private"; - private final String publicNote = "Public"; - private final String privateAndPublic = "All"; - public PersonalFragment() { // Required empty public constructor } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_personal, container, false); // Inflate the layout for this fragment activity = (MainActivity) getActivity(); @@ -150,9 +143,9 @@ public class PersonalFragment extends Fragment { 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); + map_small_filter.setText(R.string.day); + map_medium_filter.setText(R.string.week); + map_large_filter.setText(R.string.month); } setButtonsColor(); @@ -173,9 +166,9 @@ public class PersonalFragment extends Fragment { dateFilterIsVisible = false; // set text button in the right filter string - map_small_filter.setText(privateNote); - map_medium_filter.setText(publicNote); - map_large_filter.setText(privateAndPublic); + map_small_filter.setText(R.string.privateNote); + map_medium_filter.setText(R.string.publicNote); + map_large_filter.setText(R.string.privateAndPublic); } setButtonsColor(); @@ -358,27 +351,6 @@ public class PersonalFragment extends Fragment { } }; - -// //response ErrorListener for getting all user notes -// Response.ErrorListener getNotesErrorListener = new Response.ErrorListener() { -// @Override -// public void onErrorResponse(VolleyError error) { -// Log.d(TAG, "getNotesErrorListener: " + error.getMessage()); -// MainActivity.dismissLoadingDialog(); -// } -// }; - -// //Generic response ErrorListener -// Response.ErrorListener genericErrorListener = new Response.ErrorListener() { -// @Override -// public void onErrorResponse(VolleyError error) { -// Log.d(TAG, "genericErrorListener"); -// MainActivity.dismissLoadingDialog(); -// error.printStackTrace(); -// } -// }; - - private ArrayList jsonArrayToStringArray(JSONArray jArray) { ArrayList stringArray = new ArrayList(); for (int i = 0, count = jArray.length(); i < count; i++) { @@ -511,7 +483,7 @@ public class PersonalFragment extends Fragment { } //date filters else { - dateFilterSelection = Utils.WEEK_MILI; + dateFilterSelection = Utils.DAY_MILI; } setButtonsColor(); diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/RegisterActivity.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/RegisterActivity.java index 4bc5da7..0d0bd26 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/RegisterActivity.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/RegisterActivity.java @@ -40,9 +40,9 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); - this.mUsernameView = (EditText) findViewById(R.id.ra_username); - this.mPasswordView = (EditText) findViewById(R.id.ra_password); - this.mEmailView = (EditText) findViewById(R.id.ra_email); + this.mUsernameView = (EditText) findViewById(R.id.ra_username); // holds the username + this.mPasswordView = (EditText) findViewById(R.id.ra_password); // holds the password + this.mEmailView = (EditText) findViewById(R.id.ra_email); // holds the email this.self = this; this.layout = (RelativeLayout) findViewById(R.id.ra_layout); @@ -50,23 +50,23 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL // Remove Auto Focus from the Text Fields this.layout.setFocusable(true); this.layout.setFocusableInTouchMode(true); + // Buttons And Listeners this.testBtn = (Button) findViewById(R.id.btn_cancel); this.testBtn.setOnClickListener(this); this.registerButton = (Button) findViewById(R.id.ra_register_button); this.registerButton.setOnClickListener(this); - } - private boolean isUsernameValid(String username) { + private boolean isUsernameValid(String username) { // username validation return !TextUtils.isEmpty(username) && username.length() > 0; } - private boolean isPasswordValid(String password) { + private boolean isPasswordValid(String password) { // password validation return !TextUtils.isEmpty(password) && password.length() > 3; } - private boolean isEmailValid(String email) { + private boolean isEmailValid(String email) { // email validation if (TextUtils.isEmpty(email)) return false; String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"; @@ -75,52 +75,45 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL return matcher.matches(); } - private boolean isParamsValid(String username, String password, String email) { + private boolean isParamsValid(String username, String password, String email) { // private method that validates all params return (isUsernameValid(username) && isPasswordValid(password) && isEmailValid(email)); } - private void attemptRegister() { + private void attemptRegister() { // attempt registering Utils.showLoadingDialog(this, "Registering", "Please Wait..."); - Log.d(TAG, "in attemptRegister: Registering.."); - if (isParamsValid(mUsernameView.getText().toString(), mPasswordView.getText().toString(), mEmailView.getText().toString())) { - Log.d(TAG, "params are valid"); + if (isParamsValid(mUsernameView.getText().toString(), mPasswordView.getText().toString(), mEmailView.getText().toString())) { // params are valid String username = mUsernameView.getText().toString(); String password = mPasswordView.getText().toString(); String email = mEmailView.getText().toString(); // http request register JSONObject tempJson = new JSONObject(); - try { + try { // creating a user json to send the server tempJson.put("username", username); tempJson.put("password", password); tempJson.put("email", email); } catch (Exception e) { Log.d(TAG, e.toString()); } - Log.d(TAG, "JSON: " + tempJson.toString()); - VolleyUtilSingleton.getInstance(RegisterActivity.this).post(BASE_URL + REG_PATH, tempJson, onRegisterSuccess, onRegisterError); - } else { + VolleyUtilSingleton.getInstance(RegisterActivity.this).post(BASE_URL + REG_PATH, tempJson, onRegisterSuccess, onRegisterError); // register request to server + } else { // invalid params Utils.dismissLoadingDialog(); - Log.d(TAG, "Invalid params - make sure username exist, password is 4 characters or more & email is valid"); Toast.makeText(this, "Make Sure tou have entered a valid email. password at least 4 chars", Toast.LENGTH_LONG).show(); } } Response.Listener onRegisterSuccess = new Response.Listener() { @Override - public void onResponse(JSONObject response) { - Log.d(TAG, "response: " + response.toString()); + public void onResponse(JSONObject response) { // listener to success response on register from server Utils.dismissLoadingDialog(); try { - if (response.getString("message").equals("created")) { - Log.d(TAG, "onRegisterSuccess => user created"); // TODO: REMOVE console + if (response.getString("message").equals("created")) { // user created Intent loginActivity = new Intent(RegisterActivity.this, LoginActivity.class); Toast.makeText(self, "You are now a social notework member - You May Login...", Toast.LENGTH_LONG).show(); startActivity(loginActivity); } else { Toast.makeText(self, "Username is already taken. maybe: " + mUsernameView.getText().toString() + "_666 ? :)", Toast.LENGTH_LONG).show(); - Log.d(TAG, "Cannot create user, " + response.getString("message")); } - } catch (Exception e) { + } catch (Exception e) { // error on register user request Log.e(TAG, "onRegisterSuccess:" + e.getMessage()); } @@ -129,15 +122,14 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL Response.ErrorListener onRegisterError = new Response.ErrorListener() { @Override - public void onErrorResponse(VolleyError error) { + public void onErrorResponse(VolleyError error) { // listener to error response on register from server Utils.dismissLoadingDialog(); Toast.makeText(self, "Username is already taken. maybe: " + mUsernameView.getText().toString() + "_666 ? :)", Toast.LENGTH_LONG).show(); - Log.d(TAG, "onRegisterError: msg: " + error.getMessage()); } }; @Override - public void onClick(View view) { + public void onClick(View view) { // onclick methods to redirect to register and to login switch (view.getId()) { case R.id.ra_register_button: attemptRegister(); @@ -148,7 +140,7 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL } } - private void returnToLogin() { + private void returnToLogin() { // redirect to login Intent i = new Intent(RegisterActivity.this, LoginActivity.class); startActivity(i); finish(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e9d4c01..0b92b18 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -40,4 +40,19 @@ Map Avatar + + + 24 hours + Week + Month + Private + Public + All + 1 Km + 10 Km + 100 Km + Mine + Others + All +