diff --git a/android/app/capacitor.build.gradle b/android/app/capacitor.build.gradle index 5f0855e..efe5993 100644 --- a/android/app/capacitor.build.gradle +++ b/android/app/capacitor.build.gradle @@ -13,7 +13,7 @@ dependencies { implementation project(':capacitor-app') implementation project(':capacitor-haptics') implementation project(':capacitor-keyboard') - implementation project(':capacitor-screen-orientation') + implementation project(':capawesome-capacitor-screen-orientation') implementation project(':sslhandler') } diff --git a/android/capacitor.settings.gradle b/android/capacitor.settings.gradle index 85110b7..5531f65 100644 --- a/android/capacitor.settings.gradle +++ b/android/capacitor.settings.gradle @@ -14,8 +14,8 @@ project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/ include ':capacitor-keyboard' project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor/keyboard/android') -include ':capacitor-screen-orientation' -project(':capacitor-screen-orientation').projectDir = new File('../node_modules/@capacitor/screen-orientation/android') +include ':capawesome-capacitor-screen-orientation' +project(':capawesome-capacitor-screen-orientation').projectDir = new File('../node_modules/@capawesome/capacitor-screen-orientation/android') include ':sslhandler' project(':sslhandler').projectDir = new File('../node_modules/sslhandler/android') diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift index c3cd83b..adae2fd 100644 --- a/ios/App/App/AppDelegate.swift +++ b/ios/App/App/AppDelegate.swift @@ -1,5 +1,6 @@ import UIKit import Capacitor +import CapawesomeCapacitorScreenOrientation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { @@ -11,6 +12,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } + func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { + return ScreenOrientation.getSupportedInterfaceOrientations() + } + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. diff --git a/ios/App/Podfile b/ios/App/Podfile index a588489..a96e989 100644 --- a/ios/App/Podfile +++ b/ios/App/Podfile @@ -15,7 +15,7 @@ def capacitor_pods pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics' pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard' - pod 'CapacitorScreenOrientation', :path => '../../node_modules/@capacitor/screen-orientation' + pod 'CapawesomeCapacitorScreenOrientation', :path => '../../node_modules/@capawesome/capacitor-screen-orientation' pod 'Sslhandler', :path => '../../node_modules/sslhandler' pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins' end diff --git a/ios/App/Podfile.lock b/ios/App/Podfile.lock index 542ace8..98024e7 100644 --- a/ios/App/Podfile.lock +++ b/ios/App/Podfile.lock @@ -10,7 +10,7 @@ PODS: - Capacitor - CapacitorKeyboard (5.0.6): - Capacitor - - CapacitorScreenOrientation (5.0.6): + - CapawesomeCapacitorScreenOrientation (6.0.0): - Capacitor - CordovaPlugins (5.2.3): - CapacitorCordova @@ -24,7 +24,7 @@ DEPENDENCIES: - "CapacitorCordova (from `../../node_modules/@capacitor/ios`)" - "CapacitorHaptics (from `../../node_modules/@capacitor/haptics`)" - "CapacitorKeyboard (from `../../node_modules/@capacitor/keyboard`)" - - "CapacitorScreenOrientation (from `../../node_modules/@capacitor/screen-orientation`)" + - "CapawesomeCapacitorScreenOrientation (from `../../node_modules/@capawesome/capacitor-screen-orientation`)" - CordovaPlugins (from `../capacitor-cordova-ios-plugins`) - Sslhandler (from `../../node_modules/sslhandler`) @@ -41,8 +41,8 @@ EXTERNAL SOURCES: :path: "../../node_modules/@capacitor/haptics" CapacitorKeyboard: :path: "../../node_modules/@capacitor/keyboard" - CapacitorScreenOrientation: - :path: "../../node_modules/@capacitor/screen-orientation" + CapawesomeCapacitorScreenOrientation: + :path: "../../node_modules/@capawesome/capacitor-screen-orientation" CordovaPlugins: :path: "../capacitor-cordova-ios-plugins" Sslhandler: @@ -55,10 +55,10 @@ SPEC CHECKSUMS: CapacitorCordova: 35def3ebfdef491f0a7b652816eb873ff4b20bbf CapacitorHaptics: 1fffc1217c7e64a472d7845be50fb0c2f7d4204c CapacitorKeyboard: b978154b024a5f65e044908e37d15b7de58b9d12 - CapacitorScreenOrientation: e5ef438489815d05340f1b51a2b1794108dc0ac3 + CapawesomeCapacitorScreenOrientation: 82675c41cb616a64630c834b06344515a2849ff3 CordovaPlugins: d4671f1d2a1af985cd35caa0d8bbb58b95ef3c70 Sslhandler: 5b1dfaa41fdbad6e788cea98538cb0c2995b9153 -PODFILE CHECKSUM: 398e7d75531b27cb4b9dbfe967b8b16018b40804 +PODFILE CHECKSUM: 4824b7d1cba227e54345c8671e97841c8e6cf1e7 COCOAPODS: 1.12.1 diff --git a/package.json b/package.json index a322973..25e878d 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@capacitor/haptics": "5.0.6", "@capacitor/ios": "5.2.3", "@capacitor/keyboard": "5.0.6", - "@capacitor/screen-orientation": "^5.0.6", + "@capawesome/capacitor-screen-orientation": "^6.0.0", "@ionic-native/core": "^5.36.0", "@ionic-native/ionic-webview": "^5.36.0", "@ionic-native/screen-orientation": "^5.36.0", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a2b83dc..ed774da 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -4,6 +4,7 @@ import {WakelockService} from "./services/wakelock/wakelock.service"; import {ScreenOrientationService} from "./services/screen-orientation/screen-orientation.service"; import {SslHandler} from "../../capacitor_plugins/sslhandler/src"; import {SettingsService} from "./services/settings/settings.service"; +import {DiagnosticService} from "./services/diagnostic/diagnostic.service"; @Component({ selector: 'app-root', @@ -14,19 +15,18 @@ export class AppComponent implements OnInit { constructor(private storage: Storage, private wakeLockService: WakelockService, private screenOrientationService: ScreenOrientationService, - private settingsService: SettingsService) { + private settingsService: SettingsService, + private diagnosticService: DiagnosticService) { } async ngOnInit() { await this.storage.create(); await this.screenOrientationService.updateScreenOrientation(); - try { - await this.wakeLockService.updateWakeLock(); - } catch { - // exception is expected in browser because wake lock needs user interaction - } + await this.wakeLockService.updateWakeLock(); - let skipSslValidation = await this.settingsService.getSkipSslValidation(); - SslHandler.skipValidation({value: skipSslValidation}); + if (this.diagnosticService.isAndroid()) { + let skipSslValidation = await this.settingsService.getSkipSslValidation(); + SslHandler.skipValidation({value: skipSslValidation}); + } } } diff --git a/src/app/pages/shared/modals/settings-modal/settings-modal.component.html b/src/app/pages/shared/modals/settings-modal/settings-modal.component.html index fedc468..bdd9f3d 100644 --- a/src/app/pages/shared/modals/settings-modal/settings-modal.component.html +++ b/src/app/pages/shared/modals/settings-modal/settings-modal.component.html @@ -39,7 +39,7 @@ {{buttonLongPressDelay}}ms - + Auto diff --git a/src/app/pages/shared/modals/settings-modal/settings-modal.component.ts b/src/app/pages/shared/modals/settings-modal/settings-modal.component.ts index 2f19e7d..808aec6 100644 --- a/src/app/pages/shared/modals/settings-modal/settings-modal.component.ts +++ b/src/app/pages/shared/modals/settings-modal/settings-modal.component.ts @@ -46,7 +46,9 @@ export class SettingsModalComponent implements OnInit { await this.settingsService.setScreenOrientation(Number.parseInt(this.screenOrientation)); await this.wakelockService.updateWakeLock(); await this.screenOrientationService.updateScreenOrientation(); - SslHandler.skipValidation({value: this.skipSslValidation}); + if (this.diagnosticService.isAndroid()) { + SslHandler.skipValidation({value: this.skipSslValidation}); + } } async loadCurrentSettings() { @@ -74,8 +76,8 @@ export class SettingsModalComponent implements OnInit { return this.diagnosticService.isAndroid() } - public isAndroidOriOS() { - return this.diagnosticService.isAndroid() || this.diagnosticService.isiOS(); + public isiOSorAndroid() { + return this.diagnosticService.isiOSorAndroid(); } protected readonly environment = environment; diff --git a/src/app/services/diagnostic/diagnostic.service.ts b/src/app/services/diagnostic/diagnostic.service.ts index 66e8b18..84e86ea 100644 --- a/src/app/services/diagnostic/diagnostic.service.ts +++ b/src/app/services/diagnostic/diagnostic.service.ts @@ -21,4 +21,7 @@ export class DiagnosticService { return this.platform.is("ios"); } + public isiOSorAndroid() { + return this.isiOS() || this.isAndroid(); + } } diff --git a/src/app/services/screen-orientation/screen-orientation.service.ts b/src/app/services/screen-orientation/screen-orientation.service.ts index 93db9fa..009ea23 100644 --- a/src/app/services/screen-orientation/screen-orientation.service.ts +++ b/src/app/services/screen-orientation/screen-orientation.service.ts @@ -1,16 +1,23 @@ import { Injectable } from '@angular/core'; import {SettingsService} from "../settings/settings.service"; import {ScreenOrientationType} from "../../enums/screen-orientation-type"; -import {ScreenOrientation} from "@capacitor/screen-orientation"; +import { ScreenOrientation, OrientationType } from '@capawesome/capacitor-screen-orientation'; +import {DiagnosticService} from "../diagnostic/diagnostic.service"; + @Injectable({ providedIn: 'root' }) export class ScreenOrientationService { - constructor(private settingsService: SettingsService) { } + constructor(private settingsService: SettingsService, + private diagnosticService: DiagnosticService) { } public async updateScreenOrientation() { + if (!this.diagnosticService.isiOSorAndroid()) { + return; + } + let screenOrientation = await this.settingsService.getScreenOrientation(); try { switch (screenOrientation) { @@ -18,16 +25,16 @@ export class ScreenOrientationService { await ScreenOrientation.unlock(); break; case ScreenOrientationType.Landscape: - await ScreenOrientation.lock({orientation: "landscape"}); + await ScreenOrientation.lock({ type: OrientationType.LANDSCAPE_PRIMARY }); break; case ScreenOrientationType.LandscapeAlt: - await ScreenOrientation.lock({orientation: "landscape-secondary"}); + await ScreenOrientation.lock({ type: OrientationType.LANDSCAPE_SECONDARY }); break; case ScreenOrientationType.Portrait: - await ScreenOrientation.lock({orientation: "portrait"}); + await ScreenOrientation.lock({ type: OrientationType.PORTRAIT_PRIMARY }); break; case ScreenOrientationType.PortraitAlt: - await ScreenOrientation.lock({orientation: "portrait-secondary"}); + await ScreenOrientation.lock({ type: OrientationType.PORTRAIT_SECONDARY }); break; } } catch { diff --git a/src/app/services/wakelock/wakelock.service.ts b/src/app/services/wakelock/wakelock.service.ts index bec84b6..4666ea8 100644 --- a/src/app/services/wakelock/wakelock.service.ts +++ b/src/app/services/wakelock/wakelock.service.ts @@ -14,10 +14,14 @@ export class WakelockService { } public async updateWakeLock() { - if (await this.settingsService.getWakeLockEnabled() === true) { - await this.enableWakeLock(); - } else { - await this.disableWakeLock(); + try { + if (await this.settingsService.getWakeLockEnabled() === true) { + await this.enableWakeLock(); + } else { + await this.disableWakeLock(); + } + } catch { + // exception is expected in browser because wake lock needs user interaction } } diff --git a/yarn.lock b/yarn.lock index d4bea0a..bf1ab57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1436,10 +1436,10 @@ resolved "https://registry.yarnpkg.com/@capacitor/keyboard/-/keyboard-5.0.6.tgz#04400e71b677abf9f1fc1ceaffd1211e7d864319" integrity sha512-9GewAa/y2Hwkdw/Be8MTdiAjrFZ7TPDKpR44M0Y/0QMnK+mBbgzcoZ/UkuumWv6e2F1IAI+VY5eYVQHDeZcRoA== -"@capacitor/screen-orientation@^5.0.6": - version "5.0.6" - resolved "https://registry.yarnpkg.com/@capacitor/screen-orientation/-/screen-orientation-5.0.6.tgz#fb2985ff06ccfb7a176c7ed07af99fc0c9584e2b" - integrity sha512-WK8zBo+i0ivzIY7gmvr37AMFVGGIsgFUm/vUWAH9molu5qZ3w899VqwROgntAWgr2GMIpihQ3LQBg+4Cd6Rndw== +"@capawesome/capacitor-screen-orientation@^6.0.0": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@capawesome/capacitor-screen-orientation/-/capacitor-screen-orientation-6.0.0.tgz#d9572a5f31923bec147f4c898c62486ba11831f5" + integrity sha512-zVYMH/lcFNfjlfBUwheG5zSJkX9BE608p+Pxik1Talc6T7Iu2O0ivZKfMJP6f1WMmd54yD54mbsKkJ+uj0ZYtg== "@colors/colors@1.5.0": version "1.5.0"