Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-14806] #4

Merged
merged 1 commit into from
Dec 4, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 42 additions & 24 deletions Resources/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,52 @@

//bootstrap and check dependencies
if (Ti.version < 1.8) {
alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later');
alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later');
}

// This is a single context application with mutliple windows in a stack
(function() {
//determine platform and form factor and render approproate components
var osname = Ti.Platform.osname,
version = Ti.Platform.version,
height = Ti.Platform.displayCaps.platformHeight,
width = Ti.Platform.displayCaps.platformWidth;
//determine platform and form factor and render approproate components
var osname = Ti.Platform.osname,
version = Ti.Platform.version,
height = Ti.Platform.displayCaps.platformHeight,
width = Ti.Platform.displayCaps.platformWidth;

//considering tablets to have width over 720px and height over 600px - you can define your own
//considering tablets to have width over 720px and height over 600px - you can define your own
function checkTablet() {
var platform = Ti.Platform.osname;

var isTablet = osname === 'ipad' || (osname === 'android' && (width > 720) && (height > 600));
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 Window;
if (isTablet) {
Window = require('ui/tablet/ApplicationWindow');
} else {
// iPhone and Mobile Web make use of the platform-specific navigation controller,
// all other platforms follow a similar UI pattern
if (osname === 'iphone') {
Window = require('ui/handheld/ios/ApplicationWindow');
} else if (osname == 'mobileweb') {
Window = require('ui/handheld/mobileweb/ApplicationWindow');
} else {
Window = require('ui/handheld/android/ApplicationWindow');
}
}
new Window().open();
})();
var isTablet = checkTablet();
console.log(isTablet);

var Window;
if (isTablet) {
Window = require('ui/tablet/ApplicationWindow');
} else {
// iPhone and Mobile Web make use of the platform-specific navigation controller,
// all other platforms follow a similar UI pattern
if (osname === 'iphone') {
Window = require('ui/handheld/ios/ApplicationWindow');
} else if (osname == 'mobileweb') {
Window = require('ui/handheld/mobileweb/ApplicationWindow');
} else {
Window = require('ui/handheld/android/ApplicationWindow');
}
}
new Window().open();
})();