dpa99c/phonegap-istablet

Android: Checking dpi causes tablets not being recognized as tablets

Opened this issue · 1 comments

I'm submitting a ... (check one with "x"):

  • bug report
  • feature request
  • documentation issue

Bug report

Current behavior:
Using a Samsung Galaxy Tab S4 this plugin will return isTablet=false.
(this is not only related to this particular device, but can happen for other devices, too)

Expected behavior:
Using a Samsung Galaxy Tab S4 this plugin should return isTablet=true.

Environment information

  • Cordova v8.1.2
  • Android

Related code:
In src/android/IsTablet.java it's comparing metrics.densityDpi to a couple of Android density constants. In this example the Samsung Galaxy Tab S4 reports a densityDpi of 360. This particular dpi is not in the list of constants (160, 240, 160, 213, 320 and 480), therefore the check will return false for this device.

Based on my investigation so far I have 2 questions/suggestions:

  1. Why is it comparing the dpi against a set list of constants? Instead it could simply be checking metrics.densityDpi >= DisplayMetrics.DENSITY_DEFAULT.
  2. Why is it checking the dpi at all to determine if it's a tablet? In most cases a tablet is determined by its screen diagnoal (usually starting at ~7 inches), and a device with a large screen but low dpi would still likely be considered a tablet.

@dpa99c Do you intend to keep this Cordova plugin alive or can I help you. Please mail me: christopher@mindus.co, I also have other matters to discuss.