use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by omnirom.
the class ScreenTimeoutSettings method updateCandidates.
@Override
public void updateCandidates() {
final String defaultKey = getDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
final List<? extends CandidateInfo> candidateList = getCandidates();
if (candidateList == null) {
return;
}
for (CandidateInfo info : candidateList) {
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
bindPreference(pref, info.getKey(), info, defaultKey);
screen.addPreference(pref);
}
final long selectedTimeout = Long.parseLong(defaultKey);
final long maxTimeout = getMaxScreenTimeout(getContext());
if (!candidateList.isEmpty() && (selectedTimeout > maxTimeout)) {
// The selected time out value is longer than the max timeout allowed by the admin.
// Select the largest value from the list by default.
final RadioButtonPreference preferenceWithLargestTimeout = (RadioButtonPreference) screen.getPreference(candidateList.size() - 1);
preferenceWithLargestTimeout.setChecked(true);
}
mPrivacyPreference = new FooterPreference(mContext);
mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
mPrivacyPreference.setSelectable(false);
mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
if (isScreenAttentionAvailable(getContext())) {
mAdaptiveSleepPermissionController.addToScreen(screen);
mAdaptiveSleepCameraStatePreferenceController.addToScreen(screen);
mAdaptiveSleepBatterySaverPreferenceController.addToScreen(screen);
mAdaptiveSleepController.addToScreen(screen);
screen.addPreference(mPrivacyPreference);
}
if (mAdmin != null) {
setupDisabledFooterPreference();
screen.addPreference(mDisableOptionsPreference);
}
}
use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by omnirom.
the class ZenCustomRuleMessagesSettings method updatePreferences.
@Override
public void updatePreferences() {
super.updatePreferences();
PreferenceScreen screen = getPreferenceScreen();
Preference footerPreference = screen.findPreference(FooterPreference.KEY_FOOTER);
footerPreference.setTitle(mContext.getResources().getString(R.string.zen_mode_custom_messages_footer, mRule.getName()));
}
use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by omnirom.
the class OpenSupportedLinks method updateFooterPreference.
/**
* Here is handle the Footer.
*/
private void updateFooterPreference() {
final FooterPreference footer = findPreference(FOOTER_KEY);
if (footer == null) {
Log.w(TAG, "Can't find the footer preference.");
return;
}
addLinksToFooter(footer);
}
use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by omnirom.
the class BatterySaverSettings method addHelpLink.
// Changes the text to include a learn more link if possible.
@VisibleForTesting
void addHelpLink() {
FooterPreference pref = getPreferenceScreen().findPreference(KEY_FOOTER_PREFERENCE);
if (pref != null) {
pref.setSelectable(false);
pref.setLearnMoreAction(v -> {
mMetricsFeatureProvider.action(getContext(), SettingsEnums.ACTION_APP_BATTERY_LEARN_MORE);
startActivityForResult(HelpUtils.getHelpIntent(getContext(), getString(R.string.help_url_battery_saver_settings), /*backupContext=*/
""), /*requestCode=*/
0);
});
pref.setLearnMoreContentDescription(getString(R.string.battery_saver_link_a11y));
}
}
use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by omnirom.
the class ChooseLockGenericTest method updatePreferencesOrFinish_footerPreferenceAddedMediumComplexityText.
@Test
public void updatePreferencesOrFinish_footerPreferenceAddedMediumComplexityText() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false);
Intent intent = new Intent().putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name").putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_MEDIUM);
initActivity(intent);
CharSequence expectedTitle = mActivity.getString(R.string.unlock_footer_medium_complexity_requested, "app name");
mFragment.updatePreferencesOrFinish(false);
FooterPreference footer = mFragment.findPreference(KEY_LOCK_SETTINGS_FOOTER);
assertThat(footer.getTitle()).isEqualTo(expectedTitle);
}
Aggregations