From 8ba07bf1c4861590bff4bae38b77229162154828 Mon Sep 17 00:00:00 2001 From: pocha Date: Fri, 6 Jun 2014 00:46:06 +0530 Subject: [PATCH 01/17] updated instructions for challenge level 2 --- .../_fetching_tweets_with_http_get.html.md | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/twitter-http-challenge/_fetching_tweets_with_http_get.html.md b/twitter-http-challenge/_fetching_tweets_with_http_get.html.md index 1d2b587..6e1a083 100644 --- a/twitter-http-challenge/_fetching_tweets_with_http_get.html.md +++ b/twitter-http-challenge/_fetching_tweets_with_http_get.html.md @@ -55,7 +55,29 @@ Edgar ## On refresh -On refresh, lets say, you get four new tweets with title Josh, Marcus, John & Warren. **The new tweets should be added on top of existing tweets & in the same order as fetched from network**. +On refresh, lets say, you get four new tweets with title Josh, Marcus, John & Warren. + +
+[ { "body" : "..",
+    "id" : ..,
+    "title" : "Josh"
+  },
+  { "body" : "..",
+    "id" : ..,
+    "title" : "Marcus"
+  },
+  { "body" : "..",
+    "id" : ..,
+    "title" : "John"
+  },
+  { "body" : "..",
+    "id" : ..,
+    "title" : "Warren"
+  }  
+]
+
+ + **The new tweets should be added on top of existing tweets & in the same order as fetched from network**. `order of tweets on TweetListActivity`
@@ -74,7 +96,7 @@ Edgar
 
 1. Improve the login process by showing a **RelativeLayout** containing a **ProgressBar** while the login HTTP call is in progress. The RelativeLayout should be added **after Login button** in the same activity, should span height & width of screen & should have a child element ProgressBar. The ProgressBar should show up when the Login data is being sent to the server & should be hidden when the login process completes.
 
-2. Modify TweetListActivity to make an HTTP GET call when the Activity is created to fetch tweets. Handle the received Tweet objects and render them in the ListView such that *last tweet fetched should appear first in the list*.
+2. Modify TweetListActivity to make an HTTP GET call when the Activity is created to fetch tweets. Handle the received Tweet objects and render them in the ListView. **Assume that the url always return the new tweets & you should append the tweets to the items in the List**.
 
-3. Add a refresh menu item which upon click should make an HTTP GET call to get new array of tweets and append the new data to list.
+3. Add a refresh menu item which upon click should make an HTTP GET call to get new array of tweets and append the new data to list. The refresh should simply call the */tweets* url & append the tweets to the list.
 

From 975d2b30781d56b256521fcf6341f1fb94546153 Mon Sep 17 00:00:00 2001
From: pocha 
Date: Fri, 6 Jun 2014 00:59:53 +0530
Subject: [PATCH 02/17] English error correction in twitter4j lesson

---
 .../_real_twitter_with_twitter4j.html.md                  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/twitter-http-challenge/_real_twitter_with_twitter4j.html.md b/twitter-http-challenge/_real_twitter_with_twitter4j.html.md
index b0b5391..833973f 100644
--- a/twitter-http-challenge/_real_twitter_with_twitter4j.html.md
+++ b/twitter-http-challenge/_real_twitter_with_twitter4j.html.md
@@ -16,9 +16,9 @@ For using Twitter4J library, you need to register an app at [http://dev.twitter.
 
 1)  Modify MainActivity.java to have only one 'Sign in with Twitter' button . Remove the LinearLayouts containing username & password fields. Hook up the button with Twitter4J so that the user gets redirected to Twitter for authentication.
 
-2) Our tests will not be access the webView & fill in the data. Our tests will be using @DroidChallenge user oAuth token to test your app. We need to mandate that you should store the token details in your app in **codelearn_twitter** SharedPreference with key **key_acc_token** for the token & **key_acc_token_secret** for the secret. We are simply going to write @DroidChallenge token values to these keys in the SharedPreference to test your app on our server.
+2) Our tests will not be able to access the webView & fill in the data once user gets redirected to Twitter. Our tests will be using @DroidChallenge user oAuth token to test your app. We need to mandate that you should store the token details in your app in **codelearn_twitter** SharedPreference with key **key_acc_token** for the token & **key_acc_token_secret** for the secret. We are simply going to write @DroidChallenge token values to these keys in the SharedPreference to test your app on our server.
 
-**P.S. - We will not get your twitter account token details this way & the app will not post as you when run on our server. Just pause & think for a minute if you do not get it.**
+**P.S. - We will not get your twitter account token details this way & the app will not post as you when run on our server. Just pause & think for a minute if you are still in doubt.**
 
 It is a good practice to store these names in TwitterConstants.java
 
@@ -85,6 +85,6 @@ It is a good practice to store these names in TwitterConstants.java
 	
 
   
-  Add the logic to post the tweet on button click.
+  **Add the logic to post the tweet on button click.**
 
-4) Add a menu item on TweetListActivity to take user to ComposeTweetActivity**. Overall, there should only be two menu items - the first for Refresh of tweets, the second one for compose tweet. 
+4) Add a menu item on TweetListActivity to take user to **ComposeTweetActivity**. Overall, there should only be two menu items - the first for Refresh of tweets, the second one for compose tweet. 

From 03e31bb0159f5a50b272075f80ef1bd0bac83b43 Mon Sep 17 00:00:00 2001
From: pocha 
Date: Fri, 6 Jun 2014 02:41:28 +0530
Subject: [PATCH 03/17] updated instructions for twitter4j level

---
 .../_real_twitter_with_twitter4j.html.md      | 84 ++++++++++++++++++-
 1 file changed, 80 insertions(+), 4 deletions(-)

diff --git a/twitter-http-challenge/_real_twitter_with_twitter4j.html.md b/twitter-http-challenge/_real_twitter_with_twitter4j.html.md
index db67f6c..b0b5391 100644
--- a/twitter-http-challenge/_real_twitter_with_twitter4j.html.md
+++ b/twitter-http-challenge/_real_twitter_with_twitter4j.html.md
@@ -6,9 +6,85 @@ So far, the challenge involved the usage of the Codelearn Twitter API, which pro
 
 Refer to the [Javadoc](http://twitter4j.org/en/javadoc.html) and [code examples](http://twitter4j.org/en/code-examples.html) provided by Twitter4J.
 
-###Tasks
-* Insert the relevant JAR files into your Eclipse project
-* Register at [dev.twitter.com](https://dev.twitter.com) and obtain consumer key and secret for your Twitter application.
-* Replace the existing HTTP network mechanisms for logging in, fetching tweets and submitting new tweets with the methods provided by Twitter4J.
+For using Twitter4J library, you need to register an app at [http://dev.twitter.com/apps](http://dev.twitter.com/apps). For your convenience, we have created an app & you can use the API key & secret (reproduced below). It is a good practice to create a separate class `TwitterConstants.java` and define these as static variables to be used in your app
 
+     public static String CONSUMER_KEY = "pC3D9eMxb8pXNAPhBHAQFYLoS";
+     public static String CONSUMER_SECRET = "8qhOLjLHiqLQJLLQUnBNSlnUoFtbLHjWQlnaxS5W3n6NkkUeOi";
 
+    
+### Tasks
+
+1)  Modify MainActivity.java to have only one 'Sign in with Twitter' button . Remove the LinearLayouts containing username & password fields. Hook up the button with Twitter4J so that the user gets redirected to Twitter for authentication.
+
+2) Our tests will not be access the webView & fill in the data. Our tests will be using @DroidChallenge user oAuth token to test your app. We need to mandate that you should store the token details in your app in **codelearn_twitter** SharedPreference with key **key_acc_token** for the token & **key_acc_token_secret** for the secret. We are simply going to write @DroidChallenge token values to these keys in the SharedPreference to test your app on our server.
+
+**P.S. - We will not get your twitter account token details this way & the app will not post as you when run on our server. Just pause & think for a minute if you do not get it.**
+
+It is a good practice to store these names in TwitterConstants.java
+
+`TwitterConstants.java`
+
+	public static final String SHARED_PREFERENCE = "codelearn_twitter";
+	public static final String PREF_KEY_TOKEN = "key_acc_token";
+	public static final String PREF_KEY_SECRET = "key_acc_token_secret"; 
+
+& use it where it is required 
+
+`MainActivity.java`
+
+	prefs = getSharedPreferences(TwitterConstants.SHARED_PREFERENCE, MODE_PRIVATE);
+	Editor editor = prefs.edit();
+	editor.putString(TwitterConstants.PREF_KEY_TOKEN, accessToken.getToken());
+	editor.putString(TwitterConstants.PREF_KEY_SECRET, accessToken.getTokenSecret());
+
+2) Once the user gets authenticated with Twitter, he should automatically go to TweetListActivity where he can see his tweets. Modify the logic so that **only new tweets are fetched & appended to the tweet list**.
+
+3) Create a new Activity **ComposeTweetActivity** to compose a tweet. Make sure to keep the name exactly the same, also the Activity should extend normal Activity & not ActionBarActivity. A corresponding layout file **activity_compose_tweet.xml** will get generated. Replace the content of the file with the content below
+
+
+	
+
+	    
+
+	    
+
+