diff --git a/app/android/app/src/main/java/com/awesomeproject/MainActivity.java b/app/android/app/src/main/java/com/awesomeproject/MainActivity.java index 7cd8353e1..ef4328e8b 100644 --- a/app/android/app/src/main/java/com/awesomeproject/MainActivity.java +++ b/app/android/app/src/main/java/com/awesomeproject/MainActivity.java @@ -22,11 +22,6 @@ import io.tradle.nfc.RNPassportReaderModule; public class MainActivity extends ReactActivity { - // private NfcAdapter nfcAdapter; - // private PendingIntent pendingIntent; - // private IntentFilter[] intentFilters; - // private String[][] techList; - /** * Returns the name of the main component registered from JavaScript. This is used to schedule * rendering of the component. @@ -51,70 +46,6 @@ public class MainActivity extends ReactActivity { ); } - // @Override - // protected void onCreate(Bundle savedInstanceState) { - // super.onCreate(savedInstanceState); - // Log.d("MainActivity", "onCreate"); - - // nfcAdapter = NfcAdapter.getDefaultAdapter(this); - - // Intent nfcIntent = new Intent(this, getClass()); - // nfcIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); - - // pendingIntent = PendingIntent.getActivity(this, 0, nfcIntent, PendingIntent.FLAG_IMMUTABLE); - - // intentFilters = new IntentFilter[] { - // new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED), - // }; - - // techList = new String[][] { - // new String[] { IsoDep.class.getName() } - // }; - // } - - // @Override - // protected void onResume() { - // super.onResume(); - // Log.d("MainActivity", "onResume"); - // if (nfcAdapter != null) { - // nfcAdapter.enableForegroundDispatch(this, pendingIntent, intentFilters, techList); - // } - // } - - // @Override - // protected void onPause() { - // super.onPause(); - // Log.d("MainActivity", "onPause"); - // if (nfcAdapter != null) { - // nfcAdapter.disableForegroundDispatch(this); - // } - // } - - // @Override - // public void onNewIntent(Intent intent) { - // super.onNewIntent(intent); - // Log.d("MainActivity", "Intent: " + intent.toString()); - - // // Check if this intent is a NFC discovery intent - // if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { - // try { - // // Get the PassportReaderModule instance from the ReactApplicationContext - // ReactApplication application = (ReactApplication) getApplication(); - // ReactNativeHost host = application.getReactNativeHost(); - // ReactInstanceManager reactInstanceManager = host.getReactInstanceManager(); - // ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); - // Log.d("MainActivity", "ReactContext: " + reactContext); - // PassportReaderModule passportReaderModule = reactContext.getNativeModule(PassportReaderModule.class); - // Log.d("MainActivity", "PassportReaderModule: " + passportReaderModule); - - // // Call the method in the PassportReaderModule that handles the NFC intent - // passportReaderModule.handleNFCIntent(intent); - // } catch (Exception e) { - // Log.e("MainActivity", "Error handling NFC intent", e); - // } - // } - // } - @Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); diff --git a/app/android/app/src/main/java/com/awesomeproject/MainApplication.java b/app/android/app/src/main/java/com/awesomeproject/MainApplication.java index c18e36b3f..3535e5a31 100644 --- a/app/android/app/src/main/java/com/awesomeproject/MainApplication.java +++ b/app/android/app/src/main/java/com/awesomeproject/MainApplication.java @@ -8,46 +8,43 @@ import com.facebook.react.ReactPackage; import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.defaults.DefaultReactNativeHost; import com.facebook.soloader.SoLoader; -import java.util.List; import io.tradle.nfc.RNPassportReaderPackage; - -// import com.awesomeproject.PassportReaderModule; -// import com.awesomeproject.react_native_passport_reader.RNPassportReaderPackage; - +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; - } + private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost( + this + ) { + @Override + public boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; + } - @Override - protected List getPackages() { - @SuppressWarnings("UnnecessaryLocalVariable") - List packages = new PackageList(this).getPackages(); - // Packages that cannot be autolinked yet can be added manually here, for example: - // packages.add(new RNPassportReaderPackage()); - return packages; - } + @Override + protected List getPackages() { + @SuppressWarnings("UnnecessaryLocalVariable") + List packages = new PackageList(this).getPackages(); + // Packages that cannot be autolinked yet can be added manually here, for example: + // packages.add(new RNPassportReaderPackage()); + return packages; + } - @Override - protected String getJSMainModuleName() { - return "index"; - } + @Override + protected String getJSMainModuleName() { + return "index"; + } - @Override - protected boolean isNewArchEnabled() { - return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; - } + @Override + protected boolean isNewArchEnabled() { + return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; + } - @Override - protected Boolean isHermesEnabled() { - return BuildConfig.IS_HERMES_ENABLED; - } - }; + @Override + protected Boolean isHermesEnabled() { + return BuildConfig.IS_HERMES_ENABLED; + } + }; @Override public ReactNativeHost getReactNativeHost() { @@ -57,11 +54,14 @@ public class MainApplication extends Application implements ReactApplication { @Override public void onCreate() { super.onCreate(); - SoLoader.init(this, /* native exopackage */ false); + 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()); + ReactNativeFlipper.initializeFlipper( + this, + getReactNativeHost().getReactInstanceManager() + ); } } diff --git a/app/android/app/src/main/java/com/awesomeproject/MyAppPackage.java b/app/android/app/src/main/java/com/awesomeproject/MyAppPackage.java deleted file mode 100644 index 31a943f8a..000000000 --- a/app/android/app/src/main/java/com/awesomeproject/MyAppPackage.java +++ /dev/null @@ -1,28 +0,0 @@ -// package com.awesomeproject; // replace your-app-name with your app’s name -// import com.facebook.react.ReactPackage; -// import com.facebook.react.bridge.NativeModule; -// import com.facebook.react.bridge.ReactApplicationContext; -// import com.facebook.react.uimanager.ViewManager; - -// import java.util.ArrayList; -// import java.util.Collections; -// import java.util.List; - -// public class MyAppPackage implements ReactPackage { - -// @Override -// public List createViewManagers(ReactApplicationContext reactContext) { -// return Collections.emptyList(); -// } - -// @Override -// public List createNativeModules( -// ReactApplicationContext reactContext) { -// List modules = new ArrayList<>(); - -// modules.add(new PassportReaderModule(reactContext)); - -// return modules; -// } - -// } \ No newline at end of file diff --git a/app/android/app/src/main/java/com/awesomeproject/PassportReaderModule.java b/app/android/app/src/main/java/com/awesomeproject/PassportReaderModule.java deleted file mode 100644 index 864a66b14..000000000 --- a/app/android/app/src/main/java/com/awesomeproject/PassportReaderModule.java +++ /dev/null @@ -1,46 +0,0 @@ -// package com.awesomeproject; // replace your-apps-package-name with your app’s package name -// import com.facebook.react.bridge.NativeModule; -// import com.facebook.react.bridge.ReactApplicationContext; -// import com.facebook.react.bridge.ReactContext; -// import com.facebook.react.bridge.ReactContextBaseJavaModule; -// import com.facebook.react.bridge.ReactMethod; -// import java.util.Map; -// import java.util.HashMap; -// import android.util.Log; -// import com.facebook.react.modules.core.DeviceEventManagerModule; -// import com.facebook.react.bridge.ReactContext; -// import android.content.Intent; - -// public class PassportReaderModule extends ReactContextBaseJavaModule { -// private final ReactApplicationContext reactContext; - -// PassportReaderModule(ReactApplicationContext context) { -// super(context); -// this.reactContext = context; -// } - -// // add to PassportReaderModule.java -// @Override -// public String getName() { -// return "PassportReaderModule"; -// } - -// @ReactMethod -// public void createPassportEvent(String name, String location) { -// Log.d("PassportReaderModule", "Create event called with name: " + name -// + " and location: " + location); -// } - -// public void handleNFCIntent(Intent intent) { -// var nfcData = "salut"; -// Log.d("PassportReaderModule", "handleNFCIntent"); - -// // Handle the NFC intent, extract the data from the NFC tag -// // Then send an event to React Native with the read NFC data -// this.reactContext -// .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) -// .emit("NFCDataRead", nfcData); -// } - -// } -