Android: Add code for "show folder", don't activate it since it's not reliable (need a query on startup)

This commit is contained in:
Henrik Rydgård 2024-01-21 13:29:20 +01:00
parent 20626ebfee
commit 2d9afaa6df
3 changed files with 24 additions and 3 deletions

View file

@ -134,6 +134,7 @@ void System_CreateGameShortcut(const Path &path, const std::string &title) {
g_requestManager.MakeSystemRequest(SystemRequestType::CREATE_GAME_SHORTCUT, NO_REQUESTER_TOKEN, nullptr, nullptr, path.ToString(), title, 0);
}
// Also acts as just show folder, if you pass in a folder.
void System_ShowFileInFolder(const Path &path) {
g_requestManager.MakeSystemRequest(SystemRequestType::SHOW_FILE_IN_FOLDER, NO_REQUESTER_TOKEN, nullptr, nullptr, path.ToString(), "", 0);
}

View file

@ -486,7 +486,7 @@ bool System_GetPropertyBool(SystemProperty prop) {
case SYSPROP_HAS_TEXT_INPUT_DIALOG:
return true;
case SYSPROP_HAS_OPEN_DIRECTORY:
return false;
return false; // We have this implemented but it may or may not work depending on if a file explorer is installed.
case SYSPROP_HAS_ADDITIONAL_STORAGE:
return !g_additionalStorageDirs.empty();
case SYSPROP_HAS_BACK_BUTTON:
@ -1144,6 +1144,9 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
case SystemRequestType::NOTIFY_UI_STATE:
PushCommand("uistate", param1);
return true;
case SystemRequestType::SHOW_FILE_IN_FOLDER:
PushCommand("show_folder", param1);
return true;
default:
return false;
}

View file

@ -1633,8 +1633,25 @@ public abstract class NativeActivity extends Activity {
throw new Exception();
} catch (Exception e) {
NativeApp.reportException(e, params);
}
} else if (command.equals("show_folder")) {
try {
Uri selectedUri = Uri.parse(params);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");
if (intent.resolveActivityInfo(getPackageManager(), 0) != null) {
startActivity(intent);
Log.i(TAG, "Started activity for " + params);
return true;
} else {
Log.w(TAG, "No file explorer installed");
// if you reach this place, it means there is no any file
// explorer app installed on your device
return false;
}
} catch (Exception e) {
NativeApp.reportException(e, params);
return false;
}
}
return false;