You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
Add clipboard operation for android OS
This commit is contained in:
@@ -57,6 +57,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;
|
||||
@@ -101,6 +104,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;
|
||||
@@ -396,6 +400,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
||||
_self = this;
|
||||
Window window = getWindow();
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
||||
mClipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
|
||||
if (true) {
|
||||
boolean md5mismatch = false;
|
||||
@@ -563,6 +568,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();
|
||||
|
||||
Reference in New Issue
Block a user