📜 ⬆️ ⬇️

Elephants love mangoes, part 2/2: backstage look at Evernote for Windows Phone 7

By: Damien Meyers, Evernote Client Creator for WP7

image

In the previous part , the background to creating an Evernote client for Windows Phone 7 was described, an overview of the platform from the developer’s point of view was given and some problems the author had to face were described. Below we continue his story about the development of Evernote for WP7.
')

Solvable difficulties


Postponed 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. Next come lists of notebooks, tags and recent notes.

To optimize loading when opening an application, I postpone loading of all panel elements except the list of all notes. There is no XAML content in other panels, but when the loaded events require corresponding panel elements, I dynamically load the control containing the interface elements for the desired panel with the loading animation, rather than avoiding the feeling of the interface being sluggish.


Bundles Run when working with text
In the list of notes, I wanted to show the date in bold type, and then in another color a text fragment - all in a single text block.

To create formatted text, you must define a TextBlock using the Run child elements. Each Run determines the text formatting within 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 .NET Note object.

The essence of the problem in short is that you cannot bind the data of the Run elements in TextBlock, so I did not have the opportunity to simply 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 own binding mechanism, which, as it turned out, became quite popular on Stack Overflow , but this, of course, is not the thing that I want to devote so much time to development.

Audio file header
Recording through the Microphone in WP7 turns out 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. Simple saving will give you a raw data stream file and nothing else.

To play this data with any application you will need the appropriate title. Apparently, therefore, a post on my blog, explaining how to add a title to 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, the actual content is located in separate files. These include the body of the note and its 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 will need six files in isolated storage:

The speed of opening a file from isolated storage is significantly reduced if many files are located in one folder. So instead of storing the files of all the 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 I encountered was that when a user logs out of a account, the task is to delete thousands of different files in isolated storage. I do not want to force the user to wait until this happens, especially since the process may take hours. The fact is that in the API there is no call 'delete folder' and you have to resort to recursive deletion - you need to go through the folder tree and delete each file separately.

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 you re-authorize 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 to himself slowly in the background, eliminating all traces of the previous authorization.

Looking forward to Mango


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

In addition to solving most - if not all - of the problems described above, the update will introduce a number of possibilities that will not only make life easier for developers, but also help us to provide functionality and usability at a level far exceeding today's.

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’m happy to replace large pieces of code with a couple of lines: less code means fewer potential bugs.

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

Built-in search
One of the confusing moments for Evernote users 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 a particular vertical search (products, movies, places or events). The most obvious choice for Evernote are places, since notes can be geo-tagged. When you are looking for information about where to spend the weekend, and one verified place comes to your mind, then with the help of the search you can find a list of notes that were created there last time.

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

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

Background Sync
The current version of Windows Phone does not allow applications to run 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 not a single 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 capabilities. Nevertheless, it seemed rather difficult to create an application focused on working with data, with thousands of interconnected entities and without the basic capabilities of an OS, such as a database.

I am already looking 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, by simplifying the process of realizing our ideas and ideas.

Source: https://habr.com/ru/post/123860/


All Articles