diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index fd661088e6..924d8f1970 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -30,6 +30,7 @@ #include "Common/File/FileUtil.h" #include "Common/StringUtils.h" #include "Common/System/System.h" +#include "Common/System/OSD.h" #include "Common/System/Request.h" #include "Common/System/NativeApp.h" #include "Core/Config.h" @@ -161,6 +162,8 @@ void GameScreen::CreateViews() { char buffer[16]; snprintf(buffer, sizeof(buffer), "%08X", crc); System_CopyStringToClipboard(buffer); + // Success indication. Not worth a translatable string. + g_OSD.Show(OSDType::MESSAGE_SUCCESS, buffer, 1.0f); return UI::EVENT_DONE; }); tvCRCCopy_->SetVisibility(crcVisibility); diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 6bf54fa364..1011e599c5 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -499,6 +499,8 @@ bool System_GetPropertyBool(SystemProperty prop) { case SYSPROP_SUPPORTS_SUSTAINED_PERF_MODE: return sustainedPerfSupported; // 7.0 introduced sustained performance mode as an optional feature. case SYSPROP_HAS_TEXT_INPUT_DIALOG: + return androidVersion >= 11; // honeycomb + case SYSPROP_HAS_TEXT_CLIPBOARD: return true; case SYSPROP_HAS_OPEN_DIRECTORY: return false; // We have this implemented but it may or may not work depending on if a file explorer is installed. @@ -1114,6 +1116,9 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string case SystemRequestType::RECREATE_ACTIVITY: PushCommand("recreate", param1); return true; + case SystemRequestType::COPY_TO_CLIPBOARD: + PushCommand("copy_to_clipboard", param1); + return true; case SystemRequestType::INPUT_TEXT_MODAL: { std::string serialized = StringFromFormat("%d:@:%s:@:%s", requestId, param1.c_str(), param2.c_str()); diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index a3a968ccc2..b5f4e8cd77 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -7,6 +7,8 @@ import android.app.Activity; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.UiModeManager; +import android.content.ClipData; +import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -1666,10 +1668,23 @@ public abstract class NativeActivity extends Activity { NativeApp.reportException(e, params); return false; } + } else if (command.equals("copy_to_clipboard")) { + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + copyStringToClipboard(params); + } + } else { + Log.w(TAG, "Unknown string command " + command); } return false; } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + private void copyStringToClipboard(String text) { + ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("Copied Text", text); + clipboard.setPrimaryClip(clip); + } + @SuppressLint("NewApi") @Override public void recreate() {