-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add core classes for Capacitor framework in Java
- Introduced `Bridge` class to manage loading and communication with plugins, proxying native events, and interacting with the WebView. - Added `Plugin` base class for creating new plugins, including features for interacting with the `Bridge`, managing permissions, and tracking lifecycle events. - Implemented `WebViewLocalServer` to host assets, resources, and other data on virtual URLs, compatible with the Same-Origin policy. - Included various utility classes and methods to support the core functionality, such as `CapConfig`, `JSInjector`, `AndroidProtocolHandler`, and more. - Added annotations and helper classes for managing permissions and activity results. - Removed obsolete `bun.lockb` files.
- Loading branch information
1 parent
e25e769
commit 2b7ed4d
Showing
115 changed files
with
12,260 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/> | ||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
<classpathentry kind="output" path="bin/default"/> | ||
</classpath> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+17 Bytes
@capacitor/capacitor/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
@capacitor/capacitor/.gradle/buildOutputCleanup/cache.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Sun Aug 04 19:10:26 UTC 2024 | ||
gradle.version=8.8 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>capacitor-android</name> | ||
<comment>Project capacitor-android created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
<filteredResources> | ||
<filter> | ||
<id>1722756069615</id> | ||
<name></name> | ||
<type>30</type> | ||
<matcher> | ||
<id>org.eclipse.core.resources.regexFilterMatcher</id> | ||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments> | ||
</matcher> | ||
</filter> | ||
</filteredResources> | ||
</projectDescription> |
13 changes: 13 additions & 0 deletions
13
@capacitor/capacitor/.settings/org.eclipse.buildship.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
arguments=--init-script /home/gitpod/.vscode-server/data/User/globalStorage/redhat.java/1.33.0/config_linux/org.eclipse.osgi/55/0/.cp/gradle/init/init.gradle --init-script /home/gitpod/.vscode-server/data/User/globalStorage/redhat.java/1.33.0/config_linux/org.eclipse.osgi/55/0/.cp/gradle/protobuf/init.gradle | ||
auto.sync=false | ||
build.scans.enabled=false | ||
connection.gradle.distribution=GRADLE_DISTRIBUTION(LOCAL_INSTALLATION(/home/gitpod/.sdkman/candidates/gradle/current)) | ||
connection.project.dir= | ||
eclipse.preferences.version=1 | ||
gradle.user.home=/workspace/.gradle | ||
java.home=/home/gitpod/.sdkman/candidates/java/11.0.23.fx-zulu | ||
jvm.arguments= | ||
offline.mode=false | ||
override.workspace.settings=true | ||
show.console.view=true | ||
show.executions.view=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
ext { | ||
androidxActivityVersion = project.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.7.0' | ||
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1' | ||
androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.2.0' | ||
androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.10.0' | ||
androidxFragmentVersion = project.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.5.6' | ||
androidxWebkitVersion = project.hasProperty('androidxWebkitVersion') ? rootProject.ext.androidxWebkitVersion : '1.6.1' | ||
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2' | ||
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5' | ||
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1' | ||
cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '10.1.1' | ||
} | ||
|
||
|
||
buildscript { | ||
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.8.20' | ||
repositories { | ||
google() | ||
mavenCentral() | ||
maven { | ||
url "https://plugins.gradle.org/m2/" | ||
} | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:8.0.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" | ||
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33 | ||
defaultConfig { | ||
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22 | ||
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33 | ||
versionCode 1 | ||
versionName "1.0" | ||
consumerProguardFiles 'proguard-rules.pro' | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
lintOptions { | ||
baseline file("lint-baseline.xml") | ||
abortOnError true | ||
warningsAsErrors true | ||
lintConfig file('lint.xml') | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_17 | ||
targetCompatibility JavaVersion.VERSION_17 | ||
} | ||
publishing { | ||
singleVariant("release") | ||
} | ||
} | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation platform("org.jetbrains.kotlin:kotlin-bom:$kotlin_version") | ||
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:20231013' | ||
testImplementation 'org.mockito:mockito-inline:5.2.0' | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("Accept") && header.getValue().toLowerCase().contains("text/html")) {" | ||
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("yyyyMMdd_HHmmss").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("yyyy-MM-dd'T'HH:mm'Z'");" | ||
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="#F0FF1414"" | ||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> | ||
<location | ||
file="src/main/res/layout/fragment_bridge.xml" | ||
line="5" | ||
column="5"/> | ||
</issue> | ||
|
||
</issues> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
</manifest> |
Oops, something went wrong.