|
3 | 3 | import android.Manifest;
|
4 | 4 | import android.app.Activity;
|
5 | 5 | import android.content.BroadcastReceiver;
|
| 6 | +import android.content.ClipData; |
| 7 | +import android.content.ClipboardManager; |
6 | 8 | import android.content.Context;
|
7 | 9 | import android.content.Intent;
|
8 | 10 | import android.content.IntentFilter;
|
@@ -185,8 +187,18 @@ public boolean onOptionsItemSelected(MenuItem item) {
|
185 | 187 | .setNeutralButton(android.R.string.cancel, null)
|
186 | 188 | .create();
|
187 | 189 | String host = MainService.svc.lastIP + ":" + Server.current.authPort;
|
188 |
| - ((TextView)v.findViewById(R.id.txtHost)).setText(host); |
189 |
| - ((ImageView)v.findViewById(R.id.imgQR)).setImageBitmap(Utils.getQRCodeBitmap("warpinator://"+host)); |
| 190 | + String uri = "warpinator://"+host; |
| 191 | + View.OnClickListener copyListener = (s) -> { |
| 192 | + ClipData clip = ClipData.newPlainText("Device address", uri); |
| 193 | + ((ClipboardManager)getSystemService(CLIPBOARD_SERVICE)).setPrimaryClip(clip); |
| 194 | + Toast.makeText(this, R.string.address_copied, Toast.LENGTH_SHORT).show(); |
| 195 | + }; |
| 196 | + var txtHost = ((TextView)v.findViewById(R.id.txtHost)); |
| 197 | + txtHost.setText(host); |
| 198 | + txtHost.setOnClickListener(copyListener); |
| 199 | + var imgQR = ((ImageView)v.findViewById(R.id.imgQR)); |
| 200 | + imgQR.setImageBitmap(Utils.getQRCodeBitmap(uri)); |
| 201 | + imgQR.setOnClickListener(copyListener); |
190 | 202 | dialog.show();
|
191 | 203 | } else if (itemID == R.id.conn_issues) {
|
192 | 204 | Intent helpIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(helpUrl));
|
|
0 commit comments