Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix device mode selection

ammarahm-edf83d6c2d3786
diff --git a/apps/mobile/app/services/device-detection.js b/apps/mobile/app/services/device-detection.js
index 42f4f2677..5bc27c9aa 100644
--- a/apps/mobile/app/services/device-detection.js
+++ b/apps/mobile/app/services/device-detection.js
@@ -52,6 +52,9 @@ export class DeviceDetectionService {
this.height = windowSize.height;
this.adjustedWidth = this.width * this.pixelDensity;
this.adjustedHeight = this.height * this.pixelDensity;
+ screenSize = Dimensions.get("screen");
+ this.screenWidth = screenSize.width;
+ this.screenHeight = screenSize.height;
this.isPhoneOrTablet();
this.isIosOrAndroid();
this.detectIphoneX();
@@ -70,22 +73,19 @@ export class DeviceDetectionService {
checkSmallTab(orientation) {
let deviceSize = this.getDeviceSize();
- let screenSize = this.getScreenSize();
- console.log(orientation);
+
+ const isLandscape = orientation?.startsWith("LANDSCAPE");
+ const isValidTabletSize = deviceSize > 5.5;
+ const isValidLargeTabletSize = deviceSize > 9;
+
if (
- (!this.isTablet() && orientation?.startsWith("LANDSCAPE")) ||
- (this.isTablet() &&
- (orientation === "PORTRAIT" ||
- (deviceSize < screenSize - 1 && deviceSize > 5.5)))
+ (!this.isTablet() && isLandscape && isValidTabletSize) ||
+ (this.isTablet() && isValidTabletSize && !isValidLargeTabletSize)
) {
this.isTab = true;
this.isPhone = false;
this.isSmallTab = true;
- } else if (
- DeviceInfo.isTablet() &&
- orientation === "LANDSCAPE" &&
- deviceSize > 9
- ) {
+ } else if (this.isTablet() && isLandscape && isValidLargeTabletSize) {
this.isTab = true;
this.isPhone = false;
this.isSmallTab = false;
@@ -96,8 +96,8 @@ export class DeviceDetectionService {
this.isSmallTab = false;
} else {
this.isTab = true;
- this.isSmallTab = false;
- this.isPhone = true;
+ this.isSmallTab = true;
+ this.isPhone = false;
}
}
}