Some fixes
This commit is contained in:
@@ -905,23 +905,27 @@ void TxtReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
|
||||
case BA::BTN_PAGE_FORWARD:
|
||||
if (currentPage < totalPages - 1) {
|
||||
currentPage++;
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
}
|
||||
break;
|
||||
case BA::BTN_PAGE_BACK:
|
||||
if (currentPage > 0) {
|
||||
currentPage--;
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
}
|
||||
break;
|
||||
case BA::BTN_PAGE_FORWARD_10:
|
||||
currentPage += 10;
|
||||
clampPage();
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
break;
|
||||
case BA::BTN_PAGE_BACK_10:
|
||||
currentPage -= 10;
|
||||
clampPage();
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
break;
|
||||
case BA::BTN_STAR_PAGE:
|
||||
|
||||
@@ -523,21 +523,25 @@ void XtcReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
|
||||
case BA::BTN_PAGE_FORWARD:
|
||||
if (currentPage + 1 < pageCount) {
|
||||
currentPage++;
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
}
|
||||
break;
|
||||
case BA::BTN_PAGE_BACK:
|
||||
if (currentPage > 0) {
|
||||
currentPage--;
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
}
|
||||
break;
|
||||
case BA::BTN_PAGE_FORWARD_10:
|
||||
currentPage = (currentPage + 10 < pageCount) ? currentPage + 10 : pageCount - 1;
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
break;
|
||||
case BA::BTN_PAGE_BACK_10:
|
||||
currentPage = (currentPage >= 10) ? currentPage - 10 : 0;
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
break;
|
||||
case BA::BTN_NEXT_SECTION:
|
||||
@@ -547,6 +551,7 @@ void XtcReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
|
||||
[this](const auto& ch) { return ch.startPage > currentPage; });
|
||||
if (it != chapters.end()) {
|
||||
currentPage = it->startPage;
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
}
|
||||
}
|
||||
@@ -559,6 +564,7 @@ void XtcReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
|
||||
|
||||
if (prevChapter != chapters.rend()) {
|
||||
currentPage = prevChapter->startPage;
|
||||
globalReadingSessionTracker().onPageTurn();
|
||||
requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
#include <Arduino.h> // millis()
|
||||
#include <GfxRenderer.h>
|
||||
#include <I18n.h>
|
||||
#include <Utf8.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -178,7 +180,8 @@ void ReadingStatsActivity::render(RenderLock&&) {
|
||||
if (!store.getBooks().empty()) {
|
||||
std::vector<const BookReadingStats*> sorted;
|
||||
sorted.reserve(store.getBooks().size());
|
||||
for (const auto& b : store.getBooks()) sorted.push_back(&b);
|
||||
std::transform(store.getBooks().begin(), store.getBooks().end(), std::back_inserter(sorted),
|
||||
[](const BookReadingStats& b) { return &b; });
|
||||
std::sort(sorted.begin(), sorted.end(),
|
||||
[](const BookReadingStats* a, const BookReadingStats* b) { return a->totalSeconds > b->totalSeconds; });
|
||||
|
||||
@@ -199,7 +202,7 @@ void ReadingStatsActivity::render(RenderLock&&) {
|
||||
if (maxLabelWidth > 0 && renderer.getTextWidth(UI_10_FONT_ID, label.c_str()) > maxLabelWidth) {
|
||||
while (!label.empty() &&
|
||||
renderer.getTextWidth(UI_10_FONT_ID, label.c_str()) + ellipsisWidth > maxLabelWidth) {
|
||||
label.pop_back();
|
||||
utf8RemoveLastChar(label);
|
||||
}
|
||||
label += "…";
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <GfxRenderer.h>
|
||||
#include <HalClock.h>
|
||||
#include <I18n.h>
|
||||
#include <Utf8.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -107,9 +108,19 @@ void ReadingStatsBookDetailActivity::render(RenderLock&&) {
|
||||
// Header — title (truncated) and author. Title fallback to docId so we
|
||||
// still produce a usable screen if the book's metadata was never recorded.
|
||||
std::string headerTitle = (book && !book->title.empty()) ? book->title : docId;
|
||||
if (headerTitle.size() > 28) {
|
||||
headerTitle.resize(28);
|
||||
headerTitle += "…";
|
||||
{
|
||||
constexpr size_t kMaxChars = 28;
|
||||
const auto* p = reinterpret_cast<const unsigned char*>(headerTitle.c_str());
|
||||
const auto* start = p;
|
||||
size_t chars = 0;
|
||||
while (*p != 0 && chars < kMaxChars) {
|
||||
utf8NextCodepoint(&p);
|
||||
++chars;
|
||||
}
|
||||
if (*p != 0) {
|
||||
headerTitle.resize(static_cast<size_t>(p - start));
|
||||
headerTitle += "…";
|
||||
}
|
||||
}
|
||||
GUI.drawHeader(renderer,
|
||||
Rect{contentRect.x, contentRect.y + metrics.topPadding, contentRect.width, metrics.headerHeight},
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iterator>
|
||||
|
||||
#include "MappedInputManager.h"
|
||||
#include "ReadingStatsBookDetailActivity.h"
|
||||
@@ -35,9 +36,9 @@ std::string formatDuration(uint32_t totalSeconds) {
|
||||
|
||||
void ReadingStatsBookListActivity::rebuildSortedBooks() {
|
||||
sortedBooks.clear();
|
||||
for (const auto& b : READING_STATS.getBooks()) {
|
||||
sortedBooks.push_back(&b);
|
||||
}
|
||||
sortedBooks.reserve(READING_STATS.getBooks().size());
|
||||
std::transform(READING_STATS.getBooks().begin(), READING_STATS.getBooks().end(), std::back_inserter(sortedBooks),
|
||||
[](const BookReadingStats& b) { return &b; });
|
||||
std::sort(sortedBooks.begin(), sortedBooks.end(),
|
||||
[](const BookReadingStats* a, const BookReadingStats* b) { return a->totalSeconds > b->totalSeconds; });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user