@capgo/capacitor-mute 1.1.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,18 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorMute'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '12.0'
15
+ s.dependency 'Capacitor'
16
+ s.dependency 'Mute'
17
+ s.swift_version = '5.1'
18
+ end
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # capacitor-mute
2
+
3
+ Detect if the mute switch is enabled/disabled on a device
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @capgo/capacitor-mute
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`isMuted()`](#ismuted)
17
+ * [Interfaces](#interfaces)
18
+
19
+ </docgen-index>
20
+
21
+ <docgen-api>
22
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
23
+
24
+ ### isMuted()
25
+
26
+ ```typescript
27
+ isMuted() => Promise<MuteResponse>
28
+ ```
29
+
30
+ check if the device is muted
31
+
32
+ **Returns:** <code>Promise&lt;<a href="#muteresponse">MuteResponse</a>&gt;</code>
33
+
34
+ --------------------
35
+
36
+
37
+ ### Interfaces
38
+
39
+
40
+ #### MuteResponse
41
+
42
+ | Prop | Type |
43
+ | ----------- | -------------------- |
44
+ | **`value`** | <code>boolean</code> |
45
+
46
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ jcenter()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:4.2.1'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
22
+ defaultConfig {
23
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
24
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
25
+ versionCode 1
26
+ versionName "1.0"
27
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28
+ }
29
+ buildTypes {
30
+ release {
31
+ minifyEnabled false
32
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
+ }
34
+ }
35
+ lintOptions {
36
+ abortOnError false
37
+ }
38
+ compileOptions {
39
+ sourceCompatibility JavaVersion.VERSION_1_8
40
+ targetCompatibility JavaVersion.VERSION_1_8
41
+ }
42
+ }
43
+
44
+ repositories {
45
+ google()
46
+ jcenter()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="ee.forgr.plugin.mute">
3
+ </manifest>
@@ -0,0 +1,25 @@
1
+ package ee.forgr.plugin.mute;
2
+
3
+ import android.content.Context;
4
+ import android.media.AudioManager;
5
+ import com.getcapacitor.JSObject;
6
+ import com.getcapacitor.Plugin;
7
+ import com.getcapacitor.PluginCall;
8
+ import com.getcapacitor.PluginMethod;
9
+ import com.getcapacitor.annotation.CapacitorPlugin;
10
+
11
+ @CapacitorPlugin(name = "Mute")
12
+ public class MutePlugin extends Plugin {
13
+
14
+ @PluginMethod
15
+ public void isMuted(PluginCall call) {
16
+ JSObject ret = new JSObject();
17
+ ret.put("value", true);
18
+ AudioManager audio = (AudioManager) this.bridge.getContext().getSystemService(Context.AUDIO_SERVICE);
19
+ switch ( audio.getRingerMode() ) {
20
+ case AudioManager.RINGER_MODE_NORMAL:
21
+ ret.put("value", false);
22
+ }
23
+ call.resolve(ret);
24
+ }
25
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "api": {
3
+ "name": "MutePlugin",
4
+ "slug": "muteplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "isMuted",
10
+ "signature": "() => Promise<MuteResponse>",
11
+ "parameters": [],
12
+ "returns": "Promise<MuteResponse>",
13
+ "tags": [],
14
+ "docs": "check if the device is muted",
15
+ "complexTypes": [
16
+ "MuteResponse"
17
+ ],
18
+ "slug": "ismuted"
19
+ }
20
+ ],
21
+ "properties": []
22
+ },
23
+ "interfaces": [
24
+ {
25
+ "name": "MuteResponse",
26
+ "slug": "muteresponse",
27
+ "docs": "",
28
+ "tags": [],
29
+ "methods": [],
30
+ "properties": [
31
+ {
32
+ "name": "value",
33
+ "tags": [],
34
+ "docs": "",
35
+ "complexTypes": [],
36
+ "type": "boolean"
37
+ }
38
+ ]
39
+ }
40
+ ],
41
+ "enums": []
42
+ }
@@ -0,0 +1,10 @@
1
+ export interface MutePlugin {
2
+ /**
3
+ * check if the device is muted
4
+ *
5
+ */
6
+ isMuted(): Promise<MuteResponse>;
7
+ }
8
+ export interface MuteResponse {
9
+ value: boolean;
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { MutePlugin } from './definitions';
2
+ declare const Mute: MutePlugin;
3
+ export * from './definitions';
4
+ export { Mute };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const Mute = registerPlugin('Mute', {
3
+ web: () => import('./web').then(m => new m.MuteWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { Mute };
7
+ //# sourceMappingURL=index.js.map
@@ -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,IAAI,GAAG,cAAc,CAAa,MAAM,EAAE;IAC9C,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;CACtD,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { MutePlugin, MuteResponse } from './definitions';
3
+ export declare class MuteWeb extends WebPlugin implements MutePlugin {
4
+ isMuted(): Promise<MuteResponse>;
5
+ }
@@ -0,0 +1,8 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class MuteWeb extends WebPlugin {
3
+ async isMuted() {
4
+ console.log('isMuted');
5
+ throw new Error("Method not implemented.");
6
+ }
7
+ }
8
+ //# 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;AAI5C,MAAM,OAAO,OAAQ,SAAQ,SAAS;IACpC,KAAK,CAAC,OAAO;QACX,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const Mute = core.registerPlugin('Mute', {
8
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.MuteWeb()),
9
+ });
10
+
11
+ class MuteWeb extends core.WebPlugin {
12
+ async isMuted() {
13
+ console.log('isMuted');
14
+ throw new Error("Method not implemented.");
15
+ }
16
+ }
17
+
18
+ var web = /*#__PURE__*/Object.freeze({
19
+ __proto__: null,
20
+ MuteWeb: MuteWeb
21
+ });
22
+
23
+ exports.Mute = Mute;
24
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Mute = registerPlugin('Mute', {\n web: () => import('./web').then(m => new m.MuteWeb()),\n});\nexport * from './definitions';\nexport { Mute };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MuteWeb extends WebPlugin {\n async isMuted() {\n console.log('isMuted');\n throw new Error(\"Method not implemented.\");\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;AACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC;;ACFM,MAAM,OAAO,SAASC,cAAS,CAAC;AACvC,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,27 @@
1
+ var capacitorMute = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const Mute = core.registerPlugin('Mute', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.MuteWeb()),
6
+ });
7
+
8
+ class MuteWeb extends core.WebPlugin {
9
+ async isMuted() {
10
+ console.log('isMuted');
11
+ throw new Error("Method not implemented.");
12
+ }
13
+ }
14
+
15
+ var web = /*#__PURE__*/Object.freeze({
16
+ __proto__: null,
17
+ MuteWeb: MuteWeb
18
+ });
19
+
20
+ exports.Mute = Mute;
21
+
22
+ Object.defineProperty(exports, '__esModule', { value: true });
23
+
24
+ return exports;
25
+
26
+ })({}, capacitorExports);
27
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Mute = registerPlugin('Mute', {\n web: () => import('./web').then(m => new m.MuteWeb()),\n});\nexport * from './definitions';\nexport { Mute };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MuteWeb extends WebPlugin {\n async isMuted() {\n console.log('isMuted');\n throw new Error(\"Method not implemented.\");\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;IACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC;;ICFM,MAAM,OAAO,SAASC,cAAS,CAAC;IACvC,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(MutePlugin, "Mute",
7
+ CAP_PLUGIN_METHOD(isMuted, CAPPluginReturnPromise);
8
+ )
@@ -0,0 +1,22 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(MutePlugin)
9
+ public class MutePlugin: CAPPlugin {
10
+ private let implementation = Muted()
11
+ override public func load() {
12
+ implementation.initialize()
13
+ }
14
+ @objc func isMuted(_ call: CAPPluginCall) {
15
+ self.implementation.check()
16
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
17
+ call.resolve([
18
+ "value": self.implementation.isMuted()
19
+ ])
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,23 @@
1
+ import Foundation
2
+ import Mute
3
+
4
+ @objc public class Muted: NSObject {
5
+ private var _isMuted = false
6
+ public func initialize() {
7
+ Mute.shared.notify = { [weak self] mut in
8
+ self!._isMuted = mut
9
+ }
10
+ self.check()
11
+ }
12
+ @objc public func check() {
13
+ Mute.shared.isPaused = false
14
+ Mute.shared.check()
15
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
16
+ Mute.shared.isPaused = true
17
+ }
18
+ }
19
+ @objc public func isMuted() -> Bool {
20
+ print("Mute", self._isMuted)
21
+ return self._isMuted
22
+ }
23
+ }
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@capgo/capacitor-mute",
3
+ "version": "1.1.0",
4
+ "description": "Detect if the mute switch is enabled/disabled on a device",
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
+ "CapacitorMute.podspec"
15
+ ],
16
+ "author": "Martin donadieu",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/riderx/capacitor-mute.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/riderx/capacitor-mute/issues"
24
+ },
25
+ "keywords": [
26
+ "capacitor",
27
+ "plugin",
28
+ "native"
29
+ ],
30
+ "scripts": {
31
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
32
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
33
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
34
+ "verify:web": "npm run build",
35
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
36
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
37
+ "eslint": "eslint . --ext ts",
38
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
39
+ "swiftlint": "node-swiftlint",
40
+ "docgen": "docgen --api MutePlugin --output-readme README.md --output-json dist/docs.json",
41
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
42
+ "clean": "rimraf ./dist",
43
+ "watch": "tsc --watch",
44
+ "prepublishOnly": "npm run build"
45
+ },
46
+ "devDependencies": {
47
+ "@capacitor/android": "^3.0.0",
48
+ "@capacitor/core": "^3.0.0",
49
+ "@capacitor/docgen": "^0.0.10",
50
+ "@capacitor/ios": "^3.0.0",
51
+ "@ionic/eslint-config": "^0.3.0",
52
+ "@ionic/prettier-config": "^1.0.1",
53
+ "@ionic/swiftlint-config": "^1.1.2",
54
+ "eslint": "^7.11.0",
55
+ "prettier": "~2.2.0",
56
+ "prettier-plugin-java": "~1.0.0",
57
+ "rimraf": "^3.0.2",
58
+ "rollup": "^2.32.0",
59
+ "swiftlint": "^1.0.1",
60
+ "typescript": "~4.0.3"
61
+ },
62
+ "peerDependencies": {
63
+ "@capacitor/core": "^3.0.0"
64
+ },
65
+ "prettier": "@ionic/prettier-config",
66
+ "swiftlint": "@ionic/swiftlint-config",
67
+ "eslintConfig": {
68
+ "extends": "@ionic/eslint-config/recommended"
69
+ },
70
+ "capacitor": {
71
+ "ios": {
72
+ "src": "ios"
73
+ },
74
+ "android": {
75
+ "src": "android"
76
+ }
77
+ }
78
+ }