@capawesome/capacitor-app-icon 0.0.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/CapawesomeCapacitorAppIcon.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +280 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/appicon/AppIcon.java +118 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/appicon/AppIconPlugin.java +94 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/appicon/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/appicon/classes/CustomExceptions.java +11 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/appicon/classes/options/SetIconOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/appicon/classes/results/GetCurrentIconResult.java +25 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/appicon/classes/results/IsAvailableResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/appicon/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +174 -0
- package/dist/esm/definitions.d.ts +100 -0
- package/dist/esm/definitions.js +19 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +8 -0
- package/dist/esm/web.js +16 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +49 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +52 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/AppIcon.swift +40 -0
- package/ios/Plugin/AppIconPlugin.swift +77 -0
- package/ios/Plugin/Classes/Options/SetIconOptions.swift +17 -0
- package/ios/Plugin/Classes/Results/GetCurrentIconResult.swift +16 -0
- package/ios/Plugin/Classes/Results/IsAvailableResult.swift +16 -0
- package/ios/Plugin/Enums/CustomError.swift +31 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +5 -0
- package/package.json +91 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.appicon.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.appicon.interfaces.Result;
|
|
7
|
+
import org.json.JSONObject;
|
|
8
|
+
|
|
9
|
+
public class GetCurrentIconResult implements Result {
|
|
10
|
+
|
|
11
|
+
@Nullable
|
|
12
|
+
private final String icon;
|
|
13
|
+
|
|
14
|
+
public GetCurrentIconResult(@Nullable String icon) {
|
|
15
|
+
this.icon = icon;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
@NonNull
|
|
20
|
+
public JSObject toJSObject() {
|
|
21
|
+
JSObject result = new JSObject();
|
|
22
|
+
result.put("icon", icon == null ? JSONObject.NULL : icon);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.appicon.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.appicon.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class IsAvailableResult implements Result {
|
|
8
|
+
|
|
9
|
+
private final boolean available;
|
|
10
|
+
|
|
11
|
+
public IsAvailableResult(boolean available) {
|
|
12
|
+
this.available = available;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
@NonNull
|
|
17
|
+
public JSObject toJSObject() {
|
|
18
|
+
JSObject result = new JSObject();
|
|
19
|
+
result.put("available", available);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "AppIconPlugin",
|
|
4
|
+
"slug": "appiconplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "getCurrentIcon",
|
|
10
|
+
"signature": "() => Promise<GetCurrentIconResult>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<GetCurrentIconResult>",
|
|
13
|
+
"tags": [
|
|
14
|
+
{
|
|
15
|
+
"name": "since",
|
|
16
|
+
"text": "0.1.0"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"docs": "Get the name of the icon that is currently in use.\n\nReturns `null` if the default icon is in use.\n\nOnly available on Android and iOS.",
|
|
20
|
+
"complexTypes": [
|
|
21
|
+
"GetCurrentIconResult"
|
|
22
|
+
],
|
|
23
|
+
"slug": "getcurrenticon"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "isAvailable",
|
|
27
|
+
"signature": "() => Promise<IsAvailableResult>",
|
|
28
|
+
"parameters": [],
|
|
29
|
+
"returns": "Promise<IsAvailableResult>",
|
|
30
|
+
"tags": [
|
|
31
|
+
{
|
|
32
|
+
"name": "since",
|
|
33
|
+
"text": "0.1.0"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"docs": "Check if changing the app icon is supported on the current device.\n\nOn Android, this always resolves to `true`.\nOn iOS, this resolves to the value of `supportsAlternateIcons`.\n\nOnly available on Android and iOS.",
|
|
37
|
+
"complexTypes": [
|
|
38
|
+
"IsAvailableResult"
|
|
39
|
+
],
|
|
40
|
+
"slug": "isavailable"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "resetIcon",
|
|
44
|
+
"signature": "() => Promise<void>",
|
|
45
|
+
"parameters": [],
|
|
46
|
+
"returns": "Promise<void>",
|
|
47
|
+
"tags": [
|
|
48
|
+
{
|
|
49
|
+
"name": "since",
|
|
50
|
+
"text": "0.1.0"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"docs": "Restore the default app icon.\n\nOnly available on Android and iOS.",
|
|
54
|
+
"complexTypes": [],
|
|
55
|
+
"slug": "reseticon"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "setIcon",
|
|
59
|
+
"signature": "(options: SetIconOptions) => Promise<void>",
|
|
60
|
+
"parameters": [
|
|
61
|
+
{
|
|
62
|
+
"name": "options",
|
|
63
|
+
"docs": "",
|
|
64
|
+
"type": "SetIconOptions"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"returns": "Promise<void>",
|
|
68
|
+
"tags": [
|
|
69
|
+
{
|
|
70
|
+
"name": "since",
|
|
71
|
+
"text": "0.1.0"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"docs": "Change the app icon to the alternate icon with the given name.\n\nThe icon must be declared by the app beforehand. See the setup instructions\nfor [Android](https://capawesome.io/docs/plugins/app-icon/#android) and\n[iOS](https://capawesome.io/docs/plugins/app-icon/#ios) for more information.\n\nOnly available on Android and iOS.",
|
|
75
|
+
"complexTypes": [
|
|
76
|
+
"SetIconOptions"
|
|
77
|
+
],
|
|
78
|
+
"slug": "seticon"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"properties": []
|
|
82
|
+
},
|
|
83
|
+
"interfaces": [
|
|
84
|
+
{
|
|
85
|
+
"name": "GetCurrentIconResult",
|
|
86
|
+
"slug": "getcurrenticonresult",
|
|
87
|
+
"docs": "",
|
|
88
|
+
"tags": [
|
|
89
|
+
{
|
|
90
|
+
"text": "0.1.0",
|
|
91
|
+
"name": "since"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"methods": [],
|
|
95
|
+
"properties": [
|
|
96
|
+
{
|
|
97
|
+
"name": "icon",
|
|
98
|
+
"tags": [
|
|
99
|
+
{
|
|
100
|
+
"text": "'AppIconChristmas'",
|
|
101
|
+
"name": "example"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"text": "0.1.0",
|
|
105
|
+
"name": "since"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"docs": "The name of the icon that is currently in use.\n\nReturns `null` if the default icon is in use.",
|
|
109
|
+
"complexTypes": [],
|
|
110
|
+
"type": "string | null"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "IsAvailableResult",
|
|
116
|
+
"slug": "isavailableresult",
|
|
117
|
+
"docs": "",
|
|
118
|
+
"tags": [
|
|
119
|
+
{
|
|
120
|
+
"text": "0.1.0",
|
|
121
|
+
"name": "since"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"methods": [],
|
|
125
|
+
"properties": [
|
|
126
|
+
{
|
|
127
|
+
"name": "available",
|
|
128
|
+
"tags": [
|
|
129
|
+
{
|
|
130
|
+
"text": "0.1.0",
|
|
131
|
+
"name": "since"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"docs": "Whether or not changing the app icon is supported on the current device.",
|
|
135
|
+
"complexTypes": [],
|
|
136
|
+
"type": "boolean"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "SetIconOptions",
|
|
142
|
+
"slug": "seticonoptions",
|
|
143
|
+
"docs": "",
|
|
144
|
+
"tags": [
|
|
145
|
+
{
|
|
146
|
+
"text": "0.1.0",
|
|
147
|
+
"name": "since"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"methods": [],
|
|
151
|
+
"properties": [
|
|
152
|
+
{
|
|
153
|
+
"name": "icon",
|
|
154
|
+
"tags": [
|
|
155
|
+
{
|
|
156
|
+
"text": "'AppIconChristmas'",
|
|
157
|
+
"name": "example"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"text": "0.1.0",
|
|
161
|
+
"name": "since"
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"docs": "The name of the alternate icon to use.\n\nOn Android, this is the name of the `<activity-alias>` (without the leading dot).\nOn iOS, this is the key of the icon inside `CFBundleAlternateIcons`.",
|
|
165
|
+
"complexTypes": [],
|
|
166
|
+
"type": "string"
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"enums": [],
|
|
172
|
+
"typeAliases": [],
|
|
173
|
+
"pluginConfigs": []
|
|
174
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export interface AppIconPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Get the name of the icon that is currently in use.
|
|
4
|
+
*
|
|
5
|
+
* Returns `null` if the default icon is in use.
|
|
6
|
+
*
|
|
7
|
+
* Only available on Android and iOS.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
*/
|
|
11
|
+
getCurrentIcon(): Promise<GetCurrentIconResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if changing the app icon is supported on the current device.
|
|
14
|
+
*
|
|
15
|
+
* On Android, this always resolves to `true`.
|
|
16
|
+
* On iOS, this resolves to the value of `supportsAlternateIcons`.
|
|
17
|
+
*
|
|
18
|
+
* Only available on Android and iOS.
|
|
19
|
+
*
|
|
20
|
+
* @since 0.1.0
|
|
21
|
+
*/
|
|
22
|
+
isAvailable(): Promise<IsAvailableResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Restore the default app icon.
|
|
25
|
+
*
|
|
26
|
+
* Only available on Android and iOS.
|
|
27
|
+
*
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
resetIcon(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Change the app icon to the alternate icon with the given name.
|
|
33
|
+
*
|
|
34
|
+
* The icon must be declared by the app beforehand. See the setup instructions
|
|
35
|
+
* for [Android](https://capawesome.io/docs/plugins/app-icon/#android) and
|
|
36
|
+
* [iOS](https://capawesome.io/docs/plugins/app-icon/#ios) for more information.
|
|
37
|
+
*
|
|
38
|
+
* Only available on Android and iOS.
|
|
39
|
+
*
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
*/
|
|
42
|
+
setIcon(options: SetIconOptions): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @since 0.1.0
|
|
46
|
+
*/
|
|
47
|
+
export interface GetCurrentIconResult {
|
|
48
|
+
/**
|
|
49
|
+
* The name of the icon that is currently in use.
|
|
50
|
+
*
|
|
51
|
+
* Returns `null` if the default icon is in use.
|
|
52
|
+
*
|
|
53
|
+
* @example 'AppIconChristmas'
|
|
54
|
+
* @since 0.1.0
|
|
55
|
+
*/
|
|
56
|
+
icon: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @since 0.1.0
|
|
60
|
+
*/
|
|
61
|
+
export interface IsAvailableResult {
|
|
62
|
+
/**
|
|
63
|
+
* Whether or not changing the app icon is supported on the current device.
|
|
64
|
+
*
|
|
65
|
+
* @since 0.1.0
|
|
66
|
+
*/
|
|
67
|
+
available: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @since 0.1.0
|
|
71
|
+
*/
|
|
72
|
+
export interface SetIconOptions {
|
|
73
|
+
/**
|
|
74
|
+
* The name of the alternate icon to use.
|
|
75
|
+
*
|
|
76
|
+
* On Android, this is the name of the `<activity-alias>` (without the leading dot).
|
|
77
|
+
* On iOS, this is the key of the icon inside `CFBundleAlternateIcons`.
|
|
78
|
+
*
|
|
79
|
+
* @example 'AppIconChristmas'
|
|
80
|
+
* @since 0.1.0
|
|
81
|
+
*/
|
|
82
|
+
icon: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @since 0.1.0
|
|
86
|
+
*/
|
|
87
|
+
export declare enum ErrorCode {
|
|
88
|
+
/**
|
|
89
|
+
* The app icon could not be changed.
|
|
90
|
+
*
|
|
91
|
+
* @since 0.1.0
|
|
92
|
+
*/
|
|
93
|
+
ChangeFailed = "CHANGE_FAILED",
|
|
94
|
+
/**
|
|
95
|
+
* The alternate icon with the given name could not be found.
|
|
96
|
+
*
|
|
97
|
+
* @since 0.1.0
|
|
98
|
+
*/
|
|
99
|
+
IconNotFound = "ICON_NOT_FOUND"
|
|
100
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 0.1.0
|
|
3
|
+
*/
|
|
4
|
+
export var ErrorCode;
|
|
5
|
+
(function (ErrorCode) {
|
|
6
|
+
/**
|
|
7
|
+
* The app icon could not be changed.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
*/
|
|
11
|
+
ErrorCode["ChangeFailed"] = "CHANGE_FAILED";
|
|
12
|
+
/**
|
|
13
|
+
* The alternate icon with the given name could not be found.
|
|
14
|
+
*
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
*/
|
|
17
|
+
ErrorCode["IconNotFound"] = "ICON_NOT_FOUND";
|
|
18
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
19
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuFA;;GAEG;AACH,MAAM,CAAN,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB;;;;OAIG;IACH,2CAA8B,CAAA;IAC9B;;;;OAIG;IACH,4CAA+B,CAAA;AACjC,CAAC,EAbW,SAAS,KAAT,SAAS,QAapB","sourcesContent":["export interface AppIconPlugin {\n /**\n * Get the name of the icon that is currently in use.\n *\n * Returns `null` if the default icon is in use.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n getCurrentIcon(): Promise<GetCurrentIconResult>;\n /**\n * Check if changing the app icon is supported on the current device.\n *\n * On Android, this always resolves to `true`.\n * On iOS, this resolves to the value of `supportsAlternateIcons`.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n isAvailable(): Promise<IsAvailableResult>;\n /**\n * Restore the default app icon.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n resetIcon(): Promise<void>;\n /**\n * Change the app icon to the alternate icon with the given name.\n *\n * The icon must be declared by the app beforehand. See the setup instructions\n * for [Android](https://capawesome.io/docs/plugins/app-icon/#android) and\n * [iOS](https://capawesome.io/docs/plugins/app-icon/#ios) for more information.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n setIcon(options: SetIconOptions): Promise<void>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface GetCurrentIconResult {\n /**\n * The name of the icon that is currently in use.\n *\n * Returns `null` if the default icon is in use.\n *\n * @example 'AppIconChristmas'\n * @since 0.1.0\n */\n icon: string | null;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface IsAvailableResult {\n /**\n * Whether or not changing the app icon is supported on the current device.\n *\n * @since 0.1.0\n */\n available: boolean;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface SetIconOptions {\n /**\n * The name of the alternate icon to use.\n *\n * On Android, this is the name of the `<activity-alias>` (without the leading dot).\n * On iOS, this is the key of the icon inside `CFBundleAlternateIcons`.\n *\n * @example 'AppIconChristmas'\n * @since 0.1.0\n */\n icon: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport enum ErrorCode {\n /**\n * The app icon could not be changed.\n *\n * @since 0.1.0\n */\n ChangeFailed = 'CHANGE_FAILED',\n /**\n * The alternate icon with the given name could not be found.\n *\n * @since 0.1.0\n */\n IconNotFound = 'ICON_NOT_FOUND',\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,OAAO,GAAG,cAAc,CAAgB,SAAS,EAAE;IACvD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;CACzD,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { AppIconPlugin } from './definitions';\n\nconst AppIcon = registerPlugin<AppIconPlugin>('AppIcon', {\n web: () => import('./web').then(m => new m.AppIconWeb()),\n});\n\nexport * from './definitions';\nexport { AppIcon };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { AppIconPlugin, GetCurrentIconResult, IsAvailableResult, SetIconOptions } from './definitions';
|
|
3
|
+
export declare class AppIconWeb extends WebPlugin implements AppIconPlugin {
|
|
4
|
+
getCurrentIcon(): Promise<GetCurrentIconResult>;
|
|
5
|
+
isAvailable(): Promise<IsAvailableResult>;
|
|
6
|
+
resetIcon(): Promise<void>;
|
|
7
|
+
setIcon(_options: SetIconOptions): Promise<void>;
|
|
8
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class AppIconWeb extends WebPlugin {
|
|
3
|
+
async getCurrentIcon() {
|
|
4
|
+
throw this.unimplemented('Not implemented on web.');
|
|
5
|
+
}
|
|
6
|
+
async isAvailable() {
|
|
7
|
+
throw this.unimplemented('Not implemented on web.');
|
|
8
|
+
}
|
|
9
|
+
async resetIcon() {
|
|
10
|
+
throw this.unimplemented('Not implemented on web.');
|
|
11
|
+
}
|
|
12
|
+
async setIcon(_options) {
|
|
13
|
+
throw this.unimplemented('Not implemented on web.');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,UAAW,SAAQ,SAAS;IACvC,KAAK,CAAC,cAAc;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAwB;QACpC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AppIconPlugin,\n GetCurrentIconResult,\n IsAvailableResult,\n SetIconOptions,\n} from './definitions';\n\nexport class AppIconWeb extends WebPlugin implements AppIconPlugin {\n async getCurrentIcon(): Promise<GetCurrentIconResult> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async isAvailable(): Promise<IsAvailableResult> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async resetIcon(): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async setIcon(_options: SetIconOptions): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @since 0.1.0
|
|
7
|
+
*/
|
|
8
|
+
exports.ErrorCode = void 0;
|
|
9
|
+
(function (ErrorCode) {
|
|
10
|
+
/**
|
|
11
|
+
* The app icon could not be changed.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
ErrorCode["ChangeFailed"] = "CHANGE_FAILED";
|
|
16
|
+
/**
|
|
17
|
+
* The alternate icon with the given name could not be found.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
ErrorCode["IconNotFound"] = "ICON_NOT_FOUND";
|
|
22
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
23
|
+
|
|
24
|
+
const AppIcon = core.registerPlugin('AppIcon', {
|
|
25
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AppIconWeb()),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
class AppIconWeb extends core.WebPlugin {
|
|
29
|
+
async getCurrentIcon() {
|
|
30
|
+
throw this.unimplemented('Not implemented on web.');
|
|
31
|
+
}
|
|
32
|
+
async isAvailable() {
|
|
33
|
+
throw this.unimplemented('Not implemented on web.');
|
|
34
|
+
}
|
|
35
|
+
async resetIcon() {
|
|
36
|
+
throw this.unimplemented('Not implemented on web.');
|
|
37
|
+
}
|
|
38
|
+
async setIcon(_options) {
|
|
39
|
+
throw this.unimplemented('Not implemented on web.');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
44
|
+
__proto__: null,
|
|
45
|
+
AppIconWeb: AppIconWeb
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
exports.AppIcon = AppIcon;
|
|
49
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * @since 0.1.0\n */\nexport var ErrorCode;\n(function (ErrorCode) {\n /**\n * The app icon could not be changed.\n *\n * @since 0.1.0\n */\n ErrorCode[\"ChangeFailed\"] = \"CHANGE_FAILED\";\n /**\n * The alternate icon with the given name could not be found.\n *\n * @since 0.1.0\n */\n ErrorCode[\"IconNotFound\"] = \"ICON_NOT_FOUND\";\n})(ErrorCode || (ErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst AppIcon = registerPlugin('AppIcon', {\n web: () => import('./web').then(m => new m.AppIconWeb()),\n});\nexport * from './definitions';\nexport { AppIcon };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class AppIconWeb extends WebPlugin {\n async getCurrentIcon() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isAvailable() {\n throw this.unimplemented('Not implemented on web.');\n }\n async resetIcon() {\n throw this.unimplemented('Not implemented on web.');\n }\n async setIcon(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ErrorCode","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACWA;AACX,CAAC,UAAU,SAAS,EAAE;AACtB;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,cAAc,CAAC,GAAG,eAAe;AAC/C;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,cAAc,CAAC,GAAG,gBAAgB;AAChD,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC;;AChB5B,MAAC,OAAO,GAAGC,mBAAc,CAAC,SAAS,EAAE;AAC1C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;AAC5D,CAAC;;ACFM,MAAM,UAAU,SAASC,cAAS,CAAC;AAC1C,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var capacitorAppIcon = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @since 0.1.0
|
|
6
|
+
*/
|
|
7
|
+
exports.ErrorCode = void 0;
|
|
8
|
+
(function (ErrorCode) {
|
|
9
|
+
/**
|
|
10
|
+
* The app icon could not be changed.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.1.0
|
|
13
|
+
*/
|
|
14
|
+
ErrorCode["ChangeFailed"] = "CHANGE_FAILED";
|
|
15
|
+
/**
|
|
16
|
+
* The alternate icon with the given name could not be found.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
*/
|
|
20
|
+
ErrorCode["IconNotFound"] = "ICON_NOT_FOUND";
|
|
21
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
22
|
+
|
|
23
|
+
const AppIcon = core.registerPlugin('AppIcon', {
|
|
24
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AppIconWeb()),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
class AppIconWeb extends core.WebPlugin {
|
|
28
|
+
async getCurrentIcon() {
|
|
29
|
+
throw this.unimplemented('Not implemented on web.');
|
|
30
|
+
}
|
|
31
|
+
async isAvailable() {
|
|
32
|
+
throw this.unimplemented('Not implemented on web.');
|
|
33
|
+
}
|
|
34
|
+
async resetIcon() {
|
|
35
|
+
throw this.unimplemented('Not implemented on web.');
|
|
36
|
+
}
|
|
37
|
+
async setIcon(_options) {
|
|
38
|
+
throw this.unimplemented('Not implemented on web.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
43
|
+
__proto__: null,
|
|
44
|
+
AppIconWeb: AppIconWeb
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
exports.AppIcon = AppIcon;
|
|
48
|
+
|
|
49
|
+
return exports;
|
|
50
|
+
|
|
51
|
+
})({}, capacitorExports);
|
|
52
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * @since 0.1.0\n */\nexport var ErrorCode;\n(function (ErrorCode) {\n /**\n * The app icon could not be changed.\n *\n * @since 0.1.0\n */\n ErrorCode[\"ChangeFailed\"] = \"CHANGE_FAILED\";\n /**\n * The alternate icon with the given name could not be found.\n *\n * @since 0.1.0\n */\n ErrorCode[\"IconNotFound\"] = \"ICON_NOT_FOUND\";\n})(ErrorCode || (ErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst AppIcon = registerPlugin('AppIcon', {\n web: () => import('./web').then(m => new m.AppIconWeb()),\n});\nexport * from './definitions';\nexport { AppIcon };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class AppIconWeb extends WebPlugin {\n async getCurrentIcon() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isAvailable() {\n throw this.unimplemented('Not implemented on web.');\n }\n async resetIcon() {\n throw this.unimplemented('Not implemented on web.');\n }\n async setIcon(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ErrorCode","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACWA;IACX,CAAC,UAAU,SAAS,EAAE;IACtB;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,cAAc,CAAC,GAAG,eAAe;IAC/C;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,cAAc,CAAC,GAAG,gBAAgB;IAChD,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC;;AChB5B,UAAC,OAAO,GAAGC,mBAAc,CAAC,SAAS,EAAE;IAC1C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5D,CAAC;;ICFM,MAAM,UAAU,SAASC,cAAS,CAAC;IAC1C,IAAI,MAAM,cAAc,GAAG;IAC3B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
@objc public class AppIcon: NSObject {
|
|
5
|
+
let plugin: AppIconPlugin
|
|
6
|
+
|
|
7
|
+
init(plugin: AppIconPlugin) {
|
|
8
|
+
self.plugin = plugin
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public func getCurrentIcon() -> GetCurrentIconResult {
|
|
12
|
+
let icon = UIApplication.shared.alternateIconName
|
|
13
|
+
return GetCurrentIconResult(icon: icon)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@objc public func isAvailable() -> IsAvailableResult {
|
|
17
|
+
let available = UIApplication.shared.supportsAlternateIcons
|
|
18
|
+
return IsAvailableResult(available: available)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@objc public func resetIcon(completion: @escaping (Error?) -> Void) {
|
|
22
|
+
setAlternateIconName(nil, failure: CustomError.changeFailed, completion: completion)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@objc public func setIcon(_ options: SetIconOptions, completion: @escaping (Error?) -> Void) {
|
|
26
|
+
setAlternateIconName(options.icon, failure: CustomError.iconNotFound, completion: completion)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private func setAlternateIconName(_ name: String?, failure: CustomError, completion: @escaping (Error?) -> Void) {
|
|
30
|
+
DispatchQueue.main.async {
|
|
31
|
+
UIApplication.shared.setAlternateIconName(name) { error in
|
|
32
|
+
if error != nil {
|
|
33
|
+
completion(failure)
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
completion(nil)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc(AppIconPlugin)
|
|
5
|
+
public class AppIconPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
+
public let identifier = "AppIconPlugin"
|
|
7
|
+
public let jsName = "AppIcon"
|
|
8
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
9
|
+
CAPPluginMethod(name: "getCurrentIcon", returnType: CAPPluginReturnPromise),
|
|
10
|
+
CAPPluginMethod(name: "isAvailable", returnType: CAPPluginReturnPromise),
|
|
11
|
+
CAPPluginMethod(name: "resetIcon", returnType: CAPPluginReturnPromise),
|
|
12
|
+
CAPPluginMethod(name: "setIcon", returnType: CAPPluginReturnPromise)
|
|
13
|
+
]
|
|
14
|
+
public static let tag = "AppIcon"
|
|
15
|
+
|
|
16
|
+
private var implementation: AppIcon?
|
|
17
|
+
|
|
18
|
+
override public func load() {
|
|
19
|
+
self.implementation = AppIcon(plugin: self)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@objc func getCurrentIcon(_ call: CAPPluginCall) {
|
|
23
|
+
let result = implementation?.getCurrentIcon()
|
|
24
|
+
resolveCall(call, result)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@objc func isAvailable(_ call: CAPPluginCall) {
|
|
28
|
+
let result = implementation?.isAvailable()
|
|
29
|
+
resolveCall(call, result)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@objc func resetIcon(_ call: CAPPluginCall) {
|
|
33
|
+
implementation?.resetIcon { error in
|
|
34
|
+
if let error = error {
|
|
35
|
+
self.rejectCall(call, error)
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
self.resolveCall(call)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@objc func setIcon(_ call: CAPPluginCall) {
|
|
43
|
+
do {
|
|
44
|
+
let options = try SetIconOptions(call)
|
|
45
|
+
implementation?.setIcon(options) { error in
|
|
46
|
+
if let error = error {
|
|
47
|
+
self.rejectCall(call, error)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
self.resolveCall(call)
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
rejectCall(call, error)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private func rejectCall(_ call: CAPPluginCall, _ error: Error) {
|
|
58
|
+
CAPLog.print("[", AppIconPlugin.tag, "] ", error)
|
|
59
|
+
if let customError = error as? CustomError {
|
|
60
|
+
call.reject(error.localizedDescription, customError.code)
|
|
61
|
+
} else {
|
|
62
|
+
call.reject(error.localizedDescription)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private func resolveCall(_ call: CAPPluginCall) {
|
|
67
|
+
call.resolve()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private func resolveCall(_ call: CAPPluginCall, _ result: Result?) {
|
|
71
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
72
|
+
call.resolve(result)
|
|
73
|
+
} else {
|
|
74
|
+
call.resolve()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class SetIconOptions: NSObject {
|
|
5
|
+
let icon: String
|
|
6
|
+
|
|
7
|
+
init(_ call: CAPPluginCall) throws {
|
|
8
|
+
self.icon = try SetIconOptions.getIconFromCall(call)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
private static func getIconFromCall(_ call: CAPPluginCall) throws -> String {
|
|
12
|
+
guard let icon = call.getString("icon") else {
|
|
13
|
+
throw CustomError.iconMissing
|
|
14
|
+
}
|
|
15
|
+
return icon
|
|
16
|
+
}
|
|
17
|
+
}
|