@capacitor/haptics 8.0.1 → 9.0.0-next.1
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.
- package/CapacitorHaptics.podspec +1 -1
- package/Package.swift +3 -4
- package/README.md +1 -1
- package/android/build.gradle +3 -4
- package/android/src/main/java/com/capacitorjs/plugins/haptics/Haptics.java +2 -20
- package/android/src/main/java/com/capacitorjs/plugins/haptics/arguments/HapticsImpactType.java +4 -11
- package/android/src/main/java/com/capacitorjs/plugins/haptics/arguments/HapticsNotificationType.java +4 -16
- package/android/src/main/java/com/capacitorjs/plugins/haptics/arguments/HapticsSelectionType.java +0 -6
- package/android/src/main/java/com/capacitorjs/plugins/haptics/arguments/HapticsVibrationType.java +0 -2
- package/dist/docs.json +1 -1
- package/dist/esm/definitions.d.ts +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/package.json +5 -5
package/CapacitorHaptics.podspec
CHANGED
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => 'https://github.com/ionic-team/capacitor-haptics.git', :tag => 'v' + package['version'] }
|
|
13
13
|
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}', 'haptics/ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '16.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/Package.swift
CHANGED
|
@@ -3,21 +3,20 @@ import PackageDescription
|
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
5
|
name: "CapacitorHaptics",
|
|
6
|
-
platforms: [.iOS(.
|
|
6
|
+
platforms: [.iOS(.v16)],
|
|
7
7
|
products: [
|
|
8
8
|
.library(
|
|
9
9
|
name: "CapacitorHaptics",
|
|
10
10
|
targets: ["HapticsPlugin"])
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "9.0.0-alpha.5")
|
|
14
14
|
],
|
|
15
15
|
targets: [
|
|
16
16
|
.target(
|
|
17
17
|
name: "HapticsPlugin",
|
|
18
18
|
dependencies: [
|
|
19
|
-
.product(name: "Capacitor", package: "capacitor-swift-pm")
|
|
20
|
-
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm")
|
|
21
20
|
],
|
|
22
21
|
path: "ios/Sources/HapticsPlugin"),
|
|
23
22
|
.testTarget(
|
package/README.md
CHANGED
|
@@ -166,7 +166,7 @@ For example, call this when a user has lifted their finger from a control
|
|
|
166
166
|
|
|
167
167
|
| Prop | Type | Description | Default | Since |
|
|
168
168
|
| ---------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ----- |
|
|
169
|
-
| **`type`** | <code><a href="#notificationtype">NotificationType</a></code> | Notification Feedback Type The type of notification feedback generated by a [UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbacktype) object. | <code>NotificationType.
|
|
169
|
+
| **`type`** | <code><a href="#notificationtype">NotificationType</a></code> | Notification Feedback Type The type of notification feedback generated by a [UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbacktype) object. | <code>NotificationType.Success</code> | 1.0.0 |
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
#### VibrateOptions
|
package/android/build.gradle
CHANGED
|
@@ -15,7 +15,7 @@ buildscript {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
dependencies {
|
|
18
|
-
classpath 'com.android.tools.build:gradle:
|
|
18
|
+
classpath 'com.android.tools.build:gradle:9.2.1'
|
|
19
19
|
if (System.getenv("CAP_PLUGIN_PUBLISH") == "true") {
|
|
20
20
|
classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
|
|
21
21
|
}
|
|
@@ -31,10 +31,9 @@ if (System.getenv("CAP_PLUGIN_PUBLISH") == "true") {
|
|
|
31
31
|
|
|
32
32
|
android {
|
|
33
33
|
namespace = "com.capacitorjs.plugins.haptics"
|
|
34
|
-
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
34
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 37
|
|
35
35
|
defaultConfig {
|
|
36
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
37
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
36
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
|
|
38
37
|
versionCode 1
|
|
39
38
|
versionName "1.0"
|
|
40
39
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -28,21 +28,7 @@ public class Haptics {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
public void vibrate(int duration) {
|
|
31
|
-
|
|
32
|
-
vibrator.vibrate(VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE));
|
|
33
|
-
} else {
|
|
34
|
-
vibratePre26(duration);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@SuppressWarnings({ "deprecation" })
|
|
39
|
-
private void vibratePre26(int duration) {
|
|
40
|
-
vibrator.vibrate(duration);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@SuppressWarnings({ "deprecation" })
|
|
44
|
-
private void vibratePre26(long[] pattern) {
|
|
45
|
-
vibrator.vibrate(pattern, -1);
|
|
31
|
+
vibrator.vibrate(VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE));
|
|
46
32
|
}
|
|
47
33
|
|
|
48
34
|
public void selectionStart() {
|
|
@@ -60,10 +46,6 @@ public class Haptics {
|
|
|
60
46
|
}
|
|
61
47
|
|
|
62
48
|
public void performHaptics(HapticsVibrationType type) {
|
|
63
|
-
|
|
64
|
-
vibrator.vibrate(VibrationEffect.createWaveform(type.getTimings(), type.getAmplitudes(), -1));
|
|
65
|
-
} else {
|
|
66
|
-
vibratePre26(type.getOldSDKPattern());
|
|
67
|
-
}
|
|
49
|
+
vibrator.vibrate(VibrationEffect.createWaveform(type.getTimings(), type.getAmplitudes(), -1));
|
|
68
50
|
}
|
|
69
51
|
}
|
package/android/src/main/java/com/capacitorjs/plugins/haptics/arguments/HapticsImpactType.java
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
package com.capacitorjs.plugins.haptics.arguments;
|
|
2
2
|
|
|
3
3
|
public enum HapticsImpactType implements HapticsVibrationType {
|
|
4
|
-
LIGHT("LIGHT", new long[] { 0, 50 }, new int[] { 0, 110 }
|
|
5
|
-
MEDIUM("MEDIUM", new long[] { 0, 43 }, new int[] { 0, 180 }
|
|
6
|
-
HEAVY("HEAVY", new long[] { 0, 60 }, new int[] { 0, 255 }
|
|
4
|
+
LIGHT("LIGHT", new long[] { 0, 50 }, new int[] { 0, 110 }),
|
|
5
|
+
MEDIUM("MEDIUM", new long[] { 0, 43 }, new int[] { 0, 180 }),
|
|
6
|
+
HEAVY("HEAVY", new long[] { 0, 60 }, new int[] { 0, 255 });
|
|
7
7
|
|
|
8
8
|
private final String type;
|
|
9
9
|
private final long[] timings;
|
|
10
10
|
private final int[] amplitudes;
|
|
11
|
-
private final long[] oldSDKPattern;
|
|
12
11
|
|
|
13
|
-
HapticsImpactType(String type, long[] timings, int[] amplitudes
|
|
12
|
+
HapticsImpactType(String type, long[] timings, int[] amplitudes) {
|
|
14
13
|
this.type = type;
|
|
15
14
|
this.timings = timings;
|
|
16
15
|
this.amplitudes = amplitudes;
|
|
17
|
-
this.oldSDKPattern = oldSDKPattern;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
public static HapticsImpactType fromString(String style) {
|
|
@@ -35,9 +33,4 @@ public enum HapticsImpactType implements HapticsVibrationType {
|
|
|
35
33
|
public int[] getAmplitudes() {
|
|
36
34
|
return amplitudes;
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
@Override
|
|
40
|
-
public long[] getOldSDKPattern() {
|
|
41
|
-
return oldSDKPattern;
|
|
42
|
-
}
|
|
43
36
|
}
|
package/android/src/main/java/com/capacitorjs/plugins/haptics/arguments/HapticsNotificationType.java
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
package com.capacitorjs.plugins.haptics.arguments;
|
|
2
2
|
|
|
3
3
|
public enum HapticsNotificationType implements HapticsVibrationType {
|
|
4
|
-
SUCCESS("SUCCESS", new long[] { 0, 35, 65, 21 }, new int[] { 0, 250, 0, 180 }
|
|
5
|
-
WARNING(
|
|
6
|
-
|
|
7
|
-
new long[] { 0, 30, 40, 30, 50, 60 },
|
|
8
|
-
new int[] { 255, 255, 255, 255, 255, 255 },
|
|
9
|
-
new long[] { 0, 30, 40, 30, 50, 60 }
|
|
10
|
-
),
|
|
11
|
-
ERROR("ERROR", new long[] { 0, 27, 45, 50 }, new int[] { 0, 120, 0, 250 }, new long[] { 0, 27, 45, 50 });
|
|
4
|
+
SUCCESS("SUCCESS", new long[] { 0, 35, 65, 21 }, new int[] { 0, 250, 0, 180 }),
|
|
5
|
+
WARNING("WARNING", new long[] { 0, 30, 40, 30, 50, 60 }, new int[] { 255, 255, 255, 255, 255, 255 }),
|
|
6
|
+
ERROR("ERROR", new long[] { 0, 27, 45, 50 }, new int[] { 0, 120, 0, 250 });
|
|
12
7
|
|
|
13
8
|
private final String type;
|
|
14
9
|
private final long[] timings;
|
|
15
10
|
private final int[] amplitudes;
|
|
16
|
-
private final long[] oldSDKPattern;
|
|
17
11
|
|
|
18
|
-
HapticsNotificationType(String type, long[] timings, int[] amplitudes
|
|
12
|
+
HapticsNotificationType(String type, long[] timings, int[] amplitudes) {
|
|
19
13
|
this.type = type;
|
|
20
14
|
this.timings = timings;
|
|
21
15
|
this.amplitudes = amplitudes;
|
|
22
|
-
this.oldSDKPattern = oldSDKPattern;
|
|
23
16
|
}
|
|
24
17
|
|
|
25
18
|
public static HapticsNotificationType fromString(String type) {
|
|
@@ -40,9 +33,4 @@ public enum HapticsNotificationType implements HapticsVibrationType {
|
|
|
40
33
|
public int[] getAmplitudes() {
|
|
41
34
|
return amplitudes;
|
|
42
35
|
}
|
|
43
|
-
|
|
44
|
-
@Override
|
|
45
|
-
public long[] getOldSDKPattern() {
|
|
46
|
-
return oldSDKPattern;
|
|
47
|
-
}
|
|
48
36
|
}
|
package/android/src/main/java/com/capacitorjs/plugins/haptics/arguments/HapticsSelectionType.java
CHANGED
|
@@ -4,7 +4,6 @@ public class HapticsSelectionType implements HapticsVibrationType {
|
|
|
4
4
|
|
|
5
5
|
private static final long[] timings = { 0, 100 };
|
|
6
6
|
private static final int[] amplitudes = { 0, 100 };
|
|
7
|
-
private static final long[] oldSDKPattern = { 0, 70 };
|
|
8
7
|
|
|
9
8
|
@Override
|
|
10
9
|
public long[] getTimings() {
|
|
@@ -15,9 +14,4 @@ public class HapticsSelectionType implements HapticsVibrationType {
|
|
|
15
14
|
public int[] getAmplitudes() {
|
|
16
15
|
return amplitudes;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
@Override
|
|
20
|
-
public long[] getOldSDKPattern() {
|
|
21
|
-
return oldSDKPattern;
|
|
22
|
-
}
|
|
23
17
|
}
|
package/dist/docs.json
CHANGED
|
@@ -76,7 +76,7 @@ export interface NotificationOptions {
|
|
|
76
76
|
*
|
|
77
77
|
* The type of notification feedback generated by a [UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbacktype) object.
|
|
78
78
|
*
|
|
79
|
-
* @default NotificationType.
|
|
79
|
+
* @default NotificationType.Success
|
|
80
80
|
* @since 1.0.0
|
|
81
81
|
*/
|
|
82
82
|
type: NotificationType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA2DA,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;;;OAIG;IACH,8BAAe,CAAA;IAEf;;;;OAIG;IACH,gCAAiB,CAAA;IAEjB;;;;OAIG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB;AAcD,MAAM,CAAN,IAAY,gBAqBX;AArBD,WAAY,gBAAgB;IAC1B;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,mCAAe,CAAA;AACjB,CAAC,EArBW,gBAAgB,KAAhB,gBAAgB,QAqB3B","sourcesContent":["export interface HapticsPlugin {\n /**\n * Trigger a haptics \"impact\" feedback\n *\n * @since 1.0.0\n */\n impact(options?: ImpactOptions): Promise<void>;\n\n /**\n * Trigger a haptics \"notification\" feedback\n *\n * @since 1.0.0\n */\n notification(options?: NotificationOptions): Promise<void>;\n\n /**\n * Vibrate the device\n *\n * @since 1.0.0\n */\n vibrate(options?: VibrateOptions): Promise<void>;\n\n /**\n * Trigger a selection started haptic hint\n *\n * @since 1.0.0\n */\n selectionStart(): Promise<void>;\n\n /**\n * Trigger a selection changed haptic hint. If a selection was\n * started already, this will cause the device to provide haptic\n * feedback\n *\n * @since 1.0.0\n */\n selectionChanged(): Promise<void>;\n\n /**\n * If selectionStart() was called, selectionEnd() ends the selection.\n * For example, call this when a user has lifted their finger from a control\n *\n * @since 1.0.0\n */\n selectionEnd(): Promise<void>;\n}\n\nexport interface ImpactOptions {\n /**\n * Impact Feedback Style\n *\n * The mass of the objects in the collision simulated by a [UIImpactFeedbackGenerator](https://developer.apple.com/documentation/uikit/uiimpactfeedbackstyle) object.\n *\n * @default ImpactStyle.Heavy\n * @since 1.0.0\n */\n style: ImpactStyle;\n}\n\nexport enum ImpactStyle {\n /**\n * A collision between large, heavy user interface elements\n *\n * @since 1.0.0\n */\n Heavy = 'HEAVY',\n\n /**\n * A collision between moderately sized user interface elements\n *\n * @since 1.0.0\n */\n Medium = 'MEDIUM',\n\n /**\n * A collision between small, light user interface elements\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n}\n\nexport interface NotificationOptions {\n /**\n * Notification Feedback Type\n *\n * The type of notification feedback generated by a [UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbacktype) object.\n *\n * @default NotificationType.
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA2DA,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;;;OAIG;IACH,8BAAe,CAAA;IAEf;;;;OAIG;IACH,gCAAiB,CAAA;IAEjB;;;;OAIG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB;AAcD,MAAM,CAAN,IAAY,gBAqBX;AArBD,WAAY,gBAAgB;IAC1B;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,mCAAe,CAAA;AACjB,CAAC,EArBW,gBAAgB,KAAhB,gBAAgB,QAqB3B","sourcesContent":["export interface HapticsPlugin {\n /**\n * Trigger a haptics \"impact\" feedback\n *\n * @since 1.0.0\n */\n impact(options?: ImpactOptions): Promise<void>;\n\n /**\n * Trigger a haptics \"notification\" feedback\n *\n * @since 1.0.0\n */\n notification(options?: NotificationOptions): Promise<void>;\n\n /**\n * Vibrate the device\n *\n * @since 1.0.0\n */\n vibrate(options?: VibrateOptions): Promise<void>;\n\n /**\n * Trigger a selection started haptic hint\n *\n * @since 1.0.0\n */\n selectionStart(): Promise<void>;\n\n /**\n * Trigger a selection changed haptic hint. If a selection was\n * started already, this will cause the device to provide haptic\n * feedback\n *\n * @since 1.0.0\n */\n selectionChanged(): Promise<void>;\n\n /**\n * If selectionStart() was called, selectionEnd() ends the selection.\n * For example, call this when a user has lifted their finger from a control\n *\n * @since 1.0.0\n */\n selectionEnd(): Promise<void>;\n}\n\nexport interface ImpactOptions {\n /**\n * Impact Feedback Style\n *\n * The mass of the objects in the collision simulated by a [UIImpactFeedbackGenerator](https://developer.apple.com/documentation/uikit/uiimpactfeedbackstyle) object.\n *\n * @default ImpactStyle.Heavy\n * @since 1.0.0\n */\n style: ImpactStyle;\n}\n\nexport enum ImpactStyle {\n /**\n * A collision between large, heavy user interface elements\n *\n * @since 1.0.0\n */\n Heavy = 'HEAVY',\n\n /**\n * A collision between moderately sized user interface elements\n *\n * @since 1.0.0\n */\n Medium = 'MEDIUM',\n\n /**\n * A collision between small, light user interface elements\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n}\n\nexport interface NotificationOptions {\n /**\n * Notification Feedback Type\n *\n * The type of notification feedback generated by a [UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbacktype) object.\n *\n * @default NotificationType.Success\n * @since 1.0.0\n */\n type: NotificationType;\n}\n\nexport enum NotificationType {\n /**\n * A notification feedback type indicating that a task has completed successfully\n *\n * @since 1.0.0\n */\n Success = 'SUCCESS',\n\n /**\n * A notification feedback type indicating that a task has produced a warning\n *\n * @since 1.0.0\n */\n Warning = 'WARNING',\n\n /**\n * A notification feedback type indicating that a task has failed\n *\n * @since 1.0.0\n */\n Error = 'ERROR',\n}\n\nexport interface VibrateOptions {\n /**\n * Duration of the vibration in milliseconds.\n *\n * @default 300\n * @since 1.0.0\n */\n duration: number;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/haptics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-next.1",
|
|
4
4
|
"description": "The Haptics API provides physical feedback to the user through touch or vibration.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"publish:cocoapod": "pod trunk push ./CapacitorHaptics.podspec --allow-warnings"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@capacitor/android": "
|
|
51
|
-
"@capacitor/core": "
|
|
50
|
+
"@capacitor/android": "next",
|
|
51
|
+
"@capacitor/core": "next",
|
|
52
52
|
"@capacitor/docgen": "^0.3.0",
|
|
53
|
-
"@capacitor/ios": "
|
|
53
|
+
"@capacitor/ios": "next",
|
|
54
54
|
"@ionic/eslint-config": "^0.4.0",
|
|
55
55
|
"@ionic/prettier-config": "^4.0.0",
|
|
56
56
|
"@ionic/swiftlint-config": "^2.0.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"typescript": "^5.9.3"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@capacitor/core": ">=
|
|
73
|
+
"@capacitor/core": ">=9.0.0-alpha.0"
|
|
74
74
|
},
|
|
75
75
|
"prettier": "@ionic/prettier-config",
|
|
76
76
|
"swiftlint": "@ionic/swiftlint-config",
|