diff --git a/android/app/build.gradle b/android/app/build.gradle index d78e9b6..aa63f83 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -116,3 +116,4 @@ dependencies { } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) +// apply plugin: 'com.google.gms.google-services' diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 4122f36..08c91cb 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,13 @@ - - + + + + + + + diff --git a/android/app/src/main/java/com/learnproai/MainActivity.kt b/android/app/src/main/java/com/learnproai/MainActivity.kt index 1e05f0b..4557f0a 100644 --- a/android/app/src/main/java/com/learnproai/MainActivity.kt +++ b/android/app/src/main/java/com/learnproai/MainActivity.kt @@ -4,6 +4,7 @@ import com.facebook.react.ReactActivity import com.facebook.react.ReactActivityDelegate import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled import com.facebook.react.defaults.DefaultReactActivityDelegate +import com.doublesymmetry.trackplayer.service.MusicService; class MainActivity : ReactActivity() { diff --git a/android/app/src/main/java/com/learnproai/MainApplication.kt b/android/app/src/main/java/com/learnproai/MainApplication.kt index bd73eaf..baa6c7d 100644 --- a/android/app/src/main/java/com/learnproai/MainApplication.kt +++ b/android/app/src/main/java/com/learnproai/MainApplication.kt @@ -10,6 +10,7 @@ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost import com.facebook.react.defaults.DefaultReactNativeHost import com.facebook.soloader.SoLoader +import com.doublesymmetry.trackplayer.TrackPlayer; class MainApplication : Application(), ReactApplication { diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index c81d83a..3e1aae4 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - LearnProAi + LanguageMe diff --git a/android/build.gradle b/android/build.gradle index 0544d9b..7df4ce1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { buildToolsVersion = "34.0.0" - minSdkVersion = 21 + minSdkVersion = 24 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "22.1.7171670" @@ -15,6 +15,7 @@ buildscript { classpath("com.android.tools.build:gradle:7.0.0") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") classpath("com.facebook.react:react-native-gradle-plugin") + // classpath('com.google.gms:google-services:4.3.10') } } @@ -28,7 +29,7 @@ allprojects { buildscript { ext { buildToolsVersion = "34.0.0" - minSdkVersion = 21 + minSdkVersion = 24 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "22.1.7171670" @@ -42,6 +43,7 @@ buildscript { classpath("com.android.tools.build:gradle:7.0.0") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") classpath("com.facebook.react:react-native-gradle-plugin") + // classpath('com.google.gms:google-services:4.3.10') } } @@ -52,3 +54,7 @@ allprojects { google() } } + +gradle.startParameter.excludedTaskNames.addAll( + gradle.startParameter.taskNames.findAll { it.contains("testClasses") } +) diff --git a/index.js b/index.js index d5ce57d..a0d8cbe 100644 --- a/index.js +++ b/index.js @@ -2,5 +2,8 @@ import 'react-native-gesture-handler'; import { AppRegistry } from 'react-native'; import App from './App'; import { name as appName } from './app.json'; +import TrackPlayer from 'react-native-track-player'; AppRegistry.registerComponent(appName, () => App); +TrackPlayer.registerPlaybackService(() => require('./trackPlayerService.js')); + diff --git a/package-lock.json b/package-lock.json index ec5c9d4..d328346 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@react-native-firebase/auth": "^20.1.0", "@react-native-firebase/firestore": "^20.1.0", "@react-native-firebase/messaging": "^20.1.0", - "@react-native-masked-view/masked-view": "^0.3.1", + "@react-native-masked-view/masked-view": "^0.2.9", "@react-navigation/bottom-tabs": "^6.5.20", "@react-navigation/native": "^6.1.17", "@react-navigation/stack": "^6.3.29", @@ -4200,9 +4200,9 @@ } }, "node_modules/@react-native-masked-view/masked-view": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@react-native-masked-view/masked-view/-/masked-view-0.3.1.tgz", - "integrity": "sha512-uVm8U6nwFIlUd1iDIB5cS+lDadApKR+l8k4k84d9hn+GN4lzAIJhUZ9syYX7c022MxNgAlbxoFLt0pqKoyaAGg==", + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/@react-native-masked-view/masked-view/-/masked-view-0.2.9.tgz", + "integrity": "sha512-Hs4vKBKj+15VxHZHFtMaFWSBxXoOE5Ea8saoigWhahp8Mepssm0ezU+2pTl7DK9z8Y9s5uOl/aPb4QmBZ3R3Zw==", "license": "MIT", "peerDependencies": { "react": ">=16", @@ -8076,9 +8076,9 @@ "dev": true }, "node_modules/fast-xml-parser": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.0.tgz", - "integrity": "sha512-kLY3jFlwIYwBNDojclKsNAC12sfD6NwW74QB2CoNGPvtVxjliYehVunB3HYyNi+n4Tt1dAcgwYvmKF/Z18flqg==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.5.0.tgz", + "integrity": "sha512-/PlTQCI96+fZMAOLMZK4CWG1ItCbfZ/0jx7UIJFChPNrx7tcEgerUgWbeieCM9MfHInUDyK8DWYZ+YrywDJuTg==", "funding": [ { "type": "github", @@ -8089,6 +8089,7 @@ "url": "https://paypal.me/naturalintelligence" } ], + "license": "MIT", "dependencies": { "strnum": "^1.0.5" }, @@ -12275,9 +12276,10 @@ } }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "license": "MIT", "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" @@ -13755,6 +13757,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/react-native-track-player/-/react-native-track-player-4.1.1.tgz", "integrity": "sha512-E5N/eK/+HtAVJUAzXpm1cWz8ROheV9jb0TI6h2bM+333U+DWibTTnT2T1122FkCoXLXIYavtm2FR2if+5jH8cA==", + "license": "Apache-2.0", "funding": { "url": "https://github.com/doublesymmetry/react-native-track-player?sponsor=1" }, diff --git a/package.json b/package.json index 30abb49..9a70bc2 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@react-native-firebase/auth": "^20.1.0", "@react-native-firebase/firestore": "^20.1.0", "@react-native-firebase/messaging": "^20.1.0", - "@react-native-masked-view/masked-view": "^0.3.1", + "@react-native-masked-view/masked-view": "^0.2.9", "@react-navigation/bottom-tabs": "^6.5.20", "@react-navigation/native": "^6.1.17", "@react-navigation/stack": "^6.3.29", diff --git a/setup/PlayerSetup.js b/setup/PlayerSetup.js index 9bd583d..487a248 100644 --- a/setup/PlayerSetup.js +++ b/setup/PlayerSetup.js @@ -1,5 +1,5 @@ import { useEffect } from 'react'; -import { Platform } from 'react-native'; +import { AppState, Platform } from 'react-native'; import TrackPlayer from 'react-native-track-player'; export const usePlayerSetup = () => { @@ -14,10 +14,18 @@ export const usePlayerSetup = () => { TrackPlayer.CAPABILITY_STOP, TrackPlayer.CAPABILITY_SEEK_TO, ], + notificationCapabilities: [ + TrackPlayer.CAPABILITY_PLAY, + TrackPlayer.CAPABILITY_PAUSE, + TrackPlayer.CAPABILITY_STOP, + TrackPlayer.CAPABILITY_SEEK_TO, + ], compactCapabilities: [ TrackPlayer.CAPABILITY_PLAY, TrackPlayer.CAPABILITY_PAUSE, ], + foregroundService: true, + alwaysPauseOnInterruption: true, }); // Set the audio session category to allow playback in silent mode (iOS only) @@ -27,7 +35,8 @@ export const usePlayerSetup = () => { }); } }; - - setupPlayer(); + if (AppState.currentState === 'active') { + setupPlayer(); + } }, []); }; diff --git a/types.ts b/types.ts index e0c8037..42e1913 100644 --- a/types.ts +++ b/types.ts @@ -68,6 +68,7 @@ export type Reading = { difficulty: string; wordCount: number; passage: string | null; + previewText: string; // first 100 characters of the passage createdAt: Date; wordTimestamps: ReadingWithWordTimeStamps | null };