Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PRODUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ why and does nothing. The KFX to EPUB converter is its own code.
HTML and no browser: the `web` value under Platform only means that it does not
follow the iOS or Android guidelines.
- Book states: with DRM, unlocked, converted.
- The real title is only known once the book is unlocked; until then its ASIN is
shown.
- A book's title comes from the Kindle app's catalog, or from the book once unlocked;
a locked book with no title in the catalog shows its ASIN.
- Converts text books. Comics, fixed layout and dictionaries are out of scope.
- The interface is in English by default and also available in Spanish.
- Light and dark theme: it follows the system or the user sets it.
Expand Down
4 changes: 2 additions & 2 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ cualquier otro programa.

1. **Descarga tus libros** en la app de Kindle, como siempre.
2. **Abre Anzu.** Encuentra la app de Kindle y pone tus libros en estantes según lo que
les falta: por desbloquear, listos para EPUB o ya en EPUB. Hasta que un libro se
desbloquea ves un código en lugar del título; el título real aparece al desbloquearlo.
les falta: por desbloquear, listos para EPUB o ya en EPUB. Cada libro muestra el
título que tiene en la app de Kindle; si allí no lo tiene, ves su código hasta desbloquearlo.
3. **Marca los libros que quieras.** El panel lateral los lista con lo que se hará con
cada uno. Elige la carpeta donde irán los EPUB
(`Documents\EPUB` por defecto).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ say so. To remove it, uninstall Anzu from Settings › Apps like any other progr

1. **Download your books** in the Kindle app, as you normally do.
2. **Open Anzu.** It finds the Kindle app and puts your books on shelves by what they still
need: to unlock, ready for EPUB, or already in EPUB. Until a book is unlocked
you see a code instead of its title; the real title appears once it is unlocked.
need: to unlock, ready for EPUB, or already in EPUB. Each book shows the title
the Kindle app has for it; one without a title there shows its code until it is unlocked.
3. **Tick the books you want.** The side panel lists them with what will be done to each.
Choose the folder where the EPUB files will go
(`Documents\EPUB` by default).
Expand Down
7 changes: 4 additions & 3 deletions crates/anzu/src/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ impl DemoSystem {
.filter(|b| b.downloaded)
.map(|b| Book {
asin: b.asin.to_string(),
// The real title is only known once the book is unlocked.
title: (b.state != BookState::Locked).then(|| b.title.to_string()),
// As in the app, which reads it from the Kindle app's catalog: the title is
// known before the book is unlocked.
title: Some(b.title.to_string()),
source: Path::new(CONTENT_DIR).join(format!("{}_EBOK", b.asin)).join(format!("{}_EBOK.azw", b.asin)),
size: b.size,
state: b.state,
Expand Down Expand Up @@ -229,7 +230,7 @@ mod tests {
system.download_all();
let books = system.scan();
assert_eq!(books.len(), 3);
assert!(books.iter().filter(|b| b.state == BookState::Locked).all(|b| b.title.is_none()));
assert!(books.iter().all(|b| b.title.is_some()));
}

#[test]
Expand Down
12 changes: 6 additions & 6 deletions crates/anzu/src/ui/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ mod tests {
/// As in the app, a book's real title appears only once the run has finished and the
/// window reads the library again, never ahead of what has been shown.
#[test]
fn titles_appear_when_the_run_is_shown_finished() {
fn books_show_their_titles_before_and_after_the_run() {
use eframe::App;
let ctx = egui::Context::default();
super::super::theme::install(&ctx);
Expand All @@ -461,12 +461,12 @@ mod tests {
app.ui(ui, &mut frame);
});
output.textures_delta.clear();
let titled = app.books.iter().filter(|b| b.title.is_some()).count();
if app.run.result.is_none() {
assert_eq!(titled, 1, "only Walden has a title before the run ends (frame {n})");
} else {
// As in the app, which reads titles from the Kindle catalog: every book shows its
// title, locked or not.
assert!(app.books.iter().all(|b| b.title.is_some()), "a book without its title (frame {n})");
if app.run.result.is_some() {
seen_finished = true;
assert_eq!(titled, 3);
assert_eq!(app.books.len(), 3);
}
}
assert!(seen_finished);
Expand Down
20 changes: 13 additions & 7 deletions crates/anzu/src/ui/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const SHELVES: [BookState; 3] = [BookState::Locked, BookState::Unlocked, BookSta
struct Row {
asin: String,
title: String,
/// Whether the title is the book's own, from the Kindle catalog or the unlocked book,
/// rather than a fallback made from the ASIN.
named: bool,
size: u64,
state: BookState,
}
Expand Down Expand Up @@ -315,7 +318,7 @@ fn shelves(app: &mut AnzuApp, ui: &mut egui::Ui, p: theme::Palette, t: &Strings)
.books
.iter()
.filter(|b| b.state == state)
.map(|b| Row { asin: b.asin.clone(), title: AnzuApp::display_title(b, t), size: b.size, state: b.state })
.map(|b| Row { asin: b.asin.clone(), title: AnzuApp::display_title(b, t), named: b.title.is_some(), size: b.size, state: b.state })
.collect();
if rows.is_empty() {
continue;
Expand Down Expand Up @@ -451,11 +454,14 @@ fn card(app: &mut AnzuApp, ui: &mut egui::Ui, p: theme::Palette, t: &Strings, ro
let text_left = cover.right() + 12.0;
let text_width = check.left() - 10.0 - text_left;
let title_color = dim(if row.state == BookState::Locked { p.muted } else { p.fg });
let title = if row.state == BookState::Locked { row.asin.clone() } else { row.title.clone() };
// A locked book whose title is not known yet shows its ASIN until it is unlocked.
let unnamed = row.state == BookState::Locked && !row.named;
let title = if unnamed { row.asin.clone() } else { row.title.clone() };
let title = elided(&painter, &title, theme::bold_font(14.0), title_color, text_width);
let detail = match row.state {
BookState::Locked => format!("{} · {}", t.human_size(row.size), t.title_after_unlock),
_ => format!("{} · {}", row.asin, t.human_size(row.size)),
let detail = if unnamed {
format!("{} · {}", t.human_size(row.size), t.title_after_unlock)
} else {
format!("{} · {}", row.asin, t.human_size(row.size))
};
let detail = elided(&painter, &detail, theme::regular_font(12.0), dim(p.muted), text_width);
let top = rect.center().y - (title.size().y + 3.0 + detail.size().y) / 2.0;
Expand Down Expand Up @@ -567,7 +573,7 @@ fn chosen_list(app: &AnzuApp, ui: &mut egui::Ui, p: theme::Palette, t: &Strings)
painter.rect_filled(dot, 3, icons::state_fill(book.state));
let what = painter.layout_no_wrap(what.to_string(), theme::regular_font(12.0), p.muted);
let what_left = rect.right() - what.size().x;
let name = if book.state == BookState::Locked { book.asin.clone() } else { AnzuApp::display_title(book, t) };
let name = if book.state == BookState::Locked && book.title.is_none() { book.asin.clone() } else { AnzuApp::display_title(book, t) };
let name = elided(painter, &name, theme::regular_font(13.0), p.fg, what_left - 10.0 - (rect.left() + 18.0));
painter.galley(Pos2::new(rect.left() + 18.0, rect.center().y - name.size().y / 2.0), name, p.fg);
painter.galley(Pos2::new(what_left, rect.center().y - what.size().y / 2.0), what, p.muted);
Expand Down Expand Up @@ -633,7 +639,7 @@ mod tests {
use super::*;

fn row(asin: &str, title: &str, size: u64, state: BookState) -> Row {
Row { asin: asin.into(), title: title.into(), size, state }
Row { asin: asin.into(), title: title.into(), named: true, size, state }
}

fn sample() -> Vec<Row> {
Expand Down
Loading