├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── VRDeepLinkSDK ├── AndroidManifest.xml ├── BUCK ├── build.gradle ├── res │ └── .README.txt ├── src │ └── com │ │ └── facebook │ │ └── vrdeeplinksdk │ │ └── VRDeepLinkHelper.java └── test │ └── com │ └── facebook │ └── vrdeeplinksdk │ └── VRDeepLinkHelperTest.java └── VRDeeplinkSample ├── .gitignore ├── app ├── .gitignore ├── build.gradle ├── libs │ └── VRDeepLinkSDK-release.aar ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── facebook │ │ └── vrdeeplinksdk │ │ └── sample │ │ └── VRDeeplinkSampleActivity.java │ └── res │ ├── layout │ └── activity_vrdeeplink_sample.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 │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /VRDeepLinkSDK/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /VRDeepLinkSDK/BUCK: -------------------------------------------------------------------------------- 1 | android_library( 2 | name = 'vrdeeplinksdk', 3 | srcs = glob(['src/**/*.java']), 4 | deps = [ 5 | ], 6 | visibility = ['PUBLIC'] 7 | ) 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /VRDeeplinkSample/app/libs/VRDeepLinkSDK-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbsamples/VRDeepLinkSDK/622b6386879c93d41962e224de3cba1792d5e5a4/VRDeeplinkSample/app/libs/VRDeepLinkSDK-release.aar -------------------------------------------------------------------------------- /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/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/app/src/main/res/layout/activity_vrdeeplink_sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 |