Rockbox

  • Status Unconfirmed
  • Percent Complete
    0%
  • Task Type Patches
  • Category Plugins
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version Release 3.8
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by gbl08ma - 2011-03-03

FS#11989 - Contacts plugin written in LUA

Rockbox already exists for several years (fortunately), however it doesn't include a contacts list plugin by default, most likely because no one had coded one until now. As it's something that sometimes becomes handy, I decided to write my own, and as it's a simple enough plugin I've written it in LUA, to serve the purpose of a contacts plugin, to have a working example of a LUA plugin (that is not a game) and to explore the (im)possibilities of the LUA interpreter of Rockbox.

So this task will handle the development of a contacts plugin. Attached goes a BETA (but already very complete) version of the plugin. Just copy to your device (any location) and "play" the file.
The database where the contacts are stored is located at the root of your player, in a file called contacts.txt. The name and location of this file is subject to change in future versions, but the way contents are stored will probably keep being the same, so you can start adding your contacts (you can edit the file in the PC as long as you keep the format valid for LUA interpretation).

Key features (already implemented):
- View first, middle and last name of the contacts just after you open the plugin (fixed name order)
- Add contacts (lots of fields, I won't be adding more for now)
- Delete contacts (permanently and without confirmation, take care)
- View contact fields (after selecting it in the menu)
- View specific fields in their own screen (where you can also clear and, in the future, edit them)
- (Should be) Compatible with any Rockbox target that interprets LUA because the interface is entirely made of standard RB menus
- Works (at least) on my iPod Nano 2nd Gen
- Wonderful LACK OF warranty that it will work or that the plugin won't delete your contacts accidentally. Use keeping in mind this is a BETA version

To be implemented (for sure):
- Edit contacts
To be implemented (when I have time):
- Order the way names are displayed (e.g. first→middle→last to last→first→middle)
- Search for contacts by inputing part of any of the fields content
- Order contacts by categories (that's why there's a "Category" field on them)
To be implemented (if my programming skills allow it):
- Associate a image file to a contact, which will be shown when the contact is selected (and if someone codes it, why not a pictureflow of contacts?)
- Import and export contacts as vCards
- More configurable settings

Another additional note is that the current code of the plugin is not in agreement with the Rockbox coding style guidelines, I've tried to keep the number of chars in each line under 80, but there are lines where this is false. Also, the tabs are double-space instead of four spaces. This will be corrected when I finish the plugin.

Please test on your player and share the results, as well as any bugs or suggestions you might find.

Here goes an updated version that allows editing of individual contact fields or the contact as a whole (like what you do when you add a contact).

Next thing to do is implementing the settings interface and add a setting to switch the order names are displayed.

And the attachment keeps on being left out…

Nice idea using the menu system like that. I have a couple of small suggestions:
* Perhaps you could remove the distinction between viewing and editing a contact. That is, you click on a contact in the menu then you can click straight on a field and edit it. I'm not sure how useful the clear field command would be, and it seems to be the only reason for the distinction.
* I'd be tempted to roll the whole first, middle, last name thing into a single field.
* Perhaps shorten work and personal stuff to "Phone (W)"/"Phone (H)" etc., at present I have to wait for the text to scroll before I get the whole number.
* I'd stick the return, edit and delete stuff down the bottom, you'll be viewing more than editing and pressing back works to return to the previous menu (contacts list).

Not a bad idea :), i'll have to get around to importing my contacts (it would have been useful the other day…).

Stefan, here are some replies to your comment… Point 1: I know it is a bit confusing the way it is now (too many similar screens); I have made the viewing screen open a specific menu for every field, and the editing screen open a virtual keyboard. As the plugin is now, you have two ways to edit a contact: go to the editing screen where you can edit all fields in the same menu, or view the contact and edit every field individually (allowing you to clear a field without pressing backspace on the virtual keyboard several times, and that's the advantage of the clear field command). The view field screen exists to allow fields with more complex content to be seen (none of these fields exist now; on the future there will be things like picture fields and that's why this screen exists). This is something to be seen later, I guess.
Point 2: I could make it to show the complete name in the same field in the viewing screen, but I'd always need to have different fields on the database for each name, so functions like name ordering and field search are possible, when implemented.
Point 3: I like it the way you explained, the problem is that some people don't, so I'll make it into a setting like "Show full fields description" when I code the settings part.
Point 4: Other thing that could be optional… I like it at the top, you (and possibly others) like it at the bottom so I'd put that option on settings too.

About porting your contacts… well, if you need them urgently on your DAP, you can start now, but if you can wait, I'd suggest that you wait for the plugin to develop more as possibly the table format is still going to change, making old contact databases incompatible.
Also, if I find open source LUA code that can do it, I'll also work on a vCard importer/exporter… but this last thing I don't promise.

I adapted some code I'd written a few years ago to import my contacts into your program. It generally works alright.

I found a reasonably annoying bug on my player (with the lua plugin I think) where if you scroll the list of contacts too fast it crashes the player. I've attached an anonymized contact list for you to try and reproduce the problem on your iPod. The crash message I get is this:

That point 4 I mentioned in my last comment is kinda irritating too, it's hard to use the phone numbers when they're scrolling around everywhere. For me at least, the view screen would be more useful if it looked like this (with the screen boundary drawn):

Shortened view:
_
Bob Smith |

 P 12345678               |
 M 12345678              |
 bob@hotmail.com     |
 Full edit view              |

|

Full view:
_
Edit contact |

 Name: Bob Smith       |
 Ph (H): 12345678      |
 Mob (H): 12345678    |
 Email (H): bob@hotm|

…Other fields… |

 Delete contact          |

|

You can see I've made a few changes :). First, there's a shortened view (which you can see there), and a full view. The full view would have the complete list of possible fields with descriptive labels, and the contact delete button. The shortened view just shows the fields which have values, and an abbreviated label (if any is necessary). You can edit the fields in the shortened view by just clicking them, if you want to add a field you go to the full edit view. The advantage of this setup is you can have an easy to read view screen which shows the info you have, while keeping the ability to edit all the fields. Moving the delete button to the full view means it's less likely it would be accidentally pressed. Moving the contact name to the title means you'll know who you're viewing if you have to trawl through a large list of fields, since it stays on the screen at all times. It might be a problem if you have a long name though (not sure).

Flyspray removed my screen formatting, oh well.

I'm scrolling the list as fast as I can on my iPod nano2g with the file you provided me and I can't make it crash.

I have noticed, however, that sometimes glitches appear on the list. From a duplicate "!! Add Contact" on first89, like this:


- !! Add Contact (or press… - first1
- first2
.
.
.
- first87
- first88
- !! Add Contact (or press… - first90
- first91
.
.
.
- first107
———————————————End Of Screen— …to strange characters on first64, like this:


- first63
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
- first65
——————————————–EOS—-
[] = square character that appears when a character is unreadable

…to empty spaces in the menu (something never seen in Rockbox!). When we place the cursor on the empty space, which has exactly the same height as a menu item, the cursor also disappears. It's like that menu item was transparent.
Like this:


- item
- item

                                                                                         <- empty space

- item
- item
——————————–EOS– If we could make this effect happen on purpose, and without the cursor being hidden, it'd be good, as I'd like to have a separator in the menus at some places in the script :)

These three events happen randomly, only one of them seems to happen at once, and the list is created correctly only very rarely.
When we select a strange menu item, the script crashes complaining about a nil value.

All of this is very strange. I think they are all Rockbox bugs in the LUA interpreter.
I won't develop any further until I'm sure this is not a problem of Rockbox.

About your suggestions, I was going to apply them if it weren't for these bugs. And about the phone numbers rolling, you can select the field in order to open the field view screen, where the numbers won't scroll unless they are very big.

Regards, and thanks for discovering these bugs,
Gabriel

Had a chance to look at the changes in pixel-painter yet ;)?

I had a look around in the source code, one problem is that the maximum number of items in a menu is 64 (hard coded), see the top of menu.c under the apps subdirectory (#define MAX_MENU_SUBITEMS 64). You should get an array indexing overflow if you try and define more than this. This results in possible memory corruption which manifests as a crash in my case and strange menu effects in yours.

Code such as the file, database and playlist 'menus' don't use the do_menu function, they instead use the gui_synclist set of functions. This set isn't exposed to the lua plugin unfortunately.

If you want to support more than 64 contacts, you'll need to either rework how you make your list, rework the RB menuing system, or expose the lower level gui_synclist* functions to the lua plugin.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing