50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "../Activity.h"
|
|
#include "RecentBooksStore.h"
|
|
#include "util/ButtonNavigator.h"
|
|
|
|
class FileBrowserActivity final : public Activity {
|
|
public:
|
|
// Books = standard reader browser; PickFirmware = filter to .bin only and return path via ActivityResult.
|
|
enum class Mode { Books, PickFirmware };
|
|
|
|
private:
|
|
// Deletion
|
|
void clearFileMetadata(const std::string& fullPath);
|
|
|
|
ButtonNavigator buttonNavigator;
|
|
|
|
size_t selectorIndex = 0;
|
|
|
|
bool lockLongPressBack = false;
|
|
// True when this activity was entered while Confirm was already held; we must swallow the next
|
|
// release so we don't immediately auto-open the first entry.
|
|
bool lockNextConfirmRelease = false;
|
|
|
|
Mode mode = Mode::Books;
|
|
|
|
// Files state
|
|
std::string basepath = "/";
|
|
std::vector<std::string> files;
|
|
|
|
// Data loading
|
|
void loadFiles();
|
|
size_t findEntry(const std::string& name) const;
|
|
|
|
public:
|
|
explicit FileBrowserActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string initialPath = "/",
|
|
Mode mode = Mode::Books)
|
|
: Activity("FileBrowser", renderer, mappedInput),
|
|
mode(mode),
|
|
basepath(initialPath.empty() ? "/" : std::move(initialPath)) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
void render(RenderLock&&) override;
|
|
};
|