diff --git a/.idea/libraries/android_android_23.xml b/.idea/libraries/android_android_23.xml new file mode 100644 index 0000000..a279d4a --- /dev/null +++ b/.idea/libraries/android_android_23.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/animated_vector_drawable_23_3_0.xml b/.idea/libraries/animated_vector_drawable_23_3_0.xml index c887d48..4ba521e 100644 --- a/.idea/libraries/animated_vector_drawable_23_3_0.xml +++ b/.idea/libraries/animated_vector_drawable_23_3_0.xml @@ -1,13 +1,13 @@ - + - + diff --git a/.idea/libraries/appcompat_v7_23_3_0.xml b/.idea/libraries/appcompat_v7_23_3_0.xml index 39b4f84..de5aaeb 100644 --- a/.idea/libraries/appcompat_v7_23_3_0.xml +++ b/.idea/libraries/appcompat_v7_23_3_0.xml @@ -4,13 +4,13 @@ - + - + diff --git a/.idea/libraries/design_23_3_0.xml b/.idea/libraries/design_23_3_0.xml index 6172f7d..1120123 100644 --- a/.idea/libraries/design_23_3_0.xml +++ b/.idea/libraries/design_23_3_0.xml @@ -4,13 +4,13 @@ - + - + diff --git a/.idea/libraries/recyclerview_v7_23_3_0.xml b/.idea/libraries/recyclerview_v7_23_3_0.xml index 7b42040..36865de 100644 --- a/.idea/libraries/recyclerview_v7_23_3_0.xml +++ b/.idea/libraries/recyclerview_v7_23_3_0.xml @@ -9,8 +9,8 @@ - + diff --git a/.idea/libraries/support_annotations_23_3_0.xml b/.idea/libraries/support_annotations_23_3_0.xml index f9004af..118a0e7 100644 --- a/.idea/libraries/support_annotations_23_3_0.xml +++ b/.idea/libraries/support_annotations_23_3_0.xml @@ -1,12 +1,12 @@ - + - + diff --git a/.idea/libraries/support_v4_23_3_0.xml b/.idea/libraries/support_v4_23_3_0.xml index 68eb591..62a2f14 100644 --- a/.idea/libraries/support_v4_23_3_0.xml +++ b/.idea/libraries/support_v4_23_3_0.xml @@ -10,8 +10,8 @@ - + diff --git a/.idea/libraries/support_vector_drawable_23_3_0.xml b/.idea/libraries/support_vector_drawable_23_3_0.xml index 55e107d..b4ad228 100644 --- a/.idea/libraries/support_vector_drawable_23_3_0.xml +++ b/.idea/libraries/support_vector_drawable_23_3_0.xml @@ -6,8 +6,8 @@ - + diff --git a/.idea/libraries/volley_1_0_0.xml b/.idea/libraries/volley_1_0_0.xml index 8e317b7..81a83dd 100644 --- a/.idea/libraries/volley_1_0_0.xml +++ b/.idea/libraries/volley_1_0_0.xml @@ -1,8 +1,8 @@ - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c3c5da3..5c53de7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ + diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GPSUtils.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GPSUtils.java index 7c23d52..0caf2a6 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GPSUtils.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GPSUtils.java @@ -42,6 +42,8 @@ public class GPSUtils extends Service implements LocationListener { Location location; // location double latitude; // latitude double longitude; // longitude + Geocoder geocoder; + protected LocationManager locationManager; @@ -188,9 +190,9 @@ public class GPSUtils extends Service implements LocationListener { public List
getFromLocation(double latitude, double longitude, int maxResults){ try { - Geocoder geocoder; List
addresses; - geocoder = new Geocoder(this); + + geocoder = new Geocoder(mContext); if (latitude != 0 || longitude != 0) { addresses = geocoder.getFromLocation(latitude , longitude, maxResults); @@ -202,6 +204,7 @@ public class GPSUtils extends Service implements LocationListener { return null; } } catch (Exception e) { + Log.d(TAG, "in gettFromLocation"); e.printStackTrace(); return null; } diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalSpaceActivity.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalSpaceActivity.java index 6dc8c95..f76baa5 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalSpaceActivity.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalSpaceActivity.java @@ -63,12 +63,12 @@ public class PersonalSpaceActivity extends AppCompatActivity { //check for permission ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, FINE_PERM); - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.INTERNET}, FINE_PERM); this.noteList = (ListView) findViewById(R.id.ps_list_listview); addBtn = (Button) findViewById(R.id.ps_new_note_button); gpsUtils = new GPSUtils(this); + gpsUtils.getLocation(); listOfNotes = new ArrayList<>(); @@ -77,8 +77,8 @@ public class PersonalSpaceActivity extends AppCompatActivity { noteListAdapter = new ListAdapter(this, listOfNotes); noteList.setAdapter(noteListAdapter); - new HeavyWorker(this).execute(); - +// new HeavyWorker(this).execute(); + getAllNotes(); //https://thesocialnotework-api.appspot.com/api/note/all?uid= addBtn.setOnClickListener(addNewNoteDialog); @@ -88,6 +88,7 @@ public class PersonalSpaceActivity extends AppCompatActivity { } public void getAllNotes(){ + Log.d(TAG, "url: "+BASE_URL + "/note/all?uid="+userId); VolleyUtilSingleton.getInstance(PersonalSpaceActivity.this).get(BASE_URL + "/note/all?uid="+userId, getNotesSuccessListener, genericErrorListener); } @@ -139,7 +140,7 @@ public class PersonalSpaceActivity extends AppCompatActivity { } catch (Exception e) { - Log.d(TAG, e.toString()); + Log.d(TAG, "saveBtn: "+e.toString()); } //send request and close dialog @@ -226,7 +227,7 @@ public class PersonalSpaceActivity extends AppCompatActivity { Response.Listener getNotesSuccessListener = new Response.Listener() { @Override public void onResponse(JSONObject response) { - Log.d(TAG,response.toString()); + Log.d(TAG,"getNotesSuccessListener: "+response.toString()); try { //need to get all notes and add to listOfNotes JSONArray noteObjectsArray = response.getJSONArray("notes"); @@ -260,7 +261,7 @@ public class PersonalSpaceActivity extends AppCompatActivity { Response.ErrorListener getNotesErrorListener = new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { - Log.d(TAG,error.getMessage()); + Log.d(TAG,"getNotesErrorListener: "+error.getMessage()); } }; @@ -268,11 +269,60 @@ public class PersonalSpaceActivity extends AppCompatActivity { Response.ErrorListener genericErrorListener = new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { - Log.d(TAG,error.getMessage()); + Log.d(TAG,"genericErrorListener"); + error.printStackTrace(); } }; + public void requestPermissions(){ + // Here, thisActivity is the current activity + if (ContextCompat.checkSelfPermission(PersonalSpaceActivity.this, + Manifest.permission.ACCESS_FINE_LOCATION) + != PackageManager.PERMISSION_GRANTED) { + + + ActivityCompat.requestPermissions(PersonalSpaceActivity.this, + new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, + FINE_PERM); + + // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an + // app-defined int constant. The callback method gets the + // result of the request. + + } + + if (ContextCompat.checkSelfPermission(PersonalSpaceActivity.this, + Manifest.permission.ACCESS_FINE_LOCATION) + != PackageManager.PERMISSION_GRANTED) { + + + ActivityCompat.requestPermissions(PersonalSpaceActivity.this, + new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, + 1); + + // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an + // app-defined int constant. The callback method gets the + // result of the request. + + } + + if (ContextCompat.checkSelfPermission(PersonalSpaceActivity.this, + Manifest.permission.ACCESS_COARSE_LOCATION) + != PackageManager.PERMISSION_GRANTED) { + + + ActivityCompat.requestPermissions(PersonalSpaceActivity.this, + new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, + FINE_PERM); + + // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an + // app-defined int constant. The callback method gets the + // result of the request. + + } + + }