Skip to content

Commit

Permalink
Small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed Jul 30, 2012
0 parents commit 6149693
Show file tree
Hide file tree
Showing 154 changed files with 10,486 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .gitignore
@@ -0,0 +1,25 @@
# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/
out/
.idea/

# Eclipse project files
.classpath
.project
/.settings/org.eclipse.jdt.core.prefs
/.settings/org.eclipse.jdt.core.prefs.bak
*.settings
*.properties
*.iml
proguard-project.txt
14 changes: 14 additions & 0 deletions AndroidManifest.xml
@@ -0,0 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.teamboid.twitterapi"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />

<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">

</application>

</manifest>
2 changes: 2 additions & 0 deletions README.md
@@ -0,0 +1,2 @@
## Visit the [Wiki](https://github.com/afollestad/Boid-Twitter-API/wiki) for tutorials on how to use the library in your applications.
## [Generated JavaDoc](http://afollestad.github.com/Boid-Twitter-API/JavaDoc/) is also available that I try to keep as up to date as possible.
Binary file added Wiki Images/screen_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki Images/screen_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki Images/screen_3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki Images/screen_4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added libs/apache-mime4j-core-0.7.2.jar
Binary file not shown.
Binary file added libs/commons-codec-1.6.jar
Binary file not shown.
Binary file added libs/httpcore-4.2.1.jar
Binary file not shown.
Binary file added libs/httpmime-4.2.1.jar
Binary file not shown.
Binary file added res/drawable-hdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions res/values-v11/styles.xml
@@ -0,0 +1,5 @@
<resources>

<style name="AppTheme" parent="android:Theme.Holo.Light" />

</resources>
5 changes: 5 additions & 0 deletions res/values-v14/styles.xml
@@ -0,0 +1,5 @@
<resources>

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />

</resources>
3 changes: 3 additions & 0 deletions res/values/strings.xml
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Boid_API</string>
</resources>
5 changes: 5 additions & 0 deletions res/values/styles.xml
@@ -0,0 +1,5 @@
<resources>

<style name="AppTheme" parent="android:Theme.Light" />

</resources>
129 changes: 129 additions & 0 deletions src/com/teamboid/twitterapi/client/Authorizer.java
@@ -0,0 +1,129 @@
package com.teamboid.twitterapi.client;

import org.scribe.builder.ServiceBuilder;
import org.scribe.builder.api.TwitterApi;
import org.scribe.model.Token;
import org.scribe.model.Verifier;
import org.scribe.oauth.OAuthService;

/**
* Used to authenticate accounts and get logged in instances of {@link Twitter}
*
* @author Aidan Follestad
*/
public class Authorizer {

private Authorizer(String consumer, String secret, String callback) {
service = new ServiceBuilder()
.provider(TwitterApi.class)
.apiKey(consumer)
.apiSecret(secret)
.callback(callback)
.build();
_debugMode = DebugLevel.OFF;
}

public static enum DebugLevel {
/**
* Debug mode is off. Default.
*/
OFF,
/**
* Requested URLs will be printed to the console.
*/
LIGHT,
/**
* Requested URLs and received raw JSON will be printed to the console.
*/
DEEP
}

private OAuthService service;
private Token requestToken;
private DebugLevel _debugMode;
private boolean _ssl;

/**
* Intializes a new Authorizer for generating authenticated {@link Twitter} instances.
* @param consumer The OAuth consumer of your application that's registered on dev.twitter.com.
* @param secret The OAuth secret of your application that's registered on dev.twitter.com.
* @param callback The callback URL called after the user authorizes their account on the web page returned from getUrl().
* @return A new Authorizer instance
*/
public static Authorizer create(String consumer, String secret, String callback) {
return new Authorizer(consumer, secret, callback);
}

/**
* This method is used to get an un-authorized {@link Twitter} instance; it will
* not have permission to request protected resources (any functions that require you
* to be logged in).
*/
public Twitter getUnauthorizedInstance() {
TwitterBase toReturn = new TwitterBase();
toReturn._debugOn = _debugMode;
toReturn._ssl = _ssl;
return toReturn;
}

/**
* This method is used to get an authorized {@link Twitter} instance if you had already gotten
* authorization previously and stored the returned access token.
* @param accessKey The access key previously stored.
* @param accessSecret The access secret preeviously stored.
* @return An authenticated Twitter instance.
*/
public Twitter getAuthorizedInstance(String accessKey, String accessSecret) {
TwitterBase toReturn = new TwitterBase();
toReturn._debugOn = _debugMode;
toReturn._ssl = _ssl;
toReturn._oauthToken = new Token(accessKey, accessSecret);
toReturn._oauth = service;
return toReturn;
}

/**
* The method called after your receive a callback from the web browser (after using getUrl()).
* @param verifier The oauth_verifier paramter sent from the browser through the callback.
*/
public Twitter getAuthorizedInstance(String verifier) throws Exception {
if(requestToken == null) {
throw new Exception("There's no request token in the current Authorizer state, you must call getAuthorizeUrl() on the same Authorizer first.");
}
TwitterBase toReturn = new TwitterBase();
toReturn._debugOn = _debugMode;
toReturn._ssl = _ssl;
toReturn._oauthToken = service.getAccessToken(requestToken, new Verifier(verifier));
toReturn._oauth = service;
return toReturn;
}

/**
* The initial step of authentication, returns the URL of Twitter's authorization page that you must open
* in the web browser. When they login and click 'Authorize', the callback you specified in the constructor
* will be invoked. Make sure your app is set up to receive this callback and use the callback() method.
* @return
*/
public String getAuthorizeUrl() throws Exception {
requestToken = service.getRequestToken();
return service.getAuthorizationUrl(requestToken);
}

/**
* Sets whether or not SSL will be used with requests to Twitter. Defaults as true.
*
* @deprecated Use {@link Twitter#setSslEnabled(boolean)} instead.
*/
public Authorizer setUseSSL(boolean ssl) {
_ssl = ssl;
return this;
}

/**
* Sets whether or not debug is on, and what level of output it's creates.
*/
public Authorizer setDebugMode(DebugLevel debug) {
_debugMode = debug;
return this;
}
}
18 changes: 18 additions & 0 deletions src/com/teamboid/twitterapi/client/HttpParam.java
@@ -0,0 +1,18 @@
package com.teamboid.twitterapi.client;

/**
* @author Aidan Follestad
*/
public class HttpParam {

public HttpParam(String name, String value) {
_name = name;
_value = value;
}

private String _name;
private String _value;

public String getName() { return _name; }
public String getValue() { return _value; }
}
102 changes: 102 additions & 0 deletions src/com/teamboid/twitterapi/client/Paging.java
@@ -0,0 +1,102 @@
package com.teamboid.twitterapi.client;

/**
* Passes paging information to any API functions that can include page, count, since_id, or max_id parameters.
* @author Aidan Follestad
*/
public class Paging {

/**
* Initializes new Paging instance.
* @param count The number of results to retrieve.
*/
public Paging(int count) {
_count = count;
}
/**
* Initializes new Paging instance.
* @param count The number of results to retrieve.
* @param sinceId Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
* @param maxId Returns results with an ID less than (that is, older than) or equal to the specified ID.
*/
public Paging(int count, long sinceId, long maxId) {
_count = count;
_sinceId = sinceId;
_maxId = maxId;
}

private int _page;
private int _count;
private long _sinceId;
private long _maxId;

/**
* @deprecated See https://dev.twitter.com/docs/working-with-timelines
*/
public int getPage() { return _page; }
public int getCount() { return _count; }
public long getSinceId() { return _sinceId; }
public long getMaxId() { return _maxId; }

/**
* @deprecated See https://dev.twitter.com/docs/working-with-timelines
*/
public Paging setPage(int page) {
_page = page;
return this;
}

public Paging setCount(int count) {
_count = count;
return this;
}

public Paging setSinceId(long sinceId) {
_sinceId = sinceId;
return this;
}

public Paging setMaxId(long maxId) {
_maxId = maxId;
return this;
}

public String getUrlString(char startingCharacter, boolean includeSinceMaxId) {
String toReturn = "";
boolean insertedStarting = false;
if(_page > 0) {
toReturn += startingCharacter;
insertedStarting = true;
toReturn += "page=" + _page;
}
if(_count > 0) {
if(!insertedStarting) {
toReturn += startingCharacter;
insertedStarting = true;
} else toReturn += "&";
toReturn += "count=" + _count;
}
if(includeSinceMaxId) {
if(_sinceId > 0) {
if(!insertedStarting) {
toReturn += startingCharacter;
insertedStarting = true;
} else toReturn += "&";
toReturn += "since_id=" + _sinceId;
}
if(_maxId > 0) {
if(!insertedStarting) {
toReturn += startingCharacter;
insertedStarting = true;
} else toReturn += "&";
toReturn += "max_id=" + _maxId;
}
}
return toReturn;
}

@Override
public String toString() {
return getUrlString('?', true);
}
}
24 changes: 24 additions & 0 deletions src/com/teamboid/twitterapi/client/ProfileImageSize.java
@@ -0,0 +1,24 @@
package com.teamboid.twitterapi.client;

/**
* Used to specify {@link Twitter#getUserProfileImage(String, ProfileImageSize)} image sizes.
* @author Aidan Follestad
*/
public enum ProfileImageSize {
/**
* Undefined. This will be the size the image was originally uploaded in. The filesize of original images can be very big so use this parameter with caution.
*/
ORIGINAL,
/**
* 24px by 24px
*/
MINI,
/**
* 48px by 48px
*/
NORMAL,
/**
* 73px by 73px
*/
BIGGER
}

0 comments on commit 6149693

Please sign in to comment.