From 19b3a992c47f0b464d227eed68d72f3579ff1637 Mon Sep 17 00:00:00 2001 From: "Pedro R. Chacon" Date: Mon, 22 Nov 2021 22:39:22 -0400 Subject: [PATCH] Update To Version 0.0.4 - Correct use of notifications - Set Timer after tone detection --- .gitignore | 1 + README.md | 17 +++++++++++++++-- android/app/build.gradle | 2 +- .../MainActivity.java | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/README.md b/README.md index 9b7e674..d30b948 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ allprojects { dependencies { ... //framework - implementation 'com.github.The-TONE-Knows-Inc:framework-core-tone-android:v0.0.1' + implementation 'com.github.The-TONE-Knows-Inc:framework-core-tone-android:v0.0.4' ... implementation "com.facebook.react:react-native:+" // From node_modules } @@ -168,7 +168,7 @@ Inside the Override _**onCreate**_ method add the follow code to obtain the Reac } ``` -There's just 2 more Overrides to implement, one to handle permission request and the other to create the Bridge and send the response to the UI +There's just 2 more Overrides to implement, one to handle permission request and the other to create the Bridge and send the response to the UI and 2 more to handle notification that's gonna be onPause and onResume ``` java //This override start the service after permissions request @Override @@ -185,6 +185,19 @@ There's just 2 more Overrides to implement, one to handle permission request an } } + @Override + public void onResume(){ + super.onResume(); + if(toneFramework != null){ + toneFramework.turnNotificationsOn(false); + } + } + + @Override + public void onPause(){ + super.onPause(); + toneFramework.turnNotificationsOn(true); + } //This override handle the response from the service with the app open @Override public void onToneReceived(ToneModel toneModel) { diff --git a/android/app/build.gradle b/android/app/build.gradle index fe91b79..1d58a31 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -189,7 +189,7 @@ dependencies { implementation 'com.android.support:multidex:1.0.3' //noinspection GradleDynamicVersion implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation 'com.github.The-TONE-Knows-Inc:framework-core-tone-android:1.8' + implementation 'com.github.The-TONE-Knows-Inc:framework-core-tone-android:v0.0.4' implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" diff --git a/android/app/src/main/java/com/toneexpoexampleimplementation/MainActivity.java b/android/app/src/main/java/com/toneexpoexampleimplementation/MainActivity.java index fe56a4b..340d5c3 100644 --- a/android/app/src/main/java/com/toneexpoexampleimplementation/MainActivity.java +++ b/android/app/src/main/java/com/toneexpoexampleimplementation/MainActivity.java @@ -65,8 +65,6 @@ protected ReactRootView createRootView() { }; } - - //This override start the service after permissions request @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { @@ -82,6 +80,19 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in } } + @Override + public void onResume(){ + super.onResume(); + if(toneFramework != null){ + toneFramework.turnNotificationsOn(false); + } + } + + @Override + public void onPause(){ + super.onPause(); + toneFramework.turnNotificationsOn(true); + } //This override handle the response from the service with the app open @Override public void onToneReceived(ToneModel toneModel) {