Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added tweets

  • Loading branch information...
commit acc6e3649adc54266f4ac163b991948645c3658b 1 parent 9a3cbc8
Codeskraps authored
Showing with 769 additions and 93 deletions.
  1. +3 −1 .classpath
  2. +20 −17 AndroidManifest.xml
  3. BIN  libs/commons-codec-1.7.jar
  4. BIN  libs/gson-2.2.2.jar
  5. BIN  libs/scribe-1.3.0.jar
  6. BIN  res/drawable-hdpi/alerts_and_states_error.png
  7. BIN  res/drawable-mdpi/alerts_and_states_error.png
  8. BIN  res/drawable-xhdpi/alerts_and_states_error.png
  9. +88 −0 res/layout/facebook_signin.xml
  10. +3 −4 res/layout/header.xml
  11. +3 −3 res/layout/prefs.xml
  12. +36 −0 res/layout/tweet.xml
  13. +29 −0 res/layout/twitter_account.xml
  14. +88 −0 res/layout/twitter_signin.xml
  15. +3 −3 res/layout/{add_acount.xml → wordpress_acount.xml}
  16. +8 −6 res/menu/activity_main.xml
  17. +25 −5 res/values/strings.xml
  18. +1 −1  res/values/styles.xml
  19. +7 −2 res/xml/preferences.xml
  20. +3 −1 src/com/codeskraps/lolo/{ → home}/AboutActivity.java
  21. +7 −5 src/com/codeskraps/lolo/{ → home}/AddAcount.java
  22. +1 −1  src/com/codeskraps/lolo/{ → home}/LoloApp.java
  23. +6 −1 src/com/codeskraps/lolo/{ → home}/LoloProvider.java
  24. +36 −4 src/com/codeskraps/lolo/{ → home}/PrefsActivity.java
  25. +6 −2 src/com/codeskraps/lolo/{ → home}/UpdateWidgetReceiver.java
  26. +7 −2 src/com/codeskraps/lolo/{ → misc}/Constants.java
  27. +6 −24 src/com/codeskraps/lolo/{ → misc}/Utils.java
  28. +122 −0 src/com/codeskraps/lolo/twitter/TweetActivity.java
  29. +125 −0 src/com/codeskraps/lolo/twitter/TwitterAccountActivity.java
  30. +125 −0 src/com/codeskraps/lolo/twitter/TwitterSignInActivity.java
  31. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/ApiHelper.java
  32. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/Base64.java
  33. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/Base64Coder.java
  34. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/ConnectionClient.java
  35. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/MediaFile.java
  36. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/TrustAllManager.java
  37. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/TrustAllSSLSocketFactory.java
  38. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/XMLRPCClient.java
  39. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/XMLRPCException.java
  40. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/XMLRPCFault.java
  41. +1 −1  src/com/codeskraps/{ → lolo}/wordpress/XMLRPCSerializer.java
View
4 .classpath
@@ -4,7 +4,9 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="libs/acra-4.2.3.jar"/>
+ <classpathentry kind="lib" path="libs/commons-codec-1.7.jar"/>
+ <classpathentry kind="lib" path="libs/scribe-1.3.0.jar"/>
+ <classpathentry kind="lib" path="libs/gson-2.2.2.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="src" path="/matshofman-Android-RSS-Reader-Library-390ce54"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
View
37 AndroidManifest.xml
@@ -1,41 +1,44 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codeskraps.lolo"
- android:versionCode="19"
- android:versionName="1.18" >
+ android:versionCode="20"
+ android:versionName="2.0" >
<!-- Remember to update the info code version -->
<uses-sdk
- android:minSdkVersion="7"
- android:targetSdkVersion="10" />
+ android:minSdkVersion="14"
+ android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
- android:name=".LoloApp"
+ android:name=".home.LoloApp"
+ android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name=".PrefsActivity"
- android:theme="@android:style/Theme.Light.NoTitleBar" >
+ android:theme="@android:style/Theme.Holo.Light.DarkActionBar" >
+ <activity android:name=".home.PrefsActivity" >
<intent-filter>
- <action android:name="android.intent.action.MAIN" />
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".twitter.TwitterSignInActivity" />
+ <activity android:name=".twitter.TwitterAccountActivity" />
+ <activity android:name=".twitter.TweetActivity" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name=".home.AddAcount" />
<activity
- android:name=".AboutActivity"
+ android:name=".home.AboutActivity"
android:theme="@style/Theme.Translucent" />
- <activity
- android:name=".AddAcount"
- android:theme="@android:style/Theme.Light.NoTitleBar" />
<receiver
- android:name=".LoloProvider"
+ android:name=".home.LoloProvider"
android:exported="true" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
@@ -46,14 +49,14 @@
android:resource="@xml/loloinfo" />
</receiver>
<receiver
- android:name=".LoloProvider"
+ android:name=".home.LoloProvider"
android:exported="false" >
<intent-filter>
<action android:name="com.codeskraps.lolo.FORCE_WIDGET_UPDATE" />
</intent-filter>
</receiver>
<receiver
- android:name=".UpdateWidgetReceiver"
+ android:name=".home.UpdateWidgetReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.codeskraps.lolo.BROADCAST_RECEIVER" />
View
BIN  libs/commons-codec-1.7.jar
Binary file not shown
View
BIN  libs/gson-2.2.2.jar
Binary file not shown
View
BIN  libs/scribe-1.3.0.jar
Binary file not shown
View
BIN  res/drawable-hdpi/alerts_and_states_error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable-mdpi/alerts_and_states_error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable-xhdpi/alerts_and_states_error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
88 res/layout/facebook_signin.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="#FF0000" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="10dp"
+ android:text="@string/twi_help"
+ android:textColor="#444444" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_margin="5dp"
+ android:background="#555" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:text="@string/twi_stepone"
+ android:textAppearance="@android:style/TextAppearance.Holo.Large" />
+
+ <Button
+ android:id="@+id/fac_btn_goto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="10dp"
+ android:text="@string/twi_goto" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="10dp"
+ android:text="@string/twi_steptwo"
+ android:textAppearance="@android:style/TextAppearance.Holo.Large" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dp"
+ android:layout_marginTop="10dp"
+ android:text="@string/twi_enterkey"
+ android:textColor="#444444" />
+
+ <EditText
+ android:id="@+id/fac_etxt_key"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:inputType="number"
+ android:minHeight="40dp"
+ android:singleLine="true" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="right"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/fac_cancel"
+ style="@android:attr/buttonBarStyle"
+ android:layout_width="100dip"
+ android:layout_height="wrap_content"
+ android:text="@string/cancel" />
+
+ <Button
+ android:id="@+id/fac_submit"
+ style="@android:attr/buttonBarStyle"
+ android:layout_width="100dip"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:text="@string/twi_submit" />
+ </LinearLayout>
+
+</LinearLayout>
View
7 res/layout/header.xml
@@ -19,14 +19,13 @@
android:layout_marginTop="15dp"
android:text="@string/app_name"
android:textColor="#AAAAAA"
- android:textSize="25dp"
+ android:textSize="25sp"
android:typeface="normal" />
</LinearLayout>
- <LinearLayout
+ <View
android:layout_width="match_parent"
android:layout_height="1dp"
- android:background="#FF0000"
- android:orientation="horizontal" />
+ android:background="#FF0000" />
</merge>
View
6 res/layout/prefs.xml
@@ -4,10 +4,10 @@
android:layout_height="match_parent"
android:orientation="vertical" >
- <include
+ <View
android:layout_width="match_parent"
- android:layout_height="match_parent"
- layout="@layout/header" />
+ android:layout_height="1dp"
+ android:background="#FF0000" />
<ListView
android:id="@android:id/list"
View
36 res/layout/tweet.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="right"
+ android:orientation="vertical" >
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="#FF0000" />
+
+ <EditText
+ android:id="@+id/twe_etxt_data"
+ android:layout_width="match_parent"
+ android:layout_height="150dp"
+ android:layout_margin="10dp"
+ android:gravity="top"
+ android:hint="@string/twe_enter"
+ android:inputType="text" />
+
+ <TextView
+ android:id="@+id/twe_txt_feedback"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:textIsSelectable="false" />
+
+ <Button
+ android:id="@+id/twe_btn_submit"
+ android:layout_width="100dp"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="10dp"
+ android:text="@string/twi_submit" />
+
+</LinearLayout>
View
29 res/layout/twitter_account.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="#FF0000" />
+
+ <ImageView
+ android:id="@+id/tac_img_user"
+ android:layout_width="45dp"
+ android:layout_height="45dp"
+ android:layout_marginTop="10dp"
+ android:layout_margin="10dp"
+ android:contentDescription="@string/contentDescription" />
+
+ <TextView
+ android:id="@+id/tac_txt_name"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="10dp"
+ android:textAppearance="@android:style/TextAppearance.Holo.Large"
+ android:textColor="#444444"
+ android:textIsSelectable="false" />
+
+</LinearLayout>
View
88 res/layout/twitter_signin.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="#FF0000" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="10dp"
+ android:text="@string/twi_help"
+ android:textColor="#444444" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_margin="5dp"
+ android:background="#555" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:text="@string/twi_stepone"
+ android:textAppearance="@android:style/TextAppearance.Holo.Large" />
+
+ <Button
+ android:id="@+id/twi_btn_goto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="10dp"
+ android:text="@string/twi_goto" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="10dp"
+ android:text="@string/twi_steptwo"
+ android:textAppearance="@android:style/TextAppearance.Holo.Large" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dp"
+ android:layout_marginTop="10dp"
+ android:text="@string/twi_enterkey"
+ android:textColor="#444444" />
+
+ <EditText
+ android:id="@+id/twi_etxt_key"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:inputType="number"
+ android:minHeight="40dp"
+ android:singleLine="true" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="right"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/twi_cancel"
+ style="@android:attr/buttonBarStyle"
+ android:layout_width="100dip"
+ android:layout_height="wrap_content"
+ android:text="@string/cancel" />
+
+ <Button
+ android:id="@+id/twi_submit"
+ style="@android:attr/buttonBarStyle"
+ android:layout_width="100dip"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:text="@string/twi_submit" />
+ </LinearLayout>
+
+</LinearLayout>
View
6 res/layout/add_acount.xml → res/layout/wordpress_acount.xml
@@ -4,10 +4,10 @@
android:layout_height="match_parent"
android:orientation="vertical" >
- <include
+ <View
android:layout_width="match_parent"
- android:layout_height="match_parent"
- layout="@layout/header" />
+ android:layout_height="1dp"
+ android:background="#FF0000" />
<TextView
android:layout_width="fill_parent"
View
14 res/menu/activity_main.xml
@@ -1,6 +1,8 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/menu_settings"
- android:title="@string/menu_settings"
- android:orderInCategory="100"
- android:showAsAction="never" />
-</menu>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/men_settings"
+ android:showAsAction="always"
+ android:title="@string/men_setting"/>
+
+</menu>
View
30 res/values/strings.xml
@@ -1,12 +1,11 @@
<resources>
<string name="app_name">091 Labs lo-lo</string>
- <string name="menu_settings">Settings</string>
<string name="contentDescription">lo-lo Image</string>
<string name="iconImageDescription">logo</string>
<!-- Preference Activity -->
- <string name="prefsCat_General">General</string>
+ <string name="prefsCat_General">Widget</string>
<string name="prefsSync_title">Show last sync time</string>
<string name="prefsSync_summarNot">Not yet synced!</string>
<string name="prefs24_title">Use 24-hour format</string>
@@ -49,10 +48,10 @@
</string-array>
<string name="prefsCat_Info">Information</string>
- <string name="prefsInfo_Title">091 Labs lo-lo v1.18</string>
- <string name="prefsInfo_summary">GNU GPL License v3 &#8211; 2012</string>
+ <string name="prefsInfo_Title">091 Labs lo-lo v2.0</string>
+ <string name="prefsInfo_summary">GNU GPL License v3 &#8211; 2013</string>
- <!-- Add Acount -->
+ <!-- WordPress Acount -->
<string name="username">Username:</string>
<string name="password">Password:</string>
<string name="save">Save</string>
@@ -67,6 +66,27 @@
<string name="error">Error</string>
<string name="no_site_error">Sorry, could not connect to the WordPress site. Please try again later.</string>
+ <!-- Twitter Accont -->
+ <string name="twi_help">You got to sign in to Twitter using OAth and allow access to 091 Labs lo-lo app. Once you do it will give a code, come here and enter the code you are given.</string>
+ <string name="twi_stepone">Step One</string>
+ <string name="twi_steptwo">Setp Two</string>
+ <string name="twi_goto">Go to Twitter</string>
+ <string name="twi_enterkey">Enter key:</string>
+ <string name="twi_submit">Submit</string>
+ <string name="twi_dia_title">Error!</string>
+ <string name="twi_dia_ok">OK</string>
+ <string name="twi_dia_message">Something has gone wrong&#8230;</string>
+
+ <!-- Tweet -->
+ <string name="twe_enter">Enter tweet here</string>
+
+ <!-- Facebook -->
+ <string name="fac_help">You got to sign in to Facebook using OAth and allow access to 091 Labs lo-lo app. Once you do it will give a code, come here and enter the code you are given.</string>
+ <string name="fac_goto">Go to Facebook</string>
+
+ <!-- Menu -->
+ <string name="men_setting">Settings</string>
+
<!-- About -->
<string name="about_title">091 Labs lo-lo</string>
<string name="about_summary">About</string>
View
2  res/values/styles.xml
@@ -1,6 +1,6 @@
<resources>
- <style name="AppTheme" parent="android:Theme.Light" />
+ <style name="AppTheme" parent="android:Theme" />
<drawable name="transparent_background">#DD000000</drawable>
View
9 res/xml/preferences.xml
@@ -33,9 +33,14 @@
android:title="@string/prefsInterval_title" />
</PreferenceCategory>
<PreferenceCategory android:title="Accounts" >
+
+ <!-- <Preference -->
+ <!-- android:key="prefWordPressAccount" -->
+ <!-- android:title="091Labs.com account" /> -->
+
<Preference
- android:key="prefAccount"
- android:title="091Labs.com account" />
+ android:key="prefTwitterAccount"
+ android:title="Twitter account" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefsCat_Info" >
<Preference
View
4 src/com/codeskraps/lolo/AboutActivity.java → src/com/codeskraps/lolo/home/AboutActivity.java
@@ -1,4 +1,6 @@
-package com.codeskraps.lolo;
+package com.codeskraps.lolo.home;
+
+import com.codeskraps.lolo.R;
import android.app.Activity;
import android.os.Bundle;
View
12 src/com/codeskraps/lolo/AddAcount.java → src/com/codeskraps/lolo/home/AddAcount.java
@@ -1,4 +1,4 @@
-package com.codeskraps.lolo;
+package com.codeskraps.lolo.home;
import java.io.IOException;
import java.io.InputStream;
@@ -29,9 +29,11 @@
import android.widget.EditText;
import android.widget.ListView;
-import com.codeskraps.wordpress.ApiHelper;
-import com.codeskraps.wordpress.XMLRPCClient;
-import com.codeskraps.wordpress.XMLRPCException;
+import com.codeskraps.lolo.R;
+import com.codeskraps.lolo.misc.Utils;
+import com.codeskraps.lolo.wordpress.ApiHelper;
+import com.codeskraps.lolo.wordpress.XMLRPCClient;
+import com.codeskraps.lolo.wordpress.XMLRPCException;
public class AddAcount extends Activity implements OnClickListener {
private static final String TAG = AddAcount.class.getSimpleName();
@@ -50,7 +52,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.add_acount);
+ setContentView(R.layout.wordpress_acount);
etxtUsername = (EditText) findViewById(R.id.username);
etxtPassword = (EditText) findViewById(R.id.password);
View
2  src/com/codeskraps/lolo/LoloApp.java → src/com/codeskraps/lolo/home/LoloApp.java
@@ -1,4 +1,4 @@
-package com.codeskraps.lolo;
+package com.codeskraps.lolo.home;
import org.acra.ACRA;
import org.acra.annotation.ReportsCrashes;
View
7 src/com/codeskraps/lolo/LoloProvider.java → src/com/codeskraps/lolo/home/LoloProvider.java
@@ -19,7 +19,12 @@
* If not, see http://www.gnu.org/licenses.
*/
-package com.codeskraps.lolo;
+package com.codeskraps.lolo.home;
+
+import com.codeskraps.lolo.BuildConfig;
+import com.codeskraps.lolo.R;
+import com.codeskraps.lolo.misc.Constants;
+import com.codeskraps.lolo.misc.Utils;
import android.app.AlarmManager;
import android.app.PendingIntent;
View
40 src/com/codeskraps/lolo/PrefsActivity.java → src/com/codeskraps/lolo/home/PrefsActivity.java
@@ -19,7 +19,7 @@
* If not, see http://www.gnu.org/licenses.
*/
-package com.codeskraps.lolo;
+package com.codeskraps.lolo.home;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
@@ -35,6 +35,13 @@
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.MenuItem;
+
+import com.codeskraps.lolo.BuildConfig;
+import com.codeskraps.lolo.R;
+import com.codeskraps.lolo.misc.Constants;
+import com.codeskraps.lolo.twitter.TwitterAccountActivity;
+import com.codeskraps.lolo.twitter.TwitterSignInActivity;
public class PrefsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener,
OnPreferenceClickListener {
@@ -55,6 +62,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (BuildConfig.DEBUG) Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
addPreferencesFromResource(R.xml.preferences);
setContentView(R.layout.prefs);
@@ -69,7 +77,9 @@ protected void onCreate(Bundle savedInstanceState) {
chkSync = (CheckBoxPreference) findPreference(Constants.SHOW_SYNC);
chk24 = (CheckBoxPreference) findPreference(Constants.HOUR24);
lstInterval = (ListPreference) findPreference(Constants.INTERVAL);
- ((Preference) findPreference(Constants.ADD_ACOUNT)).setOnPreferenceClickListener(this);
+// ((Preference) findPreference(Constants.WORDPRESS_ACOUNT))
+// .setOnPreferenceClickListener(this);
+ ((Preference) findPreference(Constants.TWITTER_ACCOUNT)).setOnPreferenceClickListener(this);
((Preference) findPreference(Constants.ABOUT)).setOnPreferenceClickListener(this);
}
@@ -147,10 +157,22 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
@Override
public boolean onPreferenceClick(Preference pref) {
- if (pref.getKey().equals(Constants.ABOUT))
+ if (pref.getKey().equals(Constants.ABOUT)) {
startActivity(new Intent(this, AboutActivity.class));
- if (pref.getKey().equals(Constants.ADD_ACOUNT))
+ } else if (pref.getKey().equals(Constants.WORDPRESS_ACOUNT)) {
startActivity(new Intent(this, AddAcount.class));
+ } else if (pref.getKey().equals(Constants.TWITTER_ACCOUNT)) {
+ SharedPreferences prefs = PreferenceManager
+ .getDefaultSharedPreferences(getApplication());
+ String token = prefs.getString(Constants.ACCESS_TOKEN, null);
+ String secret = prefs.getString(Constants.ACCESS_SECRET, null);
+
+ if (token == null || secret == null) {
+ startActivity(new Intent(this, TwitterSignInActivity.class));
+ } else {
+ startActivity(new Intent(this, TwitterAccountActivity.class));
+ }
+ }
return true;
}
@@ -192,4 +214,14 @@ public void onBackPressed() {
super.onBackPressed();
}
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+ }
+ return true;
+ }
}
View
8 src/com/codeskraps/lolo/UpdateWidgetReceiver.java → ...om/codeskraps/lolo/home/UpdateWidgetReceiver.java
@@ -1,4 +1,4 @@
-package com.codeskraps.lolo;
+package com.codeskraps.lolo.home;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -20,7 +20,11 @@
import android.view.View;
import android.widget.RemoteViews;
-import com.codeskraps.lolo.Constants.LOLO;
+import com.codeskraps.lolo.BuildConfig;
+import com.codeskraps.lolo.R;
+import com.codeskraps.lolo.misc.Constants;
+import com.codeskraps.lolo.misc.Constants.LOLO;
+import com.codeskraps.lolo.misc.Utils;
public class UpdateWidgetReceiver extends BroadcastReceiver {
private static final String TAG = UpdateWidgetReceiver.class.getSimpleName();
View
9 src/com/codeskraps/lolo/Constants.java → src/com/codeskraps/lolo/misc/Constants.java
@@ -1,7 +1,9 @@
-package com.codeskraps.lolo;
+package com.codeskraps.lolo.misc;
public class Constants {
+ private Constants() {}
+
public static final String LOLO_URL = "http://scruffy.091labs.com/lolo/json/status.json";
public static final String LOLO_RSS = "http://091labs.com/feed/";
@@ -15,10 +17,13 @@
public static final String SHOW_SYNC = "chkSync";
public static final String HOUR24 = "chk24";
public static final String INTERVAL = "lstInterval";
- public static final String ADD_ACOUNT = "prefAccount";
+ public static final String WORDPRESS_ACOUNT = "prefWordPressAccount";
+ public static final String TWITTER_ACCOUNT = "prefTwitterAccount";
public static final String ABOUT = "prefAbout";
public static final String FIRST_LAUNCH = "firstLaunch";
public static final String RSS_TITLE = "rsstitle";
+ public static final String ACCESS_TOKEN = "accestoken";
+ public static final String ACCESS_SECRET = "accesssecret";
public enum LOLO {
ON, OFF, NULL;
View
30 src/com/codeskraps/lolo/Utils.java → src/com/codeskraps/lolo/misc/Utils.java
@@ -19,18 +19,12 @@
* If not, see http://www.gnu.org/licenses.
*/
-package com.codeskraps.lolo;
+package com.codeskraps.lolo.misc;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.util.ArrayList;
-
-import nl.matshofman.saxrssreader.RssFeed;
-import nl.matshofman.saxrssreader.RssItem;
-import nl.matshofman.saxrssreader.RssReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
@@ -43,9 +37,6 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
-import org.xml.sax.SAXException;
-
-import com.codeskraps.lolo.Constants.LOLO;
import android.app.PendingIntent;
import android.content.Context;
@@ -57,6 +48,11 @@
import android.preference.PreferenceManager;
import android.util.Log;
+import com.codeskraps.lolo.BuildConfig;
+import com.codeskraps.lolo.R;
+import com.codeskraps.lolo.home.PrefsActivity;
+import com.codeskraps.lolo.misc.Constants.LOLO;
+
public class Utils {
private static final String TAG = Utils.class.getSimpleName();
@@ -139,18 +135,4 @@ public static PendingIntent getOnTouchIntent(Context context) {
}
return pendingIntent;
}
-
- public static String[] getRSSFedd(String title) throws SAXException, IOException {
-
- URL url = new URL("http://091labs.com/feed/");
- RssFeed feed = RssReader.read(url);
-
- ArrayList<RssItem> rssItems = feed.getRssItems();
- Log.i(TAG, "RSS Items" + rssItems.size());
- for (RssItem rssItem : rssItems) {
- Log.i(TAG, "RSS Reader" + rssItem.getTitle());
- }
-
- return null;
- }
}
View
122 src/com/codeskraps/lolo/twitter/TweetActivity.java
@@ -0,0 +1,122 @@
+package com.codeskraps.lolo.twitter;
+
+import org.scribe.builder.ServiceBuilder;
+import org.scribe.builder.api.TwitterApi;
+import org.scribe.model.OAuthRequest;
+import org.scribe.model.Response;
+import org.scribe.model.Token;
+import org.scribe.model.Verb;
+import org.scribe.oauth.OAuthService;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.codeskraps.lolo.R;
+import com.codeskraps.lolo.home.PrefsActivity;
+import com.codeskraps.lolo.misc.Constants;
+
+public class TweetActivity extends Activity implements OnClickListener {
+ private static final String TAG = TweetActivity.class.getSimpleName();
+ private static final String PROTECTED_RESOURCE_URL = "https://api.twitter.com/1/statuses/update.json";
+
+ private OAuthService service = null;
+ private EditText etxtTweet = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ service = new ServiceBuilder().provider(TwitterApi.class).apiKey("Z4lEh5rSu0rV3fXt37gw7A")
+ .apiSecret("vLLTqO311ZhlVXhl1GaB72DnIwdCOPwzeozNRWy3I").build();
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+
+ setContentView(R.layout.tweet);
+
+ etxtTweet = (EditText) findViewById(R.id.twe_etxt_data);
+ ((Button) findViewById(R.id.twe_btn_submit)).setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ new PostTask().execute();
+ }
+
+ private class PostTask extends AsyncTask<Void, Void, String> {
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ setProgressBarIndeterminateVisibility(Boolean.TRUE);
+ }
+
+ @Override
+ protected String doInBackground(Void... params) {
+ try {
+ SharedPreferences prefs = PreferenceManager
+ .getDefaultSharedPreferences(getApplication());
+ String token = prefs.getString(Constants.ACCESS_TOKEN, null);
+ String secret = prefs.getString(Constants.ACCESS_SECRET, null);
+
+ Token accessToken = new Token(token, secret);
+
+ OAuthRequest request = new OAuthRequest(Verb.POST, PROTECTED_RESOURCE_URL);
+ request.addBodyParameter("status", etxtTweet.getText().toString());
+ service.signRequest(accessToken, request);
+ Response response = request.send();
+ Log.d(TAG, response.getBody());
+
+ return response.getBody();
+
+ } catch (Exception e) {
+ Log.i(TAG, "Handled: posting - " + e.getMessage(), e);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(String result) {
+ super.onPostExecute(result);
+
+ setProgressBarIndeterminateVisibility(Boolean.FALSE);
+
+ TextView txtFeedBack = (TextView) findViewById(R.id.twe_txt_feedback);
+ String message = null;
+ if (result != null && result.startsWith("{")) {
+ message = "Tweet posted succesfully!";
+ } else {
+ message = "Something has gone wrong!";
+ }
+ txtFeedBack.setText(message);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.activity_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.men_settings:
+ startActivity(new Intent(this, PrefsActivity.class));
+ break;
+ }
+ return true;
+ }
+}
View
125 src/com/codeskraps/lolo/twitter/TwitterAccountActivity.java
@@ -0,0 +1,125 @@
+package com.codeskraps.lolo.twitter;
+
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.scribe.builder.ServiceBuilder;
+import org.scribe.builder.api.TwitterApi;
+import org.scribe.model.OAuthRequest;
+import org.scribe.model.Response;
+import org.scribe.model.Token;
+import org.scribe.model.Verb;
+import org.scribe.oauth.OAuthService;
+
+import android.app.Activity;
+import android.content.SharedPreferences;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.MenuItem;
+import android.view.Window;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.codeskraps.lolo.R;
+import com.codeskraps.lolo.misc.Constants;
+import com.google.gson.Gson;
+
+public class TwitterAccountActivity extends Activity {
+ private static final String TAG = TwitterAccountActivity.class.getSimpleName();
+
+ private OAuthService service = null;
+ private Bitmap bm = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ setContentView(R.layout.twitter_account);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ service = new ServiceBuilder().provider(TwitterApi.class).apiKey("Z4lEh5rSu0rV3fXt37gw7A")
+ .apiSecret("vLLTqO311ZhlVXhl1GaB72DnIwdCOPwzeozNRWy3I").build();
+
+ new GetTask().execute();
+ }
+
+ private class GetTask extends AsyncTask<Void, Void, String> {
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ setProgressBarIndeterminateVisibility(Boolean.TRUE);
+ }
+
+ @Override
+ protected String doInBackground(Void... params) {
+
+ SharedPreferences prefs = PreferenceManager
+ .getDefaultSharedPreferences(getApplication());
+ String token = prefs.getString(Constants.ACCESS_TOKEN, null);
+ String secret = prefs.getString(Constants.ACCESS_SECRET, null);
+
+ Token accessToken = new Token(token, secret);
+
+ OAuthRequest request = new OAuthRequest(Verb.GET,
+ "https://api.twitter.com/1/account/verify_credentials.json");
+ service.signRequest(accessToken, request);
+ Response response = request.send();
+ Log.d(TAG, response.getBody());
+
+ Map<String, Object> JResult = new HashMap<String, Object>();
+ JResult = new Gson().fromJson(response.getBody(), JResult.getClass());
+
+ try {
+ URL url = new URL((String) JResult.get("profile_image_url"));
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoInput(true);
+ conn.connect();
+ InputStream is = conn.getInputStream();
+ bm = BitmapFactory.decodeStream(is);
+ } catch (Exception e) {
+ Log.i(TAG, "Handled: image - " + e.getMessage(), e);
+ }
+
+ return response.getBody();
+ }
+
+ @Override
+ protected void onPostExecute(String result) {
+ super.onPostExecute(result);
+
+ setProgressBarIndeterminateVisibility(Boolean.FALSE);
+
+ ((ImageView) findViewById(R.id.tac_img_user)).setImageBitmap(bm);
+
+ Map<String, Object> JResult = new HashMap<String, Object>();
+ JResult = new Gson().fromJson(result, JResult.getClass());
+
+ TextView user = (TextView) findViewById(R.id.tac_txt_name);
+ user.setText((String) JResult.get("name") + "\n" + (String) JResult.get("location"));
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+ }
+ return true;
+ }
+}
View
125 src/com/codeskraps/lolo/twitter/TwitterSignInActivity.java
@@ -0,0 +1,125 @@
+package com.codeskraps.lolo.twitter;
+
+import org.scribe.builder.ServiceBuilder;
+import org.scribe.builder.api.TwitterApi;
+import org.scribe.model.Token;
+import org.scribe.model.Verifier;
+import org.scribe.oauth.OAuthService;
+
+import com.codeskraps.lolo.R;
+import com.codeskraps.lolo.misc.Constants;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class TwitterSignInActivity extends Activity implements OnClickListener {
+ private static final String TAG = TwitterSignInActivity.class.getSimpleName();
+
+ private OAuthService service = null;
+ private Token requestToken = null;
+
+ private enum STEP {
+ zero, one, two
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ service = new ServiceBuilder().provider(TwitterApi.class).apiKey("Z4lEh5rSu0rV3fXt37gw7A")
+ .apiSecret("vLLTqO311ZhlVXhl1GaB72DnIwdCOPwzeozNRWy3I").build();
+ new OathTask().execute(STEP.zero);
+
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ setContentView(R.layout.twitter_signin);
+
+ ((Button) findViewById(R.id.twi_btn_goto)).setOnClickListener(this);
+ ((Button) findViewById(R.id.twi_submit)).setOnClickListener(this);
+ ((Button) findViewById(R.id.twi_cancel)).setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ // @formatter:off
+ switch (v.getId()) {
+ case R.id.twi_btn_goto: new OathTask().execute(STEP.one); break;
+ case R.id.twi_submit: new OathTask().execute(STEP.two); break;
+ case R.id.twi_cancel: finish(); break;
+ // @formatter:on
+ }
+ }
+
+ private class OathTask extends AsyncTask<STEP, Void, Void> {
+
+ @Override
+ protected Void doInBackground(STEP... params) {
+ STEP step = params[0];
+
+ if (step == STEP.zero) {
+ requestToken = service.getRequestToken();
+ }
+ if (step == STEP.one) {
+ String token = service.getAuthorizationUrl(requestToken);
+
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(token));
+ startActivity(browserIntent);
+
+ } else if (step == STEP.two) {
+ try {
+ TextView txtCode = (TextView) findViewById(R.id.twi_etxt_key);
+ String code = txtCode.getText().toString().trim();
+ Log.d(TAG, "code:" + code);
+
+ Verifier verifier = new Verifier(code);
+ Token accessToken = service.getAccessToken(requestToken, verifier);
+ Log.d(TAG, "accessToken:" + accessToken);
+
+ SharedPreferences.Editor editor = PreferenceManager
+ .getDefaultSharedPreferences(getApplication()).edit();
+ editor.putString(Constants.ACCESS_TOKEN, accessToken.getToken());
+ editor.putString(Constants.ACCESS_SECRET, accessToken.getSecret());
+ editor.commit();
+
+ TwitterSignInActivity.this.finish();
+
+ } catch (Exception e) {
+ new AlertDialog.Builder(TwitterSignInActivity.this)
+ .setIcon(R.drawable.alerts_and_states_error)
+ .setMessage(R.string.twi_dia_message)
+ .setTitle(R.string.twi_dia_title)
+ .setPositiveButton(R.string.twi_dia_ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.dismiss();
+ }
+ }).create().show();
+ }
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+ }
+ return true;
+ }
+}
View
2  src/com/codeskraps/wordpress/ApiHelper.java → src/com/codeskraps/lolo/wordpress/ApiHelper.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
import java.io.BufferedReader;
import java.io.IOException;
View
2  src/com/codeskraps/wordpress/Base64.java → src/com/codeskraps/lolo/wordpress/Base64.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
/**
* <p>Encodes and decodes to and from Base64 notation.</p>
View
2  src/com/codeskraps/wordpress/Base64Coder.java → src/com/codeskraps/lolo/wordpress/Base64Coder.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
/**
* A Base64 Encoder/Decoder.
View
2  src/com/codeskraps/wordpress/ConnectionClient.java → ...m/codeskraps/lolo/wordpress/ConnectionClient.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
View
2  src/com/codeskraps/wordpress/MediaFile.java → src/com/codeskraps/lolo/wordpress/MediaFile.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
public class MediaFile {
View
2  src/com/codeskraps/wordpress/TrustAllManager.java → ...om/codeskraps/lolo/wordpress/TrustAllManager.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
View
2  ...odeskraps/wordpress/TrustAllSSLSocketFactory.java → ...raps/lolo/wordpress/TrustAllSSLSocketFactory.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
import org.apache.http.conn.scheme.SocketFactory;
import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
View
2  src/com/codeskraps/wordpress/XMLRPCClient.java → src/com/codeskraps/lolo/wordpress/XMLRPCClient.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
import java.io.ByteArrayInputStream;
import java.io.File;
View
2  src/com/codeskraps/wordpress/XMLRPCException.java → ...om/codeskraps/lolo/wordpress/XMLRPCException.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
public class XMLRPCException extends Exception {
View
2  src/com/codeskraps/wordpress/XMLRPCFault.java → src/com/codeskraps/lolo/wordpress/XMLRPCFault.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
public class XMLRPCFault extends XMLRPCException {
/**
View
2  src/com/codeskraps/wordpress/XMLRPCSerializer.java → ...m/codeskraps/lolo/wordpress/XMLRPCSerializer.java
@@ -1,4 +1,4 @@
-package com.codeskraps.wordpress;
+package com.codeskraps.lolo.wordpress;
import java.io.BufferedReader;
import java.io.DataInputStream;
Please sign in to comment.
Something went wrong with that request. Please try again.