Example usage for android.preference EditTextPreference setText

List of usage examples for android.preference EditTextPreference setText

Introduction

In this page you can find the example usage for android.preference EditTextPreference setText.

Prototype

public void setText(String text) 

Source Link

Document

Saves the text to the SharedPreferences .

Usage

From source file:com.aware.Aware_Preferences.java

/**
 * Magnetometer module settings UI/* w w  w.j av a  2  s  .com*/
 */
private void magnetometer() {
    final PreferenceScreen magno_pref = (PreferenceScreen) findPreference("magnetometer");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    if (temp != null) {
        magno_pref.setSummary(
                magno_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        magno_pref.setSummary(magno_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference magnetometer = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_MAGNETOMETER);
    magnetometer.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_MAGNETOMETER).equals("true"));
    magnetometer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                magnetometer.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_MAGNETOMETER, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_MAGNETOMETER,
                    magnetometer.isChecked());
            if (magnetometer.isChecked()) {
                framework.startMagnetometer();
            } else {
                framework.stopMagnetometer();
            }
            return true;
        }
    });

    final EditTextPreference frequency_magnetometer = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_MAGNETOMETER);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_MAGNETOMETER).length() > 0) {
        frequency_magnetometer
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_MAGNETOMETER)
                        + " microseconds");
    }
    frequency_magnetometer
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_MAGNETOMETER));
    frequency_magnetometer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_MAGNETOMETER,
                    (String) newValue);
            frequency_magnetometer.setSummary((String) newValue + " microseconds");
            framework.startMagnetometer();
            return true;
        }
    });

}

From source file:com.aware.Aware_Preferences.java

/**
 * Accelerometer module settings UI/*from w ww  . j  av a  2s.  c  o m*/
 */
private void accelerometer() {

    final PreferenceScreen accel_pref = (PreferenceScreen) findPreference("accelerometer");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    if (temp != null) {
        accel_pref.setSummary(
                accel_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        accel_pref.setSummary(accel_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference accelerometer = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_ACCELEROMETER);
    accelerometer.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_ACCELEROMETER).equals("true"));
    accelerometer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                accelerometer.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ACCELEROMETER, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ACCELEROMETER,
                    accelerometer.isChecked());
            if (accelerometer.isChecked()) {
                framework.startAccelerometer();
            } else {
                framework.stopAccelerometer();
            }
            return true;
        }
    });

    final EditTextPreference frequency_accelerometer = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_ACCELEROMETER);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER).length() > 0) {
        frequency_accelerometer
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER)
                        + " microseconds");
    }
    frequency_accelerometer
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER));
    frequency_accelerometer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER,
                    (String) newValue);
            frequency_accelerometer.setSummary((String) newValue + " microseconds");
            framework.startAccelerometer();
            return true;
        }
    });

}

From source file:com.aware.Aware_Preferences.java

/**
 * Applications module settings UI/*w w  w  .j  ava2  s .c  o  m*/
 */
private void applications() {
    final CheckBoxPreference notifications = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_NOTIFICATIONS);
    notifications.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_NOTIFICATIONS).equals("true"));
    notifications.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (isAccessibilityServiceActive() && notifications.isChecked()) {
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_NOTIFICATIONS,
                        notifications.isChecked());
                notifications.setChecked(true);
                framework.startApplications();
                return true;
            }
            if (!isAccessibilityServiceActive()) {
                showDialog(Aware_Preferences.DIALOG_ERROR_ACCESSIBILITY);
            }
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_NOTIFICATIONS, false);
            notifications.setChecked(false);
            return false;
        }
    });
    final CheckBoxPreference crashes = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_CRASHES);
    crashes.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_CRASHES).equals("true"));
    crashes.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (isAccessibilityServiceActive() && crashes.isChecked()) {
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_CRASHES,
                        crashes.isChecked());
                crashes.setChecked(true);
                framework.startApplications();
                return true;
            }
            if (!isAccessibilityServiceActive()) {
                showDialog(Aware_Preferences.DIALOG_ERROR_ACCESSIBILITY);
            }
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_CRASHES, false);
            crashes.setChecked(false);
            return false;
        }
    });
    final CheckBoxPreference applications = (CheckBoxPreference) findPreference("status_applications");
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS).equals("true")
            && !isAccessibilityServiceActive()) {
        showDialog(Aware_Preferences.DIALOG_ERROR_ACCESSIBILITY);
        Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS, false);
        framework.stopApplications();
    }
    applications.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS).equals("true"));
    applications.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (isAccessibilityServiceActive() && applications.isChecked()) {
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS, true);
                applications.setChecked(true);
                framework.startApplications();
                return true;
            } else {
                if (!isAccessibilityServiceActive()) {
                    showDialog(Aware_Preferences.DIALOG_ERROR_ACCESSIBILITY);
                }

                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS, false);
                applications.setChecked(false);

                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_NOTIFICATIONS, false);
                notifications.setChecked(false);

                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_CRASHES, false);
                crashes.setChecked(false);

                framework.stopApplications();
                return false;
            }
        }
    });

    final EditTextPreference frequency_applications = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_APPLICATIONS);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_APPLICATIONS).length() > 0) {
        frequency_applications
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_APPLICATIONS)
                        + " seconds");
    }
    frequency_applications
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_APPLICATIONS));
    frequency_applications.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_APPLICATIONS,
                    (String) newValue);
            frequency_applications.setSummary((String) newValue + " seconds");
            framework.startApplications();
            return true;
        }
    });

    final CheckBoxPreference installations = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_INSTALLATIONS);
    installations.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_INSTALLATIONS).equals("true"));
    installations.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_INSTALLATIONS,
                    installations.isChecked());
            if (installations.isChecked()) {
                framework.startInstallations();
            } else {
                framework.stopInstallations();
            }
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Linear Accelerometer module settings UI
 *//*from   www .ja  v a  2  s .  c om*/
private void linear_accelerometer() {

    final PreferenceScreen linear_pref = (PreferenceScreen) findPreference("linear_accelerometer");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);
    if (temp != null) {
        linear_pref.setSummary(
                linear_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        linear_pref.setSummary(linear_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference linear_accelerometer = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_LINEAR_ACCELEROMETER);
    linear_accelerometer.setChecked(Aware
            .getSetting(getApplicationContext(), Aware_Preferences.STATUS_LINEAR_ACCELEROMETER).equals("true"));
    linear_accelerometer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                linear_accelerometer.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LINEAR_ACCELEROMETER, false);
                return false;
            }
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LINEAR_ACCELEROMETER,
                    linear_accelerometer.isChecked());
            if (linear_accelerometer.isChecked()) {
                framework.startLinearAccelerometer();
            } else {
                framework.stopLinearAccelerometer();
            }
            return true;
        }
    });

    final EditTextPreference frequency_linear_accelerometer = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER)
            .length() > 0) {
        frequency_linear_accelerometer.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER)
                        + " microseconds");
    }
    frequency_linear_accelerometer.setText(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER));
    frequency_linear_accelerometer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER,
                    (String) newValue);
            frequency_linear_accelerometer.setSummary((String) newValue + " microseconds");
            framework.startLinearAccelerometer();
            return true;
        }
    });

}

From source file:com.aware.Aware_Preferences.java

/**
 * Location module settings UI//from  w w w  . j  a va2  s.  com
 */
private void locations() {
    final CheckBoxPreference location_gps = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_LOCATION_GPS);
    location_gps.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS).equals("true"));
    location_gps.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            LocationManager localMng = (LocationManager) getSystemService(LOCATION_SERVICE);
            List<String> providers = localMng.getAllProviders();

            if (!providers.contains(LocationManager.GPS_PROVIDER)) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                location_gps.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS,
                    location_gps.isChecked());
            if (location_gps.isChecked()) {
                framework.startLocations();
            } else {
                framework.stopLocations();
            }
            return true;
        }
    });

    final CheckBoxPreference location_network = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_LOCATION_NETWORK);
    location_network.setChecked(Aware
            .getSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK).equals("true"));
    location_network.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            LocationManager localMng = (LocationManager) getSystemService(LOCATION_SERVICE);
            List<String> providers = localMng.getAllProviders();

            if (!providers.contains(LocationManager.NETWORK_PROVIDER)) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                location_gps.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK,
                    location_network.isChecked());
            if (location_network.isChecked()) {
                framework.startLocations();
            } else {
                framework.stopLocations();
            }
            return true;
        }
    });

    final EditTextPreference gpsInterval = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_LOCATION_GPS);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS).length() > 0) {
        gpsInterval
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS)
                        + " seconds");
    }
    gpsInterval.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS));
    gpsInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS,
                    (String) newValue);
            gpsInterval.setSummary((String) newValue + " seconds");
            framework.startLocations();
            return true;
        }
    });

    final EditTextPreference networkInterval = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_LOCATION_NETWORK);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK).length() > 0) {
        networkInterval.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK)
                        + " seconds");
    }
    networkInterval
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK));
    networkInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK,
                    (String) newValue);
            networkInterval.setSummary((String) newValue + " seconds");
            framework.startLocations();
            return true;
        }
    });

    final EditTextPreference gpsAccuracy = (EditTextPreference) findPreference(
            Aware_Preferences.MIN_LOCATION_GPS_ACCURACY);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY).length() > 0) {
        gpsAccuracy.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY)
                        + " meters");
    }
    gpsAccuracy.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY));
    gpsAccuracy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY,
                    (String) newValue);
            gpsAccuracy.setSummary((String) newValue + " meters");
            framework.startLocations();
            return true;
        }
    });

    final EditTextPreference networkAccuracy = (EditTextPreference) findPreference(
            Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY)
            .length() > 0) {
        networkAccuracy.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY)
                        + " meters");
    }
    networkAccuracy.setText(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY));
    networkAccuracy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY,
                    (String) newValue);
            networkAccuracy.setSummary((String) newValue + " meters");
            framework.startLocations();
            return true;
        }
    });

    final EditTextPreference expirateTime = (EditTextPreference) findPreference(
            Aware_Preferences.LOCATION_EXPIRATION_TIME);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME).length() > 0) {
        expirateTime.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME)
                        + " seconds");
    }
    expirateTime.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME));
    expirateTime.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME,
                    (String) newValue);
            expirateTime.setSummary((String) newValue + " seconds");
            framework.startLocations();
            return true;
        }
    });
}

From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java

/**
 * Refresh the preferences.//ww w .j  ava2 s. c  om
 */
private void refreshDisplay() {
    boolean isConnected = Matrix.getInstance(getActivity()).isConnected();
    Context appContext = getActivity().getApplicationContext();

    PreferenceManager preferenceManager = getPreferenceManager();

    // refresh the avatar
    UserAvatarPreference avatarPreference = (UserAvatarPreference) preferenceManager
            .findPreference(PreferencesManager.SETTINGS_PROFILE_PICTURE_PREFERENCE_KEY);
    avatarPreference.refreshAvatar();
    avatarPreference.setEnabled(isConnected);

    // refresh the display name
    final EditTextPreference displaynamePref = (EditTextPreference) preferenceManager
            .findPreference(PreferencesManager.SETTINGS_DISPLAY_NAME_PREFERENCE_KEY);
    displaynamePref.setSummary(mSession.getMyUser().displayname);
    displaynamePref.setText(mSession.getMyUser().displayname);
    displaynamePref.setEnabled(isConnected);

    // change password
    final EditTextPreference changePasswordPref = (EditTextPreference) preferenceManager
            .findPreference(PreferencesManager.SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY);
    changePasswordPref.setEnabled(isConnected);

    // update the push rules
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(appContext);

    BingRuleSet rules = mSession.getDataHandler().pushRules();

    GcmRegistrationManager gcmMgr = Matrix.getInstance(appContext).getSharedGCMRegistrationManager();

    for (String resourceText : mPushesRuleByResourceId.keySet()) {
        Preference preference = preferenceManager.findPreference(resourceText);

        if (null != preference) {
            if (preference instanceof BingRulePreference) {
                BingRulePreference bingRulePreference = (BingRulePreference) preference;
                bingRulePreference
                        .setEnabled((null != rules) && isConnected && gcmMgr.areDeviceNotificationsAllowed());
                bingRulePreference.setBingRule(mSession.getDataHandler().pushRules()
                        .findDefaultRule(mPushesRuleByResourceId.get(resourceText)));
            } else if (preference instanceof CheckBoxPreference) {
                CheckBoxPreference switchPreference = (CheckBoxPreference) preference;
                if (resourceText.equals(PreferencesManager.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)) {
                    switchPreference.setChecked(gcmMgr.areDeviceNotificationsAllowed());
                } else if (resourceText.equals(PreferencesManager.SETTINGS_TURN_SCREEN_ON_PREFERENCE_KEY)) {
                    switchPreference.setChecked(gcmMgr.isScreenTurnedOn());
                    switchPreference.setEnabled(gcmMgr.areDeviceNotificationsAllowed());
                } else {
                    switchPreference.setEnabled((null != rules) && isConnected);
                    switchPreference.setChecked(preferences.getBoolean(resourceText, false));
                }
            }
        }
    }

    // If notifications are disabled for the current user account or for the current user device
    // The others notifications settings have to be disable too
    boolean areNotifAllowed = rules != null && rules.findDefaultRule(BingRule.RULE_ID_DISABLE_ALL) != null
            && rules.findDefaultRule(BingRule.RULE_ID_DISABLE_ALL).isEnabled;

    Preference notificationSoundPreference = preferenceManager
            .findPreference(PreferencesManager.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY);
    notificationSoundPreference.setEnabled(!areNotifAllowed && gcmMgr.areDeviceNotificationsAllowed());

    Preference notificationPrivacyPreference = preferenceManager
            .findPreference(PreferencesManager.SETTINGS_NOTIFICATION_PRIVACY_PREFERENCE_KEY);
    if (notificationPrivacyPreference != null) {
        notificationPrivacyPreference
                .setEnabled(!areNotifAllowed && gcmMgr.areDeviceNotificationsAllowed() && gcmMgr.useGCM());
    }
}