android save picker, create dir api wip
This commit is contained in:
@@ -111,6 +111,8 @@ add_library(
|
|||||||
../../src/binary_stream.cpp
|
../../src/binary_stream.cpp
|
||||||
../../src/serializer.cpp
|
../../src/serializer.cpp
|
||||||
../../src/settings.cpp
|
../../src/settings.cpp
|
||||||
|
../../src/node_input_box.cpp
|
||||||
|
../../src/node_dialog_export_ppbr.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(native-lib PRIVATE
|
target_include_directories(native-lib PRIVATE
|
||||||
|
|||||||
@@ -296,6 +296,14 @@ void android_pick_file(std::function<void(std::string)> callback)
|
|||||||
jni->CallVoidMethod(g_engine.app->activity->clazz, method);
|
jni->CallVoidMethod(g_engine.app->activity->clazz, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void android_pick_file_save(std::function<void(std::string)> callback)
|
||||||
|
{
|
||||||
|
pick_file_callback = callback;
|
||||||
|
jclass clazz = jni->GetObjectClass(g_engine.app->activity->clazz);
|
||||||
|
jmethodID method = jni->GetMethodID(clazz, "pickFileSave", "()V");
|
||||||
|
jni->CallVoidMethod(g_engine.app->activity->clazz, method);
|
||||||
|
}
|
||||||
|
|
||||||
float get_display_density()
|
float get_display_density()
|
||||||
{
|
{
|
||||||
jclass clazz = jni->GetObjectClass(g_engine.app->activity->clazz);
|
jclass clazz = jni->GetObjectClass(g_engine.app->activity->clazz);
|
||||||
@@ -366,6 +374,17 @@ bool android_set_clipboard(const std::string& s)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool android_create_dir(const std::string& path)
|
||||||
|
{
|
||||||
|
jclass clazz = jni->GetObjectClass(g_engine.app->activity->clazz);
|
||||||
|
jmethodID method = jni->GetMethodID(clazz, "createDir", "(Ljava/lang/String;)Z");
|
||||||
|
jstring js = JniStringFromUTF8(path);
|
||||||
|
if (!js) return false;
|
||||||
|
jboolean success = jni->CallBooleanMethod(g_engine.app->activity->clazz, method, js);
|
||||||
|
jni->DeleteLocalRef(js);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
bool vr_running = false;
|
bool vr_running = false;
|
||||||
static void engine_vr_loop()
|
static void engine_vr_loop()
|
||||||
{
|
{
|
||||||
@@ -1029,12 +1048,12 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
|||||||
break;
|
break;
|
||||||
case APP_CMD_WINDOW_REDRAW_NEEDED:
|
case APP_CMD_WINDOW_REDRAW_NEEDED:
|
||||||
LOG("APP_CMD_WINDOW_REDRAW_NEEDED");
|
LOG("APP_CMD_WINDOW_REDRAW_NEEDED");
|
||||||
App::I->redraw = true;
|
App::I->ui_task([]{ App::I->update(0); });
|
||||||
ALooper_wake(engine->app->looper);
|
ALooper_wake(engine->app->looper);
|
||||||
break;
|
break;
|
||||||
case APP_CMD_WINDOW_RESIZED:
|
case APP_CMD_WINDOW_RESIZED:
|
||||||
LOG("APP_CMD_WINDOW_RESIZED");
|
LOG("APP_CMD_WINDOW_RESIZED");
|
||||||
App::I->redraw = true;
|
App::I->async_redraw();
|
||||||
ALooper_wake(engine->app->looper);
|
ALooper_wake(engine->app->looper);
|
||||||
break;
|
break;
|
||||||
case APP_CMD_CONTENT_RECT_CHANGED:
|
case APP_CMD_CONTENT_RECT_CHANGED:
|
||||||
@@ -1042,7 +1061,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
|||||||
//App::I->width = engine->app->contentRect.right - engine->app->contentRect.left;
|
//App::I->width = engine->app->contentRect.right - engine->app->contentRect.left;
|
||||||
//App::I->height = engine->app->contentRect.bottom - engine->app->contentRect.top;
|
//App::I->height = engine->app->contentRect.bottom - engine->app->contentRect.top;
|
||||||
//LOG("content rect %f %f", App::I->width, App::I->height);
|
//LOG("content rect %f %f", App::I->width, App::I->height);
|
||||||
App::I->redraw = true;
|
App::I->async_redraw();
|
||||||
ALooper_wake(engine->app->looper);
|
ALooper_wake(engine->app->looper);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -54,6 +54,23 @@ public class MainActivity extends PlatformActivity {
|
|||||||
public native void pickExternalCallback(String path);
|
public native void pickExternalCallback(String path);
|
||||||
public native void contentRectChanged(int wnd_w, int wnd_h, int rect_left, int rect_top, int rect_right, int rect_bottom);
|
public native void contentRectChanged(int wnd_w, int wnd_h, int rect_left, int rect_top, int rect_right, int rect_bottom);
|
||||||
|
|
||||||
|
public boolean createDir(String path)
|
||||||
|
{
|
||||||
|
File dir = new File(path);
|
||||||
|
|
||||||
|
if (!dir.exists())
|
||||||
|
{
|
||||||
|
boolean success = dir.mkdirs();
|
||||||
|
if (success)
|
||||||
|
Log.v("PanoPainterJava", "create path " + dir.getAbsolutePath());
|
||||||
|
else
|
||||||
|
Log.v("PanoPainterJava", "create path failed " + dir.getAbsolutePath());
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
Log.v("PanoPainterJava", "create path already existed " + dir.getAbsolutePath());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRootPath()
|
public void setRootPath()
|
||||||
{
|
{
|
||||||
Log.v("PanoPainterJava", "permission granted");
|
Log.v("PanoPainterJava", "permission granted");
|
||||||
@@ -225,13 +242,22 @@ public class MainActivity extends PlatformActivity {
|
|||||||
|
|
||||||
public void pickFile()
|
public void pickFile()
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
startActivityForResult(Intent.createChooser(intent, "Select a file"), 1);
|
startActivityForResult(Intent.createChooser(intent, "Select a file"), 1);
|
||||||
Log.v("PanoPainterJava", "pick start");
|
Log.v("PanoPainterJava", "pick start");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void pickFileSave()
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
intent.setType("*/*");
|
||||||
|
startActivityForResult(Intent.createChooser(intent, "Select a file"), 1);
|
||||||
|
Log.v("PanoPainterJava", "pick save start");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
void displayKeyboard(bool pShow);
|
void displayKeyboard(bool pShow);
|
||||||
void android_pick_file(std::function<void(std::string)> callback);
|
void android_pick_file(std::function<void(std::string)> callback);
|
||||||
|
void android_pick_file_save(std::function<void(std::string)> callback);
|
||||||
std::string android_get_clipboard();
|
std::string android_get_clipboard();
|
||||||
bool android_set_clipboard(const std::string& s);
|
bool android_set_clipboard(const std::string& s);
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
@@ -228,7 +229,7 @@ void App::pick_file_save(std::vector<std::string> types, std::function<void (std
|
|||||||
callback(path);
|
callback(path);
|
||||||
});
|
});
|
||||||
#elif __ANDROID__
|
#elif __ANDROID__
|
||||||
//android_pick_file(callback);
|
android_pick_file_save(callback);
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
std::string filter = "Supported Files (";
|
std::string filter = "Supported Files (";
|
||||||
bool first_type = true;
|
bool first_type = true;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
AAssetManager* Asset::m_am;
|
AAssetManager* Asset::m_am;
|
||||||
|
bool android_create_dir(const std::string& path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool Asset::delete_file(const std::string& path)
|
bool Asset::delete_file(const std::string& path)
|
||||||
@@ -134,6 +135,15 @@ bool Asset::is_asset(const std::string & path)
|
|||||||
return path.substr(0, 5) == "data/";
|
return path.substr(0, 5) == "data/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Asset::create_dir(const std::string& path)
|
||||||
|
{
|
||||||
|
#if __WIN__
|
||||||
|
return PathFileExistsA(path.c_str()) ? true : CreateDirectoryA(path.c_str(), NULL);
|
||||||
|
#elif __ANDROID__
|
||||||
|
return android_create_dir(path);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool Asset::open(const char* path)
|
bool Asset::open(const char* path)
|
||||||
{
|
{
|
||||||
//LOG("Asset::open %s", path);
|
//LOG("Asset::open %s", path);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public:
|
|||||||
static bool delete_file(const std::string& path);
|
static bool delete_file(const std::string& path);
|
||||||
static std::string absolute(const std::string& path);
|
static std::string absolute(const std::string& path);
|
||||||
static bool is_asset(const std::string& path);
|
static bool is_asset(const std::string& path);
|
||||||
|
static bool create_dir(const std::string& path);
|
||||||
std::string m_current_path;
|
std::string m_current_path;
|
||||||
FILE* m_fp = nullptr;
|
FILE* m_fp = nullptr;
|
||||||
int m_len = 0;
|
int m_len = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user