mirror of
https://github.com/zxing/zxing.git
synced 2025-01-13 04:07:27 -08:00
Make sure checkboxes are enabled correctly on first load
git-svn-id: https://zxing.googlecode.com/svn/trunk@1479 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
e46c6f1e9f
commit
4ed7e4ac96
|
@ -56,16 +56,26 @@ public final class PreferencesActivity extends PreferenceActivity
|
|||
preferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
decode1D = (CheckBoxPreference) preferences.findPreference(KEY_DECODE_1D);
|
||||
decodeQR = (CheckBoxPreference) preferences.findPreference(KEY_DECODE_QR);
|
||||
disableLastCheckedPref();
|
||||
}
|
||||
|
||||
// Prevent the user from turning off both decode options
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(KEY_DECODE_1D)) {
|
||||
decodeQR.setEnabled(decode1D.isChecked());
|
||||
disableLastCheckedPref();
|
||||
}
|
||||
|
||||
private void disableLastCheckedPref() {
|
||||
if (decode1D.isChecked()) {
|
||||
decodeQR.setEnabled(true);
|
||||
} else {
|
||||
decodeQR.setEnabled(false);
|
||||
decodeQR.setChecked(true);
|
||||
} else if (key.equals(KEY_DECODE_QR)) {
|
||||
decode1D.setEnabled(decodeQR.isChecked());
|
||||
}
|
||||
if (decodeQR.isChecked()) {
|
||||
decode1D.setEnabled(true);
|
||||
} else {
|
||||
decode1D.setEnabled(false);
|
||||
decode1D.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue