Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: forward port a bunch of deprecations / fix android hot reload #8139

Merged
merged 4 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ private boolean isAppDebuggable() throws Exception {
}

@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
public void invalidate() {
super.invalidate();
Log.d(TAG, "instance-destroyed");

Iterator appCheckListenerIterator = mAppCheckListeners.entrySet().iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static FirebaseApp readableMapToFirebaseApp(

if (appConfig.hasKey("automaticDataCollectionEnabled")) {
firebaseApp.setDataCollectionDefaultEnabled(
appConfig.getBoolean("automaticDataCollectionEnabled"));
Boolean.valueOf(appConfig.getBoolean("automaticDataCollectionEnabled")));
}

if (appConfig.hasKey("automaticResourceManagement")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,26 @@ public final ExecutorService getTransactionalExecutor(String identifier) {
return executorService.getTransactionalExecutor(identifier);
}

@Override
@CallSuper

// This is no longer called as of react-native 0.74 and is only here for
// compatibility with older versions. It delegates to thew new `invalidate`
// method, which all modules should implement now
// Remove this method when minimum supported react-native is 0.74
/** @noinspection removal*/
@SuppressWarnings({"deprecation", "removal"})
@Deprecated
public void onCatalystInstanceDestroy() {
// This should call the child class invalidate, which will then call super.invalidate,
// and everything will work correctly up and down the inheritance hierarchy to shut down
invalidate();
}

// This should have an @Override annotation but we cannot do
// that until our minimum supported react-native version is 0.74, since the
// method did not exist before then
@CallSuper
public void invalidate() {
super.invalidate();
executorService.shutdown();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
*/

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Point;
Expand Down Expand Up @@ -181,6 +182,7 @@ public static boolean isAppInForeground(Context context) {
return false;
}

@SuppressLint("DiscouragedApi")
public static int getResId(Context ctx, String resName) {
int resourceId = ctx.getResources().getIdentifier(resName, "string", ctx.getPackageName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public void initialize() {
}

@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
public void invalidate() {
super.invalidate();
Log.d(TAG, "instance-destroyed");

Iterator authListenerIterator = mAuthListeners.entrySet().iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class ReactNativeFirebaseDatabaseQueryModule extends ReactNativeFirebaseM
}

@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
public void invalidate() {
super.invalidate();

Iterator refIterator = queryMap.entrySet().iterator();
while (refIterator.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public class ReactNativeFirebaseDynamicLinksModule extends ReactNativeFirebaseMo
}

@Override
public void onCatalystInstanceDestroy() {
public void invalidate() {
getReactApplicationContext().removeActivityEventListener(this);
getReactApplicationContext().addLifecycleEventListener(this);
super.onCatalystInstanceDestroy();
super.invalidate();
}

@ReactMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class ReactNativeFirebaseFirestoreCollectionModule extends ReactNativeFir
}

@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
public void invalidate() {
super.invalidate();

for (int i = 0, size = collectionSnapshotListeners.size(); i < size; i++) {
int key = collectionSnapshotListeners.keyAt(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class ReactNativeFirebaseFirestoreDocumentModule extends ReactNativeFireb
}

@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
public void invalidate() {
super.invalidate();

for (int i = 0, size = documentSnapshotListeners.size(); i < size; i++) {
int key = documentSnapshotListeners.keyAt(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ReactNativeFirebaseFirestoreTransactionModule extends ReactNativeFi
}

@Override
public void onCatalystInstanceDestroy() {
public void invalidate() {
for (int i = 0, size = transactionHandlers.size(); i < size; i++) {
int key = transactionHandlers.keyAt(i);
ReactNativeFirebaseFirestoreTransactionHandler transactionHandler =
Expand All @@ -57,7 +57,7 @@ public void onCatalystInstanceDestroy() {
}

transactionHandlers.clear();
super.onCatalystInstanceDestroy();
super.invalidate();
}

@ReactMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class ReactNativeFirebasePerfModule extends ReactNativeFirebaseModule {
}

@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
public void invalidate() {
super.invalidate();
module.onTearDown();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static com.google.firebase.remoteconfig.FirebaseRemoteConfig.*;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
Expand Down Expand Up @@ -154,6 +155,7 @@ Map<String, Object> getAllValuesForApp(String appName) {
return configValuesMap;
}

@SuppressLint("DiscouragedApi")
private int getXmlResourceIdByName(String name) {
String packageName = getApplicationContext().getPackageName();
return getApplicationContext().getResources().getIdentifier(name, "xml", packageName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class ReactNativeFirebaseConfigModule extends ReactNativeFirebaseModule {
}

@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
public void invalidate() {
super.invalidate();

Iterator<Map.Entry<String, ConfigUpdateListenerRegistration>> configRegistrationsIterator =
mConfigUpdateRegistrations.entrySet().iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
}

@Override
public void onCatalystInstanceDestroy() {
public void invalidate() {
ReactNativeFirebaseStorageTask.destroyAllTasks();
super.onCatalystInstanceDestroy();
super.invalidate();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/.detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
'android.debug': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest lintDebug -DtestBuildType=debug && cd ..',
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest lintDebug -DtestBuildType=debug --warning-mode all && cd ..',
reversePorts: [
8080,
8081,
Expand Down
6 changes: 3 additions & 3 deletions tests/android/app/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'conn

reports {
xml.required = true
html.destination htmlOutDir
html.outputLocation = htmlOutDir
}

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
Expand Down Expand Up @@ -98,7 +98,7 @@ task jacocoUnitTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest'])

reports {
xml.required = true
html.destination htmlOutDir
html.outputLocation = htmlOutDir
}

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
Expand All @@ -123,7 +123,7 @@ task jacocoAndroidTestReport(type: JacocoReport) {

reports {
xml.required = true
html.destination htmlOutDir
html.outputLocation = htmlOutDir
}

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
Expand Down
Loading