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);
}
}
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);
}
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);
}
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();
}
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);
}
});
}
Aggregations