Skip to content

Commit

Permalink
chore(): update capacitor to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamol authored and godenzim committed Oct 10, 2022
1 parent d4c138b commit 89b617d
Show file tree
Hide file tree
Showing 17 changed files with 280 additions and 165 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ COPY install-test-deps.js /app
COPY package.json /app
COPY yarn.lock /app
COPY apply-diagnostic-modules.js /app
COPY fix-qrscanner-gradle.js /app

RUN yarn install-test-dependencies

Expand Down
8 changes: 5 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
lintOptions {
abortOnError false
Expand All @@ -52,6 +52,8 @@ repositories {
}

dependencies {
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
Expand Down
6 changes: 3 additions & 3 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}

Expand All @@ -18,7 +18,7 @@ dependencies {
implementation "com.android.support:support-v4:26.+"
implementation "com.android.support:appcompat-v7:26.+"
}
apply from: "../../node_modules/cordova-plugin-qrscanner/src/android/qrscanner.gradle"
apply from: "../../node_modules/cordova-plugin-qrscanner-11/src/android/qrscanner.gradle"

if (hasProperty('postBuildExtras')) {
postBuildExtras()
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/java/it/airgap/vault/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

registerPlugin(CameraPreview.class);
registerPlugin(AppInfo.class);
registerPlugin(SecurityUtils.class);
registerPlugin(SaplingNative.class);

super.onCreate(savedInstanceState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AuthPromptFragment : Fragment(R.layout.fragment_authenticator) {
private var _biometricPrompt: BiometricPrompt? = null
private val biometricPrompt: BiometricPrompt
get() = _biometricPrompt ?: run {
val executor = ContextCompat.getMainExecutor(context)
val executor = ContextCompat.getMainExecutor(requireContext())

BiometricPrompt(this, executor, object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</style>


<style name="AppTheme.NoActionBarLaunch" parent="AppTheme.NoActionBar">
<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
<item name="android:background">@drawable/screen</item>
</style>

Expand Down
7 changes: 4 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.7.10'

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.14'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -30,3 +30,4 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Thu Oct 21 16:14:56 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
distributionSha256Sum=a8da5b02437a60819cad23e10fc7e9cf32bcb57029d9cb277e26eeff76ce014b
distributionSha256Sum=e6d864e3b5bc05cc62041842b306383fc1fefcec359e70cebb1d470a6094ca82
22 changes: 12 additions & 10 deletions android/variables.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
ext {
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
androidxActivityVersion = '1.2.0'
androidxAppCompatVersion = '1.3.1'
androidxCoordinatorLayoutVersion = '1.1.0'
androidxCoreVersion = '1.3.2'
androidxFragmentVersion = '1.3.0'
minSdkVersion = 22
compileSdkVersion = 32
targetSdkVersion = 32
androidxActivityVersion = '1.4.0'
androidxAppCompatVersion = '1.4.2'
androidxCoordinatorLayoutVersion = '1.2.0'
androidxCoreVersion = '1.8.0'
androidxFragmentVersion = '1.4.1'
androidxExifinterfaceVersion = '1.3.3'
androidxMaterialVersion = '1.4.0'
androidxMaterialVersion = '1.6.1'
junitVersion = '4.13.2'
androidxTestCoreVersion = '1.4.0'
androidxJunitVersion = '1.1.3'
androidxEspressoCoreVersion = '3.4.0'
cordovaAndroidVersion = '7.0.0'
cordovaAndroidVersion = '10.1.1'
coreSplashScreenVersion = '1.0.0-rc01'
androidxWebkitVersion = '1.4.0'
}
2 changes: 1 addition & 1 deletion build/android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ WORKDIR /app
RUN yarn global add [email protected] @capacitor/[email protected] @capacitor/[email protected] && yarn cache clean --force && yarn global add n && n 16.13.1

# Install app dependencies, using wildcard if package-lock exists and copy capacitor configs and ionic configs
COPY package.json yarn.lock apply-diagnostic-modules.js capacitor.config.ts ionic.config.json /app/
COPY package.json yarn.lock apply-diagnostic-modules.js fix-qrscanner-gradle.js capacitor.config.ts ionic.config.json /app/

# install dependencies
# run ionic android build
Expand Down
26 changes: 26 additions & 0 deletions fix-qrscanner-gradle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// a workaround for cordova-diagnostic-plugin: the plugin ignores Capacitor config setting and installs all its features

const fs = require('fs')
const path = require('path')

const rootdir = ''
const qrscannerGradle = path.join(rootdir, 'node_modules/cordova-plugin-qrscanner-11/src/android/qrscanner.gradle')

const configFiles = [qrscannerGradle]

function replaceDeprecated(configFile) {
fs.readFile(configFile, 'utf8', function(err, data) {
if (err) {
return console.log(err)
}

const result = data.replaceAll('compile', 'implementation')
fs.writeFile(configFile, result, 'utf8', function(err) {
if (err) {
console.log(err)
}
})
})
}

configFiles.forEach(configFile => replaceDeprecated(configFile))
8 changes: 4 additions & 4 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -461,7 +461,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
Expand All @@ -480,7 +480,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 7VLXNQ52UC;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -507,7 +507,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 7VLXNQ52UC;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
11 changes: 1 addition & 10 deletions ios/App/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)

let statusBarRect = UIApplication.shared.statusBarFrame
guard let touchPoint = event?.allTouches?.first?.location(in: self.window) else { return }

if statusBarRect.contains(touchPoint) {
NotificationCenter.default.post(name: .capacitorStatusBarTapped, object: nil)
}
}
}


5 changes: 0 additions & 5 deletions ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string>AirGap uses your camera to scan QR Codes of transactions, and to generate entropy for the secure key generation.</string>
<key>NSFaceIDUsageDescription</key>
Expand Down
9 changes: 8 additions & 1 deletion ios/App/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
platform :ios, '12.0'
require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers'

platform :ios, '13.0'
use_frameworks!

# workaround to avoid Xcode 10 caching of Pods that requires
Expand All @@ -22,3 +24,8 @@ target 'App' do
capacitor_pods
# Add your Pods here
end


post_install do |installer|
assertDeploymentTarget(installer)
end
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lint-ci": "ng lint app --format json > ./lintReport.json || true",
"lint-fix": "tslint --fix --project tsconfig.json",
"e2e": "ng e2e",
"postinstall": "jetifier && node apply-diagnostic-modules.js",
"postinstall": "jetifier && node apply-diagnostic-modules.js && node fix-qrscanner-gradle.js",
"sonar-scanner": "sonar-scanner",
"prettier": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"remove-sapling": "replace './assets/sapling/sapling-' './assets/no-sapling-web/sapling-' ./src/app/app.component.ts",
Expand All @@ -37,8 +37,8 @@
"apply-diagnostic-modules": "node apply-diagnostic-modules.js"
},
"dependencies": {
"@airgap/angular-core": "0.0.31",
"@airgap/angular-ngrx": "0.0.31",
"@airgap/angular-core": "0.0.32-beta.9",
"@airgap/angular-ngrx": "0.0.32-beta.9",
"@airgap/coinlib-core": "0.13.6-beta.3",
"@airgap/sapling-wasm": "0.0.7",
"@angular/common": "13.2.5",
Expand All @@ -47,15 +47,15 @@
"@angular/platform-browser": "13.2.5",
"@angular/platform-browser-dynamic": "13.2.5",
"@angular/router": "13.2.5",
"@capacitor/android": "^3.2.5",
"@capacitor/app": "^1.0.5",
"@capacitor/app-launcher": "^1.0.6",
"@capacitor/clipboard": "^1.0.5",
"@capacitor/core": "^3.2.5",
"@capacitor/filesystem": "1.0.6",
"@capacitor/ios": "^3.2.5",
"@capacitor/splash-screen": "^1.1.5",
"@capacitor/status-bar": "^1.0.5",
"@capacitor/android": "^4.0.0",
"@capacitor/app": "^4.0.0",
"@capacitor/app-launcher": "^4.0.0",
"@capacitor/clipboard": "^4.0.0",
"@capacitor/core": "^4.0.0",
"@capacitor/filesystem": "^4.0.0",
"@capacitor/ios": "^4.0.0",
"@capacitor/splash-screen": "^4.0.0",
"@capacitor/status-bar": "^4.0.0",
"@download/blockies": "1.0.3",
"@ethereumjs/tx": "^3.4.0",
"@ionic-native/core": "5.36.0",
Expand Down Expand Up @@ -109,7 +109,7 @@
"@angular/compiler": "13.2.5",
"@angular/compiler-cli": "13.2.5",
"@angular/language-service": "13.2.5",
"@capacitor/cli": "3.2.5",
"@capacitor/cli": "^4.0.0",
"@ionic/angular-toolkit": "6.0.0",
"@ionic/cli": "6.18.2",
"@types/node": "17.0.21",
Expand Down
Loading

0 comments on commit 89b617d

Please sign in to comment.