Search in sources :

Example 76 with PreferenceCategory

use of android.preference.PreferenceCategory in project Jota-Text-Editor-old by jiro-aqua.

the class SettingsShortcutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPm = getPreferenceManager();
    mPs = mPm.createPreferenceScreen(this);
    // Category
    final PreferenceCategory category = new PreferenceCategory(this);
    category.setTitle(R.string.label_customize_shortcut);
    mPs.addPreference(category);
    for (DefineShortcut sd : TBL_SHORTCUT) {
        if (sd.show) {
            final CheckBoxPreference pr = new CheckBoxPreference(this);
            pr.setKey(KEY_SHORTCUT + sd.key);
            pr.setTitle(sd.name);
            pr.setSummary(getFunctionName(sd.function));
            category.addPreference(pr);
        }
    }
    setPreferenceScreen(mPs);
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference)

Example 77 with PreferenceCategory

use of android.preference.PreferenceCategory in project android_packages_apps_DSPManager by CyanogenMod.

the class WM8994 method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.wm8994_preferences);
    PreferenceScreen prefSet = getPreferenceScreen();
    for (int i = 0; i < OPTION_CONTROLS.length; i++) {
        String fileName = OPTION_CONTROLS[i][0];
        mPreferences[i] = (CheckBoxPreference) prefSet.findPreference(OPTION_CONTROLS[i][1]);
        if (Utils.fileExists(fileName)) {
            mPreferences[i].setChecked(PREF_ENABLED.equals(Utils.readOneLine(fileName)));
            mPreferences[i].setOnPreferenceChangeListener(this);
        } else {
            mPreferences[i].setSummary(R.string.pref_unavailable);
            mPreferences[i].setEnabled(false);
        }
    }
    if (Utils.fileExists(HeadsetAmplifierPreference.FILE_PATH)) {
        prefSet.findPreference("headphone_amp").setOnPreferenceChangeListener(this);
    } else {
        Preference category = prefSet.findPreference("wm8994_headphone_amp_category");
        prefSet.removePreference(category);
    }
    if (Utils.fileExists(MIC_REC_PRESET[0][0])) {
        prefSet.findPreference(MIC_REC_PRESET[0][1]).setOnPreferenceChangeListener(this);
    } else {
        Preference category = prefSet.findPreference("wm8994_microphone_recording_category");
        prefSet.removePreference(category);
    }
    Preference bassBoostPreset = prefSet.findPreference(BASS_BOOST_PRESET_PREF);
    Preference bassBoostGainRange = prefSet.findPreference(BASS_BOOST_GAIN_RANGE_PREF);
    if (Utils.fileExists(BASS_BOOST_ENABLE_FILE)) {
        bassBoostPreset.setOnPreferenceChangeListener(this);
        bassBoostGainRange.setOnPreferenceChangeListener(this);
    } else {
        PreferenceCategory bassBoostCategory = (PreferenceCategory) prefSet.findPreference("wm8994_signal_processing_category");
        bassBoostCategory.removePreference(bassBoostPreset);
        bassBoostCategory.removePreference(bassBoostGainRange);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) BassBoostPreference(com.bel.android.dspmanager.preference.BassBoostPreference) Preference(android.preference.Preference) HeadsetAmplifierPreference(com.bel.android.dspmanager.preference.HeadsetAmplifierPreference) PreferenceCategory(android.preference.PreferenceCategory)

Example 78 with PreferenceCategory

use of android.preference.PreferenceCategory in project android by nextcloud.

the class SettingsActivity method setupMoreCategory.

private void setupMoreCategory(int accentColor) {
    PreferenceCategory preferenceCategoryMore = (PreferenceCategory) findPreference("more");
    preferenceCategoryMore.setTitle(ThemeTextUtils.getColoredTitle(getString(R.string.prefs_category_more), accentColor));
    setupAutoUploadPreference(preferenceCategoryMore);
    setupCalendarPreference(preferenceCategoryMore);
    setupBackupPreference();
    setupE2EMnemonicPreference(preferenceCategoryMore);
    setupHelpPreference(preferenceCategoryMore);
    setupRecommendPreference(preferenceCategoryMore);
    setupLoggingPreference(preferenceCategoryMore);
    setupImprintPreference(preferenceCategoryMore);
    loadExternalSettingLinks(preferenceCategoryMore);
}
Also used : PreferenceCategory(android.preference.PreferenceCategory)

Example 79 with PreferenceCategory

use of android.preference.PreferenceCategory in project android by nextcloud.

the class SettingsActivity method setupDetailsCategory.

private void setupDetailsCategory(int accentColor, PreferenceScreen preferenceScreen) {
    PreferenceCategory preferenceCategoryDetails = (PreferenceCategory) findPreference("details");
    preferenceCategoryDetails.setTitle(ThemeTextUtils.getColoredTitle(getString(R.string.prefs_category_details), accentColor));
    boolean fPassCodeEnabled = getResources().getBoolean(R.bool.passcode_enabled);
    boolean fDeviceCredentialsEnabled = getResources().getBoolean(R.bool.device_credentials_enabled);
    boolean fShowHiddenFilesEnabled = getResources().getBoolean(R.bool.show_hidden_files_enabled);
    boolean fSyncedFolderLightEnabled = getResources().getBoolean(R.bool.syncedFolder_light);
    boolean fShowMediaScanNotifications = preferences.isShowMediaScanNotifications();
    setupLockPreference(preferenceCategoryDetails, fPassCodeEnabled, fDeviceCredentialsEnabled);
    setupHiddenFilesPreference(preferenceCategoryDetails, fShowHiddenFilesEnabled);
    setupShowMediaScanNotifications(preferenceCategoryDetails, fShowMediaScanNotifications);
    if (!fPassCodeEnabled && !fDeviceCredentialsEnabled && !fShowHiddenFilesEnabled && fSyncedFolderLightEnabled && fShowMediaScanNotifications) {
        preferenceScreen.removePreference(preferenceCategoryDetails);
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory)

Example 80 with PreferenceCategory

use of android.preference.PreferenceCategory in project android by nextcloud.

the class SettingsActivity method setupGeneralCategory.

private void setupGeneralCategory(int accentColor) {
    PreferenceCategory preferenceCategoryGeneral = (PreferenceCategory) findPreference("general");
    preferenceCategoryGeneral.setTitle(ThemeTextUtils.getColoredTitle(getString(R.string.prefs_category_general), accentColor));
    prefStoragePath = (ListPreference) findPreference(AppPreferencesImpl.STORAGE_PATH);
    if (prefStoragePath != null) {
        StoragePoint[] storageOptions = DataStorageProvider.getInstance().getAvailableStoragePoints();
        String[] entries = new String[storageOptions.length];
        String[] values = new String[storageOptions.length];
        for (int i = 0; i < storageOptions.length; ++i) {
            entries[i] = storageOptions[i].getDescription();
            values[i] = storageOptions[i].getPath();
        }
        prefStoragePath.setEntries(entries);
        prefStoragePath.setEntryValues(values);
        prefStoragePath.setOnPreferenceChangeListener((preference, newValue) -> {
            String newPath = (String) newValue;
            if (storagePath.equals(newPath)) {
                return true;
            }
            StorageMigration storageMigration = new StorageMigration(this, user, storagePath, newPath);
            storageMigration.setStorageMigrationProgressListener(this);
            storageMigration.migrate();
            return false;
        });
    }
    loadStoragePath();
    ListPreference themePref = (ListPreference) findPreference("darkMode");
    List<String> themeEntries = new ArrayList<>(3);
    themeEntries.add(getString(R.string.prefs_value_theme_light));
    themeEntries.add(getString(R.string.prefs_value_theme_dark));
    themeEntries.add(getString(R.string.prefs_value_theme_system));
    List<String> themeValues = new ArrayList<>(3);
    themeValues.add(DarkMode.LIGHT.name());
    themeValues.add(DarkMode.DARK.name());
    themeValues.add(DarkMode.SYSTEM.name());
    themePref.setEntries(themeEntries.toArray(new String[0]));
    themePref.setEntryValues(themeValues.toArray(new String[0]));
    if (TextUtils.isEmpty(themePref.getEntry())) {
        themePref.setValue(DarkMode.SYSTEM.name());
        themePref.setSummary(TextUtils.isEmpty(themePref.getEntry()) ? DarkMode.SYSTEM.name() : themePref.getEntry());
    }
    themePref.setOnPreferenceChangeListener((preference, newValue) -> {
        DarkMode mode = DarkMode.valueOf((String) newValue);
        preferences.setDarkThemeMode(mode);
        MainApp.setAppTheme(mode);
        return true;
    });
}
Also used : DarkMode(com.nextcloud.client.preferences.DarkMode) PreferenceCategory(android.preference.PreferenceCategory) StoragePoint(com.owncloud.android.datastorage.StoragePoint) ArrayList(java.util.ArrayList) ListPreference(android.preference.ListPreference) StoragePoint(com.owncloud.android.datastorage.StoragePoint)

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