Own Android storage paths in legacy platform services
This commit is contained in:
@@ -135,15 +135,6 @@ void execute_legacy_app_init_log(App& app)
|
||||
|
||||
// TODO: save this path somewhere in the settings, don't overwrite every start
|
||||
app.work_path = paths.work_path.empty() ? app.data_path : paths.work_path;
|
||||
#ifdef __ANDROID__
|
||||
pp::platform::legacy::set_legacy_android_storage_paths({
|
||||
app.data_path,
|
||||
app.work_path,
|
||||
app.rec_path,
|
||||
app.tmp_path,
|
||||
});
|
||||
#endif
|
||||
|
||||
//LogRemote::I.start();
|
||||
LogRemote::I.file_init();
|
||||
LOG("%s", g_version);
|
||||
|
||||
@@ -48,8 +48,11 @@ namespace {
|
||||
// DEBT-0017: fallback for platforms that do not inject PlatformServices yet.
|
||||
class LegacyPlatformServices final : public pp::platform::PlatformServices {
|
||||
public:
|
||||
explicit LegacyPlatformServices(pp::platform::legacy::LegacyGlfwPlatformShell glfw_shell = {})
|
||||
: glfw_shell_(std::move(glfw_shell))
|
||||
explicit LegacyPlatformServices(pp::platform::legacy::LegacyPlatformServicesConfig config = {})
|
||||
: glfw_shell_(std::move(config.glfw_shell))
|
||||
#ifdef __ANDROID__
|
||||
, android_storage_paths_(std::move(config.android_storage_paths))
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@@ -89,7 +92,7 @@ public:
|
||||
{},
|
||||
};
|
||||
#elif defined(__ANDROID__)
|
||||
return pp::platform::legacy::active_legacy_android_storage_paths();
|
||||
return android_storage_paths_ ? *android_storage_paths_ : pp::platform::PlatformStoragePaths {};
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
@@ -559,6 +562,9 @@ private:
|
||||
}
|
||||
|
||||
pp::platform::legacy::LegacyGlfwPlatformShell glfw_shell_;
|
||||
#ifdef __ANDROID__
|
||||
std::shared_ptr<pp::platform::PlatformStoragePaths> android_storage_paths_;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
@@ -572,8 +578,8 @@ PlatformServices& platform_services()
|
||||
}
|
||||
|
||||
std::unique_ptr<PlatformServices> create_platform_services(
|
||||
LegacyGlfwPlatformShell glfw_shell)
|
||||
LegacyPlatformServicesConfig config)
|
||||
{
|
||||
return std::make_unique<LegacyPlatformServices>(std::move(glfw_shell));
|
||||
return std::make_unique<LegacyPlatformServices>(std::move(config));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,13 @@ struct LegacyGlfwPlatformShell {
|
||||
std::function<void()> request_app_close;
|
||||
};
|
||||
|
||||
struct LegacyPlatformServicesConfig {
|
||||
LegacyGlfwPlatformShell glfw_shell;
|
||||
std::shared_ptr<pp::platform::PlatformStoragePaths> android_storage_paths;
|
||||
};
|
||||
|
||||
[[nodiscard]] PlatformServices& platform_services();
|
||||
[[nodiscard]] std::unique_ptr<PlatformServices> create_platform_services(
|
||||
LegacyGlfwPlatformShell glfw_shell = {});
|
||||
LegacyPlatformServicesConfig config = {});
|
||||
|
||||
}
|
||||
|
||||
@@ -11,20 +11,6 @@ void webgl_sync();
|
||||
namespace pp::platform::legacy {
|
||||
namespace {
|
||||
|
||||
#ifdef __ANDROID__
|
||||
struct RetainedLegacyAndroidStoragePaths final {
|
||||
pp::platform::PlatformStoragePaths storage_paths;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
[[nodiscard]] RetainedLegacyAndroidStoragePaths& retained_legacy_android_storage_paths()
|
||||
{
|
||||
static RetainedLegacyAndroidStoragePaths state;
|
||||
return state;
|
||||
}
|
||||
#endif
|
||||
|
||||
class RetainedWebPlatformServices final : public pp::platform::WebPlatformServices {
|
||||
public:
|
||||
void publish_exported_image(std::string_view path) override
|
||||
@@ -150,16 +136,4 @@ void save_legacy_web_prepared_file(
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_android_storage_paths()
|
||||
{
|
||||
return retained_legacy_android_storage_paths().storage_paths;
|
||||
}
|
||||
|
||||
void set_legacy_android_storage_paths(pp::platform::PlatformStoragePaths paths)
|
||||
{
|
||||
retained_legacy_android_storage_paths().storage_paths = std::move(paths);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -31,9 +31,4 @@ void save_legacy_web_prepared_file(
|
||||
std::string_view suggested_name,
|
||||
pp::platform::PreparedFileCallback callback);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_android_storage_paths();
|
||||
void set_legacy_android_storage_paths(pp::platform::PlatformStoragePaths paths);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user