Search in sources :

Example 56 with Preference

use of android.support.v7.preference.Preference 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(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener)

Example 57 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsageList method bindStats.

/**
     * Bind the given {@link NetworkStats}, or {@code null} to clear list.
     */
public void bindStats(NetworkStats stats, int[] restrictedUids) {
    ArrayList<AppItem> items = new ArrayList<>();
    long largest = 0;
    final int currentUserId = ActivityManager.getCurrentUser();
    UserManager userManager = UserManager.get(getContext());
    final List<UserHandle> profiles = userManager.getUserProfiles();
    final SparseArray<AppItem> knownItems = new SparseArray<AppItem>();
    PackageManager pm = getContext().getPackageManager();
    ApplicationInfo ai = null;
    try {
        ai = pm.getApplicationInfo("com.android.dialer", PackageManager.GET_ACTIVITIES);
    } catch (Exception e) {
        Log.d(TAG, "get dialer getApplicationInfo failed " + e);
    }
    NetworkStats.Entry entry = null;
    final int size = stats != null ? stats.size() : 0;
    for (int i = 0; i < size; i++) {
        entry = stats.getValues(i, entry);
        // Decide how to collapse items together
        final int uid = entry.uid;
        final int collapseKey;
        final int category;
        final int userId = UserHandle.getUserId(uid);
        if (UserHandle.isApp(uid)) {
            if (profiles.contains(new UserHandle(userId))) {
                if (userId != currentUserId) {
                    // Add to a managed user item.
                    final int managedKey = UidDetailProvider.buildKeyForUser(userId);
                    largest = accumulate(managedKey, knownItems, entry, AppItem.CATEGORY_USER, items, largest);
                }
                // Add to app item.
                collapseKey = uid;
                category = AppItem.CATEGORY_APP;
            } else {
                // If it is a removed user add it to the removed users' key
                final UserInfo info = userManager.getUserInfo(userId);
                if (info == null) {
                    collapseKey = UID_REMOVED;
                    category = AppItem.CATEGORY_APP;
                } else {
                    // Add to other user item.
                    collapseKey = UidDetailProvider.buildKeyForUser(userId);
                    category = AppItem.CATEGORY_USER;
                }
            }
        } else if (uid == UID_REMOVED || uid == UID_TETHERING) {
            collapseKey = uid;
            category = AppItem.CATEGORY_APP;
        } else if ((ai != null) && (uid == ai.uid) && getContext().getResources().getBoolean(com.android.internal.R.bool.config_video_call_datausage_enable)) {
            collapseKey = uid;
            category = AppItem.CATEGORY_APP;
        } else {
            collapseKey = android.os.Process.SYSTEM_UID;
            category = AppItem.CATEGORY_APP;
        }
        largest = accumulate(collapseKey, knownItems, entry, category, items, largest);
    }
    final int restrictedUidsMax = restrictedUids.length;
    for (int i = 0; i < restrictedUidsMax; ++i) {
        final int uid = restrictedUids[i];
        // Only splice in restricted state for current user or managed users
        if (!profiles.contains(new UserHandle(UserHandle.getUserId(uid)))) {
            continue;
        }
        AppItem item = knownItems.get(uid);
        if (item == null) {
            item = new AppItem(uid);
            item.total = -1;
            items.add(item);
            knownItems.put(item.key, item);
        }
        item.restricted = true;
    }
    Collections.sort(items);
    mApps.removeAll();
    for (int i = 0; i < items.size(); i++) {
        final int percentTotal = largest != 0 ? (int) (items.get(i).total * 100 / largest) : 0;
        AppDataUsagePreference preference = new AppDataUsagePreference(getContext(), items.get(i), percentTotal, mUidDetailProvider);
        preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                AppDataUsagePreference pref = (AppDataUsagePreference) preference;
                AppItem item = pref.getItem();
                startAppDataUsage(item);
                return true;
            }
        });
        mApps.addPreference(preference);
    }
}
Also used : ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) NetworkStats(android.net.NetworkStats) UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException) SparseArray(android.util.SparseArray) PackageManager(android.content.pm.PackageManager) AppItem(com.android.settingslib.AppItem) Preference(android.support.v7.preference.Preference) UserManager(android.os.UserManager) UserHandle(android.os.UserHandle)

Example 58 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsageSummary method inflatePreferences.

private Preference inflatePreferences(int resId) {
    PreferenceScreen rootPreferences = getPreferenceManager().inflateFromResource(getPrefContext(), resId, null);
    Preference pref = rootPreferences.getPreference(0);
    rootPreferences.removeAll();
    PreferenceScreen screen = getPreferenceScreen();
    pref.setOrder(screen.getPreferenceCount());
    screen.addPreference(pref);
    return pref;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) SummaryPreference(com.android.settings.SummaryPreference) Preference(android.support.v7.preference.Preference)

Example 59 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsageList method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Context context = getActivity();
    if (!isBandwidthControlEnabled()) {
        Log.w(TAG, "No bandwidth control; leaving");
        getActivity().finish();
    }
    try {
        mStatsSession = services.mStatsService.openSession();
    } catch (RemoteException e) {
        throw new RuntimeException(e);
    }
    mUidDetailProvider = new UidDetailProvider(context);
    addPreferencesFromResource(R.xml.data_usage_list);
    mUsageAmount = findPreference(KEY_USAGE_AMOUNT);
    mChart = (ChartDataUsagePreference) findPreference(KEY_CHART_DATA);
    mApps = (PreferenceGroup) findPreference(KEY_APPS_GROUP);
    final Bundle args = getArguments();
    mSubId = args.getInt(EXTRA_SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    mTemplate = args.getParcelable(EXTRA_NETWORK_TEMPLATE);
    mChartDeprecated = (ChartDataUsageDeprecatedPreference) findPreference(KEY_CHART_DATA_DEPRECATED);
    mChartDeprecated.setListener(mChartListener);
    mChartDeprecated.bindNetworkPolicy(null);
    mUsageSummary = (Preference) findPreference(KEY_USAGE_SUMMARY);
    mDataSelectionEnable = BillingCycleSettings.isDataSelectionEnable(context);
    mShowDataUsage = BillingCycleSettings.isShowDataUsage(context);
    if (mDataSelectionEnable) {
        //use chartDataUsageDeprecatedPreference instead;
        ((PreferenceGroup) mUsageAmount).removePreference(mChart);
        //getPreferenceScreen().removePreference(mChart);
        mChart = null;
    } else {
        ((PreferenceGroup) mUsageAmount).removePreference(mChartDeprecated);
        //getPreferenceScreen().removePreference(mChartDeprecated);
        mChartDeprecated = null;
    }
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) PreferenceGroup(android.support.v7.preference.PreferenceGroup) RemoteException(android.os.RemoteException) UidDetailProvider(com.android.settingslib.net.UidDetailProvider)

Example 60 with Preference

use of android.support.v7.preference.Preference 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");
    mForumUrl = findPreference("rr_forum");
    mSourceUrl = findPreference("rr_source");
    mFacebookUrl = findPreference("rr_facebook");
    mGoogleUrl = findPreference("rr_google_plus");
    mDonateUrl = findPreference("rr_donate");
    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(android.support.v7.preference.PreferenceScreen) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) ArrayList(java.util.ArrayList) PreferenceGroup(android.support.v7.preference.PreferenceGroup) ContentResolver(android.content.ContentResolver)

Aggregations

Preference (android.support.v7.preference.Preference)122 PreferenceScreen (android.support.v7.preference.PreferenceScreen)44 SwitchPreference (android.support.v14.preference.SwitchPreference)33 Intent (android.content.Intent)27 ListPreference (android.support.v7.preference.ListPreference)27 Context (android.content.Context)17 PreferenceCategory (android.support.v7.preference.PreferenceCategory)17 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)15 ArrayList (java.util.ArrayList)14 PackageManager (android.content.pm.PackageManager)11 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)11 PreferenceGroup (android.support.v7.preference.PreferenceGroup)11 TwoStatePreference (android.support.v7.preference.TwoStatePreference)11 Activity (android.app.Activity)10 View (android.view.View)10 Bundle (android.os.Bundle)9 TextView (android.widget.TextView)8 AlertDialog (android.support.v7.app.AlertDialog)7 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7