Skip to content

Commit

Permalink
Merge branch 'translations-build-step' of https://github.com/CovidShi…
Browse files Browse the repository at this point in the history
…eld/mobile into translations-build-step
  • Loading branch information
jordanAtShopify committed Jun 24, 2020
2 parents a6780a8 + d55032f commit 77f596e
Show file tree
Hide file tree
Showing 100 changed files with 4,670 additions and 4,113 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ APP_VERSION_NAME=1.0
SUBMIT_URL=https://submission.covidshield.app
RETRIEVE_URL=https://retrieval.covidshield.app
HMAC_KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
REGION=302

TEST_MODE=true
MOCK_SERVER=false
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ APP_VERSION_NAME=1.0
SUBMIT_URL=https://submission.covidshield.app
RETRIEVE_URL=https://retrieval.covidshield.app
HMAC_KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
REGION=302

TEST_MODE=false
MOCK_SERVER=false
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ Follow the steps outlined in [React Native Development Environment Setup](https:

#### iOS

- XCode 11.5 or greater
- Xcode 11.5 or greater
- iOS device or simulator with iOS 13.5 or greater
- [Bundler](https://bundler.io/) to install the right version of CocoaPods locally
- You also need a provisioning profile with the Exposure Notification entitlement. For more information, visit https://developer.apple.com/documentation/exposurenotification.

#### Android

- Android device or simulator with the ability to run the latest version of Google Play Services.
- Android device with the ability to run the latest version of Google Play Services or Google Play Services Beta. Sign up for beta program here https://developers.google.com/android/guides/beta-program.
- You also need a whitelisted APPLICATION_ID that will be used to publish to Google Play. You could use APPLICATION_ID from [Google Sample App](https://github.com/google/exposure-notifications-android) for testing purposes `"com.google.android.apps.exposurenotification"`. Go to [Environment config](https://github.com/CovidShield/mobile#3-environment-config) to see how to change APPLICATION_ID.

#### 1. Check out the repository

Expand Down Expand Up @@ -111,7 +113,7 @@ yarn run-android

You can also build the app with native development tool:

- For iOS, using XCode by opening the `CovidShield.xcworkspace` file in the `ios` folder.
- For iOS, using Xcode by opening the `CovidShield.xcworkspace` file in the `ios` folder.
- For Android, using Android Studio by opening `android` folder.

### Development mode
Expand Down Expand Up @@ -147,6 +149,7 @@ yarn generate-translations
3. Regenerate the translations `yarn generate-translations`.
4. Add the new option in [src/components/LanguageToggle.tsx](./src/components/LanguageToggle.tsx).
5. Add the new option in [src/screens/language/Language.tsx](./src/screens/language/Language.tsx).
6. Add the new option in Xcode `Localizations` settings (Project -> CovidShield -> Info tab -> Localizations) and make sure `Launch Screen.storyboard` is checked.

## Who built COVID Shield?

Expand Down
28 changes: 14 additions & 14 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ android {
}
buildTypes {
debug {
applicationIdSuffix ".debug"
minifyEnabled false
}
release {
minifyEnabled enableProguardInReleaseBuilds
Expand Down Expand Up @@ -187,30 +187,30 @@ android {

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])

implementation "androidx.core:core-ktx:$androidXCoreKtxVersion"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:$androidXSwipeRefreshLayoutVersion"

//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules

implementation 'com.google.android.gms:play-services-base:17.2.1'
implementation 'com.google.android.gms:play-services-tasks:17.0.2'

implementation "androidx.core:core-ktx:1.0.1"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation "com.google.android.gms:play-services-base:$googlePlayServicesBaseVersion"
implementation "com.google.android.gms:play-services-tasks:$googlePlayServicesTasksVersion"

implementation "com.google.code.gson:gson:2.8.6"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesAndroidVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesCoreVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesPlayServicesVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
debugImplementation("com.facebook.flipper:flipper:$facebookFlipperVersion") {
exclude group: 'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:$facebookFlipperVersion") {
exclude group: 'com.facebook.flipper'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
debugImplementation("com.facebook.flipper:flipper-network-plugin:$facebookFlipperVersion") {
exclude group: 'com.facebook.flipper'
}

Expand Down
Binary file modified android/app/libs/play-services-nearby-18.0.2-eap.aar
Binary file not shown.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">

<activity
android:name="app.covidshield.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
Expand Down
Binary file modified android/app/src/main/assets/animation/images/img_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions android/app/src/main/java/app/covidshield/CustomPackage.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
package app.covidshield

import android.content.Intent
import android.view.View
import app.covidshield.module.CovidShieldModule
import app.covidshield.module.ExposureNotificationModule
import app.covidshield.module.PushNotificationModule
import app.covidshield.utils.ActivityResultHelper
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ReactShadowNode
import com.facebook.react.uimanager.ViewManager

class CustomPackage : ReactPackage {
class CustomPackage : ReactPackage, ActivityResultHelper {

override fun createNativeModules(reactContext: ReactApplicationContext): MutableList<NativeModule> = mutableListOf(
ExposureNotificationModule(reactContext),
PushNotificationModule(reactContext),
CovidShieldModule(reactContext)
)
private var nativeModules: MutableList<NativeModule>? = null

override fun createNativeModules(reactContext: ReactApplicationContext): MutableList<NativeModule> {
val nativeModules = mutableListOf<NativeModule>(
ExposureNotificationModule(reactContext),
PushNotificationModule(reactContext),
CovidShieldModule(reactContext)
)
this.nativeModules = nativeModules
return nativeModules
}

override fun createViewManagers(reactContext: ReactApplicationContext): MutableList<ViewManager<View, ReactShadowNode<*>>> = mutableListOf()

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
nativeModules?.mapNotNull { it as? ActivityResultHelper }?.forEach { it.onActivityResult(requestCode, resultCode, data) }
}
}
23 changes: 0 additions & 23 deletions android/app/src/main/java/app/covidshield/MainActivity.java

This file was deleted.

28 changes: 28 additions & 0 deletions android/app/src/main/java/app/covidshield/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package app.covidshield

import android.content.Intent
import android.os.Bundle
import app.covidshield.utils.ActivityResultHelper
import com.facebook.react.ReactActivity
import org.devio.rn.splashscreen.SplashScreen

class MainActivity : ReactActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
SplashScreen.show(this)
super.onCreate(savedInstanceState)
}

/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String? {
return "CovidShield"
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
reactInstanceManager.packages.mapNotNull { it as? ActivityResultHelper }.forEach { it.onActivityResult(requestCode, resultCode, data) }
}
}
111 changes: 55 additions & 56 deletions android/app/src/main/java/app/covidshield/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,65 @@

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(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 MyReactNativePackage());
packages.add(new CustomPackage());
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 CustomPackage());
return packages;
}

@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
protected String getJSMainModuleName() {
return "index";
}
};

/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("app.covidshield.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("app.covidshield.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package app.covidshield.extensions

import java.io.File

fun File.cleanup() {
try {
deleteOnExit()
} catch (_: Exception) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package app.covidshield.extensions

import android.util.Log
import app.covidshield.BuildConfig

fun Any.log(msg: String?, tag: String = this::class.java.simpleName) {
if (BuildConfig.DEBUG) {
Log.d(tag, msg)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package app.covidshield.extensions

import com.facebook.react.bridge.Promise
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

fun Promise.rejectOnException(block: () -> Unit) {
return try {
block.invoke()
} catch (e: Exception) {
reject(e)
}
fun Promise.launch(scope: CoroutineScope, block: suspend CoroutineScope.() -> Unit) {
scope.launch(
context = CoroutineExceptionHandler { _, exception ->
this@launch.reject(exception)
},
block = block
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import org.json.JSONException
import org.json.JSONObject

fun List<Any>.toWritableArray(): WritableArray {
return convertJsonToArray(this.toJson().parse(JSONArray::class.java))
val writableArray = WritableNativeArray()
forEach { writableArray.pushMap(it.toWritableMap()) }
return writableArray
}

fun Any.toWritableMap(): WritableMap {
return convertJsonToMap(JSONObject(toJson()))
}

fun <T> ReadableMap.parse(classOfT: Class<T>): T {
return convertMapToJson(this)!!.toJson().parse(classOfT)
return convertMapToJson(this)!!.toString().parse(classOfT)
}

fun <T> ReadableArray.parse(classOfT: Class<T>): List<T> {
Expand Down
Loading

0 comments on commit 77f596e

Please sign in to comment.