This commit is contained in:
Matan Bar Yosef 2016-07-02 16:58:40 +03:00
commit 9347065832
13 changed files with 109 additions and 83 deletions

View file

@ -5,7 +5,7 @@
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
<option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.10" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

View file

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="android-android-23">
<CLASSES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/platforms/android-23/android.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="animated-vector-drawable-23.3.0">
<CLASSES>
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/res" />
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/jars/classes.jar!/" />
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/23.3.0/animated-vector-drawable-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/23.3.0/animated-vector-drawable-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/23.3.0/animated-vector-drawable-23.3.0-sources.jar!/" />
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/23.3.0/animated-vector-drawable-23.3.0-sources.jar!/" />
</SOURCES>
</library>

View file

@ -4,13 +4,13 @@
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/res" />
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/jars/classes.jar!/" />
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0-sources.jar!/" />
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0-sources.jar!/" />
</SOURCES>
</library>

View file

@ -4,13 +4,13 @@
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/res" />
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/jars/classes.jar!/" />
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/design/23.3.0/design-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/design/23.3.0/design-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/design/23.3.0/design-23.3.0-sources.jar!/" />
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/design/23.3.0/design-23.3.0-sources.jar!/" />
</SOURCES>
</library>

View file

@ -9,8 +9,8 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7/23.3.0/recyclerview-v7-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7/23.3.0/recyclerview-v7-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7/23.3.0/recyclerview-v7-23.3.0-sources.jar!/" />
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/recyclerview-v7/23.3.0/recyclerview-v7-23.3.0-sources.jar!/" />
</SOURCES>
</library>

View file

@ -1,12 +1,12 @@
<component name="libraryTable">
<library name="support-annotations-23.3.0">
<CLASSES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.3.0/support-annotations-23.3.0.jar!/" />
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.3.0/support-annotations-23.3.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.3.0/support-annotations-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.3.0/support-annotations-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.3.0/support-annotations-23.3.0-sources.jar!/" />
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/support-annotations/23.3.0/support-annotations-23.3.0-sources.jar!/" />
</SOURCES>
</library>

View file

@ -10,8 +10,8 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.3.0/support-v4-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.3.0/support-v4-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.3.0/support-v4-23.3.0-sources.jar!/" />
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/support-v4/23.3.0/support-v4-23.3.0-sources.jar!/" />
</SOURCES>
</library>

View file

@ -6,8 +6,8 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-vector-drawable/23.3.0/support-vector-drawable-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-vector-drawable/23.3.0/support-vector-drawable-23.3.0-sources.jar!/" />
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-vector-drawable/23.3.0/support-vector-drawable-23.3.0-sources.jar!/" />
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/support-vector-drawable/23.3.0/support-vector-drawable-23.3.0-sources.jar!/" />
</SOURCES>
</library>

View file

@ -1,8 +1,8 @@
<component name="libraryTable">
<library name="volley-1.0.0">
<CLASSES>
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.volley/volley/1.0.0/res" />
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.volley/volley/1.0.0/jars/classes.jar!/" />
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.volley/volley/1.0.0/res" />
</CLASSES>
<JAVADOC />
<SOURCES>

View file

@ -5,13 +5,13 @@ package com.android_app.matan.ara.sagi.thesocialnotework;
*/
public class Note {
protected int id;
// protected int id;
protected float lat, lon;
protected String address, title, body;
protected String id, address, title, body;
protected long timestamp;
protected boolean isPublic;
public Note(int id, float lat, float lon, String address, String title, String body, long timestamp, boolean isPublic) {
public Note(String id, float lat, float lon, String address, String title, String body, long timestamp, boolean isPublic) {
this.id = id;
this.lat = lat;
this.lon = lon;
@ -36,11 +36,11 @@ public class Note {
'}';
}
public int getId() {
public String getId() {
return id;
}
public void setId(int id) {
public void setId(String id) {
this.id = id;
}

View file

@ -23,6 +23,7 @@ import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
@ -38,9 +39,10 @@ public class PersonalSpaceActivity extends AppCompatActivity {
protected Button addBtn;
private final String TAG = "Personal Space Activity";
private final int FINE_PERM = 0;
private final String baseUrl = "http://thesocialnotework-api.appspot.com/api";
private final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
private boolean locationPermission;
private GPSUtils gpsUtils;
private List<Note> listOfNotes;
@Override
@ -52,41 +54,14 @@ public class PersonalSpaceActivity extends AppCompatActivity {
//check for permission
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, FINE_PERM);
// if (ContextCompat.checkSelfPermission(PersonalSpaceActivity.this,
// Manifest.permission.INTERNET)
// != PackageManager.PERMISSION_GRANTED) {
// ActivityCompat.requestPermissions(PersonalSpaceActivity.this,
// new String[]{Manifest.permission.INTERNET},
// 1);
// }
this.noteList = (ListView) findViewById(R.id.ps_list_listview);
addBtn = (Button) findViewById(R.id.ps_new_note_button);
gpsUtils = new GPSUtils(this);
final JSONObject tempJson = new JSONObject();
try {
tempJson.put("username", "aran");
tempJson.put("password", "1234");
tempJson.put("email", "abc@a.a");
} catch (Exception e) {
Log.d(TAG, e.toString());
}
//TODO remove
Button tempBtn = (Button) findViewById(R.id.temp_btn);
tempBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
VolleyUtilSingleton.getInstance(PersonalSpaceActivity.this).newUser(baseUrl + "/register", tempJson);
}
});
List<Note> listOfNotes = new ArrayList<>();
listOfNotes = new ArrayList<>();
//add demo notes to view
addDemoNotes(listOfNotes);
ListAdapter la = new ListAdapter(this, listOfNotes);
@ -126,28 +101,29 @@ public class PersonalSpaceActivity extends AppCompatActivity {
});
saveBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//volley post
final JSONObject noteJson = new JSONObject();
try {
// noteJson.put("id", 12345);
noteJson.put("owner_id", "5634472569470976");
noteJson.put("title", newTitle.getText());
noteJson.put("lat", gpsUtils.getLatitude());
noteJson.put("lng", gpsUtils.getLongitude());
noteJson.put("address",gpsUtils.getAddress());
noteJson.put("body",newBody.getText());
noteJson.put("is_public",permissionSwitch.isChecked());
noteJson.put("address", gpsUtils.getAddress());
noteJson.put("body", newBody.getText());
noteJson.put("is_public", permissionSwitch.isChecked());
// noteJson.put("tags",);
Log.d(TAG,"Json: "+noteJson.toString());
Log.d(TAG, "Json: " + noteJson.toString());
} catch (Exception e) {
Log.d(TAG, e.toString());
}
VolleyUtilSingleton.getInstance(PersonalSpaceActivity.this).newUser(BASE_URL + "/note/upsert", noteJson);
dialog.dismiss();
}
});
@ -174,42 +150,63 @@ public class PersonalSpaceActivity extends AppCompatActivity {
public void addDemoNotes(List<Note> listOfNotes) {
Note n1 = new Note(1, 100, 100, "location1", "My 1st Title", "ohh i'm so sexy1", System.currentTimeMillis() / 1000, true);
Note n2 = new Note(2, 200, 200, "location2", "My 2st Title", "ohh i'm so sexy2", System.currentTimeMillis() / 1000, true);
Note n3 = new Note(3, 300, 300, "hell", "My 3st Title", "ohh i'm so sexy3", System.currentTimeMillis() / 1000, true);
Note n4 = new Note(4, 400, 400, "hell2", "My 4st Title", "ohh i'm so sexy4", System.currentTimeMillis() / 1000, true);
Note n1 = new Note("1", 100, 100, "location1", "My 1st Title", "ohh i'm so sexy1", System.currentTimeMillis() / 1000, true);
Note n2 = new Note("2", 200, 200, "location2", "My 2st Title", "ohh i'm so sexy2", System.currentTimeMillis() / 1000, true);
Note n3 = new Note("3", 300, 300, "hell", "My 3st Title", "ohh i'm so sexy3", System.currentTimeMillis() / 1000, true);
Note n4 = new Note("4", 400, 400, "hell2", "My 4st Title", "ohh i'm so sexy4", System.currentTimeMillis() / 1000, true);
listOfNotes.add(n1);
listOfNotes.add(n2);
listOfNotes.add(n3);
listOfNotes.add(n4);
}
public void setLocationPermission(boolean locationPermission) {
this.locationPermission = locationPermission;
}
// private void newUser(String url, JSONObject body) {
// JsonObjectRequest request =
// new JsonObjectRequest(
// Request.Method.POST,
// url,
// body,
// new Response.Listener<JSONObject>() {
// @Override
// public void onResponse(JSONObject response) {
// Log.d(TAG, "success: response - " + response.toString());
//// loadData(response, true);
// }
// },
// new Response.ErrorListener() {
// @Override
// public void onErrorResponse(VolleyError error) {
// Log.d(TAG, "error: msg: " + error.getMessage());
// }
// }
// );
// VolleyUtilSingleton.getInstance(this).addToRequestQueue(request);
Response.Listener<JSONObject> newNoteSuccess = new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
String s = "";
try {
s= response.getString("id");
} catch (JSONException e) {
e.printStackTrace();
}
Log.d(TAG, "newNoteSuccess: response - " + response.toString());
Log.d(TAG, "newNoteSuccess: id response - " + s);
try {
Note addNote = new Note(
"12345",
Float.parseFloat(response.getJSONObject("location").getString("lat")),
Float.parseFloat(response.getJSONObject("location").getString("lng")),
response.getJSONObject("location").getString("address"),
response.getString("title"),
response.getString("body"),
response.getLong("created_at"),
response.getBoolean("is_public")
);
listOfNotes.add(addNote);
// addNoteToArray(addNote);
} catch (JSONException e) {
Log.e(TAG, "newNoteSuccess:" + e.getMessage());
}
}
};
// private void addNoteToArray(Note addNote) {
// listOfNotes.addNote
// }
Response.ErrorListener newNoteError = new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "newNoteError: msg: " + error.getMessage());
}
};
}

View file

@ -10,6 +10,7 @@ import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
/**
@ -64,8 +65,15 @@ public class VolleyUtilSingleton {
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d(TAG, "success: response - " + response.toString());
// loadData(response, true);
String s = "";
try {
s= response.getString("id");
} catch (JSONException e) {
e.printStackTrace();
}
Log.d(TAG, "newNoteSuccess: response - " + response.toString());
Log.d(TAG, "newNoteSuccess: id response - " + s);
}
},
new Response.ErrorListener() {
@ -78,4 +86,16 @@ public class VolleyUtilSingleton {
addToRequestQueue(request);
}
public void post(String url, JSONObject body, Response.Listener<JSONObject> successFunction, Response.ErrorListener errorFunction) {
JsonObjectRequest request =
new JsonObjectRequest(
Request.Method.POST,
url,
body,
successFunction,
errorFunction
);
addToRequestQueue(request);
}
}