[IMPROVEMENT] Add F-Droid modules as AdditionalModules (#2530)

* [IMPROVEMENT] Add F-Droid modules as AdditionalModules

* Fix missing import
This commit is contained in:
Diego Mello 2020-10-13 09:41:03 -03:00 committed by GitHub
parent 91ad21092e
commit 85f79e7f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 19 deletions

View File

@ -236,6 +236,9 @@ dependencies {
implementation project(':reactnativenotifications')
implementation project(":reactnativekeyboardinput")
implementation project(':@react-native-community_viewpager')
playImplementation project(':@react-native-firebase_app')
playImplementation project(':@react-native-firebase_analytics')
playImplementation project(':@react-native-firebase_crashlytics')
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules

View File

@ -0,0 +1,14 @@
package chat.rocket.reactnative;
import android.app.Application;
import com.facebook.react.ReactPackage;
import java.util.Arrays;
import java.util.List;
public class AdditionalModules {
public List<ReactPackage> getAdditionalModules(Application application) {
return Arrays.<ReactPackage>asList();
}
}

View File

@ -3,38 +3,31 @@ package chat.rocket.reactnative;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.Nullable;
import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import chat.rocket.reactnative.generated.BasePackageList;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import org.unimodules.core.interfaces.SingletonModule;
import com.wix.reactnativenotifications.RNNotificationsPackage;
import com.nozbe.watermelondb.WatermelonDBPackage;
import com.reactnativecommunity.viewpager.RNCViewPagerPackage;
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 com.wix.reactnativekeyboardinput.KeyboardInputPackage;
import com.nozbe.watermelondb.WatermelonDBPackage;
import com.reactnativecommunity.viewpager.RNCViewPagerPackage;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import java.util.Arrays;
import java.util.List;
import chat.rocket.reactnative.generated.BasePackageList;
public class MainApplication extends Application implements ReactApplication, INotificationsApplication {
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), null);
@ -49,17 +42,15 @@ public class MainApplication extends Application implements ReactApplication, IN
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
if (!BuildConfig.FDROID_BUILD) {
packages.add(new RNNotificationsPackage(MainApplication.this));
}
packages.add(new KeyboardInputPackage(MainApplication.this));
packages.add(new WatermelonDBPackage());
packages.add(new RNCViewPagerPackage());
// packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
List<ReactPackage> unimodules = Arrays.<ReactPackage>asList(
new ModuleRegistryAdapter(mModuleRegistryProvider)
);
packages.addAll(unimodules);
List<ReactPackage> additionalModules = new AdditionalModules().getAdditionalModules(MainApplication.this);
packages.addAll(additionalModules);
return packages;
}

View File

@ -0,0 +1,24 @@
package chat.rocket.reactnative;
import android.app.Application;
import com.facebook.react.ReactPackage;
import com.wix.reactnativenotifications.RNNotificationsPackage;
import java.util.Arrays;
import java.util.List;
import io.invertase.firebase.analytics.ReactNativeFirebaseAnalyticsPackage;
import io.invertase.firebase.app.ReactNativeFirebaseAppPackage;
import io.invertase.firebase.crashlytics.ReactNativeFirebaseCrashlyticsPackage;
public class AdditionalModules {
public List<ReactPackage> getAdditionalModules(Application application) {
return Arrays.<ReactPackage>asList(
new ReactNativeFirebaseAnalyticsPackage(),
new ReactNativeFirebaseAppPackage(),
new ReactNativeFirebaseCrashlyticsPackage(),
new RNNotificationsPackage(application)
);
}
}

View File

@ -10,5 +10,11 @@ include ':reactnativekeyboardinput'
project(':reactnativekeyboardinput').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keyboard-input/lib/android')
include ':@react-native-community_viewpager'
project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android')
include ':@react-native-firebase_app'
project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/app/android')
include ':@react-native-firebase_analytics'
project(':@react-native-firebase_analytics').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/analytics/android')
include ':@react-native-firebase_crashlytics'
project(':@react-native-firebase_crashlytics').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/crashlytics/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

View File

@ -15,6 +15,21 @@ module.exports = {
android: null,
ios: null
}
},
'@react-native-firebase/app': {
platforms: {
android: null
}
},
'@react-native-firebase/analytics': {
platforms: {
android: null
}
},
'@react-native-firebase/crashlytics': {
platforms: {
android: null
}
}
}
};