Get Sencha Touch Platform Name - extjs

console.log(Ext.os.Name)
prints the name for OS("Windows"==>in windows machine) for all browser,
But I want to know there is anyway to get the current Platform("chrome","safari","firefox","windows","ios","ios-classic") value based upon the theme currently loaded by sencha.
Because i need configure some of my component based on the browser also.
I dont need Browser name or os name, i need the platform variable used
by sencha framework. like when we using the ios6 it will take the
platform parameter as ios-classic we also pass the platform parameter
in link like http://cdn.sencha.com/touch/sencha-touch-2.3.1a/built-examples/kitchensink/index.html?platform=ios-classic# or
http://cdn.sencha.com/touch/sencha-touch-2.3.1a/built-examples/kitchensink/index.html?platform=windows# this will load the ios6 and windows theme respectively even we use any kind of browser in any OS.

you can use Ext.browser
console.log(Ext.browser.name);
console.log(Ext.browser.version);
Ext.device will not work for browser as it works only for native packing.
you can get what theme is applied by using Ext.theme.name
Ext.theme.name
getting platform for them is not directly provided in Sencha Touch. you can check implementation for that in sencha\app\microloader

I found the following configurations on http://docs-origin.sencha.com/extjs/4.2.2/#!/api/Ext , from that what i have observed is, we can't find the browser's name but we can check whether it is chrome or else like that...
example :
console.log(Ext.isWindows);
true //because i am working in windows
chromeVersion
firefoxVersion
ieVersion
isChrome
isFF10
isFF3_0
isFF3_5
isFF3_6
isFF4
isFF5
isGecko
isGecko10
isGecko3
isGecko4
isGecko5
isIE
isIE10
isIE10m
isIE10p
isIE11
isIE11m
isIE11p
isIE6
isIE7
isIE7m
isIE7p
isIE8
isIE8m
isIE8p
isIE9
isIE9m
isIE9p
isLinux
isMac
isOpera
isOpera10_5
isSafari
isSafari2
isSafari3
isSafari4
isSafari5
isSafari5_0
isWebKit
isWindows
name
operaVersion
safariVersion

In Sencha Touch 2.3 the Ext.device.Device singleton will give you information on the platform and the Ext.device.Browser will give you information on the browser.

Related

CakePhp 4.x basic Authentication

I am following the CakePHP 4.x tutorial to the letter (as far as I can see) until chapter "CMS Tutorial - Authentication".
Half way through "Now, on every request, the AuthenticationMiddleware will inspect the request session to look for an authenticated user. If we are loading the /users/login page, it will also inspect the posted form data (if any) to extract the credentials."
When I try to access articles or users I get an error:
( ! ) Fatal error: Interface
'Authentication\AuthenticationServiceProviderInterface' not found in
C:\wamp64\www\cake\src\Application.php on line 41
I have tried to figure out why this would be, but I cannot find it. I have tried looking up the same problem on the internet, no dice. Not even a mention that this could be security related (I found a mention about strict brower settings earlier but it was related to another problem).
I have uploaded my code on Github here: https://github.com/plafeber/cakephp-tutorial
I would greatly appreciate any feedback. I was under the assumption that if I create the full code set from the tutorial, given of course I run CakePHP 4.1.5 and follow the related Cake 4.x manual, that it would work. However, I already found out that I have to change the line about the use of DefaultPasswordHasher compared to what was in the code. So I can imagine the Tutorial page is not exactly as it should be.
This would be hte correct line about the use of the DefaultPasswordHasher in User.php;
//the use line
use Cake\Auth\DefaultPasswordHasher as AuthDefaultPasswordHasher;
//and the function
protected function _setPassword(string $password) : ?string
{
if (strlen($password) > 0) {
$hasher = new AuthDefaultPasswordHasher();
return $hasher->hash($password);
}
}
The solution to this was to navigate to the Cake install dir (containing the src and config folder and so on), then running the Composer call again. This apparently placed the filed in the right directories and then the error no longer appeared.

cn1PostMessage is undefined on Android. PostMessage is not working

I created a webview (BrowserComponent) and added a listener:
BComp.addWebEventListener(BrowserComponent.onMessage, e->{
Display.getInstance().callSerially(()->{
Dialog.show("Message", (String)e.getSource(), "OK", null);
});
});
Then, in the JavaScript of the embedded website, I called cn1PostMessage and postMesage. This works well in the simulator! But when building the application, on Android, it does nothing (cn1PostMessage is undefined and postMessage is not received by the main program).
var msg = "test";
if(window.cn1PostMessage) {
window.cn1PostMessage(msg);
} else {
window.parent.postMessage(msg, '*');
// Tried: window.postMessage(msg, '*');
// Tried: window.top.postMessage(msg, '*');
}
What can I do?
Thanks!
I just tried building the BrowserComponentPostMessageSample, and it seemed to work fine on my Galaxy S8, Android 8.
If you're finding that window.cn1PostMessage is undefined, then either there was a javascript error in page load that prevented that callback from being installed, or your code is running before the CodenameOne initialization code has run.
I have just added support for the "android.webContentsDebuggingEnabled" display property, which will make the app's web views debuggable using Chrome's remote development tools. This will make it easier for your to track down such issues. See usage example:
Display.getInstance().setProperty("android.webContentsDebuggingEnabled", "true");
This will be available in Friday's update (Dec. 6/19).
In the mean time, I recommend starting with the BrowserComponentPostMessageSample and modifying it to suit your needs from there.
Alternatively, if you can post a test case to demonstrate the issue, I can look at it.

chan->cdr no data after upgrade from Asterisk 1.4.21

I have a legacy Asterisk application in C which does authentication of users, routing and billing using MySQL. I have kept it with Asterisk 1.4.21 because none of the CDR data is returned in newer versions of Asterisk.
Apparently there have been some changes in 1.4.22 https://issues.asterisk.org/jira/browse/ASTERISK-13064 that have completely changed the way CDR-s are handled. Unfortunately no helpful information was given on how to properly migrate existing code.
They have changed the order of execution, the 'h' extension is called and the CDR data is reset.
My code:
ast_log(LOG_NOTICE,"Dialing string: '%s'\n", dialstr);
app = pbx_findapp("Dial");
if (app)
res = pbx_exec(chan, app, dialstr);
ast_log(LOG_NOTICE,"Return from pbx_exec '%i', Disposition: '%s'\n", res, ast_cdr_disp2str(chan->cdr->disposition));
Other parts of the code handle chan->cdr->billsec etc, but it always gives 0 values.
After a successful call I always get this log from CLI:
Return from pbx_exec '-1', Disposition: 'NO ANSWER' while the same code works fine on 1.4.21
One solution I heard is to use ast_reset() before Dial but I am not sure how to implement it.
Any help on how to adapt this application?
You can just get DIALSTATUS variable,that is enought for you application and will be supported in future releases.
pbx_builtin_getvar_helper(chan, "DIALSTATUS");

LocationManager requestLocationUpdates minTime parameter not working

I´m working with GPS in my applicaction. It works correctly in one of my mobile phone, but when I installed the software in other mobile the "minTime" parameter of LocationManager.requestLocationUpdates not working.
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime, misDistance,locationListener);
I have such as "minTime=120000" (2minutes) and "minDistance=30" (30 meters).
This fail may be due to the accuracy of the second mobile (is worse)?
The minTime parameter is just a hint, see here for more information: https://stackoverflow.com/a/4245527/1127492

How to detect if browser supports file uploading? (Mobile + Desktop)

I'm developing an application for both mobile and desktop browsers. I'm wondering if there is anyway to detect if a browser supports file uploading. I'm looking specifically for feature detection and not browser detection. Is there any way to find out?
Server-side or client side is fine.
Thanks
client side javascript:
<input type="file" name="file" value="" id="fileUploadField1">
<script type="text/javascript" charset="utf-8">
if (document.getElementById('fileUploadField1').disabled)
{ document.write('your device does not allow uploads'); }
else
{ document.write('your device does allow uploads'); }
</script>
You might be interested to read this article about current input type=file support on mobile and how to detect it: http://viljamis.com/blog/2012/file-upload-support-on-mobile/ (the detection is currently tested to be working on ~120 different mobile browser/mobile OS combinations).
Basically, we are just using similar detection as Modernizr does, but use UA detection as a backup to filter out those mobile browsers that falsely report support (there really doesn’t seem to be any other way to detect it reliably than using these both, feature detection and browser detection).
You can use Modernizr framework with forms-fileinput extension. Give it a try.
if Modernizr.fileinput
// you can use file inputs
Visit the Modernizr download page and check the forms-fileinput extension (expand the "Non-core detects" section).
Modernizr now supports a check for whether or not file uploads are supported.
From: What is the best way to check if user can upload files?
if(Modernizr.fileinput) {
//file input available!
} else {
//No file input :(
}
If you're worried about the size of this library, you can always get one component at a time - http://modernizr.com/download/ ... or you can just copy the code they use: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/forms/fileinput.js
if(navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) {
return false;
}
var elem = createElement('input');
elem.type = 'file';
return !elem.disabled;

Resources