Search in sources :

Example 76 with FooterPreference

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);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) CandidateInfo(com.android.settingslib.widget.CandidateInfo) SpannableString(android.text.SpannableString) FooterPreference(com.android.settingslib.widget.FooterPreference) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference)

Example 77 with FooterPreference

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()));
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) FooterPreference(com.android.settingslib.widget.FooterPreference)

Example 78 with FooterPreference

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);
}
Also used : FooterPreference(com.android.settingslib.widget.FooterPreference)

Example 79 with FooterPreference

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));
    }
}
Also used : FooterPreference(com.android.settingslib.widget.FooterPreference) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 80 with FooterPreference

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);
}
Also used : Intent(android.content.Intent) FooterPreference(com.android.settingslib.widget.FooterPreference) Test(org.junit.Test)

Aggregations

FooterPreference (com.android.settingslib.widget.FooterPreference)84 Test (org.junit.Test)22 Before (org.junit.Before)18 Intent (android.content.Intent)17 Preference (androidx.preference.Preference)10 View (android.view.View)8 PreferenceScreen (androidx.preference.PreferenceScreen)7 NotificationChannel (android.app.NotificationChannel)6 NotificationChannelGroup (android.app.NotificationChannelGroup)6 Preference (android.support.v7.preference.Preference)6 PreferenceCategory (android.support.v7.preference.PreferenceCategory)6 TextView (android.widget.TextView)6 LayoutPreference (com.android.settings.applications.LayoutPreference)6 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)6 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)6 Context (android.content.Context)3 Drawable (android.graphics.drawable.Drawable)2 SpannableString (android.text.SpannableString)2 Pair (android.util.Pair)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2