Add text to the Manage Settings page to show freed storage.

Bug: 29643106
Change-Id: Id05dc70e36a690e27cab67fecf921257ed7baf15
This commit is contained in:
Daniel Nishi
2016-06-24 15:53:14 -07:00
parent 148a56f156
commit 1b9afaff2b
3 changed files with 38 additions and 2 deletions

View File

@@ -7681,4 +7681,7 @@
<string name="oem_unlock_enable_disabled_summary_connectivity">Connect to the Internet first</string> <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] --> <!-- 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="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> </resources>

View File

@@ -27,12 +27,21 @@
android:title="@string/automatic_storage_manager_preference_title" android:title="@string/automatic_storage_manager_preference_title"
android:summary="@string/automatic_storage_manager_text"/> 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 <DropDownPreference
android:key="days" android:key="days"
android:summary="%s" android:summary="%s"
android:title="@string/automatic_storage_manager_days_title" android:title="@string/automatic_storage_manager_days_title"
android:entries="@array/automatic_storage_management_days" 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> </PreferenceCategory>

View File

@@ -17,12 +17,15 @@
package com.android.settings.deletionhelper; package com.android.settings.deletionhelper;
import android.app.Activity; import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.os.storage.StorageManager; import android.os.storage.StorageManager;
import android.provider.Settings; import android.provider.Settings;
import android.text.format.DateUtils;
import android.text.format.Formatter;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Switch; 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_DAYS = "days";
private static final String KEY_DELETION_HELPER = "deletion_helper"; 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 static final String KEY_STORAGE_MANAGER_SWITCH = "storage_manager_active";
private DropDownPreference mDaysToRetain; private DropDownPreference mDaysToRetain;
private Preference mFreedBytes;
private Preference mDeletionHelper; private Preference mDeletionHelper;
private SwitchPreference mStorageManagerSwitch; private SwitchPreference mStorageManagerSwitch;
@@ -67,18 +72,37 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
mDaysToRetain = (DropDownPreference) findPreference(KEY_DAYS); mDaysToRetain = (DropDownPreference) findPreference(KEY_DAYS);
mDaysToRetain.setOnPreferenceChangeListener(this); mDaysToRetain.setOnPreferenceChangeListener(this);
mFreedBytes = findPreference(KEY_FREED);
mDeletionHelper = findPreference(KEY_DELETION_HELPER); mDeletionHelper = findPreference(KEY_DELETION_HELPER);
mDeletionHelper.setOnPreferenceClickListener(this); mDeletionHelper.setOnPreferenceClickListener(this);
mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH); mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH);
mStorageManagerSwitch.setOnPreferenceChangeListener(this); 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,
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT); Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT);
String[] stringValues = String[] stringValues =
getResources().getStringArray(R.array.automatic_storage_management_days_values); getResources().getStringArray(R.array.automatic_storage_management_days_values);
mDaysToRetain.setValue(stringValues[daysValueToIndex(value, stringValues)]); 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 @Override