Skip to content

Commit

Permalink
chore: Update demo app to Capacitor 4 (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jun 8, 2023
1 parent ffaa431 commit f23ce23
Show file tree
Hide file tree
Showing 18 changed files with 544 additions and 230 deletions.
2 changes: 2 additions & 0 deletions demo/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ repositories {
}

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')
Expand Down
4 changes: 2 additions & 2 deletions demo/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 Down
1 change: 1 addition & 0 deletions demo/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
android:theme="@style/AppTheme">

<activity
android:exported="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name="io.ionic.starter.MainActivity"
android:label="@string/title_activity_main"
Expand Down
24 changes: 12 additions & 12 deletions demo/android/app/src/main/assets/capacitor.config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"appId": "io.ionic.starter",
"appName": "demo",
"bundledWebRuntime": false,
"npmClient": "yarn",
"webDir": "build",
"plugins": {
"SplashScreen": {
"launchShowDuration": 0
}
},
"cordova": {}
}
"appId": "io.ionic.starter",
"appName": "demo",
"bundledWebRuntime": false,
"npmClient": "yarn",
"webDir": "build",
"plugins": {
"SplashScreen": {
"launchShowDuration": 0
}
},
"cordova": {}
}
6 changes: 6 additions & 0 deletions demo/android/app/src/main/assets/capacitor.plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"pkg": "@capacitor-community/camera-preview",
"classpath": "com.ahm.capacitor.camera.preview.CameraPreview"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ public class MainActivity extends BridgeActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(CameraPreview.class);
}});


}
}
4 changes: 2 additions & 2 deletions demo/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:background">@null</item>
</style>


<style name="AppTheme.NoActionBarLaunch" parent="AppTheme.NoActionBar">
<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
<item name="android:background">@drawable/splash</item>
</style>
</resources>
10 changes: 6 additions & 4 deletions demo/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ buildscript {

repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -20,10 +20,12 @@ apply from: "variables.gradle"
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}


2 changes: 1 addition & 1 deletion demo/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 20 additions & 15 deletions demo/android/variables.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
ext {
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
androidxAppCompatVersion = '1.1.0'
androidxCoreVersion = '1.2.0'
androidxMaterialVersion = '1.1.0-rc02'
androidxBrowserVersion = '1.2.0'
androidxLocalbroadcastmanagerVersion = '1.0.0'
androidxExifInterfaceVersion = '1.2.0'
firebaseMessagingVersion = '20.1.2'
playServicesLocationVersion = '17.0.0'
junitVersion = '4.12'
androidxJunitVersion = '1.1.1'
androidxEspressoCoreVersion = '3.2.0'
cordovaAndroidVersion = '7.0.0'
minSdkVersion = 22
compileSdkVersion = 32
targetSdkVersion = 32
androidxAppCompatVersion = '1.4.2'
androidxCoreVersion = '1.8.0'
androidxMaterialVersion = '1.6.1'
androidxBrowserVersion = '1.4.0'
androidxLocalbroadcastmanagerVersion = '1.0.0'
androidxExifInterfaceVersion = '1.3.3'
firebaseMessagingVersion = '23.0.5'
playServicesLocationVersion = '20.0.0'
junitVersion = '4.13.2'
androidxJunitVersion = '1.1.3'
androidxEspressoCoreVersion = '3.4.0'
cordovaAndroidVersion = '10.1.1'
androidxActivityVersion = '1.4.0'
androidxCoordinatorLayoutVersion = '1.2.0'
androidxFragmentVersion = '1.4.1'
coreSplashScreenVersion = '1.0.0-rc01'
androidxWebkitVersion = '1.4.0'
}
12 changes: 6 additions & 6 deletions demo/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -332,7 +332,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -349,13 +349,13 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 98QT6FH8AB;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = io.ionic.starter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG USE_PUSH";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -370,12 +370,12 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 98QT6FH8AB;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.ionic.starter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = USE_PUSH;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
13 changes: 2 additions & 11 deletions demo/ios/App/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return CAPBridge.handleContinueActivity(userActivity, 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(CAPBridge.statusBarTappedNotification)
}
}

#if USE_PUSH

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: deviceToken)
Expand All @@ -68,7 +58,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidFailToRegisterForRemoteNotificationsWithError.name()), object: error)
}

#endif


}


5 changes: 0 additions & 5 deletions demo/ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string>To Take Photos and Video</string>
<key>NSLocationAlwaysUsageDescription</key>
Expand Down
22 changes: 11 additions & 11 deletions demo/ios/App/App/capacitor.config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"appId": "io.ionic.starter",
"appName": "demo",
"bundledWebRuntime": false,
"npmClient": "yarn",
"webDir": "build",
"plugins": {
"SplashScreen": {
"launchShowDuration": 0
}
},
"cordova": {}
"appId": "io.ionic.starter",
"appName": "demo",
"bundledWebRuntime": false,
"npmClient": "yarn",
"webDir": "build",
"plugins": {
"SplashScreen": {
"launchShowDuration": 0
}
},
"cordova": {}
}
15 changes: 10 additions & 5 deletions demo/ios/App/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
platform :ios, '11.0'
require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers'

platform :ios, '13.0'
use_frameworks!

# workaround to avoid Xcode caching of Pods that requires
Expand All @@ -7,14 +9,17 @@ use_frameworks!
install! 'cocoapods', :disable_input_output_paths => true

def capacitor_pods
# Automatic Capacitor Pod dependencies, do not delete
pod 'Capacitor', :path => '../../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../../node_modules/@capacitor/ios'
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCommunityCameraPreview', :path => '../../node_modules/@capacitor-community/camera-preview'
# Do not delete
end

target 'App' do
capacitor_pods
# Add your Pods here
end


post_install do |installer|
assertDeploymentTarget(installer)
end
9 changes: 5 additions & 4 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"version": "0.0.1",
"private": true,
"dependencies": {
"@capacitor-community/camera-preview": "^1.1.0",
"@capacitor/android": "2.4.4",
"@capacitor/core": "2.4.4",
"@capacitor-community/camera-preview": "^4.0.0",
"@capacitor/android": "^4.0.0",
"@capacitor/core": "^4.0.0",
"@capacitor/ios": "^4.0.0",
"@ionic/react": "^5.0.7",
"@ionic/react-router": "^5.0.7",
"@testing-library/jest-dom": "^4.2.4",
Expand Down Expand Up @@ -47,7 +48,7 @@
]
},
"devDependencies": {
"@capacitor/cli": "2.4.4"
"@capacitor/cli": "^4.0.0"
},
"description": "An Ionic project"
}
1 change: 0 additions & 1 deletion demo/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
IonToolbar,
} from "@ionic/react";
import React from "react";
import ExploreContainer from "../components/ExploreContainer";
import "./Home.css";
import { Plugins } from "@capacitor/core";

Expand Down
Loading

0 comments on commit f23ce23

Please sign in to comment.