Search in sources :

Example 26 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by LineageOS.

the class PowerUsageAnomalyDetailsTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mAbnormalListGroup = spy(new PreferenceCategory(mContext));
    mAnomalyList = new ArrayList<>();
    Anomaly anomaly1 = new Anomaly.Builder().setType(Anomaly.AnomalyType.WAKE_LOCK).setPackageName(PACKAGE_NAME_1).setDisplayName(NAME_APP_1).build();
    mAnomalyList.add(anomaly1);
    Anomaly anomaly2 = new Anomaly.Builder().setType(Anomaly.AnomalyType.WAKEUP_ALARM).setPackageName(PACKAGE_NAME_2).setDisplayName(NAME_APP_2).build();
    mAnomalyList.add(anomaly2);
    Anomaly anomaly3 = new Anomaly.Builder().setType(Anomaly.AnomalyType.BLUETOOTH_SCAN).setPackageName(PACKAGE_NAME_3).setDisplayName(NAME_APP_3).build();
    mAnomalyList.add(anomaly3);
    mFragment = spy(new PowerUsageAnomalyDetails());
    mFragment.mAbnormalListGroup = mAbnormalListGroup;
    mFragment.mAnomalies = mAnomalyList;
    mFragment.mBatteryUtils = new BatteryUtils(mContext);
    mFragment.mPackageManager = mPackageManager;
    mFragment.mIconDrawableFactory = mIconDrawableFactory;
    doReturn(mPreferenceManager).when(mFragment).getPreferenceManager();
    doReturn(mContext).when(mPreferenceManager).getContext();
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) Anomaly(com.android.settings.fuelgauge.anomaly.Anomaly) Before(org.junit.Before)

Example 27 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_crDroidSettings by crdroidandroid.

the class Fling method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.fling_settings);
    ContentResolver resolver = getActivity().getContentResolver();
    mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.fling_back_home_policy);
    mContext = (Context) getActivity();
    mIconPickHelper = new IconPickHelper(getActivity(), this);
    mShowLogo = (SwitchPreference) findPreference("eos_fling_show_logo");
    mShowLogo.setChecked(Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LOGO_VISIBLE, 1, UserHandle.USER_CURRENT) == 1);
    mShowLogo.setOnPreferenceChangeListener(this);
    mAnimateLogo = (SwitchPreference) findPreference("eos_fling_animate_logo");
    mAnimateLogo.setChecked(Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LOGO_ANIMATES, 1, UserHandle.USER_CURRENT) == 1);
    mAnimateLogo.setOnPreferenceChangeListener(this);
    mShowRipple = (SwitchPreference) findPreference("eos_fling_show_ripple");
    mShowRipple.setChecked(Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_RIPPLE_ENABLED, 1, UserHandle.USER_CURRENT) == 1);
    mShowRipple.setOnPreferenceChangeListener(this);
    int rippleColor = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_RIPPLE_COLOR, Color.WHITE, UserHandle.USER_CURRENT);
    mRippleColor = (ColorPickerPreference) findPreference("eos_fling_ripple_color");
    mRippleColor.setNewPreviewColor(rippleColor);
    mRippleColor.setOnPreferenceChangeListener(this);
    // NOTE: we display to the user actual timeouts starting from touch event
    // but framework wants the value less tap timeout, which is 100ms
    // so we always write 100ms less but display 100ms more
    mLongPressTimeout = (CustomSeekBarPreference) findPreference("du_fling_longpress_pref");
    int val = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LONGPRESS_TIMEOUT, 250, UserHandle.USER_CURRENT);
    val += 100;
    mLongPressTimeout.setValue(val);
    mLongPressTimeout.setOnPreferenceChangeListener(this);
    final boolean isTablet = !DUActionUtils.navigationBarCanMove();
    mSwipePortRight = (CustomSeekBarPreference) findPreference("du_fling_longswipe_port_right");
    val = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LONGSWIPE_THRESHOLD_RIGHT_PORT, isTablet ? 30 : 40, UserHandle.USER_CURRENT);
    mSwipePortRight.setValue(val);
    mSwipePortRight.setOnPreferenceChangeListener(this);
    mSwipePortLeft = (CustomSeekBarPreference) findPreference("du_fling_longswipe_port_left");
    val = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LONGSWIPE_THRESHOLD_LEFT_PORT, isTablet ? 30 : 40, UserHandle.USER_CURRENT);
    mSwipePortLeft.setValue(val);
    mSwipePortLeft.setOnPreferenceChangeListener(this);
    mSwipeLandRight = (CustomSeekBarPreference) findPreference("du_fling_longswipe_land_right");
    mSwipeLandLeft = (CustomSeekBarPreference) findPreference("du_fling_longswipe_land_left");
    mSwipeVertUp = (CustomSeekBarPreference) findPreference("du_fling_longswipe_vert_up");
    mSwipeVertDown = (CustomSeekBarPreference) findPreference("du_fling_longswipe_vert_down");
    PreferenceCategory longSwipeCategory = (PreferenceCategory) getPreferenceScreen().findPreference("eos_long_swipe_category");
    if (isTablet) {
        longSwipeCategory.removePreference(mSwipeVertUp);
        longSwipeCategory.removePreference(mSwipeVertDown);
        val = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LONGSWIPE_THRESHOLD_RIGHT_LAND, 25, UserHandle.USER_CURRENT);
        mSwipeLandRight.setValue(val);
        mSwipeLandRight.setOnPreferenceChangeListener(this);
        val = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LONGSWIPE_THRESHOLD_LEFT_LAND, 25, UserHandle.USER_CURRENT);
        mSwipeLandLeft.setValue(val);
        mSwipeLandLeft.setOnPreferenceChangeListener(this);
    } else {
        longSwipeCategory.removePreference(mSwipeLandRight);
        longSwipeCategory.removePreference(mSwipeLandLeft);
        val = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LONGSWIPE_THRESHOLD_UP_LAND, 40, UserHandle.USER_CURRENT);
        mSwipeVertUp.setValue(val);
        mSwipeVertUp.setOnPreferenceChangeListener(this);
        val = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LONGSWIPE_THRESHOLD_DOWN_LAND, 40, UserHandle.USER_CURRENT);
        mSwipeVertDown.setValue(val);
        mSwipeVertDown.setOnPreferenceChangeListener(this);
    }
    mKbCursors = (SwitchPreference) findPreference("fling_keyboard_cursors");
    mKbCursors.setChecked(Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_KEYBOARD_CURSORS, 1, UserHandle.USER_CURRENT) == 1);
    mKbCursors.setOnPreferenceChangeListener(this);
    mLogoOpacity = (CustomSeekBarPreference) findPreference("fling_logo_opacity");
    int alpha = Settings.Secure.getIntForUser(resolver, Settings.Secure.FLING_LOGO_OPACITY, 255, UserHandle.USER_CURRENT);
    mLogoOpacity.setValue(alpha);
    mLogoOpacity.setOnPreferenceChangeListener(this);
    onPreferenceScreenLoaded(ActionConstants.getDefaults(ActionConstants.FLING));
}
Also used : IconPickHelper(com.crdroid.settings.fragments.navbar.IconPickHelper) PreferenceCategory(android.support.v7.preference.PreferenceCategory) ContentResolver(android.content.ContentResolver)

Example 28 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class AccessibilitySettings method initializeAllPreferences.

private void initializeAllPreferences() {
    for (int i = 0; i < CATEGORIES.length; i++) {
        PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
        mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory);
    }
    // Text contrast.
    mToggleHighTextContrastPreference = (SwitchPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE);
    // Display inversion.
    mToggleInversionPreference = (SwitchPreference) findPreference(TOGGLE_INVERSION_PREFERENCE);
    mToggleInversionPreference.setOnPreferenceChangeListener(this);
    // Power button ends calls.
    mTogglePowerButtonEndsCallPreference = (SwitchPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE);
    if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER) || !Utils.isVoiceCapable(getActivity())) {
        mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL).removePreference(mTogglePowerButtonEndsCallPreference);
    }
    // Lock screen rotation.
    /*mToggleLockScreenRotationPreference =
                (SwitchPreference) findPreference(TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE);
        if (!RotationPolicy.isRotationSupported(getActivity())) {
            mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL)
                    .removePreference(mToggleLockScreenRotationPreference);
        }*/
    // Large pointer icon.
    mToggleLargePointerIconPreference = (SwitchPreference) findPreference(TOGGLE_LARGE_POINTER_ICON);
    // Master Mono
    mToggleMasterMonoPreference = (SwitchPreference) findPreference(TOGGLE_MASTER_MONO);
    // Long press timeout.
    mSelectLongPressTimeoutPreference = (ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE);
    mSelectLongPressTimeoutPreference.setOnPreferenceChangeListener(this);
    if (mLongPressTimeoutValueToTitleMap.size() == 0) {
        String[] timeoutValues = getResources().getStringArray(R.array.long_press_timeout_selector_values);
        mLongPressTimeoutDefault = Integer.parseInt(timeoutValues[0]);
        String[] timeoutTitles = getResources().getStringArray(R.array.long_press_timeout_selector_titles);
        final int timeoutValueCount = timeoutValues.length;
        for (int i = 0; i < timeoutValueCount; i++) {
            mLongPressTimeoutValueToTitleMap.put(timeoutValues[i], timeoutTitles[i]);
        }
    }
    // Captioning.
    mCaptioningPreferenceScreen = findPreference(CAPTIONING_PREFERENCE_SCREEN);
    // Display magnification.
    mDisplayMagnificationPreferenceScreen = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
    configureMagnificationPreferenceIfNeeded(mDisplayMagnificationPreferenceScreen);
    // Font size.
    mFontSizePreferenceScreen = findPreference(FONT_SIZE_PREFERENCE_SCREEN);
    // Autoclick after pointer stops.
    mAutoclickPreferenceScreen = findPreference(AUTOCLICK_PREFERENCE_SCREEN);
    // Display color adjustments.
    mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
    // Accessibility shortcut
    mAccessibilityShortcutPreferenceScreen = findPreference(ACCESSIBILITY_SHORTCUT_PREFERENCE);
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory)

Example 29 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class AccessibilitySettings method initializePreBundledServicesMapFromArray.

private void initializePreBundledServicesMapFromArray(String categoryKey, int key) {
    String[] services = getResources().getStringArray(key);
    PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
    for (int i = 0; i < services.length; i++) {
        ComponentName component = ComponentName.unflattenFromString(services[i]);
        mPreBundledServiceComponentToCategoryMap.put(component, category);
    }
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) ComponentName(android.content.ComponentName)

Example 30 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class ManageDomainUrls method onRebuildComplete.

@Override
public void onRebuildComplete(ArrayList<AppEntry> apps) {
    if (getContext() == null) {
        return;
    }
    final boolean disableWebActions = Global.getInt(getContext().getContentResolver(), Global.ENABLE_EPHEMERAL_FEATURE, 1) == 0;
    if (disableWebActions) {
        mDomainAppList = getPreferenceScreen();
    } else {
        final PreferenceGroup preferenceScreen = getPreferenceScreen();
        if (preferenceScreen.getPreferenceCount() == 0) {
            // add preferences
            final PreferenceCategory webActionCategory = new PreferenceCategory(getPrefContext());
            webActionCategory.setTitle(R.string.web_action_section_title);
            preferenceScreen.addPreference(webActionCategory);
            // toggle to enable / disable Web Actions [aka Instant Apps]
            mWebAction = new SwitchPreference(getPrefContext());
            mWebAction.setTitle(R.string.web_action_enable_title);
            mWebAction.setSummary(R.string.web_action_enable_summary);
            mWebAction.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTANT_APPS_ENABLED, 1) != 0);
            mWebAction.setOnPreferenceChangeListener(this);
            webActionCategory.addPreference(mWebAction);
            // Determine whether we should show the instant apps account chooser setting
            ComponentName instantAppSettingsComponent = getActivity().getPackageManager().getInstantAppResolverSettingsComponent();
            Intent instantAppSettingsIntent = null;
            if (instantAppSettingsComponent != null) {
                instantAppSettingsIntent = new Intent().setComponent(instantAppSettingsComponent);
            }
            if (instantAppSettingsIntent != null) {
                final Intent launchIntent = instantAppSettingsIntent;
                // TODO: Make this button actually launch the account chooser.
                mInstantAppAccountPreference = new Preference(getPrefContext());
                mInstantAppAccountPreference.setTitle(R.string.instant_apps_settings);
                mInstantAppAccountPreference.setOnPreferenceClickListener(pref -> {
                    startActivity(launchIntent);
                    return true;
                });
                webActionCategory.addPreference(mInstantAppAccountPreference);
            }
            // list to manage link handling per app
            mDomainAppList = new PreferenceCategory(getPrefContext());
            mDomainAppList.setTitle(R.string.domain_url_section_title);
            preferenceScreen.addPreference(mDomainAppList);
        }
    }
    rebuildAppList(mDomainAppList, apps);
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) SwitchPreference(android.support.v14.preference.SwitchPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) PreferenceGroup(android.support.v7.preference.PreferenceGroup) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Aggregations

PreferenceCategory (android.support.v7.preference.PreferenceCategory)166 Preference (android.support.v7.preference.Preference)105 PreferenceScreen (android.support.v7.preference.PreferenceScreen)75 Intent (android.content.Intent)35 Context (android.content.Context)34 SwitchPreference (android.support.v14.preference.SwitchPreference)31 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)27 ArrayList (java.util.ArrayList)24 ComponentName (android.content.ComponentName)22 ListPreference (android.support.v7.preference.ListPreference)18 Bundle (android.os.Bundle)16 PreferenceGroup (android.support.v7.preference.PreferenceGroup)14 DimmableIconPreference (com.android.settings.DimmableIconPreference)14 ContentResolver (android.content.ContentResolver)13 LayoutPreference (com.android.settings.applications.LayoutPreference)13 PreferenceManager (android.support.v7.preference.PreferenceManager)12 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)12 FooterPreference (com.android.settingslib.widget.FooterPreference)12 Test (org.junit.Test)12 Activity (android.app.Activity)9