diff --git a/NOTICE b/NOTICE
index 871aaf9..8db9abc 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,4 +1,4 @@
-Spring for Android Samples 1.0.0.RC1
+Spring for Android Samples 1.0.0.RELEASE
Copyright (c) 2010-2012 VMware, Inc. All Rights Reserved.
This product is licensed to you under the Apache License, Version 2.0 (the "License").
diff --git a/spring-android-facebook-client/.gitignore b/spring-android-facebook-client/.gitignore
new file mode 100644
index 0000000..2f1df96
--- /dev/null
+++ b/spring-android-facebook-client/.gitignore
@@ -0,0 +1,7 @@
+.DS_Store
+bin
+gen
+target
+.project
+.classpath
+.settings
diff --git a/spring-android-facebook-client/AndroidManifest.xml b/spring-android-facebook-client/AndroidManifest.xml
new file mode 100644
index 0000000..fea0b98
--- /dev/null
+++ b/spring-android-facebook-client/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-android-facebook-client/README.md b/spring-android-facebook-client/README.md
new file mode 100644
index 0000000..d7b50fc
--- /dev/null
+++ b/spring-android-facebook-client/README.md
@@ -0,0 +1,36 @@
+# Spring for Android Facebook Client
+
+## Introduction
+
+This sample app includes an Android client which connects to Twitter. This illustrate the integration of [Spring Social](http://www.springsource.org/spring-social) with [Spring for Android](http://www.springsource.org/spring-android). The Android client project requires set up of the Android SDK. See the main README at the root of this repository for more information about configuring your environment.
+
+## Build and Run the Android Client
+
+1. Navigate to the client directory:
+
+ $ cd spring-android-facebook-client
+
+2. Build the app:
+
+ $ mvn clean install
+
+3. Start the emulator using the Android Maven Plugin:
+
+ $ mvn android:emulator-start
+
+ Alternatively, you can start the emulator using the Android command line tools:
+
+ $ emulator @Default
+
+ _IMPORTANT: Ensure the emulator is fully initialized and ready or the deploy will fail._
+
+4. Deploy the app to the emulator:
+
+ $ mvn android:deploy
+
+5. Start the sample app:
+
+ $ mvn android:run
+
+ _Note: the Android Maven Plugin will attempt to deploy and run the app to all available devices, both emulators and physical devices attached to your computer._
+
diff --git a/spring-android-facebook-client/pom.xml b/spring-android-facebook-client/pom.xml
new file mode 100644
index 0000000..a2c24df
--- /dev/null
+++ b/spring-android-facebook-client/pom.xml
@@ -0,0 +1,197 @@
+
+ 4.0.0
+
+ org.springframework.android
+ spring-android-facebook-client
+ 1.0.0.RELEASE
+ apk
+ spring-android-facebook-client
+ http://www.springsource.org/spring-android
+
+ SpringSource
+ http://www.springsource.org
+
+
+
+ 15
+ 3.2.0
+ 2.3.2
+ 1.6
+ 2.8
+ 4.0.1.2
+
+ 1.0.0.RELEASE
+ 1.0.2.RELEASE
+ 1.0.1.RELEASE
+ 3.1.0.RELEASE
+ 1.9.7
+
+
+
+
+ com.google.android
+ android
+ ${com.google.android-version}
+ provided
+
+
+ org.springframework.android
+ spring-android-rest-template
+ ${org.springframework.android-version}
+
+
+ org.springframework.android
+ spring-android-auth
+ ${org.springframework.android-version}
+
+
+ org.springframework.security
+ spring-security-crypto
+ ${org.springframework.security-version}
+
+
+
+ spring-core
+ org.springframework
+
+
+
+
+ org.springframework.social
+ spring-social-core
+ ${org.springframework.social-version}
+
+
+
+ spring-web
+ org.springframework
+
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ org.springframework.social
+ spring-social-facebook
+ ${org.springframework.social-facebook-version}
+
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ ${org.codehaus.jackson-version}
+
+
+
+
+
+
+ springsource-snapshot
+ SpringSource Snapshot Repository
+ http://repo.springsource.org/snapshot
+
+ false
+
+
+ true
+
+
+
+
+ springsource-milestone
+ SpringSource Milestone Repository
+ http://repo.springsource.org/milestone
+
+ false
+
+
+
+
+ springsource-repo
+ SpringSpring Repository
+ http://repo.springsource.org/release
+
+ false
+
+
+
+
+
+ ${project.artifactId}
+ src
+
+
+ com.jayway.maven.plugins.android.generation2
+ android-maven-plugin
+ ${android-maven-plugin-version}
+
+
+ ${android-platform}
+
+ true
+ true
+
+ true
+
+
+ maven-compiler-plugin
+ ${maven-compiler-plugin-version}
+
+
+ ${java-version}
+
+
+
+ org.apache.maven.plugins
+ maven-eclipse-plugin
+ ${maven-eclipse-plugin-version}
+
+ true
+ true
+
+
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ com.jayway.maven.plugins.android.generation2
+ android-maven-plugin
+ [3.1.1,)
+
+ proguard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-android-facebook-client/proguard.cfg b/spring-android-facebook-client/proguard.cfg
new file mode 100644
index 0000000..b1cdf17
--- /dev/null
+++ b/spring-android-facebook-client/proguard.cfg
@@ -0,0 +1,40 @@
+-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 ;
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-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/spring-android-facebook-client/project.properties b/spring-android-facebook-client/project.properties
new file mode 100644
index 0000000..8da376a
--- /dev/null
+++ b/spring-android-facebook-client/project.properties
@@ -0,0 +1,11 @@
+# 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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-15
diff --git a/spring-android-facebook-client/res/drawable-hdpi/spring_android.png b/spring-android-facebook-client/res/drawable-hdpi/spring_android.png
new file mode 100644
index 0000000..8a61220
Binary files /dev/null and b/spring-android-facebook-client/res/drawable-hdpi/spring_android.png differ
diff --git a/spring-android-facebook-client/res/drawable-ldpi/spring_android.png b/spring-android-facebook-client/res/drawable-ldpi/spring_android.png
new file mode 100644
index 0000000..8455214
Binary files /dev/null and b/spring-android-facebook-client/res/drawable-ldpi/spring_android.png differ
diff --git a/spring-android-facebook-client/res/drawable-mdpi/spring_android.png b/spring-android-facebook-client/res/drawable-mdpi/spring_android.png
new file mode 100644
index 0000000..3bb1843
Binary files /dev/null and b/spring-android-facebook-client/res/drawable-mdpi/spring_android.png differ
diff --git a/spring-android-facebook-client/res/drawable/spring09_logo.png b/spring-android-facebook-client/res/drawable/spring09_logo.png
new file mode 100644
index 0000000..7917c9d
Binary files /dev/null and b/spring-android-facebook-client/res/drawable/spring09_logo.png differ
diff --git a/spring-android-showcase/client/res/layout/facebook_activity_layout.xml b/spring-android-facebook-client/res/layout/facebook_activity_layout.xml
similarity index 72%
rename from spring-android-showcase/client/res/layout/facebook_activity_layout.xml
rename to spring-android-facebook-client/res/layout/facebook_activity_layout.xml
index 49bf8d2..afe3fc9 100644
--- a/spring-android-showcase/client/res/layout/facebook_activity_layout.xml
+++ b/spring-android-facebook-client/res/layout/facebook_activity_layout.xml
@@ -1,31 +1,26 @@
+ android:orientation="vertical" >
-
+ android:text="@string/facebook_description" />
+
-
+ android:layout_height="fill_parent" >
+
-
+ android:layout_height="fill_parent" />
-
-
+
+
\ No newline at end of file
diff --git a/spring-android-facebook-client/res/layout/facebook_feed_list_item.xml b/spring-android-facebook-client/res/layout/facebook_feed_list_item.xml
new file mode 100644
index 0000000..15903d6
--- /dev/null
+++ b/spring-android-facebook-client/res/layout/facebook_feed_list_item.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/facebook_wall_post_activity_layout.xml b/spring-android-facebook-client/res/layout/facebook_wall_post_activity_layout.xml
similarity index 72%
rename from spring-android-showcase/client/res/layout/facebook_wall_post_activity_layout.xml
rename to spring-android-facebook-client/res/layout/facebook_wall_post_activity_layout.xml
index fcc8afc..f9492b7 100644
--- a/spring-android-showcase/client/res/layout/facebook_wall_post_activity_layout.xml
+++ b/spring-android-facebook-client/res/layout/facebook_wall_post_activity_layout.xml
@@ -1,34 +1,30 @@
-
+ android:orientation="vertical" >
+
-
+ android:text="What's on your mind?" />
+
-
+ android:padding="8dip" />
+
-
-
+ android:layout_height="wrap_content"
+ android:text="Submit" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/values/connect_settings.xml b/spring-android-facebook-client/res/values/connect_settings.xml
similarity index 60%
rename from spring-android-showcase/client/res/values/connect_settings.xml
rename to spring-android-facebook-client/res/values/connect_settings.xml
index ec13dc8..3eb1647 100644
--- a/spring-android-showcase/client/res/values/connect_settings.xml
+++ b/spring-android-facebook-client/res/values/connect_settings.xml
@@ -1,8 +1,5 @@
- YR571S2JiVBOFyJS5MEg
- Kb8hS0luftwCJX3qVoyiLUMfZDtK1EozFoUkjNLUMx4
- x-org-springsource-android-showcase://twitter-oauth-response
8ae8f060d81d51e90fadabaab1414a97
473e66d79ddc0e360851dc512fe0fb1e
https://www.facebook.com/connect/login_success.html
diff --git a/spring-android-facebook-client/res/values/strings.xml b/spring-android-facebook-client/res/values/strings.xml
new file mode 100644
index 0000000..2b62b3c
--- /dev/null
+++ b/spring-android-facebook-client/res/values/strings.xml
@@ -0,0 +1,8 @@
+
+
+
+ SA Facebook Client
+
+ Facebook example using Spring Social
+
+
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractAsyncActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractAsyncActivity.java
new file mode 100644
index 0000000..cae3eb7
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractAsyncActivity.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+
+/**
+ * @author Roy Clarkson
+ * @author Pierre-Yves Ricau
+ */
+public abstract class AbstractAsyncActivity extends Activity implements AsyncActivity {
+
+ protected static final String TAG = AbstractAsyncActivity.class.getSimpleName();
+
+ private ProgressDialog progressDialog;
+
+ private boolean destroyed = false;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public MainApplication getApplicationContext() {
+ return (MainApplication) super.getApplicationContext();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ this.destroyed = true;
+ }
+
+ // ***************************************
+ // Public methods
+ // ***************************************
+ public void showLoadingProgressDialog() {
+ this.showProgressDialog("Loading. Please wait...");
+ }
+
+ public void showProgressDialog(CharSequence message) {
+ if (this.progressDialog == null) {
+ this.progressDialog = new ProgressDialog(this);
+ this.progressDialog.setIndeterminate(true);
+ }
+
+ this.progressDialog.setMessage(message);
+ this.progressDialog.show();
+ }
+
+ public void dismissProgressDialog() {
+ if (this.progressDialog != null && !this.destroyed) {
+ this.progressDialog.dismiss();
+ }
+ }
+
+}
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractAsyncListActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractAsyncListActivity.java
new file mode 100644
index 0000000..2e7d62b
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractAsyncListActivity.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import android.app.ListActivity;
+import android.app.ProgressDialog;
+
+/**
+ * @author Roy Clarkson
+ * @author Pierre-Yves Ricau
+ */
+public abstract class AbstractAsyncListActivity extends ListActivity implements AsyncActivity {
+
+ protected static final String TAG = AbstractAsyncActivity.class.getSimpleName();
+
+ private ProgressDialog progressDialog;
+
+ private boolean destroyed = false;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public MainApplication getApplicationContext() {
+ return (MainApplication) super.getApplicationContext();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ this.destroyed = true;
+ }
+
+ // ***************************************
+ // Public methods
+ // ***************************************
+ public void showLoadingProgressDialog() {
+ this.showProgressDialog("Loading. Please wait...");
+ }
+
+ public void showProgressDialog(CharSequence message) {
+ if (this.progressDialog == null) {
+ this.progressDialog = new ProgressDialog(this);
+ this.progressDialog.setIndeterminate(true);
+ }
+
+ this.progressDialog.setMessage(message);
+ this.progressDialog.show();
+ }
+
+ public void dismissProgressDialog() {
+ if (this.progressDialog != null && !this.destroyed) {
+ this.progressDialog.dismiss();
+ }
+ }
+
+}
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractWebViewActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractWebViewActivity.java
new file mode 100644
index 0000000..30df845
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/AbstractWebViewActivity.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.os.Bundle;
+import android.view.Window;
+import android.webkit.WebChromeClient;
+import android.webkit.WebView;
+
+/**
+ * @author Roy Clarkson
+ */
+public abstract class AbstractWebViewActivity extends Activity implements AsyncActivity {
+
+ protected static final String TAG = AbstractWebViewActivity.class.getSimpleName();
+
+ private Activity activity;
+
+ private WebView webView;
+
+ private ProgressDialog progressDialog = null;
+
+ private boolean destroyed = false;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public MainApplication getApplicationContext() {
+ return (MainApplication) super.getApplicationContext();
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().requestFeature(Window.FEATURE_PROGRESS);
+ getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
+ this.webView = new WebView(this);
+ setContentView(webView);
+ this.activity = this;
+
+ webView.setWebChromeClient(new WebChromeClient() {
+ public void onProgressChanged(WebView view, int progress) {
+ activity.setTitle("Loading...");
+ activity.setProgress(progress * 100);
+ if (progress == 100) {
+ activity.setTitle(R.string.app_name);
+ }
+ }
+ });
+ }
+
+ // ***************************************
+ // Protected methods
+ // ***************************************
+ protected WebView getWebView() {
+ return this.webView;
+ }
+
+ // ***************************************
+ // Public methods
+ // ***************************************
+ public void showLoadingProgressDialog() {
+ showProgressDialog("Loading. Please wait...");
+ }
+
+ public void showProgressDialog(CharSequence message) {
+ if (this.progressDialog == null) {
+ this.progressDialog = new ProgressDialog(this);
+ this.progressDialog.setIndeterminate(true);
+ }
+
+ this.progressDialog.setMessage(message);
+ this.progressDialog.show();
+ }
+
+ public void dismissProgressDialog() {
+ if (this.progressDialog != null && !this.destroyed) {
+ this.progressDialog.dismiss();
+ }
+ }
+
+}
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/AsyncActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/AsyncActivity.java
new file mode 100644
index 0000000..cf31aec
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/AsyncActivity.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+/**
+ * @author Roy Clarkson
+ */
+public interface AsyncActivity {
+
+ public MainApplication getApplicationContext();
+
+ public void showLoadingProgressDialog();
+
+ public void showProgressDialog(CharSequence message);
+
+ public void dismissProgressDialog();
+
+}
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookActivity.java
new file mode 100644
index 0000000..aead0dc
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookActivity.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import org.springframework.social.connect.ConnectionRepository;
+import org.springframework.social.facebook.api.Facebook;
+import org.springframework.social.facebook.connect.FacebookConnectionFactory;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+/**
+ * @author Roy Clarkson
+ */
+public class FacebookActivity extends AbstractAsyncActivity {
+
+ protected static final String TAG = FacebookActivity.class.getSimpleName();
+
+ private ConnectionRepository connectionRepository;
+
+ private FacebookConnectionFactory connectionFactory;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.facebook_activity_layout);
+ this.connectionRepository = getApplicationContext().getConnectionRepository();
+ this.connectionFactory = getApplicationContext().getFacebookConnectionFactory();
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ if (isConnected()) {
+ showFacebookOptions();
+ } else {
+ showConnectOption();
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+
+ // ***************************************
+ // Private methods
+ // ***************************************
+ private boolean isConnected() {
+ return connectionRepository.findPrimaryConnection(Facebook.class) != null;
+ }
+
+ private void disconnect() {
+ this.connectionRepository.removeConnections(this.connectionFactory.getProviderId());
+ }
+
+ private void showConnectOption() {
+ String[] options = { "Connect" };
+ ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, options);
+ ListView listView = (ListView) this.findViewById(R.id.facebook_activity_options_list);
+ listView.setAdapter(arrayAdapter);
+
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
+ switch (position) {
+ case 0:
+ displayFacebookAuthorization();
+ break;
+ default:
+ break;
+ }
+ }
+ });
+ }
+
+ private void showFacebookOptions() {
+ String[] options = { "Disconnect", "Profile", "Home Feed", "Wall Post" };
+ ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, options);
+ ListView listView = (ListView) this.findViewById(R.id.facebook_activity_options_list);
+ listView.setAdapter(arrayAdapter);
+
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
+ Intent intent;
+ switch (position) {
+ case 0:
+ disconnect();
+ showConnectOption();
+ break;
+ case 1:
+ intent = new Intent();
+ intent.setClass(parentView.getContext(), FacebookProfileActivity.class);
+ startActivity(intent);
+ break;
+ case 2:
+ intent = new Intent();
+ intent.setClass(parentView.getContext(), FacebookHomeFeedActivity.class);
+ startActivity(intent);
+ break;
+ case 3:
+ intent = new Intent();
+ intent.setClass(parentView.getContext(), FacebookWallPostActivity.class);
+ startActivity(intent);
+ break;
+ default:
+ break;
+ }
+ }
+ });
+ }
+
+ private void displayFacebookAuthorization() {
+ Intent intent = new Intent();
+ intent.setClass(this, FacebookWebOAuthActivity.class);
+ startActivity(intent);
+ finish();
+ }
+
+}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/social/facebook/FacebookFeedListAdapter.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookFeedListAdapter.java
similarity index 92%
rename from spring-android-showcase/client/src/org/springframework/android/showcase/social/facebook/FacebookFeedListAdapter.java
rename to spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookFeedListAdapter.java
index 0366391..a046aa7 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/social/facebook/FacebookFeedListAdapter.java
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookFeedListAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.android.showcase.social.facebook;
+package org.springframework.android.facebookclient;
import java.util.List;
-import org.springframework.android.showcase.R;
import org.springframework.social.facebook.api.Post;
import android.content.Context;
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookHomeFeedActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookHomeFeedActivity.java
new file mode 100644
index 0000000..972fc7d
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookHomeFeedActivity.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import java.util.List;
+
+import org.springframework.social.facebook.api.Facebook;
+import org.springframework.social.facebook.api.Post;
+
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+
+/**
+ * @author Roy Clarkson
+ */
+public class FacebookHomeFeedActivity extends AbstractAsyncListActivity {
+
+ protected static final String TAG = FacebookHomeFeedActivity.class.getSimpleName();
+
+ private Facebook facebook;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ this.facebook = getApplicationContext().getConnectionRepository().findPrimaryConnection(Facebook.class)
+ .getApi();
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ new FetchWallFeedTask().execute();
+ }
+
+ // ***************************************
+ // Private methods
+ // ***************************************
+ private void showResult(List entries) {
+ FacebookFeedListAdapter adapter = new FacebookFeedListAdapter(this, entries);
+ setListAdapter(adapter);
+ }
+
+ // ***************************************
+ // Private classes
+ // ***************************************
+ private class FetchWallFeedTask extends AsyncTask> {
+
+ @Override
+ protected void onPreExecute() {
+ showProgressDialog("Fetching home feed...");
+ }
+
+ @Override
+ protected List doInBackground(Void... params) {
+ try {
+ return facebook.feedOperations().getHomeFeed();
+ } catch (Exception e) {
+ Log.e(TAG, e.getLocalizedMessage(), e);
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(List entries) {
+ dismissProgressDialog();
+ showResult(entries);
+ }
+
+ }
+
+}
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookProfileActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookProfileActivity.java
new file mode 100644
index 0000000..652e721
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookProfileActivity.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import org.springframework.social.facebook.api.Facebook;
+import org.springframework.social.facebook.api.FacebookProfile;
+
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+
+/**
+ * @author Roy Clarkson
+ */
+public class FacebookProfileActivity extends AbstractAsyncListActivity {
+
+ protected static final String TAG = FacebookProfileActivity.class.getSimpleName();
+
+ private Facebook facebook;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ this.facebook = getApplicationContext().getConnectionRepository().findPrimaryConnection(Facebook.class)
+ .getApi();
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ new FetchProfileTask().execute();
+ }
+
+ // ***************************************
+ // Private methods
+ // ***************************************
+ private void showResult(FacebookProfile facebookProfile) {
+ if (facebookProfile != null) {
+ FacebookProfileListAdapter adapter = new FacebookProfileListAdapter(this, facebookProfile);
+ setListAdapter(adapter);
+ }
+ }
+
+ // ***************************************
+ // Private classes
+ // ***************************************
+ private class FetchProfileTask extends AsyncTask {
+
+ @Override
+ protected void onPreExecute() {
+ showProgressDialog("Fetching profile...");
+ }
+
+ @Override
+ protected FacebookProfile doInBackground(Void... params) {
+ try {
+ return facebook.userOperations().getUserProfile();
+ } catch (Exception e) {
+ Log.e(TAG, e.getLocalizedMessage(), e);
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(FacebookProfile profile) {
+ dismissProgressDialog();
+ showResult(profile);
+ }
+
+ }
+
+}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/social/facebook/FacebookProfileListAdapter.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookProfileListAdapter.java
similarity index 95%
rename from spring-android-showcase/client/src/org/springframework/android/showcase/social/facebook/FacebookProfileListAdapter.java
rename to spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookProfileListAdapter.java
index 4c99727..e6c1cf7 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/social/facebook/FacebookProfileListAdapter.java
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookProfileListAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.android.showcase.social.facebook;
+package org.springframework.android.facebookclient;
import org.springframework.social.facebook.api.FacebookProfile;
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookWallPostActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookWallPostActivity.java
new file mode 100644
index 0000000..ad56a92
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookWallPostActivity.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import org.springframework.social.facebook.api.Facebook;
+
+import android.content.Context;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+/**
+ * @author Roy Clarkson
+ */
+public class FacebookWallPostActivity extends AbstractAsyncActivity {
+
+ protected static final String TAG = FacebookWallPostActivity.class.getSimpleName();
+
+ private Facebook facebook;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.facebook_wall_post_activity_layout);
+ this.facebook = getApplicationContext().getConnectionRepository().findPrimaryConnection(Facebook.class)
+ .getApi();
+
+ // Initiate the POST request when the button is clicked
+ final Button button = (Button) findViewById(R.id.button_submit);
+ button.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ // hide the soft keypad
+ InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ EditText editText = (EditText) findViewById(R.id.edit_text_wall_post);
+ inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);
+ new PostTweetTask().execute();
+ }
+ });
+ }
+
+ // ***************************************
+ // Private methods
+ // ***************************************
+ private void showResult(String result) {
+ Toast.makeText(this, result, Toast.LENGTH_LONG).show();
+ }
+
+ // ***************************************
+ // Private classes
+ // ***************************************
+ private class PostTweetTask extends AsyncTask {
+
+ private String wallPostText;
+
+ @Override
+ protected void onPreExecute() {
+ // before the network request begins, show a progress indicator
+ showProgressDialog("Posting to Wall...");
+
+ // retrieve the text from the EditText field
+ EditText editText = (EditText) findViewById(R.id.edit_text_wall_post);
+ this.wallPostText = editText.getText().toString();
+ }
+
+ @Override
+ protected String doInBackground(Void... params) {
+ try {
+ facebook.feedOperations().updateStatus(wallPostText);
+ return "Status updated";
+ } catch (Exception e) {
+ Log.e(TAG, e.getLocalizedMessage(), e);
+ return "An error occurred. See the log for details";
+ }
+ }
+
+ @Override
+ protected void onPostExecute(String result) {
+ // after the network request completes, hide the progress indicator
+ dismissProgressDialog();
+ showResult(result);
+ }
+
+ }
+
+}
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookWebOAuthActivity.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookWebOAuthActivity.java
new file mode 100644
index 0000000..29f9e6f
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/FacebookWebOAuthActivity.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import org.springframework.social.connect.Connection;
+import org.springframework.social.connect.ConnectionRepository;
+import org.springframework.social.connect.DuplicateConnectionException;
+import org.springframework.social.facebook.api.Facebook;
+import org.springframework.social.facebook.connect.FacebookConnectionFactory;
+import org.springframework.social.oauth2.AccessGrant;
+import org.springframework.social.oauth2.GrantType;
+import org.springframework.social.oauth2.OAuth2Parameters;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.Toast;
+
+/**
+ * @author Roy Clarkson
+ */
+public class FacebookWebOAuthActivity extends AbstractWebViewActivity {
+
+ private static final String TAG = FacebookWebOAuthActivity.class.getSimpleName();
+
+ private ConnectionRepository connectionRepository;
+
+ private FacebookConnectionFactory connectionFactory;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Facebook uses javascript to redirect to the success page
+ getWebView().getSettings().setJavaScriptEnabled(true);
+
+ // Using a custom web view client to capture the access token
+ getWebView().setWebViewClient(new FacebookOAuthWebViewClient());
+
+ this.connectionRepository = getApplicationContext().getConnectionRepository();
+ this.connectionFactory = getApplicationContext().getFacebookConnectionFactory();
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ // display the Facebook authorization page
+ getWebView().loadUrl(getAuthorizeUrl());
+ }
+
+ // ***************************************
+ // Private methods
+ // ***************************************
+ private String getAuthorizeUrl() {
+ String redirectUri = getString(R.string.facebook_oauth_callback_url);
+ String scope = getString(R.string.facebook_scope);
+
+ /*
+ * Generate the Facebook authorization url to be used in the browser or web view the display=touch parameter
+ * requests the mobile formatted version of the Facebook authorization page
+ */
+ OAuth2Parameters params = new OAuth2Parameters();
+ params.setRedirectUri(redirectUri);
+ params.setScope(scope);
+ params.add("display", "touch");
+ return this.connectionFactory.getOAuthOperations().buildAuthorizeUrl(GrantType.IMPLICIT_GRANT, params);
+ }
+
+ private void displayFacebookOptions() {
+ Intent intent = new Intent();
+ intent.setClass(this, FacebookActivity.class);
+ startActivity(intent);
+ finish();
+ }
+
+ // ***************************************
+ // Private classes
+ // ***************************************
+ private class FacebookOAuthWebViewClient extends WebViewClient {
+
+ /*
+ * The WebViewClient has another method called shouldOverridUrlLoading which does not capture the javascript
+ * redirect to the success page. So we're using onPageStarted to capture the url.
+ */
+ @Override
+ public void onPageStarted(WebView view, String url, Bitmap favicon) {
+ // parse the captured url
+ Uri uri = Uri.parse(url);
+
+ Log.d(TAG, url);
+
+ /*
+ * The access token is returned in the URI fragment of the URL. See the Desktop Apps section all the way
+ * at the bottom of this link:
+ *
+ * http://developers.facebook.com/docs/authentication/
+ *
+ * The fragment will be formatted like this:
+ *
+ * #access_token=A&expires_in=0
+ */
+ String uriFragment = uri.getFragment();
+
+ // confirm we have the fragment, and it has an access_token parameter
+ if (uriFragment != null && uriFragment.startsWith("access_token=")) {
+
+ /*
+ * The fragment also contains an "expires_in" parameter. In this
+ * example we requested the offline_access permission, which
+ * basically means the access will not expire, so we're ignoring
+ * it here
+ */
+ try {
+ // split to get the two different parameters
+ String[] params = uriFragment.split("&");
+
+ // split to get the access token parameter and value
+ String[] accessTokenParam = params[0].split("=");
+
+ // get the access token value
+ String accessToken = accessTokenParam[1];
+
+ // create the connection and persist it to the repository
+ AccessGrant accessGrant = new AccessGrant(accessToken);
+ Connection connection = connectionFactory.createConnection(accessGrant);
+
+ try {
+ connectionRepository.addConnection(connection);
+ } catch (DuplicateConnectionException e) {
+ // connection already exists in repository!
+ }
+ } catch (Exception e) {
+ // don't do anything if the parameters are not what is expected
+ }
+
+ displayFacebookOptions();
+ }
+
+ /*
+ * if there was an error with the oauth process, return the error description
+ *
+ * The error query string will look like this:
+ *
+ * ?error_reason=user_denied&error=access_denied&error_description=The +user+denied+your+request
+ */
+ if (uri.getQueryParameter("error") != null) {
+ CharSequence errorReason = uri.getQueryParameter("error_description").replace("+", " ");
+ Toast.makeText(getApplicationContext(), errorReason, Toast.LENGTH_LONG).show();
+ displayFacebookOptions();
+ }
+ }
+ }
+}
diff --git a/spring-android-facebook-client/src/org/springframework/android/facebookclient/MainApplication.java b/spring-android-facebook-client/src/org/springframework/android/facebookclient/MainApplication.java
new file mode 100644
index 0000000..dcbc575
--- /dev/null
+++ b/spring-android-facebook-client/src/org/springframework/android/facebookclient/MainApplication.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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 org.springframework.android.facebookclient;
+
+import org.springframework.security.crypto.encrypt.AndroidEncryptors;
+import org.springframework.social.connect.ConnectionRepository;
+import org.springframework.social.connect.sqlite.SQLiteConnectionRepository;
+import org.springframework.social.connect.sqlite.support.SQLiteConnectionRepositoryHelper;
+import org.springframework.social.connect.support.ConnectionFactoryRegistry;
+import org.springframework.social.facebook.api.Facebook;
+import org.springframework.social.facebook.connect.FacebookConnectionFactory;
+
+import android.app.Application;
+import android.database.sqlite.SQLiteOpenHelper;
+
+/**
+ * @author Roy Clarkson
+ */
+public class MainApplication extends Application {
+ private ConnectionFactoryRegistry connectionFactoryRegistry;
+ private SQLiteOpenHelper repositoryHelper;
+ private ConnectionRepository connectionRepository;
+
+ // ***************************************
+ // Application Methods
+ // ***************************************
+ @Override
+ public void onCreate() {
+ // create a new ConnectionFactoryLocator and populate it with Facebook ConnectionFactory
+ this.connectionFactoryRegistry = new ConnectionFactoryRegistry();
+ this.connectionFactoryRegistry.addConnectionFactory(new FacebookConnectionFactory(getFacebookAppId(),
+ getFacebookAppSecret()));
+
+ // set up the database and encryption
+ this.repositoryHelper = new SQLiteConnectionRepositoryHelper(this);
+ this.connectionRepository = new SQLiteConnectionRepository(this.repositoryHelper,
+ this.connectionFactoryRegistry, AndroidEncryptors.text("password", "5c0744940b5c369b"));
+ }
+
+ // ***************************************
+ // Private methods
+ // ***************************************
+ private String getFacebookAppId() {
+ return getString(R.string.facebook_app_id);
+ }
+
+ private String getFacebookAppSecret() {
+ return getString(R.string.facebook_app_secret);
+ }
+
+ // ***************************************
+ // Public methods
+ // ***************************************
+ public ConnectionRepository getConnectionRepository() {
+ return this.connectionRepository;
+ }
+
+ public FacebookConnectionFactory getFacebookConnectionFactory() {
+ return (FacebookConnectionFactory) this.connectionFactoryRegistry.getConnectionFactory(Facebook.class);
+ }
+
+}
diff --git a/spring-android-showcase/client/AndroidManifest.xml b/spring-android-showcase/client/AndroidManifest.xml
index 519a127..89dc6fc 100644
--- a/spring-android-showcase/client/AndroidManifest.xml
+++ b/spring-android-showcase/client/AndroidManifest.xml
@@ -2,67 +2,42 @@
+ android:versionName="1.0" >
+
+
+
+
-
-
-
-
+ android:icon="@drawable/spring_android"
+ android:label="@string/app_name" >
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/facebook_feed_list_item.xml b/spring-android-showcase/client/res/layout/facebook_feed_list_item.xml
deleted file mode 100644
index 6793013..0000000
--- a/spring-android-showcase/client/res/layout/facebook_feed_list_item.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-android-showcase/client/res/layout/google_search_activity_layout.xml b/spring-android-showcase/client/res/layout/google_search_activity_layout.xml
index d887ad2..7242ad2 100644
--- a/spring-android-showcase/client/res/layout/google_search_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/google_search_activity_layout.xml
@@ -1,17 +1,15 @@
+ android:orientation="vertical" >
-
-
+ android:padding="10dip" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/google_search_results_list_item.xml b/spring-android-showcase/client/res/layout/google_search_results_list_item.xml
index 30adde4..7c0ac48 100644
--- a/spring-android-showcase/client/res/layout/google_search_results_list_item.xml
+++ b/spring-android-showcase/client/res/layout/google_search_results_list_item.xml
@@ -1,25 +1,21 @@
+
-
+
-
+
-
-
-
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_get_gzip_activity_layout.xml b/spring-android-showcase/client/res/layout/http_get_gzip_activity_layout.xml
index 190f712..2114203 100644
--- a/spring-android-showcase/client/res/layout/http_get_gzip_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_get_gzip_activity_layout.xml
@@ -1,49 +1,42 @@
-
+ android:orientation="vertical" >
+
-
+ android:text="Headers:"
+ android:textStyle="bold" />
+
-
+ android:padding="8dip" />
+
-
+ android:text="Results:"
+ android:textStyle="bold" />
+
-
+ android:layout_height="wrap_content" >
+
-
+ android:padding="8dip" />
-
-
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_get_gzip_list_activity_layout.xml b/spring-android-showcase/client/res/layout/http_get_gzip_list_activity_layout.xml
index 1372912..c167be4 100644
--- a/spring-android-showcase/client/res/layout/http_get_gzip_list_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_get_gzip_list_activity_layout.xml
@@ -1,41 +1,36 @@
-
+ android:orientation="vertical" >
+
-
+ android:text="Headers:"
+ android:textStyle="bold" />
+
-
+ android:padding="8dip" />
+
-
+ android:text="Results:"
+ android:textStyle="bold" />
+
-
-
+ android:layout_height="wrap_content" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_get_parameters_activity_layout.xml b/spring-android-showcase/client/res/layout/http_get_parameters_activity_layout.xml
index 6b0651e..c45c878 100644
--- a/spring-android-showcase/client/res/layout/http_get_parameters_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_get_parameters_activity_layout.xml
@@ -1,48 +1,42 @@
+ android:orientation="vertical" >
-
+ android:text="@string/text_http_get_parameters_description" />
+
-
+ android:text="Enter State Abbreviation:" />
+
-
+ android:singleLine="true" />
+
-
+ android:text="Fetch state with JSON" />
+
-
-
+ android:text="Fetch state with XML" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_get_set_request_timeout_activity_layout.xml b/spring-android-showcase/client/res/layout/http_get_set_request_timeout_activity_layout.xml
index b92baf7..8341922 100644
--- a/spring-android-showcase/client/res/layout/http_get_set_request_timeout_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_get_set_request_timeout_activity_layout.xml
@@ -1,60 +1,53 @@
+ android:orientation="vertical" >
-
+ android:text="@string/text_http_get_set_request_timeout_description" />
+
-
+ android:text="Enter Server Delay in Seconds:" />
+
-
+ android:padding="8dip"
+ android:singleLine="true" />
+
-
+ android:text="Enter Request Timeout in Seconds:" />
+
-
+ android:padding="8dip"
+ android:singleLine="true" />
+
-
-
+ android:text="Submit" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_post.xml b/spring-android-showcase/client/res/layout/http_post.xml
index 7bcc924..660728e 100644
--- a/spring-android-showcase/client/res/layout/http_post.xml
+++ b/spring-android-showcase/client/res/layout/http_post.xml
@@ -1,15 +1,13 @@
+ android:orientation="vertical" >
-
-
+ android:layout_height="wrap_content"
+ android:text="Submit" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_post_activity_layout.xml b/spring-android-showcase/client/res/layout/http_post_activity_layout.xml
index ef2f786..03634cd 100644
--- a/spring-android-showcase/client/res/layout/http_post_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_post_activity_layout.xml
@@ -1,31 +1,26 @@
+ android:orientation="vertical" >
-
+ android:text="@string/text_http_post_description" />
+
-
+ android:layout_height="fill_parent" >
+
-
+ android:layout_height="fill_parent" />
-
-
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_post_form_data_layout.xml b/spring-android-showcase/client/res/layout/http_post_form_data_layout.xml
index e4c6abd..5fb34a6 100644
--- a/spring-android-showcase/client/res/layout/http_post_form_data_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_post_form_data_layout.xml
@@ -1,24 +1,21 @@
-
+ android:orientation="vertical" >
+
-
+ android:text="This example posts multipart/form-data content to the example server." />
+
-
-
+ android:text="Send" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_post_json_xml_activity_layout.xml b/spring-android-showcase/client/res/layout/http_post_json_xml_activity_layout.xml
index d660726..45d881d 100644
--- a/spring-android-showcase/client/res/layout/http_post_json_xml_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_post_json_xml_activity_layout.xml
@@ -1,71 +1,62 @@
-
+ android:orientation="vertical" >
+
-
+ android:text="Id (int):" />
+
-
+ android:singleLine="true" />
+
-
+ android:text="Subject (String):" />
+
-
+ android:singleLine="true" />
+
-
+ android:text="Text (String):" />
+
-
+ android:singleLine="true" />
+
-
+ android:layout_height="wrap_content"
+ android:text="POST JSON" />
+
-
-
+ android:layout_height="wrap_content"
+ android:text="POST XML" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_post_multi_value_activity_layout.xml b/spring-android-showcase/client/res/layout/http_post_multi_value_activity_layout.xml
index 41020bb..c74fd68 100644
--- a/spring-android-showcase/client/res/layout/http_post_multi_value_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_post_multi_value_activity_layout.xml
@@ -1,64 +1,56 @@
-
+ android:orientation="vertical" >
+
-
+ android:text="Id (int):" />
+
-
+ android:singleLine="true" />
+
-
+ android:text="Subject (String):" />
+
-
+ android:singleLine="true" />
+
-
+ android:text="Text (String):" />
+
-
+ android:singleLine="true" />
+
-
-
+ android:layout_height="wrap_content"
+ android:text="Submit" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/http_post_string_activity_layout.xml b/spring-android-showcase/client/res/layout/http_post_string_activity_layout.xml
index baede46..37927fa 100644
--- a/spring-android-showcase/client/res/layout/http_post_string_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/http_post_string_activity_layout.xml
@@ -1,32 +1,28 @@
-
+ android:orientation="vertical" >
+
-
+ android:text="Enter message text:" />
+
-
+ android:singleLine="true" />
+
-
-
+ android:text="Send" />
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/menu_activity_layout.xml b/spring-android-showcase/client/res/layout/menu_activity_layout.xml
index 5e190f7..3cc1c75 100644
--- a/spring-android-showcase/client/res/layout/menu_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/menu_activity_layout.xml
@@ -1,30 +1,25 @@
-
+ android:orientation="vertical" >
+
-
+ android:padding="8dip" />
+
-
+ android:layout_height="fill_parent" >
+
-
+ android:layout_height="fill_parent" />
-
-
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/rss_activity_layout.xml b/spring-android-showcase/client/res/layout/rss_activity_layout.xml
index e44ae48..14fcc3c 100644
--- a/spring-android-showcase/client/res/layout/rss_activity_layout.xml
+++ b/spring-android-showcase/client/res/layout/rss_activity_layout.xml
@@ -1,31 +1,26 @@
+ android:orientation="vertical" >
-
+ android:text="@string/text_rss_description" />
+
-
+ android:layout_height="fill_parent" >
+
-
+ android:layout_height="fill_parent" />
-
-
+
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/states_list_item.xml b/spring-android-showcase/client/res/layout/states_list_item.xml
index ef784e5..fac76b5 100644
--- a/spring-android-showcase/client/res/layout/states_list_item.xml
+++ b/spring-android-showcase/client/res/layout/states_list_item.xml
@@ -1,18 +1,15 @@
+
-
+
-
-
-
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/synd_feed_list_item.xml b/spring-android-showcase/client/res/layout/synd_feed_list_item.xml
index a7774b4..46cf5cb 100644
--- a/spring-android-showcase/client/res/layout/synd_feed_list_item.xml
+++ b/spring-android-showcase/client/res/layout/synd_feed_list_item.xml
@@ -1,32 +1,27 @@
+
-
+
-
+
-
+
-
-
-
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/layout/twitter_timeline_list_item.xml b/spring-android-showcase/client/res/layout/twitter_timeline_list_item.xml
index 8503971..b9c24ae 100644
--- a/spring-android-showcase/client/res/layout/twitter_timeline_list_item.xml
+++ b/spring-android-showcase/client/res/layout/twitter_timeline_list_item.xml
@@ -1,32 +1,27 @@
+
-
+
-
+
-
+
-
-
-
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/values/strings.xml b/spring-android-showcase/client/res/values/strings.xml
index 4450d2f..31c8141 100644
--- a/spring-android-showcase/client/res/values/strings.xml
+++ b/spring-android-showcase/client/res/values/strings.xml
@@ -2,63 +2,39 @@
SA Showcase
-
Select an option to view the associated example.
-
These examples make HTTP GET requests to the server.
-
These examples retrieve a list of states from the
example server. Use the MappingJacksonHttpMessageConverter to marshal JSON objects or use
- the SimpleXmlHttpMessageConverter to marshal XML objects via HTTP GET requests.
-
-
+ the SimpleXmlHttpMessageConverter to marshal XML objects via HTTP GET requests.
Two examples of Google searches, where the first
- marshals JSON using Jackson, and the second uses the Google Gson parser.
-
-
+ marshals JSON using Jackson, and the second uses the Google Gson parser.
These examples illustrate the use of gzip
compression with an HTTP GET request. You can view the response headers to compare the
- Content-Encoding, and Content-Size for the compressed versus uncompressed responses.
-
-
+ Content-Encoding, and Content-Size for the compressed versus uncompressed responses.
These examples pass a parameter to the
RestTemplate instance to retrieve a state by its abbreviation. Use the
MappingJacksonHttpMessageConverter to marshal JSON objects or use the
- SimpleXmlHttpMessageConverter to marshal XML objects via HTTP GET requests.
-
-
+ SimpleXmlHttpMessageConverter to marshal XML objects via HTTP GET requests.
The HttpComponents Http Client has
the option of setting a timeout when making http requests. This examples shows how to set the timeout
when attempting to make a request to the example server. The server delay value will cause the server
to delay its response for that many seconds. The request timeout will cause the request to timeout after
- the specified number of seconds.
-
-
+ the specified number of seconds.
These examples make HTTP POST requests to the server.
-
These examples retrieve the RSS feed from blog.springsource.com.
RSS feeds can be retrieved with the SyndFeedHttpMessageConverter or the more specific
RssChannelHttpMessageConverter. The SyndFeed message converter supports RSS and ATOM using an
- abstracted object model.
-
-
+ abstracted object model.
These examples retrieve the ATOM feed from
jira.springframework.org. ATOM feeds can be retrieved with the SyndFeedHttpMessageConverter
or the more specific AtomFeedHttpMessageConverter. The SyndFeed message converter supports
- RSS and ATOM using an abstracted object model.
-
-
- Twitter example using Spring Social.
-
- Facebook example using Spring Social
+ RSS and ATOM using an abstracted object model.
- HTTP GET
- HTTP POST
- - Twitter
- - Facebook
-
- JSON and XML
- Sending parameters
@@ -66,23 +42,19 @@
- Requesting gzip content
- Setting a Request Timeout
-
- Fetch JSON list of states
- Fetch XML list of states
-
- Google Search with Jackson
- Google Search with Gson
-
- Compressed String
- Uncompressed String
- Compressed JSON
-
- String
- JSON and XML
@@ -90,4 +62,4 @@
- Form Data
-
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/res/values/urls.xml b/spring-android-showcase/client/res/values/urls.xml
index d87a6df..fdb33a1 100644
--- a/spring-android-showcase/client/res/values/urls.xml
+++ b/spring-android-showcase/client/res/values/urls.xml
@@ -1,6 +1,8 @@
+
http://10.0.2.2:8080/spring-android-showcase-server
http://blog.springsource.com/feed
https://jira.springframework.org/plugins/servlet/streams
+
\ No newline at end of file
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractAsyncActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractAsyncActivity.java
index 903dd43..b158ef7 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractAsyncActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractAsyncActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,47 +24,42 @@
*/
public abstract class AbstractAsyncActivity extends Activity implements AsyncActivity {
- protected static final String TAG = AbstractAsyncActivity.class.getSimpleName();
+ protected static final String TAG = AbstractAsyncActivity.class.getSimpleName();
- private ProgressDialog progressDialog;
+ private ProgressDialog progressDialog;
- private boolean destroyed = false;
+ private boolean destroyed = false;
- // ***************************************
- // Activity methods
- // ***************************************
- @Override
- public MainApplication getApplicationContext() {
- return (MainApplication) super.getApplicationContext();
- }
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ this.destroyed = true;
+ }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- destroyed = true;
- }
+ // ***************************************
+ // Public methods
+ // ***************************************
+ public void showLoadingProgressDialog() {
+ this.showProgressDialog("Loading. Please wait...");
+ }
- // ***************************************
- // Public methods
- // ***************************************
- public void showLoadingProgressDialog() {
- this.showProgressDialog("Loading. Please wait...");
- }
+ public void showProgressDialog(CharSequence message) {
+ if (this.progressDialog == null) {
+ this.progressDialog = new ProgressDialog(this);
+ this.progressDialog.setIndeterminate(true);
+ }
- public void showProgressDialog(CharSequence message) {
- if (progressDialog == null) {
- progressDialog = new ProgressDialog(this);
- progressDialog.setIndeterminate(true);
- }
+ this.progressDialog.setMessage(message);
+ this.progressDialog.show();
+ }
- progressDialog.setMessage(message);
- progressDialog.show();
- }
-
- public void dismissProgressDialog() {
- if (progressDialog != null && !destroyed) {
- progressDialog.dismiss();
- }
- }
+ public void dismissProgressDialog() {
+ if (this.progressDialog != null && !this.destroyed) {
+ this.progressDialog.dismiss();
+ }
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractAsyncListActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractAsyncListActivity.java
index 23a656f..9f9e703 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractAsyncListActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractAsyncListActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,47 +24,42 @@
*/
public abstract class AbstractAsyncListActivity extends ListActivity implements AsyncActivity {
- protected static final String TAG = AbstractAsyncActivity.class.getSimpleName();
+ protected static final String TAG = AbstractAsyncActivity.class.getSimpleName();
- private ProgressDialog progressDialog;
+ private ProgressDialog progressDialog;
- private boolean destroyed = false;
+ private boolean destroyed = false;
- // ***************************************
- // Activity methods
- // ***************************************
- @Override
- public MainApplication getApplicationContext() {
- return (MainApplication) super.getApplicationContext();
- }
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ this.destroyed = true;
+ }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- destroyed = true;
- }
+ // ***************************************
+ // Public methods
+ // ***************************************
+ public void showLoadingProgressDialog() {
+ this.showProgressDialog("Loading. Please wait...");
+ }
- // ***************************************
- // Public methods
- // ***************************************
- public void showLoadingProgressDialog() {
- this.showProgressDialog("Loading. Please wait...");
- }
+ public void showProgressDialog(CharSequence message) {
+ if (this.progressDialog == null) {
+ this.progressDialog = new ProgressDialog(this);
+ this.progressDialog.setIndeterminate(true);
+ }
- public void showProgressDialog(CharSequence message) {
- if (progressDialog == null) {
- progressDialog = new ProgressDialog(this);
- progressDialog.setIndeterminate(true);
- }
+ this.progressDialog.setMessage(message);
+ this.progressDialog.show();
+ }
- progressDialog.setMessage(message);
- progressDialog.show();
- }
-
- public void dismissProgressDialog() {
- if (progressDialog != null && !destroyed) {
- progressDialog.dismiss();
- }
- }
+ public void dismissProgressDialog() {
+ if (this.progressDialog != null && !this.destroyed) {
+ this.progressDialog.dismiss();
+ }
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractMenuActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractMenuActivity.java
index 3fbb8c0..005ed50 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractMenuActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractMenuActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,29 +27,29 @@
*/
public abstract class AbstractMenuActivity extends Activity {
- // ***************************************
- // Activity methods
- // ***************************************
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.menu_activity_layout);
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.menu_activity_layout);
- final TextView textViewDescription = (TextView) this.findViewById(R.id.text_view_description);
- textViewDescription.setText(getDescription());
+ final TextView textViewDescription = (TextView) this.findViewById(R.id.text_view_description);
+ textViewDescription.setText(getDescription());
- final ListView listViewMenu = (ListView) this.findViewById(R.id.list_view_menu_items);
- listViewMenu.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, getMenuItems()));
- listViewMenu.setOnItemClickListener(getMenuOnItemClickListener());
- }
+ final ListView listViewMenu = (ListView) this.findViewById(R.id.list_view_menu_items);
+ listViewMenu.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, getMenuItems()));
+ listViewMenu.setOnItemClickListener(getMenuOnItemClickListener());
+ }
- // ***************************************
- // Abstract methods
- // ***************************************
- protected abstract String getDescription();
+ // ***************************************
+ // Abstract methods
+ // ***************************************
+ protected abstract String getDescription();
- protected abstract String[] getMenuItems();
+ protected abstract String[] getMenuItems();
- protected abstract OnItemClickListener getMenuOnItemClickListener();
+ protected abstract OnItemClickListener getMenuOnItemClickListener();
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractWebViewActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractWebViewActivity.java
deleted file mode 100644
index ee7f5ac..0000000
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/AbstractWebViewActivity.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2011 the original author or authors.
- *
- * 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 org.springframework.android.showcase;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.os.Bundle;
-import android.view.Window;
-import android.webkit.WebChromeClient;
-import android.webkit.WebView;
-
-/**
- * @author Roy Clarkson
- */
-public abstract class AbstractWebViewActivity extends Activity implements AsyncActivity {
-
- protected static final String TAG = AbstractWebViewActivity.class.getSimpleName();
-
- private Activity activity;
-
- private WebView webView;
-
- private ProgressDialog progressDialog = null;
-
- private boolean _destroyed = false;
-
- // ***************************************
- // Activity methods
- // ***************************************
- @Override
- public MainApplication getApplicationContext() {
- return (MainApplication) super.getApplicationContext();
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().requestFeature(Window.FEATURE_PROGRESS);
- getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
- webView = new WebView(this);
- setContentView(webView);
- activity = this;
-
- webView.setWebChromeClient(new WebChromeClient() {
- public void onProgressChanged(WebView view, int progress) {
- activity.setTitle("Loading...");
- activity.setProgress(progress * 100);
- if (progress == 100) {
- activity.setTitle(R.string.app_name);
- }
- }
- });
- }
-
- // ***************************************
- // Protected methods
- // ***************************************
- protected WebView getWebView() {
- return webView;
- }
-
- // ***************************************
- // Public methods
- // ***************************************
- public void showLoadingProgressDialog() {
- showProgressDialog("Loading. Please wait...");
- }
-
- public void showProgressDialog(CharSequence message) {
- if (progressDialog == null) {
- progressDialog = new ProgressDialog(this);
- progressDialog.setIndeterminate(true);
- }
-
- progressDialog.setMessage(message);
- progressDialog.show();
- }
-
- public void dismissProgressDialog() {
- if (progressDialog != null && !_destroyed) {
- progressDialog.dismiss();
- }
- }
-
-}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/AsyncActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/AsyncActivity.java
index 5b5eba8..a137a60 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/AsyncActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/AsyncActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +20,7 @@
*/
public interface AsyncActivity {
- public MainApplication getApplicationContext();
-
- public void showLoadingProgressDialog();
+ public void showLoadingProgressDialog();
public void showProgressDialog(CharSequence message);
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/MainActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/MainActivity.java
index a891ba3..77f8ba5 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/MainActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/MainActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,6 @@
import org.springframework.android.showcase.rest.HttpGetActivity;
import org.springframework.android.showcase.rest.HttpPostActivity;
-import org.springframework.android.showcase.social.facebook.FacebookActivity;
-import org.springframework.android.showcase.social.twitter.TwitterActivity;
import android.content.Intent;
import android.view.View;
@@ -31,43 +29,37 @@
*/
public class MainActivity extends AbstractMenuActivity {
- // ***************************************
- // AbstractMenuActivity methods
- // ***************************************
- @Override
- protected String getDescription() {
- return getResources().getString(R.string.text_main);
- }
+ // ***************************************
+ // AbstractMenuActivity methods
+ // ***************************************
+ @Override
+ protected String getDescription() {
+ return getResources().getString(R.string.text_main);
+ }
- @Override
- protected String[] getMenuItems() {
- return getResources().getStringArray(R.array.main_menu_items);
- }
+ @Override
+ protected String[] getMenuItems() {
+ return getResources().getStringArray(R.array.main_menu_items);
+ }
- @Override
- protected OnItemClickListener getMenuOnItemClickListener() {
- return new OnItemClickListener() {
- public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
- Class> cls = null;
- switch (position) {
- case 0:
- cls = HttpGetActivity.class;
- break;
- case 1:
- cls = HttpPostActivity.class;
- break;
- case 2:
- cls = TwitterActivity.class;
- break;
- case 3:
- cls = FacebookActivity.class;
- break;
- default:
- break;
- }
- startActivity(new Intent(parentView.getContext(), cls));
- }
- };
- }
+ @Override
+ protected OnItemClickListener getMenuOnItemClickListener() {
+ return new OnItemClickListener() {
+ public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
+ Class> cls = null;
+ switch (position) {
+ case 0:
+ cls = HttpGetActivity.class;
+ break;
+ case 1:
+ cls = HttpPostActivity.class;
+ break;
+ default:
+ break;
+ }
+ startActivity(new Intent(parentView.getContext(), cls));
+ }
+ };
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/MainApplication.java b/spring-android-showcase/client/src/org/springframework/android/showcase/MainApplication.java
deleted file mode 100644
index 0c082d3..0000000
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/MainApplication.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.springframework.android.showcase;
-
-import org.springframework.security.crypto.encrypt.AndroidEncryptors;
-import org.springframework.social.connect.ConnectionRepository;
-import org.springframework.social.connect.sqlite.SQLiteConnectionRepository;
-import org.springframework.social.connect.sqlite.support.SQLiteConnectionRepositoryHelper;
-import org.springframework.social.connect.support.ConnectionFactoryRegistry;
-import org.springframework.social.facebook.api.Facebook;
-import org.springframework.social.facebook.connect.FacebookConnectionFactory;
-import org.springframework.social.twitter.api.Twitter;
-import org.springframework.social.twitter.connect.TwitterConnectionFactory;
-
-import android.app.Application;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class MainApplication extends Application {
- private ConnectionFactoryRegistry connectionFactoryRegistry;
- private SQLiteOpenHelper repositoryHelper;
- private ConnectionRepository connectionRepository;
-
- // ***************************************
- // Application Methods
- // ***************************************
- @Override
- public void onCreate() {
- // create a new ConnectionFactoryLocator and populate it with Facebook
- // and Twitter ConnectionFactories
- connectionFactoryRegistry = new ConnectionFactoryRegistry();
- connectionFactoryRegistry.addConnectionFactory(new FacebookConnectionFactory(getFacebookAppId(), getFacebookAppSecret()));
- connectionFactoryRegistry.addConnectionFactory(new TwitterConnectionFactory(getTwitterConsumerToken(), getTwitterConsumerTokenSecret()));
-
- // set up the database and encryption
- repositoryHelper = new SQLiteConnectionRepositoryHelper(this);
- connectionRepository = new SQLiteConnectionRepository(repositoryHelper, connectionFactoryRegistry, AndroidEncryptors.text("password", "5c0744940b5c369b"));
- }
-
- // ***************************************
- // Private methods
- // ***************************************
- private String getFacebookAppId() {
- return getString(R.string.facebook_app_id);
- }
-
- private String getFacebookAppSecret() {
- return getString(R.string.facebook_app_secret);
- }
-
- private String getTwitterConsumerToken() {
- return getString(R.string.twitter_consumer_key);
- }
-
- private String getTwitterConsumerTokenSecret() {
- return getString(R.string.twitter_consumer_key_secret);
- }
-
- // ***************************************
- // Public methods
- // ***************************************
- public ConnectionRepository getConnectionRepository() {
- return connectionRepository;
- }
-
- public FacebookConnectionFactory getFacebookConnectionFactory() {
- return (FacebookConnectionFactory) connectionFactoryRegistry.getConnectionFactory(Facebook.class);
- }
-
- public TwitterConnectionFactory getTwitterConnectionFactory() {
- return (TwitterConnectionFactory) connectionFactoryRegistry.getConnectionFactory(Twitter.class);
- }
-
-}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchActivity.java
index e22316c..13d2de4 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,35 +28,35 @@
*/
public class GoogleSearchActivity extends AbstractMenuActivity {
- // ***************************************
- // AbstractMenuActivity methods
- // ***************************************
- @Override
- protected String getDescription() {
- return getResources().getString(R.string.text_http_get_google_search_description);
- }
+ // ***************************************
+ // AbstractMenuActivity methods
+ // ***************************************
+ @Override
+ protected String getDescription() {
+ return getResources().getString(R.string.text_http_get_google_search_description);
+ }
- @Override
- protected String[] getMenuItems() {
- return getResources().getStringArray(R.array.http_get_google_search_menu_items);
- }
+ @Override
+ protected String[] getMenuItems() {
+ return getResources().getStringArray(R.array.http_get_google_search_menu_items);
+ }
- @Override
- protected OnItemClickListener getMenuOnItemClickListener() {
- return new OnItemClickListener() {
- public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
- switch (position) {
- case 0:
- startActivity(new Intent(parentView.getContext(), GoogleSearchJacksonActivity.class));
- break;
- case 1:
- startActivity(new Intent(parentView.getContext(), GoogleSearchGsonActivity.class));
- break;
- default:
- break;
- }
- }
- };
- }
+ @Override
+ protected OnItemClickListener getMenuOnItemClickListener() {
+ return new OnItemClickListener() {
+ public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
+ switch (position) {
+ case 0:
+ startActivity(new Intent(parentView.getContext(), GoogleSearchJacksonActivity.class));
+ break;
+ case 1:
+ startActivity(new Intent(parentView.getContext(), GoogleSearchGsonActivity.class));
+ break;
+ default:
+ break;
+ }
+ }
+ };
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchGsonActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchGsonActivity.java
index 7159e6d..e0d482a 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchGsonActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchGsonActivity.java
@@ -34,96 +34,93 @@
*/
public class GoogleSearchGsonActivity extends AbstractAsyncListActivity {
- protected static final String TAG = GoogleSearchGsonActivity.class.getSimpleName();
-
- private List results;
-
- // ***************************************
- // Activity methods
- // ***************************************
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public void onStart() {
- super.onStart();
-
- // when this activity starts, initiate an asynchronous HTTP GET request
- new GoogleSearchTask().execute();
- }
-
- // ***************************************
- // ListActivity methods
- // ***************************************
- @Override
- protected void onListItemClick(android.widget.ListView l, android.view.View v, int position, long id) {
- if (results == null) {
- return;
- }
-
- GoogleSearchResult result = results.get(position);
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(result.getUrl())));
- }
-
- // ***************************************
- // Private methods
- // ***************************************
- private void refreshResults(GoogleSearchResponse response) {
- if (response == null) {
- return;
- }
-
- this.results = response.getResponseData().getResults();
- setListAdapter(new GoogleSearchResultListAdapter(this, results));
- }
-
- // ***************************************
- // Private classes
- // ***************************************
- private class GoogleSearchTask extends AsyncTask {
-
- @Override
- protected void onPreExecute() {
- // before the network request begins, show a progress indicator
- showLoadingProgressDialog();
- }
-
- @Override
- protected GoogleSearchResponse doInBackground(Void... params) {
- try {
- // The URL for making the GET request
- final String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}";
-
- // Create a new RestTemplate instance
- RestTemplate restTemplate = new RestTemplate();
-
- // Set a custom GsonHttpMessageConverter that supports the text/javascript media type
- GsonHttpMessageConverter messageConverter = new GsonHttpMessageConverter();
- messageConverter.setSupportedMediaTypes(Collections.singletonList(new MediaType("text", "javascript")));
- restTemplate.getMessageConverters().add(messageConverter);
-
- // Perform the HTTP GET request to the Google search API
- GoogleSearchResponse response = restTemplate.getForObject(url, GoogleSearchResponse.class, "Google Android");
-
- return response;
- } catch (Exception e) {
- Log.e(TAG, e.getMessage(), e);
- }
-
- return null;
- }
-
- @Override
- protected void onPostExecute(GoogleSearchResponse response) {
- // hide the progress indicator when the network request is complete
- dismissProgressDialog();
-
- // return the Google results
- refreshResults(response);
- }
-
- }
+ protected static final String TAG = GoogleSearchGsonActivity.class.getSimpleName();
+
+ private List results;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ // when this activity starts, initiate an asynchronous HTTP GET request
+ new GoogleSearchTask().execute();
+ }
+
+ // ***************************************
+ // ListActivity methods
+ // ***************************************
+ @Override
+ protected void onListItemClick(android.widget.ListView l, android.view.View v, int position, long id) {
+ if (this.results == null) {
+ return;
+ }
+
+ GoogleSearchResult result = this.results.get(position);
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(result.getUrl())));
+ }
+
+ // ***************************************
+ // Private methods
+ // ***************************************
+ private void refreshResults(GoogleSearchResponse response) {
+ if (response == null) {
+ return;
+ }
+
+ this.results = response.getResponseData().getResults();
+ setListAdapter(new GoogleSearchResultListAdapter(this, this.results));
+ }
+
+ // ***************************************
+ // Private classes
+ // ***************************************
+ private class GoogleSearchTask extends AsyncTask {
+
+ @Override
+ protected void onPreExecute() {
+ showLoadingProgressDialog();
+ }
+
+ @Override
+ protected GoogleSearchResponse doInBackground(Void... params) {
+ try {
+ // The URL for making the GET request
+ final String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}";
+
+ // Create a new RestTemplate instance
+ RestTemplate restTemplate = new RestTemplate();
+
+ // Set a custom GsonHttpMessageConverter that supports the text/javascript media type
+ GsonHttpMessageConverter messageConverter = new GsonHttpMessageConverter();
+ messageConverter.setSupportedMediaTypes(Collections.singletonList(new MediaType("text", "javascript")));
+ restTemplate.getMessageConverters().add(messageConverter);
+
+ // Perform the HTTP GET request to the Google search API
+ GoogleSearchResponse response = restTemplate.getForObject(url, GoogleSearchResponse.class,
+ "Google Android");
+
+ return response;
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage(), e);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(GoogleSearchResponse response) {
+ dismissProgressDialog();
+ refreshResults(response);
+ }
+
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchJacksonActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchJacksonActivity.java
index b0cea73..ff9c36c 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchJacksonActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchJacksonActivity.java
@@ -34,96 +34,92 @@
*/
public class GoogleSearchJacksonActivity extends AbstractAsyncListActivity {
- protected static final String TAG = GoogleSearchJacksonActivity.class.getSimpleName();
-
- private List results;
-
- // ***************************************
- // Activity methods
- // ***************************************
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public void onStart() {
- super.onStart();
-
- // when this activity starts, initiate an asynchronous HTTP GET request
- new GoogleSearchTask().execute();
- }
-
- // ***************************************
- // ListActivity methods
- // ***************************************
- @Override
- protected void onListItemClick(android.widget.ListView l, android.view.View v, int position, long id) {
- if (results == null) {
- return;
- }
-
- GoogleSearchResult result = results.get(position);
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(result.getUrl())));
- }
-
- // ***************************************
- // Private methods
- // ***************************************
- private void refreshResults(GoogleSearchResponse response) {
- if (response == null) {
- return;
- }
-
- this.results = response.getResponseData().getResults();
- setListAdapter(new GoogleSearchResultListAdapter(this, results));
- }
-
- // ***************************************
- // Private classes
- // ***************************************
- private class GoogleSearchTask extends AsyncTask {
-
- @Override
- protected void onPreExecute() {
- // before the network request begins, show a progress indicator
- showLoadingProgressDialog();
- }
-
- @Override
- protected GoogleSearchResponse doInBackground(Void... params) {
- try {
- // The URL for making the GET request
- final String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}";
-
- // Create a new RestTemplate instance
- RestTemplate restTemplate = new RestTemplate();
-
- // Set a custom MappingJacksonHttpMessageConverter that supports the text/javascript media type
- MappingJacksonHttpMessageConverter messageConverter = new MappingJacksonHttpMessageConverter();
- messageConverter.setSupportedMediaTypes(Collections.singletonList(new MediaType("text", "javascript")));
- restTemplate.getMessageConverters().add(messageConverter);
-
- // Perform the HTTP GET request to the Google search API
- GoogleSearchResponse response = restTemplate.getForObject(url, GoogleSearchResponse.class, "VMware");
-
- return response;
- } catch (Exception e) {
- Log.e(TAG, e.getMessage(), e);
- }
-
- return null;
- }
-
- @Override
- protected void onPostExecute(GoogleSearchResponse response) {
- // hide the progress indicator when the network request is complete
- dismissProgressDialog();
-
- // return the Google results
- refreshResults(response);
- }
-
- }
+ protected static final String TAG = GoogleSearchJacksonActivity.class.getSimpleName();
+
+ private List results;
+
+ // ***************************************
+ // Activity methods
+ // ***************************************
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ // when this activity starts, initiate an asynchronous HTTP GET request
+ new GoogleSearchTask().execute();
+ }
+
+ // ***************************************
+ // ListActivity methods
+ // ***************************************
+ @Override
+ protected void onListItemClick(android.widget.ListView l, android.view.View v, int position, long id) {
+ if (this.results == null) {
+ return;
+ }
+
+ GoogleSearchResult result = this.results.get(position);
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(result.getUrl())));
+ }
+
+ // ***************************************
+ // Private methods
+ // ***************************************
+ private void refreshResults(GoogleSearchResponse response) {
+ if (response == null) {
+ return;
+ }
+
+ this.results = response.getResponseData().getResults();
+ setListAdapter(new GoogleSearchResultListAdapter(this, this.results));
+ }
+
+ // ***************************************
+ // Private classes
+ // ***************************************
+ private class GoogleSearchTask extends AsyncTask {
+
+ @Override
+ protected void onPreExecute() {
+ showLoadingProgressDialog();
+ }
+
+ @Override
+ protected GoogleSearchResponse doInBackground(Void... params) {
+ try {
+ // The URL for making the GET request
+ final String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}";
+
+ // Create a new RestTemplate instance
+ RestTemplate restTemplate = new RestTemplate();
+
+ // Set a custom MappingJacksonHttpMessageConverter that supports the text/javascript media type
+ MappingJacksonHttpMessageConverter messageConverter = new MappingJacksonHttpMessageConverter();
+ messageConverter.setSupportedMediaTypes(Collections.singletonList(new MediaType("text", "javascript")));
+ restTemplate.getMessageConverters().add(messageConverter);
+
+ // Perform the HTTP GET request to the Google search API
+ GoogleSearchResponse response = restTemplate.getForObject(url, GoogleSearchResponse.class, "VMware");
+
+ return response;
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage(), e);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(GoogleSearchResponse response) {
+ dismissProgressDialog();
+ refreshResults(response);
+ }
+
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResponse.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResponse.java
index 818b3be..bc4d6ab 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResponse.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,29 +25,29 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class GoogleSearchResponse {
- private ResponseData responseData;
+ private ResponseData responseData;
- public void setResponseData(ResponseData responseData) {
- this.responseData = responseData;
- }
+ public void setResponseData(ResponseData responseData) {
+ this.responseData = responseData;
+ }
- public ResponseData getResponseData() {
- return responseData;
- }
+ public ResponseData getResponseData() {
+ return this.responseData;
+ }
- @JsonIgnoreProperties(ignoreUnknown = true)
- static class ResponseData {
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ static class ResponseData {
- private List results;
+ private List results;
- public void setResults(List results) {
- this.results = results;
- }
+ public void setResults(List results) {
+ this.results = results;
+ }
- public List getResults() {
- return results;
- }
+ public List getResults() {
+ return this.results;
+ }
- }
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResult.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResult.java
index 948adf1..9c9f024 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResult.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResult.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,13 +20,13 @@
/**
* @author Roy Clarkson
*/
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonIgnoreProperties(ignoreUnknown = true)
public class GoogleSearchResult {
private String title;
-
+
private String url;
-
+
private String content;
public void setTitle(String title) {
@@ -34,7 +34,7 @@ public void setTitle(String title) {
}
public String getTitle() {
- return title;
+ return this.title;
}
public void setUrl(String url) {
@@ -42,7 +42,7 @@ public void setUrl(String url) {
}
public String getUrl() {
- return url;
+ return this.url;
}
public void setContent(String content) {
@@ -50,7 +50,7 @@ public void setContent(String content) {
}
public String getContent() {
- return content;
+ return this.content;
}
-
+
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResultListAdapter.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResultListAdapter.java
index cf11139..008917e 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResultListAdapter.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/GoogleSearchResultListAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,45 +31,45 @@
*/
public class GoogleSearchResultListAdapter extends BaseAdapter {
- private List results;
- private final LayoutInflater layoutInflater;
+ private List results;
+ private final LayoutInflater layoutInflater;
- public GoogleSearchResultListAdapter(Context context, List results) {
- this.results = results;
- this.layoutInflater = LayoutInflater.from(context);
- }
+ public GoogleSearchResultListAdapter(Context context, List results) {
+ this.results = results;
+ this.layoutInflater = LayoutInflater.from(context);
+ }
- public int getCount() {
- return results != null ? results.size() : 0;
- }
+ public int getCount() {
+ return this.results != null ? this.results.size() : 0;
+ }
- public GoogleSearchResult getItem(int position) {
- return results.get(position);
- }
+ public GoogleSearchResult getItem(int position) {
+ return this.results.get(position);
+ }
- public long getItemId(int position) {
- return position;
- }
+ public long getItemId(int position) {
+ return position;
+ }
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = layoutInflater.inflate(R.layout.google_search_results_list_item, parent, false);
- }
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = this.layoutInflater.inflate(R.layout.google_search_results_list_item, parent, false);
+ }
- GoogleSearchResult result = getItem(position);
- if (result != null) {
- TextView t = (TextView) convertView.findViewById(R.id.title);
- t.setText(removeMarkup(result.getTitle()));
+ GoogleSearchResult result = getItem(position);
+ if (result != null) {
+ TextView t = (TextView) convertView.findViewById(R.id.title);
+ t.setText(removeMarkup(result.getTitle()));
- t = (TextView) convertView.findViewById(R.id.content);
- t.setText(removeMarkup(result.getContent()));
- }
+ t = (TextView) convertView.findViewById(R.id.content);
+ t.setText(removeMarkup(result.getContent()));
+ }
- return convertView;
- }
+ return convertView;
+ }
- private String removeMarkup(String s) {
- return s.replace("", "").replace("", "");
- }
+ private String removeMarkup(String s) {
+ return s.replace("", "").replace("", "");
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetActivity.java
index 205a57d..e61c1b7 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,42 +28,42 @@
*/
public class HttpGetActivity extends AbstractMenuActivity {
- // ***************************************
- // AbstractMenuActivity methods
- // ***************************************
- @Override
- protected String getDescription() {
- return getResources().getString(R.string.text_http_get_description);
- }
+ // ***************************************
+ // AbstractMenuActivity methods
+ // ***************************************
+ @Override
+ protected String getDescription() {
+ return getResources().getString(R.string.text_http_get_description);
+ }
- @Override
- protected String[] getMenuItems() {
- return getResources().getStringArray(R.array.http_get_activity_menu_items);
- }
+ @Override
+ protected String[] getMenuItems() {
+ return getResources().getStringArray(R.array.http_get_activity_menu_items);
+ }
- @Override
- protected OnItemClickListener getMenuOnItemClickListener() {
- return new OnItemClickListener() {
- public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
- switch (position) {
- case 0:
- startActivity(new Intent(parentView.getContext(), HttpGetJsonXmlActivity.class));
- break;
- case 1:
- startActivity(new Intent(parentView.getContext(), HttpGetParametersActivity.class));
- break;
- case 2:
- startActivity(new Intent(parentView.getContext(), GoogleSearchActivity.class));
- break;
- case 3:
- startActivity(new Intent(parentView.getContext(), HttpGetGzipActivity.class));
- break;
- case 4:
- startActivity(new Intent(parentView.getContext(), HttpGetSetRequestTimeoutActivity.class));
- default:
- break;
- }
- }
- };
- }
+ @Override
+ protected OnItemClickListener getMenuOnItemClickListener() {
+ return new OnItemClickListener() {
+ public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
+ switch (position) {
+ case 0:
+ startActivity(new Intent(parentView.getContext(), HttpGetJsonXmlActivity.class));
+ break;
+ case 1:
+ startActivity(new Intent(parentView.getContext(), HttpGetParametersActivity.class));
+ break;
+ case 2:
+ startActivity(new Intent(parentView.getContext(), GoogleSearchActivity.class));
+ break;
+ case 3:
+ startActivity(new Intent(parentView.getContext(), HttpGetGzipActivity.class));
+ break;
+ case 4:
+ startActivity(new Intent(parentView.getContext(), HttpGetSetRequestTimeoutActivity.class));
+ default:
+ break;
+ }
+ }
+ };
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetGzipActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetGzipActivity.java
index 7d45b61..3b6241b 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetGzipActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetGzipActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,35 +28,35 @@
*/
public class HttpGetGzipActivity extends AbstractMenuActivity {
- @Override
- protected String getDescription() {
- return getResources().getString(R.string.text_http_get_gzip_description);
- }
+ @Override
+ protected String getDescription() {
+ return getResources().getString(R.string.text_http_get_gzip_description);
+ }
- @Override
- protected String[] getMenuItems() {
- return getResources().getStringArray(R.array.http_get_gzip_activity_menu_items);
- }
+ @Override
+ protected String[] getMenuItems() {
+ return getResources().getStringArray(R.array.http_get_gzip_activity_menu_items);
+ }
- @Override
- protected OnItemClickListener getMenuOnItemClickListener() {
- return new OnItemClickListener() {
- public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
- switch (position) {
- case 0:
- startActivity(new Intent(parentView.getContext(), HttpGetGzipCompressedActivity.class));
- break;
- case 1:
- startActivity(new Intent(parentView.getContext(), HttpGetGzipUncompressedActivity.class));
- break;
- case 2:
- startActivity(new Intent(parentView.getContext(), HttpGetGzipCompressedJsonActivity.class));
- break;
- default:
- break;
- }
- }
- };
- }
+ @Override
+ protected OnItemClickListener getMenuOnItemClickListener() {
+ return new OnItemClickListener() {
+ public void onItemClick(AdapterView> parentView, View childView, int position, long id) {
+ switch (position) {
+ case 0:
+ startActivity(new Intent(parentView.getContext(), HttpGetGzipCompressedActivity.class));
+ break;
+ case 1:
+ startActivity(new Intent(parentView.getContext(), HttpGetGzipUncompressedActivity.class));
+ break;
+ case 2:
+ startActivity(new Intent(parentView.getContext(), HttpGetGzipCompressedJsonActivity.class));
+ break;
+ default:
+ break;
+ }
+ }
+ };
+ }
}
diff --git a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetGzipCompressedActivity.java b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetGzipCompressedActivity.java
index 296f967..44f35d5 100644
--- a/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetGzipCompressedActivity.java
+++ b/spring-android-showcase/client/src/org/springframework/android/showcase/rest/HttpGetGzipCompressedActivity.java
@@ -35,90 +35,88 @@
*/
public class HttpGetGzipCompressedActivity extends AbstractAsyncActivity {
- // ***************************************
- // Activity methods
- // ***************************************
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.http_get_gzip_activity_layout);
- }
-
- @Override
- public void onStart() {
- super.onStart();
- new GzipRequestTask().execute();
- }
-
- // ***************************************
- // Private methods
- // ***************************************
- private void refreshResults(ResponseEntity response) {
- if (response == null) {
- return;
- }
-
- HttpHeaders headers = response.getHeaders();
- StringBuilder sb = new StringBuilder();
- sb.append("Date: ").append(headers.getFirst("Date")).append("\n");
- sb.append("Status: ").append(headers.getFirst("Status")).append("\n");
- sb.append("Content-Type: ").append(headers.getFirst("Content-Type")).append("\n");
- sb.append("Content-Encoding: ").append(headers.getFirst("Content-Encoding")).append("\n");
- sb.append("Content-Length: ").append(headers.getFirst("Content-Length")).append("\n");
-
- TextView textView = (TextView) findViewById(R.id.text_view_headers);
- textView.setText(sb.toString());
-
- String results = response.getBody() + "\n";
-
- textView = (TextView) findViewById(R.id.text_view_results);
- textView.setText(results);
- }
-
- // ***************************************
- // Private classes
- // ***************************************
- private class GzipRequestTask extends AsyncTask> {
-
- @Override
- protected void onPreExecute() {
- // before the network request begins, show a progress indicator
- showLoadingProgressDialog();
- }
-
- @Override
- protected ResponseEntity doInBackground(Void... params) {
- try {
- // The URL for making the GET request
- final String url = "http://search.twitter.com/search.json?q={query}&rpp=100";
-
- // Add the gzip Accept-Encoding header to the request
- HttpHeaders requestHeaders = new HttpHeaders();
- requestHeaders.setAcceptEncoding(ContentCodingType.GZIP);
-
- // Create a new RestTemplate instance
- RestTemplate restTemplate = new RestTemplate();
- restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
-
- // Perform the HTTP GET request
- ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity