Search in sources :

Example 56 with PreferenceCategory

use of android.preference.PreferenceCategory in project PhoneProfiles by henrichg.

the class PreferenceFragment method getAllPreferenceScreen.

private ArrayList<Preference> getAllPreferenceScreen(Preference p, ArrayList<Preference> list) {
    if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
        PreferenceGroup pGroup = (PreferenceGroup) p;
        int pCount = pGroup.getPreferenceCount();
        if (p instanceof PreferenceScreen) {
            list.add(p);
        }
        for (int i = 0; i < pCount; i++) {
            getAllPreferenceScreen(pGroup.getPreference(i), list);
        }
    }
    return list;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) PreferenceCategory(android.preference.PreferenceCategory) PreferenceGroup(android.preference.PreferenceGroup)

Example 57 with PreferenceCategory

use of android.preference.PreferenceCategory in project android_packages_apps_Snap by LineageOS.

the class SettingsActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
    Window window = getWindow();
    window.setFlags(flag, flag);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(getResources().getString(R.string.settings_title));
    }
    final boolean isSecureCamera = getIntent().getBooleanExtra(CameraUtil.KEY_IS_SECURE_CAMERA, false);
    if (isSecureCamera) {
        setShowInLockScreen();
    }
    mSettingsManager = SettingsManager.getInstance();
    if (mSettingsManager == null) {
        finish();
        return;
    }
    mSettingsManager.registerListener(mListener);
    addPreferencesFromResource(R.xml.setting_menu_preferences);
    mSharedPreferences = getPreferenceManager().getSharedPreferences();
    mDeveloperMenuEnabled = mSharedPreferences.getBoolean(SettingsManager.KEY_DEVELOPER_MENU, false);
    filterPreferences();
    initializePreferences();
    mSharedPreferences.registerOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener);
    for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
        PreferenceCategory category = (PreferenceCategory) getPreferenceScreen().getPreference(i);
        for (int j = 0; j < category.getPreferenceCount(); j++) {
            Preference pref = category.getPreference(j);
            pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    if (!mDeveloperMenuEnabled) {
                        if (preference.getKey().equals("version_info")) {
                            privateCounter++;
                            if (privateCounter >= DEVELOPER_MENU_TOUCH_COUNT) {
                                mDeveloperMenuEnabled = true;
                                mSharedPreferences.edit().putBoolean(SettingsManager.KEY_DEVELOPER_MENU, true).apply();
                                Toast.makeText(SettingsActivity.this, "Camera developer option is enabled now", Toast.LENGTH_SHORT).show();
                                recreate();
                            }
                        } else {
                            privateCounter = 0;
                        }
                    }
                    if (preference.getKey().equals(SettingsManager.KEY_RESTORE_DEFAULT)) {
                        onRestoreDefaultSettingsClick();
                    }
                    return false;
                }
            });
        }
    }
}
Also used : Window(android.view.Window) PreferenceCategory(android.preference.PreferenceCategory) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) ActionBar(android.app.ActionBar)

Example 58 with PreferenceCategory

use of android.preference.PreferenceCategory in project MaxLock by Maxr1998.

the class MaxLockPreferenceFragment method onCreate.

@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);
    }
    if (SDK_INT < Build.VERSION_CODES.N)
        getPreferenceManager().setSharedPreferencesMode(Context.MODE_WORLD_READABLE);
    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:
            // Intika I.Mod - Pro setup
            Preference iModDelayGlobal = findPreference(Common.ENABLE_IMOD_DELAY_GLOBAL);
            Preference iModDelayPerApp = findPreference(Common.ENABLE_IMOD_DELAY_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;
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) CheckBoxPreference(android.preference.CheckBoxPreference) ImplementationPreference(de.Maxr1998.xposed.maxlock.preference.ImplementationPreference) TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) FingerprintManagerCompat(android.support.v4.hardware.fingerprint.FingerprintManagerCompat) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) ListPreference(android.preference.ListPreference) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) File(java.io.File) SuppressLint(android.annotation.SuppressLint)

Example 59 with PreferenceCategory

use of android.preference.PreferenceCategory in project fdroidclient by f-droid.

the class PreferencesFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    useTorCheckPref = (CheckBoxPreference) findPreference(Preferences.PREF_USE_TOR);
    enableProxyCheckPref = (CheckBoxPreference) findPreference(Preferences.PREF_ENABLE_PROXY);
    updateAutoDownloadPref = findPreference(Preferences.PREF_AUTO_DOWNLOAD_INSTALL_UPDATES);
    updatePrivilegedExtensionPref = findPreference(Preferences.PREF_UNINSTALL_PRIVILEGED_APP);
    AppCompatListPreference languagePref = (AppCompatListPreference) findPreference(Preferences.PREF_LANGUAGE);
    if (Build.VERSION.SDK_INT >= 24) {
        PreferenceCategory category = (PreferenceCategory) findPreference("pref_category_display");
        category.removePreference(languagePref);
    } else {
        Languages languages = Languages.get(getActivity());
        languagePref.setDefaultValue(Languages.USE_SYSTEM_DEFAULT);
        languagePref.setEntries(languages.getAllNames());
        languagePref.setEntryValues(languages.getSupportedLocales());
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) Languages(org.fdroid.fdroid.Languages) AppCompatListPreference(com.geecko.QuickLyric.view.AppCompatListPreference)

Example 60 with PreferenceCategory

use of android.preference.PreferenceCategory in project android_packages_apps_Settings by LineageOS.

the class SecuritySettings method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    PreferenceScreen root = this.getPreferenceScreen();
    if (root != null) {
        root.removeAll();
    }
    addPreferencesFromResource(R.xml.security_settings);
    root = this.getPreferenceScreen();
    mNetwork = (CheckBoxPreference) getPreferenceScreen().findPreference(LOCATION_NETWORK);
    mGps = (CheckBoxPreference) getPreferenceScreen().findPreference(LOCATION_GPS);
    mAssistedGps = (CheckBoxPreference) getPreferenceScreen().findPreference(ASSISTED_GPS);
    PreferenceManager pm = getPreferenceManager();
    // Lock screen
    if (!mLockPatternUtils.isSecure()) {
        addPreferencesFromResource(R.xml.security_settings_chooser);
    } else {
        switch(mLockPatternUtils.getKeyguardStoredPasswordQuality()) {
            case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
                addPreferencesFromResource(R.xml.security_settings_pattern);
                break;
            case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
                addPreferencesFromResource(R.xml.security_settings_pin);
                break;
            case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
            case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
                addPreferencesFromResource(R.xml.security_settings_password);
                break;
        }
    }
    // set or change current. Should be common to all unlock preference screens
    // mSetOrChange = (PreferenceScreen) pm.findPreference(KEY_UNLOCK_SET_OR_CHANGE);
    // visible pattern
    mVisiblePattern = (CheckBoxPreference) pm.findPreference(KEY_VISIBLE_PATTERN);
    // tactile feedback. Should be common to all unlock preference screens.
    mTactileFeedback = (CheckBoxPreference) pm.findPreference(KEY_TACTILE_FEEDBACK_ENABLED);
    mVisibleDots = (CheckBoxPreference) pm.findPreference(KEY_VISIBLE_DOTS);
    mShowErrorPath = (CheckBoxPreference) pm.findPreference(KEY_SHOW_ERROR_PATH);
    mShowCustomMsg = (CheckBoxPreference) pm.findPreference(KEY_SHOW_CUSTOM_MSG);
    mCustomMsg = (EditTextPreference) pm.findPreference(KEY_CUSTOM_MSG);
    mCustomMsgColor = pm.findPreference(KEY_CUSTOM_MSG_COLOR);
    mShowUnlockMsg = (CheckBoxPreference) pm.findPreference(KEY_SHOW_UNLOCK_MSG);
    mShowUnlockErrMsg = (CheckBoxPreference) pm.findPreference(KEY_SHOW_UNLOCK_ERR_MSG);
    mIncorrectDelay = (ListPreference) pm.findPreference(KEY_INCORRECT_DELAY);
    int activePhoneType = TelephonyManager.getDefault().getPhoneType();
    // do not display SIM lock for CDMA phone
    if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) {
        PreferenceScreen simLockPreferences = getPreferenceManager().createPreferenceScreen(this);
        simLockPreferences.setTitle(R.string.sim_lock_settings_category);
        // Intent to launch SIM lock settings
        simLockPreferences.setIntent(new Intent().setClassName(PACKAGE, ICC_LOCK_SETTINGS));
        PreferenceCategory simLockCat = new PreferenceCategory(this);
        simLockCat.setTitle(R.string.sim_lock_settings_title);
        root.addPreference(simLockCat);
        simLockCat.addPreference(simLockPreferences);
    }
    // Passwords
    PreferenceCategory passwordsCat = new PreferenceCategory(this);
    passwordsCat.setTitle(R.string.security_passwords_title);
    root.addPreference(passwordsCat);
    CheckBoxPreference showPassword = mShowPassword = new CheckBoxPreference(this);
    showPassword.setKey("show_password");
    showPassword.setTitle(R.string.show_password);
    showPassword.setSummary(R.string.show_password_summary);
    showPassword.setPersistent(false);
    passwordsCat.addPreference(showPassword);
    // Device policies
    PreferenceCategory devicePoliciesCat = new PreferenceCategory(this);
    devicePoliciesCat.setTitle(R.string.device_admin_title);
    root.addPreference(devicePoliciesCat);
    Preference deviceAdminButton = new Preference(this);
    deviceAdminButton.setTitle(R.string.manage_device_admin);
    deviceAdminButton.setSummary(R.string.manage_device_admin_summary);
    Intent deviceAdminIntent = new Intent();
    deviceAdminIntent.setClass(this, DeviceAdminSettings.class);
    deviceAdminButton.setIntent(deviceAdminIntent);
    devicePoliciesCat.addPreference(deviceAdminButton);
    // Credential storage
    PreferenceCategory credentialsCat = new PreferenceCategory(this);
    credentialsCat.setTitle(R.string.credentials_category);
    root.addPreference(credentialsCat);
    mCredentialStorage.createPreferences(credentialsCat, CredentialStorage.TYPE_KEYSTORE);
    return root;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) Intent(android.content.Intent) PreferenceManager(android.preference.PreferenceManager)

Aggregations

PreferenceCategory (android.preference.PreferenceCategory)80 Preference (android.preference.Preference)49 PreferenceScreen (android.preference.PreferenceScreen)31 ListPreference (android.preference.ListPreference)30 CheckBoxPreference (android.preference.CheckBoxPreference)26 Intent (android.content.Intent)19 EditTextPreference (android.preference.EditTextPreference)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)8 SwitchPreference (android.preference.SwitchPreference)8 ArrayList (java.util.ArrayList)7 Uri (android.net.Uri)6 Bundle (android.os.Bundle)5 SharedPreferences (android.content.SharedPreferences)4 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)4 View (android.view.View)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 Context (android.content.Context)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)3 RingtonePreference (android.preference.RingtonePreference)3 ListView (android.widget.ListView)3