feat: Add touch coordinate mapping and RTOS task yielding (#2481)
Co-authored-by: Julia Nguyen <julia@uxj.io>
This commit is contained in:
co-authored by
Julia Nguyen
parent
c9188a7347
commit
f42fab1c66
@@ -536,6 +536,35 @@ void KOReaderSyncActivity::loop() {
|
||||
}
|
||||
|
||||
if (state == SHOWING_RESULT) {
|
||||
auto chooseSelected = [this] {
|
||||
if (selectedOption == 0) {
|
||||
saveProgressAndReturn(remotePosition.spineIndex, remotePosition.pageNumber);
|
||||
} else if (selectedOption == 1) {
|
||||
performUpload();
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
const auto& metrics = UITheme::getInstance().getMetrics();
|
||||
const Rect screen = UITheme::getInstance().getScreenSafeArea(renderer, true, false);
|
||||
const int top = screen.y + metrics.topPadding + metrics.headerHeight + metrics.verticalSpacing;
|
||||
constexpr int optionHeight = 30;
|
||||
int touchedOption = -1;
|
||||
const auto touch = mappedInput.rowTouch(touchedOption, top + 230 - 2, optionHeight, 2);
|
||||
if (touch == MappedInputManager::RowTouch::Down) {
|
||||
if (selectedOption != touchedOption) {
|
||||
selectedOption = touchedOption;
|
||||
requestUpdate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (touch == MappedInputManager::RowTouch::Tap) {
|
||||
selectedOption = touchedOption;
|
||||
chooseSelected();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Navigate options
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Up) ||
|
||||
mappedInput.wasReleased(MappedInputManager::Button::Left)) {
|
||||
@@ -548,12 +577,7 @@ void KOReaderSyncActivity::loop() {
|
||||
}
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
||||
if (selectedOption == 0) {
|
||||
saveProgressAndReturn(remotePosition.spineIndex, remotePosition.pageNumber);
|
||||
} else if (selectedOption == 1) {
|
||||
// Upload local progress
|
||||
performUpload();
|
||||
}
|
||||
chooseSelected();
|
||||
}
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
||||
@@ -563,6 +587,21 @@ void KOReaderSyncActivity::loop() {
|
||||
}
|
||||
|
||||
if (state == NO_REMOTE_PROGRESS) {
|
||||
int tx = 0;
|
||||
int ty = 0;
|
||||
if (mappedInput.wasScreenTapped(tx, ty) && ty > renderer.getScreenHeight() / 3 &&
|
||||
ty < renderer.getScreenHeight() * 2 / 3) {
|
||||
if (documentHash.empty()) {
|
||||
if (KOREADER_STORE.getMatchMethod() == DocumentMatchMethod::FILENAME) {
|
||||
documentHash = KOReaderDocumentId::calculateFromFilename(epubPath);
|
||||
} else {
|
||||
documentHash = KOReaderDocumentId::calculate(epubPath);
|
||||
}
|
||||
}
|
||||
performUpload();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
||||
// Calculate hash if not done yet
|
||||
if (documentHash.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user