Skip to content

Commit

Permalink
Merge pull request #53 from hansemannn/TIMOB-23424
Browse files Browse the repository at this point in the history
[TIMOB-23424] Android: Support presentInviteDialog
  • Loading branch information
hieupham007 committed May 26, 2016
2 parents 59d011f + d53e0db commit 69a1edb
Show file tree
Hide file tree
Showing 177 changed files with 1,149 additions and 2,473 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ android/.settings
android/launch-*
nbproject
ios/FacebookIOS.xcodeproj/project.xcworkspace/xcuserdata/
/android/java-sources.txt
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ Also you will need a Facebook App ID ready. To create a Facebook App ID, go to t
On the iOS platform, add the following property to the \<ios\>\<plist\>\<dict\> section in tiapp.xml:
```xml
<key>FacebookAppID</key>
<string>1234567891011</string>
<string>1234567890123456</string>
<key>FacebookDisplayName</key>
<string>SomeName</string>
```
where SomeName is exactly as appears in the Facebook developer settings page

Also make sure you have a URL Scheme in tiapp.xml that looks like fb1234567891010. See Facebook docs for details on this. Add an entry to \<ios\>\<plist\>\<dict\> that looks like this, modify it for your app:
Also make sure you have a URL Scheme in tiapp.xml that looks like fb1234567890123456. See Facebook docs for details on this. Add an entry to \<ios\>\<plist\>\<dict\> that looks like this, modify it for your app:
```xml
<key>CFBundleURLTypes</key>
<array>
Expand All @@ -41,13 +41,13 @@ Also make sure you have a URL Scheme in tiapp.xml that looks like fb123456789101
<key>CFBundleURLSchemes</key>
<array>
<string>kitchensink</string>
<string>fb134793934930</string>
<string>fb1234567890123456</string>
</array>
</dict>
</array>
```

To define a url scheme suffix for multiple apps sharing the same facebook app ID, simply add the suffix (in lower case and must start with a letter) to the relevant string under the CFBundleURLSchemes key. In this example, it will look like fb134793934930foo if you are adding the suffix foo. This will also require additional configurations in the facebook dashboard, see https://developers.facebook.com/docs/ios/troubleshooting#sharedappid for details.
To define a url scheme suffix for multiple apps sharing the same facebook app ID, simply add the suffix (in lower case and must start with a letter) to the relevant string under the CFBundleURLSchemes key. In this example, it will look like fb1234567890123456foo if you are adding the suffix foo. This will also require additional configurations in the facebook dashboard, see https://developers.facebook.com/docs/ios/troubleshooting#sharedappid for details.

To enable the use of Facebook dialogs (e.g., Login, Share), you also need to include the following key and values in tiapp.xml to handle the switching in and out of your app:
```xml
Expand Down Expand Up @@ -101,9 +101,15 @@ You must also reference the string containing your Facebook app ID, inside the \
```xml
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
```
The app id goes into the the file /platform/android/res/values/strings.xml, where you should define
The app id goes into the the file /platform/android/res/values/strings.xml (or your custom theme), where you should define
```xml
<resources><string name="app_id">1234567890123456</string></resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- ... -->
<string name="app_id">1234567890123456</string>
<!-- ... -->
</resources>
</xml>
```
where the number is of course the app ID. The app ID is not set programmatically.

Expand Down Expand Up @@ -284,7 +290,7 @@ To share more information, example:
});
```
Invite Dialog (iOS)
Invite Dialog
---
Opens a supported Facebook Invite dialog from the Facebook App. To monitor if the share request succeeded
Expand Down
13 changes: 11 additions & 2 deletions android/documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Change Log
<pre>
v5.0.0 Updated Facebook API to 4.7 in iOS, that supports iOS9 [TIMOB-19383]
v5.2.0 Updated Facebook API to 4.11.0 in iOS and Android
Support `loginBehavior` on iOS and Android [MOD-2242]
Support new parameters in `logCustomEvent` on iOS and Android [MOD-2248]
Support `logPurchase` on iOS and Android [MOD-2244]

v5.1.0 Updated Facebook API to 4.10.0 in iOS [MOD-2180]
Support for the Facebook Messenger API. [MOD-2180]
Support for the Invite Dialog [MOD-2200]

v5.0.0 Updated Facebook API to 4.7.0 in iOS, that supports iOS9 [TIMOB-19383]
Updated Facebook API to 4.7.0 in Android [TIMOB-19577]

v4.0.5 fixed presentSendRequestDialog with to and title params [MOD-2126]
Expand All @@ -14,7 +23,7 @@ v4.0.2 Updated Facebook SDK from 3.21.1 to 3.23.1
Bumped iOS module version to be same as android
Fixed `requestNewReadPermissions` and the `LikeButton` in Android [MOD-2105]

v4.0.1 Changing sessionDefaultAudence to audience in Android [MOD-2107]
v4.0.1 Changing sessionDefaultAudence to audience in Android [MOD-2107]

v4.0.0 Combined and updated the Facebook module from https://github.com/mokesmokes/titanium-android-facebook/ and https://github.com/mokesmokes/titanium-ios-facebook

Expand Down
48 changes: 48 additions & 0 deletions android/example/facebook_messenger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
exports.window = function(value) {
if (Ti.Platform.osname == "android") {
Ti.API.warn("This feature is currently iOS-only.");
return;
}

var fb = require('facebook');

var win = Ti.UI.createWindow({
title: 'Login/Logout',
backgroundColor:'#fff',
layout: "vertical"
});

addButtonWithModeAndStyle(fb.MESSENGER_BUTTON_MODE_CIRCULAR,fb.MESSENGER_BUTTON_STYLE_BLUE);
addButtonWithModeAndStyle(fb.MESSENGER_BUTTON_MODE_CIRCULAR,fb.MESSENGER_BUTTON_STYLE_WHITE);
addButtonWithModeAndStyle(fb.MESSENGER_BUTTON_MODE_CIRCULAR,fb.MESSENGER_BUTTON_STYLE_WHITE_BORDERED);

addButtonWithModeAndStyle(fb.MESSENGER_BUTTON_MODE_RECTANGULAR,fb.MESSENGER_BUTTON_STYLE_BLUE);
addButtonWithModeAndStyle(fb.MESSENGER_BUTTON_MODE_RECTANGULAR,fb.MESSENGER_BUTTON_STYLE_WHITE);
addButtonWithModeAndStyle(fb.MESSENGER_BUTTON_MODE_RECTANGULAR,fb.MESSENGER_BUTTON_STYLE_WHITE_BORDERED);

function addButtonWithModeAndStyle(mode, style) {
var btn = fb.createMessengerButton({
top: 20,
mode: mode,
style: style
});

btn.addEventListener("click", shareOnMessenger);
win.add(btn);
}

function shareOnMessenger() {
if (!Ti.Platform.canOpenURL("fb-messenger-api://")) {
alert("No facebook messenger installed");
return;
}
fb.presentMessengerDialog({
title: "Appcelerator Titanium rocks!",
description: "Sent using Ti.Facebook",
link: "https://appcelerator.com",
to: []
});
}

return win;
};
2 changes: 0 additions & 2 deletions android/lib/README

This file was deleted.

Binary file added android/lib/facebook-android-4.12.0.jar
Binary file not shown.
Binary file removed android/lib/facebook_sdk_470.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
Expand All @@ -19,6 +18,7 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<resources>
<string name="messenger_send_button_text">إرسال</string>
</resources>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_enabled="true" android:color="@color/com_facebook_blue" />
<item android:color="#fffffe" />
</selector>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
Expand All @@ -19,6 +18,7 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<resources>
<string name="messenger_send_button_text">প্রেরণ করুন</string>
</resources>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_enabled="true" android:color="@color/com_facebook_messenger_blue" />
<item android:color="#fffffe" />
</selector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.
As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Developer Principles and Policies
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f2fafafa" />
<corners
android:bottomLeftRadius="@dimen/com_facebook_auth_dialog_corner_radius"
android:bottomRightRadius="@dimen/com_facebook_auth_dialog_corner_radius"
android:topLeftRadius="@dimen/com_facebook_auth_dialog_corner_radius_oversized"
android:topRightRadius="@dimen/com_facebook_auth_dialog_corner_radius_oversized" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.
As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Developer Principles and Policies
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#999999" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#33999999" />
</shape>
</item>
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.
As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Developer Principles and Policies
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/com_facebook_blue" />
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="@dimen/com_facebook_auth_dialog_corner_radius"
android:topRightRadius="@dimen/com_facebook_auth_dialog_corner_radius" />
</shape>
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,39 @@
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<item android:state_enabled="false"
android:state_focused="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_focused_disabled" />
</shape>
</item>
<item android:state_enabled="false"
android:state_focused="false">
<shape android:shape="rectangle">
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_disabled" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_focused" />
<stroke
android:width="1dp"
android:color="@color/com_facebook_button_border_color_focused" >
</stroke>
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_pressed" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color" />
</shape>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<resources>
<string name="messenger_send_button_text">Stuur</string>
</resources>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/com_facebook_button_icon_blue"/>
<item android:drawable="@drawable/com_facebook_button_icon_white"/>
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,41 @@
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_pressed" />
</shape>
</item>
<item android:state_enabled="false"
android:state_focused="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_focused_disabled" />
</shape>
</item>
<item android:state_enabled="false"
android:state_focused="false">
<shape android:shape="rectangle">
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_disabled" />
</shape>
</item>
<item android:state_pressed="true">
<item android:state_focused="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/com_facebook_button_background_color_pressed" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_focused" />
</shape>
</item>
<item android:state_selected="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/com_facebook_button_like_background_color_selected" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_selected" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color" />
</shape>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_background_color_disabled" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_login_silver_background_color_pressed" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<corners android:radius="@dimen/com_facebook_button_corner_radius" />
<solid android:color="@color/com_facebook_button_login_silver_background_color" />
</shape>
</item>
Expand Down
Loading

0 comments on commit 69a1edb

Please sign in to comment.