@ionic/capacitor-ttfd-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.0.2'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.multimeter.performance"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdk project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
25
|
+
targetSdk project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
dependencies {
|
|
51
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
52
|
+
implementation project(':capacitor-android')
|
|
53
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
54
|
+
testImplementation "junit:junit:$junitVersion"
|
|
55
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
57
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
package com.multimeter.performance;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.os.Build;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
7
|
+
import com.getcapacitor.Plugin;
|
|
8
|
+
import com.getcapacitor.PluginCall;
|
|
9
|
+
import com.getcapacitor.PluginMethod;
|
|
10
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
11
|
+
|
|
12
|
+
@CapacitorPlugin(name = "TTFDPerformance")
|
|
13
|
+
public class TTFDPerformancePlugin extends Plugin {
|
|
14
|
+
|
|
15
|
+
private static final String TAG = "TTFDPerformancePlugin";
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public void load() {
|
|
19
|
+
super.load();
|
|
20
|
+
Log.i(TAG, "TTFDPerformance Plugin loaded successfully!");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@PluginMethod
|
|
24
|
+
public void reportFullyDrawn(PluginCall call) {
|
|
25
|
+
Activity activity = getActivity();
|
|
26
|
+
|
|
27
|
+
if (activity == null) {
|
|
28
|
+
String error = "Activity not available";
|
|
29
|
+
Log.e(TAG, error);
|
|
30
|
+
call.reject(error);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
// Call reportFullyDrawn() - available since API 19
|
|
36
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
37
|
+
activity.reportFullyDrawn();
|
|
38
|
+
|
|
39
|
+
call.resolve();
|
|
40
|
+
} else {
|
|
41
|
+
String error = "reportFullyDrawn() requires API level 19 (KitKat) or higher";
|
|
42
|
+
Log.w(TAG, error);
|
|
43
|
+
call.reject(error);
|
|
44
|
+
}
|
|
45
|
+
} catch (Exception e) {
|
|
46
|
+
String error = "Failed to call reportFullyDrawn(): " + e.getMessage();
|
|
47
|
+
Log.e(TAG, error, e);
|
|
48
|
+
call.reject(error, e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ionic/capacitor-ttfd-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Capacitor plugin for TTFD (Time to Fully Drawn) performance measurement",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Plugin/"
|
|
14
|
+
],
|
|
15
|
+
"author": "OutSystems",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/ionic-team/multimeter.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"capacitor",
|
|
23
|
+
"plugin",
|
|
24
|
+
"performance",
|
|
25
|
+
"ttfd",
|
|
26
|
+
"android"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "npm run clean && tsc && rollup -c rollup.config.mjs",
|
|
30
|
+
"clean": "rimraf ./dist",
|
|
31
|
+
"watch": "tsc --watch"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@capacitor/android": "^6.0.0",
|
|
35
|
+
"@capacitor/core": "^6.0.0",
|
|
36
|
+
"@capacitor/ios": "^6.0.0",
|
|
37
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
38
|
+
"rimraf": "^5.0.5",
|
|
39
|
+
"rollup": "^4.9.6",
|
|
40
|
+
"typescript": "^5.4.2"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@capacitor/core": "^6.0.0"
|
|
44
|
+
},
|
|
45
|
+
"capacitor": {
|
|
46
|
+
"ios": {
|
|
47
|
+
"src": "ios"
|
|
48
|
+
},
|
|
49
|
+
"android": {
|
|
50
|
+
"src": "android"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|