Search in sources :

Example 1 with ActionPreference

use of com.crdroid.settings.preferences.ActionPreference in project android_packages_apps_crDroidSettings by crdroidandroid.

the class Fling method enforceAction.

/*
     * Iterate the list: if only one instance, disable it otherwise, enable
     */
private void enforceAction(ArrayList<ActionPreference> prefs, String action) {
    ArrayList<ActionPreference> actionPrefs = new ArrayList<ActionPreference>();
    for (ActionPreference pref : prefs) {
        if (pref.getActionConfig().getAction().equals(action)) {
            actionPrefs.add(pref);
        }
    }
    boolean moreThanOne = actionPrefs.size() > 1;
    for (ActionPreference pref : actionPrefs) {
        pref.setEnabled(moreThanOne);
    }
}
Also used : ArrayList(java.util.ArrayList) ActionPreference(com.crdroid.settings.preferences.ActionPreference)

Example 2 with ActionPreference

use of com.crdroid.settings.preferences.ActionPreference in project android_packages_apps_crDroidSettings by crdroidandroid.

the class ActionFragment method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (icicle != null) {
        String holderTag = icicle.getString(KEY_FOCUSED_PREFERENCE);
        if (holderTag != null) {
            mHolderTag = holderTag;
        }
    }
    mPicker = new ShortcutPickHelper(getActivity(), this);
    mPrefHolder = new ArrayList<ActionPreference>();
}
Also used : ShortcutPickHelper(com.crdroid.settings.fragments.navbar.ShortcutPickHelper) ActionPreference(com.crdroid.settings.preferences.ActionPreference)

Example 3 with ActionPreference

use of com.crdroid.settings.preferences.ActionPreference in project android_packages_apps_crDroidSettings by crdroidandroid.

the class ActionFragment method loadAndSetConfigs.

private void loadAndSetConfigs() {
    mButtons = Config.getConfig(getActivity(), mDefaults);
    mDefaultButtons = Config.getDefaultConfig(getActivity(), mDefaults);
    for (ActionPreference pref : mPrefHolder) {
        pref.setDefaults(mDefaults);
        ButtonConfig button = mButtons.get(pref.getConfigMap().button);
        ActionConfig action = button.getActionConfig(pref.getConfigMap().action);
        pref.setActionConfig(action);
        ButtonConfig defButton = mDefaultButtons.get(pref.getConfigMap().button);
        ActionConfig defAction = defButton.getActionConfig(pref.getConfigMap().action);
        pref.setDefaultActionConfig(defAction);
    }
}
Also used : ActionConfig(com.android.internal.utils.du.Config.ActionConfig) ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) ActionPreference(com.crdroid.settings.preferences.ActionPreference)

Example 4 with ActionPreference

use of com.crdroid.settings.preferences.ActionPreference in project android_packages_apps_crDroidSettings by crdroidandroid.

the class ActionFragment method findAndUpdatePreference.

protected void findAndUpdatePreference(ActionConfig action, String tag) {
    for (ActionPreference pref : mPrefHolder) {
        if (pref.getTag().equals(mHolderTag)) {
            if (action == null) {
                action = pref.getDefaultActionConfig();
            }
            pref.setActionConfig(action);
            ButtonConfig button = mButtons.get(pref.getConfigMap().button);
            ActionConfig newAction = pref.getActionConfig();
            button.setActionConfig(newAction, pref.getConfigMap().action);
            mButtons = Config.replaceButtonAtPosition(mButtons, button, pref.getConfigMap());
            Config.setConfig(getActivity(), mDefaults, mButtons);
            onActionPolicyEnforced(mPrefHolder);
            break;
        }
    }
}
Also used : ActionConfig(com.android.internal.utils.du.Config.ActionConfig) ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) ActionPreference(com.crdroid.settings.preferences.ActionPreference)

Example 5 with ActionPreference

use of com.crdroid.settings.preferences.ActionPreference in project android_packages_apps_crDroidSettings by crdroidandroid.

the class ActionFragment method onPreferenceScreenLoaded.

/**
 * load our button lists and ActionPreferences map button action targets from preference keys
 * and defaults config maps subclass is required to set desired Defaults interface int
 * ActionContants
 */
protected void onPreferenceScreenLoaded(Defaults defaults) {
    mDefaults = defaults;
    final PreferenceScreen prefScreen = getPreferenceScreen();
    for (int i = 0; i < prefScreen.getPreferenceCount(); i++) {
        Preference pref = prefScreen.getPreference(i);
        if (pref instanceof PreferenceCategory) {
            PreferenceCategory cat = (PreferenceCategory) pref;
            for (int j = 0; j < cat.getPreferenceCount(); j++) {
                Preference child = cat.getPreference(j);
                if (child instanceof ActionPreference) {
                    mPrefHolder.add((ActionPreference) child);
                }
            }
        } else if (pref instanceof ActionPreference) {
            mPrefHolder.add((ActionPreference) pref);
        }
    }
    loadAndSetConfigs();
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ActionPreference(com.crdroid.settings.preferences.ActionPreference) Preference(android.support.v7.preference.Preference) PreferenceCategory(android.support.v7.preference.PreferenceCategory) ActionPreference(com.crdroid.settings.preferences.ActionPreference)

Aggregations

ActionPreference (com.crdroid.settings.preferences.ActionPreference)5 ActionConfig (com.android.internal.utils.du.Config.ActionConfig)2 ButtonConfig (com.android.internal.utils.du.Config.ButtonConfig)2 Preference (android.support.v7.preference.Preference)1 PreferenceCategory (android.support.v7.preference.PreferenceCategory)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 ShortcutPickHelper (com.crdroid.settings.fragments.navbar.ShortcutPickHelper)1 ArrayList (java.util.ArrayList)1