use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ProgressCategory method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
final View progressBar = view.findViewById(R.id.scanning_progress);
boolean noDeviceFound = (getPreferenceCount() == 0 || (getPreferenceCount() == 1 && getPreference(0) == mNoDeviceFoundPreference));
progressBar.setVisibility(mProgress ? View.VISIBLE : View.GONE);
if (mProgress || !noDeviceFound) {
if (mNoDeviceFoundAdded) {
removePreference(mNoDeviceFoundPreference);
mNoDeviceFoundAdded = false;
}
} else {
if (!mNoDeviceFoundAdded) {
if (mNoDeviceFoundPreference == null) {
mNoDeviceFoundPreference = new Preference(getPreferenceManager().getContext());
mNoDeviceFoundPreference.setLayoutResource(R.layout.preference_empty_list);
mNoDeviceFoundPreference.setTitle(mEmptyTextRes);
mNoDeviceFoundPreference.setSelectable(false);
}
addPreference(mNoDeviceFoundPreference);
mNoDeviceFoundAdded = true;
}
}
}
use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccountSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
mProfileNotAvailablePreference = new Preference(getPrefContext());
mAuthorities = getActivity().getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
if (mAuthorities != null) {
mAuthoritiesCount = mAuthorities.length;
}
setHasOptionsMenu(true);
}
use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ProcessStatsDetail method fillProcessesSection.
private void fillProcessesSection() {
mProcGroup.removeAll();
final ArrayList<ProcStatsEntry> entries = new ArrayList<>();
for (int ie = 0; ie < mApp.mEntries.size(); ie++) {
ProcStatsEntry entry = mApp.mEntries.get(ie);
if (entry.mPackage.equals("os")) {
entry.mLabel = entry.mName;
} else {
entry.mLabel = getProcessName(mApp.mUiLabel, entry);
}
entries.add(entry);
}
Collections.sort(entries, sEntryCompare);
for (int ie = 0; ie < entries.size(); ie++) {
ProcStatsEntry entry = entries.get(ie);
Preference processPref = new Preference(getPrefContext());
processPref.setTitle(entry.mLabel);
processPref.setSelectable(false);
long duration = Math.max(entry.mRunDuration, entry.mBgDuration);
long memoryUse = Math.max((long) (entry.mRunWeight * mWeightToRam), (long) (entry.mBgWeight * mWeightToRam));
String memoryString = Formatter.formatShortFileSize(getActivity(), memoryUse);
CharSequence frequency = ProcStatsPackageEntry.getFrequency(duration / (float) mTotalTime, getActivity());
processPref.setSummary(getString(R.string.memory_use_running_format, memoryString, frequency));
mProcGroup.addPreference(processPref);
}
if (mProcGroup.getPreferenceCount() < 2) {
getPreferenceScreen().removePreference(mProcGroup);
}
}
use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageSettings method refresh.
private void refresh() {
final Context context = getPrefContext();
getPreferenceScreen().removeAll();
mInternalCategory.removeAll();
mExternalCategory.removeAll();
mInternalCategory.addPreference(mInternalSummary);
int privateCount = 0;
long privateUsedBytes = 0;
long privateTotalBytes = 0;
final List<VolumeInfo> volumes = mStorageManager.getVolumes();
Collections.sort(volumes, VolumeInfo.getDescriptionComparator());
for (VolumeInfo vol : volumes) {
if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol, sTotalInternalStorage);
final int color = COLOR_PRIVATE[privateCount++ % COLOR_PRIVATE.length];
mInternalCategory.addPreference(new StorageVolumePreference(context, vol, color, volumeTotalBytes));
if (vol.isMountedReadable()) {
final File path = vol.getPath();
privateUsedBytes += (volumeTotalBytes - path.getFreeSpace());
privateTotalBytes += volumeTotalBytes;
}
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
StorageVolumePreference ExStorageVolumePreference = new StorageVolumePreference(context, vol, COLOR_PUBLIC, 0);
//Disable preference when in change
ExStorageVolumePreference.setEnabled(vol.getState() != VolumeInfo.STATE_CHECKING && vol.getState() != VolumeInfo.STATE_EJECTING);
mExternalCategory.addPreference(ExStorageVolumePreference);
}
}
// Show missing private volumes
final List<VolumeRecord> recs = mStorageManager.getVolumeRecords();
for (VolumeRecord rec : recs) {
if (rec.getType() == VolumeInfo.TYPE_PRIVATE && mStorageManager.findVolumeByUuid(rec.getFsUuid()) == null) {
// TODO: add actual storage type to record
final Drawable icon = context.getDrawable(R.drawable.ic_sim_sd);
icon.mutate();
icon.setTint(COLOR_PUBLIC);
icon.setTintMode(PorterDuff.Mode.SRC_ATOP);
final Preference pref = new Preference(context);
pref.setKey(rec.getFsUuid());
pref.setTitle(rec.getNickname());
pref.setSummary(com.android.internal.R.string.ext_media_status_missing);
pref.setIcon(icon);
mInternalCategory.addPreference(pref);
}
}
// Show unsupported disks to give a chance to init
final List<DiskInfo> disks = mStorageManager.getDisks();
for (DiskInfo disk : disks) {
if (disk.volumeCount == 0 && disk.size > 0) {
final Preference pref = new Preference(context);
pref.setKey(disk.getId());
pref.setTitle(disk.getDescription());
pref.setSummary(com.android.internal.R.string.ext_media_status_unsupported);
pref.setIcon(R.drawable.ic_sim_sd);
mExternalCategory.addPreference(pref);
}
}
final BytesResult result = Formatter.formatBytes(getResources(), privateUsedBytes, 0);
mInternalSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large), result.value, result.units));
mInternalSummary.setSummary(getString(R.string.storage_volume_used_total, Formatter.formatFileSize(context, privateTotalBytes)));
if (mInternalCategory.getPreferenceCount() > 0) {
getPreferenceScreen().addPreference(mInternalCategory);
}
if (mExternalCategory.getPreferenceCount() > 0) {
getPreferenceScreen().addPreference(mExternalCategory);
}
if (mInternalCategory.getPreferenceCount() == 2 && mExternalCategory.getPreferenceCount() == 0) {
// Only showing primary internal storage, so just shortcut
final Bundle args = new Bundle();
args.putString(VolumeInfo.EXTRA_VOLUME_ID, VolumeInfo.ID_PRIVATE_INTERNAL);
PrivateVolumeSettings.setVolumeSize(args, sTotalInternalStorage);
Intent intent = Utils.onBuildStartFragmentIntent(getActivity(), PrivateVolumeSettings.class.getName(), args, null, R.string.apps_storage, null, false);
intent.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
getActivity().startActivity(intent);
finish();
}
}
use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InactiveApps method init.
private void init() {
PreferenceGroup screen = getPreferenceScreen();
screen.removeAll();
screen.setOrderingAsAdded(false);
final Context context = getActivity();
final PackageManager pm = context.getPackageManager();
final UsageStatsManager usm = context.getSystemService(UsageStatsManager.class);
Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = pm.queryIntentActivities(launcherIntent, 0);
for (ResolveInfo app : apps) {
String packageName = app.activityInfo.applicationInfo.packageName;
Preference p = new Preference(getPrefContext());
p.setTitle(app.loadLabel(pm));
p.setIcon(app.loadIcon(pm));
p.setKey(packageName);
updateSummary(p);
p.setOnPreferenceClickListener(this);
screen.addPreference(p);
}
}
Aggregations