Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Keyboard support/keyboard event #241

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 11 additions & 4 deletions android/src/main/java/com/reactnativeama/AmaPackage.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package com.reactnativeama

import android.util.Log
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManager
import com.reactnativeama.components.AmaFlatListWrapperManager
import com.reactnativeama.modules.AMAAnimationsStatusModule
import com.reactnativeama.components.AMAWrapperManager
import com.reactnativeama.modules.AMAKeyboardModule

class AmaPackage : ReactPackage {
init {
Log.d("AmaPackage", "AmaPackage is being initialized")
}

override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
return listOf(AMAAnimationsStatusModule(reactContext))
throw IllegalArgumentException()
return listOf(AMAKeyboardModule(reactContext))
}

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
return listOf(AmaFlatListWrapperManager())
Log.d("AmaPackage", "AmaPackage is being initialized")
return listOf(AMAWrapperManager())
}
}
13 changes: 13 additions & 0 deletions android/src/main/java/com/reactnativeama/components/AMAWrapper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.reactnativeama.components

import android.content.Context
import android.view.ViewGroup
import android.view.accessibility.AccessibilityNodeInfo

class AMAWrapper(context: Context?) : ViewGroup(context) {
private var rowsCount = 0
private var columnsCount = 1

override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.reactnativeama.components

import android.view.View
import com.facebook.react.uimanager.ViewGroupManager
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.annotations.ReactProp

class AMAWrapperManager : ViewGroupManager<AMAWrapper>() {
private lateinit var container: AMAWrapper

override fun getName() = "AMAWrapper"

override fun createViewInstance(reactContext: ThemedReactContext): AMAWrapper {
container = AMAWrapper(reactContext)

return container
}

override fun addView(parent: AMAWrapper?, child: View?, index: Int) {
container.addView(child)
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.reactnativeama.modules

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.Promise
import android.provider.Settings
import androidx.annotation.NonNull
import android.content.res.Configuration

class AMAKeyboardModule(private val context: ReactApplicationContext) :
ReactContextBaseJavaModule(context) {

@NonNull
override fun getName(): String {
return "AMAKeyboard"
}

@ReactMethod
fun isKeyboardConnected(): Boolean {
val keyboard = context.resources.configuration.keyboard

return keyboard != Configuration.KEYBOARD_UNDEFINED && keyboard != Configuration.KEYBOARD_NOKEYS
}
}
9 changes: 7 additions & 2 deletions examples/bare/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ react {
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
reactNativeDir = file("../../../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
Expand Down Expand Up @@ -104,6 +104,8 @@ android {
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])

// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

Expand All @@ -118,6 +120,9 @@ dependencies {
} else {
implementation jscFlavor
}

implementation project(':reactnativeama')
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: file("../../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
13 changes: 11 additions & 2 deletions examples/bare/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = "33.0.0"
Expand All @@ -9,13 +7,24 @@ buildscript {

// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"

// Set the kotlin version used in the Braze React SDK's buildscript
if (findProperty('android.kotlinVersion')) {
kotlin_version = findProperty('android.kotlinVersion')
} else {
kotlin_version = "1.8.10"
}
}

repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}

apply plugin: "com.facebook.react.rootproject"
10 changes: 8 additions & 2 deletions examples/bare/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
pluginManagement { includeBuild("../../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'AMA Example'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
includeBuild('../../../node_modules/@react-native/gradle-plugin')

include ':reactnativeama'
project(':reactnativeama').projectDir = new File(rootProject.projectDir, '../../../../android')
3 changes: 3 additions & 0 deletions examples/expo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ yarn-error.*

# typescript
*.tsbuildinfo

/android
/ios
57 changes: 30 additions & 27 deletions examples/expo/app.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
{
"expo": {
"name": "ama-expo-example",
"slug": "ama-expo-example",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"favicon": "./assets/favicon.png"
"expo": {
"name": "ama-expo-example",
"slug": "ama-expo-example",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"icon": "./assets/icon.png",
"package": "com.nearform.reactnativeamaexpo",
"versionCode": 1
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
}
8 changes: 4 additions & 4 deletions examples/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios"
},
"dependencies": {
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.14",
"expo": "~49.0.10",
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.4",
Expand Down
Loading
Loading