Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c8791a8 authored by Daniel Nishi's avatar Daniel Nishi Committed by Android (Google) Code Review
Browse files

Merge "Add text to the Manage Settings page to show freed storage." into nyc-mr1-dev

parents 0a7300b8 1b9afaff
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7686,4 +7686,7 @@
    <string name="oem_unlock_enable_disabled_summary_connectivity">Connect to the Internet first</string>
    <!-- setting enable OEM unlock Checkbox's summary to explain this Checkbox is disabled because this setting is unavailable on sim-locked devices. [CHAR_LIMIT=60] -->
    <string name="oem_unlock_enable_disabled_summary_sim_locked_device">Unavailable on carrier-locked devices</string>
    <string name="automatic_storage_manager_freed_bytes"><xliff:g id="size" example="3.25MB">%1$s</xliff:g> total made available\n\nLast ran on <xliff:g id="date" example="Jan 12">%2$s</xliff:g></string>
</resources>
+10 −1
Original line number Diff line number Diff line
@@ -27,12 +27,21 @@
            android:title="@string/automatic_storage_manager_preference_title"
            android:summary="@string/automatic_storage_manager_text"/>


        <com.android.settings.fuelgauge.WallOfTextPreference
            android:key="freed_bytes"
            android:persistent="false"
            android:selectable="false"
            settings:allowDividerAbove="false"
            settings:allowDividerBelow="true" />

        <DropDownPreference
            android:key="days"
            android:summary="%s"
            android:title="@string/automatic_storage_manager_days_title"
            android:entries="@array/automatic_storage_management_days"
            android:entryValues="@array/automatic_storage_management_days_values"/>
            android:entryValues="@array/automatic_storage_management_days_values"
            settings:allowDividerAbove="true" />

    </PreferenceCategory>

+25 −1
Original line number Diff line number Diff line
@@ -17,12 +17,15 @@
package com.android.settings.deletionhelper;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.text.format.DateUtils;
import android.text.format.Formatter;
import android.util.Log;
import android.view.View;
import android.widget.Switch;
@@ -49,9 +52,11 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment

    private static final String KEY_DAYS = "days";
    private static final String KEY_DELETION_HELPER = "deletion_helper";
    private static final String KEY_FREED = "freed_bytes";
    private static final String KEY_STORAGE_MANAGER_SWITCH = "storage_manager_active";

    private DropDownPreference mDaysToRetain;
    private Preference mFreedBytes;
    private Preference mDeletionHelper;
    private SwitchPreference mStorageManagerSwitch;

@@ -67,18 +72,37 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
        mDaysToRetain = (DropDownPreference) findPreference(KEY_DAYS);
        mDaysToRetain.setOnPreferenceChangeListener(this);

        mFreedBytes = findPreference(KEY_FREED);

        mDeletionHelper = findPreference(KEY_DELETION_HELPER);
        mDeletionHelper.setOnPreferenceClickListener(this);

        mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH);
        mStorageManagerSwitch.setOnPreferenceChangeListener(this);

        int value = Settings.Secure.getInt(getContentResolver(),
        ContentResolver cr = getContentResolver();
        int value = Settings.Secure.getInt(cr,
                Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
                Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT);
        String[] stringValues =
                getResources().getStringArray(R.array.automatic_storage_management_days_values);
        mDaysToRetain.setValue(stringValues[daysValueToIndex(value, stringValues)]);

        long freedBytes = Settings.Secure.getLong(cr,
                Settings.Secure.AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED,
                0);
        long lastRunMillis = Settings.Secure.getLong(cr,
                Settings.Secure.AUTOMATIC_STORAGE_MANAGER_LAST_RUN,
                0);
        if (freedBytes == 0 || lastRunMillis == 0) {
            mFreedBytes.setVisible(false);
        } else {
            Activity activity = getActivity();
            mFreedBytes.setSummary(activity.getString(
                    R.string.automatic_storage_manager_freed_bytes,
                    Formatter.formatFileSize(activity, freedBytes),
                    DateUtils.formatDateTime(activity, lastRunMillis, DateUtils.FORMAT_SHOW_DATE)));
        }
    }

    @Override