diff --git a/TravelPost/.classpath b/TravelPost/.classpath deleted file mode 100644 index 2fc4b68..0000000 --- a/TravelPost/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/TravelPost/.codepro/deadCodeEntryPoints.xml b/TravelPost/.codepro/deadCodeEntryPoints.xml deleted file mode 100644 index 814d580..0000000 --- a/TravelPost/.codepro/deadCodeEntryPoints.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/TravelPost/.project b/TravelPost/.project deleted file mode 100644 index 0c7114e..0000000 --- a/TravelPost/.project +++ /dev/null @@ -1,50 +0,0 @@ - - - TravelPost - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - ExceptionHandlerLib_src - 2 - _android_ExceptionHandlerLib_7d68b46a/src - - - FacebookLib_src - 2 - _android_FacebookLib_9c84f9bf/src - - - LocationLib_src - 2 - _android_LocationLib_84551a70/src - - - diff --git a/TravelPost/AndroidManifest.xml b/TravelPost/AndroidManifest.xml deleted file mode 100644 index 4e9a079..0000000 --- a/TravelPost/AndroidManifest.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TravelPost/ChangeLog.txt b/TravelPost/ChangeLog.txt deleted file mode 100644 index 0dd85b6..0000000 --- a/TravelPost/ChangeLog.txt +++ /dev/null @@ -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. \ No newline at end of file diff --git a/TravelPost/default.properties b/TravelPost/default.properties deleted file mode 100644 index 219555b..0000000 --- a/TravelPost/default.properties +++ /dev/null @@ -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 diff --git a/TravelPost/gen/com/TwentyCodes/android/TravelPost/R.java b/TravelPost/gen/com/TwentyCodes/android/TravelPost/R.java deleted file mode 100644 index 49c3fde..0000000 --- a/TravelPost/gen/com/TwentyCodes/android/TravelPost/R.java +++ /dev/null @@ -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; - } -} diff --git a/TravelPost/gen/com/TwentyCodes/android/exception/R.java b/TravelPost/gen/com/TwentyCodes/android/exception/R.java deleted file mode 100644 index 627600c..0000000 --- a/TravelPost/gen/com/TwentyCodes/android/exception/R.java +++ /dev/null @@ -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; - } -} diff --git a/TravelPost/libs/twitter4j-core-2.1.11.jar b/TravelPost/libs/twitter4j-core-2.1.11.jar deleted file mode 100644 index b0fb214..0000000 Binary files a/TravelPost/libs/twitter4j-core-2.1.11.jar and /dev/null differ diff --git a/TravelPost/proguard.cfg b/TravelPost/proguard.cfg deleted file mode 100644 index 8ad7d33..0000000 --- a/TravelPost/proguard.cfg +++ /dev/null @@ -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 ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (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 *; -} diff --git a/TravelPost/res/drawable-hdpi/icon.png b/TravelPost/res/drawable-hdpi/icon.png deleted file mode 100644 index 9fc1feb..0000000 Binary files a/TravelPost/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/TravelPost/res/drawable-ldpi/icon.png b/TravelPost/res/drawable-ldpi/icon.png deleted file mode 100644 index 303671e..0000000 Binary files a/TravelPost/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/TravelPost/res/drawable-mdpi/icon.png b/TravelPost/res/drawable-mdpi/icon.png deleted file mode 100644 index 182e113..0000000 Binary files a/TravelPost/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/TravelPost/res/drawable/sign_post_icon.png b/TravelPost/res/drawable/sign_post_icon.png deleted file mode 100644 index 6c9b135..0000000 Binary files a/TravelPost/res/drawable/sign_post_icon.png and /dev/null differ diff --git a/TravelPost/res/drawable/sign_post_icon_mod.png b/TravelPost/res/drawable/sign_post_icon_mod.png deleted file mode 100644 index b68e6cf..0000000 Binary files a/TravelPost/res/drawable/sign_post_icon_mod.png and /dev/null differ diff --git a/TravelPost/res/drawable/widget.png b/TravelPost/res/drawable/widget.png deleted file mode 100644 index edd900e..0000000 Binary files a/TravelPost/res/drawable/widget.png and /dev/null differ diff --git a/TravelPost/res/layout/post.xml b/TravelPost/res/layout/post.xml deleted file mode 100644 index e6ff568..0000000 --- a/TravelPost/res/layout/post.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - diff --git a/TravelPost/res/layout/travelpostwidget.xml b/TravelPost/res/layout/travelpostwidget.xml deleted file mode 100644 index 64a748a..0000000 --- a/TravelPost/res/layout/travelpostwidget.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/TravelPost/res/layout/webauth.xml b/TravelPost/res/layout/webauth.xml deleted file mode 100644 index 017861b..0000000 --- a/TravelPost/res/layout/webauth.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/TravelPost/res/values/strings.xml b/TravelPost/res/values/strings.xml deleted file mode 100644 index 17e6ded..0000000 --- a/TravelPost/res/values/strings.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - Hello World! - Travel Post - Twitter Sign In - Facebook Sign In - Location Settings - About - Post Settings - Save a post - Social Services - Whats up? - diff --git a/TravelPost/res/xml/settings.xml b/TravelPost/res/xml/settings.xml deleted file mode 100644 index d2b1415..0000000 --- a/TravelPost/res/xml/settings.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/TravelPost/res/xml/travelpostwidgetinfo.xml b/TravelPost/res/xml/travelpostwidgetinfo.xml deleted file mode 100644 index 7290f2e..0000000 --- a/TravelPost/res/xml/travelpostwidgetinfo.xml +++ /dev/null @@ -1,7 +0,0 @@ - - diff --git a/TravelPost/src/com/TwentyCodes/android/Facebook/BaseDialogListener.java b/TravelPost/src/com/TwentyCodes/android/Facebook/BaseDialogListener.java deleted file mode 100644 index d23a8c3..0000000 --- a/TravelPost/src/com/TwentyCodes/android/Facebook/BaseDialogListener.java +++ /dev/null @@ -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() { - } - -} diff --git a/TravelPost/src/com/TwentyCodes/android/Facebook/BaseRequestListener.java b/TravelPost/src/com/TwentyCodes/android/Facebook/BaseRequestListener.java deleted file mode 100644 index 2acd533..0000000 --- a/TravelPost/src/com/TwentyCodes/android/Facebook/BaseRequestListener.java +++ /dev/null @@ -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(); - } - -} diff --git a/TravelPost/src/com/TwentyCodes/android/Facebook/FacebookAuth.java b/TravelPost/src/com/TwentyCodes/android/Facebook/FacebookAuth.java deleted file mode 100644 index 7c63a77..0000000 --- a/TravelPost/src/com/TwentyCodes/android/Facebook/FacebookAuth.java +++ /dev/null @@ -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(); - } -} diff --git a/TravelPost/src/com/TwentyCodes/android/Facebook/SessionEvents.java b/TravelPost/src/com/TwentyCodes/android/Facebook/SessionEvents.java deleted file mode 100644 index 57cbe73..0000000 --- a/TravelPost/src/com/TwentyCodes/android/Facebook/SessionEvents.java +++ /dev/null @@ -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 mAuthListeners = - new LinkedList(); - private static LinkedList mLogoutListeners = - new LinkedList(); - - /** - * 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(); - } - -} diff --git a/TravelPost/src/com/TwentyCodes/android/Facebook/SessionNotValidException.java b/TravelPost/src/com/TwentyCodes/android/Facebook/SessionNotValidException.java deleted file mode 100644 index 289a417..0000000 --- a/TravelPost/src/com/TwentyCodes/android/Facebook/SessionNotValidException.java +++ /dev/null @@ -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); - } - -} diff --git a/TravelPost/src/com/TwentyCodes/android/Facebook/SessionStore.java b/TravelPost/src/com/TwentyCodes/android/Facebook/SessionStore.java deleted file mode 100644 index f3d2cf2..0000000 --- a/TravelPost/src/com/TwentyCodes/android/Facebook/SessionStore.java +++ /dev/null @@ -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(); - } - -} diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/LocationReceiver.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/LocationReceiver.java deleted file mode 100644 index 499b417..0000000 --- a/TravelPost/src/com/TwentyCodes/android/TravelPost/LocationReceiver.java +++ /dev/null @@ -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(); - } - -} \ No newline at end of file diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/PostActivity.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/PostActivity.java deleted file mode 100644 index ee28a1e..0000000 --- a/TravelPost/src/com/TwentyCodes/android/TravelPost/PostActivity.java +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/TextViewPreference.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/TextViewPreference.java deleted file mode 100644 index be84a80..0000000 --- a/TravelPost/src/com/TwentyCodes/android/TravelPost/TextViewPreference.java +++ /dev/null @@ -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; - } -} diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPost.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPost.java deleted file mode 100644 index 4bb8d20..0000000 --- a/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPost.java +++ /dev/null @@ -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); - } - -} \ No newline at end of file diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPostWidget.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPostWidget.java deleted file mode 100644 index 1bae9f6..0000000 --- a/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPostWidget.java +++ /dev/null @@ -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 - * 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.

- * 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