├── VRDeeplinkSample
├── app
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_vrdeeplink_sample.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── com
│ │ │ └── facebook
│ │ │ └── vrdeeplinksdk
│ │ │ └── sample
│ │ │ └── VRDeeplinkSampleActivity.java
│ ├── libs
│ │ └── VRDeepLinkSDK-release.aar
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── build.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
├── VRDeepLinkSDK
├── BUCK
├── res
│ └── .README.txt
├── AndroidManifest.xml
├── build.gradle
├── src
│ └── com
│ │ └── facebook
│ │ └── vrdeeplinksdk
│ │ └── VRDeepLinkHelper.java
└── test
│ └── com
│ └── facebook
│ └── vrdeeplinksdk
│ └── VRDeepLinkHelperTest.java
├── .gitignore
├── LICENSE
├── CONTRIBUTING.md
└── README.md
/VRDeeplinkSample/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | VRDeeplinkSample
3 |
4 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/libs/VRDeepLinkSDK-release.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbsamples/VRDeepLinkSDK/HEAD/VRDeeplinkSample/app/libs/VRDeepLinkSDK-release.aar
--------------------------------------------------------------------------------
/VRDeeplinkSample/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbsamples/VRDeepLinkSDK/HEAD/VRDeeplinkSample/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/VRDeepLinkSDK/BUCK:
--------------------------------------------------------------------------------
1 | android_library(
2 | name = 'vrdeeplinksdk',
3 | srcs = glob(['src/**/*.java']),
4 | deps = [
5 | ],
6 | visibility = ['PUBLIC']
7 | )
8 |
--------------------------------------------------------------------------------
/VRDeepLinkSDK/res/.README.txt:
--------------------------------------------------------------------------------
1 | This file is needed to make sure the res directory is present.
2 | The file is ignored by the Android toolchain because its name starts with a dot.
3 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbsamples/VRDeepLinkSDK/HEAD/VRDeeplinkSample/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbsamples/VRDeepLinkSDK/HEAD/VRDeeplinkSample/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbsamples/VRDeepLinkSDK/HEAD/VRDeeplinkSample/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbsamples/VRDeepLinkSDK/HEAD/VRDeeplinkSample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbsamples/VRDeepLinkSDK/HEAD/VRDeeplinkSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/VRDeepLinkSDK/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
9 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Lines that start with '#' are comments.
2 | #
3 |
4 | # Cached python scripts in bytecode form
5 | *.pyc
6 |
7 | # Gradle-related files
8 | .gradle
9 | /VRDeepLinkSDK/build/
10 | /VRDeepLinkSDK/gen/
11 | /VRDeepLinkSDK/out/
12 |
13 | # Android Studio files
14 | .idea/
15 | *.iml
16 |
17 | # Windows project files
18 | *.opensdf
19 | *.sdf
20 | *.vcxproj.user
21 | *.suo
22 |
23 | # Windows build artifacts
24 |
25 | # packed assets
26 | /*/packed/
27 | /*/assets.pak
28 |
29 | # OSX
30 | .DS_Store
31 | .AppleDouble
32 | .LSOverride
33 | ._*
34 |
35 | # VIM swap files
36 | *.swp
37 | *.swo
38 |
39 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.0.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/wongchristopher/Documents/workspace/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/build.gradle:
--------------------------------------------------------------------------------
1 | allprojects {
2 | repositories {
3 | mavenCentral()
4 | flatDir {
5 | dirs 'libs'
6 | }
7 | }
8 | }
9 |
10 | apply plugin: 'com.android.application'
11 |
12 | android {
13 | compileSdkVersion 23
14 | buildToolsVersion "23.0.3"
15 |
16 | defaultConfig {
17 | applicationId "com.facebook.vrdeeplinksdk.sample"
18 | minSdkVersion 19
19 | targetSdkVersion 23
20 | versionCode 1
21 | versionName "1.0"
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | }
30 |
31 | dependencies {
32 | compile fileTree(dir: 'libs', include: ['*.jar'])
33 | compile(name:'VRDeepLinkSDK-release', ext:'aar')
34 | testCompile 'junit:junit:4.12'
35 | compile 'com.android.support:appcompat-v7:23.1.1'
36 | }
37 |
--------------------------------------------------------------------------------
/VRDeepLinkSDK/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | }
5 | dependencies {
6 | classpath 'com.android.tools.build:gradle:1.5.0'
7 | }
8 | }
9 |
10 | apply plugin: 'com.android.library'
11 |
12 | dependencies {
13 | compile 'com.android.support:support-annotations:22.2.0'
14 | testCompile 'junit:junit:4.12'
15 | testCompile 'org.mockito:mockito-core:1.10.19'
16 | testCompile 'org.robolectric:robolectric:3.0'
17 | testCompile 'org.robolectric:shadows-support-v4:3.0'
18 | }
19 |
20 | android {
21 | compileOptions {
22 | sourceCompatibility = "1.7"
23 | targetCompatibility = "1.7"
24 | }
25 | compileSdkVersion 23
26 | buildToolsVersion '23.0.1'
27 |
28 | sourceSets {
29 | main {
30 | manifest.srcFile 'AndroidManifest.xml'
31 | java.srcDirs = ['src']
32 | }
33 |
34 | test {
35 | java {
36 | srcDirs = ["test"]
37 | }
38 | }
39 | }
40 | }
41 |
42 | allprojects {
43 | repositories {
44 | mavenCentral()
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
2 |
3 | You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4 | copy, modify, and distribute this software in source code or binary form for use
5 | in connection with the web services and APIs provided by Facebook.
6 |
7 | As with any software that integrates with the Facebook platform, your use of
8 | this software is subject to the Facebook Developer Principles and Policies
9 | [http://developers.facebook.com/policy/]. This copyright notice shall be
10 | included in all copies or substantial portions of the software.
11 |
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 |
19 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/res/layout/activity_vrdeeplink_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
19 |
20 |
25 |
26 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to VRDeepLinkSDK
2 | We want to make contributing to this project as easy and transparent as
3 | possible.
4 |
5 | ## Pull Requests
6 | We actively welcome your pull requests.
7 |
8 | 1. Fork the repo and create your branch from `master`.
9 | 2. If you've added code that should be tested, add tests.
10 | 3. If you've changed APIs, update the documentation.
11 | 4. Ensure the test suite passes.
12 | 5. Make sure your code lints.
13 | 6. If you haven't already, complete the Contributor License Agreement ("CLA").
14 |
15 | ## Contributor License Agreement ("CLA")
16 | In order to accept your pull request, we need you to submit a CLA. You only need
17 | to do this once to work on any of Facebook's open source projects.
18 |
19 | Complete your CLA here:
20 |
21 | ## Issues
22 | We use GitHub issues to track public bugs. Please ensure your description is
23 | clear and has sufficient instructions to be able to reproduce the issue.
24 |
25 | Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
26 | disclosure of security bugs. In those cases, please go through the process
27 | outlined on that page and do not file a public issue.
28 |
29 | ## Coding Style
30 | * 2 spaces for indentation rather than tabs
31 | * 80 character line length
32 | * ...
33 |
34 | ## License
35 | By contributing to VRDeepLinkSDK, you agree that your contributions will be licensed
36 | under the LICENSE file in the root directory of this source tree.
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ** THIS REPO HAS BEEN ARCHIVED AND IS NO LONGER BEING ACTIVELY MAINTAINED **
2 |
3 | # VRDeepLinkSDK
4 | This SDK provides code samples on how to construct a URI intent to view 360
5 | immersive contents that are hosted on Facebook, either in Oculus Video/360Photo
6 | app if installed or the Facebook for Android application.
7 |
8 | To begin, you will pass in the media FBId of the video/photo content to construct
9 | the parameter object. You can find the fbid of the content by inspecting the url
10 | of the content. For example for video objects, the fbid is the string of numbers
11 | (10153779045038951) at the end of the url -
12 | ```
13 | $ https://www.facebook.com/natgeo/videos/10153779045038951/
14 | ```
15 |
16 | For 360 photos, it's the value of the fbid param (1195577430501137)
17 | ```
18 | $ https://www.facebook.com/teamcoco/photos/a.1195578577167689.1073741827.108905269168364/1195577430501137
19 | ```
20 | Visit:
21 | * https://www.facebook.com/Facebook360 - To see the latest trending 360 Videos on Facebook
22 | * https://360video.fb.com - To learn about creating 360 Videos for Facebook
23 |
24 | # Requirements
25 | Requires Android OS version KitKat (4.4) or higher.
26 | To build you'll need Gradle and the Android SDK with build tools 23.0.3 or above.
27 |
28 | # Setup
29 | ```
30 | $ git clone git@github.com:fbsamples/VRDeepLinkSDK.git
31 | $ cd VRDeepLinkSDK/VRDeeplinkSample
32 | $ gradle installDebug
33 | $ adb shell am start -n com.facebook.vrdeeplinksdk.sample/.VRDeeplinkSampleActivity
34 | ```
35 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/app/src/main/java/com/facebook/vrdeeplinksdk/sample/VRDeeplinkSampleActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
3 |
4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
5 | * copy, modify, and distribute this software in source code or binary form for use
6 | * in connection with the web services and APIs provided by Facebook.
7 |
8 | * As with any software that integrates with the Facebook platform, your use of
9 | * this software is subject to the Facebook Developer Principles and Policies
10 | * [http://developers.facebook.com/policy/]. This copyright notice shall be
11 | * included in all copies or substantial portions of the software.
12 |
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 | */
20 |
21 | package com.facebook.vrdeeplinksdk.sample;
22 |
23 | import android.content.Intent;
24 | import android.support.v7.app.AppCompatActivity;
25 | import android.os.Bundle;
26 | import android.view.View;
27 | import android.widget.Button;
28 | import com.facebook.vrdeeplinksdk.VRDeepLinkHelper;
29 |
30 | public class VRDeeplinkSampleActivity extends AppCompatActivity {
31 |
32 | private static final String VIDEO_FBID = "1329049410442559";
33 | private static final String PHOTO_FBID = "1084268434960161";
34 | private final View.OnClickListener mClickListener =
35 | new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | String fbid = VIDEO_FBID;
39 | VRDeepLinkHelper.MediaType mediaType = VRDeepLinkHelper.MediaType.VIDEO;
40 | if (v == mPhotoButton) {
41 | fbid = PHOTO_FBID;
42 | mediaType = VRDeepLinkHelper.MediaType.PHOTO;
43 | }
44 | Intent intent = VRDeepLinkHelper.createDeepLinkIntent(
45 | VRDeeplinkSampleActivity.this,
46 | new VRDeepLinkHelper.VRDeepLinkParam(
47 | fbid,
48 | mediaType));
49 | startActivity(intent);
50 | }
51 | };
52 |
53 | private Button mVideoButton;
54 | private Button mPhotoButton;
55 |
56 | @Override
57 | protected void onCreate(Bundle savedInstanceState) {
58 | super.onCreate(savedInstanceState);
59 | setContentView(R.layout.activity_vrdeeplink_sample);
60 | mVideoButton = (Button) findViewById(R.id.video_button);
61 | mPhotoButton = (Button) findViewById(R.id.photo_button);
62 | mVideoButton.setOnClickListener(mClickListener);
63 | mPhotoButton.setOnClickListener(mClickListener);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/VRDeeplinkSample/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/VRDeepLinkSDK/src/com/facebook/vrdeeplinksdk/VRDeepLinkHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
3 |
4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
5 | * copy, modify, and distribute this software in source code or binary form for use
6 | * in connection with the web services and APIs provided by Facebook.
7 |
8 | * As with any software that integrates with the Facebook platform, your use of
9 | * this software is subject to the Facebook Developer Principles and Policies
10 | * [http://developers.facebook.com/policy/]. This copyright notice shall be
11 | * included in all copies or substantial portions of the software.
12 |
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 | */
20 |
21 | package com.facebook.vrdeeplinksdk;
22 |
23 | import android.content.Context;
24 | import android.content.Intent;
25 | import android.content.pm.PackageManager;
26 | import android.net.Uri;
27 | import android.support.annotation.VisibleForTesting;
28 |
29 | public class VRDeepLinkHelper {
30 | private static final String OCULUS_CINEMA_PACKAGE_NAME = "com.oculus.cinema";
31 | private static final String OCULUS_PHOTO_PACKAGE_NAME = "com.oculus.oculus360photos";
32 |
33 | private static final String URI_SCHEME_OCULUS = "oculus";
34 | private static final String URI_MEDIA_TYPE_VIDEO = "video";
35 | private static final String URI_MEDIA_TYPE_PHOTO = "photo";
36 | private static final String URI_MEDIA_SOURCE_FB = "fb";
37 |
38 | private static final String URI_SCHEME_HTTPS = "https";
39 | private static final String URI_FB_AUTHORITY = "m.facebook.com";
40 |
41 | public static enum MediaType {
42 | VIDEO,
43 | PHOTO
44 | }
45 |
46 | public static class VRDeepLinkParam {
47 | public final String mediaFbId;
48 | public final MediaType mediaType;
49 |
50 | public VRDeepLinkParam(
51 | String videoFbId,
52 | MediaType mediaType) {
53 | this.mediaFbId = videoFbId;
54 | this.mediaType = mediaType;
55 | }
56 | }
57 |
58 | /**
59 | * Helper function to create an intent to launch 360 photos/videos in Oculus Video/360Photo app.
60 | * If such app doesn't exist, we'll fallback to FB4A or m-site depending on application availability.
61 | *
62 | * @param context an android context
63 | * @param param A VRDeepLinkParam object that contains the fbid of the deeplink media and its type
64 | * @return an Intent object to launch the deeplinked content.
65 | */
66 | public static Intent createDeepLinkIntent(Context context, VRDeepLinkParam param) {
67 | if (param == null ||
68 | isStringNullOrEmpty(param.mediaFbId)) {
69 | return null;
70 | }
71 |
72 | if (IsVideoDeepLink(param)) {
73 | return createDeepLinkIntentForVideoContent(context, param);
74 | }
75 | return createDeepLinkIntentForPhotoContent(context, param);
76 | }
77 |
78 | private static Intent createDeepLinkIntentForVideoContent(Context context, VRDeepLinkParam param) {
79 | if (hasAppInstalled(context, OCULUS_CINEMA_PACKAGE_NAME)) {
80 | return createIntentForOculusApp(param);
81 | }
82 | return createIntentForFacebookApp(param);
83 | }
84 |
85 | private static Intent createDeepLinkIntentForPhotoContent(Context context, VRDeepLinkParam param) {
86 | if (hasAppInstalled(context, OCULUS_PHOTO_PACKAGE_NAME)) {
87 | return createIntentForOculusApp(param);
88 | }
89 | return createIntentForFacebookApp(param);
90 | }
91 |
92 | /**
93 | * Checks whether any of the support oculus app is installed.
94 | *
95 | * @param context an android context
96 | * @param packageName an android app package name
97 | * @return whether an app with the given package name is installed
98 | */
99 | @VisibleForTesting
100 | static boolean hasAppInstalled(Context context, String packageName) {
101 | try {
102 | context.getPackageManager().getPackageInfo(packageName, 0);
103 | return true;
104 | } catch (PackageManager.NameNotFoundException e) {
105 | return false;
106 | }
107 | }
108 |
109 | @VisibleForTesting
110 | static boolean IsVideoDeepLink(VRDeepLinkParam param) {
111 | return param != null && MediaType.VIDEO.equals(param.mediaType);
112 | }
113 |
114 | @VisibleForTesting
115 | static Intent createIntentForOculusApp(VRDeepLinkParam param) {
116 | Intent intent = new Intent();
117 | intent.setAction(Intent.ACTION_VIEW);
118 | intent.addCategory(Intent.CATEGORY_DEFAULT);
119 | String packageName = OCULUS_CINEMA_PACKAGE_NAME;
120 | String mediaTypePath = URI_MEDIA_TYPE_VIDEO;
121 | if (MediaType.PHOTO.equals(param.mediaType)) {
122 | packageName = OCULUS_PHOTO_PACKAGE_NAME;
123 | mediaTypePath = URI_MEDIA_TYPE_PHOTO;
124 | }
125 | intent.setPackage(packageName);
126 | Uri.Builder builder = new Uri.Builder();
127 | builder.scheme(URI_SCHEME_OCULUS)
128 | .authority(mediaTypePath)
129 | .appendPath(URI_MEDIA_SOURCE_FB)
130 | .appendPath(param.mediaFbId);
131 | intent.setData(builder.build());
132 | return intent;
133 | }
134 |
135 | @VisibleForTesting
136 | static Intent createIntentForFacebookApp(VRDeepLinkParam param) {
137 | Intent intent = new Intent();
138 | intent.setAction(Intent.ACTION_VIEW);
139 | intent.addCategory(Intent.CATEGORY_DEFAULT);
140 | intent.addCategory(Intent.CATEGORY_BROWSABLE);
141 | Uri.Builder builder = new Uri.Builder();
142 | builder.scheme(URI_SCHEME_HTTPS)
143 | .authority(URI_FB_AUTHORITY)
144 | .appendPath(param.mediaFbId);
145 | intent.setData(builder.build());
146 | return intent;
147 | }
148 |
149 | private static boolean isStringNullOrEmpty(String input) {
150 | return input == null || input == "";
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/VRDeepLinkSDK/test/com/facebook/vrdeeplinksdk/VRDeepLinkHelperTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
3 |
4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
5 | * copy, modify, and distribute this software in source code or binary form for use
6 | * in connection with the web services and APIs provided by Facebook.
7 |
8 | * As with any software that integrates with the Facebook platform, your use of
9 | * this software is subject to the Facebook Developer Principles and Policies
10 | * [http://developers.facebook.com/policy/]. This copyright notice shall be
11 | * included in all copies or substantial portions of the software.
12 |
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 | */
20 |
21 | package com.facebook.vrdeeplinksdk;
22 |
23 | import android.content.Context;
24 | import android.content.Intent;
25 | import android.content.pm.PackageManager;
26 | import org.junit.Assert;
27 | import org.junit.Before;
28 | import org.junit.Test;
29 | import org.junit.runner.RunWith;
30 | import org.robolectric.RobolectricGradleTestRunner;
31 | import org.robolectric.annotation.Config;
32 |
33 | import static com.facebook.vrdeeplinksdk.VRDeepLinkHelper.VRDeepLinkParam;
34 | import static org.mockito.Mockito.mock;
35 | import static org.mockito.Mockito.when;
36 |
37 | /**
38 | * Test class for the VRDeepLinkHelper, because why not.
39 | */
40 | @RunWith(RobolectricGradleTestRunner.class)
41 | @Config(constants = BuildConfig.class)
42 | public class VRDeepLinkHelperTest {
43 |
44 | private static final String RANDOM_FBID = "ImmaFBID";
45 |
46 | private Context mMockContext;
47 | private PackageManager mPackageManager;
48 |
49 | @Before
50 | public void setUp() {
51 | mMockContext = mock(Context.class);
52 | mPackageManager = mock(PackageManager.class);
53 | when(mMockContext.getPackageManager())
54 | .thenReturn(mPackageManager);
55 | }
56 |
57 | @Test
58 | public void testEmptyParam() {
59 | Assert.assertEquals(
60 | VRDeepLinkHelper.createDeepLinkIntent(mMockContext, null),
61 | null);
62 | }
63 |
64 | @Test
65 | public void testNullFBIDParam() {
66 | VRDeepLinkParam param = new VRDeepLinkParam(
67 | null,
68 | VRDeepLinkHelper.MediaType.VIDEO);
69 | Assert.assertEquals(
70 | VRDeepLinkHelper.createDeepLinkIntent(mMockContext, param),
71 | null);
72 | }
73 |
74 | @Test
75 | public void testEmptyFBIDParam() {
76 | VRDeepLinkParam param = new VRDeepLinkParam(
77 | "",
78 | VRDeepLinkHelper.MediaType.VIDEO);
79 | Assert.assertEquals(
80 | VRDeepLinkHelper.createDeepLinkIntent(mMockContext, param),
81 | null);
82 | }
83 |
84 | @Test
85 | public void testVideoIntentWithOculusVideoInstalled() {
86 | try {
87 | when(mPackageManager.getPackageInfo("com.oculus.cinema", 0))
88 | .thenReturn(null);
89 | } catch (PackageManager.NameNotFoundException e) {
90 | }
91 | VRDeepLinkParam param = new VRDeepLinkParam(
92 | RANDOM_FBID,
93 | VRDeepLinkHelper.MediaType.VIDEO);
94 | Intent intent = VRDeepLinkHelper.createDeepLinkIntent(mMockContext, param);
95 | Assert.assertNotNull(intent);
96 | Assert.assertEquals(
97 | intent.getData().toString(),
98 | "oculus://video/fb/ImmaFBID");
99 | }
100 |
101 | @Test
102 | public void testPhotoIntentWithOculus360PhotoInstalled() {
103 | try {
104 | when(mPackageManager.getPackageInfo("com.oculus.oculus360photos", 0))
105 | .thenReturn(null);
106 | } catch (PackageManager.NameNotFoundException e) {
107 | }
108 | VRDeepLinkParam param = new VRDeepLinkParam(
109 | RANDOM_FBID,
110 | VRDeepLinkHelper.MediaType.PHOTO);
111 | Intent intent = VRDeepLinkHelper.createDeepLinkIntent(mMockContext, param);
112 | Assert.assertNotNull(intent);
113 | Assert.assertEquals(
114 | intent.getData().toString(),
115 | "oculus://photo/fb/ImmaFBID");
116 | }
117 |
118 | @Test
119 | public void testVideoIntentWithNoSupportedAppInstalled() {
120 | try {
121 | when(mPackageManager.getPackageInfo("com.oculus.cinema", 0))
122 | .thenThrow(new PackageManager.NameNotFoundException());
123 | } catch (PackageManager.NameNotFoundException e) {
124 | }
125 | VRDeepLinkParam param = new VRDeepLinkParam(
126 | RANDOM_FBID,
127 | VRDeepLinkHelper.MediaType.VIDEO);
128 | Intent intent = VRDeepLinkHelper.createDeepLinkIntent(mMockContext, param);
129 | Assert.assertNotNull(intent);
130 | Assert.assertEquals(
131 | intent.getData().toString(),
132 | "https://m.facebook.com/ImmaFBID");
133 | }
134 |
135 | @Test
136 | public void testPhotoIntentWithNoSupportedAppInstalled() {
137 | try {
138 | when(mPackageManager.getPackageInfo("com.oculus.oculus360photos", 0))
139 | .thenThrow(new PackageManager.NameNotFoundException());
140 | } catch (PackageManager.NameNotFoundException e) {
141 | }
142 | VRDeepLinkParam param = new VRDeepLinkParam(
143 | RANDOM_FBID,
144 | VRDeepLinkHelper.MediaType.PHOTO);
145 | Intent intent = VRDeepLinkHelper.createDeepLinkIntent(mMockContext, param);
146 | Assert.assertNotNull(intent);
147 | Assert.assertEquals(
148 | intent.getData().toString(),
149 | "https://m.facebook.com/ImmaFBID");
150 | }
151 |
152 | @Test
153 | public void testHasAppInstalledFalse() {
154 | String mockPackageName = "haha.i.am.an.android.package";
155 | try {
156 | when(mPackageManager.getPackageInfo(mockPackageName, 0))
157 | .thenThrow(new PackageManager.NameNotFoundException());
158 | } catch (PackageManager.NameNotFoundException e) {
159 | }
160 | Assert.assertEquals(
161 | VRDeepLinkHelper.hasAppInstalled(mMockContext, mockPackageName),
162 | false);
163 | }
164 |
165 | @Test
166 | public void testHasAppInstalled() {
167 | String mockPackageName = "haha.i.am.an.android.package";
168 | try {
169 | when(mPackageManager.getPackageInfo(mockPackageName, 0))
170 | .thenReturn(null);
171 | } catch (PackageManager.NameNotFoundException e) {
172 | }
173 | Assert.assertEquals(
174 | VRDeepLinkHelper.hasAppInstalled(mMockContext, mockPackageName),
175 | true);
176 | }
177 |
178 | @Test
179 | public void testIsVideoDeepLink() {
180 | VRDeepLinkParam param = null;
181 | Assert.assertEquals(
182 | VRDeepLinkHelper.IsVideoDeepLink(param),
183 | false);
184 |
185 | param = new VRDeepLinkParam(
186 | RANDOM_FBID,
187 | VRDeepLinkHelper.MediaType.VIDEO);
188 | Assert.assertEquals(
189 | VRDeepLinkHelper.IsVideoDeepLink(param),
190 | true);
191 |
192 | param = new VRDeepLinkParam(
193 | RANDOM_FBID,
194 | VRDeepLinkHelper.MediaType.PHOTO);
195 | Assert.assertEquals(
196 | VRDeepLinkHelper.IsVideoDeepLink(param),
197 | false);
198 | }
199 | }
200 |
--------------------------------------------------------------------------------