Search in sources :

Example 6 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TtsEngineSettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.tts_engine_settings);
    mEnginesHelper = new TtsEngines(getActivity());
    final PreferenceScreen root = getPreferenceScreen();
    mLocalePreference = (ListPreference) root.findPreference(KEY_ENGINE_LOCALE);
    mLocalePreference.setOnPreferenceChangeListener(this);
    mEngineSettingsPreference = root.findPreference(KEY_ENGINE_SETTINGS);
    mEngineSettingsPreference.setOnPreferenceClickListener(this);
    mInstallVoicesPreference = root.findPreference(KEY_INSTALL_DATA);
    mInstallVoicesPreference.setOnPreferenceClickListener(this);
    root.setTitle(getEngineLabel());
    root.setKey(getEngineName());
    mEngineSettingsPreference.setTitle(getResources().getString(R.string.tts_engine_settings_title, getEngineLabel()));
    mEngineSettingsIntent = mEnginesHelper.getSettingsIntent(getEngineName());
    if (mEngineSettingsIntent == null) {
        mEngineSettingsPreference.setEnabled(false);
    }
    mInstallVoicesPreference.setEnabled(false);
    if (savedInstanceState == null) {
        mLocalePreference.setEnabled(false);
        mLocalePreference.setEntries(new CharSequence[0]);
        mLocalePreference.setEntryValues(new CharSequence[0]);
    } else {
        // Repopulate mLocalePreference with saved state. Will be updated later with
        // up-to-date values when checkTtsData() calls back with results.
        final CharSequence[] entries = savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRIES);
        final CharSequence[] entryValues = savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRY_VALUES);
        final CharSequence value = savedInstanceState.getCharSequence(STATE_KEY_LOCALE_VALUE);
        mLocalePreference.setEntries(entries);
        mLocalePreference.setEntryValues(entryValues);
        mLocalePreference.setValue(value != null ? value.toString() : null);
        mLocalePreference.setEnabled(entries.length > 0);
    }
    mVoiceDataDetails = getArguments().getParcelable(TtsEnginePreference.FRAGMENT_ARGS_VOICES);
    mTts = new TextToSpeech(getActivity().getApplicationContext(), mTtsInitListener, getEngineName());
    // Check if data packs changed
    checkTtsData();
    getActivity().registerReceiver(mLanguagesChangedReceiver, new IntentFilter(TextToSpeech.Engine.ACTION_TTS_DATA_INSTALLED));
}
Also used : IntentFilter(android.content.IntentFilter) PreferenceScreen(android.support.v7.preference.PreferenceScreen) TtsEngines(android.speech.tts.TtsEngines) TextToSpeech(android.speech.tts.TextToSpeech)

Example 7 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PrivacySettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Don't allow any access if this is not an admin user.
    // TODO: backup/restore currently only works with owner user b/22760572
    mEnabled = UserManager.get(getActivity()).isAdminUser();
    if (!mEnabled) {
        return;
    }
    addPreferencesFromResource(R.xml.privacy_settings);
    final PreferenceScreen screen = getPreferenceScreen();
    mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    mBackup = (PreferenceScreen) screen.findPreference(BACKUP_DATA);
    mAutoRestore = (SwitchPreference) screen.findPreference(AUTO_RESTORE);
    mAutoRestore.setOnPreferenceChangeListener(preferenceChangeListener);
    mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
    mManageData = (PreferenceScreen) screen.findPreference(DATA_MANAGEMENT);
    Set<String> keysToRemove = new HashSet<>();
    getNonVisibleKeys(getActivity(), keysToRemove);
    final int screenPreferenceCount = screen.getPreferenceCount();
    for (int i = screenPreferenceCount - 1; i >= 0; --i) {
        Preference preference = screen.getPreference(i);
        if (keysToRemove.contains(preference.getKey())) {
            screen.removePreference(preference);
        }
    }
    updateToggles();
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) RestrictedPreference(com.android.settingslib.RestrictedPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) HashSet(java.util.HashSet)

Example 8 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccountSettings method cleanUpPreferences.

private void cleanUpPreferences() {
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    if (preferenceScreen != null) {
        preferenceScreen.removeAll();
    }
    mProfiles.clear();
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Example 9 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccountSettings method updateUi.

void updateUi() {
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.account_settings);
    if (Utils.isManagedProfile(mUm)) {
        // This should not happen
        Log.e(TAG, "We should not be showing settings for a managed profile");
        finish();
        return;
    }
    final PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference(KEY_ACCOUNT);
    if (mUm.isLinkedUser()) {
        // Restricted user or similar
        UserInfo userInfo = mUm.getUserInfo(UserHandle.myUserId());
        updateProfileUi(userInfo, false, /* no category needed */
        preferenceScreen);
    } else {
        List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
        final int profilesCount = profiles.size();
        final boolean addCategory = profilesCount > 1;
        for (int i = 0; i < profilesCount; i++) {
            updateProfileUi(profiles.get(i), addCategory, preferenceScreen);
        }
    }
    // Add all preferences, starting with one for the primary profile.
    // Note that we're relying on the ordering given by the SparseArray keys, and on the
    // value of UserHandle.USER_OWNER being smaller than all the rest.
    final int profilesCount = mProfiles.size();
    for (int i = 0; i < profilesCount; i++) {
        ProfileData profileData = mProfiles.valueAt(i);
        if (!profileData.preferenceGroup.equals(preferenceScreen)) {
            preferenceScreen.addPreference(profileData.preferenceGroup);
        }
        updateAccountTypes(profileData);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) UserInfo(android.content.pm.UserInfo)

Example 10 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ManageDomainUrls method onRebuildComplete.

@Override
public void onRebuildComplete(ArrayList<AppEntry> apps) {
    if (getContext() == null) {
        return;
    }
    final boolean disableWebActions = Global.getInt(getContext().getContentResolver(), Global.ENABLE_EPHEMERAL_FEATURE, 1) == 0;
    if (disableWebActions) {
        mDomainAppList = getPreferenceScreen();
    } else {
        final PreferenceGroup preferenceScreen = getPreferenceScreen();
        if (preferenceScreen.getPreferenceCount() == 0) {
            // add preferences
            final PreferenceCategory webActionCategory = new PreferenceCategory(getPrefContext());
            webActionCategory.setTitle(R.string.web_action_section_title);
            preferenceScreen.addPreference(webActionCategory);
            // toggle to enable / disable Web Actions [aka Instant Apps]
            mWebAction = new SwitchPreference(getPrefContext());
            mWebAction.setTitle(R.string.web_action_enable_title);
            mWebAction.setSummary(R.string.web_action_enable_summary);
            mWebAction.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.WEB_ACTION_ENABLED, 1) != 0);
            mWebAction.setOnPreferenceChangeListener(this);
            webActionCategory.addPreference(mWebAction);
            // list to manage link handling per app
            mDomainAppList = new PreferenceCategory(getPrefContext());
            mDomainAppList.setTitle(R.string.domain_url_section_title);
            preferenceScreen.addPreference(mDomainAppList);
        }
    }
    rebuildAppList(mDomainAppList, apps);
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) SwitchPreference(android.support.v14.preference.SwitchPreference) PreferenceGroup(android.support.v7.preference.PreferenceGroup)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)640 Preference (android.support.v7.preference.Preference)458 Context (android.content.Context)127 Test (org.junit.Test)126 SwitchPreference (android.support.v14.preference.SwitchPreference)96 PreferenceCategory (android.support.v7.preference.PreferenceCategory)82 Intent (android.content.Intent)63 PreferenceGroup (android.support.v7.preference.PreferenceGroup)58 VisibleForTesting (android.support.annotation.VisibleForTesting)55 PreferenceManager (android.support.v7.preference.PreferenceManager)54 ContentResolver (android.content.ContentResolver)53 PackageManager (android.content.pm.PackageManager)51 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)48 Bundle (android.os.Bundle)46 ArrayList (java.util.ArrayList)46 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)44 ListPreference (android.support.v7.preference.ListPreference)41 ComponentName (android.content.ComponentName)31 Resources (android.content.res.Resources)30 VolumeInfo (android.os.storage.VolumeInfo)30