Java Code Examples for android.preference.CheckBoxPreference#isChecked()

The following examples show how to use android.preference.CheckBoxPreference#isChecked() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsFragment.java    From android-galaxyzoo with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences,
                                      final String key) {
    final Preference connectionPref = findPreference(key);
    if (connectionPref instanceof ListPreference) {
        showUserDescriptionAsSummary(connectionPref);
    }

    //Copy the preference to the Account:
    //This is an awful hack. Hopefully there is some other way to use preferences per-account.
    //If not, maybe we need to reimplement this fragment without using PreferencesFragment.
    String value = null;
    if (connectionPref instanceof ListPreference) {
        final ListPreference listPref = (ListPreference) connectionPref;
        value = listPref.getValue();
    } else if (connectionPref instanceof CheckBoxPreference) {
        final CheckBoxPreference checkboxPref = (CheckBoxPreference) connectionPref;
        value = checkboxPref.isChecked() ? "true" : ""; //See Boolean.parseBoolean().
    }

    LoginUtils.copyPrefToAccount(getActivity(), key, value);
}
 
Example 2
Source File: SettingsFragment.java    From android with MIT License 6 votes vote down vote up
private boolean isEmptyCarshareMode() {
    try {
        final String presKeyTemplate = getResources().getString(R.string.prefs_carshare_template);

        for (String company : getResources().getStringArray(R.array.carshare_companies)) {
            CheckBoxPreference checkBox = (CheckBoxPreference) findPreference(String.format(presKeyTemplate, company));
            if (checkBox.isEnabled() && checkBox.isChecked()) {
                return false;
            }
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    return true;
}
 
Example 3
Source File: SettingsActivity.java    From busybox with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set summary for preference
 *
 * @param pref preference
 * @param init true if no recursive
 */
private void setSummary(Preference pref, boolean init) {
    if (pref instanceof EditTextPreference) {
        EditTextPreference editPref = (EditTextPreference) pref;
        pref.setSummary(editPref.getText());

        if (editPref.getKey().equals("logfile") && !init) {
            editPref.setText(PrefStore.getLogFile(this));
            pref.setSummary(editPref.getText());
        }
    }

    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        pref.setSummary(listPref.getEntry());
    }

    if (pref instanceof CheckBoxPreference) {
        CheckBoxPreference checkPref = (CheckBoxPreference) pref;

        if (checkPref.getKey().equals("logger") && checkPref.isChecked() && init) {
            requestWritePermissions();
        }
    }
}
 
Example 4
Source File: BetterWeatherSettingsActivity.java    From BetterWeather with Apache License 2.0 6 votes vote down vote up
private void updateShortcutPreferenceState(String key) {
    Preference pref = findPreference(key);
    if (pref instanceof CheckBoxPreference) {
        CheckBoxPreference refreshOnTouchPref = (CheckBoxPreference) pref;

        Preference shortcutPref = findPreference(BetterWeatherExtension.PREF_WEATHER_SHORTCUT);

        if (shortcutPref == null) return;

        if (refreshOnTouchPref.isChecked()) {
            shortcutPref.setEnabled(false);
            shortcutPref.setSummary(R.string.shortcut_pref_help_text);
        } else {
            shortcutPref.setEnabled(true);
            bindPreferenceSummaryToValue(findPreference(BetterWeatherExtension.PREF_WEATHER_SHORTCUT));
        }
    }
}
 
Example 5
Source File: InputLanguageSelection.java    From hackerskeyboard with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPause() {
    super.onPause();
    // Save the selected languages
    String checkedLanguages = "";
    PreferenceGroup parent = getPreferenceScreen();
    int count = parent.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
        if (pref.isChecked()) {
            Locale locale = mAvailableLanguages.get(i).locale;
            checkedLanguages += get5Code(locale) + ",";
        }
    }
    if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Editor editor = sp.edit();
    editor.putString(LatinIME.PREF_SELECTED_LANGUAGES, checkedLanguages);
    SharedPreferencesCompat.apply(editor);
}
 
Example 6
Source File: Preferences.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void update_nfc_expiry_preferences(Boolean show_age) {
    try {
        ;
        final PreferenceScreen nfcScreen = (PreferenceScreen) findPreference("xdrip_plus_nfc_settings");
        final String nfc_expiry_days_string = AllPrefsFragment.this.prefs.getString("nfc_expiry_days", "14.5");

        final CheckBoxPreference nfc_show_age = (CheckBoxPreference) findPreference("nfc_show_age");
        nfc_show_age.setSummaryOff("Show the sensor expiry time based on " + nfc_expiry_days_string + " days");
        if (show_age == null) show_age = nfc_show_age.isChecked();
        if (show_age) {
            nfcScreen.removePreference(nfc_expiry_days);
        } else {
            nfc_expiry_days.setOrder(3);
            nfcScreen.addPreference(nfc_expiry_days);
        }
    } catch (NullPointerException e) {
        //
    }
}
 
Example 7
Source File: Preferences.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void update_nfc_expiry_preferences(Boolean show_age) {
    try {
        ;
        final PreferenceScreen nfcScreen = (PreferenceScreen) findPreference("xdrip_plus_nfc_settings");
        final String nfc_expiry_days_string = AllPrefsFragment.this.prefs.getString("nfc_expiry_days", "14.5");

        final CheckBoxPreference nfc_show_age = (CheckBoxPreference) findPreference("nfc_show_age");
        nfc_show_age.setSummaryOff("Show the sensor expiry time based on " + nfc_expiry_days_string + " days");
        if (show_age == null) show_age = nfc_show_age.isChecked();
        if (show_age) {
            nfcScreen.removePreference(nfc_expiry_days);
        } else {
            nfc_expiry_days.setOrder(3);
            nfcScreen.addPreference(nfc_expiry_days);
        }
    } catch (NullPointerException e) {
        //
    }
}
 
Example 8
Source File: NotificationSettingsActivity.java    From AndroidPNClient with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setPreferenceScreen(createPreferenceHierarchy());
    setPreferenceDependencies();

    CheckBoxPreference notifyPref = (CheckBoxPreference) getPreferenceManager()
            .findPreference(Constants.SETTINGS_NOTIFICATION_ENABLED);
    if (notifyPref.isChecked()) {
        notifyPref.setTitle("Notifications Enabled");
    } else {
        notifyPref.setTitle("Notifications Disabled");
    }
}
 
Example 9
Source File: NotificationSettingsActivity.java    From android-demo-xmpp-androidpn with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setPreferenceScreen(createPreferenceHierarchy());
    setPreferenceDependencies();

    CheckBoxPreference notifyPref = (CheckBoxPreference) getPreferenceManager()
            .findPreference(Constants.SETTINGS_NOTIFICATION_ENABLED);
    if (notifyPref.isChecked()) {
        notifyPref.setTitle("Notifications Enabled");
    } else {
        notifyPref.setTitle("Notifications Disabled");
    }
}
 
Example 10
Source File: PreferencesFragment.java    From WheelLogAndroid with GNU General Public License v3.0 5 votes vote down vote up
private void correctCheckState(String preference) {
    boolean setting_state = SettingsUtil.getBoolean(getActivity(), preference);
    CheckBoxPreference cb_preference = (CheckBoxPreference) findPreference(preference);
    if (cb_preference == null)
        return;

    boolean check_state = cb_preference.isChecked();

    if (setting_state != check_state)
        cb_preference.setChecked(setting_state);
}
 
Example 11
Source File: PreferencesFragment.java    From WheelLogAndroid with GNU General Public License v3.0 5 votes vote down vote up
private void correctWheelCheckState(String preference, boolean state) {
    CheckBoxPreference cb_preference = (CheckBoxPreference) findPreference(preference);
    if (cb_preference == null)
        return;

    boolean check_state = cb_preference.isChecked();

    if (state != check_state)
        cb_preference.setChecked(state);

}
 
Example 12
Source File: SettingActivity.java    From stynico with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
	// TODO: Implement this method
	super.onCreate(savedInstanceState);
	//this.getListView().setBackgroundResource(R.color.deepskyblue);
	addPreferencesFromResource(R.xml.settings);

	cb_use_first_size = (CheckBoxPreference)findPreference("cb_use_first_size");

	edit_pic_width = (EditTextPreference)findPreference("edit_pic_width");
	edit_pic_height = (EditTextPreference)findPreference("edit_pic_height");

	isSelected=cb_use_first_size.isChecked();
	setTwoEditEnabled();

	cb_use_first_size.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
		{
			public boolean onPreferenceChange(Preference p1, Object p2)
			{
				if (p1.getKey().equals("cb_use_first_size"))
				{
					isSelected=!cb_use_first_size.isChecked();
					setTwoEditEnabled();
				}
				return true;
			}
		});
}
 
Example 13
Source File: NotifySettingsActivity.java    From AndroidPNClient with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setPreferenceScreen(createPreferenceHierarchy());
    setPreferenceDependencies();

    CheckBoxPreference notifyPref = (CheckBoxPreference) getPreferenceManager()
            .findPreference(Constants.SETTINGS_NOTIFICATION_ENABLED);
    if (notifyPref.isChecked()) {
        notifyPref.setTitle(R.string.notifications_enabled);
    } else {
        notifyPref.setTitle(R.string.notifications_disabled);
    }
}
 
Example 14
Source File: SettingActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO: Implement this method
    super.onCreate(savedInstanceState);
    //this.getListView().setBackgroundResource(R.color.deepskyblue);
    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    addPreferencesFromResource(R.xml.settings);

    cb_use_first_size = (CheckBoxPreference) findPreference("cb_use_first_size");

    edit_pic_width = (EditTextPreference) findPreference("edit_pic_width");
    edit_pic_height = (EditTextPreference) findPreference("edit_pic_height");

    isSelected = cb_use_first_size.isChecked();
    setTwoEditEnabled();

    cb_use_first_size.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference p1, Object p2) {
            if (p1.getKey().equals("cb_use_first_size")) {
                isSelected = !cb_use_first_size.isChecked();
                setTwoEditEnabled();
            }
            return true;
        }
    });
}
 
Example 15
Source File: GroupSettingsFragment.java    From snapdroid with GNU General Public License v3.0 5 votes vote down vote up
public ArrayList<String> getClients() {
    ArrayList<String> clients = new ArrayList<>();
    for (int i = 0; i < prefCatClients.getPreferenceCount(); ++i) {
        CheckBoxPreference checkBoxPref = (CheckBoxPreference) prefCatClients.getPreference(i);
        if (checkBoxPref.isChecked())
            clients.add(checkBoxPref.getKey());
    }
    return clients;
}
 
Example 16
Source File: MaxLockPreferenceFragment.java    From MaxLock with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("WorldReadableFiles")
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    if (getArguments() != null) {
        screen = Screen.valueOf(getArguments().getString(Screen.KEY, Screen.MAIN.toString()));
    } else {
        screen = Screen.MAIN;
    }
    prefs = MLPreferences.getPreferences(getActivity());
    setTitle();
    if (screen == Screen.IMOD) {
        getPreferenceManager().setSharedPreferencesName(Common.PREFS_APPS);
    }
    addPreferencesFromResource(screen.preferenceXML);
    switch (screen) {
        case MAIN:
            updateImplementationStatus();
            PreferenceCategory catAppUI = (PreferenceCategory) findPreference(Common.CATEGORY_APPLICATION_UI);
            CheckBoxPreference useDark = (CheckBoxPreference) findPreference(Common.USE_DARK_STYLE);
            if (!useDark.isChecked()) {
                catAppUI.removePreference(findPreference(Common.USE_AMOLED_BLACK));
            }
            if (SDK_INT >= Build.VERSION_CODES.O) {
                catAppUI.removePreference(findPreference(Common.NEW_APP_NOTIFICATION));
            }
            break;
        case TYPE:
            FingerprintManagerCompat fpm = FingerprintManagerCompat.from(getActivity());
            if (!fpm.isHardwareDetected()) {
                getPreferenceScreen().removePreference(findPreference(Common.SHADOW_FINGERPRINT));
                getPreferenceScreen().removePreference(findPreference(Common.CATEGORY_FINGERPRINT));
            } else {
                CheckBoxPreference disableFP = (CheckBoxPreference) findPreference(Common.DISABLE_FINGERPRINT);
                if (!fpm.hasEnrolledFingerprints() && !disableFP.isChecked()) {
                    disableFP.setSummary(disableFP.getSummary() + getResources().getString(R.string.pref_fingerprint_summary_non_enrolled));
                }
            }
            break;
        case UI:
            ListPreference lp = (ListPreference) findPreference(Common.BACKGROUND);
            findPreference(Common.BACKGROUND_COLOR).setEnabled(lp.getValue().equals("color"));
            lp.setOnPreferenceChangeListener((preference, newValue) -> {
                if (preference.getKey().equals(Common.BACKGROUND)) {
                    if (newValue.toString().equals("custom")) {
                        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                        intent.setType("image/*");
                        startActivityForResult(intent, WALLPAPER_REQUEST_CODE);
                    } else
                        FileUtils.deleteQuietly(new File(getActivity().getFilesDir(), "background"));
                    findPreference(Common.BACKGROUND_COLOR).setEnabled(newValue.toString().equals("color"));
                }
                return true;
            });
            break;
        case OPTIONS:
            Preference el = findPreference(Common.ENABLE_LOGGING);
            el.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                el.setSummary(R.string.toast_pro_required);
            }
            if (MLImplementation.getImplementation(prefs) != MLImplementation.DEFAULT) {
                PreferenceCategory catOther = (PreferenceCategory) findPreference(Common.CATEGORY_OTHER);
                catOther.removePreference(findPreference(Common.HIDE_RECENTS_THUMBNAILS));
            }
            break;
        case IMOD:
            // I.Mod - Pro setup
            Preference iModDelayGlobal = findPreference(Common.ENABLE_DELAY_GENERAL);
            Preference iModDelayPerApp = findPreference(Common.ENABLE_DELAY_PER_APP);
            iModDelayGlobal.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            iModDelayPerApp.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                iModDelayGlobal.setTitle(R.string.pref_delay_needpro);
                iModDelayPerApp.setTitle(R.string.pref_delay_needpro);
            }
            break;
    }
}
 
Example 17
Source File: XmlSettingsActivity.java    From WhereYouGo with GNU General Public License v3.0 4 votes vote down vote up
@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setTitle(R.string.settings);

      needRestart = false;

/* workaround: I don't really know why I cannot call CustomActivity.customOnCreate(this); - OMG! */
      switch (Preferences.APPEARANCE_FONT_SIZE) {
          case PreferenceValues.VALUE_FONT_SIZE_SMALL:
              this.setTheme(R.style.FontSizeSmall);
              break;
          case PreferenceValues.VALUE_FONT_SIZE_MEDIUM:
              this.setTheme(R.style.FontSizeMedium);
              break;
          case PreferenceValues.VALUE_FONT_SIZE_LARGE:
              this.setTheme(R.style.FontSizeLarge);
              break;
      }

/*
       *
 */
      addPreferencesFromResource(R.xml.whereyougo_preferences);
      PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);

/*
 * Remove internal preferences
 */
      Preference somePreference = findPreference(R.string.pref_KEY_X_HIDDEN_PREFERENCES);
      PreferenceScreen preferenceScreen = getPreferenceScreen();
      preferenceScreen.removePreference(somePreference);

/*
       * Register OnClick handler
 */
      Preference preferenceRoot = findPreference(R.string.pref_KEY_S_ROOT);
      preferenceRoot.setOnPreferenceClickListener(this);

      Preference preferenceAbout = findPreference(R.string.pref_KEY_X_ABOUT);
      if (preferenceAbout != null) {
          preferenceAbout.setOnPreferenceClickListener(this);

      }

/*
       * Workaround: Update/set value preview
 */
      // String dir = Preferences.getStringPreference( R.string.pref_KEY_S_ROOT );
      // x.setSummary( "(" + dir + ") " + Locale.getString( R.string.pref_root_desc ) ); // TODO make it better :-(

/* TODO - check this code */
      if (!Utils.isAndroid201OrMore()) {
          Preference prefSensorFilter = findPreference(R.string.pref_KEY_S_SENSORS_ORIENT_FILTER);
          if (prefSensorFilter != null) {
              prefSensorFilter.setEnabled(false);
          }
      }

      if (getIntent() != null && getIntent().hasExtra(getString(R.string.pref_KEY_X_LOGIN_PREFERENCES))) {
          Preference preferenceLogin = findPreference(R.string.pref_KEY_X_LOGIN_PREFERENCES);
          if (preferenceLogin != null) {
              PreferenceScreen screen = getPreferenceScreen();
              for (int i = 0; i < screen.getPreferenceCount(); ++i) {
                  if (screen.getPreference(i) == preferenceLogin) {
                      getIntent().putExtra(getString(R.string.pref_KEY_X_LOGIN_PREFERENCES), false);
                      screen.onItemClick(null, null, i, 0);
                      break;
                  }
              }
          }
      }

      /*
       * Enable/disable status bar propertie
       */
      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
          CheckBoxPreference status_bar = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_STATUSBAR);
          CheckBoxPreference gps_hide = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_GPS_DISABLE_WHEN_HIDE);
          CheckBoxPreference gps_guiding = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_GUIDING_GPS_REQUIRED);
          if (gps_hide.isChecked()) {
              status_bar.setEnabled(!gps_guiding.isChecked());
          } else {
              status_bar.setEnabled(false);
          }
      }
  }
 
Example 18
Source File: TwoFactorPreferenceFragment.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (!verifyServiceOK()) {
        Log.d(TAG, "Avoiding create on logged out service");
        return;
    }

    mLocalizedMap = UI.getTwoFactorLookup(getResources());

    addPreferencesFromResource(R.xml.preference_twofactor);
    setHasOptionsMenu(true);

    final Map<?, ?> twoFacConfig = mService == null ? null : mService.getTwoFactorConfig();
    if (twoFacConfig == null || twoFacConfig.isEmpty()) {
        // An additional check to verifyServiceOK: We must have our 2fa data
        final GaPreferenceActivity activity = (GaPreferenceActivity) getActivity();
        if (activity != null) {
            activity.toast(R.string.err_send_not_connected_will_resume);
            activity.finish();
        }
        return;
    }
    final CheckBoxPreference emailCB = setupCheckbox(twoFacConfig, "Email");
    setupCheckbox(twoFacConfig, "Gauth");
    setupCheckbox(twoFacConfig, "SMS");
    setupCheckbox(twoFacConfig, "Phone");
    final boolean haveAny = mService.hasAnyTwoFactor();

    mLimitsPref = find("twoFacLimits");
    mLimitsPref.setOnPreferenceClickListener(this);
    // Can only set limits if at least one 2FA method is available
    setLimitsText(haveAny);

    mSendNLocktimePref = find("send_nlocktime");
    if (mService.isElements()) {
        removePreference(getPref(NLOCKTIME_EMAILS));
        removePreference(mSendNLocktimePref);
    } else {
        final CheckBoxPreference nlockCB = setupCheckbox(twoFacConfig, NLOCKTIME_EMAILS);
        final Boolean emailEnabled = emailCB.isChecked();
        nlockCB.setEnabled(emailEnabled);
        mSendNLocktimePref.setEnabled(emailEnabled);
        mSendNLocktimePref.setOnPreferenceClickListener(this);
    }
    mTwoFactorResetPref = find("reset_twofactor");

    if (haveAny)
        mTwoFactorResetPref.setOnPreferenceClickListener(this);
    else
        removePreference(mTwoFactorResetPref);
}
 
Example 19
Source File: SettingsFragment.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
@Override
public void onResume() {
    super.onResume();

    // 監視サービスの起動チェック
    mObserverPreferences.setChecked(isObservationServices());
    showIPAddress();

    // サービスとの接続完了まで操作無効にする
    getPreferenceScreen().setEnabled(false);

    // サービスとの接続
    bindDConnectWebService();

    // Dozeモード
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        CheckBoxPreference dozeModePreference = (CheckBoxPreference) getPreferenceScreen()
                .findPreference(getString(R.string.key_settings_doze_mode));
        if (dozeModePreference != null) {
            dozeModePreference.setChecked(!DConnectUtil.isDozeMode(getActivity()));
            if (DConnectUtil.isDozeMode(getActivity())) {
                dozeModePreference.setSummary(R.string.activity_settings_doze_mode_summary_off);
            } else {
                dozeModePreference.setSummary(R.string.activity_settings_doze_mode_summary_on);
            }
            dozeModePreference.setOnPreferenceChangeListener(this);
        }
    }

    // WakeLock
    CheckBoxPreference wakeLockPreference = (CheckBoxPreference) getPreferenceScreen()
            .findPreference(getString(R.string.key_settings_wake_lock));
    if (wakeLockPreference != null) {
        if (wakeLockPreference.isChecked()) {
            wakeLockPreference.setSummary(R.string.activity_settings_wake_lock_summary_on);
        } else {
            wakeLockPreference.setSummary(R.string.activity_settings_wake_lock_summary_off);
        }
        wakeLockPreference.setOnPreferenceChangeListener(this);
    }

    mPauseHandler.setFragment(this);
    mPauseHandler.resume();
}
 
Example 20
Source File: PGPClipperSettingsActivity.java    From PGPClipper with Apache License 2.0 4 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    final ListPreference themePref = (ListPreference) fragment.findPreference("themeSelection");

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    final CheckBoxPreference fingerprintCheckboxPreference = (CheckBoxPreference) fragment.findPreference("enableFingerprintAuth");
    final CheckBoxPreference pgpClipperEnabledCheckbox = (CheckBoxPreference) fragment.findPreference("pgpClipperEnabledCheckbox");

    themePref.setEntryValues(R.array.themes_values);
    themePref.setEntries(R.array.themes);

    String currentVal = sharedPreferences.getString("themeSelection", "dark");
    if (currentVal != null) {
        switch (currentVal) {
            case "dark":
                themePref.setSummary(getResources().getString(R.string.darkText));
                break;
            case "light":
                themePref.setSummary(getResources().getString(R.string.lightText));
                break;
        }
    }

    String providerApp = sharedPreferences.getString("pgpServiceProviderApp", null);
    if (providerApp == null || "".equals(providerApp)) {
        pgpClipperEnabledCheckbox.setEnabled(false);
        pgpClipperEnabledCheckbox.setChecked(false);
        stopService(new Intent(PGPClipperSettingsActivity.this, PGPClipperService.class));
    } else {
        if (pgpClipperEnabledCheckbox.isChecked()) {
            startService(new Intent(PGPClipperSettingsActivity.this, PGPClipperService.class));
        }
        pgpClipperEnabledCheckbox.setEnabled(true);
    }

    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) // Fingerprint API not supported below M
        fingerprintCheckboxPreference.setEnabled(false);
    else {
        fingerprintCheckboxPreference.setEnabled(true);
        }


}