Skip to content

Commit

Permalink
Android: Add code for "show folder", don't activate it since it's not…
Browse files Browse the repository at this point in the history
… reliable (need a query on startup)
  • Loading branch information
hrydgard committed Jan 21, 2024
1 parent 20626eb commit 2d9afaa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions Common/System/Request.cpp
Expand Up @@ -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);
}
5 changes: 4 additions & 1 deletion android/jni/app-android.cpp
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down
21 changes: 19 additions & 2 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Expand Up @@ -1633,8 +1633,25 @@ public boolean processCommand(String command, String params) {
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;
Expand Down

0 comments on commit 2d9afaa

Please sign in to comment.