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">
+
+
();
Button savejson = (Button) findViewById(R.id.savejson);
Button loadjson = (Button) findViewById(R.id.loadjson);
Button addjson = (Button) findViewById(R.id.addjson);
+
final TextView _id = (TextView) findViewById(R.id.field_idvalue);
final TextView pop = (TextView) findViewById(R.id.fieldpopvalue);
final TextView city = (TextView) findViewById(R.id.fieldcityvalue);
@@ -45,6 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {
addjson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
}
});
diff --git a/src/main/java/nyc/c4q/ListViewActivity.java b/src/main/java/nyc/c4q/ListViewActivity.java
index 78104c6..d981503 100644
--- a/src/main/java/nyc/c4q/ListViewActivity.java
+++ b/src/main/java/nyc/c4q/ListViewActivity.java
@@ -1,11 +1,16 @@
package nyc.c4q;
import android.app.Activity;
+import android.graphics.drawable.ColorDrawable;
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 {
+//array of colors
public static final String[] COLORS = {
"#142b44",
"#1d508d",
@@ -18,12 +23,69 @@ public class ListViewActivity extends Activity {
"#fa5e5b",
"#bf538d"
};
+
+ //variables
+ private ListView list;
+ private ArrayAdapter arrayAdapter;
public TextView textLog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listview);
+
+ //declaring variables
textLog = (TextView) findViewById(R.id.textLog);
+ EditText adapterCount = (EditText) findViewById(R.id.adapterCount);
+ list = (ListView) findViewById(R.id.list);
+
+ // this-The current activity context.
+ // Second param is the resource Id for list layout row item
+ // Third param is input array
+ arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, COLORS);
+ list.setAdapter(arrayAdapter);
+
+ //change the color for the division
+ // list.setDivider(new ColorDrawable());
+ ColorDrawable sage = new ColorDrawable(this.getResources().getColor(R.color.sage));
+ list.setDivider(sage);
+ list.setDividerHeight(2);
}
-}
+
+ /*TODO: For test07- was I suppose to ColorDrawable to show the string values of the array into the color background (ex: the "#color" should show a color in one of the row backgrounds*/
+//TODO: For test08- textLog should say "You clicked on Item(position=%s (item within the array), color=%s (color of the item)- Not sure within the listview or on the listview xml
+//TODO: For test09 and 10- not sure what to do with the Inputs. Is there a for loop with boolean statements in it?
+
+
+// The Idea was to make a View method that can use if statements to get the color from text to show color
+ //I got this info at http://www.survivingwithandroid.com/2013/04/android-listview-background-row-style.html
+
+// public View getView(int position, View convertView, ViewGroup parent) {
+// View v = convertView;
+//
+// PlanetHolder holder = new PlanetHolder();
+//
+// // First let's verify the convertView is not null
+// if (convertView == null) {
+// // This a new view we inflate the new layout
+// LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+// v = inflater.inflate(R.layout.row_layout, null);
+// // Now we can fill the layout with the right values
+// TextView tv = (TextView) v.findViewById(R.id.name);
+//
+// holder.planetNameView = tv;
+//
+// v.setTag(holder);
+//
+// v.setBackgroundResource(R.drawable.rounded_corner);
+// }
+// else
+// holder = (PlanetHolder) v.getTag();
+//
+// Planet p = planetList.get(position);
+// holder.planetNameView.setText(p.getName());
+//
+// return v;
+// }
+
+}
\ No newline at end of file
diff --git a/src/main/java/nyc/c4q/NetworkActivity.java b/src/main/java/nyc/c4q/NetworkActivity.java
index 3604cfc..eb2f5fa 100644
--- a/src/main/java/nyc/c4q/NetworkActivity.java
+++ b/src/main/java/nyc/c4q/NetworkActivity.java
@@ -1,29 +1,12 @@
package nyc.c4q;
import android.app.Activity;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
-import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
-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 java.io.BufferedInputStream;
-import java.io.DataOutputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-
public class NetworkActivity extends Activity {
// Fields ===========================
@@ -50,7 +33,7 @@ protected void onCreate(Bundle savedInstanceState) {
httptextlog = (TextView) findViewById(R.id.httptextlog);
httptextlog.setMovementMethod(new ScrollingMovementMethod());
- /*
+ /* TODO: Are we suppose to do this? So Confused!!
The goal is to use AsyncTasks here.
Shortcut to create URL in Java:
@@ -73,9 +56,13 @@ protected void onCreate(Bundle savedInstanceState) {
https://httpbin.org/post
*/
+
+ //Todo: Are we Suppose to do this? Fill out the OnClicks?
+
httpbinget.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
}
});
@@ -105,3 +92,6 @@ public void onClick(View v) {
});
}
}
+
+/*TODO: I know the concepts of GET and POST. Not sure how to use it though. Look at the ServiceHandler.java
+* TODO: For test12- we want to go the GET parts of the URLConnection and for test13- we want to GET the OKHTTP*/
diff --git a/src/main/java/nyc/c4q/NotificationActivity.java b/src/main/java/nyc/c4q/NotificationActivity.java
index f1f56ad..d8aefe1 100644
--- a/src/main/java/nyc/c4q/NotificationActivity.java
+++ b/src/main/java/nyc/c4q/NotificationActivity.java
@@ -1,11 +1,18 @@
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 {
+ private static final int NOTIFICATION_ID = 0 ;
NotificationManager notificationManager;
public static final int ID_AUTOCANCEL_NOTIFICATION = 1;
public static final int ID_SWIPE_NOTIFICATION = 2;
@@ -25,5 +32,48 @@ protected void onCreate(Bundle savedInstanceState) {
Button dismisspermanentnotification = (Button) findViewById(R.id.dismisspermanentnotification);
Button buttonnotification = (Button) findViewById(R.id.buttonnotification);
+
+
+// View startDelayButton = findViewById(R.id.startDelay); <---Give Delay of the Notification
+// startDelayButton.setOnClickListener(new View.OnClickListener()
+// {
+// @Override
+// public void onClick(View v)
+// {
+// startDelay();
+// }
+// });
+
+ View cancelButton = findViewById(R.id.autocancelnotification);
+ cancelButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ cancelNotification();
+ }
+ });
}
+
+
+
+
+ private void updateNotification(String titleText, String contentText) {
+ NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
+ builder.setAutoCancel(true);
+ builder.setContentTitle(titleText);
+ builder.setContentText(contentText);
+ //builder.setSmallIcon(R.drawable.);
+ Intent resultIntent = new Intent(this, NotificationActivity.class);
+ PendingIntent pendingIntent =
+ PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ builder.setContentIntent(pendingIntent);
+ Notification notification = builder.build();
+ notificationManager.notify(NOTIFICATION_ID, notification);
+ }
+
+ private void cancelNotification() {
+ NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancel(NOTIFICATION_ID);
+ }
+
}
diff --git a/src/main/java/nyc/c4q/ServiceHandler.java b/src/main/java/nyc/c4q/ServiceHandler.java
new file mode 100644
index 0000000..140503e
--- /dev/null
+++ b/src/main/java/nyc/c4q/ServiceHandler.java
@@ -0,0 +1,92 @@
+package nyc.c4q;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+/**
+ * Created by c4q-joshelynvivas on 6/28/15.
+ */
+
+//TODO: Does this have something to do with the url params? It includes POST, GET and HTTP
+ public class ServiceHandler {
+
+ String response = null;
+ public final static int GET = 1;
+// public final static int POST = 2;
+
+ public ServiceHandler() {
+
+ }
+
+ /**
+ * Making service call
+ * @url - url to make request
+ * @method - http request method
+ * */
+ public String makeServiceCall(String url, int method) {
+ return this.makeServiceCall(url, method, null);
+ }
+
+ /**
+ * Making service call
+ * @url - url to make request
+ * @method - http request method
+ * @params - http request params
+ * */
+ public String makeServiceCall(String url, int method,
+ List params) {
+ try {
+ // http client
+ DefaultHttpClient httpClient = new DefaultHttpClient();
+ HttpEntity httpEntity = null;
+ HttpResponse httpResponse = null;
+
+// // Checking http request method type
+// if (method == POST) {
+// HttpPost httpPost = new HttpPost(url);
+ // adding post params
+// if (params != null) {
+// httpPost.setEntity(new UrlEncodedFormEntity(params));
+// }
+//
+// httpResponse = httpClient.execute(httpPost);}
+
+ if (method == GET) {
+ // appending params to url
+ if (params != null) {
+ String paramString = URLEncodedUtils
+ .format(params, "utf-8");
+ url += "?" + paramString;
+ }
+ HttpGet httpGet = new HttpGet(url);
+
+ httpResponse = httpClient.execute(httpGet);
+
+ }
+ httpEntity = httpResponse.getEntity();
+ response = EntityUtils.toString(httpEntity);
+
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return response;
+
+ }
+ }
+
+
diff --git a/src/main/java/nyc/c4q/WhatIKnow.java b/src/main/java/nyc/c4q/WhatIKnow.java
new file mode 100644
index 0000000..7d3ad3d
--- /dev/null
+++ b/src/main/java/nyc/c4q/WhatIKnow.java
@@ -0,0 +1,90 @@
+package nyc.c4q;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Created by c4q-joshelynvivas on 6/28/15.\
+ *
+ * TODO: What I do know about the JSON Parsing. Brackets are Arrays and Curly Brackets are Objects. The example is from the weather Parse
+ *
+ */
+public class WhatIKnow {
+
+ // http://api.openweathermap.org/data/2.5/weather?zip=11367,us -- URL
+ //Endpoint is either the http://link or the beginning part of it (ex: zip=)
+ //Suffix is the ending part of the website once the person enters something in
+
+ private static final String JSON_URL_ENDPOINT = "http://api.openweathermap.org/data/2.5/weather?zip=";
+ private static final String JSON_URL_SUFFIX = ",us";
+
+ private static String jsonString = "";
+
+ // Goal 1
+ private static String getJsonString() {
+ String result = "";
+
+ // TODO : Step 0 - create a completed json url string by adding your own zip code
+ String jsonUrl = JSON_URL_ENDPOINT + "11367" + JSON_URL_SUFFIX;
+
+
+ // TODO : Step 1 - create an URL instance with Step 0's result
+ try {
+ //converting the json Url to an actual URL
+ URL url = new URL(jsonUrl);
+
+ // TODO : Step 2 - create a Http Url Connection with Step 1's URL
+ //make sure to have internet permission before doing this
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setConnectTimeout(0);
+ connection.setReadTimeout(0);
+
+ // TODO : Step 3 - get inputstream from Step 2 and create an instance of BufferedReader
+ //I believe this is grabbing the information to go to the project
+ InputStream inputStream = connection.getInputStream();
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+
+ // TODO : Step 4 - create a string builder instance
+ //going to create Strings
+ StringBuilder stringBuilder = new StringBuilder();
+
+ // TODO : Step 5 - read json file until the end of the line and write into string builder and save it into String variable "result"
+ String line = "";
+ while ((line = bufferedReader.readLine()) != null) {
+ stringBuilder.append(line + "\n");
+ }
+ result = stringBuilder.toString();
+
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ // Goal 2- getting Humidity of the weather api
+ public static int getHumidity() {
+ int humidity = -1;
+
+ jsonString = getJsonString();
+ try {
+ //since the file has the object first, we need the JSON to see the Object, then go down the families to get what you want
+ JSONObject object = new JSONObject(jsonString);
+ JSONObject main = object.getJSONObject("main");
+ humidity = main.getInt("humidity");
+ } catch (JSONException e) { //catch helps prevent errors
+ e.printStackTrace();
+ }
+
+ return humidity;
+ }
+ }
diff --git a/src/main/java/nyc/c4q/json/Zipcode.java b/src/main/java/nyc/c4q/json/Zipcode.java
index 6d4761f..203563b 100644
--- a/src/main/java/nyc/c4q/json/Zipcode.java
+++ b/src/main/java/nyc/c4q/json/Zipcode.java
@@ -1,4 +1,9 @@
package nyc.c4q.json;
+import com.google.gson.Gson;
+
public class Zipcode {
+ Gson gson = new Gson();
+ // Zipcode z = gson.toJson(JSONObject.) TODO: Suppose to give me a JSON_ZIPCODE of some kind. Was this the part were I was suppose to Parse it?
+
}
diff --git a/src/main/res/layout/activity_listview.xml b/src/main/res/layout/activity_listview.xml
index 0d4b9d6..cf19624 100644
--- a/src/main/res/layout/activity_listview.xml
+++ b/src/main/res/layout/activity_listview.xml
@@ -9,20 +9,34 @@
+ 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_height="0dp"
+ android:layout_weight="9"
+ />
+
+
+
\ No newline at end of file
diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml
index c83516a..d3e8612 100644
--- a/src/main/res/values/attrs.xml
+++ b/src/main/res/values/attrs.xml
@@ -1,4 +1,5 @@
10
10dp
+ #cceebb
diff --git a/src/test/java/nyc/c4q/Part1ListViewActivityTests.java b/src/test/java/nyc/c4q/Part1ListViewActivityTests.java
index c473ee1..848cd5b 100644
--- a/src/test/java/nyc/c4q/Part1ListViewActivityTests.java
+++ b/src/test/java/nyc/c4q/Part1ListViewActivityTests.java
@@ -105,8 +105,8 @@ public void test07ListViewActivityCheckRowBackgroundColors() {
for (int i = 0; i < ListViewActivity.COLORS.length; i++) {
View v = adapter.getView(i, null, list);
assertThat(v, notNullValue());
- assertThat(v.getBackground(), instanceOf(ColorDrawable.class));
- ColorDrawable background = (ColorDrawable) v.getBackground();
+ assertThat(v.getBackground(), instanceOf(ColorDrawable.class)); //Does this mean to use the ColorDrawable tool?
+ ColorDrawable background = (ColorDrawable) v.getBackground(); //was I suppose to make a drawable?
assertThat(background.getColor(), equalTo(Color.parseColor(ListViewActivity.COLORS[i])));
}
}
diff --git a/src/test/java/nyc/c4q/Part2NetworkActivityTests.java b/src/test/java/nyc/c4q/Part2NetworkActivityTests.java
index 3a561c6..d047884 100644
--- a/src/test/java/nyc/c4q/Part2NetworkActivityTests.java
+++ b/src/test/java/nyc/c4q/Part2NetworkActivityTests.java
@@ -14,7 +14,6 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-import org.robolectric.util.ActivityController;
import java.util.List;
@@ -62,7 +61,7 @@ public void test13NetworkActivityHTTPUrlConnectionGETOKHTTP() throws Exception {
@Test
public void test14Missing() {
// TODO
- // FREE question for now.
+ // FREE question for now. Thank You :D
}
@Test
diff --git a/src/test/java/nyc/c4q/Part4NotificationActivityTests.java b/src/test/java/nyc/c4q/Part4NotificationActivityTests.java
index 36a7e3b..4f1fc23 100644
--- a/src/test/java/nyc/c4q/Part4NotificationActivityTests.java
+++ b/src/test/java/nyc/c4q/Part4NotificationActivityTests.java
@@ -22,7 +22,7 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(RobolectricTestRunner.class)
-@Config(manifest = "src/main/AndroidManifest.xml", emulateSdk = 18)
+@Config(manifest = "src/main/AndroidManifest.xml", emulateSdk = 18) //should I change the SDK at 18?
public class Part4NotificationActivityTests {
private NotificationActivity notificationActivity;