diff --git a/android/app/build.gradle b/android/app/build.gradle index 33c100ff60..2ed9d8163b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -148,8 +148,8 @@ android { vectorDrawables.useSupportLibrary = true if (isPlay) { manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String] + missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" // See note below! } - missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" // See note below! } signingConfigs { @@ -198,12 +198,23 @@ android { applicationId "chat.rocket.android" dimension = "type" buildConfigField "boolean", "FDROID_BUILD", "true" + resValue "string", "rn_config_reader_custom_package", "chat.rocket.reactnative" } play { dimension = "type" buildConfigField "boolean", "FDROID_BUILD", "false" } } + sourceSets { + playDebug { + java.srcDirs = ['src/main/java', 'src/play/java'] + manifest.srcFile 'src/play/AndroidManifest.xml' + } + playRelease { + java.srcDirs = ['src/main/java', 'src/play/java'] + manifest.srcFile 'src/play/AndroidManifest.xml' + } + } applicationVariants.all { variant -> variant.outputs.each { output -> @@ -234,9 +245,9 @@ android { dependencies { addUnimodulesDependencies() implementation project(':watermelondb') - implementation project(':reactnativenotifications') implementation project(":reactnativekeyboardinput") implementation project(':@react-native-community_viewpager') + playImplementation project(':reactnativenotifications') playImplementation project(':@react-native-firebase_app') playImplementation project(':@react-native-firebase_analytics') playImplementation project(':@react-native-firebase_crashlytics') diff --git a/android/app/src/foss/java/chat/rocket/reactnative/CustomPushNotification.java b/android/app/src/foss/java/chat/rocket/reactnative/CustomPushNotification.java deleted file mode 100644 index d8c0502eb8..0000000000 --- a/android/app/src/foss/java/chat/rocket/reactnative/CustomPushNotification.java +++ /dev/null @@ -1,20 +0,0 @@ -package chat.rocket.reactnative; - -import android.content.Context; -import android.os.Bundle; - -import com.facebook.react.bridge.ReactApplicationContext; -import com.wix.reactnativenotifications.core.AppLaunchHelper; -import com.wix.reactnativenotifications.core.AppLifecycleFacade; -import com.wix.reactnativenotifications.core.JsIOHelper; -import com.wix.reactnativenotifications.core.notification.PushNotification; - -public class CustomPushNotification extends PushNotification { - public static ReactApplicationContext reactApplicationContext; - - public CustomPushNotification(Context context, Bundle bundle, AppLifecycleFacade appLifecycleFacade, AppLaunchHelper appLaunchHelper, JsIOHelper jsIoHelper) { - super(context, bundle, appLifecycleFacade, appLaunchHelper, jsIoHelper); - reactApplicationContext = new ReactApplicationContext(context); - } - -} diff --git a/android/app/src/foss/java/chat/rocket/reactnative/DismissNotification.java b/android/app/src/foss/java/chat/rocket/reactnative/DismissNotification.java deleted file mode 100644 index 48350be518..0000000000 --- a/android/app/src/foss/java/chat/rocket/reactnative/DismissNotification.java +++ /dev/null @@ -1,12 +0,0 @@ -package chat.rocket.reactnative; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -public class DismissNotification extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - - } -} diff --git a/android/app/src/foss/java/chat/rocket/reactnative/Ejson.java b/android/app/src/foss/java/chat/rocket/reactnative/Ejson.java deleted file mode 100644 index baf2632605..0000000000 --- a/android/app/src/foss/java/chat/rocket/reactnative/Ejson.java +++ /dev/null @@ -1,97 +0,0 @@ -package chat.rocket.reactnative; - -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.Callback; - -import com.ammarahmed.mmkv.SecureKeystore; -import com.tencent.mmkv.MMKV; - -import java.math.BigInteger; - -class RNCallback implements Callback { - public void invoke(Object... args) { - - } -} - -class Utils { - static public String toHex(String arg) { - try { - return String.format("%x", new BigInteger(1, arg.getBytes("UTF-8"))); - } catch (Exception e) { - return ""; - } - } -} - -public class Ejson { - String host; - String rid; - String type; - Sender sender; - String messageId; - String notificationType; - - private MMKV mmkv; - - private String TOKEN_KEY = "reactnativemeteor_usertoken-"; - - public Ejson() { - ReactApplicationContext reactApplicationContext = CustomPushNotification.reactApplicationContext; - - // Start MMKV container - MMKV.initialize(reactApplicationContext); - SecureKeystore secureKeystore = new SecureKeystore(reactApplicationContext); - - // https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/src/loader.js#L31 - String alias = Utils.toHex("com.MMKV.default"); - - // Retrieve container password - secureKeystore.getSecureKey(alias, new RNCallback() { - @Override - public void invoke(Object... args) { - String error = (String) args[0]; - if (error == null) { - String password = (String) args[1]; - mmkv = MMKV.mmkvWithID("default", MMKV.SINGLE_PROCESS_MODE, password); - } - } - }); - } - - public String getAvatarUri() { - if (type == null) { - return null; - } - return serverURL() + "/avatar/" + this.sender.username + "?rc_token=" + token() + "&rc_uid=" + userId(); - } - - public String token() { - String userId = userId(); - if (mmkv != null && userId != null) { - return mmkv.decodeString(TOKEN_KEY.concat(userId)); - } - return ""; - } - - public String userId() { - String serverURL = serverURL(); - if (mmkv != null && serverURL != null) { - return mmkv.decodeString(TOKEN_KEY.concat(serverURL)); - } - return ""; - } - - public String serverURL() { - String url = this.host; - if (url != null && url.endsWith("/")) { - url = url.substring(0, url.length() - 1); - } - return url; - } - - public class Sender { - String username; - String _id; - } -} \ No newline at end of file diff --git a/android/app/src/foss/java/chat/rocket/reactnative/ReplyBroadcast.java b/android/app/src/foss/java/chat/rocket/reactnative/ReplyBroadcast.java deleted file mode 100644 index 5203495b88..0000000000 --- a/android/app/src/foss/java/chat/rocket/reactnative/ReplyBroadcast.java +++ /dev/null @@ -1,13 +0,0 @@ -package chat.rocket.reactnative; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -public class ReplyBroadcast extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - - } -} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 35db2ebc3f..81171a699a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -45,15 +45,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/android/app/src/play/java/chat/rocket/reactnative/MainPlayApplication.java b/android/app/src/play/java/chat/rocket/reactnative/MainPlayApplication.java new file mode 100644 index 0000000000..b78dd0ea52 --- /dev/null +++ b/android/app/src/play/java/chat/rocket/reactnative/MainPlayApplication.java @@ -0,0 +1,23 @@ +package chat.rocket.reactnative; + +import android.content.Context; +import android.os.Bundle; + +import com.wix.reactnativenotifications.core.AppLaunchHelper; +import com.wix.reactnativenotifications.core.AppLifecycleFacade; +import com.wix.reactnativenotifications.core.JsIOHelper; +import com.wix.reactnativenotifications.core.notification.INotificationsApplication; +import com.wix.reactnativenotifications.core.notification.IPushNotification; + +public class MainPlayApplication extends MainApplication implements INotificationsApplication { + @Override + public IPushNotification getPushNotification(Context context, Bundle bundle, AppLifecycleFacade defaultFacade, AppLaunchHelper defaultAppLaunchHelper) { + return new CustomPushNotification( + context, + bundle, + defaultFacade, + defaultAppLaunchHelper, + new JsIOHelper() + ); + } +} diff --git a/android/build.gradle b/android/build.gradle index 8500050a42..ae769e0c75 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,12 @@ +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} + // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase() + def isPlay = !taskRequests.contains("foss") + ext { buildToolsVersion = "29.0.2" minSdkVersion = 23 @@ -8,7 +15,11 @@ buildscript { glideVersion = "4.9.0" kotlin_version = "1.3.50" supportLibVersion = "28.0.0" + libre_build = !(isPlay.toBoolean()) + jitsi_url = isPlay ? "https://github.com/RocketChat/jitsi-maven-repository/raw/master/releases" : "https://github.com/RocketChat/jitsi-maven-repository/raw/libre/releases" + jitsi_version = isPlay ? "+" : "2.10.0-libre" } + repositories { mavenLocal() google() @@ -18,9 +29,6 @@ buildscript { } } - def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase() - def isPlay = !taskRequests.contains("foss") - dependencies { if (isPlay) { classpath 'com.google.gms:google-services:4.2.0' @@ -40,7 +48,11 @@ allprojects { url("$rootDir/../node_modules/react-native/android") } maven { - url "https://github.com/RocketChat/jitsi-maven-repository/raw/master/releases" + // Android JSC is installed from npm + url("$rootDir/../node_modules/jsc-android/dist") + } + maven { + url safeExtGet("jitsi_url", "https://github.com/RocketChat/jitsi-maven-repository/raw/master/releases") } google() diff --git a/patches/react-native-device-info+5.6.2.patch b/patches/react-native-device-info+5.6.2.patch new file mode 100644 index 0000000000..c679d71f26 --- /dev/null +++ b/patches/react-native-device-info+5.6.2.patch @@ -0,0 +1,28 @@ +diff --git a/node_modules/react-native-device-info/android/build.gradle b/node_modules/react-native-device-info/android/build.gradle +index ac1a9d4..ab9aef8 100644 +--- a/node_modules/react-native-device-info/android/build.gradle ++++ b/node_modules/react-native-device-info/android/build.gradle +@@ -49,14 +49,16 @@ repositories { + dependencies { + implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" + implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '1.1.2')}" +- def firebaseIidVersion = safeExtGet('firebaseIidVersion', null) +- if(firebaseIidVersion){ +- implementation "com.google.firebase:firebase-iid:$firebaseIidVersion" +- }else{ +- def iidVersion = safeExtGet('googlePlayServicesIidVersion', safeExtGet('googlePlayServicesVersion', '17.0.0')) +- implementation "com.google.android.gms:play-services-iid:$iidVersion" ++ def libreBuild = safeExtGet('libre_build', false) ++ if (!libreBuild) { ++ def firebaseIidVersion = safeExtGet('firebaseIidVersion', null) ++ if(firebaseIidVersion){ ++ implementation "com.google.firebase:firebase-iid:$firebaseIidVersion" ++ }else{ ++ def iidVersion = safeExtGet('googlePlayServicesIidVersion', safeExtGet('googlePlayServicesVersion', '17.0.0')) ++ implementation "com.google.android.gms:play-services-iid:$iidVersion" ++ } + } +- + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2' + testImplementation "org.mockito:mockito-core:3.3.3" + } diff --git a/yarn.lock b/yarn.lock index 9cb699507d..1995ad98c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12772,8 +12772,8 @@ react-native-iphone-x-helper@^1.0.3, react-native-iphone-x-helper@^1.2.1: integrity sha512-/VbpIEp8tSNNHIvstuA3Swx610whci1Zpc9mqNkqn14DkMbw+ORviln2u0XyHG1kPvvwTNGZY6QpeFwxYaSdbQ== react-native-jitsi-meet@RocketChat/react-native-jitsi-meet: - version "2.3.1" - resolved "https://codeload.github.com/RocketChat/react-native-jitsi-meet/tar.gz/39c2c36c82b2dbb2f80c58aa788e15b526681c65" + version "2.4.0" + resolved "https://codeload.github.com/RocketChat/react-native-jitsi-meet/tar.gz/806ea2fb24d8fce90d983766af15b9fc71b3bb9a" react-native-keyboard-input@RocketChat/react-native-keyboard-input: version "6.0.0"