clean java

This commit is contained in:
0xturboblitz
2023-08-22 20:22:49 +02:00
parent 6a8df66865
commit ef634dd435
4 changed files with 34 additions and 177 deletions

View File

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

View File

@@ -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<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> 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<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> 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()
);
}
}

View File

@@ -1,28 +0,0 @@
// package com.awesomeproject; // replace your-app-name with your apps 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<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
// return Collections.emptyList();
// }
// @Override
// public List<NativeModule> createNativeModules(
// ReactApplicationContext reactContext) {
// List<NativeModule> modules = new ArrayList<>();
// modules.add(new PassportReaderModule(reactContext));
// return modules;
// }
// }

View File

@@ -1,46 +0,0 @@
// package com.awesomeproject; // replace your-apps-package-name with your apps 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);
// }
// }