android save picker, create dir api wip
This commit is contained in:
@@ -111,6 +111,8 @@ add_library(
|
||||
../../src/binary_stream.cpp
|
||||
../../src/serializer.cpp
|
||||
../../src/settings.cpp
|
||||
../../src/node_input_box.cpp
|
||||
../../src/node_dialog_export_ppbr.cpp
|
||||
)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
jclass clazz = jni->GetObjectClass(g_engine.app->activity->clazz);
|
||||
@@ -366,6 +374,17 @@ bool android_set_clipboard(const std::string& s)
|
||||
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;
|
||||
static void engine_vr_loop()
|
||||
{
|
||||
@@ -1029,12 +1048,12 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
||||
break;
|
||||
case 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);
|
||||
break;
|
||||
case APP_CMD_WINDOW_RESIZED:
|
||||
LOG("APP_CMD_WINDOW_RESIZED");
|
||||
App::I->redraw = true;
|
||||
App::I->async_redraw();
|
||||
ALooper_wake(engine->app->looper);
|
||||
break;
|
||||
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->height = engine->app->contentRect.bottom - engine->app->contentRect.top;
|
||||
//LOG("content rect %f %f", App::I->width, App::I->height);
|
||||
App::I->redraw = true;
|
||||
App::I->async_redraw();
|
||||
ALooper_wake(engine->app->looper);
|
||||
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 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()
|
||||
{
|
||||
Log.v("PanoPainterJava", "permission granted");
|
||||
@@ -225,13 +242,22 @@ public class MainActivity extends PlatformActivity {
|
||||
|
||||
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.setType("*/*");
|
||||
startActivityForResult(Intent.createChooser(intent, "Select a file"), 1);
|
||||
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
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
Reference in New Issue
Block a user