Monday, September 27, 2010
Thursday, September 23, 2010
WP7 Application Settings on IsolatedStorage
I'm starting to put together pieces for my WP7 application and one of the features I needed is to save/load application settings. There is already an integrated mechanism using IsolatedStorageSettings.ApplicationSettings, but I've implemented it using an XML file located on the IsolatedStorage. The main reason why I don't use the default one is because I want to upload/backup the file to DropBox or SkyDrive making it possible to share the same settings between various versions of the same application running on different platforms (in my case iOS and WP7) and also the user can restore the settings of an application when he changes the phone or reinstalls the application.
The VS2010 solution I am posting at the end of this entry is structured in 3 projects:
1. ConfigManager is the library used for settings management. It can read/write the settings. It also implements an indexed property, but as WP7 v1 uses Silverlight 3 it's not possible to use bindind to indexed properties (this feature is only available from Silverlight 4). If you want to directly bind settings to UI elements you will have to create bind-able properties . If the configuration file is not found on the IsolatedStorage the library will try to restore the file from Content (have a look at the sample TestConfig). It is possible to manually add values to the settings. There is nothing extraordinary in the source code.
2. TestConfig is a sample project that uses the library ConfigManager. It has a default configuration file deployed in Content (settings.xml). One of the things to pay attention to if you are binding to textboxes is to be sure that the binding is updated before saving the settings (this because if a textbox has focus, you modify it's value and select save settings you will loose the modifications if the binding is not updated). This is why I force the update of the source on TextChanged event:
((TextBox)sender).GetBindingExpression(TextBox.TextProperty).UpdateSource();
not a very elegant solution but it's the only one I found till now.
3. TestConfigMVVM is the same test project using MVVM light library. I did not include a settings file in the content and I load the default values manually.
Hope you will find the library useful and that you could spare the time I've spent in developing this part. The next post will be on synchronization with DropBox.
NAMASTE
Monday, September 20, 2010
WP7 Deploy Db as Content File
Some readers asked me about the possibility to use a database file deployed as Content with the project. Using the file directly from the content folder it is not possible as we do not have read/write access to content files. In fact if we use only the silverlight assemblies we don't have access to any content file. The solution is to use TitleContainer.Openstream from Microsoft.Xna.Framework (a reference should be added manually to your project) to read the content file and then save it to the IsolatedStorage. Once we have the file on IsolatedStorage we can use SQLiteClient to access it.
I've published an updated version of the SQLiteClient project adding a content file (test.db) and there is also ExecuteScalar inside the SQLiteCommand class.
Wednesday, September 15, 2010
WP7 Device Test Day One
Today was my first day of testing a WP7 device as my primary phone. Got the device on Monday, but being a really crazy week, I only got time to configure it today. Still have to install this weekend the development environment(I hope that tomorrow they will release the RTM also for the test devices cause I have a "clean" install of VS 2010 and I would like to keep it that way). The device is the LG and the build is the one that works with the beta tools.
In the past two days knowing that I don't have time to use/configure it I did some tests and got some interesting points. The first one was from my colleague Marius that, in the home screen kept pressing the windows(Start) button and not the arrow to go to the programs. This got me thinking that maybe it would be a good idea to be able to go to the Programs list when pressing Start(Windows) in the Home screen. The second person I gave the phone to play was my wife. She currently owns a Blackberry and I've wanted to see how she'll like the device. Bad luck... Maybe she was a little tired and wasn't in the right mood for trying new things but she didn't like the UI and gave up pretty quick (even if I told her to try the Facebook experience). Another colleague of mine (that owns an Android) returned the phone after 30 minutes of playing even if I've told him that he could play all evening as I did not had time (I will ask him why). So the feedback from the others was not as positive as I was expecting.
No let's get back to my experience. A bug that I've noticed in the beta build is in the initial wizard if you don't have the SIM card and you try to configure the windows live account it will block the device (the user should be able to configure the Wifi before configuring the windows live account in the intial wizard). I also got a "freeze" today using voice search with the word pizza :). At the beginning I did the mistake to add my Facebook account. Don't get me wrong I like the integrated experience but Facebook "polluted" my contact list with 200 people (and I don't have many friends on Facebook) which for me are not really important as phone contacts. I usually surf facebook if I have 10 minutes free time. For me it would be more suitable an Facebook application. So I took out the Facebook account and synchronized everything (calendar and contacts) using Google (it was quite an adventure to find the right programs that synchronize Outlook 2010 with my gmail account). I was good to go to test the phone.
The overall experience is good. The software keyboard is really good (but not better than the one on the iPhone or iPod touch). I have the impression that there is a lot of "wasted" space in the UI. For example when you are in a call you have the Speaker, Mute, Hold, Add speaker buttons that are small and then there is a lot of unused space. They could be a little bigger (even if the precision of the touchscreen is amazing but it would be for visibility and symmetry). Also the font is a little too small in some screens (in the home screen if you don't have really good eyes you will have some difficulties reading the screen). The worst designed part of the phone is still the Application list. It is in alphabetical order and the only thing you can do is to pin an app to the home screen or scroll scroll scroll. I've even tried, from the application list, to press search without being connected to the internet and wrote Marketplace but the result was empty. Let's hope that in the RTM this part will work. Anyway the application list is unusable when you have a lot of applications on the phone.
I am very excited to have a "real" test device and hope soon to start/have time to deliver some apps, modules.
P.S. Today in the car I was trying to call a person and I don't know what I was keep pressing that the phone was asking me if I want to delete the contact (got it at least 3 times today). Strange....
NAMASTE
Friday, September 10, 2010
Get Monotouch with 15% discount
Apple decided to take out the restrictions introduced in the iOS Developer Program earlier this year making Monotouch a "SAFE" environment to develop apps for iOS. Novell is celebrating this decision by offering a 15% discount on Monotouch for the next two weeks. If you are interested just use the discount code "MONO-331" on http://monotouch.net/Store
Friday, September 3, 2010
I hate marketing people
This post was not planned, but I have to write about it. The only reason I am not buying the iPhone 4 is the price. Today, watching the Apple presentation from 1st of September, got another confirmation. The new iPod Touch 32GB, that even Steve Jobs calls an iPhone without the phone and seems to have the exact same hardware of the iPhone, costs (in Italy) 309 Euros. The iPhone4 on the other hand 32GB costs 779 Euro, so 479 Euro for the Skyworks SKY77541/42 GSM module. That's why I hate marketing people: they decide. If they say the product will sell for that much that will be the price, but if you pass on the excitement of having a "cool" gadget you realize it doesn't worth the money. So I guess I will buy an iPod Touch for development and debugging.
P.S. Microsoft should be careful and react fast cause they are completely loosing a market on which they had some shares (that would be the PDA without a phone). The devices are still widely used (especially for restaurants) and will be used for gaming, apps. The iPod Touch is not only music anymore. Again Microsoft will have to choose a name for the OS because Windows Phone 7 without a phone it would be Windows 7 :) which is not the best choice. They've changed so many time the name of the mobile OS so one more won't count. Anyway a Windows Phone 7 without a phone makes a lot of sense to me
NAMASTE
C# for Mobile Development
A long time without blogging but I have some ideas for my next two posts (will be on Windows Mobile). Today I wanted to talk about developing on mobile platforms. Two weeks ago I joined the Monodroid preview version. So in this moment a C# developer is able to develop on all 3 major mobile platforms (Microsoft, Apple and Google).
My personal opinion on each of the development platforms:
I will start with Android and Monodroid which is the newest arrived. The integration with Visual Studio 2010 is fabulous (they plan to integrate with MonoDevelop also). I was impressed of the "activity" on the Monodroid list since launching of the preview (I have almost 500 messages in 2 weeks and it's not a preview opened to everybody) and even if it's a really early version and most of the things don't work (I've tried to use threading and sqlite library to do some comparative tests but nothing worked) there are already good ideas and a lot of interest to develop on this platform. One of the most "nasty" aspects of Android is developing the UI but Daniel Cazzulino from Clarius Consulting proposed to realize a "fake" WPF UI control just to leverage the designer, and then have a custom serialization that would transform the XAML to the android markup (this way it would be possible to use Blend too). Another aspect about Monodroid that doesn't convince me is the fact that almost everything is a "proxy" to the correspondent Java object so when you run your program every object creates another object in Java and of course this influences on memory requirements and performance. I wanted to test the Sqlite library because is not a Java wrapper and I could have a speed comparison between the Java program and the same Monodroid program (when Sqlite will work I will post the results). Then there is the runtime which has to be installed on the device. So for now I would not pay for Monodroid just to be able to write code in C# which is linked to Java (of course personal opinion and a lot of things can change when they release the first version of Monodroid) .
Then there is iOS and Monotouch. This a "mature" platform arrived at version 3.0. I love the fact that in the end the code is compiled to native code so you won't loose performance. The developer designs the interface with Apple tools and then link them to C#. You have access to feautures missing in WP 7 v1 like sockets, database and the newest one that will come to iOS 4.2 is PRINTING (if you read my blog you probably know that I am pretty "obsessed" with database and printing). Let's hope Microsoft will take Apple example and implement missing features really fast (I am referring at games for mobile where Microsoft is ahead of everyone but Apple just announced on the 1st of September the Game center and my feeling is that Google is preparing something similar for Android 3.0 for the end of the year). I think Monotouch worth every penny the only doubt remains if Apple will ever "block" the apps developed in Monotouch (they don't have any reason, but I've seen some prepotent behavior from Apple lately). You will need a MAC for developing.
The last but not least is WP7. It's is the most integrated development platform. It has everything a developer needs for development (I am not referring to the missing features of WP7) and it's FREE. I am waiting for the first devices to hit the market and "play" some more (I would have loved to have a "test" device and blog about the experience with the phone from usability to development).
In the following weeks I will also test and blog about the new controls from Resco for WP7 and Monotouch.
NAMASTE