Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 64 additions & 27 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,57 +1,94 @@
import groovy.json.JsonSlurper

buildscript {
ext.safeExtGet = {prop, fallback ->
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativePasteInput_' + name]
}

repositories {
google()
gradlePluginPortal()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22")
classpath "com.android.tools.build:gradle:8.7.2"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
}
}

def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
apply plugin: "com.android.library"
apply plugin: "kotlin-android"

apply plugin: "com.facebook.react"

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["TestItOut_" + name]).toInteger()
}
apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android'

android {
compileSdkVersion safeExtGet('compileSdkVersion', 33)
namespace "com.mattermost.pasteinputtext"


compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 24)
targetSdkVersion safeExtGet('targetSdkVersion', 33)
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true")
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
externalNativeBuild {
cmake {
cppFlags '-DBUILD_DEBUG'
}
}
}

buildFeatures {
buildConfig true
}

buildTypes {
release {
minifyEnabled false
}
}

lintOptions {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
if (isNewArchitectureEnabled()) {
// java.srcDirs += ['src/newarch']
}
java.srcDirs += [
"generated/java",
"generated/jni"
]
}
}
}

externalNativeBuild {
cmake {
path file('generated/jni/CMakeLists.txt')
version '3.22.1'
}
}
}

def kotlin_version = getExtOrDefault("kotlinVersion")

repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../node_modules/react-native/android"
}
mavenCentral()
google()
}

dependencies {
implementation 'com.facebook.react:react-native:+'
}

react {
jsRootDir = file("../src/")
libraryName = "react-native-paste-input"
codegenJavaPackageName = "com.mattermost.pastetextinput"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/

package com.facebook.react.viewmanagers;

import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ColorPropConverter;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;

public class PasteTextInputManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & PasteTextInputManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public PasteTextInputManagerDelegate(U viewManager) {
super(viewManager);
}
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
switch (propName) {
case "allowFontScaling":
mViewManager.setAllowFontScaling(view, value == null ? false : (boolean) value);
break;
case "autoCapitalize":
mViewManager.setAutoCapitalize(view, (String) value);
break;
case "autoComplete":
mViewManager.setAutoComplete(view, (String) value);
break;
case "autoCorrect":
mViewManager.setAutoCorrect(view, value == null ? false : (boolean) value);
break;
case "autoFocus":
mViewManager.setAutoFocus(view, value == null ? false : (boolean) value);
break;
case "blurOnSubmit":
mViewManager.setBlurOnSubmit(view, value == null ? false : (boolean) value);
break;
case "caretHidden":
mViewManager.setCaretHidden(view, value == null ? false : (boolean) value);
break;
case "clearButtonMode":
mViewManager.setClearButtonMode(view, value == null ? null : (String) value);
break;
case "clearTextOnFocus":
mViewManager.setClearTextOnFocus(view, value == null ? false : (boolean) value);
break;
case "contextMenuHidden":
mViewManager.setContextMenuHidden(view, value == null ? false : (boolean) value);
break;
case "defaultValue":
mViewManager.setDefaultValue(view, value == null ? null : (String) value);
break;
case "disableCopyPaste":
mViewManager.setDisableCopyPaste(view, value == null ? false : (boolean) value);
break;
case "disableFullscreenUI":
mViewManager.setDisableFullscreenUI(view, value == null ? false : (boolean) value);
break;
case "editable":
mViewManager.setEditable(view, value == null ? false : (boolean) value);
break;
case "enablesReturnKeyAutomatically":
mViewManager.setEnablesReturnKeyAutomatically(view, value == null ? false : (boolean) value);
break;
case "importantForAutofill":
mViewManager.setImportantForAutofill(view, value == null ? null : (String) value);
break;
case "inlineImageLeft":
mViewManager.setInlineImageLeft(view, value == null ? null : (String) value);
break;
case "inlineImagePadding":
mViewManager.setInlineImagePadding(view, value == null ? 0 : ((Double) value).intValue());
break;
case "inputAccessoryViewID":
mViewManager.setInputAccessoryViewID(view, value == null ? null : (String) value);
break;
case "keyboardAppearance":
mViewManager.setKeyboardAppearance(view, value == null ? null : (String) value);
break;
case "keyboardType":
mViewManager.setKeyboardType(view, (String) value);
break;
case "maxFontSizeMultiplier":
mViewManager.setMaxFontSizeMultiplier(view, value == null ? 0f : ((Double) value).floatValue());
break;
case "maxLength":
mViewManager.setMaxLength(view, value == null ? 0 : ((Double) value).intValue());
break;
case "mostRecentEventCount":
mViewManager.setMostRecentEventCount(view, value == null ? 0 : ((Double) value).intValue());
break;
case "multiline":
mViewManager.setMultiline(view, value == null ? false : (boolean) value);
break;
case "numberOfLines":
mViewManager.setNumberOfLines(view, value == null ? 0 : ((Double) value).intValue());
break;
case "passwordRules":
mViewManager.setPasswordRules(view, value == null ? null : (String) value);
break;
case "placeholder":
mViewManager.setPlaceholder(view, value == null ? null : (String) value);
break;
case "placeholderTextColor":
mViewManager.setPlaceholderTextColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "returnKeyLabel":
mViewManager.setReturnKeyLabel(view, value == null ? null : (String) value);
break;
case "returnKeyType":
mViewManager.setReturnKeyType(view, (String) value);
break;
case "scrollEnabled":
mViewManager.setScrollEnabled(view, value == null ? false : (boolean) value);
break;
case "secureTextEntry":
mViewManager.setSecureTextEntry(view, value == null ? false : (boolean) value);
break;
case "selection":
mViewManager.setSelection(view, (ReadableMap) value);
break;
case "selectionColor":
mViewManager.setSelectionColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "selectionHandleColor":
mViewManager.setSelectionHandleColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "selectTextOnFocus":
mViewManager.setSelectTextOnFocus(view, value == null ? false : (boolean) value);
break;
case "showSoftInputOnFocus":
mViewManager.setShowSoftInputOnFocus(view, value == null ? false : (boolean) value);
break;
case "smartInsertDelete":
mViewManager.setSmartInsertDelete(view, value == null ? false : (boolean) value);
break;
case "smartPunctuation":
mViewManager.setSmartPunctuation(view, value == null ? null : (String) value);
break;
case "spellCheck":
mViewManager.setSpellCheck(view, value == null ? false : (boolean) value);
break;
case "submitBehavior":
mViewManager.setSubmitBehavior(view, (String) value);
break;
case "text":
mViewManager.setText(view, value == null ? null : (String) value);
break;
case "textBreakStrategy":
mViewManager.setTextBreakStrategy(view, (String) value);
break;
case "textContentType":
mViewManager.setTextContentType(view, value == null ? null : (String) value);
break;
case "underlineColorAndroid":
mViewManager.setUnderlineColorAndroid(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "value":
mViewManager.setValue(view, value == null ? null : (String) value);
break;
case "textShadowColor":
mViewManager.setTextShadowColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "textShadowRadius":
mViewManager.setTextShadowRadius(view, value == null ? 0f : ((Double) value).floatValue());
break;
case "textDecorationLine":
mViewManager.setTextDecorationLine(view, value == null ? null : (String) value);
break;
case "fontStyle":
mViewManager.setFontStyle(view, value == null ? null : (String) value);
break;
case "textShadowOffset":
mViewManager.setTextShadowOffset(view, (ReadableMap) value);
break;
case "lineHeight":
mViewManager.setLineHeight(view, value == null ? 0f : ((Double) value).floatValue());
break;
case "textTransform":
mViewManager.setTextTransform(view, value == null ? null : (String) value);
break;
case "color":
mViewManager.setColor(view, value == null ? 0 : ((Double) value).intValue());
break;
case "letterSpacing":
mViewManager.setLetterSpacing(view, value == null ? 0f : ((Double) value).floatValue());
break;
case "fontSize":
mViewManager.setFontSize(view, value == null ? 0f : ((Double) value).floatValue());
break;
case "textAlign":
mViewManager.setTextAlign(view, value == null ? null : (String) value);
break;
case "includeFontPadding":
mViewManager.setIncludeFontPadding(view, value == null ? false : (boolean) value);
break;
case "fontWeight":
mViewManager.setFontWeight(view, value == null ? null : (String) value);
break;
case "fontFamily":
mViewManager.setFontFamily(view, value == null ? null : (String) value);
break;
case "textAlignVertical":
mViewManager.setTextAlignVertical(view, value == null ? null : (String) value);
break;
case "cursorColor":
mViewManager.setCursorColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
default:
super.setProperty(view, propName, value);
}
}

@Override
public void receiveCommand(T view, String commandName, @Nullable ReadableArray args) {
switch (commandName) {
case "focus":
mViewManager.focus(view);
break;
case "blur":
mViewManager.blur(view);
break;
case "setTextAndSelection":
mViewManager.setTextAndSelection(view, args.getInt(0), args.getString(1), args.getInt(2), args.getInt(3));
break;
}
}
}
Loading