Search in sources :

Example 26 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PowerUsageSummary method addNotAvailableMessage.

private void addNotAvailableMessage() {
    final String NOT_AVAILABLE = "not_available";
    Preference notAvailable = getCachedPreference(NOT_AVAILABLE);
    if (notAvailable == null) {
        notAvailable = new Preference(getPrefContext());
        notAvailable.setKey(NOT_AVAILABLE);
        notAvailable.setTitle(R.string.power_usage_not_available);
        mAppListGroup.addPreference(notAvailable);
    }
}
Also used : Preference(android.support.v7.preference.Preference)

Example 27 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PowerUsageDetail method addHorizontalPreference.

private void addHorizontalPreference(PreferenceCategory parent, CharSequence title, CharSequence summary) {
    Preference pref = new Preference(getPrefContext());
    pref.setLayoutResource(R.layout.horizontal_preference);
    pref.setTitle(title);
    pref.setSummary(summary);
    pref.setSelectable(false);
    parent.addPreference(pref);
}
Also used : LayoutPreference(com.android.settings.applications.LayoutPreference) Preference(android.support.v7.preference.Preference)

Example 28 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PowerUsageDetail method addControl.

private void addControl(int pageSummary, int actionTitle, final int action) {
    Preference pref = new Preference(getPrefContext());
    pref.setTitle(actionTitle);
    pref.setLayoutResource(R.layout.horizontal_preference);
    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            doAction(action);
            return true;
        }
    });
    mControlsParent.addPreference(pref);
}
Also used : OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) LayoutPreference(com.android.settings.applications.LayoutPreference) Preference(android.support.v7.preference.Preference)

Example 29 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModePrioritySettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.zen_mode_priority_settings);
    final PreferenceScreen root = getPreferenceScreen();
    mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
    mReminders = (SwitchPreference) root.findPreference(KEY_REMINDERS);
    mReminders.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (mDisableListeners)
                return true;
            final boolean val = (Boolean) newValue;
            MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_REMINDERS, val);
            if (DEBUG)
                Log.d(TAG, "onPrefChange allowReminders=" + val);
            savePolicy(getNewPriorityCategories(val, Policy.PRIORITY_CATEGORY_REMINDERS), mPolicy.priorityCallSenders, mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects);
            return true;
        }
    });
    mEvents = (SwitchPreference) root.findPreference(KEY_EVENTS);
    mEvents.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (mDisableListeners)
                return true;
            final boolean val = (Boolean) newValue;
            MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_EVENTS, val);
            if (DEBUG)
                Log.d(TAG, "onPrefChange allowEvents=" + val);
            savePolicy(getNewPriorityCategories(val, Policy.PRIORITY_CATEGORY_EVENTS), mPolicy.priorityCallSenders, mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects);
            return true;
        }
    });
    mMessages = (DropDownPreference) root.findPreference(KEY_MESSAGES);
    addSources(mMessages);
    mMessages.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (mDisableListeners)
                return false;
            final int val = Integer.parseInt((String) newValue);
            final boolean allowMessages = val != SOURCE_NONE;
            final int allowMessagesFrom = val == SOURCE_NONE ? mPolicy.priorityMessageSenders : val;
            MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_MESSAGES, val);
            if (DEBUG)
                Log.d(TAG, "onPrefChange allowMessages=" + allowMessages + " allowMessagesFrom=" + ZenModeConfig.sourceToString(allowMessagesFrom));
            savePolicy(getNewPriorityCategories(allowMessages, Policy.PRIORITY_CATEGORY_MESSAGES), mPolicy.priorityCallSenders, allowMessagesFrom, mPolicy.suppressedVisualEffects);
            return true;
        }
    });
    mCalls = (DropDownPreference) root.findPreference(KEY_CALLS);
    addSources(mCalls);
    mCalls.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (mDisableListeners)
                return false;
            final int val = Integer.parseInt((String) newValue);
            final boolean allowCalls = val != SOURCE_NONE;
            final int allowCallsFrom = val == SOURCE_NONE ? mPolicy.priorityCallSenders : val;
            MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_CALLS, val);
            if (DEBUG)
                Log.d(TAG, "onPrefChange allowCalls=" + allowCalls + " allowCallsFrom=" + ZenModeConfig.sourceToString(allowCallsFrom));
            savePolicy(getNewPriorityCategories(allowCalls, Policy.PRIORITY_CATEGORY_CALLS), allowCallsFrom, mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects);
            return true;
        }
    });
    mRepeatCallers = (SwitchPreference) root.findPreference(KEY_REPEAT_CALLERS);
    mRepeatCallers.setSummary(mContext.getString(R.string.zen_mode_repeat_callers_summary, mContext.getResources().getInteger(com.android.internal.R.integer.config_zen_repeat_callers_threshold)));
    mRepeatCallers.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (mDisableListeners)
                return true;
            final boolean val = (Boolean) newValue;
            MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_REPEAT_CALLS, val);
            if (DEBUG)
                Log.d(TAG, "onPrefChange allowRepeatCallers=" + val);
            int priorityCategories = getNewPriorityCategories(val, NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS);
            savePolicy(priorityCategories, mPolicy.priorityCallSenders, mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects);
            return true;
        }
    });
    updateControls();
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) DropDownPreference(android.support.v7.preference.DropDownPreference) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener)

Example 30 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SoundSettings method initVibrateWhenRinging.

// === Vibrate when ringing ===
private void initVibrateWhenRinging() {
    mVibrateWhenRinging = (TwoStatePreference) getPreferenceScreen().findPreference(KEY_VIBRATE_WHEN_RINGING);
    if (mVibrateWhenRinging == null) {
        Log.i(TAG, "Preference not found: " + KEY_VIBRATE_WHEN_RINGING);
        return;
    }
    if (!mVoiceCapable) {
        getPreferenceScreen().removePreference(mVibrateWhenRinging);
        mVibrateWhenRinging = null;
        return;
    }
    mVibrateWhenRinging.setPersistent(false);
    updateVibrateWhenRinging();
    mVibrateWhenRinging.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final boolean val = (Boolean) newValue;
            return Settings.System.putInt(getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, val ? 1 : 0);
        }
    });
}
Also used : RestrictedPreference(com.android.settingslib.RestrictedPreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference) RingtonePreference(com.android.settings.RingtonePreference) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener)

Aggregations

Preference (android.support.v7.preference.Preference)122 PreferenceScreen (android.support.v7.preference.PreferenceScreen)44 SwitchPreference (android.support.v14.preference.SwitchPreference)33 Intent (android.content.Intent)27 ListPreference (android.support.v7.preference.ListPreference)27 Context (android.content.Context)17 PreferenceCategory (android.support.v7.preference.PreferenceCategory)17 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)15 ArrayList (java.util.ArrayList)14 PackageManager (android.content.pm.PackageManager)11 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)11 PreferenceGroup (android.support.v7.preference.PreferenceGroup)11 TwoStatePreference (android.support.v7.preference.TwoStatePreference)11 Activity (android.app.Activity)10 View (android.view.View)10 Bundle (android.os.Bundle)9 TextView (android.widget.TextView)8 AlertDialog (android.support.v7.app.AlertDialog)7 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7