android: fix directory listing, keyboard show/hide and read chars

This commit is contained in:
2017-08-20 00:51:59 +01:00
parent a2b888efd6
commit 81a5fb10e3
6 changed files with 218 additions and 14 deletions

View File

@@ -66,6 +66,9 @@ public:
#if defined(__IOS__) && defined(__OBJC__)
GameViewController* ios_view;
#endif
#ifdef __ANDROID__
struct android_app* and_app;
#endif
void showKeyboard();
void hideKeyboard();

View File

@@ -1,6 +1,11 @@
#include "pch.h"
#include "app.h"
#ifdef __ANDROID__
void displayKeyboard(android_app* mApplication, bool pShow);
#endif
using namespace ui;
void App::resize(float w, float h)
@@ -14,17 +19,23 @@ void App::resize(float w, float h)
void App::showKeyboard()
{
LOG("show keyboard");
redraw = true;
#ifdef __IOS__
[ios_view becomeFirstResponder];
#elif __ANDROID__
displayKeyboard(and_app, true);
#endif
}
void App::hideKeyboard()
{
LOG("hide keyboard");
redraw = true;
#ifdef __IOS__
[ios_view resignFirstResponder];
#elif __ANDROID__
displayKeyboard(and_app, false);
#endif
}

View File

@@ -7,6 +7,7 @@
#endif
#ifdef __ANDROID__
#include <dirent.h>
AAssetManager* Asset::m_am;
#endif
@@ -49,7 +50,19 @@ std::vector<std::string> Asset::list_files(std::string folder, bool is_asset, co
}
else
{
DIR *dp;
struct dirent *ep;
dp = opendir(folder.c_str());
if (dp != NULL)
{
while ((ep = readdir(dp)))
if (ep->d_type != DT_DIR)
names.push_back(ep->d_name);
closedir(dp);
}
else
LOG("Couldn't open the directory: %s", folder.c_str());
}
#else
std::string abs_path = folder;

View File

@@ -44,7 +44,7 @@ void NodePanelBrush::init()
{
init_template("tpl-panel-brushes");
//m_layers_container = find<NodeBorder>("layers-container");
static auto icons = Asset::list_files("data/Icons/", true, ".*\\.png$");
static auto icons = Asset::list_files("data/Icons", true, ".*\\.png$");
if ((m_container = find<NodeBorder>("brushes")))
{