Merge lp:~j-4-deactivatedaccount/tomdroid/bugfix-800176 into lp:~tomdroid-maintainers/tomdroid/main

Proposed by Stefan Hammer
Status: Merged
Approved by: Olivier Bilodeau
Approved revision: 236
Merged at revision: 239
Proposed branch: lp:~j-4-deactivatedaccount/tomdroid/bugfix-800176
Merge into: lp:~tomdroid-maintainers/tomdroid/main
Diff against target: 73 lines (+17/-15)
3 files modified
src/org/tomdroid/Note.java (+11/-0)
src/org/tomdroid/ui/ViewNote.java (+1/-8)
src/org/tomdroid/util/Send.java (+5/-7)
To merge this branch: bzr merge lp:~j-4-deactivatedaccount/tomdroid/bugfix-800176
Reviewer Review Type Date Requested Status
Olivier Bilodeau Approve
Stefan Hammer (community) Needs Resubmitting
Review via email: mp+67458@code.launchpad.net

Description of the change

Fix critical Bug #800176.

To post a comment you must log in.
Revision history for this message
Stefan Hammer (j-4-deactivatedaccount) wrote :

I just realised, that my fix is rather quick and dirty than good.
In ViewNote.java -> showNote() there is a block of code, which does exactly the same.
I could also move this code to Note.java and just call the new method from Send() and showNote().

Maybe we should remove the title from the noteContent string at all in Note.java -> getNoteContent(). Is the title important in the content? This would save a lot of dirty workarounds to get rid of the title.

Revision history for this message
Olivier Bilodeau (plaxx) wrote :

> Maybe we should remove the title from the noteContent string at all in Note.java -> getNoteContent(). Is the title important in the content? This would save a lot of dirty workarounds to get rid of the title.

Yes, try that and lets see the patch. Try to keep the cleaner title removal technique or maybe even push that into the xml parser..

233. By Stefan Hammer

Merged with lp:tomdroid

234. By Stefan Hammer

Moved Title-remover in Note class and called it from Send and ViewNote

Revision history for this message
Stefan Hammer (j-4-deactivatedaccount) wrote :

Thanks for reviewing the other stuff! I'll try to keep things more consistent.
I changed the bugfix now. I couldn't push the code into the xml parser - no idea how this should work. But i wrote a function in the Note class and called it from ViewNote and Send.

PS: I wrote the news file and found a misunderstanding. I haven't integrated the search system wide atm, because therefore i would have to remove the search history again and call notes as search suggestions. I don't know which way is better. Maybe i will write both with an option in preferences later.

Ready for review again!

review: Needs Resubmitting
Revision history for this message
Stefan Hammer (j-4-deactivatedaccount) wrote :

oh.. Tomdroid really appears in the system wide search. didn't realize this :-D
It just doesn't bring up search results while typing. one has to select Tomdroid specifically.
Awesome. Sorry for the confusion!

235. By Stefan Hammer

Also included the improved feature graphic to get it into the master.

236. By Stefan Hammer

removed unneccesary change.

Revision history for this message
Olivier Bilodeau (plaxx) wrote :

I made some changes in the merge: it's not the caller's job to strip the title. It would be too easy to forget in the future. Instead, the title stripping is done when we assign the XML note-content to a note instead.

review: Approve
Revision history for this message
Stefan Hammer (j-4-deactivatedaccount) wrote :

Hi! Thanks for checking my work. I wasn't sure at all where to put it. I updated the master branch now and realized, that the title is not cropped when viewing the note and also when sending it. Is this on purpose?

Revision history for this message
Olivier Bilodeau (plaxx) wrote :

I found an important problem in the note-content tag stripping code when in SD Card sync that could cause the title from not stripping. I fixed it this afternoon (EDT) at revno 245: http://bazaar.launchpad.net/~tomdroid-maintainers/tomdroid/main/revision/245

Also, because this bug is on initial SD card sync, someone affected will already have the <note-content...> tag in its database (as opposed to Web sync users) and so a database delete / re-sync is required.

I'm not doing any work-arounds to parse an affected user nor am I writing a database upgrade-script because I lack the time and since we are read-only an uninstall / re-sync from SD is pretty painless and lossless. Also, most users won't even notice the difference and new notes will be parsed correctly.

Let me know if you still see the titles, you shouldn't.

Revision history for this message
Stefan Hammer (j-4-deactivatedaccount) wrote :

Thanks for the information. I deleted all the user data and now the titles are gone.
I also think, thats not worth the effort to write a workaround for this. In the worst case, the title is displayed... what the heck!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/Feature_Graphic.png'
2Binary files data/Feature_Graphic.png 2011-07-10 19:47:32 +0000 and data/Feature_Graphic.png 2011-09-05 10:27:32 +0000 differ
3=== modified file 'data/Feature_Graphic.xcf'
4Binary files data/Feature_Graphic.xcf 2011-07-10 19:47:32 +0000 and data/Feature_Graphic.xcf 2011-09-05 10:27:32 +0000 differ
5=== modified file 'src/org/tomdroid/Note.java'
6--- src/org/tomdroid/Note.java 2010-10-14 03:51:26 +0000
7+++ src/org/tomdroid/Note.java 2011-09-05 10:27:32 +0000
8@@ -28,6 +28,7 @@
9
10 import org.json.JSONArray;
11 import org.json.JSONObject;
12+import org.tomdroid.ui.Tomdroid;
13 import org.tomdroid.util.NoteContentBuilder;
14 import org.tomdroid.util.XmlUtils;
15
16@@ -192,4 +193,14 @@
17 return new String("Note: "+ getTitle() + " (" + getLastChangeDate() + ")");
18 }
19
20+ public void removeTitle(SpannableStringBuilder noteContent) {
21+ // get rid of the title that is doubled in the note's content
22+ // using quote to escape potential regexp chars in pattern
23+ Pattern removeTitle = Pattern.compile("^\\s*"+Pattern.quote(getTitle())+"\\n\\n");
24+ Matcher m = removeTitle.matcher(noteContent);
25+ if (m.find()) {
26+ noteContent = noteContent.replace(0, m.end(), "");
27+ if (Tomdroid.LOGGING_ENABLED) Log.d(TAG, "stripped the title from note-content");
28+ }
29+ }
30 }
31
32=== modified file 'src/org/tomdroid/ui/ViewNote.java'
33--- src/org/tomdroid/ui/ViewNote.java 2011-09-04 15:30:54 +0000
34+++ src/org/tomdroid/ui/ViewNote.java 2011-09-05 10:27:32 +0000
35@@ -169,14 +169,7 @@
36 private void showNote() {
37 //setTitle(note.getTitle());
38
39- // get rid of the title that is doubled in the note's content
40- // using quote to escape potential regexp chars in pattern
41- Pattern removeTitle = Pattern.compile("^\\s*"+Pattern.quote(note.getTitle())+"\\n\\n");
42- Matcher m = removeTitle.matcher(noteContent);
43- if (m.find()) {
44- noteContent = noteContent.replace(0, m.end(), "");
45- if (Tomdroid.LOGGING_ENABLED) Log.d(TAG, "stripped the title from note-content");
46- }
47+ note.removeTitle(noteContent);
48
49 // show the note (spannable makes the TextView able to output styled text)
50 content.setText(noteContent, TextView.BufferType.SPANNABLE);
51
52=== modified file 'src/org/tomdroid/util/Send.java'
53--- src/org/tomdroid/util/Send.java 2011-01-15 22:25:39 +0000
54+++ src/org/tomdroid/util/Send.java 2011-09-05 10:27:32 +0000
55@@ -35,13 +35,11 @@
56
57 //parsed ok - show
58 if(msg.what == NoteContentBuilder.PARSE_OK) {
59- String body = "";
60-
61- //remove title from content
62- if (noteContent.toString() != "") {
63- body = noteContent.toString().substring(note.getTitle().length()+2);
64- }
65-
66+
67+ note.removeTitle(noteContent);
68+
69+ String body = noteContent.toString();
70+
71 // Create a new Intent to send messages
72 Intent sendIntent = new Intent(Intent.ACTION_SEND);
73 // Add attributes to the intent

Subscribers

People subscribed via source and target branches