FileDocCategorySizeDatePackage
BrightnessPreference.javaAPI DocAndroid 1.5 API3362Wed May 06 22:42:48 BST 2009com.android.settings

BrightnessPreference

public class BrightnessPreference extends android.preference.SeekBarPreference implements SeekBar.OnSeekBarChangeListener

Fields Summary
private android.widget.SeekBar
mSeekBar
private int
mOldBrightness
private static final int
MINIMUM_BACKLIGHT
private static final int
MAXIMUM_BACKLIGHT
Constructors Summary
public BrightnessPreference(android.content.Context context, android.util.AttributeSet attrs)


         
        super(context, attrs);
    
Methods Summary
protected voidonBindDialogView(android.view.View view)

        super.onBindDialogView(view);

        mSeekBar = getSeekBar(view);
        mSeekBar.setOnSeekBarChangeListener(this);
        mSeekBar.setMax(MAXIMUM_BACKLIGHT - MINIMUM_BACKLIGHT);
        try {
            mOldBrightness = Settings.System.getInt(getContext().getContentResolver(), 
                Settings.System.SCREEN_BRIGHTNESS);
        } catch (SettingNotFoundException snfe) {
            mOldBrightness = MAXIMUM_BACKLIGHT;
        }
        mSeekBar.setProgress(mOldBrightness - MINIMUM_BACKLIGHT);
    
protected voidonDialogClosed(boolean positiveResult)

        super.onDialogClosed(positiveResult);
        
        if (positiveResult) {
            Settings.System.putInt(getContext().getContentResolver(), 
                    Settings.System.SCREEN_BRIGHTNESS,
                    mSeekBar.getProgress() + MINIMUM_BACKLIGHT);
        } else {
            setBrightness(mOldBrightness);
        }
    
public voidonProgressChanged(android.widget.SeekBar seekBar, int progress, boolean fromTouch)

        setBrightness(progress + MINIMUM_BACKLIGHT);
    
public voidonStartTrackingTouch(android.widget.SeekBar seekBar)

        // NA
    
public voidonStopTrackingTouch(android.widget.SeekBar seekBar)

        // NA
    
private voidsetBrightness(int brightness)

        try {
            IHardwareService hardware = IHardwareService.Stub.asInterface(
                    ServiceManager.getService("hardware"));
            if (hardware != null) {
                hardware.setBacklights(brightness);
            }
        } catch (RemoteException doe) {
            
        }