| 389 | } |
| 390 | |
| 391 | void KOReaderSyncActivity::loop() { |
| 392 | if (state == NO_CREDENTIALS || state == SYNC_FAILED || state == UPLOAD_COMPLETE) { |
| 393 | if (mappedInput.wasReleased(MappedInputManager::Button::Back)) { |
| 394 | returnToReader(); |
| 395 | } |
| 396 | return; |
| 397 | } |
| 398 | |
| 399 | if (state == SHOWING_RESULT) { |
| 400 | // Navigate options |
| 401 | if (mappedInput.wasReleased(MappedInputManager::Button::Up) || |
| 402 | mappedInput.wasReleased(MappedInputManager::Button::Left)) { |
| 403 | selectedOption = (selectedOption + 1) % 2; // Wrap around among 2 options |
| 404 | requestUpdate(); |
| 405 | } else if (mappedInput.wasReleased(MappedInputManager::Button::Down) || |
| 406 | mappedInput.wasReleased(MappedInputManager::Button::Right)) { |
| 407 | selectedOption = (selectedOption + 1) % 2; // Wrap around among 2 options |
| 408 | requestUpdate(); |
| 409 | } |
| 410 | |
| 411 | if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) { |
| 412 | if (selectedOption == 0) { |
| 413 | saveProgressAndReturn(remotePosition.spineIndex, remotePosition.pageNumber); |
| 414 | } else if (selectedOption == 1) { |
| 415 | // Upload local progress |
| 416 | performUpload(); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | if (mappedInput.wasReleased(MappedInputManager::Button::Back)) { |
| 421 | returnToReader(); |
| 422 | } |
| 423 | return; |
| 424 | } |
| 425 | |
| 426 | if (state == NO_REMOTE_PROGRESS) { |
| 427 | if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) { |
| 428 | // Calculate hash if not done yet |
| 429 | if (documentHash.empty()) { |
| 430 | if (KOREADER_STORE.getMatchMethod() == DocumentMatchMethod::FILENAME) { |
| 431 | documentHash = KOReaderDocumentId::calculateFromFilename(epubPath); |
| 432 | } else { |
| 433 | documentHash = KOReaderDocumentId::calculate(epubPath); |
| 434 | } |
| 435 | } |
| 436 | performUpload(); |
| 437 | } |
| 438 | |
| 439 | if (mappedInput.wasReleased(MappedInputManager::Button::Back)) { |
| 440 | returnToReader(); |
| 441 | } |
| 442 | return; |
| 443 | } |
| 444 | } |
nothing calls this directly
no test coverage detected