Commit a06cbf10 authored by Aubrey Colter's avatar Aubrey Colter Committed by Gerrit Review System

Replacing the twitter4j jar required some minor code tweaks:

Removing all of the synchronization (and thus the unnecessary variables myTwitter and myUserId)
Search is no longer anonymous in twitter4j, so I only create one instance of twitter and use it in Search as well.
Fixing a few of the blocks that broke because of method signatures that changed.
CheckAuthorized() (checkAccessCode())
Follow()
StopFollowing()
RequestFollowers()
Added the @UsesLibraries annotation that was missing in the broken code. Code is fixed, ready to publish.
Fixed the formatting to be compatible with app-inventor style.
Removed the volatile keyword on the variables because it is no longer necessary.
Moved the setOAuth back into the try block at Jose's suggestion.
Added catch (IllegalStateException) block. Andrew and I determined this should return true because the user is valid, twitter4j does not allow the OAuth to be set again.
Updated documentation to reflect changes in code.
Change-Id: Ibaa8564ac0a154992340c8fef2e6c3e84a0ff042
parent 8ef1932d
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<pathelement location="lib/keyczar/keyczar-0.66-080111-java-1.6.jar" /> <pathelement location="lib/keyczar/keyczar-0.66-080111-java-1.6.jar" />
<pathelement location="lib/objectify-3.0/objectify-3.0.jar" /> <pathelement location="lib/objectify-3.0/objectify-3.0.jar" />
<pathelement location="lib/tablelayout/TableLayout-jdk1.5-2007-04-21.jar" /> <pathelement location="lib/tablelayout/TableLayout-jdk1.5-2007-04-21.jar" />
<pathelement location="lib/twitter/twitter4j-2.0.10-SNAPSHOT.jar" /> <pathelement location="lib/twitter/twitter4j-core-android-2.2.6.jar" />
<fileset dir="buildserver/lib" includes="**/*.jar"/> <fileset dir="buildserver/lib" includes="**/*.jar"/>
<!-- gwt libs --> <!-- gwt libs -->
<pathelement location="lib/gwt/2.3.0/gwt-dev.jar"/> <pathelement location="lib/gwt/2.3.0/gwt-dev.jar"/>
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
</copy> </copy>
<copy toFile="${classes.files.dir}/YailGenerator.jar" file="${local.build.dir}/YailGenerator.jar" /> <copy toFile="${classes.files.dir}/YailGenerator.jar" file="${local.build.dir}/YailGenerator.jar" />
<copy toFile="${classes.files.dir}/kawa.jar" file="${lib.dir}/kawa/kawa-1.11-modified.jar" /> <copy toFile="${classes.files.dir}/kawa.jar" file="${lib.dir}/kawa/kawa-1.11-modified.jar" />
<copy toFile="${classes.files.dir}/twitter4j.jar" file="${lib.dir}/twitter/twitter4j-2.0.10-SNAPSHOT.jar" /> <copy toFile="${classes.files.dir}/twitter4j.jar" file="${lib.dir}/twitter/twitter4j-core-android-2.2.6.jar" />
<copy toFile="${classes.files.dir}/fusiontables.jar" file="${lib.dir}/fusiontables/fusiontables.jar" /> <copy toFile="${classes.files.dir}/fusiontables.jar" file="${lib.dir}/fusiontables/fusiontables.jar" />
<copy toFile="${classes.files.dir}/google-api-client-beta.jar" file="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" /> <copy toFile="${classes.files.dir}/google-api-client-beta.jar" file="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" />
<copy toFile="${classes.files.dir}/google-http-client-beta.jar" file="${lib.dir}/oauth/google-http-client-1.10.3-beta.jar" /> <copy toFile="${classes.files.dir}/google-http-client-beta.jar" file="${lib.dir}/oauth/google-http-client-1.10.3-beta.jar" />
......
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
<pathelement location="${public.build.dir}/CommonConstants.jar" /> <pathelement location="${public.build.dir}/CommonConstants.jar" />
<pathelement location="${lib.dir}/android/2.2/android.jar" /> <pathelement location="${lib.dir}/android/2.2/android.jar" />
<pathelement location="${lib.dir}/kawa/kawa-1.11-modified.jar" /> <pathelement location="${lib.dir}/kawa/kawa-1.11-modified.jar" />
<pathelement location="${lib.dir}/twitter/twitter4j-2.0.10-SNAPSHOT.jar" /> <pathelement location="${lib.dir}/twitter/twitter4j-core-android-2.2.6.jar" />
<pathelement location="${lib.dir}/fusiontables/fusiontables.jar" /> <pathelement location="${lib.dir}/fusiontables/fusiontables.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" /> <pathelement location="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-android2-1.10.3-beta.jar" /> <pathelement location="${lib.dir}/oauth/google-api-client-android2-1.10.3-beta.jar" />
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
<pathelement location="${lib.dir}/android/2.2/android.jar" /> <pathelement location="${lib.dir}/android/2.2/android.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" /> <pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
<pathelement location="${lib.dir}/kawa/kawa-1.11-modified.jar" /> <pathelement location="${lib.dir}/kawa/kawa-1.11-modified.jar" />
<pathelement location="${lib.dir}/twitter/twitter4j-2.0.10-SNAPSHOT.jar" /> <pathelement location="${lib.dir}/twitter/twitter4j-core-android-2.2.6.jar" />
<pathelement location="${lib.dir}/fusiontables/fusiontables.jar" /> <pathelement location="${lib.dir}/fusiontables/fusiontables.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" /> <pathelement location="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-android2-1.10.3-beta.jar" /> <pathelement location="${lib.dir}/oauth/google-api-client-android2-1.10.3-beta.jar" />
......
...@@ -944,17 +944,11 @@ ...@@ -944,17 +944,11 @@
This component allows users to interact with Twitter. This component allows users to interact with Twitter.
</p> </p>
<p> <p>
This non-visible component enables communication with Twitter. Methods are included This non-visible component enables communication with Twitter. Once a user has logged in (
to enable searching (
<code>
SearchTwitter
</code>
) and logging in to Twitter
(
<code> <code>
Authorize Authorize
</code> </code>
). Once a user has logged in and the login has been ) and the login has been
confirmed successful by the confirmed successful by the
<code> <code>
IsAuthorized IsAuthorized
...@@ -963,6 +957,13 @@ ...@@ -963,6 +957,13 @@
following methods: following methods:
</p> </p>
<ul> <ul>
<li>
Search Twitter for tweets or labels (
<code>
SearchTwitter
</code>
).
</li>
<li> <li>
Set the status of the logged-in user ( Set the status of the logged-in user (
<code> <code>
...@@ -1007,7 +1008,7 @@ ...@@ -1007,7 +1008,7 @@
). ).
</li> </li>
<li> <li>
Get the most recent messages of followed users Get the most recent messages in the user's timeline.
( (
<code> <code>
RequestFriendTimeline RequestFriendTimeline
...@@ -1024,8 +1025,8 @@ ...@@ -1024,8 +1025,8 @@
</li> </li>
</ul> </ul>
<p> <p>
In general, you invoke one of these methods and the result will bcome available In general, you invoke one of these methods and the result will become available
when the corresponding recipt event is signalled. For example, if you call when the corresponding receipt event is signaled. For example, if you call
<code> <code>
RequestFollowers RequestFollowers
</code> </code>
...@@ -1034,10 +1035,9 @@ ...@@ -1034,10 +1035,9 @@
FollowersReceived FollowersReceived
</code> </code>
event will event will
be signalled when the list of followers is available. This might take time, because be signaled when the list of followers is available. This might take time, because
the request is going over the web; the result might even never become available, the request is going over the web; the result might even never become available if,
for example, if your device is not connected to the web or the Twitter web site is for example, your device is not connected to the web or the Twitter web site is down.
down.
</p> </p>
<p> <p>
Login is handled using the OAuth protocol, as required by the Twitter API ( Login is handled using the OAuth protocol, as required by the Twitter API (
...@@ -1050,19 +1050,12 @@ ...@@ -1050,19 +1050,12 @@
<code> <code>
Authorize Authorize
</code> </code>
. This causes a Twitter login page to . This loads a Twitter login page that will allow the user to login with their username and password, and then return appropriate credentials to the Twitter component in the
be presented that will allow the user to login with their username and password if
necessary, and then return appropriate credentials to the Twitter component in the
app. Once the Twitter component has the credentials the app. Once the Twitter component has the credentials the
<code> <code>
IsAuthorized IsAuthorized
</code> </code>
event is raised to let the app know that it can proceed with Twitter API calls. The event is raised to let the app know that it can proceed with Twitter API calls. An app retains Twitter credentials across invocations,
only Twitter component method that does not require the user to be authenticated is
<code>
SearchTwitter
</code>
. An app retains Twitter credentials across invocations,
so it may not be necessary for the user to login each time he or she uses the app. so it may not be necessary for the user to login each time he or she uses the app.
Reinstalling an app will clear the credentials, as will calling the Reinstalling an app will clear the credentials, as will calling the
<code> <code>
...@@ -1085,7 +1078,7 @@ ...@@ -1085,7 +1078,7 @@
Important: Important:
</b> </b>
Most of the operation of the OAuth protocol is hidden inside the Most of the operation of the OAuth protocol is hidden inside the
Twitter component and you do not need to understand how it works in order to use Twitter component and you do not need to understand how it works to use
the component. However, it is necessary for anyone building an app with the Twitter the component. However, it is necessary for anyone building an app with the Twitter
component to supply a component to supply a
<i> <i>
...@@ -1320,7 +1313,7 @@ ...@@ -1320,7 +1313,7 @@
<code> <code>
RequestMentions RequestMentions
</code> </code>
has have
been retrieved. been retrieved.
</dd> </dd>
<dt> <dt>
...@@ -1367,11 +1360,7 @@ ...@@ -1367,11 +1360,7 @@
</dt> </dt>
<dd> <dd>
Removes authorization from this running app instance. A user will have to Removes authorization from this running app instance. A user will have to
login again to use any Twitter method other than login again to use any Twitter method.
<code>
SearchTwitter
</code>
.
</dd> </dd>
<dt> <dt>
<code> <code>
...@@ -1412,7 +1401,7 @@ ...@@ -1412,7 +1401,7 @@
</dt> </dt>
<dd> <dd>
Retrieves the 20 most recent messages in your timeline. Returns a list of Retrieves the 20 most recent messages in your timeline. Returns a list of
tuples (sub-lists), where each tuple contains username and status message. tuples (sub-lists), where each tuple contains a username and status message.
</dd> </dd>
<dt> <dt>
<code> <code>
...@@ -1420,7 +1409,7 @@ ...@@ -1420,7 +1409,7 @@
</code> </code>
</dt> </dt>
<dd> <dd>
Retrieves the most mentions of the user. Retrieves the most recent mentions of the user.
</dd> </dd>
<dt> <dt>
<code> <code>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment