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());
}
}
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);
}
}
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;
}
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;
}
}
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);
}
}
Aggregations