Search in sources :

Example 11 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory 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 12 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory 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 13 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project wire-android by wireapp.

the class DeviceDetailPreferences method updateOtrClientDetails.

private void updateOtrClientDetails() {
    // Name
    Preference preference = findPreference(getString(R.string.pref_device_details_device_key));
    preference.setTitle(DevicesPreferencesUtil.getTitle(getActivity(), otrClient));
    preference.setSummary(DevicesPreferencesUtil.getSummary(getActivity(), otrClient, true));
    // Fingerprint
    final FingerprintPreference fingerPrintPreference = (FingerprintPreference) findPreference(getString(R.string.pref_device_details_fingerprint_key));
    if (fingerprint == null) {
        fingerprint = otrClient.getFingerprint();
        fingerprintSubscription = fingerprint.subscribe(new Subscriber<Fingerprint>() {

            @Override
            public void next(Fingerprint fingerprint) {
                fingerPrintPreference.setFingerprint(fingerprint);
            }
        });
    }
    //Trust
    final SwitchPreference verifySwitchPreference = (SwitchPreference) findPreference(getString(R.string.pref_device_details_trust_key));
    if (currentDevice) {
        PreferenceCategory group = (PreferenceCategory) findPreference(getString(R.string.pref_device_details_fingerprint_category_key));
        group.removePreference(verifySwitchPreference);
    } else {
        verifySwitchPreference.setChecked(otrClient.getVerified() == Verification.VERIFIED);
        // Note: Using OnPreferenceClickListener as it was some issues with getting
        //       OnPreferenceChangeListener to work.
        verifySwitchPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                boolean newVerifiredValue = otrClient.getVerified() != Verification.VERIFIED;
                otrClient.setVerified(newVerifiredValue);
                verifySwitchPreference.setChecked(newVerifiredValue);
                trackVerified(newVerifiredValue);
                return true;
            }
        });
    }
    // Remove
    if (currentDevice) {
        Preference actionsPreference = findPreference(getString(R.string.pref_device_details_actions_category_key));
        PreferenceScreen screen = (PreferenceScreen) findPreference(getString(R.string.pref_device_details_screen_key));
        screen.removePreference(actionsPreference);
    } else {
        Preference resetSessionPreference = findPreference(getString(R.string.pref_device_details_reset_session_key));
        resetSessionPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                resetSession();
                return true;
            }
        });
        preference = findPreference(getString(R.string.pref_device_details_remove_key));
        preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new NetworkAction() {

                    @Override
                    public void execute(NetworkMode networkMode) {
                        if (getControllerFactory().getPasswordController().hasPassword()) {
                            deleteCurrentDevice();
                        } else {
                            showRemoveDeviceDialog();
                        }
                    }

                    @Override
                    public void onNoNetwork() {
                        ViewUtils.showAlertDialog(DeviceDetailPreferences.this.getActivity(), R.string.otr__remove_device__no_internet__title, R.string.otr__remove_device__no_internet__message, R.string.otr__remove_device__no_internet__button, null, true);
                    }
                });
                return true;
            }
        });
    }
}
Also used : Fingerprint(com.waz.api.Fingerprint) PreferenceScreen(android.support.v7.preference.PreferenceScreen) SwitchPreference(net.xpece.android.support.preference.SwitchPreference) Preference(android.support.v7.preference.Preference) Subscriber(com.waz.api.Subscriber) SwitchPreference(net.xpece.android.support.preference.SwitchPreference) PreferenceCategory(net.xpece.android.support.preference.PreferenceCategory) NetworkMode(com.waz.api.NetworkMode) NetworkAction(com.waz.zclient.core.stores.network.NetworkAction)

Example 14 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project frostwire by frostwire.

the class ApplicationFragment method setupStore.

private void setupStore(long purchaseTimestamp) {
    Preference p = findPreference("frostwire.prefs.offers.buy_no_ads");
    if (p != null && !Constants.IS_GOOGLE_PLAY_DISTRIBUTION) {
        PreferenceCategory category = findPreference("frostwire.prefs.other_settings");
        category.removePreference(p);
    } else if (p != null) {
        PlayStore playStore = PlayStore.getInstance();
        playStore.refresh();
        Collection<Product> purchasedProducts = Products.listEnabled(playStore, Products.DISABLE_ADS_FEATURE);
        if (purchaseTimestamp == 0 && purchasedProducts != null && purchasedProducts.size() > 0) {
            initRemoveAdsSummaryWithPurchaseInfo(p, purchasedProducts);
        // otherwise, a BuyActivity intent has been configured on application_preferences.xml
        } else if (purchaseTimestamp > 0 && (System.currentTimeMillis() - purchaseTimestamp) < 30000) {
            p.setSummary(getString(R.string.processing_payment) + "...");
            p.setOnPreferenceClickListener(null);
        } else {
            p.setSummary(R.string.remove_ads_description);
            p.setOnPreferenceClickListener(preference -> {
                PlayStore.getInstance().endAsync();
                Intent intent = new Intent(getActivity(), BuyActivity.class);
                startActivityForResult(intent, BuyActivity.PURCHASE_SUCCESSFUL_RESULT_CODE);
                return true;
            });
        }
    }
}
Also used : KitKatStoragePreference(com.frostwire.android.gui.views.preference.KitKatStoragePreference) Preference(android.support.v7.preference.Preference) PreferenceCategory(android.support.v7.preference.PreferenceCategory) Collection(java.util.Collection) Intent(android.content.Intent) PlayStore(com.frostwire.android.offers.PlayStore)

Example 15 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project frostwire by frostwire.

the class ApplicationFragment method setupStorageOption.

private void setupStorageOption() {
    // intentional repetition of preference value here
    String kitkatKey = "frostwire.prefs.storage.path";
    String lollipopKey = "frostwire.prefs.storage.path_asf";
    PreferenceCategory category = findPreference("frostwire.prefs.general");
    if (AndroidPlatform.saf()) {
        // make sure this won't be saved for kitkat
        Preference p = findPreference(kitkatKey);
        if (p != null) {
            category.removePreference(p);
        }
        p = findPreference(lollipopKey);
        if (p != null) {
            p.setOnPreferenceChangeListener((preference, newValue) -> {
                updateStorageOptionSummary(newValue.toString());
                return true;
            });
            updateStorageOptionSummary(ConfigurationManager.instance().getStoragePath());
        }
    } else {
        Preference p = findPreference(lollipopKey);
        if (p != null) {
            category.removePreference(p);
        }
    }
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) KitKatStoragePreference(com.frostwire.android.gui.views.preference.KitKatStoragePreference) Preference(android.support.v7.preference.Preference)

Aggregations

PreferenceCategory (android.support.v7.preference.PreferenceCategory)166 Preference (android.support.v7.preference.Preference)105 PreferenceScreen (android.support.v7.preference.PreferenceScreen)75 Intent (android.content.Intent)35 Context (android.content.Context)34 SwitchPreference (android.support.v14.preference.SwitchPreference)31 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)27 ArrayList (java.util.ArrayList)24 ComponentName (android.content.ComponentName)22 ListPreference (android.support.v7.preference.ListPreference)18 Bundle (android.os.Bundle)16 PreferenceGroup (android.support.v7.preference.PreferenceGroup)14 DimmableIconPreference (com.android.settings.DimmableIconPreference)14 ContentResolver (android.content.ContentResolver)13 LayoutPreference (com.android.settings.applications.LayoutPreference)13 PreferenceManager (android.support.v7.preference.PreferenceManager)12 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)12 FooterPreference (com.android.settingslib.widget.FooterPreference)12 Test (org.junit.Test)12 Activity (android.app.Activity)9