[FIX] F-Droid build for store (#2557)

* [FIX] F-Droid build for store

* Trying to make Override custom push notifications on play build only

* Use play sourceSets

* Change version code

* Fix react-native-config-reader

* [FIX] F-Droid build for store

* Trying to make Override custom push notifications on play build only

* Use play sourceSets

* Change version code

* Fix react-native-config-reader

* Remove react-native-device-info Google dependencies / Use LIBRE_BUILD of react-native-jitsi-meet

* Invalidate CI Cache

* Set specific jitsi-meet-sdk

* Specify 2.10.0-libre

* jitsi-meet using an url based on play build

* update react-native-jitsi-meet

* react-native-device-info foss

* undo some unnecessary changes

* Fix notifications

Co-authored-by: Djorkaeff Alexandre <djorkaeff.unb@gmail.com>
This commit is contained in:
Diego Mello 2020-11-09 17:14:35 -03:00 committed by GitHub
parent 192f3f1aa0
commit de81fa3464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 87 additions and 228 deletions

View File

@ -148,8 +148,8 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
if (isPlay) { if (isPlay) {
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String] manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" // See note below!
} }
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" // See note below!
} }
signingConfigs { signingConfigs {
@ -198,12 +198,23 @@ android {
applicationId "chat.rocket.android" applicationId "chat.rocket.android"
dimension = "type" dimension = "type"
buildConfigField "boolean", "FDROID_BUILD", "true" buildConfigField "boolean", "FDROID_BUILD", "true"
resValue "string", "rn_config_reader_custom_package", "chat.rocket.reactnative"
} }
play { play {
dimension = "type" dimension = "type"
buildConfigField "boolean", "FDROID_BUILD", "false" 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 -> applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
@ -234,9 +245,9 @@ android {
dependencies { dependencies {
addUnimodulesDependencies() addUnimodulesDependencies()
implementation project(':watermelondb') implementation project(':watermelondb')
implementation project(':reactnativenotifications')
implementation project(":reactnativekeyboardinput") implementation project(":reactnativekeyboardinput")
implementation project(':@react-native-community_viewpager') implementation project(':@react-native-community_viewpager')
playImplementation project(':reactnativenotifications')
playImplementation project(':@react-native-firebase_app') playImplementation project(':@react-native-firebase_app')
playImplementation project(':@react-native-firebase_analytics') playImplementation project(':@react-native-firebase_analytics')
playImplementation project(':@react-native-firebase_crashlytics') playImplementation project(':@react-native-firebase_crashlytics')

View File

@ -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);
}
}

View File

@ -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) {
}
}

View File

@ -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;
}
}

View File

@ -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) {
}
}

View File

@ -45,15 +45,6 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver
android:name=".ReplyBroadcast"
android:enabled="true"
android:exported="false" />
<receiver
android:name=".DismissNotification"
android:enabled="true"
android:exported="false" >
</receiver>
<activity <activity
android:noHistory="true" android:noHistory="true"
android:name=".share.ShareActivity" android:name=".share.ShareActivity"

View File

@ -1,8 +1,6 @@
package chat.rocket.reactnative; package chat.rocket.reactnative;
import android.app.Application; import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -14,11 +12,6 @@ import com.facebook.soloader.SoLoader;
import com.nozbe.watermelondb.WatermelonDBPackage; import com.nozbe.watermelondb.WatermelonDBPackage;
import com.reactnativecommunity.viewpager.RNCViewPagerPackage; import com.reactnativecommunity.viewpager.RNCViewPagerPackage;
import com.wix.reactnativekeyboardinput.KeyboardInputPackage; import com.wix.reactnativekeyboardinput.KeyboardInputPackage;
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;
import org.unimodules.adapters.react.ModuleRegistryAdapter; import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider; import org.unimodules.adapters.react.ReactModuleRegistryProvider;
@ -28,7 +21,7 @@ import java.util.List;
import chat.rocket.reactnative.generated.BasePackageList; import chat.rocket.reactnative.generated.BasePackageList;
public class MainApplication extends Application implements ReactApplication, INotificationsApplication { public class MainApplication extends Application implements ReactApplication {
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), null); private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), null);
@ -75,15 +68,4 @@ public class MainApplication extends Application implements ReactApplication, IN
super.onCreate(); super.onCreate();
SoLoader.init(this, /* native exopackage */ false); SoLoader.init(this, /* native exopackage */ false);
} }
@Override
public IPushNotification getPushNotification(Context context, Bundle bundle, AppLifecycleFacade defaultFacade, AppLaunchHelper defaultAppLaunchHelper) {
return new CustomPushNotification(
context,
bundle,
defaultFacade,
defaultAppLaunchHelper,
new JsIOHelper()
);
}
} }

View File

@ -1,48 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="chat.rocket.reactnative"> package="chat.rocket.reactnative">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:name=".MainApplication" android:name=".MainPlayApplication"
android:label="@string/app_name" android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
tools:replace="android:name"
> >
<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="@style/BootTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="go.rocket.chat" />
<data android:scheme="https" android:host="jitsi.rocket.chat" />
<data android:scheme="rocketchat" android:host="room" />
<data android:scheme="rocketchat" android:host="auth" />
<data android:scheme="rocketchat" android:host="jitsi.rocket.chat" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver <receiver
android:name=".ReplyBroadcast" android:name=".ReplyBroadcast"
android:enabled="true" android:enabled="true"
@ -52,20 +20,6 @@
android:enabled="true" android:enabled="true"
android:exported="false" > android:exported="false" >
</receiver> </receiver>
<activity
android:noHistory="true"
android:name=".share.ShareActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/share_extension_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<meta-data <meta-data
android:name="com.bugsnag.android.API_KEY" android:name="com.bugsnag.android.API_KEY"
android:value="${BugsnagAPIKey}" /> android:value="${BugsnagAPIKey}" />

View File

@ -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()
);
}
}

View File

@ -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. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase()
def isPlay = !taskRequests.contains("foss")
ext { ext {
buildToolsVersion = "29.0.2" buildToolsVersion = "29.0.2"
minSdkVersion = 23 minSdkVersion = 23
@ -8,7 +15,11 @@ buildscript {
glideVersion = "4.9.0" glideVersion = "4.9.0"
kotlin_version = "1.3.50" kotlin_version = "1.3.50"
supportLibVersion = "28.0.0" 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 { repositories {
mavenLocal() mavenLocal()
google() google()
@ -18,9 +29,6 @@ buildscript {
} }
} }
def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase()
def isPlay = !taskRequests.contains("foss")
dependencies { dependencies {
if (isPlay) { if (isPlay) {
classpath 'com.google.gms:google-services:4.2.0' classpath 'com.google.gms:google-services:4.2.0'
@ -40,7 +48,11 @@ allprojects {
url("$rootDir/../node_modules/react-native/android") url("$rootDir/../node_modules/react-native/android")
} }
maven { 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() google()

View File

@ -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"
}

View File

@ -12772,8 +12772,8 @@ react-native-iphone-x-helper@^1.0.3, react-native-iphone-x-helper@^1.2.1:
integrity sha512-/VbpIEp8tSNNHIvstuA3Swx610whci1Zpc9mqNkqn14DkMbw+ORviln2u0XyHG1kPvvwTNGZY6QpeFwxYaSdbQ== integrity sha512-/VbpIEp8tSNNHIvstuA3Swx610whci1Zpc9mqNkqn14DkMbw+ORviln2u0XyHG1kPvvwTNGZY6QpeFwxYaSdbQ==
react-native-jitsi-meet@RocketChat/react-native-jitsi-meet: react-native-jitsi-meet@RocketChat/react-native-jitsi-meet:
version "2.3.1" version "2.4.0"
resolved "https://codeload.github.com/RocketChat/react-native-jitsi-meet/tar.gz/39c2c36c82b2dbb2f80c58aa788e15b526681c65" resolved "https://codeload.github.com/RocketChat/react-native-jitsi-meet/tar.gz/806ea2fb24d8fce90d983766af15b9fc71b3bb9a"
react-native-keyboard-input@RocketChat/react-native-keyboard-input: react-native-keyboard-input@RocketChat/react-native-keyboard-input:
version "6.0.0" version "6.0.0"