From 0a3fdd912b07f2028d933e315448be56e0db90bc Mon Sep 17 00:00:00 2001 From: Baris Sencan Date: Fri, 30 Oct 2015 17:43:18 -0700 Subject: [PATCH] [Android] Initial commit --- .gitignore | 2 + android/build.gradle | 20 ++++++++++ android/src/main/AndroidManifest.xml | 3 ++ .../brentvatne/react/ReactVideoPackage.java | 36 ++++++++++++++++++ .../react/ReactVideoViewManager.java | 37 +++++++++++++++++++ android/src/main/res/values/styles.xml | 8 ++++ 6 files changed, 106 insertions(+) create mode 100644 android/build.gradle create mode 100644 android/src/main/AndroidManifest.xml create mode 100644 android/src/main/java/com/brentvatne/react/ReactVideoPackage.java create mode 100644 android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java create mode 100644 android/src/main/res/values/styles.xml diff --git a/.gitignore b/.gitignore index eb36a796..b7d7223d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ Examples/VideoPlayer/VideoPlayer.xcodeproj/project.xcworkspace/**/* Examples/VideoPlayer/VideoPlayer.xcodeproj/xcuserdata/**/* npm-debug.log .DS_Store +build/ +*.iml diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 00000000..45a3bd42 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.1" + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a", "x86" + } + } +} + +dependencies { + compile 'com.facebook.react:react-native:0.13.+' +} diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..646df099 --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoPackage.java b/android/src/main/java/com/brentvatne/react/ReactVideoPackage.java new file mode 100644 index 00000000..4bc2bf37 --- /dev/null +++ b/android/src/main/java/com/brentvatne/react/ReactVideoPackage.java @@ -0,0 +1,36 @@ +package com.brentvatne.react; + +import android.app.Activity; +import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.JavaScriptModule; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class ReactVideoPackage implements ReactPackage { + + private Activity mActivity = null; + + public ReactVideoPackage(Activity activity) { + mActivity = activity; + } + + @Override + public List createNativeModules(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } + + @Override + public List> createJSModules() { + return Collections.emptyList(); + } + + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Arrays.asList(new ReactVideoViewManager(mActivity)); + } +} diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java b/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java new file mode 100644 index 00000000..f1bc48bc --- /dev/null +++ b/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java @@ -0,0 +1,37 @@ +package com.brentvatne.react; + +import android.app.Activity; +import android.net.Uri; +import android.support.annotation.Nullable; +import android.widget.VideoView; +import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.uimanager.ReactProp; +import com.facebook.react.uimanager.SimpleViewManager; +import com.facebook.react.uimanager.ThemedReactContext; + +public class ReactVideoViewManager extends SimpleViewManager { + + public static final String REACT_CLASS = "RCTVideo"; + private static final String PROP_SRC = "src"; + + private Activity mActivity = null; + + public ReactVideoViewManager(Activity activity) { + mActivity = activity; + } + + @Override + public String getName() { + return REACT_CLASS; + } + + @Override + protected VideoView createViewInstance(ThemedReactContext themedReactContext) { + return new VideoView(themedReactContext); + } + + @ReactProp(name = PROP_SRC) + public void setSrc(VideoView videoView, @Nullable ReadableMap src) { + videoView.setVideoURI(Uri.parse(src.getString("uri"))); + } +} diff --git a/android/src/main/res/values/styles.xml b/android/src/main/res/values/styles.xml new file mode 100644 index 00000000..319eb0ca --- /dev/null +++ b/android/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + + +