Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
capacitor-screen-orientation
Advanced tools
For detailed tutorial on how to use this plugin visit: https://medium.com/@hinddeep.purohit007/handling-screen-orientation-changes-in-capacitor-apps-19fe339578a6
Demo Application: https://github.com/hinddeep/Demo-Ionic-Screen_Orientation
Platforms Supported: Android, iOS
The Capacitor plugin I’ve developed can be used to detect the current of orientation of the screen, lock the screen in a particular orientation (disable auto-rotate) or unlock screen rotation (enable auto-rotate) and to listen for orientation changes.
npm install capacitor-screen-orientation
Open MainActivity.java and add the following code inside this.init()
add(ScreenOrientation.class);
Adding the above mentioned line will add the following import statement:
import com.bkon.capacitor.screenorientation.ScreenOrientation;
If you encounter errors, please add both the lines manually to MainActivity.java
If you want to listen for the orientation change event on Android:
Supported Orientations:
SPECIAL NOTE: Ionic has implicitly disabled PORTRAIT_SECONDARY.
If you want to lock the screen to the specified orientation on iOS:
var orientationLock = UIInterfaceOrientationMask.all
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return self.orientationLock
}
@objc func setOrientationLock(_ notification: Notification)
{
if let data = notification.userInfo as? [String: Int]
{
for (_, mask) in data
{
switch mask
{
case 1: self.orientationLock = UIInterfaceOrientationMask.portrait
break;
case 2: self.orientationLock = UIInterfaceOrientationMask.portraitUpsideDown
break;
case 3: self.orientationLock = UIInterfaceOrientationMask.landscapeRight
break;
case 4: self.orientationLock = UIInterfaceOrientationMask.landscapeLeft
break;
case 5: self.orientationLock = UIInterfaceOrientationMask.landscape
break;
default: self.orientationLock = UIInterfaceOrientationMask.all
}
}
}
}
Supported Orientations:
SPECIAL NOTE: Ionic has implicitly disabled portraitUpsideDown.
Open app.component.ts file and import the plugin as follows:
import { Plugins } from "@capacitor/core";
const { ScreenOrientation } = Plugins;
import 'capacitor-screen-orientation'
SPECIAL NOTE: Remove import 'capacitor-screen-orientation' when compiling app for Android and iOS. THe native plugin will not be invoked if you forget to remove the import statement before building for Android and iOS Platform.
Create a function to get the current screen orientation:
async getOrientation() {
let obj = await ScreenOrientation.getScreenOrientation();
this.screen_orientation = obj.orientation;
}
Create a function to lock the screen in a particular orientation:
async lockOrientation() {
await ScreenOrientation.lockScreenOrientation({
orientation: this.screen_orientation_lock,
});
}
Supported values for screen_orientation_lock variable:
Create a function to unlock screen rotation:
async UnlockOrientation() {
await ScreenOrientation.unlockScreenOrientation({});
}
Create a function that handles subscription to the orientation change event:
subscribeToOrientationChanges() {
ScreenOrientation.addListener("orientation_changed", (data) => {
this.screen_orientation_event = data.orientation;
});
}
NOTE: NOT supported on Android
async rotate() {
await ScreenOrientation.rotateTo({
orientation: this.rotateTo,
});
}
FAQs
Handle screen orientation of a mobile device.
The npm package capacitor-screen-orientation receives a total of 60 weekly downloads. As such, capacitor-screen-orientation popularity was classified as not popular.
We found that capacitor-screen-orientation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.