FileDocCategorySizeDatePackage
BluetoothDevicePreference.javaAPI DocAndroid 1.5 API3825Wed May 06 22:42:48 BST 2009com.android.settings.bluetooth

BluetoothDevicePreference

public class BluetoothDevicePreference extends android.preference.Preference implements LocalBluetoothDevice.Callback
BluetoothDevicePreference is the preference type used to display each remote Bluetooth device in the Bluetooth Settings screen.

Fields Summary
private static final String
TAG
private static int
sDimAlpha
private LocalBluetoothDevice
mLocalDevice
private boolean
mIsBusy
Cached local copy of whether the device is busy. This is only updated from {@link #onDeviceAttributesChanged(LocalBluetoothDevice)}.
Constructors Summary
public BluetoothDevicePreference(android.content.Context context, LocalBluetoothDevice localDevice)

    
         
        super(context);

        if (sDimAlpha == Integer.MIN_VALUE) {
            TypedValue outValue = new TypedValue();
            context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true);
            sDimAlpha = (int) (outValue.getFloat() * 255);
        }
            
        mLocalDevice = localDevice;
        
        setLayoutResource(R.layout.preference_bluetooth);
        
        localDevice.registerCallback(this);
        
        onDeviceAttributesChanged(localDevice);
    
Methods Summary
public intcompareTo(android.preference.Preference another)

        if (!(another instanceof BluetoothDevicePreference)) {
            // Put other preference types above us
            return 1;
        }
        
        return mLocalDevice.compareTo(((BluetoothDevicePreference) another).mLocalDevice);
    
public LocalBluetoothDevicegetDevice()

        return mLocalDevice;
    
public booleanisEnabled()

        return super.isEnabled() && !mIsBusy;
    
protected voidonBindView(android.view.View view)

        super.onBindView(view);

        ImageView btClass = (ImageView) view.findViewById(R.id.btClass);
        btClass.setImageResource(mLocalDevice.getBtClassDrawable());
        btClass.setAlpha(isEnabled() ? 255 : sDimAlpha);        
    
public voidonDeviceAttributesChanged(LocalBluetoothDevice device)


        /*
         * The preference framework takes care of making sure the value has
         * changed before proceeding.
         */
        
        setTitle(mLocalDevice.getName());
        
        /*
         * TODO: Showed "Paired" even though it was "Connected". This may be
         * related to BluetoothHeadset not bound to the actual
         * BluetoothHeadsetService when we got here.
         */
        setSummary(mLocalDevice.getSummary());

        // Used to gray out the item
        mIsBusy = mLocalDevice.isBusy();
        
        // Data has changed
        notifyChanged();
        
        // This could affect ordering, so notify that also
        notifyHierarchyChanged();
    
protected voidonPrepareForRemoval()

        super.onPrepareForRemoval();
        mLocalDevice.unregisterCallback(this);