mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25:38 +00:00
(Android) Resources and themes are now only copied to internal storage after upgrades or for new installations
This commit is contained in:
parent
2bdad527de
commit
d87bb4e3a4
|
@ -719,10 +719,6 @@ int main(int argc, char* argv[])
|
||||||
renderer = Renderer::getInstance();
|
renderer = Renderer::getInstance();
|
||||||
window = Window::getInstance();
|
window = Window::getInstance();
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
|
||||||
Utils::Platform::Android::setupResources();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ViewController::getInstance()->setMenuColors();
|
ViewController::getInstance()->setMenuColors();
|
||||||
CollectionSystemsManager::getInstance();
|
CollectionSystemsManager::getInstance();
|
||||||
Screensaver screensaver;
|
Screensaver screensaver;
|
||||||
|
@ -740,6 +736,24 @@ int main(int argc, char* argv[])
|
||||||
LOG(LogDebug) << "Android storage state: " << SDL_AndroidGetExternalStorageState();
|
LOG(LogDebug) << "Android storage state: " << SDL_AndroidGetExternalStorageState();
|
||||||
LOG(LogDebug) << "Android internal path: " << SDL_AndroidGetInternalStoragePath();
|
LOG(LogDebug) << "Android internal path: " << SDL_AndroidGetInternalStoragePath();
|
||||||
LOG(LogDebug) << "Android external path: " << SDL_AndroidGetExternalStoragePath();
|
LOG(LogDebug) << "Android external path: " << SDL_AndroidGetExternalStoragePath();
|
||||||
|
Utils::Platform::Android::setDataDirectory();
|
||||||
|
{
|
||||||
|
std::string buildIdentifier {PROGRAM_VERSION_STRING};
|
||||||
|
buildIdentifier.append(" (r")
|
||||||
|
.append(std::to_string(PROGRAM_RELEASE_NUMBER))
|
||||||
|
.append("), built ")
|
||||||
|
.append(PROGRAM_BUILT_STRING);
|
||||||
|
if (Utils::Platform::Android::checkNeedResourceCopy(buildIdentifier)) {
|
||||||
|
LOG(LogInfo) << "Application has been updated or it's a new installation, copying "
|
||||||
|
"bundled resources and themes to internal storage...";
|
||||||
|
if (Settings::getInstance()->getBool("SplashScreen"))
|
||||||
|
window->renderSplashScreen(Window::SplashScreenState::RESOURCE_COPY, 0.0f);
|
||||||
|
if (Utils::Platform::Android::setupResources(buildIdentifier)) {
|
||||||
|
LOG(LogError) << "Copying of resources and themes failed";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(APPLICATION_UPDATER)
|
#if defined(APPLICATION_UPDATER)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
// EmulationStation Desktop Edition
|
// ES-DE Frontend
|
||||||
// Window.cpp
|
// Window.cpp
|
||||||
//
|
//
|
||||||
// Window management, screensaver management, help prompts and splash screen.
|
// Window management, screensaver management, help prompts and splash screen.
|
||||||
|
@ -144,6 +144,8 @@ bool Window::init()
|
||||||
mDefaultFonts.at(1)->buildTextCache("Loading systems...", 0.0f, 0.0f, 0x777777FF));
|
mDefaultFonts.at(1)->buildTextCache("Loading systems...", 0.0f, 0.0f, 0x777777FF));
|
||||||
mSplashTextReloading = std::unique_ptr<TextCache>(
|
mSplashTextReloading = std::unique_ptr<TextCache>(
|
||||||
mDefaultFonts.at(1)->buildTextCache("Reloading...", 0.0f, 0.0f, 0x777777FF));
|
mDefaultFonts.at(1)->buildTextCache("Reloading...", 0.0f, 0.0f, 0x777777FF));
|
||||||
|
mSplashTextResourceCopy = std::unique_ptr<TextCache>(
|
||||||
|
mDefaultFonts.at(1)->buildTextCache("Copying resources...", 0.0f, 0.0f, 0x777777FF));
|
||||||
|
|
||||||
mSplashTextPositions.x =
|
mSplashTextPositions.x =
|
||||||
(mRenderer->getScreenWidth() - mSplashTextScanning->metrics.size.x) / 2.0f;
|
(mRenderer->getScreenWidth() - mSplashTextScanning->metrics.size.x) / 2.0f;
|
||||||
|
@ -698,6 +700,9 @@ void Window::renderSplashScreen(SplashScreenState state, float progress)
|
||||||
textPosX = mSplashTextPositions.w;
|
textPosX = mSplashTextPositions.w;
|
||||||
textPosY += mDefaultFonts.at(1)->getLetterHeight();
|
textPosY += mDefaultFonts.at(1)->getLetterHeight();
|
||||||
}
|
}
|
||||||
|
else if (state == SplashScreenState::RESOURCE_COPY) {
|
||||||
|
textPosX = (mRenderer->getScreenWidth() - mSplashTextResourceCopy->metrics.size.x) / 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
trans = glm::translate(trans, glm::round(glm::vec3 {textPosX, textPosY, 0.0f}));
|
trans = glm::translate(trans, glm::round(glm::vec3 {textPosX, textPosY, 0.0f}));
|
||||||
mRenderer->setMatrix(trans);
|
mRenderer->setMatrix(trans);
|
||||||
|
@ -708,6 +713,8 @@ void Window::renderSplashScreen(SplashScreenState state, float progress)
|
||||||
mDefaultFonts.at(1)->renderTextCache(mSplashTextPopulating.get());
|
mDefaultFonts.at(1)->renderTextCache(mSplashTextPopulating.get());
|
||||||
else if (state == SplashScreenState::RELOADING)
|
else if (state == SplashScreenState::RELOADING)
|
||||||
mDefaultFonts.at(1)->renderTextCache(mSplashTextReloading.get());
|
mDefaultFonts.at(1)->renderTextCache(mSplashTextReloading.get());
|
||||||
|
else if (state == SplashScreenState::RESOURCE_COPY)
|
||||||
|
mDefaultFonts.at(1)->renderTextCache(mSplashTextResourceCopy.get());
|
||||||
|
|
||||||
mRenderer->swapBuffers();
|
mRenderer->swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
// EmulationStation Desktop Edition
|
// ES-DE Frontend
|
||||||
// Window.h
|
// Window.h
|
||||||
//
|
//
|
||||||
// Window management, screensaver management, help prompts and splash screen.
|
// Window management, screensaver management, help prompts and splash screen.
|
||||||
|
@ -109,7 +109,8 @@ public:
|
||||||
enum class SplashScreenState {
|
enum class SplashScreenState {
|
||||||
SCANNING,
|
SCANNING,
|
||||||
POPULATING,
|
POPULATING,
|
||||||
RELOADING
|
RELOADING,
|
||||||
|
RESOURCE_COPY
|
||||||
};
|
};
|
||||||
|
|
||||||
void renderSplashScreen(SplashScreenState state, float progress);
|
void renderSplashScreen(SplashScreenState state, float progress);
|
||||||
|
@ -188,6 +189,7 @@ private:
|
||||||
std::unique_ptr<TextCache> mSplashTextScanning;
|
std::unique_ptr<TextCache> mSplashTextScanning;
|
||||||
std::unique_ptr<TextCache> mSplashTextPopulating;
|
std::unique_ptr<TextCache> mSplashTextPopulating;
|
||||||
std::unique_ptr<TextCache> mSplashTextReloading;
|
std::unique_ptr<TextCache> mSplashTextReloading;
|
||||||
|
std::unique_ptr<TextCache> mSplashTextResourceCopy;
|
||||||
glm::vec4 mSplashTextPositions;
|
glm::vec4 mSplashTextPositions;
|
||||||
std::vector<ProgressBarRectangle> mProgressBarRectangles;
|
std::vector<ProgressBarRectangle> mProgressBarRectangles;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
// ES-DE
|
// ES-DE Frontend
|
||||||
// Platform.cpp
|
// Platform.cpp
|
||||||
//
|
//
|
||||||
// Platform utility functions.
|
// Platform utility functions.
|
||||||
|
@ -387,7 +387,7 @@ namespace Utils
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setupResources()
|
void setDataDirectory()
|
||||||
{
|
{
|
||||||
JNIEnv* jniEnv {reinterpret_cast<JNIEnv*>(SDL_AndroidGetJNIEnv())};
|
JNIEnv* jniEnv {reinterpret_cast<JNIEnv*>(SDL_AndroidGetJNIEnv())};
|
||||||
{
|
{
|
||||||
|
@ -401,12 +401,29 @@ namespace Utils
|
||||||
jniEnv->ReleaseStringUTFChars(dataDirectory, dataDirUtf);
|
jniEnv->ReleaseStringUTFChars(dataDirectory, dataDirUtf);
|
||||||
jniEnv->DeleteLocalRef(jniClass);
|
jniEnv->DeleteLocalRef(jniClass);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkNeedResourceCopy(const std::string& buildIdentifier)
|
||||||
|
{
|
||||||
|
JNIEnv* jniEnv {reinterpret_cast<JNIEnv*>(SDL_AndroidGetJNIEnv())};
|
||||||
|
jclass jniClass {jniEnv->FindClass("org/es_de/frontend/MainActivity")};
|
||||||
|
jmethodID methodID {jniEnv->GetStaticMethodID(jniClass, "checkNeedResourceCopy",
|
||||||
|
"(Ljava/lang/String;)Z")};
|
||||||
|
const bool returnValue {static_cast<bool>(jniEnv->CallStaticBooleanMethod(
|
||||||
|
jniClass, methodID, jniEnv->NewStringUTF(buildIdentifier.c_str())))};
|
||||||
|
jniEnv->DeleteLocalRef(jniClass);
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setupResources(const std::string& buildIdentifier)
|
||||||
|
{
|
||||||
|
JNIEnv* jniEnv {reinterpret_cast<JNIEnv*>(SDL_AndroidGetJNIEnv())};
|
||||||
{
|
{
|
||||||
jclass jniClass {jniEnv->FindClass("org/es_de/frontend/MainActivity")};
|
jclass jniClass {jniEnv->FindClass("org/es_de/frontend/MainActivity")};
|
||||||
jmethodID methodID {
|
jmethodID methodID {jniEnv->GetStaticMethodID(jniClass, "setupResources",
|
||||||
jniEnv->GetStaticMethodID(jniClass, "setupResources", "()Z")};
|
"(Ljava/lang/String;)Z")};
|
||||||
const bool returnValue {
|
const bool returnValue {static_cast<bool>(jniEnv->CallStaticBooleanMethod(
|
||||||
static_cast<bool>(jniEnv->CallStaticBooleanMethod(jniClass, methodID))};
|
jniClass, methodID, jniEnv->NewStringUTF(buildIdentifier.c_str())))};
|
||||||
jniEnv->DeleteLocalRef(jniClass);
|
jniEnv->DeleteLocalRef(jniClass);
|
||||||
if (returnValue) {
|
if (returnValue) {
|
||||||
LOG(LogError) << "Couldn't setup application resources on internal storage";
|
LOG(LogError) << "Couldn't setup application resources on internal storage";
|
||||||
|
@ -415,9 +432,10 @@ namespace Utils
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
jclass jniClass {jniEnv->FindClass("org/es_de/frontend/MainActivity")};
|
jclass jniClass {jniEnv->FindClass("org/es_de/frontend/MainActivity")};
|
||||||
jmethodID methodID {jniEnv->GetStaticMethodID(jniClass, "setupThemes", "()Z")};
|
jmethodID methodID {jniEnv->GetStaticMethodID(jniClass, "setupThemes",
|
||||||
const bool returnValue {
|
"(Ljava/lang/String;)Z")};
|
||||||
static_cast<bool>(jniEnv->CallStaticBooleanMethod(jniClass, methodID))};
|
const bool returnValue {static_cast<bool>(jniEnv->CallStaticBooleanMethod(
|
||||||
|
jniClass, methodID, jniEnv->NewStringUTF(buildIdentifier.c_str())))};
|
||||||
jniEnv->DeleteLocalRef(jniClass);
|
jniEnv->DeleteLocalRef(jniClass);
|
||||||
if (returnValue) {
|
if (returnValue) {
|
||||||
LOG(LogError) << "Couldn't setup application themes on internal storage";
|
LOG(LogError) << "Couldn't setup application themes on internal storage";
|
||||||
|
@ -436,7 +454,7 @@ namespace Utils
|
||||||
const bool returnValue {static_cast<bool>(jniEnv->CallStaticBooleanMethod(
|
const bool returnValue {static_cast<bool>(jniEnv->CallStaticBooleanMethod(
|
||||||
jniClass, methodID, jniEnv->NewStringUTF(packageName.c_str()),
|
jniClass, methodID, jniEnv->NewStringUTF(packageName.c_str()),
|
||||||
jniEnv->NewStringUTF(activity.c_str())))};
|
jniEnv->NewStringUTF(activity.c_str())))};
|
||||||
// jniEnv->DeleteLocalRef(jniClass);
|
jniEnv->DeleteLocalRef(jniClass);
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
// ES-DE
|
// ES-DE Frontend
|
||||||
// Platform.h
|
// Platform.h
|
||||||
//
|
//
|
||||||
// Platform utility functions.
|
// Platform utility functions.
|
||||||
|
@ -60,7 +60,9 @@ namespace Utils
|
||||||
namespace Android
|
namespace Android
|
||||||
{
|
{
|
||||||
bool requestStoragePermission();
|
bool requestStoragePermission();
|
||||||
bool setupResources();
|
void setDataDirectory();
|
||||||
|
bool checkNeedResourceCopy(const std::string& buildIdentifier);
|
||||||
|
bool setupResources(const std::string& buildIdentifier);
|
||||||
bool checkEmulatorInstalled(const std::string& packageName,
|
bool checkEmulatorInstalled(const std::string& packageName,
|
||||||
const std::string& activity);
|
const std::string& activity);
|
||||||
int launchGame(const std::string& packageName,
|
int launchGame(const std::string& packageName,
|
||||||
|
|
Loading…
Reference in a new issue