android.support.v7.preference.PreferenceGroup Java Examples

The following examples show how to use android.support.v7.preference.PreferenceGroup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GsPreferenceFragmentCompat.java    From openlauncher with Apache License 2.0 6 votes vote down vote up
protected PreferenceGroup getPreferenceParent(PreferenceGroup prefGroup, Preference pref) {
    for (int i = 0; i < prefGroup.getPreferenceCount(); ++i) {
        Preference prefChild = prefGroup.getPreference(i);
        if (prefChild == pref) {
            return prefGroup;
        }
        if (prefChild instanceof PreferenceGroup) {
            PreferenceGroup childGroup = (PreferenceGroup) prefChild;
            PreferenceGroup result = getPreferenceParent(childGroup, pref);
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example #2
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static CheckBoxPreference addPreference(PreferenceFragment fragment) {
//>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example #3
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static CheckBoxPreference addPreference(PreferenceFragment fragment) {
//>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example #4
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        //<5.1// CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        /*>5.1*/ SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example #5
Source File: NGWSettingsFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void addEditAccountAction(
        final IGISApplication application,
        final Account account,
        PreferenceGroup actionCategory)
{
    Preference preferenceEdit = new Preference(mStyledContext);
    preferenceEdit.setTitle(R.string.edit_account);
    preferenceEdit.setSummary(R.string.edit_account_summary);

    String url = application.getAccountUrl(account);
    String login = application.getAccountLogin(account);

    Intent intent = new Intent(mStyledContext, NGWLoginActivity.class);
    intent.putExtra(NGWLoginActivity.FOR_NEW_ACCOUNT, false);
    intent.putExtra(NGWLoginActivity.ACCOUNT_URL_TEXT, url);
    intent.putExtra(NGWLoginActivity.ACCOUNT_LOGIN_TEXT, login);
    intent.putExtra(NGWLoginActivity.CHANGE_ACCOUNT_URL, false);
    intent.putExtra(NGWLoginActivity.CHANGE_ACCOUNT_LOGIN, true);
    preferenceEdit.setIntent(intent);

    actionCategory.addPreference(preferenceEdit);
}
 
Example #6
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        //<5.1// CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        /*>5.1*/ SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example #7
Source File: GsPreferenceFragmentCompat.java    From Stringlate with MIT License 6 votes vote down vote up
protected PreferenceGroup getPreferenceParent(PreferenceGroup prefGroup, Preference pref) {
    for (int i = 0; i < prefGroup.getPreferenceCount(); ++i) {
        Preference prefChild = prefGroup.getPreference(i);
        if (prefChild == pref) {
            return prefGroup;
        }
        if (prefChild instanceof PreferenceGroup) {
            PreferenceGroup childGroup = (PreferenceGroup) prefChild;
            PreferenceGroup result = getPreferenceParent(childGroup, pref);
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example #8
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        //<5.1// CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        /*>5.1*/ SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example #9
Source File: GsPreferenceFragmentCompat.java    From Stringlate with MIT License 6 votes vote down vote up
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
Example #10
Source File: GsPreferenceFragmentCompat.java    From kimai-android with MIT License 6 votes vote down vote up
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
Example #11
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        //<5.1// CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        /*>5.1*/ SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example #12
Source File: GsPreferenceFragmentCompat.java    From openlauncher with Apache License 2.0 6 votes vote down vote up
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
Example #13
Source File: GsPreferenceFragmentCompat.java    From kimai-android with MIT License 6 votes vote down vote up
protected PreferenceGroup getPreferenceParent(PreferenceGroup prefGroup, Preference pref) {
    for (int i = 0; i < prefGroup.getPreferenceCount(); ++i) {
        Preference prefChild = prefGroup.getPreference(i);
        if (prefChild == pref) {
            return prefGroup;
        }
        if (prefChild instanceof PreferenceGroup) {
            PreferenceGroup childGroup = (PreferenceGroup) prefChild;
            PreferenceGroup result = getPreferenceParent(childGroup, pref);
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example #14
Source File: SettingsBaseFragment.java    From openlauncher with Apache License 2.0 6 votes vote down vote up
public void updateIcons(PreferenceGroup prefGroup) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference preference = prefGroup.getPreference(i);
            if (preference != null) {
                Drawable drawable = preference.getIcon();
                if (drawable != null) {
                    TypedValue color = new TypedValue();
                    getContext().getTheme().resolveAttribute(android.R.attr.textColor, color, true);
                    drawable.mutate().setColorFilter(getResources().getColor(color.resourceId), PorterDuff.Mode.SRC_IN);
                }

                if (preference instanceof PreferenceGroup) {
                    updateIcons((PreferenceGroup) preference);
                }
            }
        }
    }
}
 
Example #15
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static CheckBoxPreference addPreference(PreferenceFragment fragment) {
//>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example #16
Source File: GsPreferenceFragmentCompat.java    From memetastic with GNU General Public License v3.0 6 votes vote down vote up
protected PreferenceGroup getPreferenceParent(PreferenceGroup prefGroup, Preference pref) {
    for (int i = 0; i < prefGroup.getPreferenceCount(); ++i) {
        Preference prefChild = prefGroup.getPreference(i);
        if (prefChild == pref) {
            return prefGroup;
        }
        if (prefChild instanceof PreferenceGroup) {
            PreferenceGroup childGroup = (PreferenceGroup) prefChild;
            PreferenceGroup result = getPreferenceParent(childGroup, pref);
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example #17
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        //<5.1// CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        /*>5.1*/ SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example #18
Source File: GsPreferenceFragmentCompat.java    From memetastic with GNU General Public License v3.0 6 votes vote down vote up
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
Example #19
Source File: NGIDSettingsFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void fillAccountPreferences(PreferenceGroup screen)
{
    String notDefined = getString(R.string.not_set);
    String value = mPreferences.getString(NGIDUtils.PREF_USERNAME, null);
    screen.findPreference(NGIDUtils.PREF_USERNAME)
            .setSummary(TextUtils.isEmpty(value) ? notDefined : value);
    value = mPreferences.getString(NGIDUtils.PREF_EMAIL, null);
    screen.findPreference(NGIDUtils.PREF_EMAIL)
            .setSummary(TextUtils.isEmpty(value) ? notDefined : value);
    value = mPreferences.getString(NGIDUtils.PREF_FIRST_NAME, null);
    screen.findPreference(NGIDUtils.PREF_FIRST_NAME)
            .setSummary(TextUtils.isEmpty(value) ? notDefined : value);
    value = mPreferences.getString(NGIDUtils.PREF_LAST_NAME, null);
    screen.findPreference(NGIDUtils.PREF_LAST_NAME)
            .setSummary(TextUtils.isEmpty(value) ? notDefined : value);
    screen.findPreference("sign_out")
            .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
            {
                @Override
                public boolean onPreferenceClick(Preference preference)
                {
                    signOut(mPreferences, getContext());

                    if (!NGPreferenceActivity.isMultiPane(getActivity())) {
                        mActivity.onBackPressed();
                        mActivity.onBackPressed();
                    } else {
                        mActivity.invalidatePreferences();
                    }
                    mActivity.replaceSettingsFragment(null);
                    return false;
                }
            });
}
 
Example #20
Source File: NGWSettingsFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void addAutoSyncProperty(
        final IGISApplication application,
        final Account account,
        PreferenceGroup syncCategory)
{
    final String accountNameHash = "_" + account.name.hashCode();
    SharedPreferences sharedPreferences =
            mStyledContext.getSharedPreferences(Constants.PREFERENCES, Context.MODE_MULTI_PROCESS);

    CheckBoxPreference enablePeriodicSync = new CheckBoxPreference(mStyledContext);
    enablePeriodicSync.setKey(KEY_SYNC);
    enablePeriodicSync.setPersistent(false);
    enablePeriodicSync.setTitle(R.string.auto_sync);

    boolean isAccountSyncEnabled = isAccountSyncEnabled(account, application.getAuthority());
    enablePeriodicSync.setChecked(isAccountSyncEnabled);
    enablePeriodicSync.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
    {
        @Override
        public boolean onPreferenceChange(
                Preference preference,
                Object newValue)
        {
            boolean isChecked = (boolean) newValue;
            setAccountSyncEnabled(account, application.getAuthority(), isChecked);
            return true;
        }
    });

    long timeStamp = sharedPreferences.getLong(
            com.nextgis.maplib.util.SettingsConstants.KEY_PREF_LAST_SYNC_TIMESTAMP
                    + accountNameHash, 0);
    if (isAccountSyncEnabled && timeStamp > 0) {
        enablePeriodicSync.setSummary(ControlHelper.getSyncTime(mStyledContext, timeStamp));
    } else {
        enablePeriodicSync.setSummary(R.string.auto_sync_summary);
    }
    syncCategory.addPreference(enablePeriodicSync);
}
 
Example #21
Source File: NGIDSettingsFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void fillPreferences(PreferenceGroup screen)
{
    if (mAction != null && mAction.equals(SettingsConstantsUI.ACTION_ACCOUNT)) {
        addPreferencesFromResource(R.xml.preferences_ngid);
        fillAccountPreferences(screen);
    }
}
 
Example #22
Source File: PreferencesFragment.java    From ShaderEditor with MIT License 5 votes vote down vote up
private void setSummary(Preference preference) {
	if (preference instanceof ShaderListPreference) {
		long id = Preferences.WALLPAPER_SHADER.equals(preference.getKey()) ?
				ShaderEditorApp.preferences.getWallpaperShader() :
				ShaderEditorApp.preferences.getDefaultNewShader();
		preference.setSummary(getShaderSummary(id));
	} else if (preference instanceof ListPreference) {
		preference.setSummary(((ListPreference) preference).getEntry());
	} else if (preference instanceof PreferenceGroup) {
		setSummaries((PreferenceGroup) preference);
	}
}
 
Example #23
Source File: GsPreferenceFragmentCompat.java    From kimai-android with MIT License 5 votes vote down vote up
protected void removePreference(@Nullable Preference preference) {
    if (preference == null) {
        return;
    }
    PreferenceGroup parent = getPreferenceParent(getPreferenceScreen(), preference);
    if (parent == null) {
        return;
    }
    parent.removePreference(preference);
}
 
Example #24
Source File: GsPreferenceFragmentCompat.java    From kimai-android with MIT License 5 votes vote down vote up
/**
 * Append a pref to given {@code target}. If target is null, the current screen is taken
 * The pref icon is tint according to color
 *
 * @param pref   Preference to add
 * @param target The target to add the pref to, or null for current screen
 * @return true if successfully added
 */
protected boolean appendPreference(Preference pref, @Nullable PreferenceGroup target) {
    if (target == null) {
        if ((target = getPreferenceScreen()) == null) {
            return false;
        }
    }
    if (getIconTintColor() != null && pref.getIcon() != null && isAllowedToTint(pref)) {
        pref.setIcon(_cu.tintDrawable(pref.getIcon(), getIconTintColor()));
    }
    return target.addPreference(pref);
}
 
Example #25
Source File: GcmFragment.java    From android_packages_apps_GmsCore with Apache License 2.0 5 votes vote down vote up
private static void addPreferencesSorted(List<Preference> prefs, PreferenceGroup container) {
    // If there's some items to display, sort the items and add them to the container.
    Collections.sort(prefs, new Comparator<Preference>() {
        @Override
        public int compare(Preference lhs, Preference rhs) {
            return lhs.getTitle().toString().toLowerCase().compareTo(rhs.getTitle().toString().toLowerCase());
        }
    });
    for (Preference entry : prefs) {
        container.addPreference(entry);
    }
}
 
Example #26
Source File: SettingsFragment.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
private void removeAdvancePreference(@Nullable Preference preference) {
    // these null checks are to fix a crash due to an NPE on 4.4.4
    if (preference != null) {
        PreferenceGroup group =
                (PreferenceGroup) findPreference("pref_general");
        if (group != null) {
            group.removePreference(preference);
        }
    }
}
 
Example #27
Source File: NGWSettingsFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void fillAccountPreferences(
            PreferenceGroup screen,
            final Account account)
    {
        final IGISApplication appContext = (IGISApplication) mStyledContext.getApplicationContext();

        // add sync settings group
        PreferenceCategory syncCategory = new PreferenceCategory(mStyledContext);
        syncCategory.setTitle(R.string.sync);
        screen.addPreference(syncCategory);

        // add auto sync property
        addAutoSyncProperty(appContext, account, syncCategory);

        // add time for periodic sync
        addPeriodicSyncTime(appContext, account, syncCategory);

        // add account layers
        addAccountLayers(screen, appContext, account);

        // add actions group
        PreferenceCategory actionCategory = new PreferenceCategory(mStyledContext);
        actionCategory.setTitle(R.string.actions);
        screen.addPreference(actionCategory);

        // add "Edit account" action
        addEditAccountAction(appContext, account, actionCategory);

        // add delete account action
        addDeleteAccountAction(appContext, account, actionCategory);

// TODO: for isMultiPane() change title of Settings fragment, not of Activity
//        if (mChangeTitle && !NGPreferenceActivity.isMultiPane(mActivity)) {
        if (mChangeTitle) {
            ActionBar ab = mActivity.getSupportActionBar();
            if (null != ab) {
                ab.setTitle(account.name);
            }
        }
    }
 
Example #28
Source File: NGWSettingsFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void fillPreferences(PreferenceGroup screen)
{
    if (mAction != null && mAction.equals(SettingsConstantsUI.ACTION_ACCOUNT)) {
        Account account = getArguments().getParcelable(NGWSettingsActivity.KEY_ACCOUNT);
        fillAccountPreferences(screen, account);
    }
}
 
Example #29
Source File: GsPreferenceFragmentCompat.java    From Stringlate with MIT License 5 votes vote down vote up
/**
 * Append a pref to given {@code target}. If target is null, the current screen is taken
 * The pref icon is tint according to color
 *
 * @param pref   Preference to add
 * @param target The target to add the pref to, or null for current screen
 * @return true if successfully added
 */
protected boolean appendPreference(Preference pref, @Nullable PreferenceGroup target) {
    if (target == null) {
        if ((target = getPreferenceScreen()) == null) {
            return false;
        }
    }
    if (getIconTintColor() != null && pref.getIcon() != null && isAllowedToTint(pref)) {
        pref.setIcon(_cu.tintDrawable(pref.getIcon(), getIconTintColor()));
    }
    return target.addPreference(pref);
}
 
Example #30
Source File: GsPreferenceFragmentCompat.java    From Stringlate with MIT License 5 votes vote down vote up
protected void removePreference(@Nullable Preference preference) {
    if (preference == null) {
        return;
    }
    PreferenceGroup parent = getPreferenceParent(getPreferenceScreen(), preference);
    if (parent == null) {
        return;
    }
    parent.removePreference(preference);
}