Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85303274 authored by James Hiew's avatar James Hiew Committed by Jorge Ruesga
Browse files

Long press no longer copies to clipboard if there is nothing to copy

Previously long pressing on e.g. 'SIM status' or 'IMEI information' would show a text
copied toast, but nothing was actually copied to the clipboard.

Change-Id: I3df82ff06c14134af01438ef3314d5def625880a
parent 18cce100
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.deviceinfo;
import android.app.ActionBar;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
@@ -414,15 +415,19 @@ public class Status extends PreferenceActivity {
                    ListAdapter listAdapter = (ListAdapter) parent.getAdapter();
                    Preference pref = (Preference) listAdapter.getItem(position);

                    CharSequence summary = pref.getSummary();
                    if (!TextUtils.isEmpty(summary)) {
                        ClipboardManager cm = (ClipboardManager)
                                getSystemService(Context.CLIPBOARD_SERVICE);
                    cm.setText(pref.getSummary());
                        cm.setPrimaryClip(ClipData.newPlainText(pref.getTitle(), summary));
                        Toast.makeText(
                                Status.this,
                                com.android.internal.R.string.text_copied,
                                Toast.LENGTH_SHORT).show();
                        return true;
                    }
                    return false;
                }
            });

        Preference subs = findPreference(BUTTON_SUBSCRIPTIONS_KEY);