Skip to content
Browse files

Merge small pull requests

Summary:
To give credit for changes, I am listing author/pull request here
for changes incorporated in this checkin.

I am submitting these changes directly to master to preserve a
linear history, to allow for minor edits, and to credit multiple
people when more than one change was merged to fix a single issue.

=== Summary by submitter of pull requests in this commit ===
andypalmer:
- 160: ClassCastExceptions in Util.java
grant land:
- 216: Fix ArrayOutOfBoundsException when clicking "Don't Allow" in FbDialog one
iamnoah:
- 117: Fixed a NPE
lvillani:
- 261: Add support for Android build system.
nikreiman:
- 218: Fix exception when trying to decode invalid string
plowman:
- 246: Fix for Issue #160: ClassCastExceptions filling up the logs.

To investigate pull request 260, I enabled orientation changes in Hackbook.
This did not demonstrate the issue, but doesn't hurt anything and makes it
easier to test on the x86 emulator.

I also fixed some build issues in Hackbook around SDK version required and
the path to the SDK.

Test Plan:
Full clean builds of facebook and Hackbook.
Verify creating Eclipse project per public docs still works.
Upload photo in Android Hackbook.

Reviewers: caabernathy, jacl, vijaye, yariv

Reviewed By: jacl

CC: ekoneil, gregschechte

Differential Revision: https://phabricator.fb.com/D451434

Revert Plan: Safe to revert

Task ID: 1028564
  • Loading branch information...
1 parent 5a72863 commit 1e03bf9ea42eb663bf61eddac9d7b6bee3b6e69f @rightparen rightparen committed Apr 16, 2012
View
5 .arcconfig
@@ -0,0 +1,5 @@
+{
+ "project_id" : "facebook-android-sdk",
+ "conduit_uri" : "https://phabricator.fb.com/api/",
+ "copyright_holder" : "Facebook"
+}
View
6 .gitignore
@@ -5,11 +5,15 @@
*.classpath
*.project
*.settings
+facebook/local.properties
facebook/bin/
facebook/gen/
+examples/Hackbook/bin/
+examples/Hackbook/gen/
+examples/Hackbook/local.properties
examples/stream/bin/
examples/simple/bin/
examples/stream/gen/
examples/simple/gen/
tests/bin
-tests/gen
+tests/gen
View
5 examples/Hackbook/AndroidManifest.xml
@@ -21,8 +21,7 @@
</activity>
<activity android:name=".Hackbook"
android:label="@string/app_name"
- android:configChanges="keyboardHidden"
- android:screenOrientation="portrait">
+ android:configChanges="keyboardHidden|orientation">
</activity>
<activity
android:name=".GraphExplorer"
@@ -45,5 +44,5 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
- <uses-sdk android:minSdkVersion="3" />
+ <uses-sdk android:minSdkVersion="8" />
</manifest>
View
83 examples/Hackbook/build.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="Hackbook" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
+ unless="sdk.dir"
+ />
+
+ <!--
+ Import per project custom build rules if present at the root of the project.
+ This is the place to put custom intermediary targets such as:
+ -pre-build
+ -pre-compile
+ -post-compile (This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir})
+ -post-package
+ -post-build
+ -pre-clean
+ -->
+ <import file="custom_rules.xml" optional="true" />
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
View
2 examples/Hackbook/default.properties
@@ -11,4 +11,4 @@
split.density=false
# Project target.
target=android-8
-android.library.reference.1=../../../newdialog/facebook-android-sdk/facebook
+android.library.reference.1=../../facebook
View
20 examples/Hackbook/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
View
17 examples/Hackbook/project.properties
@@ -0,0 +1,17 @@
+# 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 edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Indicates whether an apk should be generated for each density.
+split.density=false
+android.library.reference.1=../../facebook
+# Project target.
+target=android-8
View
0 examples/Hackbook/res/layout/main.xml → examples/Hackbook/res/layout-land/main.xml
File renamed without changes.
View
43 examples/Hackbook/res/layout-port/main.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="center_horizontal">
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:padding="6dip"
+ android:layout_height="?android:attr/listPreferredItemHeight">
+ <ImageView
+ android:id="@+id/user_pic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
+ android:layout_marginRight="6dip" />
+ <TextView
+ android:id="@+id/txt"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/user_pic" />
+ <com.facebook.android.LoginButton
+ android:id="@+id/login"
+ android:src="@drawable/login_button"
+ android:layout_toRightOf="@id/user_pic"
+ android:layout_below="@id/txt"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+ </RelativeLayout>
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:background="@color/grey" />
+ <ListView
+ android:id="@+id/main_list"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:background="@color/grey" />
+</LinearLayout>
View
83 facebook/build.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="facebook" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
+ unless="sdk.dir"
+ />
+
+ <!--
+ Import per project custom build rules if present at the root of the project.
+ This is the place to put custom intermediary targets such as:
+ -pre-build
+ -pre-compile
+ -post-compile (This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir})
+ -post-package
+ -post-build
+ -pre-clean
+ -->
+ <import file="custom_rules.xml" optional="true" />
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
View
12 facebook/default.properties
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-android.library=true
-# Project target.
-target=android-3
View
20 facebook/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
View
15 facebook/project.properties
@@ -0,0 +1,15 @@
+# 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 edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+android.library=true
+# Project target.
+target=android-3
View
2 facebook/src/com/facebook/android/FacebookError.java
@@ -22,7 +22,7 @@
*
* @author ssoneff@facebook.com
*/
-public class FacebookError extends Throwable {
+public class FacebookError extends RuntimeException {
private static final long serialVersionUID = 1L;
View
21 facebook/src/com/facebook/android/Util.java
@@ -66,12 +66,13 @@ public static String encodePostBody(Bundle parameters, String boundary) {
StringBuilder sb = new StringBuilder();
for (String key : parameters.keySet()) {
- if (parameters.getByteArray(key) != null) {
+ Object parameter = parameters.get(key);
+ if (!(parameter instanceof String)) {
continue;
}
sb.append("Content-Disposition: form-data; name=\"" + key +
- "\"\r\n\r\n" + parameters.getString(key));
+ "\"\r\n\r\n" + (String)parameter);
sb.append("\r\n" + "--" + boundary + "\r\n");
}
@@ -86,6 +87,11 @@ public static String encodeUrl(Bundle parameters) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String key : parameters.keySet()) {
+ Object parameter = parameters.get(key);
+ if (!(parameter instanceof String)) {
+ continue;
+ }
+
if (first) first = false; else sb.append("&");
sb.append(URLEncoder.encode(key) + "=" +
URLEncoder.encode(parameters.getString(key)));
@@ -99,8 +105,10 @@ public static Bundle decodeUrl(String s) {
String array[] = s.split("&");
for (String parameter : array) {
String v[] = parameter.split("=");
- params.putString(URLDecoder.decode(v[0]),
- URLDecoder.decode(v[1]));
+ if (v.length == 2) {
+ params.putString(URLDecoder.decode(v[0]),
+ URLDecoder.decode(v[1]));
+ }
}
}
return params;
@@ -158,8 +166,9 @@ public static String openUrl(String url, String method, Bundle params)
if (!method.equals("GET")) {
Bundle dataparams = new Bundle();
for (String key : params.keySet()) {
- if (params.getByteArray(key) != null) {
- dataparams.putByteArray(key, params.getByteArray(key));
+ Object parameter = params.get(key);
+ if (parameter instanceof byte[]) {
+ dataparams.putByteArray(key, (byte[])parameter);
}
}

1 comment on commit 1e03bf9

@elezabeth

facebook

Please sign in to comment.
Something went wrong with that request. Please try again.