This commit is contained in:
warren powers
2011-03-12 18:38:42 +00:00
parent 3c1415e059
commit 0e8bf9a40e
35 changed files with 0 additions and 1675 deletions

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="libs/twitter4j-core-2.1.11.jar"/>
<classpathentry kind="lib" path="/LocationLib/lib/wpsapi.jar">
<attributes>
<attribute name="javadoc_location" value="http://tcdevsvn1/ShyHookdocumentation"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="FacebookLib_src"/>
<classpathentry kind="src" path="LocationLib_src"/>
<classpathentry kind="src" path="ExceptionHandlerLib_src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by Code Pro -->
<entry-points
version="1">
<explicit-entry-points/>
<include-main
enabled="true"/>
<include-tests
enabled="false"/>
<include-xml
enabled="true"/>
</entry-points>

View File

@@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TravelPost</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>ExceptionHandlerLib_src</name>
<type>2</type>
<locationURI>_android_ExceptionHandlerLib_7d68b46a/src</locationURI>
</link>
<link>
<name>FacebookLib_src</name>
<type>2</type>
<locationURI>_android_FacebookLib_9c84f9bf/src</locationURI>
</link>
<link>
<name>LocationLib_src</name>
<type>2</type>
<locationURI>_android_LocationLib_84551a70/src</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

@@ -1,47 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.TwentyCodes.android.TravelPost" android:versionName="0.0.0" android:versionCode="5" android:installLocation="internalOnly">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:label="@string/app_name"
android:configChanges="orientation" android:name="TravelPost">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="LocationReceiver" android:exported="true"
android:enabled="true" android:process=":locationreceiver">
<intent-filter>
<action android:name="TwentyCodes.TravelPost.intent.action.LocationUpdate" />
</intent-filter>
</receiver>
<receiver android:label="@string/app_name" android:name="TravelPostWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/travelpostwidgetinfo"/>
</receiver>
<service android:process=":TravelPostLocationService" android:enabled="true" android:exported="true" android:name="com.TwentyCodes.android.location.LocationService"></service>
<activity android:name="WebAuth" android:configChanges="orientation"></activity>
<activity android:name="PostActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.READ_LOGS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>

View File

@@ -1,10 +0,0 @@
changed postToWall() to postWall() in FacebookAuth.java.
created method postToWall(). this method should post without user interaction
in FacebookAuth.java i splite the init() method into two. authorize() and logout().
created postToWallDialog() in FacebookAuth.java to display a dialog when posting to wall.
t seems the facebook sdk is not saving an access token when trying to make a direct facebook graph request.
it does save the access token when calling a dialog but prompts for credentials. i believe the authorization process is failing. not sure why. still researching.

View File

@@ -1,16 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=Google Inc.:Google APIs:9
proguard.config=proguard.cfg
android.library.reference.1=../FacebookLib/
android.library.reference.2=../LocationLib
android.library.reference.3=../ExceptionHandlerLib

View File

@@ -1,62 +0,0 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.TwentyCodes.android.TravelPost;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int facebook_icon=0x7f020000;
public static final int icon=0x7f020001;
public static final int logoidea3=0x7f020002;
public static final int sign_post_icon=0x7f020003;
public static final int sign_post_icon_mod=0x7f020004;
public static final int skyhook_logo=0x7f020005;
public static final int skyhook_logo_alpha=0x7f020006;
public static final int skyhook_logo_alpha_small=0x7f020007;
public static final int tc_logo_complete=0x7f020008;
public static final int user=0x7f020009;
public static final int widget=0x7f02000a;
}
public static final class id {
public static final int authCode=0x7f060007;
public static final int authOkButton=0x7f060006;
public static final int authWebView=0x7f060008;
public static final int post=0x7f060001;
public static final int postOkButton=0x7f060000;
public static final int skyhook_img=0x7f060002;
public static final int tc_img=0x7f060004;
public static final int text=0x7f060003;
public static final int widgetbutton=0x7f060005;
}
public static final class layout {
public static final int main=0x7f030000;
public static final int post=0x7f030001;
public static final int powered_by_skyhook=0x7f030002;
public static final int travelpostwidget=0x7f030003;
public static final int webauth=0x7f030004;
}
public static final class string {
public static final int about=0x7f050007;
public static final int app_name=0x7f050001;
public static final int fb_signin=0x7f050005;
public static final int gps_fix=0x7f050002;
public static final int hello=0x7f050000;
public static final int location_settings=0x7f050006;
public static final int post_hint=0x7f05000b;
public static final int post_settings=0x7f050008;
public static final int save_a_post=0x7f050009;
public static final int services=0x7f05000a;
public static final int sorry_theres_trouble=0x7f050003;
public static final int twitter_signin=0x7f050004;
}
public static final class xml {
public static final int settings=0x7f040000;
public static final int travelpostwidgetinfo=0x7f040001;
}
}

View File

@@ -1,62 +0,0 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.TwentyCodes.android.exception;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int facebook_icon=0x7f020000;
public static final int icon=0x7f020001;
public static final int logoidea3=0x7f020002;
public static final int sign_post_icon=0x7f020003;
public static final int sign_post_icon_mod=0x7f020004;
public static final int skyhook_logo=0x7f020005;
public static final int skyhook_logo_alpha=0x7f020006;
public static final int skyhook_logo_alpha_small=0x7f020007;
public static final int tc_logo_complete=0x7f020008;
public static final int user=0x7f020009;
public static final int widget=0x7f02000a;
}
public static final class id {
public static final int authCode=0x7f060007;
public static final int authOkButton=0x7f060006;
public static final int authWebView=0x7f060008;
public static final int post=0x7f060001;
public static final int postOkButton=0x7f060000;
public static final int skyhook_img=0x7f060002;
public static final int tc_img=0x7f060004;
public static final int text=0x7f060003;
public static final int widgetbutton=0x7f060005;
}
public static final class layout {
public static final int main=0x7f030000;
public static final int post=0x7f030001;
public static final int powered_by_skyhook=0x7f030002;
public static final int travelpostwidget=0x7f030003;
public static final int webauth=0x7f030004;
}
public static final class string {
public static final int about=0x7f050007;
public static final int app_name=0x7f050001;
public static final int fb_signin=0x7f050005;
public static final int gps_fix=0x7f050002;
public static final int hello=0x7f050000;
public static final int location_settings=0x7f050006;
public static final int post_hint=0x7f05000b;
public static final int post_settings=0x7f050008;
public static final int save_a_post=0x7f050009;
public static final int services=0x7f05000a;
public static final int sorry_theres_trouble=0x7f050003;
public static final int twitter_signin=0x7f050004;
}
public static final class xml {
public static final int settings=0x7f040000;
public static final int travelpostwidgetinfo=0x7f040001;
}
}

View File

@@ -1,34 +0,0 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@android:string/ok"
android:id="@+id/postOkButton"
android:layout_alignBottom="@+id/post"
android:layout_alignTop="@id/post"
android:layout_alignParentRight="true"></Button>
<EditText android:layout_toLeftOf="@id/postOkButton"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:hint="@string/post_hint"
android:id="@id/post">
</EditText>
</RelativeLayout>
</RelativeLayout>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageButton
android:id="@+id/widgetbutton"
android:layout_gravity="center_horizontal"
android:background="@drawable/widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ok"
android:id="@+id/authOkButton"
android:layout_alignBottom="@+id/authCode"
android:layout_alignParentRight="true"></Button>
<EditText
android:layout_toLeftOf="@id/authOkButton"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:hint="Auth Code"
android:id="@+id/authCode">
</EditText>
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/authCode"
android:id="@+id/authWebView"
android:layout_alignParentTop="true">
</WebView>
</RelativeLayout>

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World!</string>
<string name="app_name">Travel Post</string>
<string name="twitter_signin">Twitter Sign In</string>
<string name="fb_signin">Facebook Sign In</string>
<string name="location_settings">Location Settings</string>
<string name="about">About</string>
<string name="post_settings">Post Settings</string>
<string name="save_a_post">Save a post</string>
<string name="services">Social Services</string>
<string name="post_hint">Whats up?</string>
</resources>

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/app_name">
<PreferenceCategory android:title="@string/post_settings">
<CheckBoxPreference android:title="@string/save_a_post" android:key="save_a_post"></CheckBoxPreference>
<EditTextPreference android:key="saved_post" android:title="Post" android:dependency="save_a_post"></EditTextPreference>
</PreferenceCategory><PreferenceCategory
android:title="@string/services">
<Preference
android:title="@string/twitter_signin"
android:key="twitter_sign_in"/>
<Preference
android:title="@string/fb_signin"
android:key="facebook_sign_in"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/location_settings">
</PreferenceCategory><PreferenceCategory android:title="@string/about">
<com.TwentyCodes.android.TravelPost.TextViewPreference android:title="@string/hello"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="146dip"
android:minHeight="72dip"
android:updatePeriodMillis="10000"
android:initialLayout="@layout/travelpostwidget"/>

View File

@@ -1,25 +0,0 @@
package com.TwentyCodes.android.Facebook;
import com.facebook.android.DialogError;
import com.facebook.android.Facebook.DialogListener;
import com.facebook.android.FacebookError;
/**
* Skeleton base class for RequestListeners, providing default error
* handling. Applications should handle these error conditions.
*
*/
public abstract class BaseDialogListener implements DialogListener {
public void onFacebookError(FacebookError e) {
e.printStackTrace();
}
public void onError(DialogError e) {
e.printStackTrace();
}
public void onCancel() {
}
}

View File

@@ -1,41 +0,0 @@
package com.TwentyCodes.android.Facebook;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import android.util.Log;
import com.facebook.android.AsyncFacebookRunner.RequestListener;
import com.facebook.android.FacebookError;
/**
* Skeleton base class for RequestListeners, providing default error
* handling. Applications should handle these error conditions.
*
*/
public abstract class BaseRequestListener implements RequestListener {
public void onFacebookError(FacebookError e, final Object state) {
Log.e("Facebook", e.getMessage());
e.printStackTrace();
}
public void onFileNotFoundException(FileNotFoundException e,
final Object state) {
Log.e("Facebook", e.getMessage());
e.printStackTrace();
}
public void onIOException(IOException e, final Object state) {
Log.e("Facebook", e.getMessage());
e.printStackTrace();
}
public void onMalformedURLException(MalformedURLException e,
final Object state) {
Log.e("Facebook", e.getMessage());
e.printStackTrace();
}
}

View File

@@ -1,263 +0,0 @@
package com.TwentyCodes.android.Facebook;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import com.TwentyCodes.android.Facebook.SessionEvents.AuthListener;
import com.TwentyCodes.android.Facebook.SessionEvents.LogoutListener;
import com.facebook.android.AsyncFacebookRunner;
import com.facebook.android.DialogError;
import com.facebook.android.Facebook;
import com.facebook.android.Facebook.DialogListener;
import com.facebook.android.FacebookError;
/**
* This class handles SSO for facebook.
* @author warren
*
*/
public class FacebookAuth {
private static final String[] PERMISSIONS = new String[] {"publish_stream"};
/* Permissions that are prompted to the user for authorization */
private static final String APP_ID = "197267276952565";
/* This is the api key for the facebook application. See /FacebookLib/APIS.txt */
private static final String TAG = "FacebookAuth";
private Facebook mFb;
private AsyncFacebookRunner mAsyncRunner;
private Context mCtx;
private Activity mActivity;
private Handler mHandler;
/**
* Constructor
* @param Context - context to work in
* @param Activity - current displayed activity
*/
public FacebookAuth(Context context, Activity activity) {
mCtx = context;
mActivity = activity;
mHandler = new Handler();
mFb = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(mFb);
SessionStore.restore(mFb, mCtx);
SessionEvents.addAuthListener(new FacebookAuthListener());
SessionEvents.addLogoutListener(new FacebookLogoutListener());
}
/**
* This method initializes the authorization process.
*/
public void init() {
Log.i(TAG, "init()");
if (mFb.isSessionValid()) {
/*
*These lines log out you out of facebook. For now commented out.
*/
// SessionEvents.onLogoutBegin();
// mAsyncRunner.logout(mCtx, new LogoutRequestListener());
} else {
mFb.authorize(mActivity, PERMISSIONS, new LoginDialogListener());
}
}
/**
* This method authorizes the facebook account
* @author warren
*/
public void authorize() throws NullPointerException {
if (!mFb.isSessionValid()) {
mFb.authorize(mActivity, PERMISSIONS, new LoginDialogListener());
}
}
/**
* This method starts the logout process
* @author warren
*/
public void logout() {
if (mFb.isSessionValid()) {
SessionEvents.onLogoutBegin();
mAsyncRunner.logout(mCtx, new LogoutRequestListener());
}
}
/**
* This method posts a message to the users wall
* @author warren
* @param msg - message to post
*/
public void postToWall(String msg) throws SessionNotValidException {
Log.d(TAG, "Testing graph API wall post");
if (mFb.isSessionValid()) {
try {
String response = mFb.request("me");
Bundle parameters = new Bundle();
parameters.putString("message", msg);
parameters.putString("description", "test test test");
response = mFb.request("me/feed", parameters, "POST");
Log.d(TAG, "got response: " + response);
if (response == null || response.equals("") || response.equals("false")) {
Log.v("Error", "Blank response");
}
} catch(Exception e) {
e.printStackTrace();
}
} else {
if (mFb.getAccessToken() == null) {
Log.i(TAG, "postToWall.access token is null");
}
throw new SessionNotValidException("This session is not valid");
}
}
/**
* Allows the user to post to their wall and input their own message
* @author warren
*/
public void postToWallDialog() {
mFb.dialog(mCtx, "feed", new FacebookDialogListener());
}
/**
* Handles facebook authorization callbacks.
* @author warren
*
*/
private class FacebookAuthListener implements AuthListener {
@Override
public void onAuthSucceed() {
SessionStore.save(mFb, mCtx);
Log.i(TAG, "FacebookAuthListener.onAuthSucceed()");
}
@Override
public void onAuthFail(String error) {
// TODO Auto-generated method stub
}
}
/**
* Handles facebook logout callbacks
* @author warren
*
*/
private class FacebookLogoutListener implements LogoutListener {
@Override
public void onLogoutBegin() {
// TODO Auto-generated method stub
}
@Override
public void onLogoutFinish() {
SessionStore.clear(mCtx);
Log.i(TAG, "FacebookLogoutListener.logout succeeded");
}
}
/**
* Handles facebook login callbacks
* @author warren
*
*/
private final class LoginDialogListener implements DialogListener {
public void onComplete(Bundle values) {
SessionEvents.onLoginSuccess();
Log.i(TAG, "LoginDialogListener.onComplete.login success");
}
public void onFacebookError(FacebookError error) {
SessionEvents.onLoginError(error.getMessage());
Log.e(TAG, "LoginDialogListener.error: " + error.getMessage());
}
public void onError(DialogError error) {
SessionEvents.onLoginError(error.getMessage());
Log.e(TAG, "LoginDialogListener.error: " + error.getMessage());
}
public void onCancel() {
SessionEvents.onLoginError("Action Canceled");
Log.e(TAG, "LoginDialogListener.login cancelled");
}
}
/**
* Listens for requests to log out.
* @author warren
*
*/
private class LogoutRequestListener extends BaseRequestListener {
public void onComplete(String response, final Object state) {
// callback should be run in the original thread,
// not the background thread
mHandler.post(new Runnable() {
public void run() {
SessionEvents.onLogoutFinish();
}
});
}
}
/**
* Listens for dialogs to post text to wall
* @author warren
*
*/
public class FacebookDialogListener extends BaseDialogListener {
public void onComplete(Bundle values) {
final String postId = values.getString("post_id");
if (postId != null) {
Log.d("Facebook-Example", "Dialog Success! post_id=" + postId);
mAsyncRunner.request(postId, new WallPostRequestListener());
} else {
Log.d("Facebook-Example", "No wall post made");
}
}
}
/**
* Listens for posts to the wall
* @author warren
*
*/
public class WallPostRequestListener extends BaseRequestListener {
public void onComplete(final String response, final Object state) {
Log.i(TAG, "WallPostRequestListener.post successful");
}
}
/**
* @return true if the session is valid
* @author ricky barrette
*/
public boolean isSessionValid() {
return mFb.isSessionValid();
}
}

View File

@@ -1,146 +0,0 @@
/*
* Copyright 2010 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.TwentyCodes.android.Facebook;
import java.util.LinkedList;
public class SessionEvents {
private static LinkedList<AuthListener> mAuthListeners =
new LinkedList<AuthListener>();
private static LinkedList<LogoutListener> mLogoutListeners =
new LinkedList<LogoutListener>();
/**
* Associate the given listener with this Facebook object. The listener's
* callback interface will be invoked when authentication events occur.
*
* @param listener
* The callback object for notifying the application when auth
* events happen.
*/
public static void addAuthListener(AuthListener listener) {
mAuthListeners.add(listener);
}
/**
* Remove the given listener from the list of those that will be notified
* when authentication events occur.
*
* @param listener
* The callback object for notifying the application when auth
* events happen.
*/
public static void removeAuthListener(AuthListener listener) {
mAuthListeners.remove(listener);
}
/**
* Associate the given listener with this Facebook object. The listener's
* callback interface will be invoked when logout occurs.
*
* @param listener
* The callback object for notifying the application when log out
* starts and finishes.
*/
public static void addLogoutListener(LogoutListener listener) {
mLogoutListeners.add(listener);
}
/**
* Remove the given listener from the list of those that will be notified
* when logout occurs.
*
* @param listener
* The callback object for notifying the application when log out
* starts and finishes.
*/
public static void removeLogoutListener(LogoutListener listener) {
mLogoutListeners.remove(listener);
}
public static void onLoginSuccess() {
for (AuthListener listener : mAuthListeners) {
listener.onAuthSucceed();
}
}
public static void onLoginError(String error) {
for (AuthListener listener : mAuthListeners) {
listener.onAuthFail(error);
}
}
public static void onLogoutBegin() {
for (LogoutListener l : mLogoutListeners) {
l.onLogoutBegin();
}
}
public static void onLogoutFinish() {
for (LogoutListener l : mLogoutListeners) {
l.onLogoutFinish();
}
}
/**
* Callback interface for authorization events.
*
*/
public static interface AuthListener {
/**
* Called when a auth flow completes successfully and a valid OAuth
* Token was received.
*
* Executed by the thread that initiated the authentication.
*
* API requests can now be made.
*/
public void onAuthSucceed();
/**
* Called when a login completes unsuccessfully with an error.
*
* Executed by the thread that initiated the authentication.
*/
public void onAuthFail(String error);
}
/**
* Callback interface for logout events.
*
*/
public static interface LogoutListener {
/**
* Called when logout begins, before session is invalidated.
* Last chance to make an API call.
*
* Executed by the thread that initiated the logout.
*/
public void onLogoutBegin();
/**
* Called when the session information has been cleared.
* UI should be updated to reflect logged-out state.
*
* Executed by the thread that initiated the logout.
*/
public void onLogoutFinish();
}
}

View File

@@ -1,16 +0,0 @@
package com.TwentyCodes.android.Facebook;
import android.accounts.AccountsException;
public class SessionNotValidException extends AccountsException {
/**
* generated id
*/
private static final long serialVersionUID = 624797017013181185L;
public SessionNotValidException(String message) {
new AccountsException(message);
}
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright 2010 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.TwentyCodes.android.Facebook;
import com.facebook.android.Facebook;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
public class SessionStore {
private static final String TOKEN = "access_token";
private static final String EXPIRES = "expires_in";
private static final String KEY = "facebook-session";
public static boolean save(Facebook session, Context context) {
Editor editor =
context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
editor.putString(TOKEN, session.getAccessToken());
editor.putLong(EXPIRES, session.getAccessExpires());
return editor.commit();
}
public static boolean restore(Facebook session, Context context) {
SharedPreferences savedSession =
context.getSharedPreferences(KEY, Context.MODE_PRIVATE);
session.setAccessToken(savedSession.getString(TOKEN, null));
session.setAccessExpires(savedSession.getLong(EXPIRES, 0));
return session.isSessionValid();
}
public static void clear(Context context) {
Editor editor =
context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
editor.clear();
editor.commit();
}
}

View File

@@ -1,129 +0,0 @@
/**
* LocationReceiver.java
* @date Jan 21, 2011
* @author ricky barrette
* @author Twenty Codes, LLC
*/
package com.TwentyCodes.android.TravelPost;
import com.TwentyCodes.android.Facebook.FacebookAuth;
import com.TwentyCodes.android.Facebook.SessionNotValidException;
import com.TwentyCodes.android.location.ReverseGeocoder;
import twitter4j.TwitterException;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
/**
* The broadcast receiver that works with LocationService.java
* @author ricky barrette
*/
public class LocationReceiver extends BroadcastReceiver{
public static final String ACTION_UPDATE = "TwentyCodes.TravelPost.intent.action.LocationUpdate";
public static final String LOCATION_PARCEL = "location_parcel";
private static final String TAG = "LocationReceiver";
private WakeLock mWakeLock;
private Context mContext;
/**
* acquires a wakelock to prevent the device's cpu from sleeping
* @param context
* @author ricky barrette
*/
private void acquireWakeLock(Context context) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
mWakeLock.acquire();
}
/**
* called when this receiver receives a location update
* @param location
* @author ricky barrette
*/
private void onLocationUpdate(Location location) {
/*
* the following is used to load prefs from shared_prefs
*/
SharedPreferences settings = mContext.getSharedPreferences(TravelPost.SETTINGS, 0);
//check to see if save a post is enabled, if not use the post the user provide
if(settings.getBoolean(TravelPost.SAVE_A_POST, false))
postToSocialServices(settings.getString(TravelPost.SAVED_POST, null), location);
else {
postToSocialServices(settings.getString(TravelPost.USERS_POST, null), location);
settings.edit().remove(TravelPost.USERS_POST).commit();
}
removeWakeLock();
}
/**
* a convince method to post to social networks
* @param string
* @author ricky barrette
*/
private void postToSocialServices(String post, Location location) {
Log.d(TravelPost.TAG, "Posting: "+ post);
//generate the post
String thePost = ReverseGeocoder.getAddressFromLocation(location) +" : "+ post;
// TODO check post size, is it greater than 140 chars?
// TODO Add more social services
//post to twitter
try {
Log.d(TravelPost.TAG, TwitterServices.tweet(mContext, thePost).toString());
} catch (TwitterException e) {
e.printStackTrace();
}
//if there is a facebook authization, then post!
if (mContext.getSharedPreferences("facebook-session", 0).getString("access_token", null) != null) {
//post to facebook
FacebookAuth fbAuth = new FacebookAuth(mContext, new Activity());
fbAuth.authorize();
try {
fbAuth.postToWall(thePost);
} catch (SessionNotValidException e) {
e.printStackTrace();
}
}
}
/**
* Called when there is a location update from the location service.
* @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
* @author ricky barrette
*/
@Override
public void onReceive(Context context, Intent intent) {
mContext = context;
acquireWakeLock(context);
if(intent.getParcelableExtra(LOCATION_PARCEL) != null){
Location location = intent.getParcelableExtra(LOCATION_PARCEL);
onLocationUpdate(location);
}
}
/**
* removes the wake lock if there is one held
* @author ricky barrette
*/
private void removeWakeLock() {
if(mWakeLock.isHeld())
mWakeLock.release();
}
}

View File

@@ -1,55 +0,0 @@
/**
* PostActivity.java
* @date Feb 5, 2011
* @author ricky barrette
* @author Twenty Codes, LLC
*/
package com.TwentyCodes.android.TravelPost;
import com.TwentyCodes.android.location.LocationService;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
/**
* This is going to be the activity that is displayed when the travel post widget is clicked.
* This genreal feel of this activity is going to be similar to the google search widget activity
* @author ricky barrette
*/
public class PostActivity extends Activity implements OnClickListener {
private EditText mPostEditText;
/**
* 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.post);
findViewById(R.id.postOkButton).setOnClickListener(this);
mPostEditText = (EditText) findViewById(R.id.post);
}
/**
* called when the ok button is pressed
* (non-Javadoc)
* @see android.view.View.OnClickListener#onClick(android.view.View)
* @author ricky barrette
*/
@Override
public void onClick(View v) {
//store post information to shared_prefs
this.getSharedPreferences(TravelPost.SETTINGS, 0).edit().putString(TravelPost.USERS_POST, mPostEditText.getText().toString()).commit();
//start the service
this.startService(LocationService.getStartServiceIntent(this, LocationReceiver.ACTION_UPDATE));
//exit the activity
this.finish();
}
}

View File

@@ -1,93 +0,0 @@
/**
* @author Twenty Codes
* @author ricky barrette
*/
package com.TwentyCodes.android.TravelPost;
import android.content.Context;
import android.graphics.Typeface;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
* this class will be a simple TextView to be used in a preference activity. you set the text using the set title tag
* @author ricky barrette
*/
public class TextViewPreference extends Preference {
/**
* creates a preference that is nothing but a text view
* @param context
*/
public TextViewPreference(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
/**
* creates a preference that is nothing but a text view
* @param context
* @param attrs
*/
public TextViewPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* creates a preference that is nothing but a text view
* @param context
* @param attrs
* @param defStyle
*/
public TextViewPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* creates a linear layout the contains only a textview.
* (non-Javadoc)
* @see android.preference.Preference#onCreateView(android.view.ViewGroup)
* @param parent
* @return
* @author ricky barrette
*/
@Override
protected View onCreateView(ViewGroup parent){
/*
* create a vertical linear layout that width and height that wraps content
*/
LinearLayout layout = new LinearLayout(getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER;
layout.setPadding(15, 5, 10, 5);
layout.setOrientation(LinearLayout.VERTICAL);
layout.removeAllViews();
/*
* create a textview that will be used to display the title provided in xml
* and add it to the lay out
*/
TextView title = new TextView(getContext());
title.setText(getTitle());
title.setTextSize(16);
title.setTypeface(Typeface.SANS_SERIF);
title.setGravity(Gravity.LEFT);
title.setLayoutParams(params);
/*
* add the title and the time picker views to the layout
*/
layout.addView(title);
layout.setId(android.R.id.widget_frame);
return layout;
}
}

View File

@@ -1,159 +0,0 @@
/**
* TravelPost.java
* @date Jan 21, 2011
* @author ricky barrette
* @author Twenty Codes, LLC
*/
package com.TwentyCodes.android.TravelPost;
import twitter4j.TwitterException;
import android.app.Activity;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.widget.RemoteViews;
import com.TwentyCodes.android.Facebook.FacebookAuth;
import com.TwentyCodes.android.exception.ExceptionHandler;
import com.TwentyCodes.android.location.LocationService;
/**
* Main activity for the Travel Post widget.
* This activity will be used to gather and store the users settings for the widget using shared_prefs
* @author ricky barrette
*/
public class TravelPost extends PreferenceActivity implements OnPreferenceClickListener {
private ExceptionHandler mExceptionReport = new ExceptionHandler(this);
private TwitterServices mTwitterServices = null;
public static final String SETTINGS = "settings";
private static final int TWITTER_AUTH_REQUEST_CODE = 0;
public static final String TAG = "TravelPost";
public static final String SAVED_POST = "saved_post";
public static final String SAVE_A_POST = "save_a_post";
public static final String USERS_POST = "users_post";
/**
* called when the web auth activity returns its result
* (non-Javadoc)
* @see android.preference.PreferenceActivity#onActivityResult(int, int, android.content.Intent)
* @author ricky barrette
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.v(TAG, "onActivityResult()");
Log.d(TAG, "Request code:"+ requestCode);
String authCode = null;
if(data != null){
authCode = data.getStringExtra(WebAuth.AUTH_CODE);
if (authCode != null) {
Log.d(TAG, authCode);
} else {
Log.d(TAG, "onActivityForResult.authCode is null");
}
} else
Log.e(TAG, "WebAuth result was null!!!");
if(resultCode == Activity.RESULT_OK)
switch(requestCode){
case TWITTER_AUTH_REQUEST_CODE:
try {
mTwitterServices.saveAuthorizationTokens(authCode);
} catch (TwitterException e) {
e.printStackTrace();
}
break;
}
}
/**
* called when the activity is first created
* (non-Javadoc)
* @see android.preference.PreferenceActivity#onCreate(android.os.Bundle)
* @author ricky barrette
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v(TAG, "onCreate()");
//set this preference activity to use the settings file we choose.
this.getPreferenceManager().setSharedPreferencesName(SETTINGS);
//start the exception handler
mExceptionReport.run();
Thread.setDefaultUncaughtExceptionHandler(mExceptionReport);
// load preferences xml
this.addPreferencesFromResource(R.xml.settings);
this.findPreference("twitter_sign_in").setOnPreferenceClickListener(this);
this.findPreference("facebook_sign_in").setOnPreferenceClickListener(this);
}
@Override
public void onDestroy(){
Log.v(TAG, "onDestroy()");
updateWidget();
super.onDestroy();
}
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference.getKey().equals("twitter_sign_in")) {
mTwitterServices = new TwitterServices(this);
try {
this.startActivityForResult(new Intent(this, WebAuth.class).putExtra(WebAuth.AUTH_URL, mTwitterServices.getAuthorizationURL()), TWITTER_AUTH_REQUEST_CODE);
} catch (TwitterException e) {
e.printStackTrace();
}
} else if (preference.getKey().equals("facebook_sign_in")) {
/*
* force facebook to re-check login info,
* if the last account information is valid, then fb does not ask for users info
*/
getSharedPreferences("facebook-session", 0).edit().clear().commit();
FacebookAuth fbAuth = new FacebookAuth(this, this);
fbAuth.authorize();
}
return false;
}
/**
* updates the widget
* @author ricky barrette
*/
private void updateWidget(){
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
ComponentName thisWidget = new ComponentName(this, TravelPostWidget.class);
PendingIntent pendingIntent;
/*
* if the save a post option is enabled then go start the service,
* else get the users input
*/
if( this.getSharedPreferences(SETTINGS, 0).getBoolean(TravelPost.SAVE_A_POST, false)){
//Create a pending intent to start the location service
pendingIntent = PendingIntent.getService(this, 0, LocationService.getStartServiceIntent(this, LocationReceiver.ACTION_UPDATE), 0);
} else {
//create a pending intent to start the post activity
pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, PostActivity.class), 0);
}
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(this.getPackageName(), R.layout.travelpostwidget);
views.setOnClickPendingIntent(R.id.widgetbutton, pendingIntent);
//send the update to the widget
appWidgetManager.updateAppWidget(thisWidget, views);
}
}

View File

@@ -1,120 +0,0 @@
/**
* TravelPostWidget.java
* @date Jan, 15, 2011
* @author warren powers
*/
package com.TwentyCodes.android.TravelPost;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.RemoteViews;
import com.TwentyCodes.android.location.LocationService;
/**
* This class will display the widget on the android screen and handle user interaction
* @author warren
* @author ricky barrette
*/
public class TravelPostWidget extends AppWidgetProvider {
/**
* Set to true when the application is being debugged.
*/
private static final boolean DEBUG = true;
public final String TAG = "TravelPostWidget";
/**
* Called in response to the ACTION_APPWIDGET_UPDATE broadcast when this AppWidget provider is being asked to provide RemoteViews for a set of AppWidgets.
* Override this method to implement your own AppWidget functionality.
* @see android.appwidget.AppWidgetProvider#onUpdate(android.content.Context, android.appwidget.AppWidgetManager, int[])
* @param context
* @param appWidgetManager
* @param appWidgetIds
* @author ricky barrette
*/
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
if(DEBUG)
Log.v(TAG, "onUpdate()");
final int N = appWidgetIds.length;
/*
* the following is used to load widget prefs from shared_prefs
*/
SharedPreferences settings = context.getSharedPreferences(TravelPost.SETTINGS, 0);
// Perform this loop procedure for each App Widget that belongs to this provider
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];
PendingIntent pendingIntent;
/*
* if the save a post option is enabled then go start the service,
* else get the users input
*/
if( settings.getBoolean(TravelPost.SAVE_A_POST, false)){
//Create a pending intent to start the location service
pendingIntent = PendingIntent.getService(context, 0, LocationService.getStartServiceIntent(context, LocationReceiver.ACTION_UPDATE), 0);
} else {
//create a pending intent to start the post activity
pendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, PostActivity.class), 0);
}
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.travelpostwidget);
views.setOnClickPendingIntent(R.id.widgetbutton, pendingIntent);
// Tell the AppWidgetManager to perform an update on the current App Widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
/**
* Implements onReceive(Context, Intent) to dispatch calls to the various other methods on AppWidgetProvider.
* (non-Javadoc)
* @see android.appwidget.AppWidgetProvider#onReceive(android.content.Context, android.content.Intent)
* @param context
* @param intent received
* @author ricky barrette
*/
@Override
public void onReceive(Context context, Intent intent) {
if(DEBUG)
Log.v(TAG, "onReceive");
// v1.5 fix that doesn't call onDelete Action
final String action = intent.getAction();
if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
final int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
this.onDeleted(context, new int[] { appWidgetId });
}
} else {
super.onReceive(context, intent);
}
}
/**
* Called in response to the ACTION_APPWIDGET_DELETED broadcast when one or more AppWidget instances have been deleted.
* Override this method to implement your own AppWidget functionality.
* (non-Javadoc)
* @see android.appwidget.AppWidgetProvider#onDeleted(android.content.Context, int[])
* @param context
* @param appWidgetIds
* @author ricky barrette
*/
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
if(DEBUG)
Log.v(TAG, "onDelete()");
super.onDeleted(context, appWidgetIds);
}
}

View File

@@ -1,96 +0,0 @@
/**
* TwitterServices.java
* @date Jan 30, 2011
* @author ricky barrette
* @author Twenty Codes, LLC
*/
package com.TwentyCodes.android.TravelPost;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;
import twitter4j.http.AccessToken;
import twitter4j.http.RequestToken;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
/**
* A convince class for working with the twitter4j API
* @author ricky barrette
*/
public class TwitterServices {
public static final String TWITTER_AUTH_TOKEN = "twitter_token";
public static final String TWITTER_AUTH_SECRET = "twitter_secret";
// private static final String TC_TEST_OAUTH_KEY = "CFYYGtuYjEHmwycZIhYS3Q";
// private static final String TC_TEST_OAUTH_SECRET = "Sf8nUTImllxET4SYriQ6e4YOLK4i8UUmO3x0tcPqhU";
private static final String TRAVEL_PORT_OAUTH_KEY = "NkSaLHkkpwMYnXryEKEA";
private static final String TRAVEL_PORT_OAUTH_SECRET = "imbqMfZs1nFxxMCtsRLrS3xWm1VOi5uZ3IuOv9iYk";
private Twitter twitter;
private static SharedPreferences shared_prefs;
private RequestToken requestToken;
/**
* Posts a tweet to twitter. <p>
* You need to authorize your application first
* @param msg
* @throws TwitterException
* @author ricky barrette
* @return Status
*/
public static Status tweet(Context context, String msg) throws TwitterException{
shared_prefs = context.getSharedPreferences(TravelPost.SETTINGS, 0);
Log.d(TravelPost.TAG, "Tweeting: "+ msg);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey(TRAVEL_PORT_OAUTH_KEY);
cb.setOAuthConsumerSecret(TRAVEL_PORT_OAUTH_SECRET);
cb.setOAuthAccessToken(shared_prefs.getString(TWITTER_AUTH_TOKEN, ""));
cb.setOAuthAccessTokenSecret(shared_prefs.getString(TWITTER_AUTH_SECRET, ""));
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
return twitter.updateStatus(msg);
}
/**
* Creates a new TwitterServices. <p>
* 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();
}
}

View File

@@ -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();
}
}