From 153e5629ec6327d51dc56f7851b7443792e5bdad Mon Sep 17 00:00:00 2001 From: Cristina Date: Thu, 10 Dec 2020 08:54:58 +0100 Subject: [PATCH 1/2] feat(android-notch): cordova plugin wrapper --- .../plugins/android-notch/index.ts | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/@ionic-native/plugins/android-notch/index.ts diff --git a/src/@ionic-native/plugins/android-notch/index.ts b/src/@ionic-native/plugins/android-notch/index.ts new file mode 100644 index 0000000000..22a5775f2c --- /dev/null +++ b/src/@ionic-native/plugins/android-notch/index.ts @@ -0,0 +1,99 @@ +import { Injectable } from '@angular/core'; +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; + +/** + * @name Android Notch + * @description + * This plugin enables developers to get the cutout and android devices inset sizes + * It is based on the cordova plugin developed by @tobspr: https://github.com/tobspr/cordova-plugin-android-notch + * This plugin works on all android versions, but we can only detect notches starting from Android 9. + * + * @usage + * ```typescript + * import { AndroidNotch } from '@ionic-native/android-notch'; + * + * + * constructor(private androidNotch: AndroidNotch) { } + * + * ... + * + * + * this.androidNotch.hasCutout() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * this.androidNotch.getInsetTop() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * this.androidNotch.getInsetRight() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * this.androidNotch.getInsetBottom() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * this.androidNotch.getInsetLeft() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * ``` + */ +@Plugin({ + pluginName: 'AndroidNotch', + plugin: 'cordova-plugin-android-notch', + pluginRef: 'AndroidNotch', + repo: 'https://github.com/tobspr/cordova-plugin-android-notch.git', + platforms: ['Android'], +}) +@Injectable() +export class AndroidNotch extends IonicNativePlugin { + /** + * Returns true if the android device has cutout + * + * @return {Promise} + */ + @Cordova() + hasCutout(): Promise { + return; + } + + /** + * Returns the heigth of the top inset + * + * @return {Promise} + */ + @Cordova() + getInsetTop(): Promise { + return; + } + + /** + * Returns the heigth of the right inset + * + * @return {Promise} + */ + @Cordova() + getInsetRight(): Promise { + return; + } + + /** + * Returns the heigth of the bottom inset + * @return {Promise} + */ + @Cordova() + getInsetBottom(): Promise { + return; + } + + /** + * Returns the heigth of the left inset + * @return {Promise} + */ + @Cordova() + getInsetLeft(): Promise { + return; + } +} From a9193ee6775707f56a42aaa85ea430be9ebb6b40 Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Sat, 23 Jan 2021 18:12:56 +0100 Subject: [PATCH 2/2] Update index.ts --- src/@ionic-native/plugins/android-notch/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/@ionic-native/plugins/android-notch/index.ts b/src/@ionic-native/plugins/android-notch/index.ts index 22a5775f2c..6d8c8c0d7b 100644 --- a/src/@ionic-native/plugins/android-notch/index.ts +++ b/src/@ionic-native/plugins/android-notch/index.ts @@ -10,7 +10,7 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; * * @usage * ```typescript - * import { AndroidNotch } from '@ionic-native/android-notch'; + * import { AndroidNotch } from '@ionic-native/android-notch/nx'; * * * constructor(private androidNotch: AndroidNotch) { }