- * Initialization of this object is only needed for authorization, posting can be done statically once the users tokens are stored. - * @author ricky barrette - */ - public TwitterServices(Context context) { - shared_prefs = context.getSharedPreferences(TravelPost.SETTINGS, 0); - twitter = new TwitterFactory().getInstance(); - twitter.setOAuthConsumer(TRAVEL_PORT_OAUTH_KEY, TRAVEL_PORT_OAUTH_SECRET); - } - - /** - * @return Authorization URL - * @throws TwitterException - * @author ricky barrette - */ - public String getAuthorizationURL() throws TwitterException{ - requestToken = twitter.getOAuthRequestToken(); - return requestToken.getAuthorizationURL(); - } - - /** - * Saves the authorization tokens for future use - * @param authorizationCode - * @return true if save was successful - * @throws TwitterException - * @author ricky barrette - */ - public boolean saveAuthorizationTokens(String authorizationCode) throws TwitterException{ - AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, authorizationCode); - Log.v(TravelPost.TAG,"saving twitter tokens"); - Editor e = shared_prefs.edit(); - e.putString(TWITTER_AUTH_TOKEN, accessToken.getToken()).commit(); - e.putString(TWITTER_AUTH_SECRET, accessToken.getTokenSecret()).commit(); - return e.commit(); - } - -} \ No newline at end of file diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/WebAuth.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/WebAuth.java deleted file mode 100644 index 626b9ca..0000000 --- a/TravelPost/src/com/TwentyCodes/android/TravelPost/WebAuth.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * WebAuth.java - * @date Jan 24, 2011 - * @author ricky barrette - * @author Twenty Codes, LLC - */ -package com.TwentyCodes.android.TravelPost; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.view.View.OnClickListener; -import android.webkit.WebView; -import android.widget.EditText; - -/** - * a simple activity that will be started to display the social client auth code for a result (user entered auth code). - * @author ricky barrette - */ -public class WebAuth extends Activity implements OnClickListener { - - public static final String AUTH_URL = "auth_url"; - public static final String AUTH_CODE = "auth_code"; - private EditText mAuthCode; - - /** - * called when the activity is first created - * (non-Javadoc) - * @see android.app.Activity#onCreate(android.os.Bundle) - * @author ricky barrette - */ - @Override - public void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - this.setContentView(R.layout.webauth); - WebView webView = (WebView) findViewById(R.id.authWebView); - webView.loadUrl(this.getIntent().getStringExtra(AUTH_URL)); - webView.requestFocus(View.FOCUS_DOWN); - - findViewById(R.id.authOkButton).setOnClickListener(this); - mAuthCode = (EditText) findViewById(R.id.authCode); - } - - /** - * called when the ok button is clicked - * (non-Javadoc) - * @see android.view.View.OnClickListener#onClick(android.view.View) - * @author ricky barrette - */ - @Override - public void onClick(View v) { - setResult(RESULT_OK, new Intent().putExtra(AUTH_CODE, mAuthCode.getText().toString())); - finish(); - } -} \ No newline at end of file