use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class FingerprintSettings method getFingerprintPreferenceForUser.
public static Preference getFingerprintPreferenceForUser(Context context, final int userId) {
FingerprintManager fpm = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (fpm == null || !fpm.isHardwareDetected()) {
Log.v(TAG, "No fingerprint hardware detected!!");
return null;
}
Preference fingerprintPreference = new Preference(context);
fingerprintPreference.setKey(KEY_FINGERPRINT_SETTINGS);
fingerprintPreference.setTitle(R.string.security_settings_fingerprint_preference_title);
final List<Fingerprint> items = fpm.getEnrolledFingerprints(userId);
final int fingerprintCount = items != null ? items.size() : 0;
final String clazz;
if (fingerprintCount > 0) {
fingerprintPreference.setSummary(context.getResources().getQuantityString(R.plurals.security_settings_fingerprint_preference_summary, fingerprintCount, fingerprintCount));
clazz = FingerprintSettings.class.getName();
} else {
fingerprintPreference.setSummary(R.string.security_settings_fingerprint_preference_summary_none);
clazz = FingerprintEnrollIntroduction.class.getName();
}
fingerprintPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
final Context context = preference.getContext();
final UserManager userManager = UserManager.get(context);
if (Utils.startQuietModeDialogIfNecessary(context, userManager, userId)) {
return false;
}
Intent intent = new Intent();
intent.setClassName("com.android.settings", clazz);
intent.putExtra(Intent.EXTRA_USER_ID, userId);
context.startActivity(intent);
return true;
}
});
return fingerprintPreference;
}
use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConfigureNotificationSettings method initLockscreenNotificationsForProfile.
// === Lockscreen (public / private) notifications ===
private void initLockscreenNotificationsForProfile() {
mLockscreenProfile = (RestrictedDropDownPreference) getPreferenceScreen().findPreference(KEY_LOCK_SCREEN_PROFILE_NOTIFICATIONS);
if (mLockscreenProfile == null) {
Log.i(TAG, "Preference not found: " + KEY_LOCK_SCREEN_PROFILE_NOTIFICATIONS);
return;
}
ArrayList<CharSequence> entries = new ArrayList<>();
ArrayList<CharSequence> values = new ArrayList<>();
entries.add(getString(R.string.lock_screen_notifications_summary_disable_profile));
values.add(Integer.toString(R.string.lock_screen_notifications_summary_disable_profile));
String summaryShowEntry = getString(R.string.lock_screen_notifications_summary_show_profile);
String summaryShowEntryValue = Integer.toString(R.string.lock_screen_notifications_summary_show_profile);
entries.add(summaryShowEntry);
values.add(summaryShowEntryValue);
setRestrictedIfNotificationFeaturesDisabled(summaryShowEntry, summaryShowEntryValue, KEYGUARD_DISABLE_SECURE_NOTIFICATIONS | KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
if (mSecureProfile) {
String summaryHideEntry = getString(R.string.lock_screen_notifications_summary_hide_profile);
String summaryHideEntryValue = Integer.toString(R.string.lock_screen_notifications_summary_hide_profile);
entries.add(summaryHideEntry);
values.add(summaryHideEntryValue);
setRestrictedIfNotificationFeaturesDisabled(summaryHideEntry, summaryHideEntryValue, KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
}
mLockscreenProfile.setOnPreClickListener((Preference p) -> Utils.startQuietModeDialogIfNecessary(mContext, UserManager.get(mContext), mProfileChallengeUserId));
mLockscreenProfile.setEntries(entries.toArray(new CharSequence[entries.size()]));
mLockscreenProfile.setEntryValues(values.toArray(new CharSequence[values.size()]));
updateLockscreenNotificationsForProfile();
if (mLockscreenProfile.getEntries().length > 1) {
mLockscreenProfile.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final int val = Integer.parseInt((String) newValue);
if (val == mLockscreenSelectedValueProfile) {
return false;
}
final boolean enabled = val != R.string.lock_screen_notifications_summary_disable_profile;
final boolean show = val == R.string.lock_screen_notifications_summary_show_profile;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0, mProfileChallengeUserId);
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0, mProfileChallengeUserId);
mLockscreenSelectedValueProfile = val;
return true;
}
});
} else {
// There is one or less option for the user, disable the drop down.
mLockscreenProfile.setEnabled(false);
}
}
use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConfigureNotificationSettings method initLockscreenNotifications.
private void initLockscreenNotifications() {
mLockscreen = (RestrictedDropDownPreference) getPreferenceScreen().findPreference(KEY_LOCK_SCREEN_NOTIFICATIONS);
if (mLockscreen == null) {
Log.i(TAG, "Preference not found: " + KEY_LOCK_SCREEN_NOTIFICATIONS);
return;
}
ArrayList<CharSequence> entries = new ArrayList<>();
ArrayList<CharSequence> values = new ArrayList<>();
entries.add(getString(R.string.lock_screen_notifications_summary_disable));
values.add(Integer.toString(R.string.lock_screen_notifications_summary_disable));
String summaryShowEntry = getString(R.string.lock_screen_notifications_summary_show);
String summaryShowEntryValue = Integer.toString(R.string.lock_screen_notifications_summary_show);
entries.add(summaryShowEntry);
values.add(summaryShowEntryValue);
setRestrictedIfNotificationFeaturesDisabled(summaryShowEntry, summaryShowEntryValue, KEYGUARD_DISABLE_SECURE_NOTIFICATIONS | KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
if (mSecure) {
String summaryHideEntry = getString(R.string.lock_screen_notifications_summary_hide);
String summaryHideEntryValue = Integer.toString(R.string.lock_screen_notifications_summary_hide);
entries.add(summaryHideEntry);
values.add(summaryHideEntryValue);
setRestrictedIfNotificationFeaturesDisabled(summaryHideEntry, summaryHideEntryValue, KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
}
mLockscreen.setEntries(entries.toArray(new CharSequence[entries.size()]));
mLockscreen.setEntryValues(values.toArray(new CharSequence[values.size()]));
updateLockscreenNotifications();
if (mLockscreen.getEntries().length > 1) {
mLockscreen.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final int val = Integer.parseInt((String) newValue);
if (val == mLockscreenSelectedValue) {
return false;
}
final boolean enabled = val != R.string.lock_screen_notifications_summary_disable;
final boolean show = val == R.string.lock_screen_notifications_summary_show;
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
mLockscreenSelectedValue = val;
return true;
}
});
} else {
// There is one or less option for the user, disable the drop down.
mLockscreen.setEnabled(false);
}
}
use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimSettings method onPause.
@Override
public void onPause() {
super.onPause();
mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangeListener);
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
for (int i = 0; i < mPhoneCount; i++) {
if (mPhoneStateListener[i] != null) {
tm.listen(mPhoneStateListener[i], PhoneStateListener.LISTEN_NONE);
mPhoneStateListener[i] = null;
}
}
for (int i = 0; i < mSimCards.getPreferenceCount(); ++i) {
Preference pref = mSimCards.getPreference(i);
if (pref instanceof SimEnablerPreference) {
// Calling cleanUp() here to dismiss/cleanup any pending dialog exists.
((SimEnablerPreference) pref).cleanUpPendingDialogs();
}
}
}
use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimSettings method updateCellularDataValues.
private void updateCellularDataValues() {
final Preference simPref = findPreference(KEY_CELLULAR_DATA);
final SubscriptionInfo sir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
simPref.setTitle(R.string.cellular_data_title);
if (DBG)
log("[updateCellularDataValues] mSubInfoList=" + mSubInfoList);
boolean callStateIdle = isCallStateIdle();
final boolean ecbMode = SystemProperties.getBoolean(TelephonyProperties.PROPERTY_INECM_MODE, false);
if (sir != null) {
simPref.setSummary(sir.getDisplayName());
// Enable data preference in msim mode and call state idle
simPref.setEnabled((mSelectableSubInfos.size() > 1) && callStateIdle && !ecbMode);
} else if (sir == null) {
simPref.setSummary(R.string.sim_selection_required_pref);
// Enable data preference in msim mode and call state idle
simPref.setEnabled((mSelectableSubInfos.size() >= 1) && callStateIdle && !ecbMode);
}
if (mNoSims != null) {
mNoSims.setEnabled(mSelectableSubInfos.size() >= 1);
}
}
Aggregations