Methods Summary |
---|
private android.preference.Preference | getDependencyPreference()
String depKey = mCheckBoxPreference.getDependency();
if (TextUtils.isEmpty(depKey)) {
return null;
}
return mCheckBoxPreference.getPreferenceManager().findPreference(depKey);
|
private void | handleStateChanged(int state)
if (state == BluetoothDevice.BLUETOOTH_STATE_OFF ||
state == BluetoothDevice.BLUETOOTH_STATE_ON) {
mCheckBoxPreference.setChecked(state == BluetoothDevice.BLUETOOTH_STATE_ON);
mCheckBoxPreference.setSummary(state == BluetoothDevice.BLUETOOTH_STATE_OFF ?
mOriginalSummary :
null);
mCheckBoxPreference.setEnabled(isEnabledByDependency());
} else if (state == BluetoothDevice.BLUETOOTH_STATE_TURNING_ON ||
state == BluetoothDevice.BLUETOOTH_STATE_TURNING_OFF) {
mCheckBoxPreference.setSummary(state == BluetoothDevice.BLUETOOTH_STATE_TURNING_ON
? R.string.wifi_starting
: R.string.wifi_stopping);
} else {
mCheckBoxPreference.setChecked(false);
mCheckBoxPreference.setSummary(R.string.wifi_error);
mCheckBoxPreference.setEnabled(true);
}
|
private boolean | isEnabledByDependency()
Preference dep = getDependencyPreference();
if (dep == null) {
return true;
}
return !dep.shouldDisableDependents();
|
public boolean | onPreferenceChange(android.preference.Preference preference, java.lang.Object value)
// Turn on/off BT
setEnabled((Boolean) value);
// Don't update UI to opposite state until we're sure
return false;
|
public void | pause()
if (mLocalManager == null) {
return;
}
mContext.unregisterReceiver(mReceiver);
mCheckBoxPreference.setOnPreferenceChangeListener(null);
|
public void | resume()
if (mLocalManager == null) {
return;
}
int state = mLocalManager.getBluetoothState();
// This is the widget enabled state, not the preference toggled state
mCheckBoxPreference.setEnabled(state == BluetoothDevice.BLUETOOTH_STATE_ON ||
state == BluetoothDevice.BLUETOOTH_STATE_OFF);
// BT state is not a sticky broadcast, so set it manually
handleStateChanged(state);
mContext.registerReceiver(mReceiver,
new IntentFilter(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION));
mCheckBoxPreference.setOnPreferenceChangeListener(this);
|
private void | setEnabled(boolean enable)
// Disable preference
mCheckBoxPreference.setEnabled(false);
mLocalManager.setBluetoothEnabled(enable);
|