Sencha Touch 2.3 – Orientationchange event does not fire on Viewport

There’s a bug on sencha 2.3 about event orientationChange of viewport

This event isn’t fired: a workaround for this is to create a subcription on app launch

Ext.Viewport.bodyElement.on('resize', Ext.emptyFn, this, { buffer: 1});

http://www.sencha.com/forum/showthread.php?272988-New-version-Sencha-Touch-2.3-Orientationchange-event-does-not-fire-on-Viewport&p=1006877

 

 

 

 

Tagged with: , , , , ,
Pubblicato su Uncategorized

Sencha Touch – Remove android toolbar

At default sencha cmd compile app with android toolbar!

To remove it, you must add this attribute

android:theme="@android:style/Theme.NoTitleBar"

to AndroidManifest.xml in folder ..\Sencha\Cmd\xxxcmd_versionxxx\stbuild\st-res\android

 

Result:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="%s" android:versionCode="%d" android:versionName="%s">
	<uses-sdk android:minSdkVersion="%s" android:targetSdkVersion="15" />
%s	<application android:icon="@drawable/icon" android:label="%s" android:theme="@android:style/Theme.NoTitleBar">
		<activity android:name=".STActivity"
%s			android:label="%s">
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
%s
%s
%s
		</activity>
	</application>
</manifest>

Source: 

http://www.sencha.com/forum/showthread.php?259817-3.1.0.256-Strange-Android-Titlebar-on-native-Apps/page2

Tagged with: , , , , , , , , ,
Pubblicato su Uncategorized

Sencha Command – Java Heap

My sencha cmd create me some problems on compilation because it can’t take enough memory!
The building show an error about java heap space after a stop of some minutes.

...myProject\app\.sencha\app\build-impl. 
xml:158: com.sencha.exceptions.
ExScript: Wrapped com.sencha.exceptions.BasicException:
<strong><em> Java heap space</em></strong> (x-app-build#291)

So.. to increase it, you open sencha.cfg in ..\Sencha\Cmd\xxxVersionxxx\ search md.jvm.args variable and increase its value!

Tagged with: , , , , , , , , , , , , , , , , ,
Pubblicato su Uncategorized

Html text overflow!

I have to delimitate the overflow text in a html: I’m happy to know that a css class is enought to accomplish that!

This link explains the text-overflow css property!
https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow

Opera usees a different property


p {
  white-space: nowrap;
  width: 100%;                   
  overflow: hidden;   /* "overflow" value must be different from "visible" */
  text-overflow: ellipsis;    /* IE 6+, FF 7+, WebKit (Safari, Chrome), Opera 11+*/
  -o-text-overflow: ellipsis; /* Opera 9 e 10 */
}
Tagged with: , , ,
Pubblicato su Html

Ext Field: Change value without firing events!

To change a value of a Ext field without firing events it’s enough suspend events, do the action and reactive the events!

field.suspendEvents(false);
field.setValue(newValue);
field.resumeEvents();
Tagged with: , , , , ,
Pubblicato su Uncategorized

Android device manager

Finally google added a method to allow to track down a device registered on our profile!

Now, not only Apple users can find their iPhone (by Find my IPhone feature), infact google introduced Android device manager about a month ago!

Immagine

To access it open following link:
https://www.google.com/android/devicemanager

or, go to playstore page, open setting and click “mange device” item.

Immagine

 

It’s important enable this function on device.

From google https://support.google.com/accounts/answer/3265955?p=android_device_manager&rd=1&hl=en

Turn on Android Device Manager

Note: If you’re using a tablet with multiple users, only the tablet owner can manage the settings for Android Device Manager.

  1. Open  Google Settings from your device’s apps menu.
  2. Touch Android Device Manager.

You can turn on the following options:

  • Remotely locate this device. Remotely locate a device and find its approximate location on Google Maps. For devices running 4.1 and higher, location access must also be enabled. To turn it on, go to Google Settings > Location > Access location.
  • Allow remote factory reset. Remotely erase all data on your device. Touch this option, then select Activate to turn on the device administrator.
Tagged with: ,
Pubblicato su Uncategorized

Sencha touch – manage ajax error

I’m developing a sencha touch app and I need to manage errors of every ajax call! The most simple solution consist of subscribe to every call and manage response but it’s very repetitive and I don’t like it!

The solution I choose is to extend base class of Connection and override response method.

In the launch method of app.js I added this code:

Ext.define('Ext.data.myConnection', {
override: 'Ext.data.Connection',

onComplete : function(request) {
var response = this.callParent([request]);

if(!request.options.disableLoginRedirect){
if(response.status != 200){
         var extraMsg = 'response code: ' + response.status;
         Ext.callback(Ext.goToLogin, this, [extraMsg]);
       }else if(response.responseText){
         try{
           //parse json resposne
           var resObj = Ext.JSON.decode(response.responseText);
           if(resObj && !resObj.success &&
             resObj.code === Ext.errorCodes.NOT_LOGGED){
             Ext.callback(Ext.goToLogin, this, ['Not logged!']););
           }
         }catch(e){
       }
     }
   }
   return response;
 }
});

With this code every ajax call will be verified automatically.

In case of you want avoid this behavior for some request it will enought add ‘disableLoginRedirect=true’ in the request options!

Ext.Ajax.request({
  url: requestUrl,
  disableLoginRedirect : true, //this options!!!!
  ....
  success:
   ...
  },
  failure: function(response, opts) {
   ...
  }
});

If you are using JSONP the class to modify is:

Ext.define('Ext.data.proxy.myJsonP', {
    override: 'Ext.data.proxy.JsonP',

    createRequestCallback: function(request, operation, callback, scope) {
        var jsonPme = this;
        
        return function(success, response, errorType) {
            delete jsonPme.lastRequest;
            //console.log('jsonp callback');

            if(success && response){                  
                if(!response.success && response.code === Ext.errorCodes.NOT_LOGGED && (!request.options || !request.options.disableLoginRedirect)){
                    var extraMsg = 'not logged!';
                    Ext.callback(Ext.goToLogin, this, [extraMsg]);
                }else{
                    jsonPme.processResponse(success, operation, request, response, callback, scope);
                }
            }
        };
    }
});
Tagged with: , , , , , , , , , , ,
Pubblicato su Ext, ExtJs, Sencha

Demo effect!

Demo effect: too many user = too many client = web server KO! 

Argh!

Tagged with: , , ,
Pubblicato su Uncategorized

laziness

I started to view “big bang theory” in streaming! The first step was to connect the tv to the pc with an HDMI cable: Now I could view the series comfortably lying down on my bed! IMG_20130722_204356[1]

But the problem was that… I had to get up every time to start the next episode…

mmmm maybe ..

Tagged with: , , , , ,
Pubblicato su Uncategorized

Asp.net MVC 4 CORS

To allow cross-domain in asp.net it’s enough to modify web.config file adding this configuration:

<system.webServer>

    ...
    ...
    ...
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Headers" value="accept, maxdataserviceversion, origin, x-requested-with, dataserviceversion, Content-Type" />
        <!--<add name="Access-Control-Allow-Origin" value="*" />-->
        <add name="Access-Control-Request-Headers" value="X-Custom-Header" />
        <add name="Access-Control-Max-Age" value="1728000" />
        <add name="Access-Control-Allow-Methods" value="OPTIONS, GET, POST, PUT, DELETE" />
        <add name="Access-Control-Allow-Credentials" value="true" />
       
      </customHeaders>
      
    </httpProtocol>
    <directoryBrowse enabled="true" />
    <security>
      <requestFiltering>
        <fileExtensions>
          <add fileExtension=".json" allowed="true" />
        </fileExtensions>
        <verbs>
          <add verb="GET" allowed="true" />
          <add verb="POST" allowed="true" />
          <add verb="OPTIONS" allowed="true" />
          <add verb="DELETE" allowed="true" />
          <add verb="PUT" allowed="true" />
          <add verb="REMOVE" allowed="true" />
        </verbs>
      </requestFiltering>
    </security>
    ...
    ...
    ...

If you are using Chrome you don’t need any other configurations. If you user Safari (and iphone app built with phonegap, sencha cmd ecc..) you need to add in global.asax:


void Application_PreSendRequestHeaders(Object sender, EventArgs e)
{
     Response.Cache.SetCacheability(HttpCacheability.NoCache);
}

And in web.xml add

<authentication mode="Forms">
  <forms cookieless="UseCookies"/>
</authentication
Tagged with: , , , , , , , , ,
Pubblicato su Uncategorized