Skip to content

Commit

Permalink
WIP: fix updated package
Browse files Browse the repository at this point in the history
  • Loading branch information
dimninik committed Sep 6, 2023
1 parent 929e0bf commit a2a3c2a
Show file tree
Hide file tree
Showing 9 changed files with 817 additions and 484 deletions.
48 changes: 28 additions & 20 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["BlePlx_" + name]).toInteger()
}

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion safeExtGet('compileSdkVersion', 27)
buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3')
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion 21
targetSdkVersion safeExtGet('targetSdkVersion', 27)
}
lintOptions {
abortOnError false
defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
}
buildTypes {
release {
minifyEnabled false
}
}

lintOptions {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
Expand Down
5 changes: 5 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BlePlx_kotlinVersion=1.7.0
BlePlx_minSdkVersion=23
BlePlx_targetSdkVersion=31
BlePlx_compileSdkVersion=31
BlePlx_ndkversion=21.4.7075529
8 changes: 0 additions & 8 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.polidea.reactnativeble">
<!-- Android >= 12 -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Android < 12 -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
minSdkVersion = 23
compileSdkVersion = 33
targetSdkVersion = 33

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const DashboardScreen = (_props: DashboardScreenProps) => {
setBLEReady(true)
}

const addFoundDevice = (device: Device) =>
const addFoundDevice = (device: Device) => {
console.log('found device', device.id)
setFoundDevices(prevState => {
const indexToReplace = prevState.findIndex(currentDevice => currentDevice.id === device.id)
if (indexToReplace === -1) {
Expand All @@ -25,6 +26,7 @@ export const DashboardScreen = (_props: DashboardScreenProps) => {
prevState[indexToReplace] = device
return prevState
})
}

useEffect(() => {
BLEService.initializeBLE(onBLEReady)
Expand All @@ -41,6 +43,7 @@ export const DashboardScreen = (_props: DashboardScreenProps) => {
return (
<ScreenDefaultContainer>
<AppButton label="Look for devices" onPress={() => BLEService.scanDevices(addFoundDevice)} />
<AppButton label="Request bluetooth permission" onPress={() => BLEService.requestBluetoothPermission()} />
<FlatList
style={{ flex: 1 }}
data={foundDevices}
Expand Down
2 changes: 1 addition & 1 deletion example/src/services/BLEService/BLEService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class BLEServiceInstance {
}
};

private requestBluetoothPermission = async () => {
public requestBluetoothPermission = async () => {
try {
const grantedLocation = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
Expand Down
25 changes: 24 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@
"react-native": "index.js",
"source": "index.js",
"types": "index.d.ts",
"files": [
"src",
"lib",
"android",
"ios",
"cpp",
"*.podspec",
"!lib/typescript/example",
"!ios/build",
"!android/build",
"!android/gradle",
"!android/gradlew",
"!android/gradlew.bat",
"!android/local.properties",
"!**/__tests__",
"!**/__fixtures__",
"!**/__mocks__",
"!**/.*"
],
"scripts": {
"test": "jest",
"lint": "flow && documentation lint index.js",
Expand Down Expand Up @@ -38,7 +57,7 @@
"metro-react-native-babel-preset": "^0.64.0",
"prettier": "^2.1.1",
"react": "17.0.2",
"react-native": "0.65.1"
"react-native": "0.70.0"
},
"keywords": [
"React",
Expand All @@ -49,6 +68,10 @@
"BLE",
"Polidea"
],
"engines": {
"node": ">= 16.0.0"
},
"packageManager": "^[email protected]",
"jest": {
"preset": "react-native",
"modulePathIgnorePatterns": [
Expand Down
34 changes: 34 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build:android": {
"inputs": [
"package.json",
"android",
"!android/build",
"src/*.ts",
"src/*.tsx",
"example/package.json",
"example/android",
"!example/android/.gradle",
"!example/android/build",
"!example/android/app/build"
],
"outputs": []
},
"build:ios": {
"inputs": [
"package.json",
"*.podspec",
"ios",
"src/*.ts",
"src/*.tsx",
"example/package.json",
"example/ios",
"!example/ios/build",
"!example/ios/Pods"
],
"outputs": []
}
}
}
Loading

0 comments on commit a2a3c2a

Please sign in to comment.