diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..65365be --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] + +indent_style = space +indent_size = 2 + +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..030ef14 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +*.pbxproj -text +# specific for windows script files +*.bat text eol=crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1d57418..fcce9a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,21 @@ +# OSX +.DS_Store + +# XDE +.expo/ + +# VSCode +.vscode/ +jsconfig.json +.vs + # Xcode !**/*.xcodeproj !**/*.pbxproj !**/*.xcworkspacedata !**/*.xcsettings !**/*.xcscheme +build/ *.pbxuser !default.pbxuser *.mode1v3 @@ -21,6 +33,28 @@ DerivedData *.xcuserstate project.xcworkspace +# Android Studio/IJ +build/ +.classpath +.cxx +.gradle +.idea +.project +.settings +local.properties +android.iml +*.iml +*.hprof + +# Android memory profiler files +*.hprof + +# Test generated files +/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js +*.js.meta +/coverage +/third-party + # Gradle /build/ /packages/react-native-gradle-plugin/build/ @@ -37,49 +71,27 @@ project.xcworkspace /template/android/app/build/ /template/android/build/ -# Buck -.buckd -buck-out -/.lsp.buckd -/.lsp-buck-out -/ReactAndroid/src/main/jni/prebuilt/lib/ -/ReactAndroid/src/main/gen - -# Android Studio -.project -.settings -.classpath - -# Watchman -.watchmanconfig - -# Android -.idea -.gradle -local.properties -*.iml +# iOS / CocoaPods +/example/ios/Pods/ +/template/ios/build/ +/template/ios/Pods/ +/template/ios/Podfile.lock +/packages/rn-tester/Gemfile.lock +# Ruby Gems (Bundler) +/vendor +/template/vendor -# Node -node_modules +# node.js +node_modules/ +npm-debug.log +yarn-debug.log +yarn-error.log *.log .nvm /bots/node_modules/ package-lock.json -# OS X -.DS_Store - -# Hermes -/sdks/hermes - -# Test generated files -/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js -*.js.meta - -/coverage -/third-party - # Root dir shouldn't have Xcode project /*.xcodeproj @@ -95,17 +107,6 @@ package-lock.json /React/FBReactNativeSpec/**/*.xcodeproj /packages/react-native-codegen/**/*.xcodeproj -# Ruby Gems (Bundler) -/vendor -/template/vendor - -# iOS / CocoaPods -/example/ios/Pods/ -/template/ios/build/ -/template/ios/Pods/ -/template/ios/Podfile.lock -/packages/rn-tester/Gemfile.lock - # Ignore RNTester specific Pods, but keep the __offline_mirrors__ here. /packages/rn-tester/Pods/* !/packages/rn-tester/Pods/__offline_mirrors__ @@ -116,15 +117,21 @@ package-lock.json /ReactCommon/react/renderer/components/rncore/ /packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec* -# Visual studio -.vscode -.vs - -# Android memory profiler files -*.hprof +# BUCK +.buckd +buck-out/ +\.buckd/ +android/app/libs +android/keystores/debug.keystore +/.lsp.buckd +/.lsp-buck-out +/ReactAndroid/src/main/jni/prebuilt/lib/ +/ReactAndroid/src/main/gen +*.keystore +!debug.keystore -#expo -.expo/ +# Expo +.expo/* dist/ npm-debug.* *.jks @@ -135,64 +142,5 @@ npm-debug.* *.orig.* web-build/ - -# @generated expo-cli sync-e7dcf75f4e856f7b6f3239b3f3a7dd614ee755a8 -# The following patterns were generated by expo-cli - -# OSX -# -.DS_Store - -# Xcode -# -build/ -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata -*.xccheckout -*.moved-aside -DerivedData -*.hmap -*.ipa -*.xcuserstate -project.xcworkspace - -# Android/IntelliJ -# -build/ -.idea -.gradle -local.properties -*.iml -*.hprof - -# node.js -# -node_modules/ -npm-debug.log -yarn-error.log - -# BUCK -buck-out/ -\.buckd/ -*.keystore -!debug.keystore - -# Bundle artifacts -*.jsbundle - -# CocoaPods -/ios/Pods/ - -# Expo -.expo/ -web-build/ -dist/ - -# @end expo-cli \ No newline at end of file +# generated by bob +lib/ \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index 36af219..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx lint-staged diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1 @@ +{} diff --git a/.watchmanconfig b/.watchmanconfig new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.watchmanconfig @@ -0,0 +1 @@ +{} diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 0000000..fedc0f1 --- /dev/null +++ b/.yarnrc @@ -0,0 +1,3 @@ +# Override Yarn command so we can automatically setup the repo on running `yarn` + +yarn-path "scripts/bootstrap.js" diff --git a/App.js b/App.js index 4067280..5ff778a 100644 --- a/App.js +++ b/App.js @@ -1,16 +1,22 @@ -import React from 'react' -import { NavigationContainer } from '@react-navigation/native' -import { createNativeStackNavigator } from '@react-navigation/native-stack' -import ActionBarImage from './components/ActionBarImage' -import Article from './pages/Article' -import { LinearGradient } from 'expo-linear-gradient' -import ActionBarImageWhite from './components/ActionBarImageWhite' -import styleApp from './styles/styleApp' -import HomeScreen from './pages/Homescreen' -import InFeed from './pages/InFeed' -import { HOMESCREEN, DEMOSCREEN, TEADSPINK, TEADSBLUE, NATIVESCREEN } from './constants' +import React from 'react'; +import { NavigationContainer } from '@react-navigation/native'; +import { createNativeStackNavigator } from '@react-navigation/native-stack'; +import ActionBarImage from './components/ActionBarImage'; +import Article from './pages/Article'; +import { LinearGradient } from 'expo-linear-gradient'; +import ActionBarImageWhite from './components/ActionBarImageWhite'; +import styleApp from './styles/styleApp'; +import HomeScreen from './pages/Homescreen'; +import InFeed from './pages/InFeed'; +import { + HOMESCREEN, + DEMOSCREEN, + TEADSPINK, + TEADSBLUE, + NATIVESCREEN, +} from './constants'; -const Stack = createNativeStackNavigator() +const Stack = createNativeStackNavigator(); export default function App() { return ( @@ -20,7 +26,7 @@ export default function App() { name={HOMESCREEN} component={HomeScreen} options={{ - headerTitle: () => + headerTitle: () => , }} /> - ) + ), }} /> - ) + ), }} /> - ) + ); } diff --git a/README.md b/README.md index e01ac8d..add70ca 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,76 @@ -# Teads SDK for React Native +

+ + Teads logo + +

-This is a sample with the basic implementation of Teads ads within a React Native application. Teads does not provide an offical React Native component. +--- -[Teads SDK Documentation for Android & iOS](https://support.teads.tv/support/solutions/articles/36000165909) +# 🚀 TeadsSDK on React Native with react-native-teads-sdk-module -# Setup +Teads allows you to integrate a single SDK into your app, and serve premium branded "outstream" video ads from Teads SSP ad server. +This sample app shows you how to use our official TeadsSDK with React Native. -Install Expo, then +# 🔜 Installation our npm package on your app +not available yet + +```sh +npm install react-native-teads-sdk-module ``` -npm install + +# ⚙️ Usage of react-native-teads-sdk-module + +```js +import { TeadsModule } from 'react-native-teads-sdk-module'; + +// ... + +const result = await TeadsModule(); ``` -# Run +## 🚲 Launch the example App +```sh +yarn +yarn example android ``` -npm start + +OR + +```sh +yarn +yarn example ios ``` -# Run Android +with IDE + +directly from Xcode with -open your favorite android emulator -click A key to open your app in Expo Go -(this will run your app without your native modules, so without the sdk) +```sh +cd YourRepository/example/ios +rm -rf Pods/ Podfile.lock TeadsSdkModuleExample.xcworkspace/ +pod install +open TeadsSdkModuleExample.xcworkspace/ +``` -# Run iOS +then build and run -open an ios simulator -click I key to open your app in Expo Go -(this will run your app without your native modules, so without the sdk) +OR -# Run Android with the natives modules +directly from Android studio -``` -npm start -``` +open project and run it +with metro launched on the side -build the android app, and lauch it via Android Studio +## 🎓 Contributing -# Run iOS with the natives modules +See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. -``` -npm start -``` +## ✅ License -build the iOS app, and lauch with : +MIT -``` -npm run ios -``` +--- + +Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob) diff --git a/android/app/BUCK b/android/app/BUCK deleted file mode 100644 index 2755600..0000000 --- a/android/app/BUCK +++ /dev/null @@ -1,55 +0,0 @@ -# To learn about Buck see [Docs](https://buckbuild.com/). -# To run your application with Buck: -# - install Buck -# - `npm start` - to start the packager -# - `cd android` -# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` -# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck -# - `buck install -r android/app` - compile, install and run application -# - -load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") - -lib_deps = [] - -create_aar_targets(glob(["libs/*.aar"])) - -create_jar_targets(glob(["libs/*.jar"])) - -android_library( - name = "all-libs", - exported_deps = lib_deps, -) - -android_library( - name = "app-code", - srcs = glob([ - "src/main/java/**/*.java", - ]), - deps = [ - ":all-libs", - ":build_config", - ":res", - ], -) - -android_build_config( - name = "build_config", - package = "com.numa.maurin.Project", -) - -android_resource( - name = "res", - package = "com.numa.maurin.Project", - res = "src/main/res", -) - -android_binary( - name = "app", - keystore = "//android/keystores:debug", - manifest = "src/main/AndroidManifest.xml", - package_type = "debug", - deps = [ - ":app-code", - ], -) diff --git a/android/app/build_defs.bzl b/android/app/build_defs.bzl deleted file mode 100644 index fff270f..0000000 --- a/android/app/build_defs.bzl +++ /dev/null @@ -1,19 +0,0 @@ -"""Helper definitions to glob .aar and .jar targets""" - -def create_aar_targets(aarfiles): - for aarfile in aarfiles: - name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] - lib_deps.append(":" + name) - android_prebuilt_aar( - name = name, - aar = aarfile, - ) - -def create_jar_targets(jarfiles): - for jarfile in jarfiles: - name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] - lib_deps.append(":" + name) - prebuilt_jar( - name = name, - binary_jar = jarfile, - ) diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml deleted file mode 100644 index 99e38fc..0000000 --- a/android/app/src/debug/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index 9b91813..0000000 --- a/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/app/src/main/java/com/numa/maurin/Project/MainActivity.java b/android/app/src/main/java/com/numa/maurin/Project/MainActivity.java deleted file mode 100644 index 3831d52..0000000 --- a/android/app/src/main/java/com/numa/maurin/Project/MainActivity.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.numa.maurin.Project; - -import android.os.Build; -import android.os.Bundle; - -import com.facebook.react.ReactActivity; -import com.facebook.react.ReactActivityDelegate; -import com.facebook.react.ReactRootView; - -import expo.modules.ReactActivityDelegateWrapper; - -public class MainActivity extends ReactActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - // Set the theme to AppTheme BEFORE onCreate to support - // coloring the background, status bar, and navigation bar. - // This is required for expo-splash-screen. - setTheme(R.style.AppTheme); - super.onCreate(null); - } - - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ - @Override - protected String getMainComponentName() { - return "main"; - } - - @Override - protected ReactActivityDelegate createReactActivityDelegate() { - return new ReactActivityDelegateWrapper(this, - new ReactActivityDelegate(this, getMainComponentName()) - ); - } - - /** - * Align the back button behavior with Android S - * where moving root activities to background instead of finishing activities. - * @see onBackPressed - */ - @Override - public void invokeDefaultOnBackPressed() { - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) { - if (!moveTaskToBack(false)) { - // For non-root activities, use the default implementation to finish them. - super.invokeDefaultOnBackPressed(); - } - return; - } - - // Use the default back button implementation on Android S - // because it's doing more than {@link Activity#moveTaskToBack} in fact. - super.invokeDefaultOnBackPressed(); - } -} diff --git a/android/app/src/main/java/com/numa/maurin/Project/teadsInReadModule/InReadModule.java b/android/app/src/main/java/com/numa/maurin/Project/teadsInReadModule/InReadModule.java deleted file mode 100644 index 47b5b8f..0000000 --- a/android/app/src/main/java/com/numa/maurin/Project/teadsInReadModule/InReadModule.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.numa.maurin.Project.teadsInReadModule; - - - -import com.facebook.react.bridge.NativeModule; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContext; -import com.facebook.react.bridge.ReactContextBaseJavaModule; -import com.facebook.react.bridge.ReactMethod; -import java.util.Map; -import java.util.HashMap; -import android.util.Log; -import androidx.annotation.NonNull; - -public class InReadModule extends ReactContextBaseJavaModule { - InReadModule(ReactApplicationContext context) { - super(context); - } - - @NonNull - @Override - public String getName() { - return "InReadModule"; - } - - @ReactMethod - public void createInRead(String name, String location) { - Log.d("InReadModule", "print a InRead name: " + name - + " and location: " + location); - } -} \ No newline at end of file diff --git a/android/app/src/main/java/com/numa/maurin/Project/teadsInReadModule/MyAppPackage.java b/android/app/src/main/java/com/numa/maurin/Project/teadsInReadModule/MyAppPackage.java deleted file mode 100644 index bed10fd..0000000 --- a/android/app/src/main/java/com/numa/maurin/Project/teadsInReadModule/MyAppPackage.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.numa.maurin.Project.teadsInReadModule; - -import com.facebook.react.ReactPackage; -import com.facebook.react.bridge.NativeModule; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.uimanager.ViewManager; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class MyAppPackage implements ReactPackage { - - @Override - public List createViewManagers(ReactApplicationContext reactContext) { - return Collections.emptyList(); - } - - @Override - public List createNativeModules( - ReactApplicationContext reactContext) { - List modules = new ArrayList<>(); - - modules.add(new InReadModule(reactContext)); - - return modules; - } - -} \ No newline at end of file diff --git a/android/app/src/main/res/drawable-hdpi/splashscreen_image.png b/android/app/src/main/res/drawable-hdpi/splashscreen_image.png deleted file mode 100644 index c52c2c6..0000000 Binary files a/android/app/src/main/res/drawable-hdpi/splashscreen_image.png and /dev/null differ diff --git a/android/app/src/main/res/drawable-mdpi/splashscreen_image.png b/android/app/src/main/res/drawable-mdpi/splashscreen_image.png deleted file mode 100644 index c52c2c6..0000000 Binary files a/android/app/src/main/res/drawable-mdpi/splashscreen_image.png and /dev/null differ diff --git a/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png b/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png deleted file mode 100644 index c52c2c6..0000000 Binary files a/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png and /dev/null differ diff --git a/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png b/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png deleted file mode 100644 index c52c2c6..0000000 Binary files a/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png and /dev/null differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png b/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png deleted file mode 100644 index c52c2c6..0000000 Binary files a/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png and /dev/null differ diff --git a/android/app/src/main/res/drawable/splashscreen.xml b/android/app/src/main/res/drawable/splashscreen.xml deleted file mode 100644 index c8568e1..0000000 --- a/android/app/src/main/res/drawable/splashscreen.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index 3941bea..0000000 --- a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index 3941bea..0000000 --- a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index 7fae0cc..0000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png deleted file mode 100644 index 135d15e..0000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index afa0a4e..0000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 78aaf45..0000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png deleted file mode 100644 index 880334f..0000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index c4f6e10..0000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 7a0f085..0000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png deleted file mode 100644 index 6f951ef..0000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 6c2d40b..0000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 730e3fa..0000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png deleted file mode 100644 index 0cdce03..0000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index 3452615..0000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index b11a322..0000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png deleted file mode 100644 index eaa8cd1..0000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index b51fd15..0000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/values-night/colors.xml b/android/app/src/main/res/values-night/colors.xml deleted file mode 100644 index 3c05de5..0000000 --- a/android/app/src/main/res/values-night/colors.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml deleted file mode 100644 index bb2087f..0000000 --- a/android/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,6 +0,0 @@ - - #ffffff - #FFFFFF - #023c69 - #ffffff - \ No newline at end of file diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml deleted file mode 100644 index 230c685..0000000 --- a/android/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - Project - contain - false - \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml deleted file mode 100644 index b0cbdbe..0000000 --- a/android/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 1dae3d1..810a5b3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,40 +1,158 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { - ext { - buildToolsVersion = "29.0.3" - minSdkVersion = 21 - compileSdkVersion = 30 - targetSdkVersion = 30 - } - repositories { - google() - mavenCentral() - jcenter() - } - dependencies { - classpath('com.android.tools.build:gradle:4.0.2') + // Buildscript is evaluated before everything else so we can't use getExtOrDefault + def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['TeadsSdkModule_kotlinVersion'] + + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.0.0' + // noinspection DifferentKotlinGradleVersion + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +def isNewArchitectureEnabled() { + return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" +} + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +if (isNewArchitectureEnabled()) { + apply plugin: 'com.facebook.react' +} + +def getExtOrDefault(name) { + return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['TeadsSdkModule_' + name] +} + +def getExtOrIntegerDefault(name) { + return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['TeadsSdkModule_' + name]).toInteger() +} - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files +android { + compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') + + defaultConfig { + minSdkVersion getExtOrIntegerDefault('minSdkVersion') + targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') + buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() + } + buildTypes { + release { + minifyEnabled false } + } + + lintOptions { + disable 'GradleCompatible' + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } -allprojects { - repositories { - mavenLocal() +repositories { + mavenCentral() + google() + + def found = false + def defaultDir = null + def androidSourcesName = 'React Native sources' + + if (rootProject.ext.has('reactNativeAndroidRoot')) { + defaultDir = rootProject.ext.get('reactNativeAndroidRoot') + } else { + defaultDir = new File( + projectDir, + '/../../../node_modules/react-native/android' + ) + } + + if (defaultDir.exists()) { + maven { + url defaultDir.toString() + name androidSourcesName + } + + logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}") + found = true + } else { + def parentDir = rootProject.projectDir + + 1.upto(5, { + if (found) return true + parentDir = parentDir.parentFile + + def androidSourcesDir = new File( + parentDir, + 'node_modules/react-native' + ) + + def androidPrebuiltBinaryDir = new File( + parentDir, + 'node_modules/react-native/android' + ) + + if (androidPrebuiltBinaryDir.exists()) { maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../android")) + url androidPrebuiltBinaryDir.toString() + name androidSourcesName } + + logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}") + found = true + } else if (androidSourcesDir.exists()) { maven { - // Android JSC is installed from npm - url(new File(["node", "--print", "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), "../dist")) + url androidSourcesDir.toString() + name androidSourcesName } - google() - mavenCentral() - jcenter() - maven { url 'https://www.jitpack.io' } - } + logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}") + found = true + } + }) + } + + if (!found) { + throw new GradleException( + "${project.name}: unable to locate React Native android sources. " + + "Ensure you have you installed React Native as a dependency in your project and try again." + ) + } +} + +def kotlin_version = getExtOrDefault('kotlinVersion') + + + +dependencies { + // Teads inApp SDK + implementation("tv.teads.sdk.android:sdk:5.0.22@aar") { + transitive = true + } + // Required dependency + implementation 'com.google.android.gms:play-services-ads:20.2.0' // or higher + + // Mandatory for Huawei device compatibility + implementation 'com.huawei.hms:ads-identifier:3.4.28.313' + + //noinspection GradleDynamicVersion + implementation "com.facebook.react:react-native:+" + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" +// From node_modules +} + +if (isNewArchitectureEnabled()) { + react { + jsRootDir = file("../src/") + libraryName = "TeadsSdkModule" + codegenJavaPackageName = "com.reactnativeteadssdkmodule" + } } diff --git a/android/gradle.properties b/android/gradle.properties index 8eac5b6..43d6a8f 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,41 +1,6 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true - -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true - -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true - -# Version of flipper SDK to use with React Native -FLIPPER_VERSION=0.54.0 - -# The hosted JavaScript engine -# Supported values: expo.jsEngine = "hermes" | "jsc" -expo.jsEngine=jsc - -# Enable GIF support in React Native images (~200 B increase) -expo.gif.enabled=true -# Enable webp support in React Native images (~85 KB increase) -expo.webp.enabled=true -# Enable animated webp support (~3.4 MB increase) -# Disabled by default because iOS doesn't support animated webp -expo.webp.animated=false \ No newline at end of file +TeadsSdkModule_kotlinVersion=1.7.0 +TeadsSdkModule_minSdkVersion=19 +TeadsSdkModule_targetSdkVersion=28 +TeadsSdkModule_compileSdkVersion=31 +TeadsSdkModule_ndkversion=21.4.7075529 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index d8ff61a..da9702f 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu May 19 15:41:38 CEST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew index 1b6c787..4f906e0 100755 --- a/android/gradlew +++ b/android/gradlew @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env sh # -# Copyright © 2015-2021 the original authors. +# Copyright 2015 the original author or authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,101 +17,67 @@ # ############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# +## +## Gradle start up script for UN*X +## ############################################################################## # Attempt to set APP_HOME - # Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} +APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum +MAX_FD="maximum" warn () { echo "$*" -} >&2 +} die () { echo echo "$*" echo exit 1 -} >&2 +} # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -121,9 +87,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java + JAVACMD="$JAVA_HOME/jre/sh/java" else - JAVACMD=$JAVA_HOME/bin/java + JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -132,7 +98,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD=java + JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -140,95 +106,80 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi fi -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi # For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg + i=`expr $i + 1` done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat index ac1b06f..107acd3 100644 --- a/android/gradlew.bat +++ b/android/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ed44eae --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/ArrayUtil.kt b/android/src/main/java/com/reactnativeteadssdkmodule/ArrayUtil.kt new file mode 100644 index 0000000..f720826 --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/ArrayUtil.kt @@ -0,0 +1,65 @@ +package com.reactnativeteadssdkmodule + +import com.facebook.react.bridge.Arguments +import com.facebook.react.bridge.ReadableArray +import com.facebook.react.bridge.ReadableType +import com.facebook.react.bridge.WritableArray +import org.json.JSONArray +import org.json.JSONException +import org.json.JSONObject + +/* + ArrayUtil exposes a set of helper methods for working with + ReadableArray (by React Native), Object[], and JSONArray. + MIT License + Copyright (c) 2020 Marc Mendiola + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + The above copyright notice and this permission 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. + */ + + + +object ArrayUtil { + + fun toWritableArray(array: Array?): WritableArray { + val writableArray = Arguments.createArray() + for (i in array!!.indices) { + val value = array[i] + if (value == null) { + writableArray.pushNull() + } + if (value is Boolean) { + writableArray.pushBoolean((value as Boolean?)!!) + } + if (value is Double) { + writableArray.pushDouble((value as Double?)!!) + } + if (value is Int) { + writableArray.pushInt((value as Int?)!!) + } + if (value is String) { + writableArray.pushString(value as String?) + } + if (value is Map<*, *>) { + writableArray.pushMap(MapUtil.toWritableMap(value as MutableMap)) + } + if (value!!.javaClass.isArray) { + writableArray.pushArray(toWritableArray(value as Array?)) + } + } + return writableArray + } +} diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/MapUtil.kt b/android/src/main/java/com/reactnativeteadssdkmodule/MapUtil.kt new file mode 100644 index 0000000..67630a2 --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/MapUtil.kt @@ -0,0 +1,61 @@ +package com.reactnativeteadssdkmodule + +import com.facebook.react.bridge.* + +import com.reactnativeteadssdkmodule.ArrayUtil.toWritableArray +import org.json.JSONArray +import org.json.JSONException +import org.json.JSONObject +import java.util.HashMap + +/* + MapUtil exposes a set of helper methods for working with + ReadableMap (by React Native), Map, and JSONObject. + MIT License + Copyright (c) 2020 Marc Mendiola + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + The above copyright notice and this permission 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. + */ + + + +object MapUtil { + + fun toWritableMap(map: MutableMap): WritableMap { + val writableMap = Arguments.createMap() + val iterator: MutableIterator<*> = map.entries.iterator() + while (iterator.hasNext()) { + val (key, value) = iterator.next() as Map.Entry<*, *> + if (value == null) { + writableMap.putNull((key as String?)!!) + } else if (value is Boolean) { + writableMap.putBoolean((key as String?)!!, (value as Boolean?)!!) + } else if (value is Double) { + writableMap.putDouble((key as String?)!!, (value as Double?)!!) + } else if (value is Int) { + writableMap.putInt((key as String?)!!, (value as Int?)!!) + } else if (value is String) { + writableMap.putString((key as String?)!!, value as String?) + } else if (value is Map<*, *>) { + writableMap.putMap((key as String?)!!, toWritableMap(value as MutableMap)) + } else if (value.javaClass != null && value.javaClass.isArray) { + writableMap.putArray((key as String?)!!, toWritableArray(value as Array?)) + } + iterator.remove() + } + return writableMap + } +} diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNAd.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNAd.kt new file mode 100644 index 0000000..4f17579 --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNAd.kt @@ -0,0 +1,27 @@ +package com.reactnativeteadssdkmodule + +import com.facebook.react.bridge.* + + +class RNAd(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { + + + override fun getName(): String { + return "RNAd" + } + + //delegate + //auto on android + @ReactMethod + fun delegate(promise: Promise) { + promise.resolve(true) + } + + //playback + //auto on android + fun playback(promise: Promise) { + promise.resolve(true) + } + +} + diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNAdInstanceManager.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNAdInstanceManager.kt new file mode 100644 index 0000000..f0cd9d6 --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNAdInstanceManager.kt @@ -0,0 +1,44 @@ +package com.reactnativeteadssdkmodule + +import tv.teads.sdk.InReadAdPlacement +import tv.teads.sdk.renderer.InReadAdView + + +object RNAdInstanceManager { + class AdInstanceMap constructor(val inReadAdView: InReadAdView, val id: String) + class AdPlacementMap constructor(val inReadAdPlacement: InReadAdPlacement, val id: Int) + + private var placementList: MutableList = mutableListOf() + private var adViewInstancesMapList: MutableList = mutableListOf() + + //AD + fun new(instance: AdInstanceMap) { + adViewInstancesMapList.add(instance) + } + + @Throws() + fun instance(requestIdentifier: String): AdInstanceMap { + val instance = adViewInstancesMapList.firstOrNull { it.id == requestIdentifier } + if (instance != null) { + return instance + } else { + throw IllegalStateException("AdInstanceMap is null") + } + } + + //PLACEMENT + fun new(placement: AdPlacementMap) { + placementList.add(placement) + } + + @Throws() + fun instance(pid: Int): AdPlacementMap { + val placement = placementList.firstOrNull { it.id == pid } + if (placement != null) { + return placement + } else { + throw IllegalStateException("AdPlacementMap is null") + } + } + +} diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNAdPlacementSettings.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNAdPlacementSettings.kt new file mode 100644 index 0000000..bdc2dbb --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNAdPlacementSettings.kt @@ -0,0 +1,126 @@ +package com.reactnativeteadssdkmodule + +import com.facebook.react.bridge.* +import com.facebook.react.modules.systeminfo.ReactNativeVersion +import tv.teads.sdk.AdPlacementSettings +import tv.teads.sdk.utils.userConsent.TCFVersion + +class RNAdPlacementSettings(reactContext: ReactApplicationContext) : + ReactContextBaseJavaModule(reactContext) { + + private var placementSettingsBuilder = AdPlacementSettings.Builder() + + init { + placementSettingsBuilder.build() + placementSettingsBuilder.addPlacementExtra("plugin", "react_native") + placementSettingsBuilder.addPlacementExtra( + "pluginVersion", + ReactNativeVersion.VERSION.get("major") + .toString() + "." + ReactNativeVersion.VERSION.get("minor") + .toString() + "." + ReactNativeVersion.VERSION.get("patch").toString() + ) + } + + override fun getName(): String { + return "RNAdPlacementSettings" + } + + private fun convertSettingsAsWritableMap(settings: AdPlacementSettings.Builder): WritableMap { + //convert AdPlacementSettings into WritableMap for ReactNative compatibility + val map: MutableMap = settings.build().toMap() as MutableMap + return MapUtil.toWritableMap(map) + } + + @ReactMethod + fun disableCrashMonitoring(promise: Promise) { + try { + placementSettingsBuilder.disableCrashMonitoring() + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } catch (e: Throwable) { + promise.reject("error on native:", e) + } + } + + @ReactMethod + fun disableTeadsAudioSessionManagement(promise: Promise) { + //IOS only + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //enableDebug + @ReactMethod + fun enableDebug(promise: Promise) { + placementSettingsBuilder.enableDebug() + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //userConsent + @ReactMethod + fun userConsent( + subjectToGDPR: String, + consent: String, + tcfVersion: Int, + cmpSdkId: Int, + promise: Promise + ) { + placementSettingsBuilder.userConsent( + subjectToGDPR, + consent, + TCFVersion.fromInt(tcfVersion), + cmpSdkId + ) + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //setUsPrivacy + @ReactMethod + fun setUsPrivacy( + consent: String, + promise: Promise + ) { + placementSettingsBuilder.setUsPrivacy(consent) + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //disableBatteryMonitoring + @ReactMethod + fun disableBatteryMonitoring(promise: Promise) { + // iOS Only + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //addExtras + @ReactMethod + fun addExtras(key: String, value: String, promise: Promise) { + placementSettingsBuilder.addPlacementExtra(key, value) + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //enableLocation + @ReactMethod + fun enableLocation(promise: Promise) { + placementSettingsBuilder.enableLocation() + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //useLightEndScreen + @ReactMethod + fun useLightEndScreen(promise: Promise) { + placementSettingsBuilder.useLightEndScreen() + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //hideBrowserUrl + @ReactMethod + fun hideBrowserUrl(promise: Promise) { + placementSettingsBuilder.hideBrowserUrl() + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } + + //toolBarBackgroundColor + @ReactMethod + fun toolBarBackgroundColor(color: Int, promise: Promise) { + placementSettingsBuilder.toolBarBackgroundColor(color) + promise.resolve(convertSettingsAsWritableMap(placementSettingsBuilder)) + } +} diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNAdRatio.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNAdRatio.kt new file mode 100644 index 0000000..43d1d9e --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNAdRatio.kt @@ -0,0 +1,36 @@ +package com.reactnativeteadssdkmodule + +import com.facebook.react.bridge.Promise +import com.facebook.react.bridge.ReactApplicationContext +import com.facebook.react.bridge.ReactContextBaseJavaModule +import com.facebook.react.bridge.ReactMethod + +class RNAdRatio(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { + + override fun getName(): String { + return "RNAdRatio" + } + + //calculateHeight + @ReactMethod + fun calculateHeight(width: Double, requestIdentifier: String, promise: Promise) { + promise.resolve( + RNAdInstanceManager.instance(requestIdentifier).inReadAdView.inReadAd.adRatio.calculateHeight( + width.toInt() + ).toDouble() + ) + } + + //value + @ReactMethod + fun value(width: Double, requestIdentifier: String, promise: Promise) { + promise.resolve( + RNAdInstanceManager.instance(requestIdentifier).inReadAdView.inReadAd.adRatio.getAdSlotRatio( + width.toInt() + ).toDouble() + ) + } + +} + + diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNAdRequestSettings.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNAdRequestSettings.kt new file mode 100644 index 0000000..83eb5eb --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNAdRequestSettings.kt @@ -0,0 +1,44 @@ +package com.reactnativeteadssdkmodule + +import com.facebook.react.bridge.* +import tv.teads.sdk.AdPlacementSettings +import tv.teads.sdk.AdRequestSettings + + +class RNAdRequestSettings(reactContext: ReactApplicationContext) : + ReactContextBaseJavaModule(reactContext) { + private val adRequestSettings = AdRequestSettings.Builder() + + override fun getName(): String { + return "RNAdRequestSettings" + } + + private fun convertSettingsAsWritableMap(settings: AdRequestSettings.Builder): WritableMap { + //tool to convert AdRequestSettings into WritableMap for ReactNative compatibility + val map: MutableMap = settings.build().toMap() as MutableMap + return MapUtil.toWritableMap(map) + } + + //enableValidationMode + @ReactMethod + fun enableValidationMode(promise: Promise) { + adRequestSettings.enableValidationMode() + promise.resolve(convertSettingsAsWritableMap(adRequestSettings)) + } + + //pageUrl + @ReactMethod + fun pageUrl(urlString: String, promise: Promise) { + adRequestSettings.pageSlotUrl(urlString) + promise.resolve(convertSettingsAsWritableMap(adRequestSettings)) + } + + //addExtraSetting + @ReactMethod + fun addExtraSetting(key: String, value: String, promise: Promise) { + adRequestSettings.addExtra(key, value) + promise.resolve(convertSettingsAsWritableMap(adRequestSettings)) + } + + +} diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdPlacement.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdPlacement.kt new file mode 100644 index 0000000..94d49a0 --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdPlacement.kt @@ -0,0 +1,201 @@ +package com.reactnativeteadssdkmodule + +import android.os.Handler +import android.os.Looper +import android.util.Log +import com.facebook.react.bridge.* +import com.facebook.react.modules.core.DeviceEventManagerModule +import tv.teads.sdk.* +import tv.teads.sdk.renderer.InReadAdView +import java.util.* + + +class RNInReadAdPlacement(reactContext: ReactApplicationContext) : + ReactContextBaseJavaModule(reactContext) { + + override fun getName(): String { + return "RNInReadAdPlacement" + } + + private fun sendEvent(reactContext: ReactContext, eventName: String, params: WritableMap?) { + reactContext + .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java) + .emit(eventName, params) + } + + //requestAd + @ReactMethod + fun requestAd(pid: Int, settingsMap: ReadableMap, promise: Promise) { + val instanceIdentifier = UUID.randomUUID().toString() + RNAdInstanceManager.instance(pid).inReadAdPlacement.requestAd(AdRequestSettings.fromMap( + settingsMap.toHashMap().toMap() + ), + object : InReadAdListener { + override fun adOpportunityTrackerView(trackerView: AdOpportunityTrackerView) { + val params = Arguments.createMap() + params.putString("adId", instanceIdentifier) + sendEvent(reactApplicationContext, "adOpportunityTrackerView", params) + } + + override fun onAdReceived( + inReadAdView: InReadAdView, + adRatio: AdRatio + ) { + RNAdInstanceManager.new( + RNAdInstanceManager.AdInstanceMap( + inReadAdView, + instanceIdentifier + ) + ) + promise.resolve(instanceIdentifier) + val params = Arguments.createMap() + params.putString("adId", instanceIdentifier) + sendEvent(reactApplicationContext, "didReceiveAd", params) + Handler(Looper.getMainLooper()).post { + Log.d("from ad", "didReceiveAd") + + } + } + + override fun onAdClicked() { + val params = Arguments.createMap() + params.putString("adId",instanceIdentifier) + sendEvent(reactApplicationContext, "didRecordClick", params) + Handler(Looper.getMainLooper()).post { + Log.d("form ad", "didRecordClick") + } + } + + override fun onAdClosed() { + val params = Arguments.createMap() + params.putString("adId", instanceIdentifier) + sendEvent(reactApplicationContext, "didClose", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from ad", + "didClose" + ) + } + } + + override fun onAdError(code: Int, description: String) { + val params = Arguments.createMap() + params.putString("adId", instanceIdentifier) + params.putInt("code",code) + params.putString("description", description) + sendEvent(reactApplicationContext, "didCatchError", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from ad", + "didCatchError" + ) + Log.d("from error", description) + } + } + + override fun onAdImpression() { + val params = Arguments.createMap() + params.putString("adId", instanceIdentifier) + sendEvent(reactApplicationContext, "didRecordImpression", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from ad", + "didRecordImpression" + ) + } + } + + override fun onAdExpandedToFullscreen() { + val params = Arguments.createMap() + params.putString("adId", instanceIdentifier) + sendEvent(reactApplicationContext, "didExpandedToFullscreen", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from ad", + "didExpandedToFullscreen" + ) + } + } + + override fun onAdCollapsedFromFullscreen() { + val params = Arguments.createMap() + params.putString("adId",instanceIdentifier) + sendEvent(reactApplicationContext, "didCollapsedFromFullscreen", params) + Handler(Looper.getMainLooper()).post { + Log.d("from ad", "didCollapsedFromFullscreen") + } + } + + override fun onAdRatioUpdate(adRatio: AdRatio) { + val params = Arguments.createMap() + params.putString("adId",instanceIdentifier) + sendEvent(reactApplicationContext, "didUpdateRatio", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from ad", + "didUpdateRatio" + ) + + } + } + + override fun onFailToReceiveAd(failReason: String) { + val params = Arguments.createMap() + params.putString("adId",instanceIdentifier) + params.putString("failReason", failReason) + sendEvent(reactApplicationContext, "didFailToReceiveAd", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from Ad", + "didFailToReceiveAd" + ) + Log.d("from fail", failReason) + } + } + }, + object : VideoPlaybackListener { + override fun onVideoComplete() { + val params = Arguments.createMap() + params.putString("adId", instanceIdentifier) + sendEvent(reactApplicationContext, "didComplete", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from ad", + "didComplete" + ) + } + } + + override fun onVideoPause() { + val params = Arguments.createMap() + params.putString("adId",instanceIdentifier) + sendEvent(reactApplicationContext, "didPause", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from ad", + "didPause" + ) + } + } + + override fun onVideoPlay() { + val params = Arguments.createMap() + params.putString("adId",instanceIdentifier) + sendEvent(reactApplicationContext, "didPlay", params) + Handler(Looper.getMainLooper()).post { + Log.d( + "from ad", + "didPlay" + ) + + } + } + + }) + + } + + +} + + diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdView.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdView.kt new file mode 100644 index 0000000..8a5be37 --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdView.kt @@ -0,0 +1,10 @@ + +package com.reactnativeteadssdkmodule +import android.content.Context +import android.widget.FrameLayout +import tv.teads.sdk.renderer.InReadAdView + +class RNInReadAdView(context: Context) : FrameLayout(context) { + var inReadAdView: InReadAdView = InReadAdView(context) +} + diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdViewManager.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdViewManager.kt new file mode 100644 index 0000000..87081dc --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNInReadAdViewManager.kt @@ -0,0 +1,31 @@ +import com.facebook.react.uimanager.SimpleViewManager +import com.facebook.react.uimanager.ThemedReactContext +import com.facebook.react.uimanager.annotations.ReactProp +import com.reactnativeteadssdkmodule.RNAdInstanceManager +import com.reactnativeteadssdkmodule.RNInReadAdView + +class RNInReadAdViewManager : SimpleViewManager() { + companion object { + private const val REACT_CLASS = "RNInReadAdView" + } + + override fun getName(): String { + return REACT_CLASS + } + + @ReactProp(name = "adId") + fun setAdId(view: RNInReadAdView, adId: String?) { + if (adId != null) { + view.inReadAdView = RNAdInstanceManager.instance(adId).inReadAdView + view.addView(view.inReadAdView) + } + view.invalidate() + view.inReadAdView.invalidate() + } + + + override fun createViewInstance(reactContext: ThemedReactContext): RNInReadAdView { + return RNInReadAdView(reactContext.baseContext) + } + +} diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/RNTeads.kt b/android/src/main/java/com/reactnativeteadssdkmodule/RNTeads.kt new file mode 100644 index 0000000..0473afa --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/RNTeads.kt @@ -0,0 +1,31 @@ +package com.reactnativeteadssdkmodule + +import com.facebook.react.bridge.* +import tv.teads.sdk.AdPlacementSettings +import tv.teads.sdk.TeadsSDK + + +class RNTeads(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { + + override fun getName(): String { + return "RNTeads" + } + + //createInReadPlacement + @ReactMethod + fun createInReadPlacement(pid: Int, settingsMap: ReadableMap, promise: Promise) { + RNAdInstanceManager.new( + RNAdInstanceManager.AdPlacementMap( + TeadsSDK.createInReadPlacement( + reactApplicationContext, + pid, + AdPlacementSettings.fromMap(settingsMap.toHashMap().toMap()) + ), + pid + ) + ) + promise.resolve("ok") + } + +} + diff --git a/android/src/main/java/com/reactnativeteadssdkmodule/TeadsSdkModulePackage.kt b/android/src/main/java/com/reactnativeteadssdkmodule/TeadsSdkModulePackage.kt new file mode 100644 index 0000000..9128f2f --- /dev/null +++ b/android/src/main/java/com/reactnativeteadssdkmodule/TeadsSdkModulePackage.kt @@ -0,0 +1,25 @@ +package com.reactnativeteadssdkmodule + +import RNInReadAdViewManager +import com.facebook.react.ReactPackage +import com.facebook.react.bridge.NativeModule +import com.facebook.react.bridge.ReactApplicationContext + + +class TeadsSdkModulePackage : ReactPackage { + override fun createNativeModules(reactContext: ReactApplicationContext): List { + return listOf( + RNAdPlacementSettings(reactContext), + RNAdRequestSettings(reactContext), + RNTeads(reactContext), + RNInReadAdPlacement(reactContext), + RNAdRatio(reactContext), + + ) + } + + override fun createViewManagers( + reactContext: ReactApplicationContext + ) = listOf(RNInReadAdViewManager()) +} + diff --git a/babel.config.js b/babel.config.js index d799d65..f842b77 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,6 +1,3 @@ -module.exports = function (api) { - api.cache(true) - return { - presets: ['babel-preset-expo'] - } -} +module.exports = { + presets: ['module:metro-react-native-babel-preset'], +}; diff --git a/components/ActionBarImage.js b/components/ActionBarImage.js index a14f85a..939e3a0 100644 --- a/components/ActionBarImage.js +++ b/components/ActionBarImage.js @@ -1,16 +1,19 @@ -import React from 'react' -import { View, Image } from 'react-native' -import logo from '../assets/react.png' -import TeadsSampleAppBlack from '../assets/Teads-Sample-App.imageset/Teads-Sample-App-black.png' -import styleActionBarImage from '../styles/styleActionBarImage' +import React from 'react'; +import { View, Image } from 'react-native'; +import logo from '../assets/react.png'; +import TeadsSampleAppBlack from '../assets/Teads-Sample-App.imageset/Teads-Sample-App-black.png'; +import styleActionBarImage from '../styles/styleActionBarImage'; const ActionBarImage = () => { return ( - + - ) -} + ); +}; -export default ActionBarImage +export default ActionBarImage; diff --git a/components/ActionBarImageWhite.js b/components/ActionBarImageWhite.js index 86be7f7..6f27f17 100644 --- a/components/ActionBarImageWhite.js +++ b/components/ActionBarImageWhite.js @@ -1,14 +1,17 @@ -import React from 'react' -import { View, Image } from 'react-native' -import TeadsSampleAppWhite from '../assets/Teads-Sample-App.imageset/Teads-Sample-App-white.png' -import styleActionBarImageWhite from '../styles/styleActionBarImageWhite' +import React from 'react'; +import { View, Image } from 'react-native'; +import TeadsSampleAppWhite from '../assets/Teads-Sample-App.imageset/Teads-Sample-App-white.png'; +import styleActionBarImageWhite from '../styles/styleActionBarImageWhite'; const ActionBarImageWhite = () => { return ( - + - ) -} + ); +}; -export default ActionBarImageWhite +export default ActionBarImageWhite; diff --git a/components/InFeedItem.js b/components/InFeedItem.js index be57dca..5c3b4a4 100644 --- a/components/InFeedItem.js +++ b/components/InFeedItem.js @@ -1,8 +1,8 @@ -import { Text, View, Button, Image } from 'react-native' -import { Card } from 'react-native-elements' -import styleInFeedItem from '../styles/styleInFeedItem' -import { COVER_RESIZING, RADIUS_CARD } from '../constants' -import * as React from 'react' +import { Text, View, Button, Image } from 'react-native'; +import { Card } from 'react-native-elements'; +import styleInFeedItem from '../styles/styleInFeedItem'; +import { COVER_RESIZING, RADIUS_CARD } from '../constants'; +import * as React from 'react'; const InFeedItem = ({ icon, text, title, media, time, source, textButton }) => { return ( @@ -13,7 +13,7 @@ const InFeedItem = ({ icon, text, title, media, time, source, textButton }) => { style={styleInFeedItem.imageLogoItem} resizeMode={COVER_RESIZING} source={{ - uri: icon + uri: icon, }} /> @@ -22,7 +22,10 @@ const InFeedItem = ({ icon, text, title, media, time, source, textButton }) => { {time}min -