Longpress any row in Status to copy text to the clipboard.
Really convenient for grabbing IMEI/MAC/serial/etc. Change-Id: I30dd6109d76f342108b10571cf043158b09743d0
This commit is contained in:
committed by
Dan Sandler
parent
31959aad71
commit
b771532330
@@ -18,6 +18,7 @@ package com.android.settings.deviceinfo;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@@ -42,6 +43,12 @@ import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.telephony.Phone;
|
||||
import com.android.internal.telephony.PhoneConstants;
|
||||
@@ -302,6 +309,27 @@ public class Status extends PreferenceActivity {
|
||||
} else {
|
||||
removePreferenceFromScreen(KEY_SERIAL_NUMBER);
|
||||
}
|
||||
|
||||
// Make every pref on this screen copy its data to the clipboard on longpress.
|
||||
// Super convenient for capturing the IMEI, MAC addr, serial, etc.
|
||||
getListView().setOnItemLongClickListener(
|
||||
new AdapterView.OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
ListAdapter listAdapter = (ListAdapter) parent.getAdapter();
|
||||
Preference pref = (Preference) listAdapter.getItem(position);
|
||||
|
||||
ClipboardManager cm = (ClipboardManager)
|
||||
getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setText(pref.getSummary());
|
||||
Toast.makeText(
|
||||
Status.this,
|
||||
com.android.internal.R.string.text_copied,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user