build: Install project dependencies and configure mobile platforms.

This commit is contained in:
francy 2026-02-09 16:10:02 +01:00
parent 5630c6cee7
commit 2acd0e3ccb
1845 changed files with 274163 additions and 89 deletions

101
android/.gitignore vendored Normal file
View File

@ -0,0 +1,101 @@
# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
# Android Profiling
*.hprof
# Cordova plugins for Capacitor
capacitor-cordova-android-plugins
# Copied web assets
app/src/main/assets/public
# Generated Config files
app/src/main/assets/capacitor.config.json
app/src/main/assets/capacitor.plugins.json
app/src/main/res/xml/config.xml

2
android/app/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build/*
!/build/.npmkeep

54
android/app/build.gradle Normal file
View File

@ -0,0 +1,54 @@
apply plugin: 'com.android.application'
android {
namespace = "art.wondersheets.app"
compileSdk = rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "art.wondersheets.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
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 fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
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')
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}

View File

@ -0,0 +1,19 @@
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
}
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
}
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}

21
android/app/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,26 @@
package com.getcapacitor.myapp;
import static org.junit.Assert.*;
import android.content.Context;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.getcapacitor.app", appContext.getPackageName());
}
}

View File

@ -0,0 +1,41 @@
<?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">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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 -->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

View File

@ -0,0 +1,5 @@
package art.wondersheets.app;
import com.getcapacitor.BridgeActivity;
public class MainActivity extends BridgeActivity {}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">WonderSheets</string>
<string name="title_activity_main">WonderSheets</string>
<string name="package_name">art.wondersheets.app</string>
<string name="custom_url_scheme">art.wondersheets.app</string>
</resources>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<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="Theme.SplashScreen">
<item name="android:background">@drawable/splash</item>
</style>
</resources>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images" path="." />
<cache-path name="my_cache_images" path="." />
</paths>

View File

@ -0,0 +1,18 @@
package com.getcapacitor.myapp;
import static org.junit.Assert.*;
import org.junit.Test;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

29
android/build.gradle Normal file
View File

@ -0,0 +1,29 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.13.0'
classpath 'com.google.gms:google-services:4.4.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply from: "variables.gradle"
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -0,0 +1,3 @@
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')

22
android/gradle.properties Normal file
View File

@ -0,0 +1,22 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

Binary file not shown.

View File

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

251
android/gradlew vendored Executable file
View File

@ -0,0 +1,251 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

94
android/gradlew.bat vendored Normal file
View File

@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

5
android/settings.gradle Normal file
View File

@ -0,0 +1,5 @@
include ':app'
include ':capacitor-cordova-android-plugins'
project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')
apply from: 'capacitor.settings.gradle'

16
android/variables.gradle Normal file
View File

@ -0,0 +1,16 @@
ext {
minSdkVersion = 24
compileSdkVersion = 36
targetSdkVersion = 36
androidxActivityVersion = '1.11.0'
androidxAppCompatVersion = '1.7.1'
androidxCoordinatorLayoutVersion = '1.3.0'
androidxCoreVersion = '1.17.0'
androidxFragmentVersion = '1.8.9'
coreSplashScreenVersion = '1.2.0'
androidxWebkitVersion = '1.14.0'
junitVersion = '4.13.2'
androidxJunitVersion = '1.3.0'
androidxEspressoCoreVersion = '3.7.0'
cordovaAndroidVersion = '14.0.1'
}

5
capacitor.config.json Normal file
View File

@ -0,0 +1,5 @@
{
"appId": "art.wondersheets.app",
"appName": "WonderSheets",
"webDir": "dist"
}

1
dist/assets/index-B54QSxKf.css vendored Normal file

File diff suppressed because one or more lines are too long

269
dist/assets/index-IVUbEl2F.js vendored Normal file

File diff suppressed because one or more lines are too long

18
dist/assets/index.es-CVtinQ7o.js vendored Normal file

File diff suppressed because one or more lines are too long

2
dist/assets/purify.es-B9ZVCkUG.js vendored Normal file

File diff suppressed because one or more lines are too long

22
dist/index.html vendored Normal file
View File

@ -0,0 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WonderSheets - AI Activity Page Creator </title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<script defer src="https://analytics.wondersheets.art/script.js"
data-website-id="c98700d0-c89a-41af-9445-e7da9641154e"></script>
<script type="module" crossorigin src="/assets/index-IVUbEl2F.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-B54QSxKf.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

13
ios/.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
App/build
App/Pods
App/output
App/App/public
DerivedData
xcuserdata
# Cordova plugins for Capacitor
capacitor-cordova-ios-plugins
# Generated Config files
App/App/capacitor.config.json
App/App/config.xml

View File

@ -0,0 +1,376 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 60;
objects = {
/* Begin PBXBuildFile section */
2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; };
4D22ABE92AF431CB00220026 /* CapApp-SPM in Frameworks */ = {isa = PBXBuildFile; productRef = 4D22ABE82AF431CB00220026 /* CapApp-SPM */; };
50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; };
504EC3081FED79650016851F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F /* AppDelegate.swift */; };
504EC30D1FED79650016851F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F /* Main.storyboard */; };
504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; };
504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; };
50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = "<group>"; };
50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = "<group>"; };
504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
504EC3071FED79650016851F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
504EC30C1FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
504EC3011FED79650016851F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4D22ABE92AF431CB00220026 /* CapApp-SPM in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
504EC2FB1FED79650016851F = {
isa = PBXGroup;
children = (
958DCC722DB07C7200EA8C5F /* debug.xcconfig */,
504EC3061FED79650016851F /* App */,
504EC3051FED79650016851F /* Products */,
);
sourceTree = "<group>";
};
504EC3051FED79650016851F /* Products */ = {
isa = PBXGroup;
children = (
504EC3041FED79650016851F /* App.app */,
);
name = Products;
sourceTree = "<group>";
};
504EC3061FED79650016851F /* App */ = {
isa = PBXGroup;
children = (
50379B222058CBB4000EE86E /* capacitor.config.json */,
504EC3071FED79650016851F /* AppDelegate.swift */,
504EC30B1FED79650016851F /* Main.storyboard */,
504EC30E1FED79650016851F /* Assets.xcassets */,
504EC3101FED79650016851F /* LaunchScreen.storyboard */,
504EC3131FED79650016851F /* Info.plist */,
2FAD9762203C412B000D30F8 /* config.xml */,
50B271D01FEDC1A000F3C39B /* public */,
);
path = App;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
504EC3031FED79650016851F /* App */ = {
isa = PBXNativeTarget;
buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */;
buildPhases = (
504EC3001FED79650016851F /* Sources */,
504EC3011FED79650016851F /* Frameworks */,
504EC3021FED79650016851F /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = App;
packageProductDependencies = (
4D22ABE82AF431CB00220026 /* CapApp-SPM */,
);
productName = App;
productReference = 504EC3041FED79650016851F /* App.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
504EC2FC1FED79650016851F /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 0920;
TargetAttributes = {
504EC3031FED79650016851F = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1100;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */;
compatibilityVersion = "Xcode 8.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 504EC2FB1FED79650016851F;
packageReferences = (
D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */,
);
productRefGroup = 504EC3051FED79650016851F /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
504EC3031FED79650016851F /* App */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
504EC3021FED79650016851F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */,
50B271D11FEDC1A000F3C39B /* public in Resources */,
504EC30F1FED79650016851F /* Assets.xcassets in Resources */,
50379B232058CBB4000EE86E /* capacitor.config.json in Resources */,
504EC30D1FED79650016851F /* Main.storyboard in Resources */,
2FAD9763203C412B000D30F8 /* config.xml in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
504EC3001FED79650016851F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
504EC3081FED79650016851F /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
504EC30B1FED79650016851F /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
504EC30C1FED79650016851F /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
504EC3101FED79650016851F /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
504EC3111FED79650016851F /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
504EC3141FED79650016851F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
504EC3151FED79650016851F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
504EC3171FED79650016851F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = art.wondersheets.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
504EC3181FED79650016851F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = art.wondersheets.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */ = {
isa = XCConfigurationList;
buildConfigurations = (
504EC3141FED79650016851F /* Debug */,
504EC3151FED79650016851F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */ = {
isa = XCConfigurationList;
buildConfigurations = (
504EC3171FED79650016851F /* Debug */,
504EC3181FED79650016851F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = "CapApp-SPM";
};
/* End XCLocalSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
4D22ABE82AF431CB00220026 /* CapApp-SPM */ = {
isa = XCSwiftPackageProductDependency;
package = D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */;
productName = "CapApp-SPM";
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 504EC2FC1FED79650016851F /* Project object */;
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,49 @@
import UIKit
import Capacitor
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
// Called when the app was launched with a url. Feel free to add additional processing here,
// but if you want the App API to support tracking app url opens, make sure to keep this call
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Called when the app was launched with an activity, including Universal Links.
// Feel free to add additional processing here, but if you want the App API to support
// tracking app url opens, make sure to keep this call
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "AppIcon-512@2x.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "splash-2732x2732-2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "splash-2732x2732-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "splash-2732x2732.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17132" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17105"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<imageView key="view" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Splash" id="snD-IY-ifK">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</imageView>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="Splash" width="1366" height="1366"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14111" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
</dependencies>
<scenes>
<!--Bridge View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="CAPBridgeViewController" customModule="Capacitor" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

51
ios/App/App/Info.plist Normal file
View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CAPACITOR_DEBUG</key>
<string>$(CAPACITOR_DEBUG)</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>WonderSheets</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
</dict>
</plist>

9
ios/App/CapApp-SPM/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

View File

@ -0,0 +1,25 @@
// swift-tools-version: 5.9
import PackageDescription
// DO NOT MODIFY THIS FILE - managed by Capacitor CLI commands
let package = Package(
name: "CapApp-SPM",
platforms: [.iOS(.v15)],
products: [
.library(
name: "CapApp-SPM",
targets: ["CapApp-SPM"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "8.0.2")
],
targets: [
.target(
name: "CapApp-SPM",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm")
]
)
]
)

View File

@ -0,0 +1,5 @@
# CapApp-SPM
This SPM is used to host SPM dependencies for you Capacitor project
Do not modify the contents of it or there may be unintended consequences.

View File

@ -0,0 +1 @@
public let isCapacitorApp = true

1
ios/debug.xcconfig Normal file
View File

@ -0,0 +1 @@
CAPACITOR_DEBUG = true

1
node_modules/.bin/cap generated vendored Symbolic link
View File

@ -0,0 +1 @@
../@capacitor/cli/bin/capacitor

1
node_modules/.bin/capacitor generated vendored Symbolic link
View File

@ -0,0 +1 @@
../@capacitor/cli/bin/capacitor

1
node_modules/.bin/is-docker generated vendored Symbolic link
View File

@ -0,0 +1 @@
../is-docker/cli.js

1
node_modules/.bin/native-run generated vendored Symbolic link
View File

@ -0,0 +1 @@
../native-run/bin/native-run

1
node_modules/.bin/tree-kill generated vendored Symbolic link
View File

@ -0,0 +1 @@
../tree-kill/cli.js

919
node_modules/.package-lock.json generated vendored

File diff suppressed because it is too large Load Diff

21
node_modules/@capacitor/android/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-present Drifty Co.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

94
node_modules/@capacitor/android/capacitor/build.gradle generated vendored Normal file
View File

@ -0,0 +1,94 @@
ext {
androidxActivityVersion = project.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.11.0'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.3.0'
androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.17.0'
androidxFragmentVersion = project.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.8.9'
androidxWebkitVersion = project.hasProperty('androidxWebkitVersion') ? rootProject.ext.androidxWebkitVersion : '1.14.0'
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '14.0.1'
}
buildscript {
repositories {
google()
mavenCentral()
maven {
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.13.0'
if (System.getenv("CAP_PUBLISH") == "true") {
classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
}
}
}
tasks.withType(Javadoc).all { enabled = false }
apply plugin: 'com.android.library'
if (System.getenv("CAP_PUBLISH") == "true") {
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply from: file('../scripts/publish-root.gradle')
apply from: file('../scripts/publish-module.gradle')
}
android {
namespace = "com.getcapacitor.android"
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
versionCode 1
versionName "1.0"
consumerProguardFiles 'proguard-rules.pro'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
lintOptions {
baseline file("lint-baseline.xml")
abortOnError = true
warningsAsErrors = true
lintConfig = file('lint.xml')
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
publishing {
singleVariant("release")
}
}
repositories {
google()
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.core:core:$androidxCoreVersion"
implementation "androidx.activity:activity:$androidxActivityVersion"
implementation "androidx.fragment:fragment:$androidxFragmentVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.webkit:webkit:$androidxWebkitVersion"
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation "org.apache.cordova:framework:$cordovaAndroidVersion"
testImplementation 'org.json:json:20250517'
testImplementation 'org.mockito:mockito-core:5.20.0'
}

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 4.1.1" client="gradle" variant="all" version="4.1.1">
<issue
id="DefaultLocale"
message="Implicitly using the default locale is a common source of bugs: Use `String.format(Locale, ...)` instead"
errorLine1=" String msg = String.format("
errorLine2=" ^">
<location
file="src/main/java/com/getcapacitor/BridgeWebChromeClient.java"
line="474"
column="26"/>
</issue>
<issue
id="DefaultLocale"
message="Implicitly using the default locale is a common source of bugs: Use `toUpperCase(Locale)` instead. For strings meant to be internal use `Locale.ROOT`, otherwise `Locale.getDefault()`."
errorLine1=" return mask.toUpperCase().equals(string.toUpperCase());"
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/com/getcapacitor/util/HostMask.java"
line="110"
column="29"/>
</issue>
<issue
id="DefaultLocale"
message="Implicitly using the default locale is a common source of bugs: Use `toUpperCase(Locale)` instead. For strings meant to be internal use `Locale.ROOT`, otherwise `Locale.getDefault()`."
errorLine1=" return mask.toUpperCase().equals(string.toUpperCase());"
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/com/getcapacitor/util/HostMask.java"
line="110"
column="57"/>
</issue>
<issue
id="DefaultLocale"
message="Implicitly using the default locale is a common source of bugs: Use `toLowerCase(Locale)` instead. For strings meant to be internal use `Locale.ROOT`, otherwise `Locale.getDefault()`."
errorLine1=" switch (spinnerStyle.toLowerCase()) {"
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/com/getcapacitor/Splash.java"
line="127"
column="38"/>
</issue>
<issue
id="DefaultLocale"
message="Implicitly using the default locale is a common source of bugs: Use `toLowerCase(Locale)` instead. For strings meant to be internal use `Locale.ROOT`, otherwise `Locale.getDefault()`."
errorLine1=" if (header.getKey().equalsIgnoreCase(&quot;Accept&quot;) &amp;&amp; header.getValue().toLowerCase().contains(&quot;text/html&quot;)) {"
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/com/getcapacitor/WebViewLocalServer.java"
line="327"
column="89"/>
</issue>
<issue
id="SimpleDateFormat"
message="To get local formatting use `getDateInstance()`, `getDateTimeInstance()`, or `getTimeInstance()`, or use `new SimpleDateFormat(String template, Locale locale)` with for example `Locale.US` for ASCII dates."
errorLine1=" String timeStamp = new SimpleDateFormat(&quot;yyyyMMdd_HHmmss&quot;).format(new Date());"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/getcapacitor/BridgeWebChromeClient.java"
line="511"
column="28"/>
</issue>
<issue
id="SimpleDateFormat"
message="To get local formatting use `getDateInstance()`, `getDateTimeInstance()`, or `getTimeInstance()`, or use `new SimpleDateFormat(String template, Locale locale)` with for example `Locale.US` for ASCII dates."
errorLine1=" DateFormat df = new SimpleDateFormat(&quot;yyyy-MM-dd&apos;T&apos;HH:mm&apos;Z&apos;&quot;);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/getcapacitor/PluginResult.java"
line="44"
column="25"/>
</issue>
<issue
id="SetJavaScriptEnabled"
message="Using `setJavaScriptEnabled` can introduce XSS vulnerabilities into your application, review carefully"
errorLine1=" settings.setJavaScriptEnabled(true);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/getcapacitor/Bridge.java"
line="384"
column="9"/>
</issue>
<issue
id="Recycle"
message="This `TypedArray` should be recycled after use with `#recycle()`"
errorLine1=" TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.bridge_fragment);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/getcapacitor/BridgeFragment.java"
line="84"
column="32"/>
</issue>
<issue
id="StaticFieldLeak"
message="Do not place Android context classes in static fields; this is a memory leak"
errorLine1=" private static ImageView splashImage;"
errorLine2=" ~~~~~~">
<location
file="src/main/java/com/getcapacitor/Splash.java"
line="41"
column="13"/>
</issue>
<issue
id="StaticFieldLeak"
message="Do not place Android context classes in static fields; this is a memory leak"
errorLine1=" private static ProgressBar spinnerBar;"
errorLine2=" ~~~~~~">
<location
file="src/main/java/com/getcapacitor/Splash.java"
line="42"
column="13"/>
</issue>
<issue
id="Overdraw"
message="Possible overdraw: Root element paints background `#F0FF1414` with a theme that also paints a background (inferred theme is `@android:style/Theme.Holo`)"
errorLine1=" android:background=&quot;#F0FF1414&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/fragment_bridge.xml"
line="5"
column="5"/>
</issue>
</issues>

9
node_modules/@capacitor/android/capacitor/lint.xml generated vendored Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="GradleDependency" severity="ignore" />
<issue id="AndroidGradlePluginVersion" severity="ignore" />
<issue id="DiscouragedApi">
<ignore path="src/main/java/com/getcapacitor/plugin/util/AssetUtil.java" />
</issue>
<issue id="ObsoleteSdkInt" severity="informational" />
</lint>

View File

@ -0,0 +1,28 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Rules for Capacitor v3 plugins and annotations
-keep @com.getcapacitor.annotation.CapacitorPlugin public class * {
@com.getcapacitor.annotation.PermissionCallback <methods>;
@com.getcapacitor.annotation.ActivityCallback <methods>;
@com.getcapacitor.annotation.Permission <methods>;
@com.getcapacitor.PluginMethod public <methods>;
}
-keep public class * extends com.getcapacitor.Plugin { *; }
# Rules for Capacitor v2 plugins and annotations
# These are deprecated but can still be used with Capacitor for now
-keep @com.getcapacitor.NativePlugin public class * {
@com.getcapacitor.PluginMethod public <methods>;
}
# Rules for Cordova plugins
-keep public class * extends org.apache.cordova.* {
public <methods>;
public <fields>;
}

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,94 @@
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package com.getcapacitor;
import android.content.Context;
import android.content.res.AssetManager;
import android.net.Uri;
import android.util.TypedValue;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class AndroidProtocolHandler {
private Context context;
public AndroidProtocolHandler(Context context) {
this.context = context;
}
public InputStream openAsset(String path) throws IOException {
return context.getAssets().open(path, AssetManager.ACCESS_STREAMING);
}
public InputStream openResource(Uri uri) {
assert uri.getPath() != null;
// The path must be of the form ".../asset_type/asset_name.ext".
List<String> pathSegments = uri.getPathSegments();
String assetType = pathSegments.get(pathSegments.size() - 2);
String assetName = pathSegments.get(pathSegments.size() - 1);
// Drop the file extension.
assetName = assetName.split("\\.")[0];
try {
// Use the application context for resolving the resource package name so that we do
// not use the browser's own resources. Note that if 'context' here belongs to the
// test suite, it does not have a separate application context. In that case we use
// the original context object directly.
if (context.getApplicationContext() != null) {
context = context.getApplicationContext();
}
int fieldId = getFieldId(context, assetType, assetName);
int valueType = getValueType(context, fieldId);
if (valueType == TypedValue.TYPE_STRING) {
return context.getResources().openRawResource(fieldId);
} else {
Logger.error("Asset not of type string: " + uri);
}
} catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException e) {
Logger.error("Unable to open resource URL: " + uri, e);
}
return null;
}
private static int getFieldId(Context context, String assetType, String assetName)
throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
Class<?> d = context.getClassLoader().loadClass(context.getPackageName() + ".R$" + assetType);
java.lang.reflect.Field field = d.getField(assetName);
return field.getInt(null);
}
public InputStream openFile(String filePath) throws IOException {
String realPath = filePath.replace(Bridge.CAPACITOR_FILE_START, "");
File localFile = new File(realPath);
return new FileInputStream(localFile);
}
public InputStream openContentUrl(Uri uri) throws IOException {
Integer port = uri.getPort();
String baseUrl = uri.getScheme() + "://" + uri.getHost();
if (port != -1) {
baseUrl += ":" + port;
}
String realPath = uri.toString().replace(baseUrl + Bridge.CAPACITOR_CONTENT_START, "content:/");
InputStream stream = null;
try {
stream = context.getContentResolver().openInputStream(Uri.parse(realPath));
} catch (SecurityException e) {
Logger.error("Unable to open content URL: " + uri, e);
}
return stream;
}
private static int getValueType(Context context, int fieldId) {
TypedValue value = new TypedValue();
context.getResources().getValue(fieldId, value, true);
return value.type;
}
}

View File

@ -0,0 +1,61 @@
package com.getcapacitor;
import androidx.annotation.Nullable;
public class App {
/**
* Interface for callbacks when app status changes.
*/
public interface AppStatusChangeListener {
void onAppStatusChanged(Boolean isActive);
}
/**
* Interface for callbacks when app is restored with pending plugin call.
*/
public interface AppRestoredListener {
void onAppRestored(PluginResult result);
}
@Nullable
private AppStatusChangeListener statusChangeListener;
@Nullable
private AppRestoredListener appRestoredListener;
private boolean isActive = false;
public boolean isActive() {
return isActive;
}
/**
* Set the object to receive callbacks.
* @param listener
*/
public void setStatusChangeListener(@Nullable AppStatusChangeListener listener) {
this.statusChangeListener = listener;
}
/**
* Set the object to receive callbacks.
* @param listener
*/
public void setAppRestoredListener(@Nullable AppRestoredListener listener) {
this.appRestoredListener = listener;
}
protected void fireRestoredResult(PluginResult result) {
if (appRestoredListener != null) {
appRestoredListener.onAppRestored(result);
}
}
public void fireStatusChange(boolean isActive) {
this.isActive = isActive;
if (statusChangeListener != null) {
statusChangeListener.onAppStatusChanged(isActive);
}
}
}

View File

@ -0,0 +1,65 @@
package com.getcapacitor;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.appcompat.app.AppCompatActivity;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Objects;
import java.util.UUID;
public final class AppUUID {
private static final String KEY = "CapacitorAppUUID";
public static String getAppUUID(AppCompatActivity activity) throws Exception {
assertAppUUID(activity);
return readUUID(activity);
}
public static void regenerateAppUUID(AppCompatActivity activity) throws Exception {
try {
String uuid = generateUUID();
writeUUID(activity, uuid);
} catch (NoSuchAlgorithmException ex) {
throw new Exception("Capacitor App UUID could not be generated.");
}
}
private static void assertAppUUID(AppCompatActivity activity) throws Exception {
String uuid = readUUID(activity);
if (uuid.equals("")) {
regenerateAppUUID(activity);
}
}
private static String generateUUID() throws NoSuchAlgorithmException {
MessageDigest salt = MessageDigest.getInstance("SHA-256");
salt.update(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
return bytesToHex(salt.digest());
}
private static String readUUID(AppCompatActivity activity) {
SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
return sharedPref.getString(KEY, "");
}
private static void writeUUID(AppCompatActivity activity, String uuid) {
SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(KEY, uuid);
editor.apply();
}
private static String bytesToHex(byte[] bytes) {
byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
byte[] hexChars = new byte[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
}
return new String(hexChars, StandardCharsets.UTF_8);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,212 @@
package com.getcapacitor;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.getcapacitor.android.R;
import java.util.ArrayList;
import java.util.List;
public class BridgeActivity extends AppCompatActivity {
protected Bridge bridge;
protected boolean keepRunning = true;
protected CapConfig config;
protected int activityDepth = 0;
protected List<Class<? extends Plugin>> initialPlugins = new ArrayList<>();
protected final Bridge.Builder bridgeBuilder = new Bridge.Builder(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bridgeBuilder.setInstanceState(savedInstanceState);
getApplication().setTheme(R.style.AppTheme_NoActionBar);
setTheme(R.style.AppTheme_NoActionBar);
try {
setContentView(R.layout.capacitor_bridge_layout_main);
} catch (Exception ex) {
setContentView(R.layout.no_webview);
return;
}
PluginManager loader = new PluginManager(getAssets());
try {
bridgeBuilder.addPlugins(loader.loadPluginClasses());
} catch (PluginLoadException ex) {
Logger.error("Error loading plugins.", ex);
}
this.load();
}
protected void load() {
Logger.debug("Starting BridgeActivity");
bridge = bridgeBuilder.addPlugins(initialPlugins).setConfig(config).create();
this.keepRunning = bridge.shouldKeepRunning();
this.onNewIntent(getIntent());
}
public void registerPlugin(Class<? extends Plugin> plugin) {
bridgeBuilder.addPlugin(plugin);
}
public void registerPlugins(List<Class<? extends Plugin>> plugins) {
bridgeBuilder.addPlugins(plugins);
}
public Bridge getBridge() {
return this.bridge;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
bridge.saveInstanceState(outState);
}
@Override
public void onStart() {
super.onStart();
activityDepth++;
if (this.bridge != null) {
this.bridge.onStart();
Logger.debug("App started");
}
}
@Override
public void onRestart() {
super.onRestart();
this.bridge.onRestart();
Logger.debug("App restarted");
}
@Override
public void onResume() {
super.onResume();
if (bridge != null) {
bridge.getApp().fireStatusChange(true);
this.bridge.onResume();
Logger.debug("App resumed");
}
}
@Override
public void onPause() {
super.onPause();
if (bridge != null) {
this.bridge.onPause();
Logger.debug("App paused");
}
}
@Override
public void onStop() {
super.onStop();
if (bridge != null) {
activityDepth = Math.max(0, activityDepth - 1);
if (activityDepth == 0) {
bridge.getApp().fireStatusChange(false);
}
this.bridge.onStop();
Logger.debug("App stopped");
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (this.bridge != null) {
this.bridge.onDestroy();
Logger.debug("App destroyed");
}
}
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.bridge.onDetachedFromWindow();
}
/**
* Handles permission request results.
*
* Capacitor is backwards compatible such that plugins using legacy permission request codes
* may coexist with plugins using the AndroidX Activity v1.2 permission callback flow introduced
* in Capacitor 3.0.
*
* In this method, plugins are checked first for ownership of the legacy permission request code.
* If the {@link Bridge#onRequestPermissionsResult(int, String[], int[])} method indicates it has
* handled the permission, then the permission callback will be considered complete. Otherwise,
* the permission will be handled using the AndroidX Activity flow.
*
* @param requestCode the request code associated with the permission request
* @param permissions the Android permission strings requested
* @param grantResults the status result of the permission request
*/
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (this.bridge == null) {
return;
}
if (!bridge.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
/**
* Handles activity results.
*
* Capacitor is backwards compatible such that plugins using legacy activity result codes
* may coexist with plugins using the AndroidX Activity v1.2 activity callback flow introduced
* in Capacitor 3.0.
*
* In this method, plugins are checked first for ownership of the legacy request code. If the
* {@link Bridge#onActivityResult(int, int, Intent)} method indicates it has handled the activity
* result, then the callback will be considered complete. Otherwise, the result will be handled
* using the AndroidX Activiy flow.
*
* @param requestCode the request code associated with the activity result
* @param resultCode the result code
* @param data any data included with the activity result
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (this.bridge == null) {
return;
}
if (!bridge.onActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (this.bridge == null || intent == null) {
return;
}
this.bridge.onNewIntent(intent);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (this.bridge == null) {
return;
}
this.bridge.onConfigurationChanged(newConfig);
}
}

View File

@ -0,0 +1,467 @@
package com.getcapacitor;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.webkit.ConsoleMessage;
import android.webkit.GeolocationPermissions;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.MimeTypeMap;
import android.webkit.PermissionRequest;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.EditText;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.core.content.FileProvider;
import com.getcapacitor.util.PermissionHelper;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Custom WebChromeClient handler, required for showing dialogs, confirms, etc. in our
* WebView instance.
*/
public class BridgeWebChromeClient extends WebChromeClient {
private interface PermissionListener {
void onPermissionSelect(Boolean isGranted);
}
private interface ActivityResultListener {
void onActivityResult(ActivityResult result);
}
private ActivityResultLauncher permissionLauncher;
private ActivityResultLauncher activityLauncher;
private PermissionListener permissionListener;
private ActivityResultListener activityListener;
private Bridge bridge;
public BridgeWebChromeClient(Bridge bridge) {
this.bridge = bridge;
ActivityResultCallback<Map<String, Boolean>> permissionCallback = (Map<String, Boolean> isGranted) -> {
if (permissionListener != null) {
boolean granted = true;
for (Map.Entry<String, Boolean> permission : isGranted.entrySet()) {
if (!permission.getValue()) granted = false;
}
permissionListener.onPermissionSelect(granted);
}
};
permissionLauncher = bridge.registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), permissionCallback);
activityLauncher = bridge.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), (result) -> {
if (activityListener != null) {
activityListener.onActivityResult(result);
}
});
}
/**
* Render web content in `view`.
*
* Both this method and {@link #onHideCustomView()} are required for
* rendering web content in full screen.
*
* @see <a href="https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)">onShowCustomView() docs</a>
*/
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
callback.onCustomViewHidden();
super.onShowCustomView(view, callback);
}
/**
* Render web content in the original Web View again.
*
* Do not remove this method--@see #onShowCustomView(View, CustomViewCallback).
*/
@Override
public void onHideCustomView() {
super.onHideCustomView();
}
@Override
public void onPermissionRequest(final PermissionRequest request) {
List<String> permissionList = new ArrayList<>();
if (Arrays.asList(request.getResources()).contains("android.webkit.resource.VIDEO_CAPTURE")) {
permissionList.add(Manifest.permission.CAMERA);
}
if (Arrays.asList(request.getResources()).contains("android.webkit.resource.AUDIO_CAPTURE")) {
permissionList.add(Manifest.permission.MODIFY_AUDIO_SETTINGS);
permissionList.add(Manifest.permission.RECORD_AUDIO);
}
if (!permissionList.isEmpty()) {
String[] permissions = permissionList.toArray(new String[0]);
permissionListener = (isGranted) -> {
if (isGranted) {
request.grant(request.getResources());
} else {
request.deny();
}
};
permissionLauncher.launch(permissions);
} else {
request.grant(request.getResources());
}
}
/**
* Show the browser alert modal
* @param view
* @param url
* @param message
* @param result
* @return
*/
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
if (bridge.getActivity().isFinishing()) {
return true;
}
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder
.setMessage(message)
.setPositiveButton("OK", (dialog, buttonIndex) -> {
dialog.dismiss();
result.confirm();
})
.setOnCancelListener((dialog) -> {
dialog.dismiss();
result.cancel();
});
AlertDialog dialog = builder.create();
dialog.show();
return true;
}
/**
* Show the browser confirm modal
* @param view
* @param url
* @param message
* @param result
* @return
*/
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
if (bridge.getActivity().isFinishing()) {
return true;
}
final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder
.setMessage(message)
.setPositiveButton("OK", (dialog, buttonIndex) -> {
dialog.dismiss();
result.confirm();
})
.setNegativeButton("Cancel", (dialog, buttonIndex) -> {
dialog.dismiss();
result.cancel();
})
.setOnCancelListener((dialog) -> {
dialog.dismiss();
result.cancel();
});
AlertDialog dialog = builder.create();
dialog.show();
return true;
}
/**
* Show the browser prompt modal
* @param view
* @param url
* @param message
* @param defaultValue
* @param result
* @return
*/
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
if (bridge.getActivity().isFinishing()) {
return true;
}
final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
final EditText input = new EditText(view.getContext());
builder
.setMessage(message)
.setView(input)
.setPositiveButton("OK", (dialog, buttonIndex) -> {
dialog.dismiss();
String inputText1 = input.getText().toString().trim();
result.confirm(inputText1);
})
.setNegativeButton("Cancel", (dialog, buttonIndex) -> {
dialog.dismiss();
result.cancel();
})
.setOnCancelListener((dialog) -> {
dialog.dismiss();
result.cancel();
});
AlertDialog dialog = builder.create();
dialog.show();
return true;
}
/**
* Handle the browser geolocation permission prompt
* @param origin
* @param callback
*/
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
super.onGeolocationPermissionsShowPrompt(origin, callback);
Logger.debug("onGeolocationPermissionsShowPrompt: DOING IT HERE FOR ORIGIN: " + origin);
final String[] geoPermissions = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION };
if (!PermissionHelper.hasPermissions(bridge.getContext(), geoPermissions)) {
permissionListener = (isGranted) -> {
if (isGranted) {
callback.invoke(origin, true, false);
} else {
final String[] coarsePermission = { Manifest.permission.ACCESS_COARSE_LOCATION };
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
PermissionHelper.hasPermissions(bridge.getContext(), coarsePermission)
) {
callback.invoke(origin, true, false);
} else {
callback.invoke(origin, false, false);
}
}
};
permissionLauncher.launch(geoPermissions);
} else {
// permission is already granted
callback.invoke(origin, true, false);
Logger.debug("onGeolocationPermissionsShowPrompt: has required permission");
}
}
@Override
public boolean onShowFileChooser(
WebView webView,
final ValueCallback<Uri[]> filePathCallback,
final FileChooserParams fileChooserParams
) {
List<String> acceptTypes = Arrays.asList(fileChooserParams.getAcceptTypes());
boolean captureEnabled = fileChooserParams.isCaptureEnabled();
boolean capturePhoto = captureEnabled && acceptTypes.contains("image/*");
final boolean captureVideo = captureEnabled && acceptTypes.contains("video/*");
if ((capturePhoto || captureVideo)) {
if (isMediaCaptureSupported()) {
showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
} else {
permissionListener = (isGranted) -> {
if (isGranted) {
showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
} else {
Logger.warn(Logger.tags("FileChooser"), "Camera permission not granted");
filePathCallback.onReceiveValue(null);
}
};
final String[] camPermission = { Manifest.permission.CAMERA };
permissionLauncher.launch(camPermission);
}
} else {
showFilePicker(filePathCallback, fileChooserParams);
}
return true;
}
private boolean isMediaCaptureSupported() {
String[] permissions = { Manifest.permission.CAMERA };
return (
PermissionHelper.hasPermissions(bridge.getContext(), permissions) ||
!PermissionHelper.hasDefinedPermission(bridge.getContext(), Manifest.permission.CAMERA)
);
}
private void showMediaCaptureOrFilePicker(ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams, boolean isVideo) {
boolean shown;
if (isVideo) {
shown = showVideoCapturePicker(filePathCallback);
} else {
shown = showImageCapturePicker(filePathCallback);
}
if (!shown) {
Logger.warn(Logger.tags("FileChooser"), "Media capture intent could not be launched. Falling back to default file picker.");
showFilePicker(filePathCallback, fileChooserParams);
}
}
@SuppressLint("QueryPermissionsNeeded")
private boolean showImageCapturePicker(final ValueCallback<Uri[]> filePathCallback) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(bridge.getActivity().getPackageManager()) == null) {
return false;
}
final Uri imageFileUri;
try {
imageFileUri = createImageFileUri();
} catch (Exception ex) {
Logger.error("Unable to create temporary media capture file: " + ex.getMessage());
return false;
}
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri);
activityListener = (activityResult) -> {
Uri[] result = null;
if (activityResult.getResultCode() == Activity.RESULT_OK) {
result = new Uri[] { imageFileUri };
}
filePathCallback.onReceiveValue(result);
};
activityLauncher.launch(takePictureIntent);
return true;
}
@SuppressLint("QueryPermissionsNeeded")
private boolean showVideoCapturePicker(final ValueCallback<Uri[]> filePathCallback) {
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(bridge.getActivity().getPackageManager()) == null) {
return false;
}
activityListener = (activityResult) -> {
Uri[] result = null;
if (activityResult.getResultCode() == Activity.RESULT_OK) {
result = new Uri[] { activityResult.getData().getData() };
}
filePathCallback.onReceiveValue(result);
};
activityLauncher.launch(takeVideoIntent);
return true;
}
private void showFilePicker(final ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
Intent intent = fileChooserParams.createIntent();
if (fileChooserParams.getMode() == FileChooserParams.MODE_OPEN_MULTIPLE) {
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
}
if (fileChooserParams.getAcceptTypes().length > 1 || intent.getType().startsWith(".")) {
String[] validTypes = getValidTypes(fileChooserParams.getAcceptTypes());
intent.putExtra(Intent.EXTRA_MIME_TYPES, validTypes);
if (intent.getType().startsWith(".")) {
intent.setType(validTypes[0]);
}
}
try {
activityListener = (activityResult) -> {
Uri[] result;
Intent resultIntent = activityResult.getData();
if (activityResult.getResultCode() == Activity.RESULT_OK && resultIntent.getClipData() != null) {
final int numFiles = resultIntent.getClipData().getItemCount();
result = new Uri[numFiles];
for (int i = 0; i < numFiles; i++) {
result[i] = resultIntent.getClipData().getItemAt(i).getUri();
}
} else {
result = WebChromeClient.FileChooserParams.parseResult(activityResult.getResultCode(), resultIntent);
}
filePathCallback.onReceiveValue(result);
};
activityLauncher.launch(intent);
} catch (ActivityNotFoundException e) {
filePathCallback.onReceiveValue(null);
}
}
private String[] getValidTypes(String[] currentTypes) {
List<String> validTypes = new ArrayList<>();
MimeTypeMap mtm = MimeTypeMap.getSingleton();
for (String mime : currentTypes) {
if (mime.startsWith(".")) {
String extension = mime.substring(1);
String extensionMime = mtm.getMimeTypeFromExtension(extension);
if (extensionMime != null && !validTypes.contains(extensionMime)) {
validTypes.add(extensionMime);
}
} else if (!validTypes.contains(mime)) {
validTypes.add(mime);
}
}
Object[] validObj = validTypes.toArray();
return Arrays.copyOf(validObj, validObj.length, String[].class);
}
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
String tag = Logger.tags("Console");
if (consoleMessage.message() != null && isValidMsg(consoleMessage.message())) {
String msg = String.format(
"File: %s - Line %d - Msg: %s",
consoleMessage.sourceId(),
consoleMessage.lineNumber(),
consoleMessage.message()
);
String level = consoleMessage.messageLevel().name();
if ("ERROR".equalsIgnoreCase(level)) {
Logger.error(tag, msg, null);
} else if ("WARNING".equalsIgnoreCase(level)) {
Logger.warn(tag, msg);
} else if ("TIP".equalsIgnoreCase(level)) {
Logger.debug(tag, msg);
} else {
Logger.info(tag, msg);
}
}
return true;
}
public boolean isValidMsg(String msg) {
return !(msg.contains("%cresult %c") || (msg.contains("%cnative %c")) || msg.equalsIgnoreCase("console.groupEnd"));
}
private Uri createImageFileUri() throws IOException {
Activity activity = bridge.getActivity();
File photoFile = createImageFile(activity);
return FileProvider.getUriForFile(activity, bridge.getContext().getPackageName() + ".fileprovider", photoFile);
}
private File createImageFile(Activity activity) throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
return File.createTempFile(imageFileName, ".jpg", storageDir);
}
}

View File

@ -0,0 +1,117 @@
package com.getcapacitor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import java.util.List;
public class BridgeWebViewClient extends WebViewClient {
private Bridge bridge;
public BridgeWebViewClient(Bridge bridge) {
this.bridge = bridge;
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
return bridge.getLocalServer().shouldInterceptRequest(request);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
Uri url = request.getUrl();
return bridge.launchIntent(url);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
if (webViewListeners != null && view.getProgress() == 100) {
for (WebViewListener listener : bridge.getWebViewListeners()) {
listener.onPageLoaded(view);
}
}
}
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
if (webViewListeners != null) {
for (WebViewListener listener : bridge.getWebViewListeners()) {
listener.onReceivedError(view);
}
}
String errorPath = bridge.getErrorUrl();
if (errorPath != null && request.isForMainFrame()) {
view.loadUrl(errorPath);
}
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
bridge.reset();
List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
if (webViewListeners != null) {
for (WebViewListener listener : bridge.getWebViewListeners()) {
listener.onPageStarted(view);
}
}
}
@Override
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
super.onReceivedHttpError(view, request, errorResponse);
List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
if (webViewListeners != null) {
for (WebViewListener listener : bridge.getWebViewListeners()) {
listener.onReceivedHttpError(view);
}
}
String errorPath = bridge.getErrorUrl();
if (errorPath != null && request.isForMainFrame()) {
view.loadUrl(errorPath);
}
}
@Override
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) {
super.onRenderProcessGone(view, detail);
boolean result = false;
List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
if (webViewListeners != null) {
for (WebViewListener listener : bridge.getWebViewListeners()) {
result = listener.onRenderProcessGone(view, detail) || result;
}
}
return result;
}
@Override
public void onPageCommitVisible(WebView view, String url) {
super.onPageCommitVisible(view, url);
List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
if (webViewListeners != null) {
for (WebViewListener listener : bridge.getWebViewListeners()) {
listener.onPageCommitVisible(view, url);
}
}
}
}

View File

@ -0,0 +1,709 @@
package com.getcapacitor;
import static com.getcapacitor.Bridge.CAPACITOR_HTTPS_SCHEME;
import static com.getcapacitor.Bridge.DEFAULT_ANDROID_WEBVIEW_VERSION;
import static com.getcapacitor.Bridge.DEFAULT_HUAWEI_WEBVIEW_VERSION;
import static com.getcapacitor.Bridge.MINIMUM_ANDROID_WEBVIEW_VERSION;
import static com.getcapacitor.Bridge.MINIMUM_HUAWEI_WEBVIEW_VERSION;
import static com.getcapacitor.FileUtils.readFileFromAssets;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.AssetManager;
import androidx.annotation.Nullable;
import com.getcapacitor.util.JSONUtils;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Represents the configuration options for Capacitor
*/
public class CapConfig {
private static final String LOG_BEHAVIOR_NONE = "none";
private static final String LOG_BEHAVIOR_DEBUG = "debug";
private static final String LOG_BEHAVIOR_PRODUCTION = "production";
// Server Config
private boolean html5mode = true;
private String serverUrl;
private String hostname = "localhost";
private String androidScheme = CAPACITOR_HTTPS_SCHEME;
private String[] allowNavigation;
// Android Config
private String overriddenUserAgentString;
private String appendedUserAgentString;
private String backgroundColor;
private boolean allowMixedContent = false;
private boolean captureInput = false;
private boolean webContentsDebuggingEnabled = false;
private boolean loggingEnabled = true;
private boolean initialFocus = true;
private boolean useLegacyBridge = false;
private int minWebViewVersion = DEFAULT_ANDROID_WEBVIEW_VERSION;
private int minHuaweiWebViewVersion = DEFAULT_HUAWEI_WEBVIEW_VERSION;
private String errorPath;
private boolean zoomableWebView = false;
private boolean resolveServiceWorkerRequests = true;
// Embedded
private String startPath;
// Plugins
private Map<String, PluginConfig> pluginsConfiguration = null;
// Config Object JSON (legacy)
private JSONObject configJSON = new JSONObject();
/**
* Constructs an empty config file.
*/
private CapConfig() {}
/**
* Get an instance of the Config file object.
* @deprecated use {@link #loadDefault(Context)} to load an instance of the Config object
* from the capacitor.config.json file, or use the {@link CapConfig.Builder} to construct
* a CapConfig for embedded use.
*
* @param assetManager The AssetManager used to load the config file
* @param config JSON describing a configuration to use
*/
@Deprecated
public CapConfig(AssetManager assetManager, JSONObject config) {
if (config != null) {
this.configJSON = config;
} else {
// Load the capacitor.config.json
loadConfigFromAssets(assetManager, null);
}
deserializeConfig(null);
}
/**
* Constructs a Capacitor Configuration from config.json file.
*
* @param context The context.
* @return A loaded config file, if successful.
*/
public static CapConfig loadDefault(Context context) {
CapConfig config = new CapConfig();
if (context == null) {
Logger.error("Capacitor Config could not be created from file. Context must not be null.");
return config;
}
config.loadConfigFromAssets(context.getAssets(), null);
config.deserializeConfig(context);
return config;
}
/**
* Constructs a Capacitor Configuration from config.json file within the app assets.
*
* @param context The context.
* @param path A path relative to the root assets directory.
* @return A loaded config file, if successful.
*/
public static CapConfig loadFromAssets(Context context, String path) {
CapConfig config = new CapConfig();
if (context == null) {
Logger.error("Capacitor Config could not be created from file. Context must not be null.");
return config;
}
config.loadConfigFromAssets(context.getAssets(), path);
config.deserializeConfig(context);
return config;
}
/**
* Constructs a Capacitor Configuration from config.json file within the app file-space.
*
* @param context The context.
* @param path A path relative to the root of the app file-space.
* @return A loaded config file, if successful.
*/
public static CapConfig loadFromFile(Context context, String path) {
CapConfig config = new CapConfig();
if (context == null) {
Logger.error("Capacitor Config could not be created from file. Context must not be null.");
return config;
}
config.loadConfigFromFile(path);
config.deserializeConfig(context);
return config;
}
/**
* Constructs a Capacitor Configuration using ConfigBuilder.
*
* @param builder A config builder initialized with values
*/
private CapConfig(Builder builder) {
// Server Config
this.html5mode = builder.html5mode;
this.serverUrl = builder.serverUrl;
this.hostname = builder.hostname;
if (this.validateScheme(builder.androidScheme)) {
this.androidScheme = builder.androidScheme;
}
this.allowNavigation = builder.allowNavigation;
// Android Config
this.overriddenUserAgentString = builder.overriddenUserAgentString;
this.appendedUserAgentString = builder.appendedUserAgentString;
this.backgroundColor = builder.backgroundColor;
this.allowMixedContent = builder.allowMixedContent;
this.captureInput = builder.captureInput;
this.webContentsDebuggingEnabled = builder.webContentsDebuggingEnabled;
this.loggingEnabled = builder.loggingEnabled;
this.initialFocus = builder.initialFocus;
this.useLegacyBridge = builder.useLegacyBridge;
this.minWebViewVersion = builder.minWebViewVersion;
this.minHuaweiWebViewVersion = builder.minHuaweiWebViewVersion;
this.errorPath = builder.errorPath;
this.zoomableWebView = builder.zoomableWebView;
this.resolveServiceWorkerRequests = builder.resolveServiceWorkerRequests;
// Embedded
this.startPath = builder.startPath;
// Plugins Config
this.pluginsConfiguration = builder.pluginsConfiguration;
}
/**
* Loads a Capacitor Configuration JSON file into a Capacitor Configuration object.
* An optional path string can be provided to look for the config in a subdirectory path.
*/
private void loadConfigFromAssets(AssetManager assetManager, String path) {
if (path == null) {
path = "";
} else {
// Add slash at the end to form a proper file path if going deeper in assets dir
if (path.charAt(path.length() - 1) != '/') {
path = path + "/";
}
}
try {
String jsonString = readFileFromAssets(assetManager, path + "capacitor.config.json");
configJSON = new JSONObject(jsonString);
} catch (IOException ex) {
Logger.error("Unable to load capacitor.config.json. Run npx cap copy first", ex);
} catch (JSONException ex) {
Logger.error("Unable to parse capacitor.config.json. Make sure it's valid json", ex);
}
}
/**
* Loads a Capacitor Configuration JSON file into a Capacitor Configuration object.
* An optional path string can be provided to look for the config in a subdirectory path.
*/
private void loadConfigFromFile(String path) {
if (path == null) {
path = "";
} else {
// Add slash at the end to form a proper file path if going deeper in assets dir
if (path.charAt(path.length() - 1) != '/') {
path = path + "/";
}
}
try {
File configFile = new File(path + "capacitor.config.json");
String jsonString = FileUtils.readFileFromDisk(configFile);
configJSON = new JSONObject(jsonString);
} catch (JSONException ex) {
Logger.error("Unable to parse capacitor.config.json. Make sure it's valid json", ex);
} catch (IOException ex) {
Logger.error("Unable to load capacitor.config.json.", ex);
}
}
/**
* Deserializes the config from JSON into a Capacitor Configuration object.
*/
private void deserializeConfig(@Nullable Context context) {
boolean isDebug = context != null && (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
// Server
html5mode = JSONUtils.getBoolean(configJSON, "server.html5mode", html5mode);
serverUrl = JSONUtils.getString(configJSON, "server.url", null);
hostname = JSONUtils.getString(configJSON, "server.hostname", hostname);
errorPath = JSONUtils.getString(configJSON, "server.errorPath", null);
startPath = JSONUtils.getString(configJSON, "server.appStartPath", null);
String configSchema = JSONUtils.getString(configJSON, "server.androidScheme", androidScheme);
if (this.validateScheme(configSchema)) {
androidScheme = configSchema;
}
allowNavigation = JSONUtils.getArray(configJSON, "server.allowNavigation", null);
// Android
overriddenUserAgentString = JSONUtils.getString(
configJSON,
"android.overrideUserAgent",
JSONUtils.getString(configJSON, "overrideUserAgent", null)
);
appendedUserAgentString = JSONUtils.getString(
configJSON,
"android.appendUserAgent",
JSONUtils.getString(configJSON, "appendUserAgent", null)
);
backgroundColor = JSONUtils.getString(
configJSON,
"android.backgroundColor",
JSONUtils.getString(configJSON, "backgroundColor", null)
);
allowMixedContent = JSONUtils.getBoolean(
configJSON,
"android.allowMixedContent",
JSONUtils.getBoolean(configJSON, "allowMixedContent", allowMixedContent)
);
minWebViewVersion = JSONUtils.getInt(configJSON, "android.minWebViewVersion", DEFAULT_ANDROID_WEBVIEW_VERSION);
minHuaweiWebViewVersion = JSONUtils.getInt(configJSON, "android.minHuaweiWebViewVersion", DEFAULT_HUAWEI_WEBVIEW_VERSION);
captureInput = JSONUtils.getBoolean(configJSON, "android.captureInput", captureInput);
useLegacyBridge = JSONUtils.getBoolean(configJSON, "android.useLegacyBridge", useLegacyBridge);
webContentsDebuggingEnabled = JSONUtils.getBoolean(configJSON, "android.webContentsDebuggingEnabled", isDebug);
zoomableWebView = JSONUtils.getBoolean(configJSON, "android.zoomEnabled", JSONUtils.getBoolean(configJSON, "zoomEnabled", false));
resolveServiceWorkerRequests = JSONUtils.getBoolean(configJSON, "android.resolveServiceWorkerRequests", true);
String logBehavior = JSONUtils.getString(
configJSON,
"android.loggingBehavior",
JSONUtils.getString(configJSON, "loggingBehavior", LOG_BEHAVIOR_DEBUG)
);
switch (logBehavior.toLowerCase(Locale.ROOT)) {
case LOG_BEHAVIOR_PRODUCTION:
loggingEnabled = true;
break;
case LOG_BEHAVIOR_NONE:
loggingEnabled = false;
break;
default: // LOG_BEHAVIOR_DEBUG
loggingEnabled = isDebug;
}
initialFocus = JSONUtils.getBoolean(
configJSON,
"android.initialFocus",
JSONUtils.getBoolean(configJSON, "initialFocus", initialFocus)
);
// Plugins
pluginsConfiguration = deserializePluginsConfig(JSONUtils.getObject(configJSON, "plugins"));
}
private boolean validateScheme(String scheme) {
List<String> invalidSchemes = Arrays.asList("file", "ftp", "ftps", "ws", "wss", "about", "blob", "data");
if (invalidSchemes.contains(scheme)) {
Logger.warn(scheme + " is not an allowed scheme. Defaulting to https.");
return false;
}
// Non-http(s) schemes are not allowed to modify the URL path as of Android Webview 117
if (!scheme.equals("http") && !scheme.equals("https")) {
Logger.warn(
"Using a non-standard scheme: " + scheme + " for Android. This is known to cause issues as of Android Webview 117."
);
}
return true;
}
public boolean isHTML5Mode() {
return html5mode;
}
public String getServerUrl() {
return serverUrl;
}
public String getErrorPath() {
return errorPath;
}
public String getHostname() {
return hostname;
}
public String getStartPath() {
return startPath;
}
public String getAndroidScheme() {
return androidScheme;
}
public String[] getAllowNavigation() {
return allowNavigation;
}
public String getOverriddenUserAgentString() {
return overriddenUserAgentString;
}
public String getAppendedUserAgentString() {
return appendedUserAgentString;
}
public String getBackgroundColor() {
return backgroundColor;
}
public boolean isMixedContentAllowed() {
return allowMixedContent;
}
public boolean isInputCaptured() {
return captureInput;
}
public boolean isResolveServiceWorkerRequests() {
return resolveServiceWorkerRequests;
}
public boolean isWebContentsDebuggingEnabled() {
return webContentsDebuggingEnabled;
}
public boolean isZoomableWebView() {
return zoomableWebView;
}
public boolean isLoggingEnabled() {
return loggingEnabled;
}
public boolean isInitialFocus() {
return initialFocus;
}
public boolean isUsingLegacyBridge() {
return useLegacyBridge;
}
public int getMinWebViewVersion() {
if (minWebViewVersion < MINIMUM_ANDROID_WEBVIEW_VERSION) {
Logger.warn("Specified minimum webview version is too low, defaulting to " + MINIMUM_ANDROID_WEBVIEW_VERSION);
return MINIMUM_ANDROID_WEBVIEW_VERSION;
}
return minWebViewVersion;
}
public int getMinHuaweiWebViewVersion() {
if (minHuaweiWebViewVersion < MINIMUM_HUAWEI_WEBVIEW_VERSION) {
Logger.warn("Specified minimum Huawei webview version is too low, defaulting to " + MINIMUM_HUAWEI_WEBVIEW_VERSION);
return MINIMUM_HUAWEI_WEBVIEW_VERSION;
}
return minHuaweiWebViewVersion;
}
public PluginConfig getPluginConfiguration(String pluginId) {
PluginConfig pluginConfig = pluginsConfiguration.get(pluginId);
if (pluginConfig == null) {
pluginConfig = new PluginConfig(new JSONObject());
}
return pluginConfig;
}
/**
* Get a JSON object value from the Capacitor config.
* @deprecated use {@link PluginConfig#getObject(String)} to access plugin config values.
* For main Capacitor config values, use the appropriate getter.
*
* @param key A key to fetch from the config
* @return The value from the config, if exists. Null if not
*/
@Deprecated
public JSONObject getObject(String key) {
try {
return configJSON.getJSONObject(key);
} catch (Exception ex) {}
return null;
}
/**
* Get a string value from the Capacitor config.
* @deprecated use {@link PluginConfig#getString(String, String)} to access plugin config
* values. For main Capacitor config values, use the appropriate getter.
*
* @param key A key to fetch from the config
* @return The value from the config, if exists. Null if not
*/
@Deprecated
public String getString(String key) {
return JSONUtils.getString(configJSON, key, null);
}
/**
* Get a string value from the Capacitor config.
* @deprecated use {@link PluginConfig#getString(String, String)} to access plugin config
* values. For main Capacitor config values, use the appropriate getter.
*
* @param key A key to fetch from the config
* @param defaultValue A default value to return if the key does not exist in the config
* @return The value from the config, if key exists. Default value returned if not
*/
@Deprecated
public String getString(String key, String defaultValue) {
return JSONUtils.getString(configJSON, key, defaultValue);
}
/**
* Get a boolean value from the Capacitor config.
* @deprecated use {@link PluginConfig#getBoolean(String, boolean)} to access plugin config
* values. For main Capacitor config values, use the appropriate getter.
*
* @param key A key to fetch from the config
* @param defaultValue A default value to return if the key does not exist in the config
* @return The value from the config, if key exists. Default value returned if not
*/
@Deprecated
public boolean getBoolean(String key, boolean defaultValue) {
return JSONUtils.getBoolean(configJSON, key, defaultValue);
}
/**
* Get an integer value from the Capacitor config.
* @deprecated use {@link PluginConfig#getInt(String, int)} to access the plugin config
* values. For main Capacitor config values, use the appropriate getter.
*
* @param key A key to fetch from the config
* @param defaultValue A default value to return if the key does not exist in the config
* @return The value from the config, if key exists. Default value returned if not
*/
@Deprecated
public int getInt(String key, int defaultValue) {
return JSONUtils.getInt(configJSON, key, defaultValue);
}
/**
* Get a string array value from the Capacitor config.
* @deprecated use {@link PluginConfig#getArray(String)} to access the plugin config
* values. For main Capacitor config values, use the appropriate getter.
*
* @param key A key to fetch from the config
* @return The value from the config, if exists. Null if not
*/
@Deprecated
public String[] getArray(String key) {
return JSONUtils.getArray(configJSON, key, null);
}
/**
* Get a string array value from the Capacitor config.
* @deprecated use {@link PluginConfig#getArray(String, String[])} to access the plugin
* config values. For main Capacitor config values, use the appropriate getter.
*
* @param key A key to fetch from the config
* @param defaultValue A default value to return if the key does not exist in the config
* @return The value from the config, if key exists. Default value returned if not
*/
@Deprecated
public String[] getArray(String key, String[] defaultValue) {
return JSONUtils.getArray(configJSON, key, defaultValue);
}
private static Map<String, PluginConfig> deserializePluginsConfig(JSONObject pluginsConfig) {
Map<String, PluginConfig> pluginsMap = new HashMap<>();
// return an empty map if there is no pluginsConfig json
if (pluginsConfig == null) {
return pluginsMap;
}
Iterator<String> pluginIds = pluginsConfig.keys();
while (pluginIds.hasNext()) {
String pluginId = pluginIds.next();
JSONObject value = null;
try {
value = pluginsConfig.getJSONObject(pluginId);
PluginConfig pluginConfig = new PluginConfig(value);
pluginsMap.put(pluginId, pluginConfig);
} catch (JSONException e) {
e.printStackTrace();
}
}
return pluginsMap;
}
/**
* Builds a Capacitor Configuration in code
*/
public static class Builder {
private Context context;
// Server Config Values
private boolean html5mode = true;
private String serverUrl;
private String errorPath;
private String hostname = "localhost";
private String androidScheme = CAPACITOR_HTTPS_SCHEME;
private String[] allowNavigation;
// Android Config Values
private String overriddenUserAgentString;
private String appendedUserAgentString;
private String backgroundColor;
private boolean allowMixedContent = false;
private boolean captureInput = false;
private Boolean webContentsDebuggingEnabled = null;
private boolean loggingEnabled = true;
private boolean initialFocus = false;
private boolean useLegacyBridge = false;
private int minWebViewVersion = DEFAULT_ANDROID_WEBVIEW_VERSION;
private int minHuaweiWebViewVersion = DEFAULT_HUAWEI_WEBVIEW_VERSION;
private boolean zoomableWebView = false;
private boolean resolveServiceWorkerRequests = true;
// Embedded
private String startPath = null;
// Plugins Config Object
private Map<String, PluginConfig> pluginsConfiguration = new HashMap<>();
/**
* Constructs a new CapConfig Builder.
*
* @param context The context
*/
public Builder(Context context) {
this.context = context;
}
/**
* Builds a Capacitor Config from the builder.
*
* @return A new Capacitor Config
*/
public CapConfig create() {
if (webContentsDebuggingEnabled == null) {
webContentsDebuggingEnabled = (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
}
return new CapConfig(this);
}
public Builder setPluginsConfiguration(JSONObject pluginsConfiguration) {
this.pluginsConfiguration = deserializePluginsConfig(pluginsConfiguration);
return this;
}
public Builder setHTML5mode(boolean html5mode) {
this.html5mode = html5mode;
return this;
}
public Builder setServerUrl(String serverUrl) {
this.serverUrl = serverUrl;
return this;
}
public Builder setErrorPath(String errorPath) {
this.errorPath = errorPath;
return this;
}
public Builder setHostname(String hostname) {
this.hostname = hostname;
return this;
}
public Builder setStartPath(String path) {
this.startPath = path;
return this;
}
public Builder setAndroidScheme(String androidScheme) {
this.androidScheme = androidScheme;
return this;
}
public Builder setAllowNavigation(String[] allowNavigation) {
this.allowNavigation = allowNavigation;
return this;
}
public Builder setOverriddenUserAgentString(String overriddenUserAgentString) {
this.overriddenUserAgentString = overriddenUserAgentString;
return this;
}
public Builder setAppendedUserAgentString(String appendedUserAgentString) {
this.appendedUserAgentString = appendedUserAgentString;
return this;
}
public Builder setBackgroundColor(String backgroundColor) {
this.backgroundColor = backgroundColor;
return this;
}
public Builder setAllowMixedContent(boolean allowMixedContent) {
this.allowMixedContent = allowMixedContent;
return this;
}
public Builder setCaptureInput(boolean captureInput) {
this.captureInput = captureInput;
return this;
}
public Builder setUseLegacyBridge(boolean useLegacyBridge) {
this.useLegacyBridge = useLegacyBridge;
return this;
}
public Builder setResolveServiceWorkerRequests(boolean resolveServiceWorkerRequests) {
this.resolveServiceWorkerRequests = resolveServiceWorkerRequests;
return this;
}
public Builder setWebContentsDebuggingEnabled(boolean webContentsDebuggingEnabled) {
this.webContentsDebuggingEnabled = webContentsDebuggingEnabled;
return this;
}
public Builder setZoomableWebView(boolean zoomableWebView) {
this.zoomableWebView = zoomableWebView;
return this;
}
public Builder setLoggingEnabled(boolean enabled) {
this.loggingEnabled = enabled;
return this;
}
public Builder setInitialFocus(boolean focus) {
this.initialFocus = focus;
return this;
}
}
}

View File

@ -0,0 +1,57 @@
package com.getcapacitor;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.webkit.WebView;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class CapacitorWebView extends WebView {
private BaseInputConnection capInputConnection;
private Bridge bridge;
public CapacitorWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setBridge(Bridge bridge) {
this.bridge = bridge;
}
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
CapConfig config;
if (bridge != null) {
config = bridge.getConfig();
} else {
config = CapConfig.loadDefault(getContext());
}
boolean captureInput = config.isInputCaptured();
if (captureInput) {
if (capInputConnection == null) {
capInputConnection = new BaseInputConnection(this, false);
}
return capInputConnection;
}
return super.onCreateInputConnection(outAttrs);
}
@Override
@SuppressWarnings("deprecation")
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_MULTIPLE) {
evaluateJavascript("document.activeElement.value = document.activeElement.value + '" + event.getCharacters() + "';", null);
return false;
}
return super.dispatchKeyEvent(event);
}
}

Some files were not shown because too many files have changed in this diff Show More