diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-09-09 14:53:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-09 14:53:23 +0200 |
commit | 1093c0ff51b980634dffdd9618eaa53061da6419 (patch) | |
tree | 6129a410087237fc1687d384db9376365232a228 /platform/android/java/src | |
parent | ffe158ae85b970cbc05b4da1047102dc19dc8297 (diff) | |
parent | f68e1270797b169e9a31ad5b45f6dd0a2041a27d (diff) |
Merge pull request #21783 from xsellier/feature/clipboard-android
Add clipboard operation for android OS
Diffstat (limited to 'platform/android/java/src')
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/Godot.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index ef798fc790..92c9be5d43 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -59,6 +59,9 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; import android.media.MediaPlayer; +import android.content.ClipboardManager; +import android.content.ClipData; + import java.lang.reflect.Method; import java.util.List; import java.util.ArrayList; @@ -103,6 +106,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC private TextView mAverageSpeed; private TextView mTimeRemaining; private ProgressBar mPB; + private ClipboardManager mClipboard; private View mDashboard; private View mCellMessage; @@ -441,6 +445,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC Window window = getWindow(); //window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + mClipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); //check for apk expansion API if (true) { @@ -607,6 +612,24 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC } } + public String getClipboard() { + + String copiedText = ""; + + if (mClipboard.getPrimaryClip() != null) { + ClipData.Item item = mClipboard.getPrimaryClip().getItemAt(0); + copiedText = item.getText().toString(); + } + + return copiedText; + } + + public void setClipboard(String p_text) { + + ClipData clip = ClipData.newPlainText("myLabel", p_text); + mClipboard.setPrimaryClip(clip); + } + @Override protected void onResume() { super.onResume(); |