Search in sources :

Example 66 with Preference

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

the class InstalledAppDetails method addAppInstallerInfoPref.

private void addAppInstallerInfoPref(PreferenceScreen screen) {
    String installerPackageName = null;
    try {
        installerPackageName = getContext().getPackageManager().getInstallerPackageName(mPackageName);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "Exception while retrieving the package installer of " + mPackageName, e);
    }
    if (installerPackageName == null) {
        return;
    }
    final CharSequence installerLabel = Utils.getApplicationLabel(getContext(), installerPackageName);
    if (installerLabel == null) {
        return;
    }
    PreferenceCategory category = new PreferenceCategory(getPrefContext());
    category.setTitle(R.string.app_install_details_group_title);
    screen.addPreference(category);
    Preference pref = new Preference(getPrefContext());
    pref.setTitle(R.string.app_install_details_title);
    pref.setKey("app_info_store");
    pref.setSummary(getString(R.string.app_install_details_summary, installerLabel));
    final Intent intent = new Intent(Intent.ACTION_SHOW_APP_INFO).setPackage(installerPackageName);
    final Intent result = resolveIntent(intent);
    if (result != null) {
        result.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackageName);
        pref.setIntent(result);
    } else {
        pref.setEnabled(false);
    }
    category.addPreference(pref);
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent)

Example 67 with Preference

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

the class InputMethodAndLanguageSettings method onResume.

@Override
public void onResume() {
    super.onResume();
    mSettingsObserver.resume();
    mIm.registerInputDeviceListener(this, null);
    final Preference spellChecker = findPreference(KEY_SPELL_CHECKERS);
    if (spellChecker != null) {
        final TextServicesManager tsm = (TextServicesManager) getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
        if (!tsm.isSpellCheckerEnabled()) {
            spellChecker.setSummary(R.string.switch_off_text);
        } else {
            final SpellCheckerInfo sci = tsm.getCurrentSpellChecker();
            if (sci != null) {
                spellChecker.setSummary(sci.loadLabel(getPackageManager()));
            } else {
                spellChecker.setSummary(R.string.spell_checker_not_selected);
            }
        }
    }
    if (!mShowsOnlyFullImeAndKeyboardList) {
        if (mLanguagePref != null) {
            String localeNames = getLocaleNames(getActivity());
            mLanguagePref.setSummary(localeNames);
        }
        updateUserDictionaryPreference(findPreference(KEY_USER_DICTIONARY_SETTINGS));
        if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
            mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
        }
    }
    updateInputDevices();
    // Refresh internal states in mInputMethodSettingValues to keep the latest
    // "InputMethodInfo"s and "InputMethodSubtype"s
    mInputMethodSettingValues.refreshAllInputMethodAndSubtypes();
    updateInputMethodPreferenceViews();
}
Also used : ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) TextServicesManager(android.view.textservice.TextServicesManager) SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 68 with Preference

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

the class InputMethodAndSubtypeEnabler method updateImplicitlyEnabledSubtypesOf.

private void updateImplicitlyEnabledSubtypesOf(final InputMethodInfo imi, final boolean check) {
    final String imiId = imi.getId();
    final List<Preference> subtypePrefs = mInputMethodAndSubtypePrefsMap.get(imiId);
    final List<InputMethodSubtype> implicitlyEnabledSubtypes = mImm.getEnabledInputMethodSubtypeList(imi, true);
    if (subtypePrefs == null || implicitlyEnabledSubtypes == null) {
        return;
    }
    for (final Preference pref : subtypePrefs) {
        if (!(pref instanceof TwoStatePreference)) {
            continue;
        }
        final TwoStatePreference subtypePref = (TwoStatePreference) pref;
        subtypePref.setChecked(false);
        if (check) {
            for (final InputMethodSubtype subtype : implicitlyEnabledSubtypes) {
                final String implicitlyEnabledSubtypePrefKey = imiId + subtype.hashCode();
                if (subtypePref.getKey().equals(implicitlyEnabledSubtypePrefKey)) {
                    subtypePref.setChecked(true);
                    break;
                }
            }
        }
    }
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) TwoStatePreference(android.support.v7.preference.TwoStatePreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference)

Example 69 with Preference

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

the class InputMethodAndLanguageSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.language_settings);
    final Activity activity = getActivity();
    mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mInputMethodSettingValues = InputMethodSettingValuesWrapper.getInstance(activity);
    try {
        mDefaultInputMethodSelectorVisibility = Integer.valueOf(getString(R.string.input_method_selector_visibility_default_value));
    } catch (NumberFormatException e) {
    }
    if (activity.getAssets().getLocales().length == 1) {
        // No "Select language" pref if there's only one system locale available.
        getPreferenceScreen().removePreference(findPreference(KEY_PHONE_LANGUAGE));
    } else {
        mLanguagePref = findPreference(KEY_PHONE_LANGUAGE);
    }
    if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
        mShowInputMethodSelectorPref = (ListPreference) findPreference(KEY_INPUT_METHOD_SELECTOR);
        mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
        // TODO: Update current input method name on summary
        updateInputMethodSelectorSummary(loadInputMethodSelectorVisibility());
    }
    new VoiceInputOutputSettings(this).onCreate();
    // Get references to dynamically constructed categories.
    mHardKeyboardCategory = (PreferenceCategory) findPreference("hard_keyboard");
    mKeyboardSettingsCategory = (PreferenceCategory) findPreference("keyboard_settings_category");
    mGameControllerCategory = (PreferenceCategory) findPreference("game_controller_settings_category");
    final Intent startingIntent = activity.getIntent();
    // Filter out irrelevant features if invoked from IME settings button.
    mShowsOnlyFullImeAndKeyboardList = Settings.ACTION_INPUT_METHOD_SETTINGS.equals(startingIntent.getAction());
    if (mShowsOnlyFullImeAndKeyboardList) {
        getPreferenceScreen().removeAll();
        if (mHardKeyboardCategory != null) {
            getPreferenceScreen().addPreference(mHardKeyboardCategory);
        }
        if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
            getPreferenceScreen().addPreference(mShowInputMethodSelectorPref);
        }
        if (mKeyboardSettingsCategory != null) {
            mKeyboardSettingsCategory.removeAll();
            getPreferenceScreen().addPreference(mKeyboardSettingsCategory);
        }
    }
    // Build hard keyboard and game controller preference categories.
    mIm = (InputManager) activity.getSystemService(Context.INPUT_SERVICE);
    updateInputDevices();
    // Spell Checker
    final Preference spellChecker = findPreference(KEY_SPELL_CHECKERS);
    if (spellChecker != null) {
        // Note: KEY_SPELL_CHECKERS preference is marked as persistent="false" in XML.
        InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(spellChecker);
        final Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setClass(activity, SubSettings.class);
        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, SpellCheckersSettings.class.getName());
        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.spellcheckers_settings_title);
        spellChecker.setIntent(intent);
    }
    mHandler = new Handler();
    mSettingsObserver = new SettingsObserver(mHandler, activity);
    mDpm = (DevicePolicyManager) (getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE));
    // If we've launched from the keyboard layout notification, go ahead and just show the
    // keyboard layout dialog.
    final InputDeviceIdentifier identifier = startingIntent.getParcelableExtra(Settings.EXTRA_INPUT_DEVICE_IDENTIFIER);
    if (mShowsOnlyFullImeAndKeyboardList && identifier != null) {
        showKeyboardLayoutDialog(identifier);
    }
    updateCurrentImeName();
}
Also used : InputDeviceIdentifier(android.hardware.input.InputDeviceIdentifier) VoiceInputOutputSettings(com.android.settings.VoiceInputOutputSettings) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) SettingsActivity(com.android.settings.SettingsActivity) KeyboardLayoutPickerActivity(com.android.settings.Settings.KeyboardLayoutPickerActivity) Activity(android.app.Activity) Handler(android.os.Handler) Intent(android.content.Intent)

Example 70 with Preference

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

the class InputMethodAndLanguageSettings method updateUserDictionaryPreference.

private void updateUserDictionaryPreference(Preference userDictionaryPreference) {
    if (userDictionaryPreference == null) {
        return;
    }
    final Activity activity = getActivity();
    final TreeSet<String> localeSet = UserDictionaryList.getUserDictionaryLocalesSet(activity);
    if (null == localeSet) {
        // The locale list is null if and only if the user dictionary service is
        // not present or disabled. In this case we need to remove the preference.
        getPreferenceScreen().removePreference(userDictionaryPreference);
    } else {
        userDictionaryPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference arg0) {
                // Redirect to UserDictionarySettings if the user needs only one
                // language.
                final Bundle extras = new Bundle();
                final Class<? extends Fragment> targetFragment;
                if (localeSet.size() <= 1) {
                    if (!localeSet.isEmpty()) {
                        // If the size of localeList is 0, we don't set the locale
                        // parameter in the extras. This will be interpreted by the
                        // UserDictionarySettings class as meaning
                        // "the current locale". Note that with the current code for
                        // UserDictionaryList#getUserDictionaryLocalesSet()
                        // the locale list always has at least one element, since it
                        // always includes the current locale explicitly.
                        // @see UserDictionaryList.getUserDictionaryLocalesSet().
                        extras.putString("locale", localeSet.first());
                    }
                    targetFragment = UserDictionarySettings.class;
                } else {
                    targetFragment = UserDictionaryList.class;
                }
                startFragment(InputMethodAndLanguageSettings.this, targetFragment.getCanonicalName(), -1, -1, extras);
                return true;
            }
        });
    }
}
Also used : OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) UserDictionarySettings(com.android.settings.UserDictionarySettings) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) Bundle(android.os.Bundle) SettingsActivity(com.android.settings.SettingsActivity) KeyboardLayoutPickerActivity(com.android.settings.Settings.KeyboardLayoutPickerActivity) Activity(android.app.Activity) SettingsPreferenceFragment(com.android.settings.SettingsPreferenceFragment) Fragment(android.app.Fragment)

Aggregations

Preference (android.support.v7.preference.Preference)122 PreferenceScreen (android.support.v7.preference.PreferenceScreen)44 SwitchPreference (android.support.v14.preference.SwitchPreference)33 Intent (android.content.Intent)27 ListPreference (android.support.v7.preference.ListPreference)27 Context (android.content.Context)17 PreferenceCategory (android.support.v7.preference.PreferenceCategory)17 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)15 ArrayList (java.util.ArrayList)14 PackageManager (android.content.pm.PackageManager)11 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)11 PreferenceGroup (android.support.v7.preference.PreferenceGroup)11 TwoStatePreference (android.support.v7.preference.TwoStatePreference)11 Activity (android.app.Activity)10 View (android.view.View)10 Bundle (android.os.Bundle)9 TextView (android.widget.TextView)8 AlertDialog (android.support.v7.app.AlertDialog)7 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7