Sunday, January 29, 2012

Windows Phone, Silverlight and Rich Text Fields

I'm currently working with a mobile dating application, named as Hooxter. You should follow it on twitter @hooxter just in case You are interested how it develops, but now to the actual topic.

The mobile application has one screen where I need to display formatted text, basically it's a chat windows where the conversation is rolling and each post is displayed as own chapter together with the information who sent that post.

In QT this was pretty straight forward, since I can just use QTextBrowser to display it, but the story was different in Windows Phone application and specially when You use MVVM pattern.

If You have such problem, just combine the information from following three posts and You have the same functionality in WP.

First, take RichTextBox to use by using instructions in here.

Secondly You need to the content as bindable, simple solution from here.

Then last but not least, define the custom namespace by using the instructions from here.

Please also note that You need to add namespace for the new content You add to the model, check notes for that from this post

Monday, July 11, 2011

Elisa Viihde and iPad remote control

I recently bought a new house and finally I had some extra space in basement to locate my servers in a fancy rack.
When renovating the house, I decided that I'm not going to put any coaxial cable for TV antennas to any room excluding the server room. Anyhow, all rooms has now cat6 wiring, totally 48 plugs all over the house.

So now when everything is "ready", all my TV's are using Ethernet to get "the signal". The solution is pretty standard one, I have one HP Proliant acting as a HTPC which has several DVB-T USB dongles connected to the TV-antenna. Each TV has XBOX-360 connected to them and that's working as a media extender for the HTPC Media Center, so now I can use the XBOX to see movies, pictures, gaming and watching live TV.

Last Christmas I subscribed Elisa Viihde for 24 for months. Elisa Viihde is an IPTV service offered by the largest Telco in Finland called as Elisa. The box has one issue, the "basic" channels are received via the terrestrial TV network.
So now when I did not have any of such wiring in my house, I had a small issue since I could not connect the Elisa Viihde box directly in to my TV. Or I could, but I could then watch only the "pay-TV" and I would need to switch back to XBOX when I want to see the "regular channels".

I did mount one HDMI cable to the wall when fixing the walls. The cable goes directly to the basement from my living room wall, the same applies to all speaker wires...

The final solution was to locate the Elisa Viihde box to the basement and connect that via HDMI cable to the TV. Ok, all works excluding the remote controller. To solve that issue, I bough and device called as USB-UIRT from http://www.usbuirt.com/ it took a week to arrive my local post office and after that, I just needed to figure out that how to use it.

I installed IIS server with PHP and the USB-UIRT to my HTPC. Then one extra application called as UUTX which I found from here http://www.etcwiki.org/wiki/Uutx.exe_command_line_for_usb-uirt. And later I just recorded the commands from Elisa Viihde remote controller and stored them in one file.
I tested the commands with the uutx.exe and all were working fine. So next step was to write extremely simple PHP script which converts the commands to buttons and displays them on a web-page.

Now I can connect to that web-page by using iPad and manage the Elisa Viihde from my living room...

Btw. the Elisa Viihde is connected also to the amplifier I have on my server room, so now there is not too many visible devices in the living room excluding the flat-screen LG and the speakers.

The next step is to implement this code to use jQuery UI and Ajaxize the it, but since it's doing it's job and there is +28 celcius outside, I think to jump in to my convertible and ride to the beach...

Saturday, August 29, 2009

Samsung SGH-i200 and CellID

I have one on-going project where I need to use location data of mobile device to perform some actions. I have been doing some LBS related stuff earlier, based on GPS data from Nokia devices by using Java API, but now I need to target also to "low-end" devices which has no GPS capability. Ok, there's no trick, since all know that the cell-id can be used for such purpose and when comparing that to some back-end database holding a information for cellId/MNC/MCC geo-location mapping.

In the Symbian based devices, there's no issue, at least when using C++ API, Java API may have some limitations. So my Symbian (3rd edition) client is working just fine.

Then it was time to create same application for Windows Mobile 6. During the development, I got my first touch to C# and Microsoft development tools. Well, I must say that I'm happily surprised about their tools. If You compare Carbide C++ for Symbian and Visual Studio 2008 for Windows Mobile, I need to say that the Windows world feels more user friendly.

Currently I have only one device with WM 6.0 and that is one of those low-end mobiles using WM, Samsung SGH-i200. I bought that as a new from Finland and the price was 98 euros, not bad... Anyhow, the user interface of the device doesn't look fancy at all, the home-page/desktop or how do You call it in Windows looks ok, but rest is from the eighties... So if some one is complaining that Nokia has weak user experience, I really need to say that the WM is even worst. And now I'm comparing low-end versions, like S40 of Nokia and WM 6 standard.

So, to the problem. The RIL interface seems to be nicely documented by Microsoft, so it didn't take many minutes to write the skeleton out for testing. What I have learn from Mobile Development is that it's usually more efficient to write a simple skeleton to test that all API's You need are working and then start building the real application. You can never trust that the API's are working as documented.

And exactly that happened in here. I get the CellID, MNC and MCC out, but since I know very well the ones available in my home-office, I noticed immediately that those are not even near to the correct ones. I know that in some WM devices those are working fine, I did Googling and got the proof :) The MNC and MCC are constant, but the CellId changes sometimes. I'm pretty sure that the engineers in Samsung hasn't implement this feature and that they are just returning some rubbish values for me to avoid writing some extra line of code to return that the API is not available.

I hopefully get HTC with WM 6 Professional during next week, so let's see how that performs.

Friday, August 28, 2009

jQuery remove for HTML select options

Today, I faced yet another issue with jQuery :)

I'm building a product configurator where each select event effects to other fields, filling in parameters compatible with the field where the selection was made. For selectors, I'm using HTML select field.

So what my plan was. I was planning to query the data from the server via regular getJSON method and then based on the result, populate required fields in the configurator. First thing was to clean all existing fields from old data, before populating them with a new data. For cleaning I was using the standard remove method provided by the jQuery.

To fill in the fields, I'm using Sam Collett's tool to manage data on selects. I'm using it in many places so it was a natural choose for htis as well. Anyhow, when stress-testing the configurator, I noticed that sometimes there's empty options on select, which were not cleaned properly by the jQuery remove ? I tried also just to insert empty html and jQuery empty method, but no success. When I removed the code which populated the fields, the select was empty...

Then I finally decided to make tests with the removeOption from the Sam's library and voila, works like a charm.

So if You ever face similar problems, I recommend You to try out Sam's library.


function someproductRePopulateFields(data, status, message)
{
var elementList = $("#"+data.method);

elementList.removeOption(/./);

if (data.statusMessage)
{
updateStatusMessage(data.statusMessage);
}
else
{
updateStatusMessage("");
var selectOptions = $("#"+data.method);
selectOptions.addOption(data.elements);
}
}

Monday, August 17, 2009

jQuery callbacks on HTML load

In my current project, I needed to start using jQuery as a library for user interface components.
The project uses AJAX quite heavily so I have spent some time thinking how to do the things
efficiently since the customer has pretty great requirements from performance.

There's a couple of places where the system loads content to a DIV and then some Javascript
function needs to be called to perform some action after the document is loaded. Action could be like initializing Google map.

Since jQuery doesn't support live events for "ready" type of events, I need to find some other method to initialize the map.
One could be onload event on body, but since this is a framework and div's are updated on fly based on the application loaded, it's out of the question.
Another manner would be to use $(document).ready inline in the HTML code loaded to DIV, but from my opinion it's not elegant style either, at least based on MVC.

Since request expecting response as HTML is not capable to deliver Javascript call-backs, I decided to do one simple trick.

I added one extra header to response, let's call it as X-onLoadCallBack.
Then when the callback of successful transaction is called by jQuery after the HTML is loaded,
the call-back will check if the mentioned header is found and executes it by using eval.

Later I faced another issue, since I needed two callbacks to be called on-load. One for the framework and another for the plugin in the framework.
Solution is to add two call-backs with same header name.
I noticed that based on http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/#dfn-getallresponseheader they are separated with comma, so
I added a check to verify if there's multiple callbacks and then loop them through and execute eval one-by-one.



// function triggered on page load
function somefunction()
{
$.getJSON("index.php", {element: element, objectId: id}, checkResults);
}

function checkResults()
{
// Other code in here....
$(document).ready(function(){
$("#mainarea").load("index.php", {element:'run_plugin'}, checkCallBacks)
});

}

function checkCallBacks(responseText, textStatus, XMLHttpRequest)
{
pluginCallBackFunction = XMLHttpRequest.getResponseHeader('X-onLoadCallBack');

if (pluginCallBackFunction.match(","))
{
var cBPluginArray = pluginCallBackFunction.split(", ");
$.each(cBPluginArray, function(key, val){eval(val+"();");})
}
else if (pluginCallBackFunction)
{
eval(pluginCallBackFunction+"();");
}
}


Note that when sending headers from PHP, You must define "replace" flag to false and it allows multiple headers with same name.

Monday, May 19, 2008

Nokia E51 and Asterisk

I got Nokia E51 and decided to do some testing with that against Asterisk PBX.

Everything was working fine until the phone was not able to receive any calls, it freezed completely and only way to get it back online was hard reboot.

I tried to Google, no results, I reflashed it, no results, tried all different settings combinations on handset, no results.

I started to go through the Asterisk confs from scratch and finally found the error. I had switched the "videosupport" parameter in sip.conf to yes and when I switched that back off, everything started to work again...

Anyway, it seems to work nicely now so I'm going to do some field testing with it.

Friday, January 18, 2008

Windows Vista and Slow Keyboard Response

Long time no entries, but finally I got so pissed up that I need to write one :)

I got Dell Inspiron 6400 laptop some months ago. The PC had factory installed Vista Business, so I was a little bit of worry how stable it is, but seems to work ok.

I started to install applications I used on my old XP PC. Everything went well and all got installed, excluding Stonegate VPN client which didn't have support for Vista.
I decided to replace that with OpenVPN since I'm not happy to Stonegate VPN client stability, not even in my old XP where it caused issues with the network every now and then.
I use the PC suite for syncing my mobile with PC, in XP I had Outlook, but in Vista I decided to use Windows Contacts which replaced the Windows Address Book from earlier Windows versions.

After initial sync, the PC started to act weirdly, when typing text output to screen got jammed, frozen what ever you want to call it, but letters appeared sometimes with three to five second delay.
This happened in all programs and it was very annoying when trying to write some document, email etc.

I tried to google, but no fix found. So I decided to remove PC suite which was the last program installed. No effect.
I continued to remove applications one-by-one, no effect.
I decided to re-install Vista since I was sure that I have somekind of virus in my PC which were not detected by antivirus software.

After re-installation Vista, everything started to work fine. I started re-install applications one by one, testing if the same issue appears again. Didn't happen. This time I didn't spend time with syncing my phone.

That all happened on last octobre and until today everything has been working fine.

Today I got new mobile and I decided to sync the contacts through the PC from old E50 to new Nokia 6110 Navigator. First I noticed that the PC Suite didn't support Windows contacts, so I needed to upgrade it to the latest one. After syncing the contacts from E50 to PC, the same issue happened again. Text started to flos slowly to the screen.

Ok, now I was sure that it was the PC suite since that's the only software I have installed today. I decided to make one test before removing the PC Suite, since it didn't help on last time. I removed all contacts from my Windows Contacts after syncing them to my 6110.

What happened, the issue was solved, text was flowing nicely and smoothly. I tested it again by syncing the contacts to the Windows Contacts from the mobile phone and I had same issue again. So remove the contacts again - no issues...

As a conclusion. If You have several contacts in Your Windows Contacts - it will generate typing problems in all applications.