Merge remote-tracking branch 'origin' into v3

This commit is contained in:
yogevbd
2020-01-12 15:03:39 +02:00
19 changed files with 170 additions and 66 deletions

View File

@@ -1,7 +1,6 @@
import groovy.json.JsonSlurper
apply plugin: 'com.android.library'
apply from: '../prepare-robolectric.gradle'
String resolveFlavor() {
def packageSlurper = new JsonSlurper()
@@ -18,7 +17,7 @@ String resolveFlavor() {
}
android {
compileSdkVersion 27
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
@@ -56,6 +55,10 @@ android {
}
}
}
unitTests {
includeAndroidResources = true
}
}
flavorDimensions "RNNotifications.reactNativeVersion"
@@ -83,8 +86,8 @@ dependencies {
// tests
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.5.1'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'org.assertj:assertj-core:3.8.0'
testImplementation 'com.squareup.assertj:assertj-android:1.1.1'
testImplementation 'org.mockito:mockito-core:2.13.0'
testImplementation 'org.mockito:mockito-core:2.25.1'
}

View File

@@ -1,8 +0,0 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Wed Jan 30 11:37:18 IST 2019
sdk.dir=/Users/yogevbd/android-sdk-macosx

View File

@@ -10,8 +10,6 @@
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<!-- Ref: http://stackoverflow.com/questions/13602190/java-lang-securityexception-requires-vibrate-permission-on-jelly-bean-4-2 -->
<uses-permission android:name="android.permission.VIBRATE" />
<application>

View File

@@ -108,7 +108,12 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
@ReactMethod
public void setCategories(ReadableArray categories) {
}
public void cancelDeliveredNotification(String tag, int notificationId) {
IPushNotificationsDrawer notificationsDrawer = PushNotificationsDrawer.get(getReactApplicationContext().getApplicationContext());
notificationsDrawer.onNotificationClearRequest(tag, notificationId);
}
@ReactMethod
@@ -117,6 +122,11 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
promise.resolve(new Boolean(hasPermission));
}
@ReactMethod void removeAllDeliveredNotifications() {
IPushNotificationsDrawer notificationsDrawer = PushNotificationsDrawer.get(getReactApplicationContext().getApplicationContext());
notificationsDrawer.onAllNotificationsClearRequest();
}
protected void startFcmIntentService(String extraFlag) {
final Context appContext = getReactApplicationContext().getApplicationContext();
final Intent tokenFetchIntent = new Intent(appContext, FcmInstanceIdRefreshHandlerService.class);

View File

@@ -9,4 +9,6 @@ public interface IPushNotificationsDrawer {
void onNotificationOpened();
void onNotificationClearRequest(int id);
void onNotificationClearRequest(String tag, int id);
void onAllNotificationsClearRequest();
}

View File

@@ -60,6 +60,18 @@ public class PushNotificationsDrawer implements IPushNotificationsDrawer {
notificationManager.cancel(id);
}
@Override
public void onNotificationClearRequest(String tag, int id) {
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(tag, id);
}
@Override
public void onAllNotificationsClearRequest() {
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}
protected void clearAll() {
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();

View File

@@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@@ -1,6 +1,6 @@
#Thu Jan 04 11:01:32 EET 2018
#Thu Dec 12 22:41:40 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

View File

@@ -1,43 +0,0 @@
def robolectricDependenciesFolder = new File(rootProject.buildDir, "robolectric-3.5.1-dependencies")
configurations.create('robolectricRuntime')
dependencies {
testImplementation "org.khronos:opengl-api:gl1.1-android-2.1_r1"
robolectricRuntime "org.robolectric:android-all:8.1.0-robolectric-4402310"
robolectricRuntime "org.robolectric:annotations:3.5.1"
robolectricRuntime "org.robolectric:junit:3.5.1"
robolectricRuntime "org.robolectric:resources:3.5.1"
robolectricRuntime "org.robolectric:sandbox:3.5.1"
robolectricRuntime "org.robolectric:utils:3.5.1"
robolectricRuntime "org.robolectric:shadows-framework:3.5.1"
}
rootProject.task(type: Copy, overwrite: true, "downloadRobolectricDependencies") {
println "downloadRobolectricDependencies into " + robolectricDependenciesFolder
from configurations.robolectricRuntime
into robolectricDependenciesFolder
}
project.afterEvaluate {
tasks.all {
if (it.name.startsWith("test")) {
it.dependsOn(rootProject.tasks.findByName("downloadRobolectricDependencies"))
}
}
}
android {
testOptions {
unitTests {
includeAndroidResources = true
}
unitTests.all {
systemProperty 'robolectric.offline', 'true'
systemProperty 'robolectric.dependency.dir', robolectricDependenciesFolder
}
}
}