Search in sources :

Example 6 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project ForPDA by RadiationX.

the class SettingsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    currentThemeIsDark = App.get().isDarkTheme();
    setTheme(currentThemeIsDark ? R.style.PreferenceAppThemeDark : R.style.PreferenceAppThemeLight);
    setContentView(R.layout.activity_settings);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(R.string.activity_title_settings);
    }
    PreferenceFragmentCompat fragment = null;
    Intent intent = getIntent();
    if (intent != null) {
        String settingsArgument = intent.getStringExtra(ARG_NEW_PREFERENCE_SCREEN);
        if (settingsArgument != null) {
            if (settingsArgument.equals(NotificationsSettingsFragment.PREFERENCE_SCREEN_NAME)) {
                fragment = new NotificationsSettingsFragment();
            }
        }
    }
    if (fragment == null) {
        fragment = new SettingsFragment();
    }
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_content, fragment).commit();
    /*View view = findViewById(R.id.fragment_content);
        view.setBackgroundColor(Color.TRANSPARENT);
        view.setBackgroundColor(Color.rgb(4, 26, 55));*/
    App.get().addPreferenceChangeObserver(appThemeChangeObserver);
}
Also used : NotificationsSettingsFragment(forpdateam.ru.forpda.ui.fragments.settings.NotificationsSettingsFragment) SettingsFragment(forpdateam.ru.forpda.ui.fragments.settings.SettingsFragment) PreferenceFragmentCompat(android.support.v7.preference.PreferenceFragmentCompat) Intent(android.content.Intent) NotificationsSettingsFragment(forpdateam.ru.forpda.ui.fragments.settings.NotificationsSettingsFragment) ActionBar(android.support.v7.app.ActionBar)

Example 7 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project sms-backup-plus by jberkel.

the class MainActivity method onPreferenceStartFragment.

@Override
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference preference) {
    if (LOCAL_LOGV) {
        Log.v(TAG, "onPreferenceStartFragment(" + preference + ")");
    }
    final Fragment fragment = Fragment.instantiate(this, preference.getFragment(), new BundleBuilder().putString(SCREEN_TITLE, String.valueOf(preference.getTitle())).build());
    showFragment(fragment, preference.getKey());
    return true;
}
Also used : BundleBuilder(com.zegoggles.smssync.utils.BundleBuilder) Fragment(android.support.v4.app.Fragment)

Example 8 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project NewPipe by TeamNewPipe.

the class SettingsActivity method onPreferenceStartFragment.

@Override
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference preference) {
    Fragment fragment = Fragment.instantiate(this, preference.getFragment(), preference.getExtras());
    getSupportFragmentManager().beginTransaction().setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out).replace(R.id.fragment_holder, fragment).addToBackStack(null).commit();
    return true;
}
Also used : Fragment(android.support.v4.app.Fragment)

Example 9 with PreferenceFragmentCompat

use of android.support.v4.preference.PreferenceFragmentCompat in project network-monitor by caarmen.

the class PreferenceFragmentCompatHack method onDisplayPreferenceDialog.

/**
 * Displays preference dialogs which aren't supported by default in PreferenceFragmentCompat.
 *
 * @return true if we managed a preference which isn't supported by default, false otherwise.
 */
public static boolean onDisplayPreferenceDialog(PreferenceFragmentCompat preferenceFragmentCompat, Preference preference) {
    FragmentManager fragmentManager = preferenceFragmentCompat.getFragmentManager();
    if (fragmentManager == null)
        return false;
    DialogFragment dialogFragment = (DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG_DIALOG);
    if (dialogFragment != null)
        return false;
    // Hack to allow a MultiSelectListPreference
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH && preference instanceof MultiSelectListPreference) {
        dialogFragment = MultiSelectListPreferenceDialogFragmentCompat.newInstance(preference.getKey());
    } else // Hack to allow a PasswordPreference
    if (preference instanceof PasswordPreference) {
        dialogFragment = PasswordPreferenceDialogFragmentCompat.newInstance(preference.getKey());
    }
    // We've created our own fragment:
    if (dialogFragment != null) {
        dialogFragment.setTargetFragment(preferenceFragmentCompat, 0);
        dialogFragment.show(fragmentManager, FRAGMENT_TAG_DIALOG);
        return true;
    }
    return false;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) DialogFragment(android.support.v4.app.DialogFragment) MultiSelectListPreference(android.support.v14.preference.MultiSelectListPreference)

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