Skip to content

Commit

Permalink
Merge branch 'master' into feat/deployment-firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
esmeetewinkel authored Apr 2, 2024
2 parents 178795f + 6f3cc05 commit eabc2da
Show file tree
Hide file tree
Showing 24 changed files with 451 additions and 166 deletions.
22 changes: 2 additions & 20 deletions .github/workflows/reusable-android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# Configuration
##################################################################################
env:
APP_ID: ${{vars.APP_ID}}
APP_NAME: ${{vars.APP_NAME}}
DEPLOYMENT_NAME: ${{vars.DEPLOYMENT_NAME}}
APP_CODE_BRANCH: ${{vars.APP_CODE_BRANCH}}
PARENT_DEPLOYMENT_REPO: ${{vars.PARENT_DEPLOYMENT_REPO}}
Expand Down Expand Up @@ -102,24 +100,8 @@ jobs:
- name: Set deployment
run: yarn workflow deployment set $DEPLOYMENT_NAME --skip-refresh

- name: Populate android assets
run: yarn workflow populate_android_assets

- name: Update config names in android files
run: |
sed -i -e "s/international.idems.plh_teens/$APP_ID/g" -e "s/PLH Teens/$APP_NAME/g" ./capacitor.config.ts ./android/app/src/main/assets/capacitor.config.json ./android/app/src/main/res/values/strings.xml ./android/app/src/main/AndroidManifest.xml ./android/app/src/main/java/international/idems/plh_teens/MainActivity.java ./android/app/build.gradle
- name: Add version number to build.gradle
run: |
# Define the path to the file
FILE_PATH="./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/config.ts"
# Extract the version number
VERSION=$(grep 'content_tag_latest:' $FILE_PATH | sed 's/content_tag_latest: *"\(.*\)",/\1/')
echo "Extracted Version: $VERSION"
# Run versioning script
yarn run version $VERSION --android
- name: Prepare android configuration
run: yarn workflow android

- name: Download Build Artifact
uses: actions/download-artifact@v3
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/reusable-app-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ jobs:
ref: ${{inputs.branch}}
path: ".idems_app/deployments/${{env.DEPLOYMENT_NAME}}"
fetch-depth: 0

- name: Update version number
run: |
# Define the path to the file
FILE_PATH="./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/config.ts"
# Extract the version number
VERSION=$(grep 'content_tag_latest:' $FILE_PATH | sed 's/content_tag_latest: *"\(.*\)",/\1/')
echo "Extracted Version: $VERSION"

- name: Populate Encryption key
if: env.DEPLOYMENT_PRIVATE_KEY != ''
Expand Down
31 changes: 2 additions & 29 deletions .github/workflows/reusable-content-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,35 +105,8 @@ jobs:
run: yarn workflow sync

- name: Increment version number
run: |
# Define the path to the file
FILE_PATH="./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/config.ts"
# Extract the version number
VERSION=$(grep 'content_tag_latest:' $FILE_PATH | sed 's/content_tag_latest: *"\(.*\)",/\1/')
echo "Extracted Version: $VERSION"
# Split the version into major, minor, and patch components
IFS='.' read -ra VERSION_PARTS <<< "$VERSION"

if [[ ${#VERSION_PARTS[@]} -ne 3 ]]; then
echo "Error: Version format is not as expected."
exit 1
fi

PATCH_VERSION="${VERSION_PARTS[2]}"

# Increment the patch version
NEW_PATCH_VERSION=$((PATCH_VERSION + 1))

# Construct the new version
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEW_PATCH_VERSION"

echo "New Version: $NEW_VERSION"
echo "Command: s/$VERSION/$NEW_VERSION/ $FILE_PATH"

sed -i 's/\(content_tag_latest: "\)\([0-9]\+\.[0-9]\+\.\)\([0-9]\+\)"/\1\2'$((NEW_PATCH_VERSION))'"/' $FILE_PATH

run: yarn scripts version --content --auto-patch

- name: Commit changes
working-directory: .idems_app/deployments/${{env.DEPLOYMENT_NAME}}
run: |
Expand Down
6 changes: 6 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ capacitor-cordova-android-plugins

# Copied web assets
app/src/main/assets/public

# Files populated from templates
capacitor.config.json
# build.gradle
# AndroidManifest.xml
# strings.xml
59 changes: 59 additions & 0 deletions android/app/build.template.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apply plugin: 'com.android.application'

android {
namespace "${APP_ID}"
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "${APP_ID}"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode ${VERSION_CODE}
versionName "${VERSION_NAME}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}

dependencies {
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')

// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:32.7.2')

// Declare the dependencies for the Crashlytics and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-perf'
}

apply from: 'capacitor.build.gradle'

try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf' // Firebase Performance Monitoring plugin
apply plugin: 'com.google.firebase.crashlytics' // Firebase Crashlytics plugin
}
} catch(Exception e) {
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
77 changes: 77 additions & 0 deletions android/app/src/main/AndroidManifest.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true" android:requestLegacyExternalStorage="true">
<!-- usesCleartextTraffic is required by capacitor-blob-writer -->
<!-- requestLegacyExternalStorage is required to save files to "Documents" folder on Android 10 -->

<activity android:exported="true" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:name="${APP_ID}.MainActivity" android:label="@string/title_activity_main" android:theme="@style/AppTheme.NoActionBarLaunch" android:launchMode="singleTask">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/custom_url_scheme" />
</intent-filter>

</activity>

<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
</provider>
</application>

<!-- Permissions -->

<!-- CC NOTE - 2021-06-02
As we don't currrently need GeoLocation have removed permission
(some installs on unsupported tester devices, e.g. Tecno-wx3p
If we want to put back we should make non-required and add runtime check
in the app before using feature (might require both uses-feature and uses-permission
https://stackoverflow.com/questions/30391355/can-i-get-access-to-nfc-without-manifest-permission-in-android
https://stackoverflow.com/questions/28079449/uses-permission-vs-uses-feature
https://developer.android.com/guide/topics/manifest/uses-feature-element
https://developer.android.com/guide/topics/manifest/uses-permission-element
E.g. To enable camera include uses-permission for camera but manually add all features as optional
https://developer.android.com/reference/android/Manifest.permission#CAMERA
https://developer.android.com/guide/topics/manifest/uses-feature-element#camera-hw-features
-->



<!-- Normal permissions, granted at install, don't require prompt -->
<!-- https://developer.android.com/training/basics/network-ops/connecting -->
<!-- <uses-permission android:name="android.permission.INTERNET" /> -->
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->


<!-- Requested permissions, required in the app -->
<!-- Camera, Photos, input file -->
<!-- <uses-permission android:required="false" android:name="android.permission.READ_EXTERNAL_STORAGE"/> -->
<!-- <uses-permission android:required="false" android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->

<!-- Navigator.getUserMedia -->
<!-- Video -->
<!-- <uses-permission android:required="false" android:name="android.permission.CAMERA" /> -->
<!-- Audio -->
<!-- <uses-permission android:required="false" android:name="android.permission.RECORD_AUDIO" /> -->
<!-- <uses-permission android:required="false" android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> -->


<!-- Optional permissions, features we might make optional -->

<!-- <uses-feature android:name="android.hardware.location.gps" /> -->


<!-- Not required permissions, features we have decided we don't want -->
<!-- Geolocation API -->
<!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> -->
<!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> -->
</manifest>
21 changes: 0 additions & 21 deletions android/app/src/main/assets/capacitor.config.json

This file was deleted.

15 changes: 15 additions & 0 deletions android/templates/MainActivity.template.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ${APP_ID};

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;

import java.util.ArrayList;

public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
7 changes: 7 additions & 0 deletions android/templates/strings.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">${APP_NAME}</string>
<string name="title_activity_main">${APP_NAME}</string>
<string name="package_name">${APP_ID}</string>
<string name="custom_url_scheme">${APP_ID}</string>
</resources>
35 changes: 35 additions & 0 deletions capacitor.config.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// <reference types="@capacitor/local-notifications" />
/// <reference types="@capacitor/splash-screen" />

import { CapacitorConfig } from "@capacitor/cli";

const config: CapacitorConfig = {
appId: "${APP_ID}",
appName: "${APP_NAME}",
webDir: "www",
plugins: {
SplashScreen: {
launchShowDuration: 7000, // app.component.ts should manually dismiss before duration
launchAutoHide: true,
androidScaleType: "CENTER_CROP",
},
FirebaseAuthentication: {
skipNativeAuth: false,
providers: ["google.com"],
},
},
server: {
androidScheme: "http",
/**
* NOTE - to support live-reload on external device (e.g. emulator)
* 1) Uncomment url and replace with local ip to serve live-reload on local device
* 2) Sync to capacitor `npx cap sync`
* 3) Serve via `yarn ng serve --configuration=external`
* 4) Run app from android studio `npx cap open android` and run
* Local browser (localhost:4000), device app and device browser ([ip]:4200) should all be able to access served app
**/
// url: "http://192.168.50.67:4200",
},
};

export default config;
6 changes: 3 additions & 3 deletions documentation/docs/developers/android-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ const config: IDeploymentConfig = {
```
To generate the android assets, run
```sh
yarn workflow populate_android_assets
yarn workflow android
```
Or, to generate just the splash screens or just the app icons, run
```sh
yarn workflow set_splash_image
yarn workflow android set_splash_image
```
or
```sh
yarn workflow set_launcher_icon
yarn workflow android set_launcher_icon
```
respectively.

Expand Down
5 changes: 1 addition & 4 deletions documentation/docs/developers/in-app-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ _Build -> Build Bundles / APKs -> Build Bundle_

6. Download the app from the internal link created.

7. Increase version and repeat steps 1-4
```
yarn run version --android
```
7. Increase version (defined in deployment config `git.content_tag_latest`) and repeat steps 1-4

8. Follow link to new internal update but do not install (assume this makes device aware of potential update instead of waiting for store periodic check)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"intro.js": "^3.4.0",
"jquery": "^3.7.1",
"jquery-touchswipe": "^1.6.19",
"katex": "^0.16.9",
"katex": "^0.16.10",
"lottie-web": "^5.12.2",
"marked": "^2.1.3",
"mergexml": "^1.2.3",
Expand Down
Loading

0 comments on commit eabc2da

Please sign in to comment.