Elephants Love Mango, Part 2/2: A Backstage Look at Evernote for Windows Phone 7

    Posted by Damian Meyers, creator of the Evernote client for WP7.

    image

    The previous part described the background of the Evernote client for Windows Phone 7, gave an overview of the platform from the developer's point of view, and described some of the problems the author had to deal with. Below we continue his story about developing Evernote for WP7.

    Solvable Challenges


    Delayed loading of panel elements
    Evernote for WP7 initially has several panels in the panoramic interface. The first panel that you see when you start work contains a list of all your notes. The following are lists of notebooks, tags, and recent notes.

    To optimize loading when I open the application, I delay the loading of all panel elements except the list of all notes. There is no XAML content in other panels, but when loaded events require appropriate panel elements, I dynamically load a control containing interface elements for the necessary panel with loading animation, which avoids the feeling of inhibition of the interface.


    Run Bundles When Working With Text
    In the list of notes, I wanted to show the date in bold, and then in a different color the text fragment - all in a single text block.

    To create rich text, you must define a TextBlock using the Run children. Each Run defines the formatting of the text inside the corresponding Run.

    All work with XAML is done through building links. You define the user interface using a declarative markup language and associate the properties of the interface elements with the properties of the .NET objects. For example, the Text property of a TextBlock element is associated with a Title in a Note .NET object.

    The essence of the problem in short is that you cannot bind the data of the Run elements in a TextBlock, so I couldn’t just bind the text of the first Run to the date property of the note, and the second to the property of its fragment.

    As a result, I wrote my binding mechanism, which, as it turned out, became quite popular on Stack Overflow , but this, of course, is not the thing that you want to devote so much time to developing.

    Audio file header
    Recording via Microphone in WP7 is pretty decent, but if you want to do something with the recorded data stream, for example, save it as a file, then you're out of luck. A simple save will give you a raw data stream file and nothing more.

    To reproduce this data by any application, you need an appropriate header. Apparently, this is why a post on my blog explaining how to add a title to the WAV is one of the most popular.

    Isolated Storage Performance
    Although I store metadata (title, date, etc.) for all notes, notebooks, tags, etc. in a single “database” file, in fact, the content is located in separate files. They include the body of the note and the associated “resource” data, such as file attachments, images, and audio recordings.

    I also cache the contents of the note, which I convert to HTML for local viewing. Thus, for a note with three attached images, you need six files in isolated storage:
    • preview notes to display in the list of notes;
    • note content;
    • note content converted to HTML;
    • three image files.

    The speed of opening a file from isolated storage is significantly reduced if many files are located in the same folder. So instead of storing the files of all notes in a single folder with the note identifier as the file name, I place the content in a subfolder whose name is determined by the two-digit hash of the note identifier.

    Another problem that I encountered was that when a user logs out of an account, the task is to delete thousands of different files in isolated storage. I don’t want to make the user wait until this happens, especially since the process can take hours. The fact is that the API does not have a call to 'delete folder' and you have to resort to recursive deletion - you need to go through the folder tree and delete each file individually.

    My solution was to store all the data under the root folder with a unique identifier (Guid) and access this folder in the settings dictionary. When you log out, I clear this link, and when re-authorizing you get a new identifier (and the corresponding folder). I have a background thread that deletes all files that do not match the current user id. He can try himself quietly in the background, eliminating all traces of the previous authorization.

    Waiting for Mango


    Wikipedia claims that mango is the most widely consumed fruit in the world, and although I'm not sure that the next release of Windows Phone, codenamed Mango, will ensure unqualified success for the platform, it will obviously become a significant event not only for users, but also for developers.

    In addition to solving the majority - if not all - of the problems described above, the update will bring a number of features that will not only simplify the life of developers, but also help us ensure functionality and usability at a level significantly higher than today.

    Here are some of the things I look forward to:

    Database
    This innovation is almost invisible to the user, but for me the appearance of a native supported database is important. I will gladly replace large pieces of code with a couple of lines: less code - fewer potential bugs.

    Silverlight 4
    Many of the problems that I had to work around in the current version of Windows Phone can be addressed in Silverlight 4, such as, for example, the inability to bind data from Runs elements to TextBlock. Accordingly, the developer will get rid of many inconveniences, which in fact should be solved elementarily.

    Inline search
    One of the incomprehensible moments for users of the Evernote application on Windows Phone is the fact that when you click on the search button on the phone itself while the Evernote client is running, they switch to Bing instead of their own Evernote search. And to access the second you need to click on a special button in the application interface.

    The situation may change in Mango, when applications can indicate that they are operators of one or another vertical search (products, films, places or events). The most obvious choices for Evernote are places, since notes can be geotagged. When you are looking for information on where to spend the weekend, and one proven place comes to mind, then using the search you can find a list of notes created there for the last time.

    Deep integration
    In order to create a new note right now using Evernote, you need to first launch the application, and then click on the “New Note” button. This process can be shortened to one click using deep integration. It will allow you to create tiles (tile widgets on the main screen) associated with a specific function (for example, make a photo note) or with specific content (separate notepad or note).

    Tiles
    We will study the possibilities of using the new functionality of tiles in Mango, possibly in order to display unsynchronized content with their help or to display the number of unresolved issues in to-do lists.

    Background sync
    The current version of Windows Phone does not allow running applications in the background, and although Mango has taken certain steps in this direction, Microsoft is modestly silent about how long the application can be kept running in the background. However, if you have a phone and Wi-Fi, there is no real reason that would prevent you from using a powerful connection to synchronize your Evernote account in the background.

    Conclusion


    Windows Phone 7 is in many ways an excellent programming platform, combining the use of the .NET framework and C # with Silverlight. However, it seemed complicated enough to create a data-oriented application with thousands of interconnected entities and without the basic capabilities inherent in an OS such as a database.

    I already look forward to the potential of the next version of Windows Phone Mango, which will open up much more opportunities for us, as developers and as designers, simplifying the process of bringing our ideas and ideas to life.

    Also popular now: