Search in sources :

Example 26 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AdaptiveSleepSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final FooterPreference footerPreference = mFooterPreferenceMixin.createFooterPreference();
    mContext = getContext();
    footerPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
    footerPreference.setTitle(R.string.adaptive_sleep_privacy);
    Preference permissionPreference = findPreference(AdaptiveSleepPermissionPreferenceController.PREF_NAME);
    if (permissionPreference != null) {
        permissionPreference.setVisible(false);
    }
    mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE).edit().putBoolean(PREF_KEY_INTERACTED, true).apply();
}
Also used : Preference(androidx.preference.Preference) FooterPreference(com.android.settingslib.widget.FooterPreference) FooterPreference(com.android.settingslib.widget.FooterPreference)

Example 27 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DcDimmingSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = getContext();
    mDcDimmingManager = (DcDimmingManager) getSystemService(Context.DC_DIM_SERVICE);
    if (mDcDimmingManager == null || !mDcDimmingManager.isAvailable()) {
        return;
    }
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mMinimumBacklight = pm.getMinimumScreenBrightnessSetting();
    mMaximumBacklight = pm.getMaximumScreenBrightnessSetting();
    SettingsObserver settingsObserver = new SettingsObserver(new Handler());
    settingsObserver.observe();
    LayoutPreference brightnessPreference = findPreference(KEY_BRIGHTNESS);
    mSeekBar = brightnessPreference.findViewById(R.id.seekbar);
    mBrightnessValue = brightnessPreference.findViewById(R.id.value);
    mBrightnessTitle = brightnessPreference.findViewById(R.id.title);
    mBrightnessSumm = brightnessPreference.findViewById(R.id.summary);
    mSeekBar.setOnSeekBarChangeListener(this);
    mSeekBar.setMax(GAMMA_SPACE_MAX / 2);
    LayoutPreference preference = findPreference(KEY_FORCE_BUTTON);
    mTurnOnButton = preference.findViewById(R.id.dc_dimming_on_button);
    mTurnOnButton.setOnClickListener(mForceListener);
    mTurnOffButton = preference.findViewById(R.id.dc_dimming_off_button);
    mTurnOffButton.setOnClickListener(mForceListener);
    mRestoreAuto = findPreference(KEY_RESTORE_BUTTON);
    Button restoreActiveButton = mRestoreAuto.findViewById(R.id.dc_dimming_restore_active);
    restoreActiveButton.setOnClickListener(mRestoreListener);
    mDropPreference = findPreference(KEY_AUTO_MODE);
    mDropPreference.setEntries(new CharSequence[] { mContext.getString(R.string.dark_ui_auto_mode_never), mContext.getString(R.string.dark_ui_auto_mode_auto), mContext.getString(R.string.dc_dimming_mode_brightness), mContext.getString(R.string.dc_dimming_mode_full) });
    mDropPreference.setEntryValues(new CharSequence[] { String.valueOf(MODE_AUTO_OFF), String.valueOf(MODE_AUTO_TIME), String.valueOf(MODE_AUTO_BRIGHTNESS), String.valueOf(MODE_AUTO_FULL) });
    mDropPreference.setValue(String.valueOf(mDcDimmingManager.getAutoMode()));
    mDropPreference.setOnPreferenceChangeListener(this);
    Preference footerPreference = findPreference(FooterPreference.KEY_FOOTER);
    footerPreference.setTitle(mContext.getResources().getString(R.string.dc_dimming_info));
    final int gamma = convertLinearToGamma(mDcDimmingManager.getBrightnessThreshold(), mMinimumBacklight, mMaximumBacklight);
    mSeekBar.setProgress(gamma);
    updateStateInternal();
}
Also used : PowerManager(android.os.PowerManager) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Button(android.widget.Button) LayoutPreference(com.android.settingslib.widget.LayoutPreference) DropDownPreference(androidx.preference.DropDownPreference) Preference(androidx.preference.Preference) FooterPreference(com.android.settingslib.widget.FooterPreference) Handler(android.os.Handler)

Example 28 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MultiUserFooterPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    mUserCaps.updateAddUserCapabilities(mContext);
    final FooterPreference pref = mFooterMixin.createFooterPreference();
    pref.setTitle(R.string.user_settings_footer_text);
    pref.setVisible(isAvailable());
}
Also used : FooterPreference(com.android.settingslib.widget.FooterPreference)

Example 29 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LocationFooterPreferenceController method updateState.

/**
 * Insert footer preferences. Send a {@link LocationManager#SETTINGS_FOOTER_DISPLAYED_ACTION}
 * broadcast to receivers who have injected a footer
 */
@Override
public void updateState(Preference preference) {
    PreferenceCategory category = (PreferenceCategory) preference;
    category.removeAll();
    mFooterInjectors.clear();
    Collection<FooterData> footerData = getFooterData();
    for (FooterData data : footerData) {
        // Generate a footer preference with the given text
        FooterPreference footerPreference = new FooterPreference(preference.getContext());
        String footerString;
        try {
            footerString = mPackageManager.getResourcesForApplication(data.applicationInfo).getString(data.footerStringRes);
        } catch (NameNotFoundException exception) {
            Log.w(TAG, "Resources not found for application " + data.applicationInfo.packageName);
            continue;
        }
        footerPreference.setTitle(footerString);
        // Inject the footer
        category.addPreference(footerPreference);
        // Send broadcast to the injector announcing a footer has been injected
        sendBroadcastFooterDisplayed(data.componentName);
        mFooterInjectors.add(data.componentName);
    }
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) FooterPreference(com.android.settingslib.widget.FooterPreference)

Example 30 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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) {
        SupportPageLearnMoreSpan.linkify(mFooterText, this, mHelpUri);
        pref.setTitle(mFooterText);
    }
}
Also used : FooterPreference(com.android.settingslib.widget.FooterPreference) VisibleForTesting(androidx.annotation.VisibleForTesting)

Aggregations

FooterPreference (com.android.settingslib.widget.FooterPreference)56 Before (org.junit.Before)14 Test (org.junit.Test)12 NotificationChannel (android.app.NotificationChannel)6 NotificationChannelGroup (android.app.NotificationChannelGroup)6 Preference (android.support.v7.preference.Preference)6 PreferenceCategory (android.support.v7.preference.PreferenceCategory)6 View (android.view.View)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 Intent (android.content.Intent)5 Preference (androidx.preference.Preference)5 PreferenceScreen (androidx.preference.PreferenceScreen)3 Context (android.content.Context)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Handler (android.os.Handler)1 PowerManager (android.os.PowerManager)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1