-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert: React Native 73 Upgrade (#2439)
* Revert: 2426 part 2 * Revert "chore: Working upgrade" This reverts commit b12eb04. * chore: Put back Privacy Info
- Loading branch information
Showing
214 changed files
with
1,964 additions
and
2,631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
projects/Mallard/android/app/src/debug/java/com/guardian/editions/ReactNativeFlipper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root | ||
* directory of this source tree. | ||
*/ | ||
package com.rndiffapp; | ||
|
||
import android.content.Context; | ||
import com.facebook.flipper.android.AndroidFlipperClient; | ||
import com.facebook.flipper.android.utils.FlipperUtils; | ||
import com.facebook.flipper.core.FlipperClient; | ||
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; | ||
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; | ||
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; | ||
import com.facebook.flipper.plugins.inspector.DescriptorMapping; | ||
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; | ||
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; | ||
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; | ||
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; | ||
import com.facebook.react.ReactInstanceEventListener; | ||
import com.facebook.react.ReactInstanceManager; | ||
import com.facebook.react.bridge.ReactContext; | ||
import com.facebook.react.modules.network.NetworkingModule; | ||
import okhttp3.OkHttpClient; | ||
|
||
/** | ||
* Class responsible of loading Flipper inside your React Native application. This is the debug | ||
* flavor of it. Here you can add your own plugins and customize the Flipper setup. | ||
*/ | ||
public class ReactNativeFlipper { | ||
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { | ||
if (FlipperUtils.shouldEnableFlipper(context)) { | ||
final FlipperClient client = AndroidFlipperClient.getInstance(context); | ||
|
||
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); | ||
client.addPlugin(new DatabasesFlipperPlugin(context)); | ||
client.addPlugin(new SharedPreferencesFlipperPlugin(context)); | ||
client.addPlugin(CrashReporterPlugin.getInstance()); | ||
|
||
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); | ||
NetworkingModule.setCustomClientBuilder( | ||
new NetworkingModule.CustomClientBuilder() { | ||
@Override | ||
public void apply(OkHttpClient.Builder builder) { | ||
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); | ||
} | ||
}); | ||
client.addPlugin(networkFlipperPlugin); | ||
client.start(); | ||
|
||
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized | ||
// Hence we run if after all native modules have been initialized | ||
ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); | ||
if (reactContext == null) { | ||
reactInstanceManager.addReactInstanceEventListener( | ||
new ReactInstanceEventListener() { | ||
@Override | ||
public void onReactContextInitialized(ReactContext reactContext) { | ||
reactInstanceManager.removeReactInstanceEventListener(this); | ||
reactContext.runOnNativeModulesQueueThread( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
client.addPlugin(new FrescoFlipperPlugin()); | ||
} | ||
}); | ||
} | ||
}); | ||
} else { | ||
client.addPlugin(new FrescoFlipperPlugin()); | ||
} | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
projects/Mallard/android/app/src/main/java/com/guardian/editions/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.guardian.editions; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.pm.ActivityInfo; | ||
import android.content.res.Configuration; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
|
||
import com.facebook.react.ReactActivityDelegate; | ||
import com.facebook.react.ReactActivity; | ||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; | ||
import com.facebook.react.defaults.DefaultReactActivityDelegate; | ||
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView; | ||
|
||
import org.devio.rn.splashscreen.SplashScreen; | ||
|
||
public class MainActivity extends ReactActivity { | ||
|
||
@SuppressLint("SourceLockedOrientationActivity") | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
SplashScreen.show(this); | ||
super.onCreate(null); | ||
|
||
if(!isTablet()) { | ||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
} | ||
} | ||
|
||
private boolean isTablet() { | ||
return getResources().getBoolean(R.bool.is_tablet); | ||
} | ||
|
||
/** | ||
* Returns the name of the main component registered from JavaScript. | ||
* This is used to schedule rendering of the component. | ||
*/ | ||
@Override | ||
protected String getMainComponentName() { | ||
return "Mallard"; | ||
} | ||
|
||
/** | ||
* Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link | ||
* DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React | ||
* (aka React 18) with two boolean flags. | ||
*/ | ||
@Override | ||
protected ReactActivityDelegate createReactActivityDelegate() { | ||
return new DefaultReactActivityDelegate( | ||
this, | ||
getMainComponentName(), | ||
// If you opted-in for the New Architecture, we enable the Fabric Renderer. | ||
DefaultNewArchitectureEntryPoint.getFabricEnabled()); | ||
} | ||
|
||
// There is a known issue with androix 1.1.0 which cause webview to crash | ||
// This is a workaround for this bug (https://github.com/react-native-webview/react-native-webview/issues/858) | ||
// androidX bug: https://issuetracker.google.com/issues/141132133 | ||
@Override | ||
public void applyOverrideConfiguration(Configuration overrideConfiguration) { | ||
if(Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT <= 25) { | ||
return; | ||
} | ||
super.applyOverrideConfiguration(overrideConfiguration); | ||
} | ||
} |
55 changes: 0 additions & 55 deletions
55
projects/Mallard/android/app/src/main/java/com/guardian/editions/MainActivity.kt
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
projects/Mallard/android/app/src/main/java/com/guardian/editions/MainApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.guardian.editions; | ||
|
||
import android.app.Application; | ||
|
||
import com.guardian.editions.releasestream.ReleaseStreamPackage; | ||
|
||
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.ReactNativeHost; | ||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; | ||
import com.facebook.react.defaults.DefaultReactNativeHost; | ||
import com.facebook.react.shell.MainReactPackage; | ||
import com.facebook.soloader.SoLoader; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class MainApplication extends Application implements ReactApplication { | ||
|
||
private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) { | ||
@Override | ||
public boolean getUseDeveloperSupport() { | ||
return BuildConfig.DEBUG; | ||
} | ||
|
||
@Override | ||
protected List<ReactPackage> getPackages() { | ||
@SuppressWarnings("UnnecessaryLocalVariable") | ||
List<ReactPackage> packages = new PackageList(this).getPackages(); | ||
|
||
packages.add(new ReleaseStreamPackage()); | ||
|
||
// packages.add(new MainReactPackage(), | ||
// packages.add(new RNDeviceInfo()); | ||
// packages.add(new NetInfoPackage()); | ||
// packages.add(new ReactNativePushNotificationPackage()); | ||
// packages.add(new ReactNativeConfigPackage()); | ||
// packages.add(new KeychainPackage()); | ||
// packages.add(new RNCMaskedViewPackage()); | ||
// packages.add(new RNCWebViewPackage()); | ||
// packages.add(new RNZipArchivePackage()); | ||
// packages.add(new SvgPackage()); | ||
// packages.add(new AsyncStoragePackage()); | ||
// packages.add(new RNFetchBlobPackage()); | ||
// packages.add(new RNScreensPackage()); | ||
// packages.add(new RNGestureHandlerPackage()); | ||
return packages; | ||
} | ||
|
||
@Override | ||
protected String getJSMainModuleName() { | ||
return "index"; | ||
} | ||
|
||
@Override | ||
protected boolean isNewArchEnabled() { | ||
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; | ||
} | ||
@Override | ||
protected Boolean isHermesEnabled() { | ||
return BuildConfig.IS_HERMES_ENABLED; | ||
} | ||
|
||
}; | ||
|
||
@Override | ||
public ReactNativeHost getReactNativeHost() { | ||
return mReactNativeHost; | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
SoLoader.init(this, /* native exopackage */ false); | ||
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { | ||
// If you opted-in for the New Architecture, we load the native entry point for this app. | ||
DefaultNewArchitectureEntryPoint.load(); | ||
} | ||
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
projects/Mallard/android/app/src/main/java/com/guardian/editions/MainApplication.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.