Search in sources :

Example 21 with Preference

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;
        }
    }
}
Also used : Preference(android.support.v7.preference.Preference) View(android.view.View)

Example 22 with Preference

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);
}
Also used : DimmableIconPreference(com.android.settings.DimmableIconPreference) Preference(android.support.v7.preference.Preference)

Example 23 with Preference

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);
    }
}
Also used : SummaryPreference(com.android.settings.SummaryPreference) Preference(android.support.v7.preference.Preference) CancellablePreference(com.android.settings.CancellablePreference) ArrayList(java.util.ArrayList)

Example 24 with Preference

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();
    }
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) DiskInfo(android.os.storage.DiskInfo) VolumeInfo(android.os.storage.VolumeInfo) Intent(android.content.Intent) BytesResult(android.text.format.Formatter.BytesResult) VolumeRecord(android.os.storage.VolumeRecord) Preference(android.support.v7.preference.Preference) File(java.io.File)

Example 25 with Preference

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);
    }
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Preference(android.support.v7.preference.Preference) UsageStatsManager(android.app.usage.UsageStatsManager) PreferenceGroup(android.support.v7.preference.PreferenceGroup) Intent(android.content.Intent)

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