diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index ea076f1..bdd2be8 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -4,6 +4,8 @@
android:versionCode="2"
android:versionName="1.0.0-SNAPSHOT">
+
+
zipcodes;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -45,6 +43,25 @@ protected void onCreate(Bundle savedInstanceState) {
addjson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
+ JSONArray jArr = new JSONArray();
+ JSONObject jObj = new JSONObject();
+ try {
+
+ jObj.put("ID", _id.getText());
+ jObj.put("pop", pop.getText());
+ jObj.put("city", city.getText());
+ jObj.put("state", state.getText());
+ jObj.put("_lat", _lat.getText());
+ jObj.put("_long", _lat.getText());
+
+ jArr.put(jObj);
+
+ } catch (Exception e) {
+ System.out.println("Error:" + e);
+ }
+
+
}
});
@@ -61,8 +78,39 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
File directory = getExternalCacheDir();
- File file = new File(directory, "zipcodes.json");
+ File file = new File(directory, "Zipcodes.json");
}
});
+
+
+ }
+
+ public String loadJSONFromAsset() {
+ String json = null;
+ try {
+
+ InputStream is = getAssets().open("json/Zipcode.json");
+
+ int size = is.available();
+
+ byte[] buffer = new byte[size];
+
+ is.read(buffer);
+
+ is.close();
+
+ json = new String(buffer, "UTF-8");
+
+
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ return null;
+ }
+ return json;
+
}
+
+
+
+
}
diff --git a/src/main/java/nyc/c4q/ListViewActivity.java b/src/main/java/nyc/c4q/ListViewActivity.java
index 78104c6..f942c79 100644
--- a/src/main/java/nyc/c4q/ListViewActivity.java
+++ b/src/main/java/nyc/c4q/ListViewActivity.java
@@ -2,10 +2,14 @@
import android.app.Activity;
import android.os.Bundle;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ListView;
import android.widget.TextView;
public class ListViewActivity extends Activity {
+
public static final String[] COLORS = {
"#142b44",
"#1d508d",
@@ -25,5 +29,15 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listview);
textLog = (TextView) findViewById(R.id.textLog);
+ ListView listview = (ListView)findViewById(R.id.list);
+ EditText phoneinput = (EditText)findViewById(R.id.adapterCount);
+ ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, COLORS);
+ listview.setAdapter(adapter);
+
}
+
+
}
+
+
+
diff --git a/src/main/java/nyc/c4q/NetworkActivity.java b/src/main/java/nyc/c4q/NetworkActivity.java
index 3604cfc..8f21ab9 100644
--- a/src/main/java/nyc/c4q/NetworkActivity.java
+++ b/src/main/java/nyc/c4q/NetworkActivity.java
@@ -8,21 +8,17 @@
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
+import android.widget.Toast;
-import com.squareup.okhttp.FormEncodingBuilder;
-import com.squareup.okhttp.HttpUrl;
-import com.squareup.okhttp.OkHttpClient;
-import com.squareup.okhttp.Request;
-import com.squareup.okhttp.RequestBody;
-import com.squareup.okhttp.Response;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
-import java.io.BufferedInputStream;
-import java.io.DataOutputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
+import java.io.InputStreamReader;
public class NetworkActivity extends Activity {
@@ -76,6 +72,7 @@ protected void onCreate(Bundle savedInstanceState) {
httpbinget.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ new HttpAsyncTask().execute(urlParams);
}
});
@@ -104,4 +101,65 @@ public void onClick(View v) {
}
});
}
+
+ public static String GET(String url){
+ InputStream inputStream = null;
+ String result = "";
+ try {
+
+ // create HttpClient
+ HttpClient httpclient = new DefaultHttpClient();
+
+ // make GET request to the given URL
+ HttpResponse httpResponse = httpclient.execute(new HttpGet(url));
+
+ // receive response as inputStream
+ inputStream = httpResponse.getEntity().getContent();
+
+ if(inputStream != null)
+ result = url.toString();
+ else
+ result = "Did not work!";
+
+ } catch (Exception e) {
+ Log.d("InputStream", e.getLocalizedMessage());
+ }
+
+ return result;
+ }
+
+ // convert inputstream to String
+ private static String convertInputStreamToString(InputStream inputStream) throws IOException {
+ BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
+ String line = "";
+ String result = "";
+ while((line = bufferedReader.readLine()) != null)
+ result += line;
+
+ inputStream.close();
+ return result;
+
+ }
+
+ private class HttpAsyncTask extends AsyncTask {
+
+ @Override
+ protected String doInBackground(String... urls) {
+
+ return GET(urls[0]);
+
+ }
+ // onPostExecute displays the results of the AsyncTask.
+ @Override
+ protected void onPostExecute(String result) {
+ Toast.makeText(getBaseContext(), "Received!", Toast.LENGTH_LONG).show();
+
+ httptextlog.setText(urlParams);
+ }
+ }
+
+
+
}
+
+
diff --git a/src/main/java/nyc/c4q/NotificationActivity.java b/src/main/java/nyc/c4q/NotificationActivity.java
index f1f56ad..1ddfd2e 100644
--- a/src/main/java/nyc/c4q/NotificationActivity.java
+++ b/src/main/java/nyc/c4q/NotificationActivity.java
@@ -1,8 +1,14 @@
package nyc.c4q;
import android.app.Activity;
+import android.app.Notification;
import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
+import android.support.v4.app.NotificationCompat;
+import android.view.View;
import android.widget.Button;
public class NotificationActivity extends Activity {
@@ -11,6 +17,8 @@ public class NotificationActivity extends Activity {
public static final int ID_SWIPE_NOTIFICATION = 2;
public static final int ID_PERMANENT_NOTIFICATION = 3;
public static final int ID_BUTTON_NOTIFICATION = 4;
+ public static final int NOTIFICATION_ID = 1234;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -25,5 +33,81 @@ protected void onCreate(Bundle savedInstanceState) {
Button dismisspermanentnotification = (Button) findViewById(R.id.dismisspermanentnotification);
Button buttonnotification = (Button) findViewById(R.id.buttonnotification);
+
+ autocancelnotification.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ cancelNotification();
+ }
+ });
+
+ swipenotification.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ swipeNotification();
+ }
+ });
+
+ permanentnotification.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ ongoingNotification();
+ }
+ });
}
+
+
+ private void cancelNotification() {
+
+ Intent intent = new Intent();
+ PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
+ Notification noti = new Notification.Builder(this)
+ .setContentTitle("default@c4q.nyc")
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .setContentText("Touch me to dismiss me!")
+ .setContentIntent(pIntent).getNotification();
+ noti.flags = Notification.FLAG_AUTO_CANCEL;
+ NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ notificationManager.notify(0, noti);
+
+ }
+
+ private void swipeNotification() {
+
+ Intent intent = new Intent();
+ PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
+ Notification noti = new Notification.Builder(this)
+ .setContentTitle("swipe@c4q.nyc")
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .setContentText("Swipe right if you want to meet me. Otherwise, I'm not going away.")
+ .setContentIntent(pIntent).getNotification();
+
+ NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ notificationManager.notify(0, noti);
+
+ }
+
+ private void ongoingNotification() {
+
+
+ NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
+// builder.setOngoing(true);
+ builder.setContentTitle("permanent@c4q.nyc");
+ builder.setSmallIcon(R.drawable.c4qfavicon);
+ builder.setContentText("I'm staying planted right here.");
+
+ Intent resultIntent = new Intent();
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, resultIntent, 0);
+ builder.setContentIntent(pendingIntent);
+
+ Notification notification = builder.build();
+ notification.flags = Notification.FLAG_ONGOING_EVENT;
+ notificationManager.notify(NOTIFICATION_ID, notification);
+ }
+
}
diff --git a/src/main/java/nyc/c4q/json/Zipcode.java b/src/main/java/nyc/c4q/json/Zipcode.java
index 6d4761f..670fdc4 100644
--- a/src/main/java/nyc/c4q/json/Zipcode.java
+++ b/src/main/java/nyc/c4q/json/Zipcode.java
@@ -1,4 +1,11 @@
package nyc.c4q.json;
public class Zipcode {
+ public String _id = "11101";
+ public String city="ASTORIA";
+ public String state="NY";
+ public int pop=23142;
+ public double[] loc= {-73.939393, 0.01};
+
+
}
diff --git a/src/main/res/layout/activity_listview.xml b/src/main/res/layout/activity_listview.xml
index 0d4b9d6..073b742 100644
--- a/src/main/res/layout/activity_listview.xml
+++ b/src/main/res/layout/activity_listview.xml
@@ -3,26 +3,38 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_listview"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="0dp"
android:orientation="vertical"
tools:context="nyc.c4q.ListViewActivity">
+
+
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="3"
+ android:text="You have not clicked anything." />
+
+
+ android:layout_width="match_parent"
+ android:layout_weight="9"
+ android:layout_height="0dp"/>
\ No newline at end of file
diff --git a/src/main/res/layout/listview_tile.xml b/src/main/res/layout/listview_tile.xml
index 7da0366..b6aa2be 100644
--- a/src/main/res/layout/listview_tile.xml
+++ b/src/main/res/layout/listview_tile.xml
@@ -4,7 +4,8 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:padding="@dimen/rowPadding">
+ android:padding="@dimen/rowPadding"
+ android:background="#ffbcffff">