You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Add clipboard operation for android OS
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user