Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bookmark improvements #111

Closed
wants to merge 7 commits into from
Closed

Conversation

jsmitza
Copy link

@jsmitza jsmitza commented Mar 22, 2018

Hi, I love and-bible! I propose the following changes that will enhance the bookmark side with minimal GUI changes:

  1. Display date bookmark added in bookmark list. (Added TwoLine2TitleListItem for this)
  2. Display translation abbreviation in the bookmark list and show the text from that translation. (E.g. KJV and T4T)
  3. Let a long press on bookmark list (after a bookmark was selected) select all bookmarks from previous long press to current long press. Useful to quickly select many bookmark entries for delete or labeling.
  4. Show add bookmark button also if bookmark exist already. If selected the bookmark's date will be updated to the current time.

Note that the above require a change to the bookmark db table. In my tests it upgrades correctly (i.e. if you save bookmarks beforehand and then restore afterwards).

Regards
Jacques

jsmitza added 7 commits March 15, 2018 23:39
…on book name in the bookmark list. (Does not display corresponding translation yet)
… previous long click. (Can now quickly select multiple entries)
re-add. This will move bookmark up in date order list.
@tuomas2
Copy link
Contributor

tuomas2 commented Mar 28, 2018

It would be helpful if you added screenshot or two to demonstrate the new feature.

@jsmitza
Copy link
Author

jsmitza commented Mar 29, 2018

Good suggestion, see below:
image

Edit: Note that the only visual change in the 2nd screen (from before) is that BOTH the add and remove buttons are shown at the top if a bookmarked verse (with the star) is re-selected.

@jsmitza
Copy link
Author

jsmitza commented Mar 29, 2018

As to the motivation for this change - see this from my feature request:

Minimal bookmark enhancement to support verse journal

Background: I don't have time/will to type notes in the app, but a chronological list of the verses that stood out for me during Bible reading helps me to meditate for longer on them as I revisit the list. It helps me see patterns on what God is saying to me over time. And Bible supports this to some extent already through bookmarks (thank you!) but it needs improvement.

@ildar
Copy link

ildar commented Mar 29, 2018 via email

Copy link
Contributor

@tuomas2 tuomas2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea and suggest that this will be merged. Code looks OK and readable. There are some commented out code that needs to be cleaned up. See other small comments too.

(Please note that I'm not throughly familiar with the codebase but wanted to help with this code review. @mjdenham needs to check this too :) )

//
// // create DTO with all required info to display this Translation text
// retval.add(new TranslationDto(book, text, fontFile));
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget here some commented-out code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some books may need a special font to display. For now I do not cater for this in the bookmark list - not sure that it is necessary. Your input on this will be welcomed.

I copied the corresponding code from CompareTranslationsControl (where the font is supported), but commented it out with a explanatory comment at the start. This can be taken out/modified depending on the way we want to go.

@@ -78,10 +81,12 @@ public boolean toggleBookmarkForVerseRange(VerseRange verseRange) {
} else {
Dialogs.getInstance().showErrorMsg(R.string.error_occurred);
}
} else {
}
if ((bookmarkDto ==null) || (menuItemId == R.id.add_bookmark)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code style (space before null)

bookUsed = bookmark.getBookUsed();
} catch (Exception e) {
Log.e(TAG, "Error getting book used", e);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be more specific with exception. Or is there a proper reason for catching everything?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the pattern in other parts of the existing code (e.g in Bookmarks.java)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. This is considered generally bad habit but perhaps Martin has reason for this. At least error is logged properly.

//Book book = currentPageControl.getCurrentBible().getSwordDocumentFacade().getDocumentByInitials(abbrev);
Book book = currentBible.getSwordDocumentFacade().getDocumentByInitials(bookUsed);
if (book != null) {
verseText = swordContentFacade.getPlainText(book, bookmark.getConvertibleVerseRange().getVerseRange(((AbstractPassageBook) book).getVersification()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too long line, could you split? Also, readability could be improved by splitting some of this line into variables.


String bookUsed = bookmark.getBookUsed();
if ((bookUsed != null) && (!bookUsed.isEmpty()) && !bookUsed.equals(getCurrentBookUsed())) {
//Book book = currentPageControl.getCurrentBible().getSwordDocumentFacade().getDocumentByInitials(abbrev);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :-)

String bookUsed = bookmarkControl.getBookmarkBookUsed(item);
if (bookUsed != null && !bookUsed.isEmpty()) {
key += " " + bookUsed;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tabs and spaces mixed in the code. I think the codebase uses tabs and not spaces in indentation. Could you fix that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Check all other files that you have changed too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that though the codebase mostly use tabs as indents, it is not true everywhere (not my edits). If required I can change the indents for all the files I touched to be tabs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Perhaps @mjdenham can comment on this. If this is the case, all files should be checked at some point and changed such that they are consistently indented everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tended to use tabs, but I can't insist on it.

int iStart = lastPos < position ? lastPos : position;
int iEnd = lastPos < position ? position : lastPos;
for (int i = iStart; i <= iEnd; i++) {
getListView().setItemChecked(i,true);//isItemChecked(lastPos));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean up commented out code

@@ -165,7 +165,7 @@ public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
// if start verse already bookmarked then enable Delete Bookmark menu item else Add Bookmark
Verse startVerse = getStartVerse();
boolean isVerseBookmarked = startVerse!=null && bookmarkControl.isBookmarkForKey(startVerse);
menu.findItem(R.id.add_bookmark).setVisible(!isVerseBookmarked);
menu.findItem(R.id.add_bookmark).setVisible(true);//!isVerseBookmarked);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up commented out code

// final TypedArray a = context.obtainStyledAttributes(
// attrs, R.styleable.TwoLineListItem);
//
// a.recycle();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean up commented out code. And as everything is commented out here, remove redundant function and in above altenrative constructor signatures replace this( with super(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a copy of the code in TwoLineListItem; if I change this the original should also be changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, then I guess here you could perhaps inherit this new class from TwoLineListItem? And I think you could consider improving TwoLineListItem code too as I suggested.

@@ -12,6 +12,7 @@
import net.bible.android.control.page.CurrentBiblePage;
import net.bible.android.control.page.CurrentPageManager;
import net.bible.android.control.page.window.ActiveWindowPageManagerProvider;
import net.bible.android.control.versification.ConvertibleVerseRange;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused import

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsmitza thanks for this proposal and the ability to not only make a great suggestion but to also make the commitment to code a solution. For me this is one of the key missing features that currently prevent me from using And Bible. In reality it would be nice if there were separate features for "hilighting" and "bookmarking" but your idea is a fine proposal to at least let bookmarks function as hilights.

@mjdenham
Copy link
Contributor

Thanks for doing this. I love the idea of refreshing bookmarks.

Why do we need to save bookUsed? Bookmarks are not book specific.

@mjdenham
Copy link
Contributor

mjdenham commented Apr 13, 2018

Maybe you could split up the pull request into small parts. Maybe:

  1. refresh bookmarks
  2. show date
  3. there seems to be more but I can't quite make it out because there is too much

Parts 1. and 2. should be fairly small pull requests which I can understand and accept quite quickly.

@jsmitza
Copy link
Author

jsmitza commented Apr 13, 2018

Why bookUsed: If you use different translations, you want to see your bookmark in the specific translation/language that you used to bookmark the verse. I read different translations (English, Afrikaans, T4T, etc) and often the specific wording in a specific translation is the one that touches my heart. When I review my bookmarks I want to see each bookmarked verse in the list in the translation that was used. See the screenshot at the beginning as an example. So bookUsed need to be saved.

@jsmitza
Copy link
Author

jsmitza commented Apr 13, 2018

Splitting Up: I am willing to do this, but it may not be soon, as I now have to work overtime for a month or so to make a deadline. (Which is why I am also slow to comment).

Note that the 4 items listed at the top are the only changes done. Part 2 might actually be more intrusive because it needs the database change.

@mjdenham
Copy link
Contributor

Unfortunately making bookmarks book specific would not be something I would easily embrace. There are advantages to the bookmarks following whichever translation you are using.

@mjdenham
Copy link
Contributor

Take plenty of time - I do!

@jsmitza
Copy link
Author

jsmitza commented Apr 14, 2018

What if
a) I make this an administration setting that you can turn on or off (and the default could be off as in the past): If turned on, bookmarks will show the corresponding translation and jump there if selected. If turned off it will not show the translation and follow the current translation. (Note that my changes will already show the bookmark in the current translation if no book was specified (or if it could not be found)). OR
b) We just add another button at the top of the bookmark list that toggle between the two modes mentioned in a)

Would this cover your reservations? I think b) is the best, but then I need an icon :-) It really is a dealbreaker for me to be able to see the actual history of my past encounters with God. (Often the specific wording of one translation can stand out for me, and I miss out on this if a single translation is used in the list). This is why I took the time to do the work. If you will embrace it if I add a) or b), then I plan to do the extra work.

@mjdenham
Copy link
Contributor

I don't want to rush this in. I am not sure about it myself and don't like adding unnecessary complexity into the ui and the code.

You could start a thread to discuss this functionality in the And Bible discussion forum if you like.

@jsmitza
Copy link
Author

jsmitza commented Apr 15, 2018

Ok, I decided to spend a week-end day to try and split up as Martin suggested. Hope I do this right! I added 5 branches, one for each feature. They can be selected/merged individually as needed.

  1. bookmark-showdate: Shows the date a bookmark was added in the bookmark list.
  2. bookmark-update-date: Allows refreshing of an existing bookmark's date to current time by adding the selected verse again.
  3. bookmark-select-many: Allows quick selection of many bookmarks in a list for labeling or deletion. Two long-presses will select all bookmarks between them.
  4. bookgrid-underline-cur: Improve the highlight of the current book or chapter in the selection grid by underlining the name/chapter. (Why: Difficult to see current item otherwise, and it helps to quickly find the current book if you just want to change the chapter.)
  5. bookmarklist-show-books-used: Add show-translation button at top of bookmark list (icon should probably be changed). Toggles between showing bookmarks in current translation, or each one in the original translation where it was bookmarked. Note that this change also involves a database upgrade (done automatically) as we now also need to save the book used by a bookmark.

I hope the above facilitates quicker trying/acceptance of some (if not all) of the changes.

@tuomas2
Copy link
Contributor

tuomas2 commented Apr 15, 2018

@jsmitza Can you create a new pull request out of each branch and then close this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants