Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14806] ProjectTemplate: values used as comparison to determine device form factor are wrong

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-02-13T21:25:41.000+0000
Affected Version/sRelease 3.1.2
Fix Version/s2013 Sprint 23, 2013 Sprint 25, 2013 Sprint 25 Tooling, Release 3.2.0
ComponentsAndroid, Templates
Labelsqe-3.1.2, qe-closed-3.2.0, qe-testadded
ReporterFederico Casali
AssigneeChristian Sullivan
Created2013-08-10T01:38:09.000+0000
Updated2016-11-29T11:48:30.000+0000

Description

Problem description

In Appcelerator Studio template samples for classic projects, the values used as comparison to determine if the device is a tablet or a handheld are outdated and could lead to a wrong detection.

Steps to reproduce

Create a new Single Window Project and open app.js. Check line:
var isTablet = osname === 'ipad' || (osname === 'android' && (width > 899 || height > 899));
A Google Galaxy Nexus device (for example) has those values:
height: 1184 width:  720
As a result, it is being detected as a 'tablet' while is a 'handheld' device.

Comments

  1. Christian Sullivan 2013-10-11

    PRs to [MASTER] https://github.com/appcelerator-developer-relations/Template.Tabbed/pull/6 https://github.com/appcelerator-developer-relations/Template.SingleWindow/pull/3 https://github.com/appcelerator-developer-relations/Template.MasterDetail/pull/3 https://github.com/appcelerator-developer-relations/Sample.Todo/pull/7 https://github.com/appcelerator-developer-relations/Sample.Mapping/pull/7
  2. Dhirendra Jha 2013-10-23

    This issue is still reproducible. Still shows the below line in app.js file. Hence reopening this issue.
       var isTablet = osname === 'ipad' || (osname === 'android' && (width > 899 || height > 899));
       
    Test Environment - Appc Studio - 3.2.0.201310230601 SDK - 3.2.0.v20131022171645 acs -1.0.7 alloy - 1.2.2 titanium - 3.2.0 titanium-code-processor - 1.0.3 Xcode - 5.0.1 OS - Mac OS X Mavericks (10.9)
  3. Michael Xia 2013-11-15

    The PR is merged, and the new template is updated in the Studio ruble.
  4. Samuel Dowse 2013-11-18

    Verified fixed on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201311160316 Titanium SDK, build: 3.2.0.v20131118142443 CLI: 3.2.0-alpha Alloy: 1.3.0 app.js by default shows: var isTablet = osname === 'ipad' || (osname === 'android' && (width > 720) && (height > 600)); Closing.
  5. Lokesh Choudhary 2013-11-18

    I don't get it. A Samsung Galaxy S4 has height:1920 & width:1080 which according to the fix will be considered as a tablet whereas its a handheld device. Reopening. Environment: Appcel Studio : 3.2.0.201311161724 Ti SDK : 3.2.0.v20131117001643 Mac OSX : 10.8.5 Alloy : 1.3.0 CLI - 3.2.0-alpha Device: Samsung Galaxy S4 running android 4.2.2
  6. Christian Sullivan 2013-11-20

    [~mxia] [~ingo] So what is the agreed parameters of a tablet? The lager devices may be handhelds, but they are considered Phablets which falls in between phone and tablet.
  7. Ingo Muschenetz 2013-12-03

    Use the code here: https://github.com/appcelerator/alloy/blob/7ca0be6f142046f328b6b911b28fa3117501e14d/Alloy/lib/alloy.js#L449 Which is basically the same as here: http://stackoverflow.com/questions/16784101/how-to-find-tablet-or-phone-in-android-programmatically
  8. Christian Sullivan 2013-12-04

    PRs: https://github.com/appcelerator-developer-relations/Template.MasterDetail/pull/4 https://github.com/appcelerator-developer-relations/Template.Tabbed/pull/8 https://github.com/appcelerator-developer-relations/Template.SingleWindow/pull/4
  9. Samuel Dowse 2013-12-17

    Verified fixed on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201312142258 Titanium SDK, build: 3.2.0.v20131216064236 CLI: 3.2.0-cr3 Alloy: 1.3.0-cr Android Phone: Galaxy S4 (4.2.2) Screen Resolution: 1920x1080 Used "Master Detail" classic application. Used the following code
         function checkTablet() {
           var platform = Ti.Platform.osname;
       
           switch (platform) {
             case 'ipad':
               return true;
             case 'android':
               var psc = Ti.Platform.Android.physicalSizeCategory;
               var tiAndroid = Ti.Platform.Android;
               return psc === tiAndroid.PHYSICAL_SIZE_CATEGORY_LARGE || psc === tiAndroid.PHYSICAL_SIZE_CATEGORY_XLARGE;
             default:
               return Math.min(
                 Ti.Platform.displayCaps.platformHeight,
                 Ti.Platform.displayCaps.platformWidth
               ) >= 400
           }
         }
       
         var isTablet = checkTablet();
         console.log(isTablet);
       
    Code verified that the device was infact a phone despite the large screen resolution. Closing

JSON Source