I'm sure I'm just overlooking this question but I cant seem to find how to check the device.
I want to check whether the device is either a phone, a tablet in landscape mode, a tablet in portrait mode or a other device (computer).
What I have is this:
if (Ext.platform.isPhone) {
console.log("phone");
}
if (Ext.platform.isTablet) {
console.log("tablet");
}
var x = Ext.platform;
But platform is undefined (probably because this is the way of Sencha Touch 1).
Does anyone know the correct place for me to access the device check?
Sencha Environment Detection offers a large spectrum through simple means.
Instead of Ext.os.is.Tablet, you can make life easier via Ext.os.deviceType which will return:
Phone
Tablet
Desktop
NB: this value can also be fudged by adding "?deviceType=" to the url.
http://localhost/mypage.html?deviceType=Tablet
Ext.os.name is the singleton returning:
iOS
Android
webOS
BlackBerry
RIMTablet
MacOS
Windows
Linux
Bada
Other
The usual ability of browser detection is available through Ext.browser.name.
Something I've only recently encountered, which I love is feature detection - allowing coding similar to Modernizr / YepNope based off ability of device. Ext.feature offers:
Ext.feature.has.Audio
Ext.feature.has.Canvas
Ext.feature.has.ClassList
Ext.feature.has.CreateContextualFragment
Ext.feature.has.Css3dTransforms
Ext.feature.has.CssAnimations
Ext.feature.has.CssTransforms
Ext.feature.has.CssTransitions
Ext.feature.has.DeviceMotion
Ext.feature.has.Geolocation
Ext.feature.has.History
Ext.feature.has.Orientation
Ext.feature.has.OrientationChange
Ext.feature.has.Range
Ext.feature.has.SqlDatabase
Ext.feature.has.Svg
Ext.feature.has.Touch
Ext.feature.has.Video
Ext.feature.has.Vml
Ext.feature.has.WebSockets
To detect fullscreen/app/homescreen browser mode on iOS:
window.navigator.standalone == true
Orientation Ext.device.Orientation and orientation change:
Ext.device.Orientation.on({
scope: this,
orientationchange: function(e) {
console.log('Alpha: ', e.alpha);
console.log('Beta: ', e.beta);
console.log('Gamma: ', e.gamma);
}
});
Orientation is based on Viewport. I usually add a listener which is more reliable:
onOrientationChange: function(viewport, orientation, width, height) {
// test trigger and values
console.log('o:' + orientation + ' w:' + width + ' h:' + height);
if (width > height) {
orientation = 'landscape';
} else {
orientation = 'portrait';
}
// add handlers here...
}
Use Ext.env.OS's is() method.
Note that only major component and simplified value of the version are
available via direct property checking. Supported values are: iOS,
iPad, iPhone, iPod, Android, WebOS, BlackBerry, Bada, MacOS, Windows,
Linux and Other
if (Ext.os.is('Android')) { ... }
if (Ext.os.is.Android2) { ... } // Equivalent to (Ext.os.is.Android && Ext.os.version.equals(2))
if (Ext.os.is.iOS32) { ... } // Equivalent to (Ext.os.is.iOS && Ext.os.version.equals(3.2))
Alternatively, you can also use PhoneGap Device API
I found the answer to it:
What seems to be the case is that Ext.os.is.(tablet/phone or something else) is true or undefined. If it is not the case it will be undefined.
I.a. Ext.os.is.Tablet is true when on a tablet and undefined when not.
So this is the answer I was looking for
if(Ext.os.is.Tablet){
this._bIsTablet = true;
}else if(Ext.os.is.Phone){
this._bIsPhone = true;
}else{
this._bIsOther = true;
}
Related
I'm developing camera app right now.
I finished most of important features but the most important feature left.
I want my app auto exposure mode.
Here is my sample.
do {
try camera.lockForConfiguration()
camera.focusMode = .continuousAutoFocus
camera.exposureMode = .continuousAutoExposure
camera.unlockForConfiguration()
} catch {
return
}
I made this setting between lockForConfiguration and unlockForConfiguration.
This lead to autoexposure, however it is different from native camera app.
Also, shutter speed does not go below 1/40.
It is always 1/40 whenever it is in dark environment.(where native camera app adjust shutter speed to 1/2 or even 1)
I found the answer here (https://developer.apple.com/forums/thread/26227)
But I don't understand this answer and even how to do that...
session.beginConfiguration()
defer {
session.commitConfiguration()
}
device = AVCaptureDevice.default(.builtInDualWideCamera, for: .video, position: .back)
guard let camera = device else {
set(error: .cameraUnavailable)
status = .failed
return
}
I set AVCapturedevice in this code. Also there is a session.
The answer says don't touch sessionpreset, so I did do anything by sessionPreset.
But how can I set the avcapturedevice by activeformat..?
This is very hard to understand.
Just to check if this is work, I added this codes just below above codes.
'''
var bestFormat: AVCaptureDevice.Format?
bestFormat = device!.formats[2]
print(self.device?.formats)
do {
try camera.lockForConfiguration()
camera.focusMode = .continuousAutoFocus
camera.exposureMode = .continuousAutoExposure
camera.activeFormat = bestFormat!
// camera.setExposureModeCustom(duration: CMTime(value: 1, timescale: 500), iso: 2000)
camera.unlockForConfiguration()
} catch {
return
}
'''
I believe this does not work because camera-resolution doesn't change.
even if device!.formats[2] is low resolution for me (I checked it)
I am trying to detect if a client is an iPad, and to do that I'm trying to use window.navigator.platform and window.navigator.maxTouchPoints.
I'm trying to do this from Vue, by setting it as a computed property.
One device I have to test this with is an MDM-device, an iPad running the latest iOS and using Safari as the browser.
This is my computed property:
// ...
computed: {
isIpad() {
return navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 0;
}
}
And this is the view:
<div class="feature">
<div v-if="isIpad" class="feature-desktop">This feature is only available on desktops.</div>
</div>
In my vue-inspector on MacOS/Firefox the computed property is correct, returning false as expected. When I try to emulate an iPad through Firefox, it returns true, as expected. However, if I open the page using Safari on my MDM-enabled iPad, this property returns false.
Sadly, I cannot connect with developer tools as the iPad is locked down, but I can manually put javascript on the page to print out the result of both navigator.platform and navigator.maxTouchPoints, and they return the expected MacIntel platform and 5 touch points.
<script type="application/javascript">
document.getElementById('app').innerHTML = navigator.platform + ' ' + navigator.maxTouchPoints; // Prints MacIntel and 5
</script>
Does anyone have any experience with this sort of thing? I've yet to attempt setting a data-property with mounted().
Using the mounted event handler to set a data-property solved my problem.
I need yout help to find out how to write and read files from external usb storage from Tizen Smart TVs. Problem starts when detecting it
`
/**
* Hello World Sample Project
*/
// import Label component
var Label = caph.require('ui.base.component.Label');
caph.app.addScene('main', $class({
$extends : caph.require('ui.base.Scene'),
// oncreate is called when the scene is created
oncreate : function() {
// add "Hello World"
this.addChild(new Label({
text : 'Hello World',
size : [ 500, 100 ],
position : [ 300, 400 ]
}).setTextSize('72px').setStyle({
backgroundColor : 'red',
color : 'white'
}));
/// Here the filesystem showd show me all the storages
tizen.filesystem.listStorages(checkCorruptedRemovableDrives);
}
})).run();
`
And here is the Success callback, this show me how much storages I have.
`
/* Success event handler */
var checkCorruptedRemovableDrives = function(storages) {
/// Here I will kow how much storages I have
console.log(storages.length);
for (var i = 0; i < storages.length; i++) {
if (storages[i].type != "EXTERNAL")
continue;
if (storages[i].state == "UNMOUNTABLE")
console.log("External drive " + storages[i].label + " is corrupted.");
}
};
`
Here is the method thrown when there are errors, this is never called.
var checkCorruptedRemovableDrivesError = function(storages){
console.log("Error");
}
Now, the console output is aways a simple 0 meanning I have no storage (but I have the internal one and two usb ones mounted).
Has Anyone faced this problem or have any Idea on how to solve it?
Samsung Tizen TV always uses "removable2" as label for USB.
So you don't need to use listStorage and getStorage.
Multiple USBs are distinguished as "removable2/sda1", "removable2/sda2"
tizen.filesystem.resolve("removable2", function(e){
e.listFiles(function(r){
for(i = 0; i < r.length; i++){
tizen.filesystem.resolve(r[i].path + r[i].name, function(t){
//You resolve USB root. Do something you want with USB.
}, function(t){
console.log("resolve error for " + r[i].path + r[i].name);
console.log(t);
}, "rw"); //you should use rw permission, to write something in usb.
}
});
},function(e){
console.log("removable2 resolve error");
console.log(e);
}, "r"); // permission should be given as r for removable2
Here is test app made by me. and you can check how to use SDK 1.5
http://www.samsungdforum.com/SamsungDForum/ForumView/3ad8bd6023af18a7?forumID=d88a711f47dc6e9f
This app is working in both of TV and SDK 1.5
Do you use Web Simulator?
APIs don't work in Web Simulator properly. It can't simulate things well.
When I check listStorage in 'emulator', it throws list of storages.
but even though I can get list of storage, I can't use it in filesystem. It is bug of SDK 1.4.
SDK 1.5 will have test features for USB storage, and it is planned to release in a month. Wait for a month :(
I want to use multiple USB camera with Web RTC.
For ex)
https://apprtc.appspot.com/?r=93443359
This application is web RTC sample.
I can connect to another machine, but I have to disconnect once to change the camera.
What I want to is,
1.Use two camera at the same time on the same screen.
2.(if 1 is not possible),I want to switch the camera without disconnecting current connection
Does anyone have information about how to use two camera on Web RTC?
call getUserMedia twice and change the camera input in between
You can use constraints to specify which camera to use and you can have both of them displayed in one page as well. To specify which camera to use take a look at the following snippet (only works on Chrome 30+):
getUserMedia({
video: {
mandatory: {
sourceId: webcamId,
...
}
},
successCallback,
failCallback);
The webcamId you can get by:
MediaStreamTrack.getSources(function(sources){
var cams = _.filter(sources, function(e){ //only return video elements
return e.kind === 'video';
});
var camIds = _.map(cams, function (e) { // return only ids
return e.id;
});
});
In the snippet above I've used underscore methods filter and map.
More information on:
WebRTC video sources
constraints
I am experimenting with making Blackberry widgets but having a little trouble.
My first trial involves displaying a button which, when clicked, calls a JavaScript function that should alert the phones latitude and longitude.
The function looks:
function whereAmI() {
var latitude = blackberry.location.latitude;
var longitude = blackberry.location.longitude;
alert("Lat: "+latitude+", Long: "+longitude);
}
But it only ever alerts "Lat: 0, Long: 0". I've checked and my GPS seems to be working ok.
I'm running OS 5.* on a Curve 8900.
Any help would be appreciated :)
I discovered that I wasn't signing my files properly - now that I have, everything works fine.
For kaban:
// called when location object changes
function locationCB()
{
alert("Latitude " + blackberry.location.latitude);
alert("Longitude " + blackberry.location.longitude);
return true;
}
// test to see if the blackberry location API is supported
if( window.blackberry && blackberry.location.GPSSupported)
{
document.write("GPS Supported");
// Set our call back function
blackberry.location.onLocationUpdate("locationCB()");
// set to Autonomous mode
blackberry.location.setAidMode(2);
//refresh the location
blackberry.location.refreshLocation();
}
else
{
document.write("This Device doesn't support the Blackberry Location API");
}
Does your widget have permission to use GPS? Go to Options->Applications, select your app, then "Edit Permissions". Make sure "Location Data" (in Connections) is set to Allow.