Search in sources :

Example 1 with ActionPreference

use of com.aicp.extras.preference.ActionPreference in project packages_apps_AicpExtras by AICP.

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.aicp.extras.preference.ActionPreference)

Example 2 with ActionPreference

use of com.aicp.extras.preference.ActionPreference in project packages_apps_AicpExtras by AICP.

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) Preference(android.support.v7.preference.Preference) ActionPreference(com.aicp.extras.preference.ActionPreference) PreferenceCategory(android.support.v7.preference.PreferenceCategory) ActionPreference(com.aicp.extras.preference.ActionPreference)

Example 3 with ActionPreference

use of com.aicp.extras.preference.ActionPreference in project packages_apps_AicpExtras by AICP.

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.aicp.extras.ShortcutPickHelper) ActionPreference(com.aicp.extras.preference.ActionPreference)

Example 4 with ActionPreference

use of com.aicp.extras.preference.ActionPreference in project packages_apps_AicpExtras by AICP.

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.aicp.extras.preference.ActionPreference)

Example 5 with ActionPreference

use of com.aicp.extras.preference.ActionPreference in project packages_apps_AicpExtras by AICP.

the class FlingSettings 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.aicp.extras.preference.ActionPreference)

Aggregations

ActionPreference (com.aicp.extras.preference.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.aicp.extras.ShortcutPickHelper)1 ArrayList (java.util.ArrayList)1