diff --git a/TravelPost/.classpath b/TravelPost/.classpath
new file mode 100644
index 0000000..d22ac25
--- /dev/null
+++ b/TravelPost/.classpath
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TravelPost/.project b/TravelPost/.project
new file mode 100644
index 0000000..0c7114e
--- /dev/null
+++ b/TravelPost/.project
@@ -0,0 +1,50 @@
+
+
+ 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
new file mode 100644
index 0000000..4fb5afa
--- /dev/null
+++ b/TravelPost/AndroidManifest.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TravelPost/default.properties b/TravelPost/default.properties
new file mode 100644
index 0000000..f7e9cf6
--- /dev/null
+++ b/TravelPost/default.properties
@@ -0,0 +1,14 @@
+# 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:12
+android.library.reference.3=../LocationLib
+android.library.reference.1=../ExceptionHandlerLib
+android.library.reference.2=../FacebookLib
diff --git a/TravelPost/gen/com/TwentyCodes/android/SkyHook/R.java b/TravelPost/gen/com/TwentyCodes/android/SkyHook/R.java
new file mode 100644
index 0000000..5604e16
--- /dev/null
+++ b/TravelPost/gen/com/TwentyCodes/android/SkyHook/R.java
@@ -0,0 +1,88 @@
+/* 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.SkyHook;
+
+public final class R {
+ public static final class array {
+ public static final int accuracy_entries=0x7f060000;
+ public static final int accuracy_values=0x7f060001;
+ }
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int compass=0x7f020000;
+ public static final int facebook_icon=0x7f020001;
+ public static final int icon=0x7f020002;
+ public static final int logoidea3=0x7f020003;
+ public static final int needle=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 class id {
+ public static final int skyhook_img=0x7f070000;
+ public static final int socialsites=0x7f070003;
+ public static final int tc_img=0x7f070002;
+ public static final int text=0x7f070001;
+ }
+ public static final class layout {
+ public static final int powered_by_skyhook=0x7f030000;
+ }
+ public static final class string {
+ public static final int about=0x7f050005;
+ public static final int about_info=0x7f050006;
+ public static final int about_verify=0x7f050007;
+ public static final int accuracy=0x7f050008;
+ public static final int accuracy_info=0x7f050009;
+ public static final int add_social_site=0x7f05000a;
+ public static final int app_name=0x7f050000;
+ public static final int cancel_service=0x7f05000b;
+ public static final int check_in_at=0x7f05000c;
+ public static final int clear=0x7f05000d;
+ public static final int crash=0x7f050003;
+ public static final int disable_facebook_checkin=0x7f05000e;
+ public static final int enable_facebook_checkin=0x7f05000f;
+ public static final int facebook=0x7f050010;
+ public static final int facebook_already_authorized=0x7f050011;
+ public static final int facebook_authorization_failure=0x7f050012;
+ public static final int facebook_options=0x7f050013;
+ public static final int facebook_session_not_valid=0x7f050014;
+ public static final int fb_signin=0x7f050015;
+ public static final int gathering=0x7f05001c;
+ public static final int gps_fix=0x7f050001;
+ public static final int loading=0x7f050016;
+ public static final int location_settings=0x7f050017;
+ public static final int poor_data_connection=0x7f05001e;
+ public static final int post_hint=0x7f050018;
+ public static final int post_lenght=0x7f050019;
+ public static final int post_settings=0x7f05001d;
+ public static final int post_to_long=0x7f05001a;
+ public static final int posting=0x7f05001b;
+ public static final int remove_facebook=0x7f05001f;
+ public static final int remove_facebook_confirmation=0x7f050020;
+ public static final int remove_site_title=0x7f050021;
+ public static final int remove_twitter=0x7f050022;
+ public static final int save_a_post=0x7f050023;
+ public static final int social_site=0x7f050024;
+ public static final int sorry=0x7f050004;
+ public static final int sorry_theres_trouble=0x7f050002;
+ public static final int twitter=0x7f050025;
+ public static final int twitter_already_authorized=0x7f050026;
+ public static final int twitter_authorization_failure=0x7f050027;
+ public static final int twitter_exception=0x7f050028;
+ public static final int twitter_signin=0x7f050029;
+ public static final int update=0x7f05002a;
+ public static final int verify_message=0x7f05002b;
+ public static final int verify_post=0x7f05002c;
+ }
+ public static final class xml {
+ public static final int travelpostmain=0x7f040000;
+ }
+}
diff --git a/TravelPost/gen/com/TwentyCodes/android/TravelPost/R.java b/TravelPost/gen/com/TwentyCodes/android/TravelPost/R.java
new file mode 100644
index 0000000..effcc3e
--- /dev/null
+++ b/TravelPost/gen/com/TwentyCodes/android/TravelPost/R.java
@@ -0,0 +1,88 @@
+/* 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 array {
+ public static final int accuracy_entries=0x7f060000;
+ public static final int accuracy_values=0x7f060001;
+ }
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int compass=0x7f020000;
+ public static final int facebook_icon=0x7f020001;
+ public static final int icon=0x7f020002;
+ public static final int logoidea3=0x7f020003;
+ public static final int needle=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 class id {
+ public static final int skyhook_img=0x7f070000;
+ public static final int socialsites=0x7f070003;
+ public static final int tc_img=0x7f070002;
+ public static final int text=0x7f070001;
+ }
+ public static final class layout {
+ public static final int powered_by_skyhook=0x7f030000;
+ }
+ public static final class string {
+ public static final int about=0x7f050005;
+ public static final int about_info=0x7f050006;
+ public static final int about_verify=0x7f050007;
+ public static final int accuracy=0x7f050008;
+ public static final int accuracy_info=0x7f050009;
+ public static final int add_social_site=0x7f05000a;
+ public static final int app_name=0x7f050000;
+ public static final int cancel_service=0x7f05000b;
+ public static final int check_in_at=0x7f05000c;
+ public static final int clear=0x7f05000d;
+ public static final int crash=0x7f050003;
+ public static final int disable_facebook_checkin=0x7f05000e;
+ public static final int enable_facebook_checkin=0x7f05000f;
+ public static final int facebook=0x7f050010;
+ public static final int facebook_already_authorized=0x7f050011;
+ public static final int facebook_authorization_failure=0x7f050012;
+ public static final int facebook_options=0x7f050013;
+ public static final int facebook_session_not_valid=0x7f050014;
+ public static final int fb_signin=0x7f050015;
+ public static final int gathering=0x7f05001c;
+ public static final int gps_fix=0x7f050001;
+ public static final int loading=0x7f050016;
+ public static final int location_settings=0x7f050017;
+ public static final int poor_data_connection=0x7f05001e;
+ public static final int post_hint=0x7f050018;
+ public static final int post_lenght=0x7f050019;
+ public static final int post_settings=0x7f05001d;
+ public static final int post_to_long=0x7f05001a;
+ public static final int posting=0x7f05001b;
+ public static final int remove_facebook=0x7f05001f;
+ public static final int remove_facebook_confirmation=0x7f050020;
+ public static final int remove_site_title=0x7f050021;
+ public static final int remove_twitter=0x7f050022;
+ public static final int save_a_post=0x7f050023;
+ public static final int social_site=0x7f050024;
+ public static final int sorry=0x7f050004;
+ public static final int sorry_theres_trouble=0x7f050002;
+ public static final int twitter=0x7f050025;
+ public static final int twitter_already_authorized=0x7f050026;
+ public static final int twitter_authorization_failure=0x7f050027;
+ public static final int twitter_exception=0x7f050028;
+ public static final int twitter_signin=0x7f050029;
+ public static final int update=0x7f05002a;
+ public static final int verify_message=0x7f05002b;
+ public static final int verify_post=0x7f05002c;
+ }
+ public static final class xml {
+ public static final int travelpostmain=0x7f040000;
+ }
+}
diff --git a/TravelPost/gen/com/TwentyCodes/android/exception/R.java b/TravelPost/gen/com/TwentyCodes/android/exception/R.java
new file mode 100644
index 0000000..dff2bb2
--- /dev/null
+++ b/TravelPost/gen/com/TwentyCodes/android/exception/R.java
@@ -0,0 +1,88 @@
+/* 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 array {
+ public static final int accuracy_entries=0x7f060000;
+ public static final int accuracy_values=0x7f060001;
+ }
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int compass=0x7f020000;
+ public static final int facebook_icon=0x7f020001;
+ public static final int icon=0x7f020002;
+ public static final int logoidea3=0x7f020003;
+ public static final int needle=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 class id {
+ public static final int skyhook_img=0x7f070000;
+ public static final int socialsites=0x7f070003;
+ public static final int tc_img=0x7f070002;
+ public static final int text=0x7f070001;
+ }
+ public static final class layout {
+ public static final int powered_by_skyhook=0x7f030000;
+ }
+ public static final class string {
+ public static final int about=0x7f050005;
+ public static final int about_info=0x7f050006;
+ public static final int about_verify=0x7f050007;
+ public static final int accuracy=0x7f050008;
+ public static final int accuracy_info=0x7f050009;
+ public static final int add_social_site=0x7f05000a;
+ public static final int app_name=0x7f050000;
+ public static final int cancel_service=0x7f05000b;
+ public static final int check_in_at=0x7f05000c;
+ public static final int clear=0x7f05000d;
+ public static final int crash=0x7f050003;
+ public static final int disable_facebook_checkin=0x7f05000e;
+ public static final int enable_facebook_checkin=0x7f05000f;
+ public static final int facebook=0x7f050010;
+ public static final int facebook_already_authorized=0x7f050011;
+ public static final int facebook_authorization_failure=0x7f050012;
+ public static final int facebook_options=0x7f050013;
+ public static final int facebook_session_not_valid=0x7f050014;
+ public static final int fb_signin=0x7f050015;
+ public static final int gathering=0x7f05001c;
+ public static final int gps_fix=0x7f050001;
+ public static final int loading=0x7f050016;
+ public static final int location_settings=0x7f050017;
+ public static final int poor_data_connection=0x7f05001e;
+ public static final int post_hint=0x7f050018;
+ public static final int post_lenght=0x7f050019;
+ public static final int post_settings=0x7f05001d;
+ public static final int post_to_long=0x7f05001a;
+ public static final int posting=0x7f05001b;
+ public static final int remove_facebook=0x7f05001f;
+ public static final int remove_facebook_confirmation=0x7f050020;
+ public static final int remove_site_title=0x7f050021;
+ public static final int remove_twitter=0x7f050022;
+ public static final int save_a_post=0x7f050023;
+ public static final int social_site=0x7f050024;
+ public static final int sorry=0x7f050004;
+ public static final int sorry_theres_trouble=0x7f050002;
+ public static final int twitter=0x7f050025;
+ public static final int twitter_already_authorized=0x7f050026;
+ public static final int twitter_authorization_failure=0x7f050027;
+ public static final int twitter_exception=0x7f050028;
+ public static final int twitter_signin=0x7f050029;
+ public static final int update=0x7f05002a;
+ public static final int verify_message=0x7f05002b;
+ public static final int verify_post=0x7f05002c;
+ }
+ public static final class xml {
+ public static final int travelpostmain=0x7f040000;
+ }
+}
diff --git a/TravelPost/gen/com/facebook/android/R.java b/TravelPost/gen/com/facebook/android/R.java
new file mode 100644
index 0000000..69cefba
--- /dev/null
+++ b/TravelPost/gen/com/facebook/android/R.java
@@ -0,0 +1,88 @@
+/* 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.facebook.android;
+
+public final class R {
+ public static final class array {
+ public static final int accuracy_entries=0x7f060000;
+ public static final int accuracy_values=0x7f060001;
+ }
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int compass=0x7f020000;
+ public static final int facebook_icon=0x7f020001;
+ public static final int icon=0x7f020002;
+ public static final int logoidea3=0x7f020003;
+ public static final int needle=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 class id {
+ public static final int skyhook_img=0x7f070000;
+ public static final int socialsites=0x7f070003;
+ public static final int tc_img=0x7f070002;
+ public static final int text=0x7f070001;
+ }
+ public static final class layout {
+ public static final int powered_by_skyhook=0x7f030000;
+ }
+ public static final class string {
+ public static final int about=0x7f050005;
+ public static final int about_info=0x7f050006;
+ public static final int about_verify=0x7f050007;
+ public static final int accuracy=0x7f050008;
+ public static final int accuracy_info=0x7f050009;
+ public static final int add_social_site=0x7f05000a;
+ public static final int app_name=0x7f050000;
+ public static final int cancel_service=0x7f05000b;
+ public static final int check_in_at=0x7f05000c;
+ public static final int clear=0x7f05000d;
+ public static final int crash=0x7f050003;
+ public static final int disable_facebook_checkin=0x7f05000e;
+ public static final int enable_facebook_checkin=0x7f05000f;
+ public static final int facebook=0x7f050010;
+ public static final int facebook_already_authorized=0x7f050011;
+ public static final int facebook_authorization_failure=0x7f050012;
+ public static final int facebook_options=0x7f050013;
+ public static final int facebook_session_not_valid=0x7f050014;
+ public static final int fb_signin=0x7f050015;
+ public static final int gathering=0x7f05001c;
+ public static final int gps_fix=0x7f050001;
+ public static final int loading=0x7f050016;
+ public static final int location_settings=0x7f050017;
+ public static final int poor_data_connection=0x7f05001e;
+ public static final int post_hint=0x7f050018;
+ public static final int post_lenght=0x7f050019;
+ public static final int post_settings=0x7f05001d;
+ public static final int post_to_long=0x7f05001a;
+ public static final int posting=0x7f05001b;
+ public static final int remove_facebook=0x7f05001f;
+ public static final int remove_facebook_confirmation=0x7f050020;
+ public static final int remove_site_title=0x7f050021;
+ public static final int remove_twitter=0x7f050022;
+ public static final int save_a_post=0x7f050023;
+ public static final int social_site=0x7f050024;
+ public static final int sorry=0x7f050004;
+ public static final int sorry_theres_trouble=0x7f050002;
+ public static final int twitter=0x7f050025;
+ public static final int twitter_already_authorized=0x7f050026;
+ public static final int twitter_authorization_failure=0x7f050027;
+ public static final int twitter_exception=0x7f050028;
+ public static final int twitter_signin=0x7f050029;
+ public static final int update=0x7f05002a;
+ public static final int verify_message=0x7f05002b;
+ public static final int verify_post=0x7f05002c;
+ }
+ public static final class xml {
+ public static final int travelpostmain=0x7f040000;
+ }
+}
diff --git a/TravelPost/libs/twitter4j-core-2.1.11.jar b/TravelPost/libs/twitter4j-core-2.1.11.jar
new file mode 100644
index 0000000..b0fb214
Binary files /dev/null and b/TravelPost/libs/twitter4j-core-2.1.11.jar differ
diff --git a/TravelPost/proguard.cfg b/TravelPost/proguard.cfg
new file mode 100644
index 0000000..12dd039
--- /dev/null
+++ b/TravelPost/proguard.cfg
@@ -0,0 +1,36 @@
+-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 * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-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
new file mode 100644
index 0000000..8074c4c
Binary files /dev/null and b/TravelPost/res/drawable-hdpi/icon.png differ
diff --git a/TravelPost/res/drawable-ldpi/icon.png b/TravelPost/res/drawable-ldpi/icon.png
new file mode 100644
index 0000000..1095584
Binary files /dev/null and b/TravelPost/res/drawable-ldpi/icon.png differ
diff --git a/TravelPost/res/drawable-mdpi/icon.png b/TravelPost/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000..a07c69f
Binary files /dev/null and b/TravelPost/res/drawable-mdpi/icon.png differ
diff --git a/TravelPost/res/values/arrays.xml b/TravelPost/res/values/arrays.xml
new file mode 100644
index 0000000..9601df3
--- /dev/null
+++ b/TravelPost/res/values/arrays.xml
@@ -0,0 +1,13 @@
+
+
+
+ High (8 meters)
+ Medium (20 meters)
+ Low (50 meters)
+
+
+ 8
+ 20
+ 50
+
+
diff --git a/TravelPost/res/values/strings.xml b/TravelPost/res/values/strings.xml
new file mode 100644
index 0000000..e45a1dc
--- /dev/null
+++ b/TravelPost/res/values/strings.xml
@@ -0,0 +1,44 @@
+
+
+ About
+ Travel Post will post your location to several different social sites like Facebook! Simply add the widget to your homescreen and press the widget. If you have any questions or comments feel free to email us at TwentyCodes@gmail.com.
+ Please review your post
+ Accuracy
+ Higher accuracy equals longer wait.
+ Add A Social Site
+ Travel Post
+ Do you want to cancel your post?
+ Check in at:
+ Clear
+ Post to Facebook Wall
+ Post to Facebook Check In
+ Facebook
+ Facebook is already authorized.
+ Unable to authorize Facebook account. Please try again.
+ Facebook Options
+ Your Facebook session is no longer valid. Please log in to Facebook again.
+ Facebook Sign In
+ Loading...
+ Location Settings
+ Whats up?
+ Post Lenght:
+ Please Reduce your post to 140 chars
+ Posting...
+ Gathering location...
+ Post Settings
+ We are having issues connecting to the internet. Please try again later.
+ Remove Facebook
+ Are you sure you want to remove Facebook? You will not be able to post messages to Facebook anymore.
+ Remove Social Site
+ Are you sure you want to remove Twitter? You will not be able to post messages to Twitter anymore.
+ Save a Post
+ Social Sites
+ Twitter
+ Twitter is already authorized.
+ Unable to authorize Twitter account. Please try again.
+ We could not connect to Twitter. Please check your connection and try again.
+ Twitter Sign In
+ Update
+ Verify the message before posting.
+ Verify Post
+
diff --git a/TravelPost/res/xml/travelpostmain.xml b/TravelPost/res/xml/travelpostmain.xml
new file mode 100644
index 0000000..ebfb2c8
--- /dev/null
+++ b/TravelPost/res/xml/travelpostmain.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/Debug/Debug.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/Debug/Debug.java
new file mode 100644
index 0000000..3a04a27
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/Debug/Debug.java
@@ -0,0 +1,15 @@
+package com.TwentyCodes.android.TravelPost.Debug;
+
+/**
+ * This class is used to hold debug values used throughout the application.
+ */
+
+public class Debug {
+
+ /**
+ * This variable if true will enable android logging.
+ */
+ public static final boolean LOGGING = true;
+
+
+}
diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/Facebook.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/Facebook.java
new file mode 100644
index 0000000..b889305
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/Facebook.java
@@ -0,0 +1,254 @@
+package com.TwentyCodes.android.TravelPost.SocialSites;
+
+import java.io.IOException;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.TwentyCodes.android.TravelPost.Debug.Debug;
+import com.TwentyCodes.android.TravelPost.SocialSites.FacebookEvents.AuthListener;
+import com.TwentyCodes.android.TravelPost.SocialSites.FacebookEvents.LogoutListener;
+import com.facebook.android.AsyncFacebookRunner;
+import com.facebook.android.Facebook.DialogListener;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+
+public class Facebook {
+
+ private static final String[] PERMISSIONS = new String[] {"publish_stream", "publish_checkins"};
+ /* 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 = "Facebook";
+ private final com.facebook.android.Facebook mFb = new com.facebook.android.Facebook(APP_ID);
+ private final AsyncFacebookRunner mAsync = new AsyncFacebookRunner(mFb);
+ private Context mCtx;
+ private Handler mHandler;
+
+ /**
+ * @param loginDialogListener - specify your own listener
+ */
+
+ public void authorize(DialogListener loginDialogListener) {
+ if (Debug.LOGGING)
+ Log.i(TAG, "authorize()");
+ if (!this.mFb.isSessionValid()) {
+ Log.i(TAG, "authorize().seesion is not valid");
+ this.mFb.authorize(this.mCtx, PERMISSIONS, loginDialogListener);
+ }
+ }
+
+ /**
+ * Users Facebooks check in server to post to the users wall.
+ * @param text to post to wall
+ * @param Location object representing the users current location
+ * @param placeId found using places search this.placeSearch(Location)
+ * @throws SessionNotValidException - if the facebook session is not valid
+ * @return String JSON object response of post
+ */
+ public String checkIn(String post, Location location, String placeId) throws FacebookSessionNotValidException, JSONException, IOException {
+ if (this.mFb.isSessionValid()) {
+ Bundle parameters = new Bundle();
+ parameters.putString("place", placeId);
+ parameters.putString("message", post);
+ parameters.putString("coordinates", new JSONObject().put("latitude", location.getLatitude()).put("longitude", location.getLongitude()).toString());
+ return this.mFb.request("me/checkins", parameters, "POST");
+ } else {
+ if (this.mFb.getAccessToken() == null && Debug.LOGGING) {
+ Log.i(TAG, "postToWall.access token is null");
+ }
+ throw new FacebookSessionNotValidException("This session is not valid");
+ }
+ }
+
+ public Facebook(final Context context) {
+ this.mCtx = context;
+ this.mHandler = new Handler();
+ FacebookSessionStore.restore(this.mFb, this.mCtx);
+ FacebookEvents.addAuthListener(new FacebookAuthListener());
+ FacebookEvents.addLogoutListener(new FacebookLogoutListener());
+ }
+
+ /**
+ * @return true if the session is valid
+ */
+ public boolean isSessionValid() {
+ return this.mFb.isSessionValid();
+ }
+
+ /**
+ * This method started the Facebook logout process
+ */
+
+ public void logout() {
+ if (this.mFb.isSessionValid()) {
+ FacebookEvents.onLogoutBegin();
+ this.mAsync.logout(this.mCtx, new LogoutRequestListener());
+ }
+ }
+
+ /**
+ * Searches facebook for places that the provided location could be
+ * @param location to perform the search
+ * @param radius to search in meters. recommended radius is 1000
+ * @return A String of a JASONObject of places
+ * @throws SessionNotValidException if session is not valid
+ */
+ public String placeSearch(Location location, long radius) throws FacebookSessionNotValidException, IOException {
+ if (this.mFb.isSessionValid()) {
+ Bundle parameters = new Bundle();
+ parameters.putString("type", "place");
+ parameters.putString("center", location.getLatitude()+","+location.getLongitude());
+ parameters.putString("distance", Long.toString(radius));
+ return this.mFb.request("search", parameters, "GET");
+ } else {
+ if (this.mFb.getAccessToken() == null && Debug.LOGGING) {
+ Log.i(TAG, "postToWall.access token is null");
+ }
+ throw new FacebookSessionNotValidException("This session is not valid");
+ }
+ }
+
+ /**
+ * Allows the user to post to their wall and input their own message
+ * This method displays a dialog asking for input
+ * @author warren
+ */
+
+ public void postToWallDialog() {
+ this.mFb.dialog(this.mCtx, "feed", new FacebookDialogListener());
+ }
+
+ /**
+ * This method posts a message to the users wall
+ * @author warren
+ * @param msg - message to post
+ */
+
+ public void postToWall(String msg) throws FacebookSessionNotValidException, IOException {
+ if (Debug.LOGGING)
+ Log.d(TAG, "postToWall()");
+ if (mFb.isSessionValid()) {
+ Bundle parameters = new Bundle();
+ parameters.putString("message", msg);
+ String response = mFb.request("me/feed", parameters, "POST");
+ if (Debug.LOGGING)
+ Log.d(TAG, "received response: " + response);
+
+ if ((response == null || response.equals("") || response.equals("false")) && Debug.LOGGING) {
+ Log.v("Error", "Blank response");
+ throw new IOException("No response from post request");
+ }
+ } else {
+ if (mFb.getAccessToken() == null && Debug.LOGGING) {
+ Log.i(TAG, "postToWall.access token is null");
+ }
+ throw new FacebookSessionNotValidException("This session is not valid");
+ }
+ }
+
+ /**
+ * Handles facebook authorization callbacks.
+ * @author warren
+ *
+ */
+
+ private class FacebookAuthListener implements AuthListener {
+
+ @Override
+ public void onAuthSucceed() {
+ FacebookSessionStore.save(mFb, mCtx);
+ if (Debug.LOGGING)
+ Log.i(TAG, "FacebookAuthListener.onAuthSucceed()");
+ }
+
+ @Override
+ public void onAuthFail(String error) {
+ if (Debug.LOGGING)
+ Log.i(TAG, "FacebookAuthListener.anAuthFail");
+ }
+ }
+
+ /**
+ * Handles facebook logout callbacks
+ * @author warren
+ *
+ */
+
+ private class FacebookLogoutListener implements LogoutListener {
+
+ @Override
+ public void onLogoutBegin() {
+ if (Debug.LOGGING)
+ Log.i(TAG, "FacebookLogoutListener.logout being");
+
+ }
+
+ @Override
+ public void onLogoutFinish() {
+ FacebookSessionStore.clear(mCtx);
+ if (Debug.LOGGING)
+ Log.i(TAG, "FacebookLogoutListener.logout succeeded");
+
+ }
+
+ }
+
+ /**
+ * Listens for requests to log out.
+ * @author warren
+ *
+ */
+
+ private class LogoutRequestListener extends FacebookBaseRequestListener {
+ 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() {
+ FacebookEvents.onLogoutFinish();
+ }
+ });
+ }
+ }
+
+ /**
+ * Listens for dialogs to post text to wall
+ * @author warren
+ *
+ */
+
+ public class FacebookDialogListener extends FacebookBaseDialogListener {
+
+ public void onComplete(Bundle values, Dialog dialog) {
+ final String postId = values.getString("post_id");
+ if (postId != null) {
+ if (Debug.LOGGING)
+ Log.d(TAG, "Dialog Success. post_id=" + postId);
+ mAsync.request(postId, new WallPostRequestListener());
+ } else {
+ if (Debug.LOGGING)
+ Log.d(TAG, "No wall post made");
+ }
+ }
+ }
+
+ /**
+ * Listens for posts to the wall
+ * @author warren
+ *
+ */
+
+ public class WallPostRequestListener extends FacebookBaseRequestListener {
+
+ public void onComplete(final String response, final Object state) {
+ if (Debug.LOGGING)
+ Log.i(TAG, "WallPostRequestListener.post successful");
+ }
+ }
+}
diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookBaseDialogListener.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookBaseDialogListener.java
new file mode 100644
index 0000000..2e6f2fa
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookBaseDialogListener.java
@@ -0,0 +1,19 @@
+package com.TwentyCodes.android.TravelPost.SocialSites;
+
+import com.facebook.android.DialogError;
+import com.facebook.android.Facebook.DialogListener;
+import com.facebook.android.FacebookError;
+
+public abstract class FacebookBaseDialogListener 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/TravelPost/SocialSites/FacebookBaseRequestListener.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookBaseRequestListener.java
new file mode 100644
index 0000000..578d916
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookBaseRequestListener.java
@@ -0,0 +1,38 @@
+package com.TwentyCodes.android.TravelPost.SocialSites;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import android.util.Log;
+
+import com.TwentyCodes.android.TravelPost.Debug.Debug;
+import com.facebook.android.AsyncFacebookRunner.RequestListener;
+import com.facebook.android.FacebookError;
+
+public abstract class FacebookBaseRequestListener implements RequestListener {
+
+ public void onFacebookError(FacebookError e, final Object state) {
+ if (Debug.LOGGING)
+ Log.e("Facebook", e.getMessage());
+ e.printStackTrace();
+ }
+
+ public void onFileNotFoundException(FileNotFoundException e, final Object state) {
+ if (Debug.LOGGING)
+ Log.e("Facebook", e.getMessage());
+ e.printStackTrace();
+ }
+
+ public void onIOException(IOException e, final Object state) {
+ if (Debug.LOGGING)
+ Log.e("Facebook", e.getMessage());
+ e.printStackTrace();
+ }
+
+ public void onMalformedURLException(MalformedURLException e, final Object state) {
+ if (Debug.LOGGING)
+ Log.e("Facebook", e.getMessage());
+ e.printStackTrace();
+ }
+}
diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookEvents.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookEvents.java
new file mode 100644
index 0000000..101b64f
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookEvents.java
@@ -0,0 +1,144 @@
+/*
+ * 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.TravelPost.SocialSites;
+
+import java.util.LinkedList;
+
+public class FacebookEvents {
+
+ 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/TravelPost/SocialSites/FacebookSessionNotValidException.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookSessionNotValidException.java
new file mode 100644
index 0000000..129ecd0
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookSessionNotValidException.java
@@ -0,0 +1,16 @@
+package com.TwentyCodes.android.TravelPost.SocialSites;
+
+import android.accounts.AccountsException;
+
+public class FacebookSessionNotValidException extends AccountsException {
+
+ /**
+ * Generated serial UID
+ */
+ private static final long serialVersionUID = -6783174641458701144L;
+
+ public FacebookSessionNotValidException(String message) {
+ new AccountsException(message);
+ }
+
+}
diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookSessionStore.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookSessionStore.java
new file mode 100644
index 0000000..cbc1329
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/FacebookSessionStore.java
@@ -0,0 +1,38 @@
+package com.TwentyCodes.android.TravelPost.SocialSites;
+
+import com.TwentyCodes.android.TravelPost.Debug.Debug;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.util.Log;
+
+public class FacebookSessionStore {
+ private static final String TOKEN = "access_token";
+ private static final String EXPIRES = "expires_in";
+ private static final String KEY = "facebook-session";
+ private static final String TAG = "FacebookSessionStore";
+
+ public static boolean save(com.facebook.android.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(com.facebook.android.Facebook session, Context context) {
+ if (context == null && Debug.LOGGING)
+ Log.i(TAG, "restore().context is null");
+ 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/SocialSites/Twitter.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/Twitter.java
new file mode 100644
index 0000000..9f88778
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/SocialSites/Twitter.java
@@ -0,0 +1,17 @@
+package com.TwentyCodes.android.TravelPost.SocialSites;
+
+import android.content.Context;
+
+public class Twitter {
+
+ private Context mCtx;
+
+ public Twitter (Context ctx) {
+ this.mCtx = ctx;
+ }
+
+ public void authorize() {
+
+ }
+
+}
diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPostMain.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPostMain.java
new file mode 100644
index 0000000..a8c7fc3
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/TravelPostMain.java
@@ -0,0 +1,248 @@
+package com.TwentyCodes.android.TravelPost;
+
+import com.TwentyCodes.android.TravelPost.Debug.Debug;
+import com.TwentyCodes.android.TravelPost.SocialSites.Facebook;
+import com.TwentyCodes.android.TravelPost.SocialSites.FacebookEvents;
+import com.TwentyCodes.android.exception.ExceptionHandler;
+import com.facebook.android.DialogError;
+import com.facebook.android.FacebookError;
+import com.facebook.android.Facebook.DialogListener;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceCategory;
+import android.util.Log;
+import android.widget.Toast;
+
+public class TravelPostMain extends PreferenceActivity implements OnPreferenceClickListener {
+
+ private static final String SETTINGS = "settings"; //Shared Prefs name
+ private static final String AUTHORIZED = "authorized"; //key for shared prefs showing how many social sites are added
+ private static final String FACEBOOK = "Facebook"; //the facebook shared pref
+ private static final String TWITTER = "Twitter"; //the twitter shared pref
+ private static final String TAG = "TravelPostMain";
+
+ private static PreferenceCategory mSocialSites;
+ private static SharedPreferences mPrefs;
+ private static SharedPreferences mFacebookPrefs;
+ private static Facebook mFb;
+ private static Context mAppCtx;
+
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (Debug.LOGGING)
+ Log.i(TAG, "onCreate()");
+
+ /* Sets default uncaught exception handler */
+ Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
+
+ mAppCtx = this.getApplicationContext();
+
+ this.initActivity();
+ }
+
+ /**
+ * This method initializes the xml layout and all variables needed for that layout
+ */
+ private void initActivity() {
+ if (Debug.LOGGING)
+ Log.i(TAG, "initActivity()");
+ this.getPreferenceManager().setSharedPreferencesName(SETTINGS);
+ this.addPreferencesFromResource(R.xml.travelpostmain);
+
+ mFb = new Facebook(this); //it seems dialogs crash when handed an application context. need to use this
+ mPrefs = this.getSharedPreferences(SETTINGS, 0);
+ mFacebookPrefs = this.getSharedPreferences(FACEBOOK, 0);
+ mSocialSites = (PreferenceCategory) this.findPreference("socialsites");
+ this.findPreference("add_social_site").setOnPreferenceClickListener(this);
+ }
+
+ /**
+ * Places the preferences for the social sites
+ */
+
+ protected void initPreferences() {
+ String[] socialSites = new String[] {FACEBOOK, TWITTER};
+ /* We only need to create social site preferences if non have been authorized */
+ if (this.getSharedPreferences(SETTINGS, 0).getInt(AUTHORIZED, 0) > 0) {
+ /* This for loop searches for available social sites an adds the preference */
+ for (String site : socialSites) {
+ /*
+ * The nested if block below does two things for each social site.
+ * 1. The outer if block and the else if block first checks which site we are looking at and wether it is authorized
+ * 2. The inner if blocks check to see if the preference for the corresponding site does not exist.
+ * If both prove true it creates the preference
+ */
+ if (site.equals(FACEBOOK) && mFacebookPrefs.getBoolean(AUTHORIZED, false)) {
+ if (mSocialSites.findPreference(mAppCtx.getString(R.string.facebook)) == null) {
+ createPreference(R.string.facebook);
+ }
+ } else if (site.equals(TWITTER) && mAppCtx.getSharedPreferences(TWITTER, 0).getBoolean(AUTHORIZED, false)) {
+ if (mSocialSites.findPreference(mAppCtx.getString(R.string.twitter)) == null) {
+ createPreference(R.string.twitter);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Will display a prompt asking for what social site to add. Will be called when the add a social site is clicked.
+ * @author warren
+ */
+
+ private void displaySocialSitesDialog() {
+ final CharSequence[] sites = {this.getString(R.string.facebook), this.getString(R.string.twitter)};
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(this.getText(R.string.add_social_site));
+ builder.setItems(sites, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int item) {
+ addSocialSite(sites[item]);
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+ }
+
+ /**
+ * Adds the site and creates a preference
+ * @author warren
+ * @param site
+ */
+
+ private void addSocialSite(CharSequence site) {
+ if (Debug.LOGGING)
+ Log.i(TAG, "addSocialSite.site" + site);
+
+ if (site.equals(FACEBOOK)) {
+ if (this.getSharedPreferences(FACEBOOK, 0).getBoolean(AUTHORIZED, false)) {
+ Toast.makeText(this, this.getString(R.string.facebook_already_authorized), Toast.LENGTH_LONG);
+ } else {
+ mFb.authorize(new LoginDialogListener());
+ }
+ } else if (site.equals(TWITTER)) {
+
+ }
+ }
+
+ @Override
+ public void onStart() {
+ if (Debug.LOGGING)
+ Log.i(TAG, "onStart()");
+ initPreferences();
+ super.onStart();
+ }
+
+ @Override
+ public void onDestroy() {
+ if (Debug.LOGGING)
+ Log.i(TAG, "onDestroy()");
+ super.onDestroy();
+ }
+
+ @Override
+ public void onRestart() {
+ if (Debug.LOGGING)
+ Log.i(TAG, "onRestart()");
+ super.onRestart();
+ }
+
+ @Override
+ public void onPause() {
+ if (Debug.LOGGING)
+ Log.i(TAG, "onPause()");
+ super.onPause();
+ }
+
+ @Override
+ public void onStop() {
+ if (Debug.LOGGING)
+ Log.i(TAG, "onStop()");
+ super.onStop();
+ }
+
+ @Override
+ public void onResume() {
+ if (Debug.LOGGING)
+ Log.i(TAG, "onResume()");
+ super.onResume();
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (Debug.LOGGING)
+ Log.i(TAG, "onPreferenceClick()");
+ if (preference.getKey().equals("add_social_site")) {
+ this.displaySocialSitesDialog();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * This method creates a preferences with the given ID under the socialsites preference category.
+ * It also assigned the onclicklistener
+ * @param id - auto generated id of title of preference. (ex: R.string.facebook)
+ */
+
+ protected void createPreference(int id) {
+ Preference pref = new Preference(mAppCtx);
+ pref.setTitle(mAppCtx.getString(id));
+ pref.setKey(mAppCtx.getString(id));
+ mSocialSites.addPreference(pref);
+ pref.setOnPreferenceClickListener(this);
+ }
+
+ /**
+ * Handles facebook login callbacks
+ * @author warren
+ *
+ */
+
+ protected final class LoginDialogListener implements DialogListener {
+ public void onComplete(Bundle values, Dialog dialog) {
+ FacebookEvents.onLoginSuccess();
+ if (Debug.LOGGING)
+ Log.i(TAG, "LoginDialogListener.onComplete.login success");
+
+ SharedPreferences prefs = TravelPostMain.mPrefs;
+ SharedPreferences fbPrefs = TravelPostMain.mFacebookPrefs;
+ if (TravelPostMain.mFb.isSessionValid()) {
+ fbPrefs.edit().putBoolean(TravelPostMain.AUTHORIZED, true).commit();
+ int auths = prefs.getInt(TravelPostMain.AUTHORIZED, 0);
+ prefs.edit().putInt(TravelPostMain.AUTHORIZED, auths + 1).commit();
+ }
+ TravelPostMain tp = new TravelPostMain();
+ tp.initPreferences();
+ }
+
+ public void onFacebookError(FacebookError error) {
+ FacebookEvents.onLoginError(error.getMessage());
+ if (Debug.LOGGING)
+ Log.e(TAG, "LoginDialogListener.error: " + error.getMessage());
+ }
+
+ public void onError(DialogError error) {
+ FacebookEvents.onLoginError(error.getMessage());
+ if (Debug.LOGGING)
+ Log.e(TAG, "LoginDialogListener.error: " + error.getMessage());
+ }
+
+ public void onCancel() {
+ FacebookEvents.onLoginError("Action Canceled");
+ if (Debug.LOGGING)
+ Log.e(TAG, "LoginDialogListener.login cancelled");
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/TravelPost/src/com/TwentyCodes/android/TravelPost/UI/AboutView.java b/TravelPost/src/com/TwentyCodes/android/TravelPost/UI/AboutView.java
new file mode 100644
index 0000000..fa87402
--- /dev/null
+++ b/TravelPost/src/com/TwentyCodes/android/TravelPost/UI/AboutView.java
@@ -0,0 +1,70 @@
+package com.TwentyCodes.android.TravelPost.UI;
+
+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;
+
+public class AboutView extends Preference {
+
+
+ public AboutView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ public AboutView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public AboutView(Context context) {
+ super(context);
+ }
+
+ /**
+ * 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(this.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;
+ }
+
+}