Search in sources :

Example 1 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project wire-android by wireapp.

the class ZetaPreferencesActivity method onPreferenceDisplayDialog.

@Override
public boolean onPreferenceDisplayDialog(PreferenceFragmentCompat preferenceFragmentCompat, Preference preference) {
    final String key = preference.getKey();
    final DialogFragment f;
    if (preference.getKey().equals(getString(R.string.pref_options_ringtones_ping_key)) || preference.getKey().equals(getString(R.string.pref_options_ringtones_text_key)) || preference.getKey().equals(getString(R.string.pref_options_ringtones_ringtone_key))) {
        final int defaultId = preference.getExtras().getInt(WireRingtonePreferenceDialogFragment.EXTRA_DEFAULT);
        f = WireRingtonePreferenceDialogFragment.newInstance(key, defaultId);
    } else {
        return false;
    }
    f.setTargetFragment(preferenceFragmentCompat, 0);
    f.show(getSupportFragmentManager(), key);
    return true;
}
Also used : WireRingtonePreferenceDialogFragment(com.waz.zclient.pages.main.profile.preferences.dialogs.WireRingtonePreferenceDialogFragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 2 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project TumCampusApp by TCA-Team.

the class UserPreferencesActivity method onPreferenceStartScreen.

@Override
public boolean onPreferenceStartScreen(PreferenceFragmentCompat preferenceFragmentCompat, PreferenceScreen preferenceScreen) {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    SettingsFragment fragment = new SettingsFragment();
    Bundle args = new Bundle();
    args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
    fragment.setArguments(args);
    ft.replace(R.id.settings_frame, fragment, preferenceScreen.getKey());
    ft.addToBackStack(preferenceScreen.getKey());
    ft.commit();
    return true;
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Bundle(android.os.Bundle)

Example 3 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project Douya by DreaminginCodeZH.

the class LicensesDialogPreference method onDisplayPreferenceDialog.

/**
     * Users should override {@link PreferenceFragmentCompat#onDisplayPreferenceDialog(Preference)}
     * and check the return value of this method, only call through to super implementation if
     * {@code false} is returned.
     *
     * @param preferenceFragment The preference fragment
     * @param preference The preference, as in
     * {@link PreferenceFragmentCompat#onDisplayPreferenceDialog(Preference)}
     * @return Whether the call has been handled by this method.
     */
public static boolean onDisplayPreferenceDialog(PreferenceFragmentCompat preferenceFragment, Preference preference) {
    if (preference instanceof LicensesDialogPreference) {
        // getChildFragmentManager() will lead to looking for target fragment in the child
        // fragment manager.
        FragmentManager fragmentManager = preferenceFragment.getFragmentManager();
        if (fragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG) == null) {
            LicensesDialogFragment dialogFragment = new LicensesDialogFragment.Builder(preferenceFragment.getActivity()).setNotices(R.raw.licenses).setUseAppCompat(true).build();
            dialogFragment.setTargetFragment(preferenceFragment, 0);
            dialogFragment.show(fragmentManager, DIALOG_FRAGMENT_TAG);
        }
        return true;
    }
    return false;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) LicensesDialogFragment(de.psdev.licensesdialog.LicensesDialogFragment)

Example 4 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project wire-android by wireapp.

the class ZetaPreferencesActivity method onBuildPreferenceFragment.

@Override
public PreferenceFragmentCompat onBuildPreferenceFragment(PreferenceScreen preferenceScreen) {
    final String rootKey = preferenceScreen.getKey();
    final Bundle extras = preferenceScreen.getExtras();
    final PreferenceFragmentCompat instance;
    if (rootKey.equals(getString(R.string.pref_account_screen_key))) {
        instance = AccountPreferences.newInstance(rootKey, extras);
    } else if (rootKey.equals(getString(R.string.pref_about_screen_key))) {
        instance = AboutPreferences.newInstance(rootKey, extras);
    } else if (rootKey.equals(getString(R.string.pref_options_screen_key))) {
        instance = OptionsPreferences.newInstance(rootKey, extras);
    } else if (rootKey.equals(getString(R.string.pref_support_screen_key))) {
        instance = SupportPreferences.newInstance(rootKey, extras);
    } else if (rootKey.equals(getString(R.string.pref_advanced_screen_key))) {
        instance = AdvancedPreferences.newInstance(rootKey, extras);
    } else if (rootKey.equals(getString(R.string.pref_developer_screen_key))) {
        instance = DeveloperPreferences.newInstance(rootKey, extras);
    } else if (rootKey.equals(getString(R.string.pref_devices_screen_key))) {
        instance = DevicesPreferences.newInstance(rootKey, extras);
    } else if (rootKey.equals(getString(R.string.pref_device_details_screen_key))) {
        instance = DeviceDetailPreferences.newInstance(rootKey, extras);
    } else {
        instance = RootPreferences.newInstance(rootKey, extras);
    }
    resetIntentExtras(preferenceScreen);
    return instance;
}
Also used : Bundle(android.os.Bundle) PreferenceFragmentCompat(android.support.v7.preference.PreferenceFragmentCompat)

Example 5 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project twicalico by moko256.

the class SettingsActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeAsUpIndicator(R.drawable.ic_back_white_24dp);
    if (savedInstanceState == null) {
        PreferenceFragmentCompat fragment = new SettingsFragment();
        if (getIntent() != null) {
            String title = getIntent().getStringExtra("title");
            if (title != null) {
                actionBar.setTitle(title);
            }
            String key = getIntent().getStringExtra(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT);
            if (key != null) {
                Bundle args = new Bundle();
                args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, key);
                fragment.setArguments(args);
            }
        }
        getSupportFragmentManager().beginTransaction().add(R.id.activity_settings_container, fragment).commit();
    }
}
Also used : Bundle(android.os.Bundle) PreferenceFragmentCompat(android.support.v7.preference.PreferenceFragmentCompat) ActionBar(android.support.v7.app.ActionBar)

Aggregations

Bundle (android.os.Bundle)3 PreferenceFragmentCompat (android.support.v7.preference.PreferenceFragmentCompat)3 DialogFragment (android.support.v4.app.DialogFragment)2 Fragment (android.support.v4.app.Fragment)2 FragmentManager (android.support.v4.app.FragmentManager)2 ActionBar (android.support.v7.app.ActionBar)2 Intent (android.content.Intent)1 MultiSelectListPreference (android.support.v14.preference.MultiSelectListPreference)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 WireRingtonePreferenceDialogFragment (com.waz.zclient.pages.main.profile.preferences.dialogs.WireRingtonePreferenceDialogFragment)1 BundleBuilder (com.zegoggles.smssync.utils.BundleBuilder)1 LicensesDialogFragment (de.psdev.licensesdialog.LicensesDialogFragment)1 NotificationsSettingsFragment (forpdateam.ru.forpda.ui.fragments.settings.NotificationsSettingsFragment)1 SettingsFragment (forpdateam.ru.forpda.ui.fragments.settings.SettingsFragment)1