mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Add clipboard operation for android OS
This commit is contained in:
parent
0b180a0732
commit
4d2853fcdc
4 changed files with 71 additions and 48 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue