Search in sources :

Example 86 with PreferenceScreen

use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class About method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.about_rom);
    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getContentResolver();
    mSiteUrl = findPreference("rr_website");
    mSourceUrl = findPreference("rr_source");
    mFacebookUrl = findPreference("rr_facebook");
    mDonateUrl = findPreference("rr_donate");
    mTelegramUrl = findPreference("rr_tg");
    PreferenceGroup devsGroup = (PreferenceGroup) findPreference("devs");
    ArrayList<Preference> devs = new ArrayList<Preference>();
    for (int i = 0; i < devsGroup.getPreferenceCount(); i++) {
        devs.add(devsGroup.getPreference(i));
    }
    devsGroup.removeAll();
    devsGroup.setOrderingAsAdded(false);
    Collections.shuffle(devs);
    for (int i = 0; i < devs.size(); i++) {
        Preference p = devs.get(i);
        p.setOrder(i);
        devsGroup.addPreference(p);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) SwitchPreference(androidx.preference.SwitchPreference) CheckBoxPreference(androidx.preference.CheckBoxPreference) Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) ArrayList(java.util.ArrayList) PreferenceGroup(androidx.preference.PreferenceGroup) ContentResolver(android.content.ContentResolver)

Example 87 with PreferenceScreen

use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class Animations method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.rr_animations);
    mContext = getActivity();
    peakRate = getResources().getInteger(com.android.internal.R.integer.config_defaultPeakRefreshRate);
    ContentResolver resolver = getActivity().getContentResolver();
    PreferenceScreen prefs = getPreferenceScreen();
    mListViewAnimation = (ListPreference) prefs.findPreference(KEY_LISTVIEW_ANIMATION);
    int listviewanimation = Settings.Global.getInt(getContentResolver(), Settings.Global.LISTVIEW_ANIMATION, 0);
    mListViewAnimation.setValue(String.valueOf(listviewanimation));
    mListViewAnimation.setSummary(mListViewAnimation.getEntry());
    mListViewAnimation.setOnPreferenceChangeListener(this);
    mListViewInterpolator = (ListPreference) prefs.findPreference(KEY_LISTVIEW_INTERPOLATOR);
    int listviewinterpolator = Settings.Global.getInt(getContentResolver(), Settings.Global.LISTVIEW_INTERPOLATOR, 0);
    mListViewInterpolator.setValue(String.valueOf(listviewinterpolator));
    mListViewInterpolator.setSummary(mListViewInterpolator.getEntry());
    mListViewInterpolator.setOnPreferenceChangeListener(this);
    mListViewInterpolator.setEnabled(listviewanimation > 0);
    mScreenOffAnimation = (ListPreference) findPreference(SCREEN_OFF_ANIMATION);
    int screenOffStyle = Settings.System.getInt(resolver, Settings.System.SCREEN_OFF_ANIMATION, 0);
    mScreenOffAnimation.setValue(String.valueOf(screenOffStyle));
    mScreenOffAnimation.setSummary(mScreenOffAnimation.getEntry());
    mScreenOffAnimation.setOnPreferenceChangeListener(this);
    mScrollingCachePref = (ListPreference) findPreference(SCROLLINGCACHE_PREF);
    mScrollingCachePref.setValue(SystemProperties.get(SCROLLINGCACHE_PERSIST_PROP, SystemProperties.get(SCROLLINGCACHE_PERSIST_PROP, SCROLLINGCACHE_DEFAULT)));
    mScrollingCachePref.setSummary(mScrollingCachePref.getEntry());
    mScrollingCachePref.setOnPreferenceChangeListener(this);
    mRefreshRate = (ListPreference) findPreference(KEY_REFRESH_RATE);
    if (isAvailable()) {
        int defVarRateSetting = getContext().getResources().getInteger(com.android.internal.R.integer.config_defaultVariableRefreshRateSetting);
        int refreshRate = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.REFRESH_RATE_SETTING, defVarRateSetting);
        mRefreshRate.setValue(String.valueOf(refreshRate));
        mRefreshRate.setOnPreferenceChangeListener(this);
        updateRefreshRate(refreshRate);
    } else {
        removePreference("refresh_rate_setting");
    }
    int anim = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.RR_CONFIG_ANIM, 0);
    try {
        if (anim == 0) {
            removePreference("animation");
        } else if (anim == 1) {
            removePreference("preview");
        } else if (anim == 2) {
            removePreference("animation");
            removePreference("preview");
        }
    } catch (Exception e) {
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) RemoteException(android.os.RemoteException) ContentResolver(android.content.ContentResolver)

Example 88 with PreferenceScreen

use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BatterySettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.aggressive_battery);
    mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.add_sensor_block_package_summary);
    final PreferenceScreen prefScreen = getPreferenceScreen();
    mPackageManager = getPackageManager();
    mPackageAdapter = new PackageListAdapter(getActivity());
    mSensorBlockPrefList = (PreferenceGroup) findPreference("sensor_block_applications");
    mSensorBlockPrefList.setOrderingAsAdded(false);
    mBlockedPackages = new HashMap<String, Package>();
    mAddSensorBlockPref = findPreference("add_sensor_block_packages");
    mAddSensorBlockPref.setOnPreferenceClickListener(this);
    mContext = getActivity().getApplicationContext();
    int anim = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.RR_CONFIG_ANIM, 0);
    try {
        if (anim == 0) {
            removePreference("animation");
        } else if (anim == 1) {
            removePreference("preview");
        } else if (anim == 2) {
            removePreference("animation");
            removePreference("preview");
        }
    } catch (Exception e) {
    }
}
Also used : PackageListAdapter(com.android.settings.rr.Preferences.PackageListAdapter) PreferenceScreen(androidx.preference.PreferenceScreen) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 89 with PreferenceScreen

use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ScreenPinningSettings method updateDisplay.

public void updateDisplay() {
    PreferenceScreen root = getPreferenceScreen();
    if (root != null) {
        root.removeAll();
    }
    if (isLockToAppEnabled(getActivity())) {
        addPreferencesFromResource(R.xml.screen_pinning_settings);
        root = getPreferenceScreen();
        mUseScreenLock = (SwitchPreference) root.findPreference(KEY_USE_SCREEN_LOCK);
        mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                return setScreenLockUsed((boolean) newValue);
            }
        });
        mUseScreenLock.setChecked(isScreenLockUsed());
        mUseScreenLock.setTitle(getCurrentSecurityTitle());
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) OnPreferenceChangeListener(androidx.preference.Preference.OnPreferenceChangeListener)

Example 90 with PreferenceScreen

use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PrivateVolumeSettings method update.

private void update() {
    if (!isVolumeValid()) {
        getActivity().finish();
        return;
    }
    setTitle();
    // Valid options may have changed
    getActivity().invalidateOptionsMenu();
    final Context context = getActivity();
    final PreferenceScreen screen = getPreferenceScreen();
    screen.removeAll();
    addPreference(screen, mSummary);
    List<UserInfo> allUsers = mUserManager.getUsers();
    final int userCount = allUsers.size();
    final boolean showHeaders = userCount > 1;
    final boolean showShared = (mSharedVolume != null) && mSharedVolume.isMountedReadable();
    mItemPoolIndex = 0;
    mHeaderPoolIndex = 0;
    int addedUserCount = 0;
    // Add current user and its profiles first
    for (int userIndex = 0; userIndex < userCount; ++userIndex) {
        final UserInfo userInfo = allUsers.get(userIndex);
        if (Utils.isProfileOf(mCurrentUser, userInfo)) {
            final PreferenceGroup details = showHeaders ? addCategory(screen, userInfo.name) : screen;
            addDetailItems(details, showShared, userInfo.id);
            ++addedUserCount;
        }
    }
    // Add rest of users
    if (userCount - addedUserCount > 0) {
        PreferenceGroup otherUsers = addCategory(screen, getText(R.string.storage_other_users));
        for (int userIndex = 0; userIndex < userCount; ++userIndex) {
            final UserInfo userInfo = allUsers.get(userIndex);
            if (!Utils.isProfileOf(mCurrentUser, userInfo)) {
                addItem(otherUsers, /* titleRes */
                0, userInfo.name, userInfo.id);
            }
        }
    }
    addItem(screen, R.string.storage_detail_cached, null, UserHandle.USER_NULL);
    if (showShared) {
        addPreference(screen, mExplore);
    }
    final long freeBytes = mVolume.getPath().getFreeSpace();
    final long usedBytes = mTotalSize - freeBytes;
    if (LOGV)
        Log.v(TAG, "update() freeBytes: " + freeBytes + " usedBytes: " + usedBytes);
    final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
    mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large), result.value, result.units));
    mSummary.setSummary(getString(R.string.storage_volume_used, Formatter.formatFileSize(context, mTotalSize)));
    mSummary.setPercent(usedBytes, mTotalSize);
    mMeasure.forceMeasure();
    mNeedsUpdate = false;
}
Also used : Context(android.content.Context) PreferenceScreen(androidx.preference.PreferenceScreen) UserInfo(android.content.pm.UserInfo) PreferenceGroup(androidx.preference.PreferenceGroup) BytesResult(android.text.format.Formatter.BytesResult)

Aggregations

PreferenceScreen (androidx.preference.PreferenceScreen)244 Preference (androidx.preference.Preference)81 Test (org.junit.Test)60 Context (android.content.Context)36 PreferenceManager (androidx.preference.PreferenceManager)36 ContentResolver (android.content.ContentResolver)25 PreferenceCategory (androidx.preference.PreferenceCategory)24 Bundle (android.os.Bundle)20 ArrayList (java.util.ArrayList)20 SwitchPreference (androidx.preference.SwitchPreference)19 Resources (android.content.res.Resources)18 Before (org.junit.Before)17 ListPreference (androidx.preference.ListPreference)14 PackageManager (android.content.pm.PackageManager)13 PreferenceGroup (androidx.preference.PreferenceGroup)13 ApplicationInfo (android.content.pm.ApplicationInfo)9 VisibleForTesting (androidx.annotation.VisibleForTesting)9 List (java.util.List)9 UserManager (android.os.UserManager)8 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)8