I've added a couple of features to OI Notepad that I wanted some
feedback on. I can commit these to svn if desired.
The first is a timestamp insertion. While editing a note, the user can
get a menu item "Insert timestamp" which inserts the give date & time at
the current point. I know that I would find this extremely useful; I
take a lot of notes in meetings using OI Notepad, and I usually want the
top line to read, "Meeting with joe about foo april 27, 2009".
The second feature is somewhat similar in that it inserts text at a
given point, but it does so by calling out to zxing. zxing is a QR Code
reader & generator. For those who don't know, QR codes are two
dimensional barcodes which encode a certain amount of data, including
plain text. With this feature, a user can scan a QR code, and the
scanned text will be inserted into the note at the given point. This
can be used to give someone a copy of a note, share bookmarks, contact
data, or to pass notes in class, for instance :)
I haven't added a "share note" feature, although that isn't hard. It
should probably be part of the "send" function?
I'm not positive about how good my "insert at point" function is. It
adds a string to the given point, but does so by adding it to the
database. I wanted to just add it to mText, but that didn't get updated
when returning from the QR code intent. Check out my function and let
me know how it looks.
If these features are of interest, I can commit my code and you can hack
at it directly :)
peace,
isaac
private void insertAtPoint (String textToInsert) {
String originalText = mText.getText().toString();
int insertPos = mText.getSelectionStart();
ContentValues values = new ContentValues();
StringBuffer sb = new StringBuffer(originalText);
sb.insert(insertPos, textToInsert);
// This stuff is only done when working with a full-fledged note.
if (!mNoteOnly) {
// Bump the modification time to now.
values.put(Notes.MODIFIED_DATE, System.currentTimeMillis());
String title = ExtractTitle.extractTitle(originalText);
values.put(Notes.TITLE, title);
}
// Write our text back into the provider.
String newNote = sb.toString();
values.put(Notes.NOTE, newNote);
// Commit all of our changes to persistent storage. When the
update completes
// the content provider will notify the cursor of the change,
which will
// cause the UI to be updated.
getContentResolver().update(mUri, values, null, null);
//ijones: notification doesn't seem to trigger for some reason :(
mText.setTextKeepState(newNote);
}
It uses zxing, an open source qr code generator. Called "Barcode
Scanner" in the market. (Does it all via intents.)
peace,
isaac
http://animate-innovations.com/?q=content/integrating-qr-codes-android-app-zxing
peace,
isaac